allow quad dominated meshing of faces

This commit is contained in:
Christopher Lackner 2022-02-25 10:50:51 +01:00
parent f44c1894b8
commit d6770fda0c
3 changed files with 26 additions and 2 deletions

View File

@ -17,12 +17,14 @@ namespace netgen
optional<Vec<4>> col;
double maxh = 1e99;
double hpref = 0; // number of hp refinement levels (will be multiplied by factor later)
optional<bool> quad_dominated;
void Merge(const ShapeProperties & prop2)
{
if (!name && prop2.name) name = prop2.name;
if (!col && prop2.col) col = prop2.col;
maxh = min2(maxh, prop2.maxh);
hpref = max2(hpref, prop2.hpref);
if(!quad_dominated.has_value()) quad_dominated = prop2.quad_dominated;
}
string GetName() const { return name ? *name : "default"; }

View File

@ -198,9 +198,14 @@ namespace netgen
bool OCCGeometry :: MeshFace(Mesh& mesh,
const MeshingParameters& mparam, int nr, FlatArray<int, PointIndex> glob2loc) const
{
bool failed = OCCMeshFace(*this, mesh, glob2loc, mparam, nr, PARAMETERSPACE, true);
MeshingParameters local_mp = mparam;
auto face = TopoDS::Face(fmap(nr+1));
if(auto quad_dominated = OCCGeometry::global_shape_properties[face.TShape()].quad_dominated; quad_dominated.has_value())
local_mp.quad = *quad_dominated;
bool failed = OCCMeshFace(*this, mesh, glob2loc, local_mp, nr, PARAMETERSPACE, true);
if(failed)
failed = OCCMeshFace(*this, mesh, glob2loc, mparam, nr, PLANESPACE, false);
failed = OCCMeshFace(*this, mesh, glob2loc, local_mp, nr, PLANESPACE, false);
if(failed)
{

View File

@ -1423,6 +1423,14 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
.def(py::init([] (const TopoDS_Shape & shape) {
return TopoDS::Face(shape);
}))
.def_property("quad_dominated", [](const TopoDS_Face& self) -> optional<bool>
{
return OCCGeometry::global_shape_properties[self.TShape()].quad_dominated;
},
[](TopoDS_Face& self, optional<bool> quad_dominated)
{
OCCGeometry::global_shape_properties[self.TShape()].quad_dominated = quad_dominated;
})
.def_property_readonly("surf", [] (TopoDS_Face face) -> Handle(Geom_Surface)
{
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
@ -1642,6 +1650,15 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
val = max2(hpref, val);
}
}, "set hpref for all elements of list")
.def_property("quad_dominated", [](ListOfShapes& shapes)
{
throw Exception("Cannot get property of ListOfShapes, get the property from individual shapes!");
},
[](ListOfShapes& shapes, optional<bool> quad_dominated)
{
for(auto& shape : shapes)
OCCGeometry::global_shape_properties[shape.TShape()].quad_dominated = quad_dominated;
})
.def("Identify", py::overload_cast<const ListOfShapes&, const ListOfShapes&, string, Identifications::ID_TYPE, gp_Trsf>(&Identify),
py::arg("other"), py::arg("name"),