MCPcopy Create free account
hub / github.com/OpenWebCAD/node-occ / extractShape

Function extractShape

src/Tools.cc:189–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189static int extractShape(const TopoDS_Shape& shape, std::list<v8::Local<v8::Object> >& shapes)
190{
191 TopAbs_ShapeEnum type = shape.ShapeType();
192
193 if (type != TopAbs_COMPOUND) {
194 extractSubShape(shape, shapes);
195 return 0;
196 }
197
198 TopExp_Explorer ex;
199 int ret = 0;
200
201 // extract compund
202 for (ex.Init(shape, TopAbs_COMPOUND); ex.More(); ex.Next())
203 ret += extractSubShape(ex.Current(), shapes);
204
205 // extract solids
206 for (ex.Init(shape, TopAbs_COMPSOLID); ex.More(); ex.Next())
207 ret += extractSubShape(ex.Current(), shapes);
208 for (ex.Init(shape, TopAbs_SOLID); ex.More(); ex.Next())
209 ret += extractSubShape(ex.Current(), shapes);
210
211 // extract free faces
212 for (ex.Init(shape, TopAbs_SHELL, TopAbs_SOLID); ex.More(); ex.Next())
213 ret += extractSubShape(ex.Current(), shapes);
214 for (ex.Init(shape, TopAbs_FACE, TopAbs_SOLID); ex.More(); ex.Next())
215 ret += extractSubShape(ex.Current(), shapes);
216
217 // extract free wires
218 for (ex.Init(shape, TopAbs_WIRE, TopAbs_FACE); ex.More(); ex.Next())
219 ret += extractSubShape(ex.Current(), shapes);
220
221 // extract free edges
222 for (ex.Init(shape, TopAbs_EDGE, TopAbs_WIRE); ex.More(); ex.Next())
223 ret += extractSubShape(ex.Current(), shapes);
224
225 // extract free vertices
226 for (ex.Init(shape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next())
227 ret += extractSubShape(ex.Current(), shapes);
228
229 return ret;
230}
231
232static v8::Local<v8::Array> convert(std::list<v8::Local<v8::Object> > & shapes) {
233 v8::Local<v8::Array> arr = Nan::New<v8::Array>((int)shapes.size());

Callers 1

WorkCompleteMethod · 0.85

Calls 2

extractSubShapeFunction · 0.85
InitMethod · 0.45

Tested by

no test coverage detected