mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-12 14:10:34 +05:00
occ material, copy names from step-loading to global names
This commit is contained in:
parent
f3caa7182a
commit
7e0f0326de
@ -1556,6 +1556,9 @@ namespace netgen
|
|||||||
// cout << "name = " << pair.second << endl;
|
// cout << "name = " << pair.second << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto [s,n] : shape_names)
|
||||||
|
OCCGeometry::global_shape_names[s] = n;
|
||||||
|
|
||||||
|
|
||||||
timer_getnames.Start();
|
timer_getnames.Start();
|
||||||
for (exp0.Init(occgeo->shape, TopAbs_SOLID); exp0.More(); exp0.Next())
|
for (exp0.Init(occgeo->shape, TopAbs_SOLID); exp0.More(); exp0.Next())
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <BRepAlgoAPI_Cut.hxx>
|
#include <BRepAlgoAPI_Cut.hxx>
|
||||||
#include <BRepAlgoAPI_Common.hxx>
|
#include <BRepAlgoAPI_Common.hxx>
|
||||||
#include <BRepAlgoAPI_Fuse.hxx>
|
#include <BRepAlgoAPI_Fuse.hxx>
|
||||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
// #include <XCAFDoc_VisMaterialTool.hxx>
|
||||||
#include <TDF_Attribute.hxx>
|
#include <TDF_Attribute.hxx>
|
||||||
#include <Standard_GUID.hxx>
|
#include <Standard_GUID.hxx>
|
||||||
|
|
||||||
@ -70,31 +70,36 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
auto geo = make_shared<OCCGeometry> (shape);
|
auto geo = make_shared<OCCGeometry> (shape);
|
||||||
ng_geometry = geo;
|
ng_geometry = geo;
|
||||||
|
|
||||||
geo->BuildFMap();
|
// geo->BuildFMap();
|
||||||
geo->CalcBoundingBox();
|
// geo->CalcBoundingBox();
|
||||||
return geo;
|
return geo;
|
||||||
}), py::arg("shape"),
|
}), py::arg("shape"),
|
||||||
"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)
|
||||||
{
|
{
|
||||||
BOPAlgo_Builder aBuilder;
|
cout << "start gluing" << endl;
|
||||||
|
BOPAlgo_Builder builder;
|
||||||
// Setting arguments
|
|
||||||
TopTools_ListOfShape aLSObjects;
|
|
||||||
/*
|
|
||||||
for (TopExp_Explorer exp_solid(shape, TopAbs_SOLID); exp_solid.More(); exp_solid.Next())
|
|
||||||
aLSObjects.Append (exp_solid.Current());
|
|
||||||
*/
|
|
||||||
for (auto & s : shapes)
|
for (auto & s : shapes)
|
||||||
aLSObjects.Append (s);
|
builder.AddArgument(s);
|
||||||
aBuilder.SetArguments(aLSObjects);
|
builder.Perform();
|
||||||
aBuilder.Perform();
|
cout << "glued together" << endl;
|
||||||
|
|
||||||
auto geo = make_shared<OCCGeometry> (aBuilder.Shape());
|
Handle(BRepTools_History) history = builder.History ();
|
||||||
|
|
||||||
|
for (auto & s : shapes)
|
||||||
|
for (TopExp_Explorer e(s, TopAbs_SOLID); e.More(); e.Next())
|
||||||
|
{
|
||||||
|
auto name = OCCGeometry::global_shape_names[e.Current().TShape()];
|
||||||
|
TopTools_ListOfShape modlist = history->Modified(e.Current());
|
||||||
|
for (auto mods : modlist)
|
||||||
|
OCCGeometry::global_shape_names[mods.TShape()] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto geo = make_shared<OCCGeometry> (builder.Shape());
|
||||||
ng_geometry = geo;
|
ng_geometry = geo;
|
||||||
geo->BuildFMap();
|
// geo->BuildFMap();
|
||||||
geo->CalcBoundingBox();
|
// geo->CalcBoundingBox();
|
||||||
return geo;
|
return geo;
|
||||||
}), py::arg("shape"),
|
}), py::arg("shape"),
|
||||||
"Create Netgen OCCGeometry from existing TopoDS_Shape")
|
"Create Netgen OCCGeometry from existing TopoDS_Shape")
|
||||||
@ -291,8 +296,14 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
|
|
||||||
.def("bc", [](const TopoDS_Shape & shape, const string & name)
|
.def("bc", [](const TopoDS_Shape & shape, const string & name)
|
||||||
{
|
{
|
||||||
TopExp_Explorer e;
|
for (TopExp_Explorer e(shape, TopAbs_FACE); e.More(); e.Next())
|
||||||
for (e.Init(shape, TopAbs_FACE); e.More(); e.Next())
|
OCCGeometry::global_shape_names[e.Current().TShape()] = name;
|
||||||
|
return shape;
|
||||||
|
})
|
||||||
|
|
||||||
|
.def("mat", [](const TopoDS_Shape & shape, const string & name)
|
||||||
|
{
|
||||||
|
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
OCCGeometry::global_shape_names[e.Current().TShape()] = name;
|
OCCGeometry::global_shape_names[e.Current().TShape()] = name;
|
||||||
return shape;
|
return shape;
|
||||||
})
|
})
|
||||||
@ -378,7 +389,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
app->NewDocument ("STEP-XCAF",doc);
|
app->NewDocument ("STEP-XCAF",doc);
|
||||||
Handle(XCAFDoc_ShapeTool) shape_tool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
|
Handle(XCAFDoc_ShapeTool) shape_tool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
|
||||||
Handle(XCAFDoc_MaterialTool) material_tool = XCAFDoc_DocumentTool::MaterialTool(doc->Main());
|
Handle(XCAFDoc_MaterialTool) material_tool = XCAFDoc_DocumentTool::MaterialTool(doc->Main());
|
||||||
Handle(XCAFDoc_VisMaterialTool) vismaterial_tool = XCAFDoc_DocumentTool::VisMaterialTool(doc->Main());
|
// Handle(XCAFDoc_VisMaterialTool) vismaterial_tool = XCAFDoc_DocumentTool::VisMaterialTool(doc->Main());
|
||||||
|
|
||||||
cout << "handle(shape) = " << *(void**)(void*)(&(shape.TShape())) << endl;
|
cout << "handle(shape) = " << *(void**)(void*)(&(shape.TShape())) << endl;
|
||||||
|
|
||||||
@ -415,7 +426,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
|
|
||||||
// cout << "findshape = " << shape_tool -> FindShape(shape) << endl;
|
// cout << "findshape = " << shape_tool -> FindShape(shape) << endl;
|
||||||
cout << "IsMaterial = " << material_tool->IsMaterial(label) << endl;
|
cout << "IsMaterial = " << material_tool->IsMaterial(label) << endl;
|
||||||
cout << "IsVisMaterial = " << vismaterial_tool->IsMaterial(label) << endl;
|
// cout << "IsVisMaterial = " << vismaterial_tool->IsMaterial(label) << endl;
|
||||||
}
|
}
|
||||||
}, py::arg("shape")=TopoDS_Shape());
|
}, py::arg("shape")=TopoDS_Shape());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user