merge endMeshStep

This commit is contained in:
Christopher Lackner 2016-12-05 15:08:25 +01:00
commit dc3a214994
21 changed files with 112 additions and 83 deletions

View File

@ -129,14 +129,12 @@ namespace netgen
extern int CSGGenerateMesh (CSGeometry & geom,
shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int CSGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
return CSGGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
return CSGGenerateMesh (*this, mesh, mparam);
}
const Refinement & CSGeometry :: GetRefinement () const

View File

@ -313,8 +313,7 @@ namespace netgen
Array<BCModification> bcmodifications;
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
virtual const Refinement & GetRefinement () const;
};

View File

@ -658,17 +658,16 @@ namespace netgen
int CSGGenerateMesh (CSGeometry & geom,
shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
if (mesh && mesh->GetNSE() &&
!geom.GetNSolids())
{
if (perfstepsstart < MESHCONST_MESHVOLUME)
perfstepsstart = MESHCONST_MESHVOLUME;
if (mparam.perfstepsstart < MESHCONST_MESHVOLUME)
mparam.perfstepsstart = MESHCONST_MESHVOLUME;
}
if (perfstepsstart <= MESHCONST_ANALYSE)
if (mparam.perfstepsstart <= MESHCONST_ANALYSE)
{
if (mesh)
mesh -> DeleteMesh();
@ -709,11 +708,11 @@ namespace netgen
}
if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHEDGES)
if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
{
FindEdges (geom, *mesh, mparam, true);
if (multithread.terminate) return TCL_OK;
@ -746,11 +745,11 @@ namespace netgen
}
}
if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHEDGES)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHSURFACE)
if (mparam.perfstepsstart <= MESHCONST_MESHSURFACE)
{
MeshSurface (geom, *mesh, mparam);
if (multithread.terminate) return TCL_OK;
@ -791,10 +790,11 @@ namespace netgen
mesh->CalcSurfacesOfNode();
}
if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_OPTSURFACE)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHVOLUME)
if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME)
{
multithread.task = "Volume meshing";
@ -825,11 +825,11 @@ namespace netgen
#endif
}
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHVOLUME)
return TCL_OK;
if (perfstepsstart <= MESHCONST_OPTVOLUME)
if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME)
{
multithread.task = "Volume optimization";

View File

@ -626,7 +626,7 @@ DLL_HEADER void ExportCSG(py::module &m)
geo->FindIdenticSurfaces(1e-8 * geo->MaxSize());
try
{
geo->GenerateMesh (dummy, param, 0, 6);
geo->GenerateMesh (dummy, param);
}
catch (NgException ex)
{

View File

@ -986,8 +986,7 @@ namespace netgen
MeshingParameters & mp);
int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int SplineGeometry2d :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
MeshFromSpline2D (*this, mesh, mparam);
return 0;

View File

@ -156,8 +156,7 @@ namespace netgen
}
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
void PartitionBoundary (MeshingParameters & mp, double h, Mesh & mesh2d);

View File

@ -258,7 +258,7 @@ DLL_HEADER void ExportGeom2d(py::module &m)
mesh->SetGeometry(self);
SetGlobalMesh (mesh);
ng_geometry = self;
self->GenerateMesh(mesh, mparam, 0, 0);
self->GenerateMesh(mesh, mparam);
return mesh;
}))

View File

@ -1,5 +1,8 @@
#ifndef INCOPENGL_HPP___
#define INCOPENGL_HPP___
#define GL_GLEXT_PROTOTYPES
#include <mydefs.hpp>
# if defined(TOGL_AGL) || defined(TOGL_AGL_CLASSIC) || defined(TOGL_NSOPENGL)
# include <OpenGL/gl.h>
@ -17,15 +20,20 @@
#include <GL/glxext.h>
#endif
#ifdef WIN32
// part of OpenGL 1.2, but not in Microsoft's OpenGL 1.1 header:
// GL version sould be checked at runtime
#ifndef GL_CLAMP_TO_EDGE
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_CLAMP_TO_EDGE 0x812F
#define GL_ARRAY_BUFFER 0x8892
#define GL_ELEMENT_ARRAY_BUFFER 0x8893
#define GL_STATIC_DRAW 0x88E4
typedef ptrdiff_t GLintptr;
typedef ptrdiff_t GLsizeiptr;
extern void (*glBindBuffer) (GLenum a, GLuint b);
extern void (*glDeleteBuffers) (GLsizei a, const GLuint *b);
extern void (*glGenBuffers) (GLsizei a, GLuint *b);
extern void (*glBufferData) (GLenum a, GLsizeiptr b, const GLvoid *c, GLenum d);
extern void (*glBufferSubData) (GLenum a, GLintptr b, GLsizeiptr c, const GLvoid *d);
#endif
DLL_HEADER void LoadOpenGLFunctionPointers();
#endif // INCOPENGL_HPP___

View File

@ -14,12 +14,11 @@ namespace netgen
int NetgenGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int NetgenGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
if (!mesh) return 1;
if (perfstepsstart <= MESHCONST_MESHVOLUME)
if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME)
{
multithread.task = "Volume meshing";
@ -37,11 +36,11 @@ namespace netgen
}
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHVOLUME)
return 0;
if (perfstepsstart <= MESHCONST_OPTVOLUME)
if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME)
{
multithread.task = "Volume optimization";

View File

@ -18,8 +18,7 @@ namespace netgen
public:
virtual ~NetgenGeometry () { ; }
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
virtual const Refinement & GetRefinement () const;

View File

@ -1091,6 +1091,11 @@ namespace netgen
double elsizeweight = 0.2;
/// init with default values
/// start at step
int perfstepsstart = 0;
/// end at step
int perfstepsend = 6;
/// from mp3:
/// give up quality class, 2d meshing

View File

@ -586,12 +586,18 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
;
py::enum_<MESHING_STEP>(m,"MeshingStep")
.value("MESHEDGES",MESHCONST_MESHEDGES)
.value("MESHSURFACE",MESHCONST_OPTSURFACE)
.value("MESHVOLUME",MESHCONST_OPTVOLUME)
;
typedef MeshingParameters MP;
py::class_<MP> (m, "MeshingParameters")
.def(py::init<>())
.def("__init__",
[](MP *instance, double maxh, bool quad_dominated, int optsteps2d, int optsteps3d,
int only3D_domain)
MESHING_STEP perfstepsend, int only3D_domain)
{
new (instance) MeshingParameters;
instance->maxh = maxh;
@ -599,13 +605,14 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
instance->optsteps2d = optsteps2d;
instance->optsteps3d = optsteps3d;
instance->only3D_domain_nr = only3D_domain;
instance->perfstepsend = perfstepsend;
},
py::arg("maxh")=1000,
py::arg("quad_dominated")=false,
py::arg("optsteps2d") = 3,
py::arg("optsteps3d") = 3,
py::arg("only3D_domain") = 0,
py::arg("onlySurface") = false
py::arg("perfstepsend") = MESHCONST_OPTVOLUME,
,
"create meshing parameters"
)

View File

@ -1273,12 +1273,11 @@ namespace netgen
int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int OCCGenerateMesh (OCCGeometry & geom, shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
multithread.percent = 0;
if (perfstepsstart <= MESHCONST_ANALYSE)
if (mparam.perfstepsstart <= MESHCONST_ANALYSE)
{
// delete mesh;
// mesh = make_shared<Mesh>();
@ -1287,10 +1286,10 @@ namespace netgen
OCCSetLocalMeshSize(geom,*mesh);
}
if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_ANALYSE)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHEDGES)
if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
{
OCCFindEdges (geom, *mesh);
@ -1360,12 +1359,12 @@ namespace netgen
#endif
}
if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHEDGES)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHSURFACE)
if (mparam.perfstepsstart <= MESHCONST_MESHSURFACE)
{
OCCMeshSurface (geom, *mesh, perfstepsend);
OCCMeshSurface (geom, *mesh, mparam.perfstepsend);
if (multithread.terminate) return TCL_OK;
#ifdef LOG_STREAM
@ -1384,10 +1383,10 @@ namespace netgen
mesh->CalcSurfacesOfNode();
}
if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_OPTSURFACE)
return TCL_OK;
if (perfstepsstart <= MESHCONST_MESHVOLUME)
if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME)
{
multithread.task = "Volume meshing";
@ -1426,10 +1425,10 @@ namespace netgen
#endif
}
if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME)
if (multithread.terminate || mparam.perfstepsend <= MESHCONST_MESHVOLUME)
return TCL_OK;
if (perfstepsstart <= MESHCONST_OPTVOLUME)
if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME)
{
multithread.task = "Volume optimization";

View File

@ -1564,10 +1564,9 @@ namespace netgen
int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int OCCGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
return OCCGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
return OCCGenerateMesh (*this, mesh, mparam);
}

View File

@ -387,8 +387,7 @@ namespace netgen
// void WriteOCC_STL(char * filename);
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
DLL_HEADER virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
DLL_HEADER virtual const Refinement & GetRefinement () const;
};

View File

@ -91,10 +91,9 @@ void STLGeometry :: Save (string filename) const
int STLGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int STLGeometry :: GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
return STLMeshingDummy (this, mesh, mparam, perfstepsstart, perfstepsend);
return STLMeshingDummy (this, mesh, mparam);
}

View File

@ -452,8 +452,7 @@ namespace netgen
friend class MeshingSTLSurface;
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
virtual int GenerateMesh (shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
virtual const Refinement & GetRefinement () const;
};
@ -463,8 +462,7 @@ namespace netgen
extern int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
extern int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam);
}

View File

@ -1329,16 +1329,15 @@ void STLGeometry :: RestrictHChartDistOneChart(int chartnum, Array<int>& acttrig
}
int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingParameters & mparam)
{
if (perfstepsstart > perfstepsend) return 0;
if (mparam.perfstepsstart > mparam.perfstepsend) return 0;
multithread.terminate = 0;
int success = 1;
//int trialcntouter = 0;
if (perfstepsstart <= MESHCONST_MESHEDGES)
if (mparam.perfstepsstart <= MESHCONST_MESHEDGES)
{
if (mesh)
mesh -> DeleteMesh();
@ -1368,8 +1367,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (multithread.terminate)
return 0;
if (perfstepsstart <= MESHCONST_MESHSURFACE &&
perfstepsend >= MESHCONST_MESHSURFACE)
if (mparam.perfstepsstart <= MESHCONST_MESHSURFACE &&
mparam.perfstepsend >= MESHCONST_MESHSURFACE)
{
if (!stlgeometry->edgesfound)
@ -1417,8 +1416,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (success)
{
if (perfstepsstart <= MESHCONST_OPTSURFACE &&
perfstepsend >= MESHCONST_OPTSURFACE)
if (mparam.perfstepsstart <= MESHCONST_OPTSURFACE &&
mparam.perfstepsend >= MESHCONST_OPTSURFACE)
{
if (!stlgeometry->edgesfound)
{
@ -1469,8 +1468,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (multithread.terminate)
return 0;
if (perfstepsstart <= MESHCONST_MESHVOLUME &&
perfstepsend >= MESHCONST_MESHVOLUME)
if (mparam.perfstepsstart <= MESHCONST_MESHVOLUME &&
mparam.perfstepsend >= MESHCONST_MESHVOLUME)
{
if (stlgeometry->volumemeshed)
{
@ -1540,8 +1539,8 @@ int STLMeshingDummy (STLGeometry* stlgeometry, shared_ptr<Mesh> & mesh, MeshingP
if (multithread.terminate)
return 0;
if (perfstepsstart <= MESHCONST_OPTVOLUME &&
perfstepsend >= MESHCONST_OPTVOLUME)
if (mparam.perfstepsstart <= MESHCONST_OPTVOLUME &&
mparam.perfstepsend >= MESHCONST_OPTVOLUME)
{
if (!stlgeometry->edgesfound)
{

View File

@ -4805,3 +4805,22 @@ void Ng_Redraw (bool blocking)
#endif
}
#ifdef OPENGL
#ifdef WIN32
void (*glBindBuffer) (GLenum a, GLuint b);
void (*glDeleteBuffers) (GLsizei a, const GLuint *b);
void (*glGenBuffers) (GLsizei a, GLuint *b);
void (*glBufferData) (GLenum a, GLsizeiptr b, const GLvoid *c, GLenum d);
void (*glBufferSubData) (GLenum a, GLintptr b, GLsizeiptr c, const GLvoid *d);
DLL_HEADER void LoadOpenGLFunctionPointers() {
glBindBuffer = (decltype(glBindBuffer)) wglGetProcAddress("glBindBuffer");
glBufferSubData = (decltype(glBufferSubData)) wglGetProcAddress("glBufferSubData");
glBufferData = (decltype(glBufferData)) wglGetProcAddress("glBufferData");
glDeleteBuffers = (decltype(glDeleteBuffers)) wglGetProcAddress("glDeleteBuffers");
glGenBuffers = (decltype(glGenBuffers)) wglGetProcAddress("glGenBuffers");
if(!glBindBuffer) throw std::runtime_error("Could not load OpenGL functions!");
}
#else // WIN32
DLL_HEADER void LoadOpenGLFunctionPointers() { }
#endif // WIN32
#endif // OPENGL

View File

@ -43,7 +43,7 @@ class DLL_HEADER VisualSceneSolution : public VisualScene
Point<3> p;
};
// #define USE_BUFFERS
#define USE_BUFFERS
#ifdef USE_BUFFERS
bool has_surfel_vbo = false;
GLuint surfel_vbo[4]; //

View File

@ -1328,8 +1328,9 @@ namespace netgen
// vsmesh.SetMesh (mesh);
SetGlobalMesh (mesh);
mesh -> SetGeometry(ng_geometry);
int res = ng_geometry -> GenerateMesh (mesh, mparam, perfstepsstart, perfstepsend);
mparam.perfstepsstart = perfstepsstart;
mparam.perfstepsend = perfstepsend;
int res = ng_geometry -> GenerateMesh (mesh, mparam);
if (res != MESHING3_OK)
{
@ -1938,6 +1939,7 @@ namespace netgen
if (nodisplay)
return;
LoadOpenGLFunctionPointers();
fontbase = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 );
Set_OpenGLText_Callback (&MyOpenGLText_GUI);
@ -2078,6 +2080,8 @@ namespace netgen
// possible values: 12,14,16,18,20,22,24,28,32
font = selectFont(18);
LoadOpenGLFunctionPointers();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);