I pushed a fix for this.
Reimplementing constraint solver
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Reimplementing constraint solver
Now to the gil. This is rather painful, as any use of Py::Object (creation, reassignment, destruction) must happen with GIL engaged, because I assume that changing reference count is a Py API call, and
I think rather than locking the gil in just about every routine of ConstraintSolver, I'd instead place an assert in PyHandle, that will force us to engage gil in event handlers.Non-Python created threads
When threads are created using the dedicated Python APIs (such as the threading module), a thread state is automatically associated to them and the code showed above is therefore correct. However, when threads are created from C (for example by a third-party library with its own thread management), they don’t hold the GIL, nor is there a thread state structure for them.
If you need to call Python code from these threads (often this will be part of a callback API provided by the aforementioned third-party library), you must first register these threads with the interpreter by creating a thread state data structure, then acquiring the GIL, and finally storing their thread state pointer, before you can start using the Python/C API. When you are done, you should reset the thread state pointer, release the GIL, and finally free the thread state data structure.
Re: Reimplementing constraint solver
Nothing fancy, just to keep you going comfortably:
Code: Select all
Sketcher: Default to GCS and SwitchSolver command
===================================================
This is intended as a temporary facility to switch during runtime solver between GCS and FCS.
How?
ActiveSketch.switchSolver()
It informs in the Console of the activated solver.
Re: Reimplementing constraint solver
Any recommended way to clear (empty) the parameterStore?DeepSOIC wrote:...
Re: Reimplementing constraint solver
New question related to ParaPoint and ParaShape<ParaPoint>.DeepSOIC wrote:...
I see that a parashape is something like applying a transformation (placement) to a parageometry (correct me if I am wrong).
I am implementing the interface with the coincident constraint, and I have a pair of hparapoints which I would like to feed to the constraint constructor, which takes h(parashape<parapoint>) aka HShape_Points, like this:
Code: Select all
FCS::G2D::HParaPoint &p1 = Points[pointId1];
FCS::G2D::HParaPoint &p2 = Points[pointId2];
c.fcsConstr = new FCS::G2D::ConstraintPointCoincident(p1,p2);
- DeepSOIC
- Veteran
- Posts: 7896
- Joined: Fri Aug 29, 2014 12:45 am
- Location: used to be Saint-Petersburg, Russia
Re: Reimplementing constraint solver
It is done like that:
This is somewhat inconvenient, you are welcome to improve on it. One way to improve is to add a toShape() method to all geometries.
EDIT: it may also be a good idea to create a unity transform as a singleton, so as to not have to create it insane number of times.
Code: Select all
FCS::G2D::HShape_Point sh = new FCS::G2D::ParaShape<FCS::G2D::ParaPoint>(new FCS::G2D::ParaTransform(), hp);
EDIT: it may also be a good idea to create a unity transform as a singleton, so as to not have to create it insane number of times.