Miscellaneous fixes

This commit is contained in:
jrheinlaender
2013-05-15 19:13:21 +04:30
committed by Stefan Tröger
parent 1f42d4e3a3
commit 4645fdcd37
9 changed files with 64 additions and 29 deletions

View File

@@ -29,6 +29,8 @@
# include <TopoDS.hxx>
# include <BRep_Tool.hxx>
# include <gp_Pnt.hxx>
# include <gp_Pln.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
#endif
@@ -114,4 +116,20 @@ bool Feature::isDatum(const App::DocumentObject* feature)
feature->getTypeId().isDerivedFrom(Part::Datum::getClassTypeId());
}
TopoDS_Shape Feature::makeShapeFromPlane(const App::DocumentObject* obj)
{
const App::Plane* plane = static_cast<const App::Plane*>(obj);
if (plane == NULL)
throw Base::Exception("Feature: Null object");
Base::Rotation rot = plane->Placement.getValue().getRotation();
Base::Vector3d normal(0,0,1);
rot.multVec(normal, normal);
BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0,0,0), gp_Dir(normal.x,normal.y,normal.z)));
if (!builder.IsDone())
throw Base::Exception("Feature: Could not create shape from base plane");
return builder.Shape();
}
}

View File

@@ -66,6 +66,8 @@ protected:
/// Grab any point from the given face
static const gp_Pnt getPointFromFace(const TopoDS_Face& f);
/// Make a shape from a base plane (convenience method)
static TopoDS_Shape makeShapeFromPlane(const App::DocumentObject* obj);
};
} //namespace PartDesign

View File

@@ -457,18 +457,9 @@ void SketchBased::getUpToFaceFromLinkSub(TopoDS_Face& upToFace,
throw Base::Exception("SketchBased: Up to face: No face selected");
if (ref->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
App::Plane* plane = static_cast<App::Plane*>(ref);
Base::Rotation rot = plane->Placement.getValue().getRotation();
Base::Vector3d normal(0,0,1);
rot.multVec(normal, normal);
BRepBuilderAPI_MakeFace builder(gp_Pln(gp_Pnt(0,0,0), gp_Dir(normal.x,normal.y,normal.z)));
if (!builder.IsDone())
throw Base::Exception("SketchBased: Up to face: Could not create shape from base plane");
upToFace = TopoDS::Face(builder.Shape());
upToFace = TopoDS::Face(makeShapeFromPlane(ref));
return;
}
if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
} else if (ref->getTypeId().isDerivedFrom(PartDesign::Plane::getClassTypeId())) {
Part::Datum* datum = static_cast<Part::Datum*>(ref);
upToFace = TopoDS::Face(datum->getShape());
return;

View File

@@ -251,15 +251,25 @@ App::DocumentObjectExecReturn *Transformed::execute(void)
return new App::DocumentObjectExecReturn("Transformation failed", (*o));
// Check for intersection with support
if (!Part::checkIntersection(support, mkTrf.Shape(), false, true)) {
try {
if (!Part::checkIntersection(support, mkTrf.Shape(), false, true)) {
#ifdef FC_DEBUG // do not write this in release mode because a message appears already in the task view
Base::Console().Warning("Transformed shape does not intersect support %s: Removed\n", (*o)->getNameInDocument());
Base::Console().Warning("Transformed shape does not intersect support %s: Removed\n", (*o)->getNameInDocument());
#endif
nointersect_trsfms.insert(t);
} else {
v_transformations.push_back(t);
v_transformedShapes.push_back(mkTrf.Shape());
// Note: Transformations that do not intersect the support are ignored in the overlap tests
nointersect_trsfms.insert(t);
} else {
v_transformations.push_back(t);
v_transformedShapes.push_back(mkTrf.Shape());
// Note: Transformations that do not intersect the support are ignored in the overlap tests
}
} catch (Standard_Failure) {
// Note: Ignoring this failure is probably pointless because if the intersection check fails, the later
// fuse operation of the transformation result will also fail
Handle_Standard_Failure e = Standard_Failure::Caught();
std::string msg("Transformation: Intersection check failed");
if (e->GetMessageString() != NULL)
msg += std::string(": '") + e->GetMessageString() + "'";
return new App::DocumentObjectExecReturn(msg.c_str());
}
}