Sketcher Ellipse: porting tangent-line to DeriVector2
Replacing a ton of unreadable, sage generated math code with
easy-to-manage C++ code.
Sketcher Ellipse: porting internal align-t to DeriVector2
Sketcher Ellipse: small math refactor; const members
Moving the repeating code computing deriv+value of major radius to a
method of GCS::Ellipse.
Marking several methods of DeriVector2 as const member functions.
Sketcher Ellipse: porting arc angle rules to DeriVector2
Just porting.
Probably a complete remake of the concept is worth... Angles can be
calculated explicitly, there's no need to load the solver. I see no
benefits whatsoever on using the solver to keep track of angle values.
Sketcher Ellipse: porting equality to DeriVector2
Fix AngleViaPoint to support new derivative calculation technique.
OpticConstraints: Adding Snell's law. Fix AngleViaPoint to support new derivative calculation technique.
Snell's law constraint added to GCS, but not yet exposed and cannot be
tested.
Since the way CalculateNormal() returns derivatives had changed,
AngleViaPoint constraint needed modifications. Nothing serious.
OpticConstraints: SnellsLaw progress
Addable through python. Fix math. Some quick-and-dirty visual stuff to
get rid of hangs and to see the constraint in action.
OpticConstraints: SnellsLaw: flipping logic fix
OpticConstraints: SnellsLaw progress
Added toolbar button. Allowed editing a datum by doubleclick. New error
message approach during constraint creation.
OpticConstraints: SnellsLaw
OpticConstraints: SnellsLaw: list label improvement
OpticConstraints: SnellsLaw: fix after rebase
OpticConstraints: SnellsLaw: expose helper constraints
Snell's law internally is made of three constraints: point-on-object,
coincident and the Snell's sin/sin. They were all buried under one UI
constraint. Exposing them allows to construct reflection and
birefringence on the point (attempting to do so used to result in
redundant constraints and was often not functional at all).
This commit breaks compatibility with older files.
OpticConstraints: SnellsLaw: small refactor of math
Placing the duplicated code of error and gradient calculation into a
private method.
OpticConstraints: SnellsLaw: fix datum edit unit
OpticConstraints: SnellsLaw: fix datum edit bug
After previous fix, the dimensionless value was not accepted (the
constraint's value did not change, the changes were ignored).
GCS::Vector2D was morphed into a DeriVector2, a derivative-aware vector.
A bunch of vector math methods were added that implicitly calculate
respective derivatives. Now, there is no need to calculate the partials
- most is done implicitly.
AngleViaPoint: fixes in UI routines + new messages
Goofed undo message in tangency via point is fixed.
Forgotten updateActive, clearSelection have been added.
New more informative error messages for tangent constraint.
AngleViaPoint: using it instead of via line tangency
* replaced the helper construction line for ellipse-to-ellipse and
similar tangency with a point. Using tangent-via-point there
* deleted tangency via line for point-to-point on
(cherry picked from commit 9e3fa8c8de0f49c0ef3c978e015eb905358dbdd9)
AngleViaPoint: internal/external tangency locking
*Added automatic tangency type lockdown for all new constraints (only
for point-wise tangency).
Tangency type is stored in the constraint datum field, as an angle value
shifted by Pi/2 (to be able to treat 0.0 as undefined type).
Added ability to switch the tangency by setting datum value from python
(can be abused by passing arbitrary angle).
Further simplified the tangency related code in Sketch.cpp.
AngleViaPoint: added license to Geo.cpp
AngleViaPoint: renames in Constraints.cpp/.h
Changed some names to increase self-explanatoryness:
bool "remapped" renamed to "pvecChangedFlag"
"ReconstructEverything()" renamed to "ReconstructGeomPointers()"
AngleViaPoint: renames in Constraints.cpp/.h
Changed some names to increase self-explanatoryness:
bool "remapped" renamed to "pvecChangedFlag"
"ReconstructEverything()" renamed to "ReconstructGeomPointers()"
AngleViaPoint: using for endpoint perpendicularity
+ direction lockdown, just as with tangency.
+ quite a lot of old code is gone because of that
AngleViaPoint: perp-ty UI routine made similar to tangent
(Git has made a very messy diff.)
The changes are:
* Perpendicularity-via-point (3-element selection) support added.
* Endpoint-to-curve and endpoint-to-endpoint supports all shape
combinations.
* a bit of code cleanup and clarifications.
AngleViaPoint: placement of perpendicular icon in 3d view
AngleViaPoint: fix: allow setDatum of perpendicular constraint
AngleViaPoint: fix: centers of ellipses are not endpoints
isSimpleVertex used to return false for centers of ellipses and arcs of
ellipses, which made them being accepted for point-to-point tangency.
Should be fixed forever, mo more changes are expected to be necessary
for new types of geometry.
AngleViaPoint: precalc with OCC (work in progress)
Work in progress (not yet working).
Using OCC's tangent to replace implementation of
SketchObject::calculateAngleViaPoint.
AngleViaPoint: fix math: normal now points inwards, where it was intended initially and goofed up.
AngleViaPoint: adding comments to the code
AngleViaPoint: using GeomCurve::closestParameterToBasicCurve for angle precalculation
AngleViaPoint: Py method: changeConstraintsLocking
changeConstraintsLocking(True) - locks/re-locks all lockable
tangency/perpendicularity constraints of the sketch (applicable to
existing sketches).
changeConstraintsLocking(False) - removes locking information from
lockable constraints
AngleViaPoint: final SketchObject::calculateAngleViaPoint
Now, finally, using OCC functionality (thanks Abdullah!), without
composing temporary Sketch object.
Solver iteration limit independent of system size (reduces hangs when
solver fails to converge).
Repaint() instead of update() to force render for every movePoint.
Sketcher: New Constraint AngleViaPoint
* Adding generic CalculateNormal() method
* Reconfiguration of GCS geometry classes: adding a base class "Curve",
that has a pure virtual function CalculateNormal().
* Initial inplementation of the new function.
* adding Vector2D class (I wanted to reuse the existing, but got wierd
compile errors, so implemented a new one... TODO.)
* Adding redirection support into GCS shapes. Adding a Copy method to
GCS::Curve.
* Automatic point-on-object
* Angle precalculation: when AngleViaPoint is added, angle is properly calculated based on
existing geometry.
* Added tangency-via-point using one.
* Implemented placement of tangency-via-point icon in 3d view. Also
affected is the placement of point-on-object icon (since it is very
similar code, it is now shared with tangency-via-point)
* Placement and moving of angle datum
Functions: calculateAngleViaPoint, isPointOnCurve,
calculateConstraintError exposed to python
* Endpoint tangency: All endpoint-to-endpoint and endpoint-to-curve tangency now works
through AngleViaPoint constraint and obsolete code clean up (most procedures
addConstraintTangentXXX2YYY)
Part: Extension of Geometry::Curve to wrap more functions of OCC
Apart from:
bool tangent(double u, gp_Dir&) const;
that was already implemented, now it also implements:
Base::Vector3d pointAtParameter(double u) const;
Base::Vector3d firstDerivativeAtParameter(double u) const;
Base::Vector3d secondDerivativeAtParameter(double u) const;
bool normal(double u, gp_Dir& dir) const;
bool closestParameter(Base::Vector3d point, double &u);
i.e. apart from giving the tangent vector for a given curve at parameter value u,
it also gives:
- The point cartesian coordinates of the curve point at parameter value u
- The vector of the first derivative at parameter value u
- The vector of the second derivative at parameter value u
- The normal vector to the curve at parameter value u
- The parameter value of a curve closest ot a given point
Code cleanup: Changing Trim functionality of Ellipse to use OCC calculations
Part Curve functions extension: closestParameterToBasicCurve
It provides the parameter of the curve closest to a given point. If the curve is a Trimmed curve, the parameter of the basic underlaying curve closest to the point is provided.