expose stl meshing options (algorithm for auto-detecting feature edges)

This commit is contained in:
Bryn Lloyd 2019-03-01 16:40:28 +01:00
parent 533e5dedac
commit 85fcc6843e
2 changed files with 139 additions and 12 deletions

View File

@ -694,6 +694,16 @@ namespace nglib
}
DLL_HEADER void Ng_STL_DeleteGeometry (Ng_STL_Geometry * geom)
{
if (geom)
{
STLGeometry* geometry = (STLGeometry*)geom;
geometry->Clear();
delete geometry;
geometry = NULL;
}
}
// after adding triangles (and edges) initialize
@ -724,7 +734,8 @@ namespace nglib
// automatically generates edges:
DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
Ng_Mesh* mesh,
Ng_Meshing_Parameters * mp)
Ng_Meshing_Parameters * mp,
Ng_STL_Parameters * stlp)
{
STLGeometry* stlgeometry = (STLGeometry*)geom;
Mesh* me = (Mesh*)mesh;
@ -734,6 +745,7 @@ namespace nglib
// object
//MeshingParameters mparam;
mp->Transfer_Parameters();
if (stlp) stlp->Transfer_Parameters();
me -> SetGlobalH (mparam.maxh);
me -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
@ -769,7 +781,8 @@ namespace nglib
// generates mesh, empty mesh be already created.
DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
Ng_Mesh* mesh,
Ng_Meshing_Parameters * mp)
Ng_Meshing_Parameters * mp,
Ng_STL_Parameters * stlp)
{
STLGeometry* stlgeometry = (STLGeometry*)geom;
Mesh* me = (Mesh*)mesh;
@ -779,6 +792,7 @@ namespace nglib
// object
//MeshingParameters mparam;
mp->Transfer_Parameters();
if (stlp) stlp->Transfer_Parameters();
/*
@ -1135,6 +1149,72 @@ namespace nglib
mparam.checkoverlap = check_overlap;
mparam.checkoverlappingboundary = check_overlapping_boundary;
}
DLL_HEADER Ng_STL_Parameters :: Ng_STL_Parameters()
{
yangle = 30;
contyangle = 20;
chartangle = 10; // original = 15
outerchartangle = 80; // original = 70;
usesearchtree = 0;
atlasminh = 1.0; // original = 1E-4
resthatlasenable = 1;
resthatlasfac = 2;
resthchartdistenable = 1;
resthchartdistfac = 0.3; // original = 1.2
resthedgeangleenable = 0;
resthedgeanglefac = 1;
resthsurfmeshcurvenable = 1;
resthsurfmeshcurvfac = 1;
resthlinelengthenable = 1;
resthlinelengthfac = 0.2; // original = 0.5
resthcloseedgefac = 1;
resthcloseedgeenable = 1;
}
DLL_HEADER void Ng_STL_Parameters :: Transfer_Parameters()
{
stlparam.yangle = yangle;
stlparam.contyangle = contyangle;
stlparam.chartangle = chartangle;
stlparam.outerchartangle = outerchartangle;
stlparam.usesearchtree = usesearchtree;
stlparam.atlasminh = atlasminh;
stlparam.resthatlasenable = resthatlasenable;
stlparam.resthatlasfac = resthatlasfac;
stlparam.resthchartdistenable = resthchartdistenable;
stlparam.resthchartdistfac = resthchartdistfac;
stlparam.resthedgeangleenable = resthedgeangleenable;
stlparam.resthedgeanglefac = resthedgeanglefac;
stlparam.resthsurfmeshcurvenable = resthsurfmeshcurvenable;
stlparam.resthsurfmeshcurvfac = resthsurfmeshcurvfac;
stlparam.resthlinelengthenable = resthlinelengthenable;
stlparam.resthlinelengthfac = resthlinelengthfac;
stlparam.resthcloseedgeenable = resthcloseedgeenable;
stlparam.resthcloseedgefac = resthcloseedgefac;
}
// ------------------ End - Meshing Parameters related functions --------------------

View File

@ -23,8 +23,8 @@
// Philippose - 14.02.2009
// Modifications for creating a DLL in Windows
#ifdef WIN32
#ifdef NGLIB_EXPORTS || nglib_EXPORTS
#if defined(WIN32)
#if defined(NGLIB_EXPORTS) || defined(nglib_EXPORTS)
#define DLL_HEADER __declspec(dllexport)
#else
#define DLL_HEADER __declspec(dllimport)
@ -183,6 +183,49 @@ public:
};
class DLL_HEADER Ng_STL_Parameters
{
public:
// Algorithm may be somewhat like Canny edge detector
// on mesh?
double yangle; // 30
double contyangle; // 30
// I think this is used to split surface into patches/charts,
//which are flattened to use 2d meshing routines.
double chartangle; // 15
double outerchartangle; // 70
int usesearchtree; // 0
double atlasminh; // 1e-4
// Factors which influence the local mesh size
// as a relation to some metric, e.g. curvature,
// line length, etc.
// TODO: document each of these properly
int resthatlasenable; // 1
double resthatlasfac; // 2
int resthchartdistenable; // 1
double resthchartdistfac; // 0.3
int resthedgeangleenable; // 0
double resthedgeanglefac; // 1
int resthsurfmeshcurvenable; // 0
double resthsurfmeshcurvfac; // 0.5
int resthlinelengthenable; // 1
double resthlinelengthfac; // 0.5
int resthcloseedgeenable; // 1
double resthcloseedgefac; // 1.0
Ng_STL_Parameters();
void Transfer_Parameters();
};
// *** Functions Exported by this Library *************
@ -622,6 +665,8 @@ DLL_HEADER Ng_STL_Geometry * Ng_STL_LoadGeometry (const char * filename, int bin
DLL_HEADER Ng_STL_Geometry * Ng_STL_NewGeometry ();
DLL_HEADER void Ng_STL_DeleteGeometry (Ng_STL_Geometry * geom);
// fills STL Geometry
// positive orientation
// normal vector may be null-pointer
@ -639,13 +684,15 @@ DLL_HEADER Ng_Result Ng_STL_InitSTLGeometry (Ng_STL_Geometry * geom);
// automatically generates edges:
DLL_HEADER Ng_Result Ng_STL_MakeEdges (Ng_STL_Geometry * geom,
Ng_Mesh* mesh,
Ng_Meshing_Parameters * mp);
Ng_Meshing_Parameters * mp,
Ng_STL_Parameters * stlp = nullptr);
// generates mesh, empty mesh must be already created.
DLL_HEADER Ng_Result Ng_STL_GenerateSurfaceMesh (Ng_STL_Geometry * geom,
Ng_Mesh * mesh,
Ng_Meshing_Parameters * mp);
Ng_Meshing_Parameters * mp,
Ng_STL_Parameters * stlp = nullptr);
#ifdef ACIS