Added glueing to OCC interface, geom.Glue() from Python

This commit is contained in:
Joachim Schöberl 2020-05-31 21:58:21 +02:00
parent ad525cbfb9
commit dc15e50956
3 changed files with 84 additions and 1 deletions

View File

@ -169,8 +169,89 @@ namespace netgen
}
void OCCGeometry :: GlueGeometry()
{
PrintMessage(1, "OCC Glue Geometry");
/*
//
BRep_Builder builder;
TopoDS_Shape my_fuse;
int cnt = 0;
for (TopExp_Explorer exp_solid(shape, TopAbs_SOLID); exp_solid.More(); exp_solid.Next())
{
cout << "cnt = " << cnt << endl;
if (cnt == 0)
my_fuse = exp_solid.Current();
else
// my_fuse = BRepAlgoAPI_Fuse (my_fuse, exp_solid.Current());
my_fuse = QANewModTopOpe_Glue::QANewModTopOpe_Glue(my_fuse, exp_solid.Current());
cnt++;
}
cout << "remove" << endl;
// for (int i = 1; i <= somap.Size(); i++)
// builder.Remove (shape, somap(i));
cout << "now add" << endl;
// builder.Add (shape, my_fuse);
shape = my_fuse;
cout << "build fmap" << endl;
BuildFMap();
*/
// from
// https://www.opencascade.com/doc/occt-7.4.0/overview/html/occt_user_guides__boolean_operations.html
BOPAlgo_Builder aBuilder;
// Setting arguments
TopTools_ListOfShape aLSObjects;
for (TopExp_Explorer exp_solid(shape, TopAbs_SOLID); exp_solid.More(); exp_solid.Next())
aLSObjects.Append (exp_solid.Current());
aBuilder.SetArguments(aLSObjects);
// Setting options for GF
// Set parallel processing mode (default is false)
// Standard_Boolean bRunParallel = Standard_True;
// aBuilder.SetRunParallel(bRunParallel);
// Set Fuzzy value (default is Precision::Confusion())
// Standard_Real aFuzzyValue = 1.e-5;
// aBuilder.SetFuzzyValue(aFuzzyValue);
// Set safe processing mode (default is false)
// Standard_Boolean bSafeMode = Standard_True;
// aBuilder.SetNonDestructive(bSafeMode);
// Set Gluing mode for coinciding arguments (default is off)
// BOPAlgo_GlueEnum aGlue = BOPAlgo_GlueShift;
// aBuilder.SetGlue(aGlue);
// Disabling/Enabling the check for inverted solids (default is true)
// Standard Boolean bCheckInverted = Standard_False;
// aBuilder.SetCheckInverted(bCheckInverted);
// Set OBB usage (default is false)
// Standard_Boolean bUseOBB = Standard_True;
// aBuilder.SetUseOBB(buseobb);
// Perform the operation
aBuilder.Perform();
// Check for the errors
if (aBuilder.HasErrors())
{
cout << "builder has errors" << endl;
return;
}
// Check for the warnings
if (aBuilder.HasWarnings())
{
// treatment of the warnings
;
}
// result of the operation
shape = aBuilder.Shape();
BuildFMap();
}
void OCCGeometry :: HealGeometry ()
{
int nrc = 0, nrcs = 0,

View File

@ -78,7 +78,7 @@
#include "Bnd_Box.hxx"
#include "ShapeAnalysis.hxx"
#include "ShapeBuild_ReShape.hxx"
#include "BOPAlgo_Builder.hxx"
// Philippose - 29/01/2009
// OpenCascade XDE Support
@ -343,6 +343,7 @@ namespace netgen
void MakeSolid();
void HealGeometry();
void GlueGeometry();
// Philippose - 15/01/2009
// Sets the maximum mesh size for a given face

View File

@ -66,6 +66,7 @@ DLL_HEADER void ExportNgOCC(py::module &m)
}), py::arg("filename"),
"Load OCC geometry from step, brep or iges file")
.def(NGSPickle<OCCGeometry>())
.def("Glue", &OCCGeometry::GlueGeometry)
.def("Heal",[](OCCGeometry & self, double tolerance, bool fixsmalledges, bool fixspotstripfaces, bool sewfaces, bool makesolids, bool splitpartitions)
{
self.tolerance = tolerance;