[TD]fix handling of composite shapes
This commit is contained in:
committed by
WandererFan
parent
4e0498c48e
commit
484ff4fafb
@@ -116,15 +116,7 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> l
|
||||
auto shape = Part::Feature::getShape(l);
|
||||
if(!shape.IsNull()) {
|
||||
// BRepTools::Write(shape, "DVPgetShape.brep"); //debug
|
||||
if (shape.ShapeType() > TopAbs_COMPSOLID) { //simple shape
|
||||
//do we need to apply placement here too??
|
||||
sourceShapes.push_back(shape);
|
||||
} else { //complex shape
|
||||
std::vector<TopoDS_Shape> drawable = extractDrawableShapes(shape);
|
||||
if (!drawable.empty()) {
|
||||
sourceShapes.insert(sourceShapes.end(),drawable.begin(),drawable.end());
|
||||
}
|
||||
}
|
||||
sourceShapes.push_back(shape);
|
||||
} else {
|
||||
std::vector<TopoDS_Shape> shapeList = getShapesFromObject(l);
|
||||
sourceShapes.insert(sourceShapes.end(),shapeList.begin(),shapeList.end());
|
||||
@@ -203,14 +195,7 @@ std::vector<TopoDS_Shape> ShapeExtractor::getXShapes(const App::Link* xLink)
|
||||
ts.transformGeometry(netTransform);
|
||||
shape = ts.getShape();
|
||||
}
|
||||
if (shape.ShapeType() > TopAbs_COMPSOLID) { //simple shape
|
||||
xSourceShapes.push_back(shape);
|
||||
} else { //complex shape
|
||||
std::vector<TopoDS_Shape> drawable = extractDrawableShapes(shape);
|
||||
if (!drawable.empty()) {
|
||||
xSourceShapes.insert(xSourceShapes.end(),drawable.begin(),drawable.end());
|
||||
}
|
||||
}
|
||||
xSourceShapes.push_back(shape);
|
||||
} else {
|
||||
Base::Console().Message("SE::getXShapes - no shape from getXShape\n");
|
||||
}
|
||||
@@ -228,15 +213,7 @@ std::vector<TopoDS_Shape> ShapeExtractor::getXShapes(const App::Link* xLink)
|
||||
ts.transformGeometry(netTransform);
|
||||
shape = ts.getShape();
|
||||
}
|
||||
|
||||
if (shape.ShapeType() > TopAbs_COMPSOLID) { //simple shape
|
||||
xSourceShapes.push_back(shape);
|
||||
} else { //complex shape
|
||||
std::vector<TopoDS_Shape> drawable = extractDrawableShapes(shape);
|
||||
if (!drawable.empty()) {
|
||||
xSourceShapes.insert(xSourceShapes.end(),drawable.begin(),drawable.end());
|
||||
}
|
||||
}
|
||||
xSourceShapes.push_back(shape);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,61 +293,6 @@ TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector<App::DocumentObjec
|
||||
return baseShape;
|
||||
}
|
||||
|
||||
std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes(const TopoDS_Shape shapeIn)
|
||||
{
|
||||
// Base::Console().Message("SE::extractDrawableShapes()\n");
|
||||
std::vector<TopoDS_Shape> result;
|
||||
std::vector<TopoDS_Shape> extShapes; //extracted Shapes (solids mostly)
|
||||
std::vector<TopoDS_Shape> extEdges; //extracted loose Edges
|
||||
if (shapeIn.ShapeType() == TopAbs_COMPOUND) { //Compound is most general shape type
|
||||
//getSolids from Compound
|
||||
TopExp_Explorer expSolid(shapeIn, TopAbs_SOLID);
|
||||
for (int i = 1; expSolid.More(); expSolid.Next(), i++) {
|
||||
TopoDS_Solid s = TopoDS::Solid(expSolid.Current());
|
||||
if (!s.IsNull() && !Part::TopoShape(s).isInfinite()) {
|
||||
extShapes.push_back(s);
|
||||
}
|
||||
}
|
||||
//get edges not part of a solid
|
||||
//???? should this look for Faces(Wires?) before Edges?
|
||||
TopExp_Explorer expEdge(shapeIn, TopAbs_EDGE, TopAbs_SOLID);
|
||||
for (int i = 1; expEdge.More(); expEdge.Next(), i++) {
|
||||
TopoDS_Shape s = expEdge.Current();
|
||||
if (!s.IsNull() && !Part::TopoShape(s).isInfinite()) {
|
||||
extEdges.push_back(s);
|
||||
}
|
||||
}
|
||||
} else if (shapeIn.ShapeType() == TopAbs_COMPSOLID) {
|
||||
//get Solids from compSolid
|
||||
TopExp_Explorer expSolid(shapeIn, TopAbs_SOLID);
|
||||
for (int i = 1; expSolid.More(); expSolid.Next(), i++) {
|
||||
TopoDS_Solid s = TopoDS::Solid(expSolid.Current());
|
||||
if (!s.IsNull() && !Part::TopoShape(s).isInfinite()) {
|
||||
extShapes.push_back(s);
|
||||
}
|
||||
}
|
||||
//vs using 2d geom as construction geom?
|
||||
//get edges not part of a solid
|
||||
//???? should this look for Faces(Wires?) before Edges?
|
||||
TopExp_Explorer expEdge(shapeIn, TopAbs_EDGE, TopAbs_SOLID);
|
||||
for (int i = 1; expEdge.More(); expEdge.Next(), i++) {
|
||||
TopoDS_Shape s = expEdge.Current();
|
||||
if (!s.IsNull() && !Part::TopoShape(s).isInfinite()) {
|
||||
extEdges.push_back(s);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//not a Compound or a CompSolid just push_back shape_In)
|
||||
extShapes.push_back(shapeIn);
|
||||
}
|
||||
|
||||
result = extShapes;
|
||||
if (!extEdges.empty()) {
|
||||
result.insert(std::end(result), std::begin(extEdges), std::end(extEdges));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ShapeExtractor::is2dObject(App::DocumentObject* obj)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef _ShapeExtractor_h_
|
||||
#define _ShapeExtractor_h_
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
@@ -50,7 +52,6 @@ public:
|
||||
static std::vector<TopoDS_Shape> getXShapes(const App::Link* xLink);
|
||||
static std::vector<TopoDS_Shape> getShapesFromObject(const App::DocumentObject* docObj);
|
||||
static TopoDS_Shape getShapesFused(const std::vector<App::DocumentObject*> links);
|
||||
static std::vector<TopoDS_Shape> extractDrawableShapes(const TopoDS_Shape shapeIn);
|
||||
|
||||
static bool is2dObject(App::DocumentObject* obj);
|
||||
static bool isEdgeType(App::DocumentObject* obj);
|
||||
@@ -59,7 +60,6 @@ public:
|
||||
static Base::Vector3d getLocation3dFromFeat(App::DocumentObject* obj);
|
||||
static bool prefAdd2d(void);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user