+ raise exception in TopoShape::getSubShape() if shape is empty or wrong sub-type is given
git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5349 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
@@ -92,7 +92,7 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
|
||||
// setup and diagnose the sketch
|
||||
rebuildExternalGeometry();
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
if (dofs < 0) { // over-constrained sketch
|
||||
std::string msg="Over-constrained sketch\n";
|
||||
@@ -123,7 +123,7 @@ int SketchObject::hasConflicts(void) const
|
||||
{
|
||||
// set up a sketch (including dofs counting and diagnosing of conflicts)
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
if (dofs < 0) // over-constrained sketch
|
||||
return -2;
|
||||
@@ -161,7 +161,7 @@ int SketchObject::setDatum(int ConstrId, double Datum)
|
||||
|
||||
// set up a sketch (including dofs counting and diagnosing of conflicts)
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
int err=0;
|
||||
if (dofs < 0) // over-constrained sketch
|
||||
@@ -187,7 +187,7 @@ int SketchObject::setDatum(int ConstrId, double Datum)
|
||||
int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toPoint, bool relative)
|
||||
{
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
if (dofs < 0) // over-constrained sketch
|
||||
return -1;
|
||||
@@ -668,7 +668,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
|
||||
PointPos secondPos1 = Sketcher::none, secondPos2 = Sketcher::none;
|
||||
ConstraintType constrType1 = Sketcher::PointOnObject, constrType2 = Sketcher::PointOnObject;
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
it != constraints.end(); ++it) {
|
||||
Constraint *constr = *(it);
|
||||
if (secondPos1 == Sketcher::none && (constr->First == GeoId1 && constr->Second == GeoId)) {
|
||||
@@ -691,7 +691,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
newConstr->SecondPos = secondPos1;
|
||||
delConstraintOnPoint(GeoId1, secondPos1, false);
|
||||
}
|
||||
|
||||
|
||||
addConstraint(newConstr);
|
||||
|
||||
// Reset the second pos
|
||||
@@ -737,7 +737,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
|
||||
ConstraintType constrType = Sketcher::PointOnObject;
|
||||
PointPos secondPos = Sketcher::none;
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
it != constraints.end(); ++it) {
|
||||
Constraint *constr = *(it);
|
||||
if ((constr->First == GeoId1 && constr->Second == GeoId)) {
|
||||
@@ -818,7 +818,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
|
||||
PointPos secondPos1 = Sketcher::none, secondPos2 = Sketcher::none;
|
||||
ConstraintType constrType1 = Sketcher::PointOnObject, constrType2 = Sketcher::PointOnObject;
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
it != constraints.end(); ++it) {
|
||||
Constraint *constr = *(it);
|
||||
if (secondPos1 == Sketcher::none && (constr->First == GeoId1 && constr->Second == GeoId)) {
|
||||
@@ -904,7 +904,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
PointPos secondPos1 = Sketcher::none, secondPos2 = Sketcher::none;
|
||||
ConstraintType constrType1 = Sketcher::PointOnObject, constrType2 = Sketcher::PointOnObject;
|
||||
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
it != constraints.end(); ++it) {
|
||||
Constraint *constr = *(it);
|
||||
if (secondPos1 == Sketcher::none &&
|
||||
@@ -970,7 +970,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
|
||||
ConstraintType constrType = Sketcher::PointOnObject;
|
||||
PointPos secondPos = Sketcher::none;
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
|
||||
it != constraints.end(); ++it) {
|
||||
Constraint *constr = *(it);
|
||||
if ((constr->First == GeoId1 && constr->Second == GeoId)) {
|
||||
@@ -1013,7 +1013,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
|
||||
|
||||
if (constrType == Sketcher::Coincident)
|
||||
newConstr->SecondPos = secondPos;
|
||||
|
||||
|
||||
addConstraint(newConstr);
|
||||
delete newConstr;
|
||||
return 0;
|
||||
@@ -1065,7 +1065,7 @@ int SketchObject::delExternal(int ExtGeoId)
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
const Part::Geometry* SketchObject::getGeometry(int GeoId) const
|
||||
{
|
||||
if (GeoId >= 0) {
|
||||
@@ -1122,7 +1122,14 @@ void SketchObject::rebuildExternalGeometry(void)
|
||||
const Part::Feature *refObj=static_cast<const Part::Feature*>(Obj);
|
||||
const Part::TopoShape& refShape=refObj->Shape.getShape();
|
||||
|
||||
TopoDS_Shape refSubShape=refShape.getSubShape(SubElement.c_str());
|
||||
TopoDS_Shape refSubShape;
|
||||
try {
|
||||
refSubShape = refShape.getSubShape(SubElement.c_str());
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Base::Exception(e->GetMessageString());
|
||||
}
|
||||
|
||||
switch (refSubShape.ShapeType())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user