diff --git a/libsrc/meshing/meshfunc.cpp b/libsrc/meshing/meshfunc.cpp index 6714ccf8..68dcd347 100644 --- a/libsrc/meshing/meshfunc.cpp +++ b/libsrc/meshing/meshfunc.cpp @@ -539,8 +539,9 @@ namespace netgen if (md[i].mesh->CheckOverlappingBoundary()) throw NgException ("Stop meshing since boundary mesh is overlapping"); - // TODO: FillCloseSurface is still not working with CSG closesurfaces - // FillCloseSurface( md[i] ); + // TODO: FillCloseSurface is not working with CSG closesurfaces + if(md[i].mesh->GetGeometry()->GetGeomType() == Mesh::GEOM_OCC) + FillCloseSurface( md[i] ); CloseOpenQuads( md[i] ); MeshDomain(md[i]); }); diff --git a/libsrc/occ/occgeom.cpp b/libsrc/occ/occgeom.cpp index 278b0aab..5a81f981 100644 --- a/libsrc/occ/occgeom.cpp +++ b/libsrc/occ/occgeom.cpp @@ -1995,42 +1995,46 @@ namespace netgen return true; } - void OCCGeometry :: Identify(const TopoDS_Shape & me, const TopoDS_Shape & you, string name, Identifications::ID_TYPE type, std::optional opt_trafo) + void Identify(const TopoDS_Shape & me, const TopoDS_Shape & you, string name, Identifications::ID_TYPE type, std::optional opt_trafo) { - auto type_me = me.ShapeType(); - auto type_you = you.ShapeType(); - if(type_me != type_you) - throw NgException ("Identify: cannot identify different shape types"); - - Transformation<3> trafo; + gp_Trsf trafo; if(opt_trafo) { - trafo = occ2ng(*opt_trafo); + trafo = *opt_trafo; } else { - auto cme = GetCenter(me); - auto cyou = GetCenter(you); - trafo = Transformation<3>(cyou-cme); + auto v = GetCenter(you) - GetCenter(me); + trafo.SetTranslation(gp_Vec(v[0], v[1], v[2])); } + ListOfShapes list_me, list_you; + list_me.push_back(me); + list_you.push_back(you); + Identify(list_me, list_you, name, type, trafo); + } + + void Identify(const ListOfShapes & me, const ListOfShapes & you, string name, Identifications::ID_TYPE type, gp_Trsf occ_trafo) + { + Transformation<3> trafo = occ2ng(occ_trafo); + ListOfShapes id_me; ListOfShapes id_you; - if(auto faces_me = GetFaces(me); faces_me.size()>0) + if(auto faces_me = me.Faces(); faces_me.size()>0) { id_me = faces_me; - id_you = GetFaces(you); + id_you = you.Faces(); } - else if(auto edges_me = GetEdges(me); edges_me.size()>0) + else if(auto edges_me = me.Edges(); edges_me.size()>0) { id_me = edges_me; - id_you = GetEdges(you); + id_you = you.Edges(); } else { - id_me = GetVertices(me); - id_you = GetVertices(you); + id_me = me.Vertices(); + id_you = you.Vertices(); } for(auto shape_me : id_me) @@ -2039,7 +2043,7 @@ namespace netgen if(!IsMappedShape(trafo, shape_me, shape_you)) continue; - identifications[shape_me.TShape()].push_back + OCCGeometry::identifications[shape_me.TShape()].push_back (OCCIdentification { shape_me.TShape(), shape_you.TShape(), trafo, name, type }); } } diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index e8d6a7b7..0619cb97 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -342,11 +342,13 @@ namespace netgen bool ErrorInSurfaceMeshing (); // void WriteOCC_STL(char * filename); - static void Identify(const TopoDS_Shape & me, const TopoDS_Shape & you, string name, Identifications::ID_TYPE type, std::optional opt_trafo = nullopt); private: //bool FastProject (int surfi, Point<3> & ap, double& u, double& v) const; }; + + void Identify(const ListOfShapes & me, const ListOfShapes & you, string name, Identifications::ID_TYPE type, gp_Trsf occ_trafo); + void Identify(const TopoDS_Shape & me, const TopoDS_Shape & you, string name, Identifications::ID_TYPE type, std::optional opt_trafo); void PrintContents (OCCGeometry * geom); diff --git a/libsrc/occ/python_occ_shapes.cpp b/libsrc/occ/python_occ_shapes.cpp index 46fc1b4f..178dfbc5 100644 --- a/libsrc/occ/python_occ_shapes.cpp +++ b/libsrc/occ/python_occ_shapes.cpp @@ -1080,7 +1080,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) BRepMesh_IncrementalMesh (shape, deflection, true); }) - .def("Identify", OCCGeometry::Identify, py::arg("other"), py::arg("name"), + + .def("Identify", py::overload_cast>(&Identify), + py::arg("other"), py::arg("name"), py::arg("type")=Identifications::PERIODIC, py::arg("trafo")=nullopt, "Identify shapes for periodic meshing") @@ -1625,6 +1627,11 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m) } }, "set hpref for all elements of list") + .def("Identify", py::overload_cast(&Identify), + py::arg("other"), py::arg("name"), + py::arg("type")=Identifications::PERIODIC, py::arg("trafo"), + "Identify shapes for periodic meshing") + ;