Sketcher: Augment malformed constraint messages

===============================================

Enable a user recomputing an object/document to identify which sketch has the malformed constraints.
This commit is contained in:
Abdullah Tahiri
2020-07-02 17:46:16 +02:00
parent 1fa1d753b0
commit 4ed35140c0
3 changed files with 83 additions and 71 deletions

View File

@@ -69,6 +69,7 @@ Sketch::Sketch()
, RecalculateInitialSolutionWhileMovingPoint(false)
, GCSsys(), ConstraintsCounter(0)
, isInitMove(false), isFine(true), moveStep(0)
, malformedConstraints(false)
, defaultSolver(GCS::DogLeg)
, defaultSolverRedundant(GCS::DogLeg)
, debugMode(GCS::Minimal)
@@ -116,6 +117,7 @@ void Sketch::clear(void)
isInitMove = false;
ConstraintsCounter = 0;
Conflicting.clear();
malformedConstraints = false;
}
int Sketch::setUpSketch(const std::vector<Part::Geometry *> &GeoList,
@@ -1493,6 +1495,7 @@ int Sketch::addConstraints(const std::vector<Constraint *> &ConstraintList)
if(rtn == -1) {
Base::Console().Error("Sketcher constraint number %d is malformed!\n",cid);
malformedConstraints = true;
}
}
@@ -1511,6 +1514,7 @@ int Sketch::addConstraints(const std::vector<Constraint *> &ConstraintList,
if(rtn == -1) {
Base::Console().Error("Sketcher constraint number %d is malformed!\n",cid);
malformedConstraints = true;
}
}
else {

View File

@@ -58,7 +58,7 @@ public:
/// delete all geometry and constraints, leave an empty sketch
void clear(void);
/** set the sketch up with geoms and constraints
*
*
* returns the degree of freedom of a sketch and calculates a list of
* conflicting constraints
*
@@ -105,6 +105,8 @@ public:
inline bool hasRedundancies(void) const { return !Redundant.empty(); }
inline const std::vector<int> &getRedundant(void) const { return Redundant; }
inline bool hasMalformedConstraints(void) const { return malformedConstraints; }
/** set the datum of a distance or angle constraint to a certain value and solve
* This can cause the solving to fail!
*/
@@ -114,7 +116,7 @@ public:
* sketch status as a reference
*/
int initMove(int geoId, PointPos pos, bool fine=true);
/** Resets the initialization of a point or curve drag
*/
void resetInitMove();
@@ -161,85 +163,85 @@ public:
/// add one constraint to the sketch
int addConstraint(const Constraint *constraint);
/**
/**
* add a fixed X coordinate constraint to a point
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
int addCoordinateXConstraint(int geoId, PointPos pos, double * value, bool driving = true);
/**
/**
* add a fixed Y coordinate constraint to a point
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addCoordinateYConstraint(int geoId, PointPos pos, double * value, bool driving = true);
/**
/**
* add a horizontal distance constraint to two points or line ends
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
int addDistanceXConstraint(int geoId, double * value, bool driving = true);
/**
/**
* add a horizontal distance constraint to two points or line ends
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addDistanceXConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, double * value, bool driving = true);
/**
/**
* add a vertical distance constraint to two points or line ends
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
int addDistanceYConstraint(int geoId, double * value, bool driving = true);
/**
/**
* add a vertical distance constraint to two points or line ends
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addDistanceYConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, double * value, bool driving = true);
/// add a horizontal constraint to a geometry
int addHorizontalConstraint(int geoId);
int addHorizontalConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2);
/// add a vertical constraint to a geometry
int addVerticalConstraint(int geoId);
int addVerticalConstraint(int geoId);
int addVerticalConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2);
/// add a coincident constraint to two points of two geometries
int addPointCoincidentConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2);
/**
/**
* add a length or distance constraint
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addDistanceConstraint(int geoId1, double * value, bool driving = true);
/**
/**
* add a length or distance constraint
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addDistanceConstraint(int geoId1, PointPos pos1, int geoId2, double * value, bool driving = true);
/**
/**
* add a length or distance constraint
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addDistanceConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, double * value, bool driving = true);
/// add a parallel constraint between two lines
int addParallelConstraint(int geoId1, int geoId2);
@@ -253,80 +255,80 @@ public:
int geoId3, PointPos pos3,
double * value,
ConstraintType cTyp, bool driving = true);
/**
/**
* add a radius constraint on a circle or an arc
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addRadiusConstraint(int geoId, double * value, bool driving = true);
/**
/**
* add a radius constraint on a circle or an arc
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addDiameterConstraint(int geoId, double * value, bool driving = true);
/**
/**
* add an angle constraint on a line or between two lines
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addAngleConstraint(int geoId, double * value, bool driving = true);
/**
/**
* add an angle constraint on a line or between two lines
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addAngleConstraint(int geoId1, int geoId2, double * value, bool driving = true);
/**
/**
* add an angle constraint on a line or between two lines
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addAngleConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, double * value, bool driving = true);
/**
/**
* add angle-via-point constraint between any two curves
*
*
* double * value is a pointer to double allocated in the heap, containing the
* constraint value and already inserted into either the FixParameters or
* constraint value and already inserted into either the FixParameters or
* Parameters array, as the case may be.
*/
*/
int addAngleViaPointConstraint(int geoId1, int geoId2, int geoId3, PointPos pos3, double value, bool driving = true);
/// add an equal length or radius constraints between two lines or between circles and arcs
int addEqualConstraint(int geoId1, int geoId2);
int addEqualConstraint(int geoId1, int geoId2);
/// add a point on line constraint
int addPointOnObjectConstraint(int geoId1, PointPos pos1, int geoId2, bool driving = true);
/// add a symmetric constraint between two points with respect to a line
int addSymmetricConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, int geoId3);
/// add a symmetric constraint between three points, the last point is in the middle of the first two
int addSymmetricConstraint(int geoId1, PointPos pos1, int geoId2, PointPos pos2, int geoId3, PointPos pos3);
/**
/**
* add a snell's law constraint
*
* double * value and double * second are each a pointer to double
* allocated in the heap and already inserted into either the
*
* double * value and double * second are each a pointer to double
* allocated in the heap and already inserted into either the
* FixParameters or Parameters array, as the case may be.
*
*
* value must contain the constraint value (the ratio of n2/n1)
* second may be initialized to any value, however the solver will
* provide n1 in value and n2 in second.
*/
*/
int addSnellsLawConstraint(int geoIdRay1, PointPos posRay1,
int geoIdRay2, PointPos posRay2,
int geoIdBnd,
double * value,
double * second, bool driving = true);
//@}
/// Internal Alignment constraints
//@{
/// add InternalAlignmentEllipseMajorDiameter to a line and an ellipse
@@ -406,7 +408,7 @@ protected:
int ConstraintsCounter;
std::vector<int> Conflicting;
std::vector<int> Redundant;
std::vector<double *> pconstraintplistOut;
// solving parameters
@@ -429,6 +431,8 @@ protected:
Base::Vector3d initToPoint;
double moveStep;
bool malformedConstraints;
public:
GCS::Algorithm defaultSolver;
GCS::Algorithm defaultSolverRedundant;
@@ -456,7 +460,7 @@ public:
inline void setDL_tolgRedundant(double val){GCSsys.DL_tolgRedundant=val;}
inline void setDL_tolxRedundant(double val){GCSsys.DL_tolxRedundant=val;}
inline void setDL_tolfRedundant(double val){GCSsys.DL_tolfRedundant=val;}
protected:
GCS::DebugMode debugMode;
@@ -464,7 +468,7 @@ private:
bool updateGeometry(void);
bool updateNonDrivingConstraints(void);
void calculateDependentParametersElements(void);
/// checks if the index bounds and converts negative indices to positive

View File

@@ -286,6 +286,10 @@ int SketchObject::solve(bool updateGeoAfterSolving/*=true*/)
}
}
if(solvedSketch.hasMalformedConstraints()) {
Base::Console().Error("Sketch %s has malformed constraints!\n",this->getNameInDocument());
}
lastSolveTime=solvedSketch.SolveTime;
if (err == 0 && updateGeoAfterSolving) {