Merge pull request #479 from abdullahtahiriyo/bspline_stage1b_2017_firstdeliverable_fixes

Bspline stage1b 2017 firstdeliverable fixes
This commit is contained in:
wwmayer 2017-01-29 11:40:26 +01:00 committed by GitHub
commit 1e4b6ed00b
2 changed files with 40 additions and 12 deletions

View File

@ -644,13 +644,25 @@ int SketchObject::addGeometry(const Part::Geometry *geo, bool construction/*=fal
return Geometry.getSize()-1;
}
int SketchObject::delGeometry(int GeoId)
int SketchObject::delGeometry(int GeoId, bool deleteinternalgeo)
{
const std::vector< Part::Geometry * > &vals = getInternalGeometry();
if (GeoId < 0 || GeoId >= int(vals.size()))
return -1;
this->DeleteUnusedInternalGeometry(GeoId);
const Part::Geometry *geo = getGeometry(GeoId);
// Only for supported types
if ((geo->getTypeId() == Part::GeomEllipse::getClassTypeId() ||
geo->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() ||
geo->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ||
geo->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() ||
geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId())) {
if(deleteinternalgeo) {
this->DeleteUnusedInternalGeometry(GeoId, true);
return 0;
}
}
std::vector< Part::Geometry * > newVals(vals);
newVals.erase(newVals.begin()+GeoId);
@ -3474,7 +3486,7 @@ int SketchObject::ExposeInternalGeometry(int GeoId)
return -1; // not supported type
}
int SketchObject::DeleteUnusedInternalGeometry(int GeoId)
int SketchObject::DeleteUnusedInternalGeometry(int GeoId, bool delgeoid)
{
if (GeoId < 0 || GeoId > getHighestCurveIndex())
return -1;
@ -3552,11 +3564,14 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId)
if (majorconstraints<2)
delgeometries.push_back(majorelementindex);
if(delgeoid)
delgeometries.push_back(GeoId);
std::sort(delgeometries.begin(), delgeometries.end()); // indices over an erased element get automatically updated!!
if (delgeometries.size()>0) {
for (std::vector<int>::reverse_iterator it=delgeometries.rbegin(); it!=delgeometries.rend(); ++it) {
delGeometry(*it);
delGeometry(*it,false);
}
}
@ -3637,11 +3652,14 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId)
if (majorelementindex == -1 && focus1elementindex !=-1 && focus1constraints<3) // focus has one coincident and one internal align
delgeometries.push_back(focus1elementindex);
if(delgeoid)
delgeometries.push_back(GeoId);
std::sort(delgeometries.begin(), delgeometries.end()); // indices over an erased element get automatically updated!!
if (delgeometries.size()>0) {
for (std::vector<int>::reverse_iterator it=delgeometries.rbegin(); it!=delgeometries.rend(); ++it) {
delGeometry(*it);
delGeometry(*it,false);
}
}
@ -3700,11 +3718,14 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId)
}
}
if(delgeoid)
delgeometries.push_back(GeoId);
std::sort(delgeometries.begin(), delgeometries.end()); // indices over an erased element get automatically updated!!
if (delgeometries.size()>0) {
for (std::vector<int>::reverse_iterator it=delgeometries.rbegin(); it!=delgeometries.rend(); ++it) {
delGeometry(*it);
delGeometry(*it,false);
}
}
@ -3727,7 +3748,7 @@ int SketchObject::DeleteUnusedInternalGeometry(int GeoId)
if (delgeometries.size()>0) {
for (std::vector<int>::reverse_iterator it=delgeometries.rbegin(); it!=delgeometries.rend(); ++it) {
delGeometry(*it);
delGeometry(*it,false);
}
}

View File

@ -90,8 +90,13 @@ public:
int addGeometry(const Part::Geometry *geo, bool construction=false);
/// add unspecified geometry
int addGeometry(const std::vector<Part::Geometry *> &geoList, bool construction=false);
/// delete geometry
int delGeometry(int GeoId);
/*!
\brief Deletes indicated geometry (by geoid).
\param GeoId - the geometry to delete
\param deleteinternalgeo - if true deletes the associated and unconstraint internal geometry, otherwise deletes only the GeoId
\retval int - 0 if successful
*/
int delGeometry(int GeoId, bool deleteinternalgeo = true);
/// add all constraints in the list
int addConstraints(const std::vector<Constraint *> &ConstraintList);
/// add constraint
@ -184,11 +189,13 @@ public:
* \return -1 on error
*/
int ExposeInternalGeometry(int GeoId);
/// Deletes all unused (not further constrained) internal geometry
/*!
* \return -1 on error
\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
*/
int DeleteUnusedInternalGeometry(int GeoId);
int DeleteUnusedInternalGeometry(int GeoId, bool delgeoid=false);
/// retrieves for a Vertex number the corresponding GeoId and PosId
void getGeoVertexIndex(int VertexId, int &GeoId, PointPos &PosId) const;