Download

Online

Gallery

Blog

  Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 12
Posts: 12   Pages: 2   [ 1 2 | Next Page ]
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 3410 times and has 11 replies Next Thread
nathanjshaffer
Newbie



United States
Joined: Dec 20, 2020
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Patch submission

I'm not sure where is the best place to submit a patch. I have been working on a modification that I think will be useful. This program would benefit greatly from a constraint solver. This would allow for things like locking walls to a certain length/angle or having dimensions that are attached to walls and grow with the wall.

To work towards this, I have made a pretty deep rewrite that does a couple things in this patch.

1. float arrays have been replaced by a Vector2D class. This allows for simpler code and puts a lot of the point math into a library. This will also be important for implementing a constraint solver as the algorithm should deal with points, not lines.

2. walls ends are connected to a wallpoint instead of directly to a wall. Moving a point, moves the connected walls. This allows more than 2 walls to be joined at a point.

3. I made the dimension help lines appear during dragging a wall. This helps with better placement based on wall length

This patch allowed me to learn how the code was laid out and to simplify a lot of things.. I don't see an file upload, so I will just add it as a post.
[Aug 1, 2022, 2:14:12 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9141
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

Thanks for trying to improve Sweet Home 3D. You may submit your patch in a Features request ticket.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Aug 1, 2022, 3:09:17 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
sjb007
Advanced Member




Joined: May 18, 2021
Post Count: 210
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

That sounds like some really interesting stuff, Nathan. I look forward to taking it for a spin. In the meantime, you told us the benefits... but, is anything lost with your patch? Any functions that will have to be reimplmented?
[Aug 1, 2022, 9:09:40 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
nathanjshaffer
Newbie



United States
Joined: Dec 20, 2020
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

Patch submitted - ticket #1090

No functionality lost as far as I am aware. I am still working on making the new version save/load and will need to be able to update older saved files to the new version. I also didn't completely replace all of the float arrays in the entire codebase. It was a lot of time going through it all, so i created a conversion function to shortcut as I need to simply get it to build and test. so some of the classes that are completely unrelated to walls still use float[]. At some point I will get around to doing everything. this was more of a proof of concept.

I am researching constraint solver algorithms. I found a university dissertation where someone had written a simple 2D solver in java. I contacted her to see if I could get the source code, but she no longer has it unfortunately. The paper is
here and has some sample Java classes as well as psuedo-code for the pan algorithm. It will take some doing to get it all figured out, but should make this project far more capable.
[Aug 2, 2022, 5:13:01 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9141
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

Thanks for posting this patch. I will have a look to it but I’m a little worried by the changes it may apply to the Sweet Home 3D API. If these changes are not compatible with the existing API (for example you changed the return type of methods which returned à float array), existing plug-ins and derived versions won’t work anymore.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
[Aug 3, 2022, 11:27:37 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
nathanjshaffer
Newbie



United States
Joined: Dec 20, 2020
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

That's a valid concern. Is the API what plugins use? Do API developers access these finctions directly, or does the API act as a layer? I wrote toFloatArray() / fromFloatArray functions in the Vector2D class that convert betweenn the two as there are same java built-in libraries that use float arrays, so that would help to transition any plugins that need to old return values. Anther option is to keep the old methods and mark them obsolete, then write new functions with a different name with the new return type. This would just require some new thinking about what the new method names would be since the old names were the best option.

for example
public Vector2D getArcCircleCenter(){...}


could be
public Vector2D getArcCircleCenterVector(){...}

/*
* @deprecated
*/
public float[] getArcCircleCenter(){
return Vector2D.toFloatArray(getArcCircleCenterVector());
}


this would allow any old plugins to keep working
[Aug 3, 2022, 10:44:01 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
nathanjshaffer
Newbie



United States
Joined: Dec 20, 2020
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

Also, I just posted a second patch with save/load completed for vectors. Still need to make it convert the old saved files.
[Aug 3, 2022, 10:56:00 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Daniels118
Advanced Member
Member's Avatar

Italy
Joined: Nov 17, 2021
Post Count: 398
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

@nathanjshaffer
Although it would be nice to have a class to represent a point instead of an array, I think making a change in the existing API is a bit bully towards the plugin developers.
You could consider to implement the new features as a plugin, and if you need the points as Vector2D instead of float arrays you can just convert them forth and back.
[Aug 4, 2022, 8:35:11 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
nathanjshaffer
Newbie



United States
Joined: Dec 20, 2020
Post Count: 6
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

I get that, but my thought is to actually make an underlying change to the 2d system. Basically to make the program behave more like a modern CAD system with a fully constraint based design. This is a step in that direction. It's not just changing float[] to vector2D for convenience, it is changing how walls are stored and joined. in the old system, each wall kept a reference to the wall connected to it. With the new system, each wall is connected to a point. Moving the point, moves the walls connected. This will open up a lot of possibilites, such as having multiple walls joined together, (already implemented) having walls join to a wall midpoint, or to a coincident, locking angles and wall lengths, keeping walls parallel or perpendicular, locking furniture and window spacing, etc. Adding a constraint solver as a plugin doesn't make much sense to me as that functionality, if included should really be a part of the base programming. Converting everything back and forth and constraint solving every time a wall is drawn or dragged would be computationally expensive. Further, as I mentioned, now that I am aware of the potential conflicts with plugin developers, I think it is perfectly possible to provide reverse compatibility with most of the functions through deprecated methods to ease the transition. Also Vector based classes will make plugin developers jobs much easier. As long as they have the choice and nothing is forced on them, it shouldn't be too burdensome.

The codebase is 15 years old, and while I am not advocating change for the sake of change, it might be naive to think a growing project won't have to rethink some major changes in the architecture over that time. My suggestion is to create a branch to develop a constraint based system and try to get it working to see if there is interest from the plugin developers. If there is then, we can work on a migration solution so their plugin's don't break. I have zero interest on shitting on plugin developers, so I am completely open to helping work out a solution that makes everyone happy
[Aug 4, 2022, 3:32:23 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Puybaret
Expert
Member's Avatar

France
Joined: Nov 7, 2005
Post Count: 9141
Status: Offline
Reply to this Post  Reply with Quote 
Re: Patch submission

I had a look to your patch. Here are my comments:
- Maybe you didn't notice, but the API of the model layer depends only on very basic Java classes, and not on classes of java.awt.geom package (their implementation may depend on such classes but it's another point). It was an intuition to program this way, but I think I was right when I had to port Sweet Home 3D to JavaScript where java.awt.geom package doesn't exist. Your new classes Vector2D and Line2D introduce a change in this way of programming because they inherit from classes of java.awt.geom package.
Inheriting of java.awt.geom.Point2D which has some public fields don't respect also the conventions of the program where all fields are encapsulated.
- Naming of Vector2D is questionnable since it's a point not a vector.
- You seem to have not applied standard conventions to your code (spaces, no if else for statements without braces, no if and its consequence on the same line...). If you want your code to end one day in Sweet Home 3D code base, you should use at minimum the Source > Format menu item in Eclipse (maybe current rules should be updated because they don't seem to add braces).
- You idea of using a separate WallPoint objects for wall points seems too restrictive: why not using the same idea for rooms which corners may be bound to wall points, dimension lines bound to walls and other items?
- Did you check whether undo / redo actions still work correctly (probably running JUnit tests will be enough for that)?
- Some javadoc comments were changed a little too fast in DimensionLine.java and maybe other places. It also seems that you copied some code from elsewhere without updating comments (like @since JavaFX 8.0 which probably comes from Point2D class in JavaFX).
- Breaking forward compatibility of SH3D files is a difficult decision to make. You may still open a 7.0 SH3D file with Sweet Home 3D 1.0, even if such a wide support isn't really interesting because all the missing features will be ignored by this old version.
Breaking this wide compatibility will happen sooner or later, because it doesn't worth keeping the Home serialized version entry and Home.xml entry in a SH3D file for ever. But I've prepared this change for a long time since SH3X is a file extension associated to Sweet Home 3D since version 5.3 when Home.xml entry was added.
- Breaking existing API is not an option for the moment. You may say that after 15 years, it's time to break things, but I fear that developers won't follow you, arguing that continuing these 15 years of compatibility is nice for them. By the way, it's not in Java spirit, and not in mine too.

for example
public Vector2D getArcCircleCenter(){...}


could be
public Vector2D getArcCircleCenterVector(){...}

/*
* @deprecated
*/
public float[] getArcCircleCenter(){
return Vector2D.toFloatArray(getArcCircleCenterVector());
}

Java doesn't allow overloading methods which have just a change in their return type. You'll have to use a different name for such methods.

Although it would be nice to have a class to represent a point instead of an array, I think making a change in the existing API is a bit bully towards the plugin developers.
The lack of a Point class instead of a float array comes mainly from the origin of Sweet Home 3D: as it was first the case study of a book I wrote about Swing, I didn't want to add too many classes and chose this kind of simplification. But the good thing is that I spent more time on the application architecture which helped it to live almost 17 years so far.

But let's finish on a positive point: the good thing of the GNU GPL is that it allows anyone to create derived versions and redistribute them, so feel free Nathan to continue your development and propose some improvements which will add some must-have features.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
----------------------------------------
[Edit 2 times, last edit by Puybaret at Aug 5, 2022, 3:33:02 PM]
[Aug 5, 2022, 11:14:17 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Posts: 12   Pages: 2   [ 1 2 | Next Page ]
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

    Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads
   
© Copyright 2006-2024 eTeks - All rights reserved