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), std::vector<OCCIdentification>> OCCGeometry::identifications;
OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape)
OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape, int aoccdim)
{
shape = _shape;
occdim = aoccdim;
changed = true;
BuildFMap();
CalcBoundingBox();

View File

@ -241,7 +241,6 @@ namespace netgen
{
Point<3> center;
OCCParameters occparam;
public:
static std::map<Handle(TopoDS_TShape), ShapeProperties> global_shape_properties;
static std::map<Handle(TopoDS_TShape), std::vector<OCCIdentification>> identifications;
@ -286,6 +285,8 @@ namespace netgen
bool sewfaces;
bool makesolids;
bool splitpartitions;
int occdim = 3; // meshing is always done 3D, changed to 2D later of occdim=2
OCCGeometry()
{
@ -297,7 +298,7 @@ namespace netgen
vmap.Clear();
}
OCCGeometry(const TopoDS_Shape& _shape);
OCCGeometry(const TopoDS_Shape& _shape, int aoccdim = 3);
Mesh::GEOM_TYPE GetGeomType() const override
{ 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"),
"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;
// geo->BuildFMap();
// geo->CalcBoundingBox();
return geo;
}), py::arg("shape"),
}), py::arg("shape"), py::arg("dim")=3,
"Create Netgen OCCGeometry from existing TopoDS_Shape")
.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);
if(result != 0)
throw Exception("Meshing failed!");
if (geo->occdim==2)
mesh->SetDimension(2);
SetGlobalMesh(mesh);
ng_geometry = geo;
return mesh;