Apparently B-Spline knot insertion is challenging the sketcher update process
and spurious GUI updates sometimes occur in the intermediate step after the
knot is inserted but before the internal geometries are re-defined. This set of
comments points to a previous fix and related discussion as a suggestion.
When new control points are created in a b-spline in a sketch, do not constrain
their weights to be equal to the first, unless they are already equal. This way
if we have unequal weights to begin with and OCC has computed the appropriate
weights so that the new spline is closer to the original, the weights are not
disturbed.
===================================================
This commit is an independent refactor of the identifications used at Sketcher level.
It introduces a new type "GeoElementId" as a combination of GeoId and PointPos.
It moves the Undefined GeoId, previous Constraint::GeoUndef to GeoEnum, together with all
other fixed values of GeoIds.
========================================================================
As GeometryFacade is provided with more sketcher specific functionality, the demand
for to get GeometryFacades instead of Part::Geometry object increases too. This
addition reflects this increase of demand.
==============================================
Separate struct into own file to avoid having to include all the dependencies of SketchObject in other code that relies on GeoEnum.
LGTM complains about using continue statements inside a loop
whose condition is always false. In addition, the C++ core guidelines
recommend against using the do...while construct, and in this case it
was really serving as a goto, just hiding the actual goto keyword.
This commit replaces the loop and continue structure with simple
conditionals.
=============================================
This commit is directed to external functionality of the split() function.
1. getAppliedConstraints renamed to getConstraintIndices
This is just for clarity being a general function
2. SwapInvolvedGeometry functionality moved to Constraint class
Why?
i. Because it is a specific operation on a constraint, it must not be
a public function, as it does not define interface of the Sketch.
ii. It could be a lambda or a private utility function, but them it would not be reusable.
iii. It could be part of a helper class, but then, it is would be less reusable.
3. renaming of the flag passed to transferConstraints function
======================================
* Refactor the code for all GeomTrimmedCurve and non-periodic BSplines in a single block, adding
support for arcs of hyperbola, parabola and B-Splines.
* Refactor the code for periodic curves (circle, ellipse) in a single block, adding support for
periodic B-Splines.
* Add support for trimming limited by external geometry
* Trim deletes a geometry if intersections are detected and nothing would be left after trimming
* Trim deletes a geometry if no intersection are detected
Bonus:
* Function addConstraint moving the constraint instead of cloning it again
* SketchObject::seekTrimPoints as a wrapper of Part2DObject::seekTrimPoints providing
a correct handling of GeoId indices.
* Helper functions addConstraint/createconstraint to create new constraints and move them
into the Constraint property
* New getGeometry with templated return type defaulting to Part::Geometry.
====================================================================
When the ellipse to be projected and the sketch plane are parallel, the original code
by shermelin provided for a translation of the original ellipse, which would be the best solution
if it weren't because the Sketcher, internally, works under the assumption of a normal vector to the
sketcher plane being (0,0,1). If the original ellipse is parallel to the sketch plane, but the sketch
plane is not the XY plane, the copy and translation would result in a ellipse not in the XY plane of the
Sketcher. Then the sketcher internals will not properly consider its dimensions.
The solution applied here is to default to the general method for non-parallel planes.
It solves:
https://forum.freecadweb.org/viewtopic.php?f=3&t=55284#p477522
Fixes Coverity issue:
CID 316539 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
uninit_member: Non-static class member lastHasPartialRedundancies is not initialized in this constructor nor in any functions that it calls.
========================================
The geometry state stored in the geometryFacade is modified following a mutable model
(without setting the Geometry property on Constraint change), in order to avoid coupling
the addition/removal of a constraint with a change of the Geometry Property.
This design decision however interferes with the ability of the Geometry property to restore
the correct geometry state upon redo/undo.
While such a situation is rare in the case of Internal Alignment geometry, because constraint
addition/removal is performed with the corresponding geometry addition/removal (within the same
transaction. That is not the case with the Block constraint (or another future general case where
the geometry state may be applied).
This commit leverages the synchronisation mechanism already in use for non-properties (e.g. external geometry or
vertex indices) to check and synchronise geometry state upon undo/redo and restore.
Bonus:
- addGeometryState is refactored to separate the checking logic from the setting logic.
Currently the sketch fillet tool deletes any constraints associated with
the two lines to be filleted. By leaving a vertex at the intersection,
we can instead preserve most constraints in reasonable ways.
Sketch fillet horizontal and vertical point-to-point constraint support
Also better future compatibility for point constraints, and some minor tweaks.
================================
New deleteGeometries function, according to the comment should the same
as deleteGeometry but at a time. However, this is not accurate, as deleteGeometry
deletes any internal geometry associated to the provided GeoIds, whereas
deleteGeometries does not delete that internal geometry.
Solution:
Split deleteGeometries into two different functions:
1) delGeometriesExclusiveList
2) delGeometry
The former will not delete associated internal geometry. It is more efficient, but
it is the resposibility of the caller not to leave internal geometry undeleted.
The latter, implemented in terms of the former, will delete associated internal
geometry too.
As a bonus, the latter will also remove any GeoId duplicates.
=========================================================================
Sometimes it happens that malformed constraints are arrived to.
Example:
https://forum.freecadweb.org/viewtopic.php?f=3&t=53780#p463271
It is not the first time. They usually go under the radar and when they are
detected is too late to know what caused them. The user is desperate too.
This commit makes malformed constraints to prevent the recompute of the project.
This is in the best interest of the user.
========================================================
This property stores whether a Sketch has 0 DoF or not upon solve.
It is serialised to disk, enabling a recently loaded project to have an accurate
populated property even before the first solve() call.
========================================
Report:
https://github.com/FreeCAD/FreeCAD/pull/4183https://github.com/realthunder/FreeCAD_assembly3/issues/387
Problem:
renameConstraint() previously implemented exclusively in SketchObjectPyImp.cpp,
will change the Constraints property without updating the solver. A prospective
drag operation would rely on a deleted pointer constraint which leads to the
crash.
Solution:
- mark the solver status as needing an update
- leverage new through sketchobject r/w interface to ensure solver is synchronised
before the temporary move operation starts
Bonus:
move the core of the function to SketchObject.cpp so that input data validity
check on constraint change is inhibited.
This fixes issue
https://tracker.freecadweb.org/view.php?id=4513
addSymmetric will now only transfer Vertical and Horizontal constraints if the reference axis is either
- the HAxis
- the VAxis
- a Vertical line
- a Horizontal line