Sketcher: BSpline deletion/special hideunused internal geometry
=============================================================== The implementation of BSpline differs from previous complex forms. The BSpline is created constraint to be polynomic (non-rational), with radius of first circle and equality constraints. Hide unused internal geometry considers as unused the following constraints: - A pole which has equality constraints with another pole of the same bspline - Any radius constraint on a pole Deletion of a BSpline will delete the internal geometry that is unused as per the definition above. If there is another constraint (other than the Internal alignment constraint) it will leave the internal geometry having such constraint undeleted.
This commit is contained in:
@@ -3491,7 +3491,7 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId, bool delgeoid)
|
||||
if (GeoId < 0 || GeoId > getHighestCurveIndex())
|
||||
return -1;
|
||||
|
||||
const Part::Geometry *geo = getGeometry(GeoId);
|
||||
const Part::Geometry *geo = getGeometry(GeoId);
|
||||
// Only for supported types
|
||||
if (geo->getTypeId() == Part::GeomEllipse::getClassTypeId() ||
|
||||
geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() ||
|
||||
@@ -3574,8 +3574,12 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId, bool delgeoid)
|
||||
delGeometry(*it,false);
|
||||
}
|
||||
}
|
||||
|
||||
return delgeometries.size(); //number of deleted elements
|
||||
|
||||
int ndeleted = delgeometries.size();
|
||||
|
||||
delgeometries.clear();
|
||||
|
||||
return ndeleted; //number of deleted elements
|
||||
}
|
||||
else if( geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId()) {
|
||||
// if the focus-to-vertex line is constrained, then never delete the focus
|
||||
@@ -3663,7 +3667,11 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId, bool delgeoid)
|
||||
}
|
||||
}
|
||||
|
||||
return delgeometries.size(); //number of deleted elements
|
||||
int ndeleted = delgeometries.size();
|
||||
|
||||
delgeometries.clear();
|
||||
|
||||
return ndeleted; //number of deleted elements
|
||||
}
|
||||
else if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) {
|
||||
|
||||
@@ -3697,30 +3705,47 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId, bool delgeoid)
|
||||
}
|
||||
|
||||
std::vector<int> delgeometries;
|
||||
bool firstpoledeleted = false;
|
||||
|
||||
for (it=controlpointgeoids.begin(), ita=associatedcontraints.begin(); it!=controlpointgeoids.end() && ita!=associatedcontraints.end(); ++it, ++ita) {
|
||||
if ((*it) != -1) {
|
||||
// look for a circle at geoid index
|
||||
for (std::vector< Sketcher::Constraint * >::const_iterator itc= vals.begin();
|
||||
itc != vals.end(); ++itc) {
|
||||
for (std::vector< Sketcher::Constraint * >::const_iterator itc= vals.begin(); itc != vals.end(); ++itc) {
|
||||
|
||||
if ((*itc)->Second == (*it) || (*itc)->First == (*it) || (*itc)->Third == (*it))
|
||||
if ( (*itc)->Type==Sketcher::Equal ) {
|
||||
bool f=false,s=false;
|
||||
for ( std::vector<int>::iterator its=controlpointgeoids.begin(); its!=controlpointgeoids.end(); ++its) {
|
||||
if( (*itc)->First == *its ) {
|
||||
f=true;
|
||||
}
|
||||
else if ( (*itc)->Second == *its ) {
|
||||
s=true;
|
||||
}
|
||||
|
||||
if (f && s) { // the equality constraint is not interpole
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( (f && !s) || (!f && s) ) { // the equality constraint constraints a pole but it is not interpole
|
||||
(*ita)++;
|
||||
}
|
||||
|
||||
}
|
||||
// ignore radiuses
|
||||
else if ((*itc)->Type!=Sketcher::Radius && ( (*itc)->Second == (*it) || (*itc)->First == (*it) || (*itc)->Third == (*it)) )
|
||||
(*ita)++;
|
||||
|
||||
}
|
||||
|
||||
if ((*ita)<3 ) { // IA + Weight
|
||||
if ( (*ita) < 2 ) { // IA
|
||||
delgeometries.push_back((*it));
|
||||
|
||||
if (it == controlpointgeoids.begin())
|
||||
firstpoledeleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(delgeoid)
|
||||
delgeometries.push_back(GeoId);
|
||||
|
||||
|
||||
std::sort(delgeometries.begin(), delgeometries.end()); // indices over an erased element get automatically updated!!
|
||||
|
||||
if (delgeometries.size()>0) {
|
||||
@@ -3729,30 +3754,10 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId, bool delgeoid)
|
||||
}
|
||||
}
|
||||
|
||||
// retest the first pole after removal of equality constraints from other poles
|
||||
associatedcontraints[0] = 0;
|
||||
int ndeleted = delgeometries.size();
|
||||
delgeometries.clear();
|
||||
|
||||
if (controlpointgeoids[0] != -1 && !firstpoledeleted) {
|
||||
// look for a circle at geoid index
|
||||
for (std::vector< Sketcher::Constraint * >::const_iterator itc= vals.begin(); itc != vals.end(); ++itc) {
|
||||
if ((*itc)->Second == controlpointgeoids[0] ||
|
||||
(*itc)->First == controlpointgeoids[0] ||
|
||||
(*itc)->Third == controlpointgeoids[0])
|
||||
associatedcontraints[0]++;
|
||||
}
|
||||
|
||||
if (associatedcontraints[0]<4 ) // IA + Weight + Radius
|
||||
delgeometries.push_back(controlpointgeoids[0]);
|
||||
}
|
||||
|
||||
if (delgeometries.size()>0) {
|
||||
for (std::vector<int>::reverse_iterator it=delgeometries.rbegin(); it!=delgeometries.rend(); ++it) {
|
||||
delGeometry(*it,false);
|
||||
}
|
||||
}
|
||||
|
||||
return delgeometries.size(); //number of deleted elements
|
||||
return ndeleted; //number of deleted elements
|
||||
}
|
||||
else {
|
||||
return -1; // not supported type
|
||||
|
||||
@@ -193,7 +193,7 @@ public:
|
||||
\brief Deletes all unused (not further constrained) internal geometry
|
||||
\param GeoId - the geometry having the internal geometry to delete
|
||||
\param delgeoid - if true in addition to the unused internal geometry also deletes the GeoId geometry
|
||||
\retval int - returns -1 on error
|
||||
\retval int - returns -1 on error, otherwise the number of deleted elements
|
||||
*/
|
||||
int DeleteUnusedInternalGeometry(int GeoId, bool delgeoid=false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user