Skip to content

Commit fc7890c

Browse files
committed
[TD]fix Compound of Edges as Source for View
1 parent e3530f9 commit fc7890c

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

src/Mod/TechDraw/App/ShapeExtractor.cpp

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> l
5959
auto shape = Part::Feature::getShape(l); //finds shape within DocObj??
6060
if(!shape.IsNull()) {
6161
// BRepTools::Write(shape, "DVPgetShape.brep"); //debug
62-
if (shape.ShapeType() > TopAbs_COMPSOLID) {
62+
if (shape.ShapeType() > TopAbs_COMPSOLID) { //simple shape
6363
sourceShapes.push_back(shape);
64-
} else {
64+
} else { //complex shape
6565
std::vector<TopoDS_Shape> drawable = extractDrawableShapes(shape);
6666
if (!drawable.empty()) {
6767
sourceShapes.insert(sourceShapes.end(),drawable.begin(),drawable.end());
@@ -98,6 +98,7 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> l
9898

9999
std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject(const App::DocumentObject* docObj)
100100
{
101+
// Base::Console().Message("SE::getShapesFromObject(%s)\n", docObj->getNameInDocument());
101102
std::vector<TopoDS_Shape> result;
102103

103104
const App::GroupExtension* gex = dynamic_cast<const App::GroupExtension*>(docObj);
@@ -146,6 +147,7 @@ std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject(const App::Documen
146147

147148
TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector<App::DocumentObject*> links)
148149
{
150+
// Base::Console().Message("SE::getShapesFused()\n");
149151
TopoDS_Shape baseShape = getShapes(links);
150152
if (!baseShape.IsNull()) {
151153
TopoDS_Iterator it(baseShape);
@@ -166,20 +168,56 @@ TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector<App::DocumentObjec
166168
return baseShape;
167169
}
168170

169-
std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes(const TopoDS_Shape shapeIn)
171+
std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes(const TopoDS_Shape shapeIn)
170172
{
171-
//this pulls solids out of compound
172-
//should it pull Shells, Faces, Wires, Edges, Vertexes too???
173+
// Base::Console().Message("SE::extractDrawableShapes()\n");
173174
std::vector<TopoDS_Shape> result;
174-
if ( (shapeIn.ShapeType() == TopAbs_COMPOUND) ||
175-
(shapeIn.ShapeType() == TopAbs_COMPSOLID) ) { //not sure about this one
175+
std::vector<TopoDS_Shape> extShapes; //extracted Shapes (solids mostly)
176+
std::vector<TopoDS_Shape> extEdges; //extracted loose Edges
177+
if (shapeIn.ShapeType() == TopAbs_COMPOUND) { //Compound is most general shape type
178+
//getSolids from Compound
176179
TopExp_Explorer expSolid(shapeIn, TopAbs_SOLID);
177180
for (int i = 1; expSolid.More(); expSolid.Next(), i++) {
178181
TopoDS_Solid s = TopoDS::Solid(expSolid.Current());
179182
if (!s.IsNull()) {
180-
result.push_back(s);
183+
extShapes.push_back(s);
181184
}
182185
}
186+
//get edges not part of a solid
187+
//???? should this look for Faces(Wires?) before Edges?
188+
TopExp_Explorer expEdge(shapeIn, TopAbs_EDGE, TopAbs_SOLID);
189+
for (int i = 1; expEdge.More(); expEdge.Next(), i++) {
190+
TopoDS_Shape s = expEdge.Current();
191+
if (!s.IsNull()) {
192+
extEdges.push_back(s);
193+
}
194+
}
195+
} else if (shapeIn.ShapeType() == TopAbs_COMPSOLID) {
196+
//get Solids from compSolid
197+
TopExp_Explorer expSolid(shapeIn, TopAbs_SOLID);
198+
for (int i = 1; expSolid.More(); expSolid.Next(), i++) {
199+
TopoDS_Solid s = TopoDS::Solid(expSolid.Current());
200+
if (!s.IsNull()) {
201+
extShapes.push_back(s);
202+
}
203+
}
204+
//get edges not part of a solid
205+
//???? should this look for Faces(Wires?) before Edges?
206+
TopExp_Explorer expEdge(shapeIn, TopAbs_EDGE, TopAbs_SOLID);
207+
for (int i = 1; expEdge.More(); expEdge.Next(), i++) {
208+
TopoDS_Shape s = expEdge.Current();
209+
if (!s.IsNull()) {
210+
extEdges.push_back(s);
211+
}
212+
}
213+
} else {
214+
//not a Compound or a CompSolid just push_back shape_In)
215+
extShapes.push_back(shapeIn);
216+
}
217+
218+
result = extShapes;
219+
if (!extEdges.empty()) {
220+
result.insert(std::end(result), std::begin(extEdges), std::end(extEdges));
183221
}
184222
return result;
185223
}

0 commit comments

Comments
 (0)