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.
This commit is contained in:
j
2021-02-03 15:11:02 +01:00
committed by Abdullah Tahiri
parent fde9048778
commit 7413a8a717
2 changed files with 262 additions and 46 deletions

View File

@@ -64,6 +64,14 @@ public:
~SketchObject();
/// Property
/**
The Geometry list contains the non-external Part::Geometry objects in the sketch. The list
may be accessed directly, or indirectly via getInternalGeometry().
Many of the methods in this class take geoId and posId parameters. A GeoId is a unique identifier for
geometry in the Sketch. geoId >= 0 means an index in the Geometry list. geoId < 0 refers to sketch
axes and external geometry. posId is a PointPos enum, documented in Constraint.h.
*/
Part ::PropertyGeometryList Geometry;
Sketcher::PropertyConstraintList Constraints;
App ::PropertyLinkSubList ExternalGeometry;
@@ -97,9 +105,19 @@ public:
\retval bool - true if the geometry is supported
*/
bool isSupportedGeometry(const Part::Geometry *geo) const;
/// add unspecified geometry
/*!
\brief Add geometry to a sketch
\param geo - geometry to add
\param construction - true for construction lines
\retval int - GeoId of added element
*/
int addGeometry(const Part::Geometry *geo, bool construction=false);
/// add unspecified geometry
/*!
\brief Add multiple geometry elements to a sketch
\param geoList - geometry to add
\param construction - true for construction lines
\retval int - GeoId of last added element
*/
int addGeometry(const std::vector<Part::Geometry *> &geoList, bool construction=false);
/*!
\brief Deletes indicated geometry (by geoid).
@@ -218,11 +236,28 @@ public:
int toggleConstruction(int GeoId);
int setConstruction(int GeoId, bool on);
/// create a fillet
int fillet(int geoId, PointPos pos, double radius, bool trim=true);
/*!
\brief Create a sketch fillet from the point at the intersection of two lines
\param geoId, pos - one of the (exactly) two coincident endpoints
\param radius - fillet radius
\param trim - if false, leaves the original lines untouched
\param createCorner - keep geoId/pos as a Point and keep as many constraints as possible
\retval - 0 on success, -1 on failure
*/
int fillet(int geoId, PointPos pos, double radius, bool trim=true, bool preserveCorner=false);
/*!
\brief More general form of fillet
\param geoId1, geoId2 - geoId for two lines (which don't necessarily have to coincide)
\param refPnt1, refPnt2 - reference points on the input geometry, used to influence the free fillet variables
\param radius - fillet radius
\param trim - if false, leaves the original lines untouched
\param preserveCorner - if the lines are coincident, place a Point where they meet and keep as many
of the existing constraints as possible
\retval - 0 on success, -1 on failure
*/
int fillet(int geoId1, int geoId2,
const Base::Vector3d& refPnt1, const Base::Vector3d& refPnt2,
double radius, bool trim=true);
double radius, bool trim=true, bool createCorner=false);
/// trim a curve
int trim(int geoId, const Base::Vector3d& point);
@@ -479,6 +514,19 @@ protected:
std::vector<Part::Geometry *> supportedGeometry(const std::vector<Part::Geometry *> &geoList) const;
/*!
\brief Transfer constraints on lines being filleted.
Since filleting moves the endpoints of the input geometry, existing constraints may no longer be
sensible. If fillet() was called with preserveCorner=false, the constraints are simply deleted.
But if the lines are coincident and preserveCorner=true, we can preserve most constraints on the
old end points by moving them to the preserved corner, or transforming distance constraints on
straight lines into point-to-point distance constraints.
\param geoId1, podId1, geoId2, posId2 - The two lines that have just been filleted
*/
void transferFilletConstraints(int geoId1, PointPos posId1, int geoId2, PointPos posId2);
// refactoring functions
// check whether constraint may be changed driving status
int testDrivingChange(int ConstrId, bool isdriving);