From 157b246f7f7826355a81dd5abb2a488fa5cf78a6 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Sat, 24 Jul 2021 13:14:21 +0200 Subject: [PATCH] occ: box, cyl --- libsrc/occ/occgenmesh.cpp | 3 ++- libsrc/occ/occgeom.hpp | 3 ++- libsrc/occ/python_occ.cpp | 26 ++++++++++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/libsrc/occ/occgenmesh.cpp b/libsrc/occ/occgenmesh.cpp index bfc2aefd..5b024b62 100644 --- a/libsrc/occ/occgenmesh.cpp +++ b/libsrc/occ/occgenmesh.cpp @@ -642,7 +642,8 @@ namespace netgen Box<3> bb = geom.GetBoundingBox(); - int projecttype = PLANESPACE; + // int projecttype = PLANESPACE; + int projecttype = PARAMETERSPACE; static Timer tinit("init"); tinit.Start(); diff --git a/libsrc/occ/occgeom.hpp b/libsrc/occ/occgeom.hpp index 82f77f6b..1ecef3b2 100644 --- a/libsrc/occ/occgeom.hpp +++ b/libsrc/occ/occgeom.hpp @@ -290,7 +290,8 @@ namespace netgen Point<3> & newp, PointGeomInfo & newgi) const override; void BuildFMap(); - + + auto GetShape() const { return shape; } Box<3> GetBoundingBox() const { return boundingbox; } diff --git a/libsrc/occ/python_occ.cpp b/libsrc/occ/python_occ.cpp index b0390976..6cbb60f9 100644 --- a/libsrc/occ/python_occ.cpp +++ b/libsrc/occ/python_occ.cpp @@ -8,9 +8,15 @@ #include #include #include +#include #include +#include +#include #include #include +#include + + using namespace netgen; @@ -206,6 +212,7 @@ DLL_HEADER void ExportNgOCC(py::module &m) }, py::arg("mp") = nullptr, py::call_guard(), (meshingparameter_description + occparameter_description).c_str()) + .def_property_readonly("shape", [](const OCCGeometry & self) { return self.GetShape(); }) ; py::enum_(m, "TopAbs_ShapeEnum", "Enumeration of all supported TopoDS_Shapes") @@ -238,14 +245,17 @@ DLL_HEADER void ExportNgOCC(py::module &m) { // https://dev.opencascade.org/doc/occt-7.3.0/overview/html/occt_user_guides__boolean_operations.html#occt_algorithms_10a BOPAlgo_MakerVolume aMV; - // BOPAlgo_Section aMV; - // BOPAlgo_Builder aBuilder; + // BOPAlgo_Section aMV; // only vertices + edges + // BOPAlgo_Builder aMV; + // BRepAlgoAPI_Cut aMV; TopTools_ListOfShape aLSObjects; aLSObjects.Append (shape1); aLSObjects.Append (shape2); // aBuilder.SetArguments(aLSObjects); aMV.SetArguments(aLSObjects); + // aMV.SetIntersect(true); aMV.Perform(); + // aMV.Build(); return aMV.Shape(); }); ; @@ -255,6 +265,18 @@ DLL_HEADER void ExportNgOCC(py::module &m) gp_Pnt cc { py::cast (c[0]), py::cast(c[1]), py::cast(c[2]) }; return BRepPrimAPI_MakeSphere (cc, r).Shape(); }); + m.def("Cylinder", [] (py::tuple pnt, py::tuple dir, double r, double h) + { + gp_Pnt cpnt { py::cast (pnt[0]), py::cast(pnt[1]), py::cast(pnt[2]) }; + gp_Dir cdir { py::cast (dir[0]), py::cast(dir[1]), py::cast(dir[2]) }; + return BRepPrimAPI_MakeCylinder (gp_Ax2(cpnt, cdir), r, h).Shape(); + }); + m.def("Box", [] (py::tuple p1, py::tuple p2) + { + gp_Pnt cp1 { py::cast (p1[0]), py::cast(p1[1]), py::cast(p1[2]) }; + gp_Pnt cp2 { py::cast (p2[0]), py::cast(p2[1]), py::cast(p2[2]) }; + return BRepPrimAPI_MakeBox (cp1, cp2).Shape(); + }); m.def("LoadOCCGeometry",[] (const string & filename) {