| 187 | } |
| 188 | |
| 189 | static 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 | |
| 232 | static 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()); |
no test coverage detected