Reimplementing constraint solver

Discussion about the development of the Assembly workbench.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Reimplementing constraint solver

Post by DeepSOIC »

triplus wrote: Sun Apr 19, 2020 5:03 pm @DeepSOIC

Any chance of a todo list, table or info graphic tracking the progress? Like all this red things still need to get sorted out and all this green ones have already been done?
I don't have one, so let me write one up real quick...
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Reimplementing constraint solver

Post by DeepSOIC »

triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Reimplementing constraint solver

Post by triplus »

Looks good and i have to say nice progress already. Could you do me a favor and add one item under each:

Code: Select all

[*]3d geometry
[*]3d constraints
Whatever is considered "the easiest" to do. I suspect point and point-point distance could qualify? The math behind it doesn't look all that terrifying and in general most 3D geometric constraints solvers i have tried have the least amount of issues with it. Seeing something like that in writing would further solidify this effort as genuine. In addition it will be easier to redirect people here. @ickby might finally say heck i have that in my private branch already.

As for the front-end, beyond Sketcher. Are you particularity interested in tackling that or would rather see someone like @realthunder to chime in with Assembly 3 expertise? All that selection stuff, constrain representation in tree view as document objects and icons and ... possible edit modes ... I am mainly asking due to trying to figure out the appropriate upstream strategy. As if you are OK with that, then likely this will be made a requirement. That is potential directly Assembly upstreaming related functionality to be in-sync with this efforts scope for now.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Reimplementing constraint solver

Post by abdullah »

DeepSOIC wrote: Sat Apr 18, 2020 12:25 pm
abdullah wrote: Sat Apr 18, 2020 7:04 am You may remember the quick fix from unique_ptr to shared_ptr to make MSVC compile. I have changed this back to a unique_ptr, but revised the way and it should compile now.
Why not just use shared_ptr? I get a feeling that using unique_ptr in this case gives a lot of restraints, no benefits, quite a bit of extra code, … an I get a feeling you are only doing it to flex your c++ muscle :P
A unique_ptr does not need reference counting and does not need to create a control block.

Aside from those benefits, which may be marginal given that the structure is almost not used in comparison to the overall solve, there is no real software requirement reason why to use shared pointer in this situation. I really struggle to accept there is no way to "convince MSVC", basically because I already got away with it in GeometryExtensions...

There should be no extra code once MSVC swallows it...
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Reimplementing constraint solver

Post by abdullah »

DeepSOIC wrote: Mon Apr 20, 2020 11:02 am Second crash is fixed, and I can now make a triangle. Yay!
FCSSketch-triangle.png
Thanks man! I have been looking at the fixes and they should have come from me. There was actually nothing wrong with ConstraintSolver. Sorry for that.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Reimplementing constraint solver

Post by DeepSOIC »

abdullah wrote: Tue Apr 21, 2020 11:58 am Thanks man! I have been looking at the fixes and they should have come from me.
No problem!

abdullah wrote: Tue Apr 21, 2020 11:52 am there is no real software requirement reason why to use shared pointer in this situation. I really struggle to accept there is no way to "convince MSVC", basically because I already got away with it in GeometryExtensions...
You're right, and there probably is a way to convince it, but i think it is just not worth the fight. + the problem might come up again as the code is modified.
User avatar
czinehuba
Posts: 160
Joined: Mon Oct 15, 2018 4:59 am
Location: UK
Contact:

Re: Reimplementing constraint solver

Post by czinehuba »

triplus wrote: Mon Apr 20, 2020 2:41 pm Looks good and i have to say nice progress already. Could you do me a favor and add one item under each:

Code: Select all

[*]3d geometry
[*]3d constraints
Awsome work guys. Not a developper so don't know how easy or hard is to implement. But just a few things what other software do in terms of 3D sketch if this helps.
[*]3d geometry
- line
- helical curve(i know this exists in primitives already)
- arc (3points andn centre)
- bend
- point
- equation curve
- spline (control vertex and interpolation)

[*]3d geometry projections
- intersection curves
- silhouette curves
- project to surface
- curve on face
- include geometry

[*]3d constraints
- dimensions z,y,z
- coincident
- colinear
- on face
- lock
- equal
- parallele
- perpendicular
- parallele x.y.z and xy,yz,zx
- tangent
- smooth (g2)
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Reimplementing constraint solver

Post by triplus »

Hi @czinehuba

That is a nice list BUT in my opinion it is not yet the time for that. One would more than do for now. More can be added after, like over the next decade.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: Reimplementing constraint solver

Post by abdullah »

DeepSOIC wrote: Tue Apr 21, 2020 2:56 pm You're right, and there probably is a way to convince it, but i think it is just not worth the fight. + the problem might come up again as the code is modified.
I have the very bad habit of fighting lost causes.

The underlying idea of a unique_pointer vs shared_pointer is exclusive vs shared ownership.

In the case of GeoDef, there is a clear exclusive ownership. It is a FCSSketch-only structure that serves the purpose of keeping track of the relation between Sketcher and Solver. Neither the Sketcher, nor the Solver want it, it is worthless for them.

Looking at the error, I think I might be forced to explicitly write a move constructor/operator for GeoDef, but I need time to look at it.

I would also like to refactor the geometry and constraint creation before I extend the concept to other geometries and constraints.

This week is an awful one though, I do not think I will have time to code before the weekend. :(
User avatar
czinehuba
Posts: 160
Joined: Mon Oct 15, 2018 4:59 am
Location: UK
Contact:

Re: Reimplementing constraint solver

Post by czinehuba »

triplus wrote: Wed Apr 22, 2020 10:25 am Hi @czinehuba

That is a nice list BUT in my opinion it is not yet the time for that. One would more than do for now. More can be added after, like over the next decade.
Agree, just wanted to help out to show what other system do and work. Developpers then can choose one or two which is the easiest to implement.
Post Reply