mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
Utility function to generate OCC shape triangulation -> always use same parameters
This commit is contained in:
parent
ebcca37714
commit
b8aa568626
@ -1,6 +1,8 @@
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRep_TVertex.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
|
||||
#include "occ_utils.hpp"
|
||||
|
||||
@ -55,4 +57,24 @@ namespace netgen
|
||||
#endif
|
||||
return {occ2ng(bb.CornerMin()), occ2ng(bb.CornerMax())};
|
||||
}
|
||||
|
||||
Standard_Integer BuildTriangulation( const TopoDS_Shape & shape )
|
||||
{
|
||||
BRepTools::Clean (shape);
|
||||
double deflection = 0.01;
|
||||
|
||||
// https://dev.opencascade.org/doc/overview/html/occt_user_guides__mesh.html
|
||||
// from Standard_Boolean meshing_imeshtools_parameters()
|
||||
IMeshTools_Parameters aMeshParams;
|
||||
aMeshParams.Deflection = 0.01;
|
||||
aMeshParams.Angle = 0.5;
|
||||
aMeshParams.Relative = Standard_False;
|
||||
aMeshParams.InParallel = Standard_True;
|
||||
aMeshParams.MinSize = Precision::Confusion();
|
||||
aMeshParams.InternalVerticesMode = Standard_True;
|
||||
aMeshParams.ControlSurfaceDeflection = Standard_True;
|
||||
|
||||
BRepMesh_IncrementalMesh aMesher (shape, aMeshParams);
|
||||
return aMesher.GetStatusFlags();
|
||||
}
|
||||
}
|
||||
|
@ -76,6 +76,8 @@ namespace netgen
|
||||
bool opposite_direction;
|
||||
};
|
||||
|
||||
Standard_Integer BuildTriangulation( const TopoDS_Shape & shape );
|
||||
|
||||
|
||||
class MyExplorer
|
||||
{
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepLProp_CLProps.hxx>
|
||||
#include <BRepLProp_SLProps.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
@ -654,6 +653,7 @@ namespace netgen
|
||||
|
||||
int nfaces = geom.fmap.Extent();
|
||||
|
||||
BuildTriangulation(geom.shape);
|
||||
for (int i = 1; i <= nfaces && !multithread.terminate; i++)
|
||||
{
|
||||
multithread.percent = 100 * (i-1)/double(nfaces);
|
||||
@ -663,29 +663,6 @@ namespace netgen
|
||||
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
|
||||
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
|
||||
|
||||
if (triangulation.IsNull())
|
||||
{
|
||||
BRepTools::Clean (geom.shape);
|
||||
// BRepMesh_IncrementalMesh (geom.shape, 0.01, true);
|
||||
|
||||
// https://dev.opencascade.org/doc/overview/html/occt_user_guides__mesh.html
|
||||
IMeshTools_Parameters aMeshParams;
|
||||
aMeshParams.Deflection = 0.01;
|
||||
aMeshParams.Angle = 0.5;
|
||||
aMeshParams.Relative = Standard_False;
|
||||
aMeshParams.InParallel = Standard_True;
|
||||
aMeshParams.MinSize = Precision::Confusion();
|
||||
aMeshParams.InternalVerticesMode = Standard_True;
|
||||
aMeshParams.ControlSurfaceDeflection = Standard_True;
|
||||
|
||||
BRepMesh_IncrementalMesh aMesher (geom.shape, aMeshParams);
|
||||
const Standard_Integer aStatus = aMesher.GetStatusFlags();
|
||||
if (aStatus != 0)
|
||||
cout << "BRepMesh_IncrementalMesh.status = " << aStatus << endl;
|
||||
|
||||
triangulation = BRep_Tool::Triangulation (face, loc);
|
||||
}
|
||||
|
||||
if(triangulation.IsNull())
|
||||
{
|
||||
if (geom.shape.Infinite())
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepOffsetAPI_Sewing.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <IGESCAFControl_Reader.hxx>
|
||||
@ -1387,12 +1386,9 @@ namespace netgen
|
||||
|
||||
void OCCGeometry :: BuildVisualizationMesh (double deflection)
|
||||
{
|
||||
cout << "Preparing visualization (deflection = " << deflection << ") ... " << flush;
|
||||
|
||||
BRepTools::Clean (shape);
|
||||
// BRepMesh_IncrementalMesh::
|
||||
BRepMesh_IncrementalMesh (shape, deflection, true);
|
||||
cout << "done" << endl;
|
||||
// cout << IM(5) << "Preparing visualization (deflection = " << deflection << ") ... " << flush;
|
||||
BuildTriangulation(shape);
|
||||
// cout << IM(5) << "done" << endl;
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include <meshing.hpp>
|
||||
|
||||
#include "occgeom.hpp"
|
||||
#include "occ_utils.hpp"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
@ -32,7 +33,6 @@
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepLProp_SLProps.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepOffsetAPI_MakeOffset.hxx>
|
||||
#include <BRepOffsetAPI_MakePipe.hxx>
|
||||
#include <BRepOffsetAPI_MakePipeShell.hxx>
|
||||
@ -45,7 +45,6 @@
|
||||
#include <BRepPrimAPI_MakePrism.hxx>
|
||||
#include <BRepPrimAPI_MakeRevol.hxx>
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <GCE2d_MakeArcOfCircle.hxx>
|
||||
#include <GCE2d_MakeCircle.hxx>
|
||||
#include <GCE2d_MakeSegment.hxx>
|
||||
@ -1150,9 +1149,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
||||
|
||||
.def("MakeTriangulation", [](const TopoDS_Shape & shape)
|
||||
{
|
||||
BRepTools::Clean (shape);
|
||||
double deflection = 0.01;
|
||||
BRepMesh_IncrementalMesh (shape, deflection, true);
|
||||
BuildTriangulation(shape);
|
||||
})
|
||||
|
||||
|
||||
@ -1181,12 +1178,6 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
||||
throw NgException ("Triangulation: shape is not a face");
|
||||
}
|
||||
|
||||
/*
|
||||
BRepTools::Clean (shape);
|
||||
double deflection = 0.01;
|
||||
BRepMesh_IncrementalMesh (shape, deflection, true);
|
||||
*/
|
||||
|
||||
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
|
||||
|
||||
TopLoc_Location loc;
|
||||
@ -1194,9 +1185,7 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
||||
|
||||
if (triangulation.IsNull())
|
||||
{
|
||||
BRepTools::Clean (shape);
|
||||
double deflection = 0.01;
|
||||
BRepMesh_IncrementalMesh (shape, deflection, true);
|
||||
BuildTriangulation(shape);
|
||||
triangulation = BRep_Tool::Triangulation (face, loc);
|
||||
}
|
||||
// throw Exception("Don't have a triangulation, call 'MakeTriangulation' first");
|
||||
@ -1217,30 +1206,9 @@ DLL_HEADER void ExportNgOCCShapes(py::module &m)
|
||||
})
|
||||
.def("_webgui_data", [](const TopoDS_Shape & shape)
|
||||
{
|
||||
BRepTools::Clean (shape);
|
||||
double deflection = 0.01;
|
||||
|
||||
// BRepMesh_IncrementalMesh mesher(shape, deflection,Standard_True, 0.01, true);
|
||||
// mesher.Perform();
|
||||
|
||||
|
||||
// https://dev.opencascade.org/doc/overview/html/occt_user_guides__mesh.html
|
||||
// from Standard_Boolean meshing_imeshtools_parameters()
|
||||
IMeshTools_Parameters aMeshParams;
|
||||
aMeshParams.Deflection = 0.01;
|
||||
aMeshParams.Angle = 0.5;
|
||||
aMeshParams.Relative = Standard_False;
|
||||
aMeshParams.InParallel = Standard_True;
|
||||
aMeshParams.MinSize = Precision::Confusion();
|
||||
aMeshParams.InternalVerticesMode = Standard_True;
|
||||
aMeshParams.ControlSurfaceDeflection = Standard_True;
|
||||
|
||||
BRepMesh_IncrementalMesh aMesher (shape, aMeshParams);
|
||||
const Standard_Integer aStatus = aMesher.GetStatusFlags();
|
||||
auto status = BuildTriangulation(shape);
|
||||
// cout << "status = " << aStatus << endl;
|
||||
|
||||
// triangulation = BRep_Tool::Triangulation (face, loc);
|
||||
|
||||
std::vector<double> p[3];
|
||||
std::vector<double> n[3];
|
||||
py::list names, colors, solid_names;
|
||||
|
Loading…
Reference in New Issue
Block a user