Sketcher: Ability for SketchObject to create a list of dependent geometric elements
This commit is contained in:
@@ -5568,6 +5568,61 @@ void SketchObject::appendRedundantMsg(const std::vector<int> &redundant, std::st
|
||||
msg = ss.str();
|
||||
}
|
||||
|
||||
void SketchObject::getGeometryWithDependentParameters(std::vector<std::pair<int,PointPos>>& geometrymap)
|
||||
{
|
||||
auto geos = getInternalGeometry();
|
||||
|
||||
GCS::QRAlgorithm curQRAlg = getSolvedSketch().getQRAlgorithm();
|
||||
|
||||
if(curQRAlg == GCS::EigenSparseQR) {
|
||||
getSolvedSketch().setQRAlgorithm(GCS::EigenDenseQR);
|
||||
solve(false);
|
||||
}
|
||||
|
||||
auto addelement = [this,&geometrymap](int geoId, PointPos pos = Sketcher::none){
|
||||
if(getSolvedSketch().hasDependentParameters(geoId, pos))
|
||||
geometrymap.emplace_back(geoId,pos);
|
||||
};
|
||||
|
||||
|
||||
int geoid = 0;
|
||||
|
||||
for(auto geo : geos) {
|
||||
if(geo->getTypeId() == Part::GeomPoint::getClassTypeId()) {
|
||||
addelement(geoid, Sketcher::start);
|
||||
}
|
||||
else if(geo->getTypeId() == Part::GeomLineSegment::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) {
|
||||
|
||||
addelement(geoid, Sketcher::start);
|
||||
addelement(geoid, Sketcher::end);
|
||||
addelement(geoid);
|
||||
}
|
||||
else if(geo->getTypeId() == Part::GeomCircle::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomEllipse::getClassTypeId() ) {
|
||||
|
||||
addelement(geoid, Sketcher::mid);
|
||||
addelement(geoid);
|
||||
}
|
||||
else if(geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() ) {
|
||||
|
||||
addelement(geoid, Sketcher::start);
|
||||
addelement(geoid, Sketcher::end);
|
||||
addelement(geoid, Sketcher::mid);
|
||||
addelement(geoid);
|
||||
}
|
||||
|
||||
geoid++;
|
||||
}
|
||||
|
||||
if(curQRAlg == GCS::EigenSparseQR) {
|
||||
getSolvedSketch().setQRAlgorithm(GCS::EigenSparseQR);
|
||||
}
|
||||
}
|
||||
|
||||
bool SketchObject::evaluateConstraint(const Constraint *constraint) const
|
||||
{
|
||||
//if requireXXX, GeoUndef is treated as an error. If not requireXXX,
|
||||
|
||||
@@ -316,6 +316,10 @@ public:
|
||||
inline const std::vector<int> &getLastRedundant(void) const { return lastRedundant; }
|
||||
/// gets the solved sketch as a reference
|
||||
inline Sketch &getSolvedSketch(void) {return solvedSketch;}
|
||||
|
||||
/// returns the geometric elements/vertex which the solver detects as having dependent parameters.
|
||||
/// these parameters relate to not fully constraint edges/vertices.
|
||||
void getGeometryWithDependentParameters(std::vector<std::pair<int,PointPos>>& geometrymap);
|
||||
|
||||
/// Flag to allow external geometry from other bodies than the one this sketch belongs to
|
||||
bool isAllowedOtherBody() const {
|
||||
|
||||
Reference in New Issue
Block a user