Commit Graph

418 Commits

Author SHA1 Message Date
mosfet80
0b3bb1d365 Update SketchObject.cpp
Initialize variable
2022-03-01 17:42:23 +01:00
Ajinkya Dahale
3d452d9396 [Sketcher] Add comment suggesting future segfault fixes
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.
2022-02-15 13:44:02 +01:00
Abdullah Tahiri
d885bb7ef7 Sketcher: Remove unnecesary geometry touch 2022-01-09 11:40:49 +01:00
Ajinkya Dahale
07cad4ab64 [Sketcher] Add insertBSplineKnot to SketcherObject
[Sketcher] Workaround for segfault on knot insertion
2022-01-09 11:33:53 +01:00
Abdullah Tahiri
22c31aeac6 Sketcher: Adapt Typed Facade to new behaviour of automatic taking ownership of emplaced pointer 2021-12-27 21:03:51 +01:00
Abdullah Tahiri
053cc36541 EditCoinManager: Additional refactoring 2021-12-27 21:03:51 +01:00
Ajinkya Dahale
f801acfe8c [Sketcher] Constrain new B-spline pole weight only if equal to first
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.
2021-12-25 08:42:18 +01:00
Abdullah Tahiri
44567167ff Sketcher: Convert PointPos into an enum CLASS 2021-12-11 16:17:21 +01:00
Abdullah Tahiri
182596ba08 Sketcher: GeoId, GeoElementId and GeoUndef refactor
===================================================

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.
2021-12-11 16:17:21 +01:00
Abdullah Tahiri
0331b8a0ab Sketcher: SketchObject - method to getCompleteGeometry as GeometryFacade
========================================================================

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.
2021-12-07 16:30:53 +01:00
Abdullah Tahiri
9a6e12b73d Sketcher: Move GeoEnum struct to separate file
==============================================

Separate struct into own file to avoid having to include all the dependencies of SketchObject in other code that relies on GeoEnum.
2021-12-07 16:30:53 +01:00
0penBrain
0d52ef4c13 [Sketcher] Floating point computation immunity for carbon copy parallel/aligned checks 2021-11-27 08:58:25 +01:00
luz paz
56aeb07202 Sketcher: fix typos in Constraint Widget
- Follow-up to 5b745514e0f

- Sketcher: fix relevant typos

- Re-Add mistakenly deleted files

- fix build
2021-10-23 18:37:33 +02:00
Abdullah Tahiri
7872d0b3bc Sketcher: Overload setVirtualSpace to allow setting a group of constraints 2021-09-28 20:06:52 +02:00
Chris Hennes
9afc4503ab [Sketcher] Refactor split code
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.
2021-09-17 23:43:12 +02:00
Abdullah Tahiri
11410fa53e Sketcher: Remove Axes Alignment algorithm 2021-06-20 06:16:11 +02:00
Abdullah Tahiri
841c328eb3 Sketcher: Changes to split edge functionality
=============================================

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
2021-04-24 14:38:44 +02:00
Tomas Pavlicek
a7d83b5e15 Sketcher - Add new Split Edge action 2021-04-24 14:30:35 +02:00
Abdullah Tahiri
a6cae70e94 Sketcher: Adapt fillet to moving addConstraint 2021-04-07 08:05:04 +02:00
Abdullah Tahiri
30ce0310b8 Sketcher: SketchObject - Trim refactor
======================================

* 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.
2021-03-21 06:56:23 +01:00
Benjamin Nauck
7422a64c84 [Sketcher] Use std::shared_ptr instead of boost::shared_ptr
There's no need to use boost version when stl has support for shared_ptr
2021-03-06 19:32:03 +01:00
wmayer
8163e562f3 Sketcher: [skip ci] fix bad static_cast 2021-02-20 22:46:51 +01:00
Abdullah Tahiri
c8f9197bf0 Sketcher: Fix external geometry ellipse projection in parallel plane
====================================================================

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
2021-02-13 15:18:34 +01:00
Benjamin Nauck
92a479bf01 Sketcher: Fix uninitialized scalar field in ctor
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.
2021-02-11 11:48:19 +01:00
Abdullah Tahiri
2be7f8cbcb Sketcher: fix malformed constraint on nurbs conversion
======================================================

Coincident on midpoint cannot be supported by a bspline.

Fixes:
https://forum.freecadweb.org/viewtopic.php?p=476410#p476410
2021-02-10 06:41:16 +01:00
Abdullah Tahiri
4c55d91093 Sketcher: Fix geometry state synchronisation routine 2021-02-09 20:22:30 +01:00
Abdullah Tahiri
26c060f64f Sketcher: Geometry state synchronisation
========================================

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.
2021-02-09 08:14:36 +01:00
j
7413a8a717 Sketcher: Preserve corner and constraints for sketch fillets
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.
2021-02-04 08:10:28 +01:00
Abdullah Tahiri
5a5ed565a8 Sketcher: SketchObject partially redundant status 2021-01-23 07:53:28 +01:00
Abdullah Tahiri
e9c22f93fd Sketcher: Migrate old construction points as construction
=========================================================

Fix that construction points, which did not have the construction flag before, as construction flag was
reserved for internal alignment points, are migrated as construction points.

Fixes:
https://forum.freecadweb.org/viewtopic.php?f=8&t=53466&start=40#p467176
https://forum.freecadweb.org/viewtopic.php?p=467160#p467160
2021-01-14 19:22:15 +01:00
Benjamin Nauck
6c6790e8b5 [Sketcher] Fix crash in SketcherObject::setDatum
The variable newVals can't be used after std::move, fetch it from the
constraint it if an error occurs.
2021-01-09 07:50:31 +01:00
Abdullah Tahiri
81735a92e8 Sketcher: std::move improvement fixes 2021-01-07 12:03:26 +01:00
Zheng, Lei
dc57a3df59 Part/Sketcher: improve list property update efficiency 2021-01-07 10:27:21 +01:00
Abdullah Tahiri
37836ed666 Sketcher: deleteGeometries split
================================

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.
2021-01-06 13:54:00 +01:00
Abdullah Tahiri
64df620407 Sketcher: Retrieve 1-based list of malformed constraints from solver 2021-01-06 13:54:00 +01:00
Abdullah Tahiri
c2dd10b41a Sketcher: Treat malformed solver constraints as an error during recompute
=========================================================================

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.
2021-01-06 13:54:00 +01:00
Abdullah Tahiri
e05bb7ac73 Sketcher: Add FullyConstrained read-only output property
========================================================

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.
2021-01-06 13:54:00 +01:00
luz paz
f497f09238 Fix typos [skip ci]
Typos ffound via `codespell v2.1.dev0`  
Also includes fixes in deprecated code of `src/Mod/Assembly`
2020-12-28 23:14:04 +01:00
Abdullah Tahiri
56f3db079f Sketcher: Fix crash on constraint rename
========================================

Report:
https://github.com/FreeCAD/FreeCAD/pull/4183
https://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.
2020-12-27 08:24:43 +01:00
Abdullah Tahiri
5c8e65728f Sketcher: Trigger elements widget update on toggle/set construction geometry 2020-12-27 08:24:43 +01:00
Abdullah Tahiri
b6729a41d7 Sketcher: encapsulate Sketch::SolveTime and RecalculateInitialSolutionWhileMovingPoint members 2020-12-27 08:24:43 +01:00
luz paz
7028017e8d Sketcher: typo in function name 2020-12-27 06:08:01 +01:00
luz paz
439bf8960d Fix typos [skip ci]
Found via `codespell v2.1.dev0`
2020-12-23 14:32:38 -05:00
David Osterberg
69cd283663 Apply style suggestions from @abdullahtahiriyo 2020-12-23 06:23:17 +01:00
David Osterberg
e1328a5876 Sketcher: Fix issue #4513 - SketchObject::addSymmetric
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
2020-12-23 06:23:17 +01:00
Abdullah Tahiri
e9e6be66c3 Sketcher: Support for defining point 2020-12-22 07:10:48 +01:00
David Osterberg
fe4c00e920 Sketcher: Fix several issues in SketchObject::trim
Issues addressed:
- exception when trimming a loose end of a Arc of circle
- conflicting constraints when trimming
- loss of tangency when trimming arcs tangent to lines or other curves
- incorrect trimming when the intersecing geometry has a PointOnObject constraint to the arc, but also another intersection og geometry.

Fixes:
https://tracker.freecadweb.org/view.php?id=4066
https://tracker.freecadweb.org/view.php?id=3910

Also see forum discussion
https://forum.freecadweb.org/viewtopic.php?f=10&t=53299
2020-12-21 20:03:02 +01:00
David Osterberg
854191eb02 Improve comment and remove uncessary return statement 2020-12-21 08:37:37 +01:00
David Österberg
ca1ebf2321 Update src/Mod/Sketcher/App/SketchObject.cpp
Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2020-12-21 08:37:37 +01:00
David Osterberg
06c31d2478 Delete Equal constraints on LineSegments in SketchObject::trim
This closes:
https://tracker.freecadweb.org/view.php?id=4510
2020-12-21 08:37:37 +01:00