Don't copy occ shape in OCCGeometry ctor by default

This commit is contained in:
mhochsteger@cerbsim.com 2021-11-05 20:26:43 +01:00
parent 0da6aeb94f
commit 239cdf694f
3 changed files with 22 additions and 9 deletions

View File

@ -52,17 +52,30 @@
namespace netgen
{
void LoadOCCInto(OCCGeometry* occgeo, const char* filename);
void PrintContents (OCCGeometry * geom);
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, int aoccdim)
OCCGeometry::OCCGeometry(const TopoDS_Shape& _shape, int aoccdim, bool copy)
{
auto filename = GetTempFilename();
step_utils::WriteSTEP(_shape, filename.c_str());
LoadOCCInto(this, filename.c_str());
occdim = aoccdim;
std::remove(filename.c_str());
if(copy)
{
auto filename = GetTempFilename();
step_utils::WriteSTEP(_shape, filename.c_str());
LoadOCCInto(this, filename.c_str());
occdim = aoccdim;
std::remove(filename.c_str());
}
else
{
shape = _shape;
changed = 1;
occdim = aoccdim;
BuildFMap();
CalcBoundingBox();
PrintContents (this);
}
}
string STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader)

View File

@ -298,7 +298,7 @@ namespace netgen
vmap.Clear();
}
OCCGeometry(const TopoDS_Shape& _shape, int aoccdim = 3);
OCCGeometry(const TopoDS_Shape& _shape, int aoccdim = 3, bool copy = false);
Mesh::GEOM_TYPE GetGeomType() const override
{ return Mesh::GEOM_OCC; }

View File

@ -126,7 +126,7 @@ 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, int occdim)
.def(py::init([] (const TopoDS_Shape& shape, int occdim, bool copy)
{
auto geo = make_shared<OCCGeometry> (shape, occdim);
// ng_geometry = geo;
@ -134,7 +134,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
// geo->BuildFMap();
// geo->CalcBoundingBox();
return geo;
}), py::arg("shape"), py::arg("dim")=3,
}), py::arg("shape"), py::arg("dim")=3, py::arg("copy")=false,
"Create Netgen OCCGeometry from existing TopoDS_Shape")
.def(py::init([] (const std::vector<TopoDS_Shape> shapes)