mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-14 10:08:32 +05:00
'Nearest' to point selector, Revolution of arbitrary shapes
This commit is contained in:
parent
60053c5e44
commit
be6dbdadbf
@ -41,6 +41,7 @@
|
|||||||
#include <BRepFilletAPI_MakeFillet.hxx>
|
#include <BRepFilletAPI_MakeFillet.hxx>
|
||||||
#include <BRepOffsetAPI_ThruSections.hxx>
|
#include <BRepOffsetAPI_ThruSections.hxx>
|
||||||
#include <BRepOffsetAPI_MakeOffset.hxx>
|
#include <BRepOffsetAPI_MakeOffset.hxx>
|
||||||
|
#include <BRepExtrema_DistShapeShape.hxx>
|
||||||
|
|
||||||
#include <BRepGProp.hxx>
|
#include <BRepGProp.hxx>
|
||||||
#include <BRepOffsetAPI_MakeThickSolid.hxx>
|
#include <BRepOffsetAPI_MakeThickSolid.hxx>
|
||||||
@ -109,6 +110,23 @@ public:
|
|||||||
}
|
}
|
||||||
return maxshape;
|
return maxshape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TopoDS_Shape Nearest(gp_Pnt pnt)
|
||||||
|
{
|
||||||
|
double mindist = 1e99;
|
||||||
|
TopoDS_Shape nearestshape;
|
||||||
|
auto vertex = BRepBuilderAPI_MakeVertex (pnt).Vertex();
|
||||||
|
|
||||||
|
for (auto shape : *this)
|
||||||
|
{
|
||||||
|
double dist = BRepExtrema_DistShapeShape(shape, vertex).Value();
|
||||||
|
// cout << "dist = " << dist << endl;
|
||||||
|
if (dist < mindist)
|
||||||
|
nearestshape = shape;
|
||||||
|
}
|
||||||
|
return nearestshape;
|
||||||
|
}
|
||||||
|
|
||||||
ListOfShapes SubShapes(TopAbs_ShapeEnum type) const
|
ListOfShapes SubShapes(TopAbs_ShapeEnum type) const
|
||||||
{
|
{
|
||||||
std::set<TopoDS_Shape, ShapeLess> unique_shapes;
|
std::set<TopoDS_Shape, ShapeLess> unique_shapes;
|
||||||
@ -1010,7 +1028,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
}, py::arg("v"), "extrude shape by vector 'v'")
|
}, py::arg("v"), "extrude shape by vector 'v'")
|
||||||
|
|
||||||
.def("Revolve", [](const TopoDS_Shape & shape, const gp_Ax1 &A, const double D) {
|
.def("Revolve", [](const TopoDS_Shape & shape, const gp_Ax1 &A, const double D) {
|
||||||
for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next())
|
// for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
// return BRepPrimAPI_MakeRevol (shape, A, D*M_PI/180).Shape();
|
// return BRepPrimAPI_MakeRevol (shape, A, D*M_PI/180).Shape();
|
||||||
BRepPrimAPI_MakeRevol builder(shape, A, D*M_PI/180);
|
BRepPrimAPI_MakeRevol builder(shape, A, D*M_PI/180);
|
||||||
@ -1025,7 +1043,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
|
|
||||||
return builder.Shape();
|
return builder.Shape();
|
||||||
}
|
}
|
||||||
throw Exception("no face found for revolve");
|
// throw Exception("no face found for revolve");
|
||||||
}, py::arg("axis"), py::arg("ang"), "revolve shape around 'axis' by 'ang' degrees")
|
}, py::arg("axis"), py::arg("ang"), "revolve shape around 'axis' by 'ang' degrees")
|
||||||
|
|
||||||
.def("Find", [](const TopoDS_Shape & shape, gp_Pnt p)
|
.def("Find", [](const TopoDS_Shape & shape, gp_Pnt p)
|
||||||
@ -1558,6 +1576,10 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
|||||||
{ return CastShape(shapes.Max(-dir)); },
|
{ return CastShape(shapes.Max(-dir)); },
|
||||||
py::arg("dir"), "returns shape where center of gravity is minimal in the direction 'dir'")
|
py::arg("dir"), "returns shape where center of gravity is minimal in the direction 'dir'")
|
||||||
|
|
||||||
|
.def("Nearest", [] (ListOfShapes & shapes, gp_Pnt pnt)
|
||||||
|
{ return CastShape(shapes.Nearest(pnt)); },
|
||||||
|
py::arg("p"), "returns shape nearest to point 'p'")
|
||||||
|
|
||||||
.def_property("name", [](ListOfShapes& shapes)
|
.def_property("name", [](ListOfShapes& shapes)
|
||||||
{
|
{
|
||||||
throw Exception("Cannot get property of ListOfShapes, get the property from individual shapes!");
|
throw Exception("Cannot get property of ListOfShapes, get the property from individual shapes!");
|
||||||
|
Loading…
Reference in New Issue
Block a user