Mod: catch exception raised by Rotation::setValue
This commit is contained in:
@@ -94,6 +94,33 @@ ImportOCAF::~ImportOCAF()
|
||||
{
|
||||
}
|
||||
|
||||
void ImportOCAF::tryPlacementFromLoc(App::GeoFeature* part, const TopLoc_Location& part_loc)
|
||||
{
|
||||
gp_Trsf trf;
|
||||
Base::Matrix4D mtrx;
|
||||
if (part_loc.IsIdentity()) {
|
||||
trf = part_loc.Transformation();
|
||||
}
|
||||
else {
|
||||
trf = TopLoc_Location(part_loc.FirstDatum()).Transformation();
|
||||
}
|
||||
|
||||
Part::TopoShape::convertToMatrix(trf, mtrx);
|
||||
tryPlacementFromMatrix(part, mtrx);
|
||||
}
|
||||
|
||||
void ImportOCAF::tryPlacementFromMatrix(App::GeoFeature* part, const Base::Matrix4D& mat)
|
||||
{
|
||||
try {
|
||||
Base::Placement pl;
|
||||
pl.fromMatrix(mat);
|
||||
part->Placement.setValue(pl);
|
||||
}
|
||||
catch (const Base::ValueError& e) {
|
||||
e.ReportException();
|
||||
}
|
||||
}
|
||||
|
||||
void ImportOCAF::loadShapes()
|
||||
{
|
||||
std::vector<App::DocumentObject*> lValue;
|
||||
@@ -235,17 +262,7 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
// there local placement updated and relative to the STEP file content
|
||||
// standard FreeCAD placement was absolute we are now moving to relative
|
||||
|
||||
gp_Trsf trf;
|
||||
Base::Matrix4D mtrx;
|
||||
if (part_loc.IsIdentity())
|
||||
trf = part_loc.Transformation();
|
||||
else
|
||||
trf = TopLoc_Location(part_loc.FirstDatum()).Transformation();
|
||||
Part::TopoShape::convertToMatrix(trf, mtrx);
|
||||
Base::Placement pl;
|
||||
pl.fromMatrix(mtrx);
|
||||
pcPart->Placement.setValue(pl);
|
||||
|
||||
tryPlacementFromLoc(pcPart, part_loc);
|
||||
lValue.push_back(pcPart);
|
||||
}
|
||||
}
|
||||
@@ -332,20 +349,14 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
if (!comp.IsNull() && (ctSolids||ctShells||ctEdges||ctVertices)) {
|
||||
Part::Feature* part = static_cast<Part::Feature*>(doc->addObject("Part::Feature"));
|
||||
// Let's allocate the relative placement of the Compound from the STEP file
|
||||
gp_Trsf trf;
|
||||
Base::Matrix4D mtrx;
|
||||
if ( loc.IsIdentity() )
|
||||
trf = loc.Transformation();
|
||||
else
|
||||
trf = TopLoc_Location(loc.FirstDatum()).Transformation();
|
||||
Part::TopoShape::convertToMatrix(trf, mtrx);
|
||||
Base::Placement pl;
|
||||
pl.fromMatrix(mtrx);
|
||||
part->Placement.setValue(pl);
|
||||
if (!loc.IsIdentity())
|
||||
tryPlacementFromLoc(part, loc);
|
||||
if (!loc.IsIdentity()) {
|
||||
part->Shape.setValue(comp.Moved(loc));
|
||||
else
|
||||
}
|
||||
else {
|
||||
part->Shape.setValue(comp);
|
||||
}
|
||||
|
||||
part->Label.setValue(name);
|
||||
lValue.push_back(part);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user