@@ -59,9 +59,9 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> l
59
59
auto shape = Part::Feature::getShape (l); // finds shape within DocObj??
60
60
if (!shape.IsNull ()) {
61
61
// BRepTools::Write(shape, "DVPgetShape.brep"); //debug
62
- if (shape.ShapeType () > TopAbs_COMPSOLID) {
62
+ if (shape.ShapeType () > TopAbs_COMPSOLID) { // simple shape
63
63
sourceShapes.push_back (shape);
64
- } else {
64
+ } else { // complex shape
65
65
std::vector<TopoDS_Shape> drawable = extractDrawableShapes (shape);
66
66
if (!drawable.empty ()) {
67
67
sourceShapes.insert (sourceShapes.end (),drawable.begin (),drawable.end ());
@@ -98,6 +98,7 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector<App::DocumentObject*> l
98
98
99
99
std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject (const App::DocumentObject* docObj)
100
100
{
101
+ // Base::Console().Message("SE::getShapesFromObject(%s)\n", docObj->getNameInDocument());
101
102
std::vector<TopoDS_Shape> result;
102
103
103
104
const App::GroupExtension* gex = dynamic_cast <const App::GroupExtension*>(docObj);
@@ -146,6 +147,7 @@ std::vector<TopoDS_Shape> ShapeExtractor::getShapesFromObject(const App::Documen
146
147
147
148
TopoDS_Shape ShapeExtractor::getShapesFused (const std::vector<App::DocumentObject*> links)
148
149
{
150
+ // Base::Console().Message("SE::getShapesFused()\n");
149
151
TopoDS_Shape baseShape = getShapes (links);
150
152
if (!baseShape.IsNull ()) {
151
153
TopoDS_Iterator it (baseShape);
@@ -166,20 +168,56 @@ TopoDS_Shape ShapeExtractor::getShapesFused(const std::vector<App::DocumentObjec
166
168
return baseShape;
167
169
}
168
170
169
- std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes (const TopoDS_Shape shapeIn)
171
+ std::vector<TopoDS_Shape> ShapeExtractor::extractDrawableShapes (const TopoDS_Shape shapeIn)
170
172
{
171
- // this pulls solids out of compound
172
- // should it pull Shells, Faces, Wires, Edges, Vertexes too???
173
+ // Base::Console().Message("SE::extractDrawableShapes()\n");
173
174
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
176
179
TopExp_Explorer expSolid (shapeIn, TopAbs_SOLID);
177
180
for (int i = 1 ; expSolid.More (); expSolid.Next (), i++) {
178
181
TopoDS_Solid s = TopoDS::Solid (expSolid.Current ());
179
182
if (!s.IsNull ()) {
180
- result .push_back (s);
183
+ extShapes .push_back (s);
181
184
}
182
185
}
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));
183
221
}
184
222
return result;
185
223
}
0 commit comments