OCCGeometry(shape, dim=2) will generate 2D mesh (materials+bc)

This commit is contained in:
Joachim Schoeberl 2021-09-09 13:19:34 +02:00
parent 9b3578740f
commit 93d3a7ce4b
3 changed files with 10 additions and 6 deletions

View File

@ -46,9 +46,10 @@ namespace netgen
std::map<Handle(TopoDS_TShape), ShapeProperties> OCCGeometry::global_shape_properties; std::map<Handle(TopoDS_TShape), ShapeProperties> OCCGeometry::global_shape_properties;
std::map<Handle(TopoDS_TShape), std::vector<OCCIdentification>> OCCGeometry::identifications; std::map<Handle(TopoDS_TShape), std::vector<OCCIdentification>> OCCGeometry::identifications;
OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape) OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape, int aoccdim)
{ {
shape = _shape; shape = _shape;
occdim = aoccdim;
changed = true; changed = true;
BuildFMap(); BuildFMap();
CalcBoundingBox(); CalcBoundingBox();

View File

@ -241,7 +241,6 @@ namespace netgen
{ {
Point<3> center; Point<3> center;
OCCParameters occparam; OCCParameters occparam;
public: public:
static std::map<Handle(TopoDS_TShape), ShapeProperties> global_shape_properties; static std::map<Handle(TopoDS_TShape), ShapeProperties> global_shape_properties;
static std::map<Handle(TopoDS_TShape), std::vector<OCCIdentification>> identifications; static std::map<Handle(TopoDS_TShape), std::vector<OCCIdentification>> identifications;
@ -287,6 +286,8 @@ namespace netgen
bool makesolids; bool makesolids;
bool splitpartitions; bool splitpartitions;
int occdim = 3; // meshing is always done 3D, changed to 2D later of occdim=2
OCCGeometry() OCCGeometry()
{ {
somap.Clear(); somap.Clear();
@ -297,7 +298,7 @@ namespace netgen
vmap.Clear(); vmap.Clear();
} }
OCCGeometry(const TopoDS_Shape& _shape); OCCGeometry(const TopoDS_Shape& _shape, int aoccdim = 3);
Mesh::GEOM_TYPE GetGeomType() const override Mesh::GEOM_TYPE GetGeomType() const override
{ return Mesh::GEOM_OCC; } { return Mesh::GEOM_OCC; }

View File

@ -116,15 +116,15 @@ DLL_HEADER void ExportNgOCC(py::module &m)
.def(py::init<const TopoDS_Shape&>(), py::arg("shape"), .def(py::init<const TopoDS_Shape&>(), py::arg("shape"),
"Create Netgen OCCGeometry from existing TopoDS_Shape") "Create Netgen OCCGeometry from existing TopoDS_Shape")
*/ */
.def(py::init([] (const TopoDS_Shape& shape) .def(py::init([] (const TopoDS_Shape& shape, int occdim)
{ {
auto geo = make_shared<OCCGeometry> (shape); auto geo = make_shared<OCCGeometry> (shape, occdim);
ng_geometry = geo; ng_geometry = geo;
// geo->BuildFMap(); // geo->BuildFMap();
// geo->CalcBoundingBox(); // geo->CalcBoundingBox();
return geo; return geo;
}), py::arg("shape"), }), py::arg("shape"), py::arg("dim")=3,
"Create Netgen OCCGeometry from existing TopoDS_Shape") "Create Netgen OCCGeometry from existing TopoDS_Shape")
.def(py::init([] (const std::vector<TopoDS_Shape> shapes) .def(py::init([] (const std::vector<TopoDS_Shape> shapes)
@ -287,6 +287,8 @@ DLL_HEADER void ExportNgOCC(py::module &m)
auto result = geo->GenerateMesh(mesh, mp); auto result = geo->GenerateMesh(mesh, mp);
if(result != 0) if(result != 0)
throw Exception("Meshing failed!"); throw Exception("Meshing failed!");
if (geo->occdim==2)
mesh->SetDimension(2);
SetGlobalMesh(mesh); SetGlobalMesh(mesh);
ng_geometry = geo; ng_geometry = geo;
return mesh; return mesh;