mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
pywrapping occ
This commit is contained in:
parent
057d6a4ed4
commit
56e848eea9
@ -225,6 +225,27 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
.export_values()
|
.export_values()
|
||||||
;
|
;
|
||||||
|
|
||||||
|
py::class_<gp_Pnt>(m, "gp_Pnt")
|
||||||
|
.def(py::init([] (py::tuple pnt)
|
||||||
|
{
|
||||||
|
return gp_Pnt(py::cast<double>(pnt[0]),
|
||||||
|
py::cast<double>(pnt[1]),
|
||||||
|
py::cast<double>(pnt[2]));
|
||||||
|
}))
|
||||||
|
;
|
||||||
|
|
||||||
|
py::class_<gp_Dir>(m, "gp_Dir")
|
||||||
|
.def(py::init([] (py::tuple dir)
|
||||||
|
{
|
||||||
|
return gp_Dir(py::cast<double>(dir[0]),
|
||||||
|
py::cast<double>(dir[1]),
|
||||||
|
py::cast<double>(dir[2]));
|
||||||
|
}))
|
||||||
|
;
|
||||||
|
py::implicitly_convertible<py::tuple, gp_Pnt>();
|
||||||
|
py::implicitly_convertible<py::tuple, gp_Dir>();
|
||||||
|
|
||||||
|
|
||||||
py::class_<TopoDS_Shape> (m, "TopoDS_Shape")
|
py::class_<TopoDS_Shape> (m, "TopoDS_Shape")
|
||||||
.def("__str__", [] (const TopoDS_Shape & shape)
|
.def("__str__", [] (const TopoDS_Shape & shape)
|
||||||
{
|
{
|
||||||
@ -246,7 +267,19 @@ 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
|
// https://dev.opencascade.org/doc/occt-7.3.0/overview/html/occt_user_guides__boolean_operations.html#occt_algorithms_10a
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
choose boolean operation:
|
||||||
|
https://uma.ensta-paris.fr/soft/XLiFE++/?module=doc&action=source&set=release&file=OpenCascade_8cpp_source.html
|
||||||
|
BRepAlgoAPI_BooleanOperation bop;
|
||||||
|
bop.SetArguments(args); bop.SetTools(tools);
|
||||||
|
bop.SetOperation(BOPAlgo_FUSE);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOPAlgo_MakerVolume aMV;
|
BOPAlgo_MakerVolume aMV;
|
||||||
|
// aMV.SetOperation(BOPAlgo_CUT);
|
||||||
// BOPAlgo_Section aMV; // only vertices + edges
|
// BOPAlgo_Section aMV; // only vertices + edges
|
||||||
// BOPAlgo_Builder aMV;
|
// BOPAlgo_Builder aMV;
|
||||||
// BRepAlgoAPI_Cut aMV;
|
// BRepAlgoAPI_Cut aMV;
|
||||||
@ -256,7 +289,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
// aBuilder.SetArguments(aLSObjects);
|
// aBuilder.SetArguments(aLSObjects);
|
||||||
aMV.SetArguments(aLSObjects);
|
aMV.SetArguments(aLSObjects);
|
||||||
// aMV.SetIntersect(true);
|
// aMV.SetIntersect(true);
|
||||||
aMV.Perform();
|
aMV.Perform(); // howto perform BOPAlgo_CUT ???
|
||||||
// aMV.Build();
|
// aMV.Build();
|
||||||
return aMV.Shape();
|
return aMV.Shape();
|
||||||
|
|
||||||
@ -275,21 +308,15 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
});
|
});
|
||||||
;
|
;
|
||||||
|
|
||||||
m.def("Sphere", [] (py::tuple c, double r)
|
m.def("Sphere", [] (gp_Pnt cc, double r) {
|
||||||
{
|
|
||||||
gp_Pnt cc { py::cast<double> (c[0]), py::cast<double>(c[1]), py::cast<double>(c[2]) };
|
|
||||||
return BRepPrimAPI_MakeSphere (cc, r).Shape();
|
return BRepPrimAPI_MakeSphere (cc, r).Shape();
|
||||||
});
|
});
|
||||||
m.def("Cylinder", [] (py::tuple pnt, py::tuple dir, double r, double h)
|
|
||||||
{
|
m.def("Cylinder", [] (gp_Pnt cpnt, gp_Dir cdir, double r, double h) {
|
||||||
gp_Pnt cpnt { py::cast<double> (pnt[0]), py::cast<double>(pnt[1]), py::cast<double>(pnt[2]) };
|
|
||||||
gp_Dir cdir { py::cast<double> (dir[0]), py::cast<double>(dir[1]), py::cast<double>(dir[2]) };
|
|
||||||
return BRepPrimAPI_MakeCylinder (gp_Ax2(cpnt, cdir), r, h).Shape();
|
return BRepPrimAPI_MakeCylinder (gp_Ax2(cpnt, cdir), r, h).Shape();
|
||||||
});
|
});
|
||||||
m.def("Box", [] (py::tuple p1, py::tuple p2)
|
|
||||||
{
|
m.def("Box", [] (gp_Pnt cp1, gp_Pnt cp2) {
|
||||||
gp_Pnt cp1 { py::cast<double> (p1[0]), py::cast<double>(p1[1]), py::cast<double>(p1[2]) };
|
|
||||||
gp_Pnt cp2 { py::cast<double> (p2[0]), py::cast<double>(p2[1]), py::cast<double>(p2[2]) };
|
|
||||||
return BRepPrimAPI_MakeBox (cp1, cp2).Shape();
|
return BRepPrimAPI_MakeBox (cp1, cp2).Shape();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2407,7 +2407,7 @@
|
|||||||
],
|
],
|
||||||
"ne1d": 666,
|
"ne1d": 666,
|
||||||
"ne2d": 4880,
|
"ne2d": 4880,
|
||||||
"ne3d": 31729,
|
"ne3d": 31724,
|
||||||
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 2, 7, 22, 105, 239, 652, 1497, 3032, 4913, 6571, 7208, 5276, 1715]",
|
"quality_histogram": "[0, 0, 0, 0, 0, 0, 0, 2, 7, 22, 105, 239, 652, 1497, 3032, 4913, 6571, 7208, 5276, 1715]",
|
||||||
"total_badness": 38119.574769
|
"total_badness": 38119.574769
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user