From 27aaae9fb54310b12681437f1aca3a8f8f6a4b61 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Wed, 10 Aug 2022 07:45:30 +0200 Subject: [PATCH] add solid -> faces map in renderData of occ geom --- libsrc/occ/python_occ_shapes.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 9ee9d6ab..4aa2e040 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1177,15 +1177,18 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) std::vector p[3]; std::vector n[3]; - py::list names, colors; + py::list names, colors, solid_names; + std::vector> solid_face_map; int index = 0; Box<3> box(Box<3>::EMPTY_BOX); + TopTools_IndexedMapOfShape fmap; for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next()) { TopoDS_Face face = TopoDS::Face(e.Current()); // Handle(TopoDS_Face) face = e.Current(); + fmap.Add(face); ExtractFaceData(face, index, p, n, box); auto & props = OCCGeometry::global_shape_properties[face.TShape()]; if(props.col) @@ -1204,6 +1207,19 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) index++; } + for(auto& solid : GetSolids(shape)) + { + std::vector faces; + for(auto& face : GetFaces(solid)) + faces.push_back(fmap.FindIndex(face)-1); + solid_face_map.push_back(move(faces)); + auto& props = OCCGeometry::global_shape_properties[solid.TShape()]; + if(props.name) + solid_names.append(*props.name); + else + solid_names.append(""); + } + std::vector edge_p[2]; py::list edge_names, edge_colors; index = 0; @@ -1263,6 +1279,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) data["autoscale"] = false; data["colors"] = colors; data["names"] = names; + data["solid_names"] = solid_names; py::list edges; edges.append(edge_p[0]); @@ -1270,6 +1287,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) data["edges"] = edges; data["edge_names"] = edge_names; data["edge_colors"] = edge_colors; + data["solid_face_map"] = solid_face_map; return data; }) ;