mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
Global 'Glue' function, preserve more history
This commit is contained in:
parent
e502eeee2f
commit
4da7f6ac72
@ -51,7 +51,7 @@ namespace netgen
|
|||||||
BuildFMap();
|
BuildFMap();
|
||||||
CalcBoundingBox();
|
CalcBoundingBox();
|
||||||
|
|
||||||
TopExp_Explorer e;
|
TopExp_Explorer e, exp1;
|
||||||
for (e.Init(shape, TopAbs_SOLID); e.More(); e.Next())
|
for (e.Init(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
TopoDS_Solid solid = TopoDS::Solid(e.Current());
|
TopoDS_Solid solid = TopoDS::Solid(e.Current());
|
||||||
@ -68,16 +68,15 @@ namespace netgen
|
|||||||
if (name == "")
|
if (name == "")
|
||||||
name = string("bc_") + ToString(fnames.Size());
|
name = string("bc_") + ToString(fnames.Size());
|
||||||
fnames.Append(name);
|
fnames.Append(name);
|
||||||
/*
|
|
||||||
for (exp1.Init(face, TopAbs_EDGE); exp1.More(); exp1.Next())
|
for (exp1.Init(face, TopAbs_EDGE); exp1.More(); exp1.Next())
|
||||||
{
|
{
|
||||||
TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
|
TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
|
||||||
// name = STEP_GetEntityName(edge,&reader);
|
// name = STEP_GetEntityName(edge,&reader);
|
||||||
// cout << "getname = " << name << ", mapname = " << shape_names[edge.TShape()] << endl;
|
// cout << "getname = " << name << ", mapname = " << shape_names[edge.TShape()] << endl;
|
||||||
name = shape_names[edge.TShape()];
|
name = global_shape_names[edge.TShape()];
|
||||||
occgeo->enames.Append(name);
|
enames.Append(name);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +289,17 @@ namespace netgen
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Handle(BRepTools_History) history = aBuilder.History ();
|
||||||
|
|
||||||
|
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
|
{
|
||||||
|
auto name = OCCGeometry::global_shape_names[e.Current().TShape()];
|
||||||
|
for (auto mods : history->Modified(e.Current()))
|
||||||
|
OCCGeometry::global_shape_names[mods.TShape()] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// result of the operation
|
// result of the operation
|
||||||
shape = aBuilder.Shape();
|
shape = aBuilder.Shape();
|
||||||
BuildFMap();
|
BuildFMap();
|
||||||
|
@ -341,16 +341,18 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
for (TopExp_Explorer e(shape1, TopAbs_FACE); e.More(); e.Next())
|
for (TopExp_Explorer e(shape1, TopAbs_FACE); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
const string & name = OCCGeometry::global_shape_names[e.Current().TShape()];
|
const string & name = OCCGeometry::global_shape_names[e.Current().TShape()];
|
||||||
TopTools_ListOfShape modlist = history->Modified(e.Current());
|
// TopTools_ListOfShape modlist = history->Modified(e.Current());
|
||||||
for (auto s : modlist)
|
// for (auto s : modlist)
|
||||||
|
for (auto s : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_names[s.TShape()] = name;
|
OCCGeometry::global_shape_names[s.TShape()] = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TopExp_Explorer e(shape2, TopAbs_FACE); e.More(); e.Next())
|
for (TopExp_Explorer e(shape2, TopAbs_FACE); e.More(); e.Next())
|
||||||
{
|
{
|
||||||
const string & name = OCCGeometry::global_shape_names[e.Current().TShape()];
|
const string & name = OCCGeometry::global_shape_names[e.Current().TShape()];
|
||||||
TopTools_ListOfShape modlist = history->Modified(e.Current());
|
// TopTools_ListOfShape modlist = history->Modified(e.Current());
|
||||||
for (auto s : modlist)
|
// for (auto s : modlist)
|
||||||
|
for (auto s : history->Modified(e.Current()))
|
||||||
OCCGeometry::global_shape_names[s.TShape()] = name;
|
OCCGeometry::global_shape_names[s.TShape()] = name;
|
||||||
}
|
}
|
||||||
#endif // OCC_HAVE_HISTORY
|
#endif // OCC_HAVE_HISTORY
|
||||||
@ -375,16 +377,66 @@ DLL_HEADER void ExportNgOCC(py::module &m)
|
|||||||
m.def("Box", [] (gp_Pnt cp1, gp_Pnt cp2) {
|
m.def("Box", [] (gp_Pnt cp1, gp_Pnt cp2) {
|
||||||
return BRepPrimAPI_MakeBox (cp1, cp2).Shape();
|
return BRepPrimAPI_MakeBox (cp1, cp2).Shape();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m.def("Glue", [] (const std::vector<TopoDS_Shape> shapes) -> TopoDS_Shape
|
||||||
|
{
|
||||||
|
BOPAlgo_Builder builder;
|
||||||
|
for (auto & s : shapes)
|
||||||
|
for (TopExp_Explorer e(s, TopAbs_SOLID); e.More(); e.Next())
|
||||||
|
builder.AddArgument(e.Current());
|
||||||
|
|
||||||
|
builder.Perform();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.Shape();
|
||||||
|
});
|
||||||
|
|
||||||
|
m.def("Glue", [] (TopoDS_Shape shape) -> TopoDS_Shape
|
||||||
|
{
|
||||||
|
BOPAlgo_Builder builder;
|
||||||
|
|
||||||
|
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
|
builder.AddArgument(e.Current());
|
||||||
|
|
||||||
|
builder.Perform();
|
||||||
|
|
||||||
|
if (builder.HasErrors())
|
||||||
|
builder.DumpErrors(cout);
|
||||||
|
if (builder.HasWarnings())
|
||||||
|
builder.DumpWarnings(cout);
|
||||||
|
|
||||||
|
Handle(BRepTools_History) history = builder.History ();
|
||||||
|
|
||||||
|
for (TopExp_Explorer e(shape, TopAbs_SOLID); e.More(); e.Next())
|
||||||
|
{
|
||||||
|
auto name = OCCGeometry::global_shape_names[e.Current().TShape()];
|
||||||
|
for (auto mods : history->Modified(e.Current()))
|
||||||
|
OCCGeometry::global_shape_names[mods.TShape()] = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.Shape();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
m.def("LoadOCCGeometry",[] (const string & filename)
|
m.def("LoadOCCGeometry",[] (const string & filename)
|
||||||
{
|
{
|
||||||
cout << "WARNING: LoadOCCGeometry is deprecated! Just use the OCCGeometry(filename) constructor. It is able to read brep and iges files as well!" << endl;
|
cout << "WARNING: LoadOCCGeometry is deprecated! Just use the OCCGeometry(filename) constructor. It is able to read brep and iges files as well!" << endl;
|
||||||
ifstream ist(filename);
|
ifstream ist(filename);
|
||||||
OCCGeometry * instance = new OCCGeometry();
|
OCCGeometry * instance = new OCCGeometry();
|
||||||
instance = LoadOCC_STEP(filename.c_str());
|
instance = LoadOCC_STEP(filename.c_str());
|
||||||
ng_geometry = shared_ptr<OCCGeometry>(instance, NOOP_Deleter);
|
ng_geometry = shared_ptr<OCCGeometry>(instance, NOOP_Deleter);
|
||||||
return ng_geometry;
|
return ng_geometry;
|
||||||
},py::call_guard<py::gil_scoped_release>());
|
},py::call_guard<py::gil_scoped_release>());
|
||||||
|
|
||||||
|
|
||||||
m.def("TestXCAF", [] (TopoDS_Shape shape) {
|
m.def("TestXCAF", [] (TopoDS_Shape shape) {
|
||||||
|
Loading…
Reference in New Issue
Block a user