mirror of
https://github.com/NGSolve/netgen.git
synced 2025-04-13 08:37:28 +05:00
little OCC-meshing cleanup
This commit is contained in:
parent
954cae2686
commit
321bee9b02
@ -21,6 +21,7 @@ namespace netgen
|
||||
|
||||
Meshing2 :: Meshing2 (const MeshingParameters & mp, const Box<3> & aboundingbox)
|
||||
{
|
||||
static Timer t("Mesing2::Meshing2"); RegionTimer r(t);
|
||||
boundingbox = aboundingbox;
|
||||
|
||||
LoadRules (NULL, mp.quad);
|
||||
|
@ -41,24 +41,14 @@ namespace netgen
|
||||
return 1e99;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double Line :: Length ()
|
||||
{
|
||||
return (p1-p0).Length();
|
||||
}
|
||||
|
||||
|
||||
|
||||
inline Point<3> occ2ng (const gp_Pnt & p)
|
||||
{
|
||||
return Point<3> (p.X(), p.Y(), p.Z());
|
||||
}
|
||||
|
||||
|
||||
|
||||
double ComputeH (double kappa, const MeshingParameters & mparam)
|
||||
{
|
||||
/*
|
||||
double hret;
|
||||
kappa *= mparam.curvaturesafety;
|
||||
|
||||
@ -70,12 +60,14 @@ namespace netgen
|
||||
if (mparam.maxh < hret)
|
||||
hret = mparam.maxh;
|
||||
|
||||
return (hret);
|
||||
return hret;
|
||||
*/
|
||||
// return min(mparam.maxh, 1/kappa);
|
||||
return (mparam.maxh*kappa < 1) ? mparam.maxh : 1/kappa;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void RestrictHTriangle (gp_Pnt2d & par0, gp_Pnt2d & par1, gp_Pnt2d & par2,
|
||||
BRepLProp_SLProps * prop, Mesh & mesh, int depth, double h,
|
||||
const MeshingParameters & mparam)
|
||||
@ -316,6 +308,8 @@ namespace netgen
|
||||
|
||||
void OCCFindEdges (OCCGeometry & geom, Mesh & mesh, const MeshingParameters & mparam)
|
||||
{
|
||||
static Timer t("OCCFindEdges"); RegionTimer r(t);
|
||||
static Timer tsearch("OCCFindEdges - search point");
|
||||
const char * savetask = multithread.task;
|
||||
multithread.task = "Edge meshing";
|
||||
|
||||
@ -329,6 +323,7 @@ namespace netgen
|
||||
|
||||
double eps = 1e-6 * geom.GetBoundingBox().Diam();
|
||||
|
||||
tsearch.Start();
|
||||
for (int i = 1; i <= nvertices; i++)
|
||||
{
|
||||
gp_Pnt pnt = BRep_Tool::Pnt (TopoDS::Vertex(geom.vmap(i)));
|
||||
@ -346,6 +341,7 @@ namespace netgen
|
||||
if (!exists)
|
||||
mesh.AddPoint (mp);
|
||||
}
|
||||
tsearch.Stop();
|
||||
|
||||
(*testout) << "different vertices = " << mesh.GetNP() << endl;
|
||||
|
||||
@ -504,6 +500,7 @@ namespace netgen
|
||||
for (int i = 1; i <= mp.Size(); i++)
|
||||
{
|
||||
bool exists = 0;
|
||||
tsearch.Start();
|
||||
int j;
|
||||
for (j = first_ep; j <= mesh.GetNP(); j++)
|
||||
if ((mesh.Point(j)-Point<3>(mp[i-1])).Length() < eps)
|
||||
@ -511,6 +508,7 @@ namespace netgen
|
||||
exists = 1;
|
||||
break;
|
||||
}
|
||||
tsearch.Stop();
|
||||
|
||||
if (exists)
|
||||
pnums[i] = j;
|
||||
@ -611,8 +609,10 @@ namespace netgen
|
||||
void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend,
|
||||
MeshingParameters & mparam)
|
||||
{
|
||||
int i, j, k;
|
||||
int changed;
|
||||
static Timer t("OCCMeshSurface"); RegionTimer r(t);
|
||||
|
||||
// int i, j, k;
|
||||
// int changed;
|
||||
|
||||
const char * savetask = multithread.task;
|
||||
multithread.task = "Surface meshing";
|
||||
@ -633,7 +633,7 @@ namespace netgen
|
||||
|
||||
int surfmesherror = 0;
|
||||
|
||||
for (k = 1; k <= mesh.GetNFD(); k++)
|
||||
for (int k = 1; k <= mesh.GetNFD(); k++)
|
||||
{
|
||||
if(1==0 && !geom.fvispar[k-1].IsDrawable())
|
||||
{
|
||||
@ -655,7 +655,6 @@ namespace netgen
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
|
||||
|
||||
int oldnf = mesh.GetNSE();
|
||||
@ -664,7 +663,10 @@ namespace netgen
|
||||
|
||||
// int projecttype = PLANESPACE;
|
||||
|
||||
static Timer tinit("init");
|
||||
tinit.Start();
|
||||
Meshing2OCCSurfaces meshing(TopoDS::Face(geom.fmap(k)), bb, projecttype, mparam);
|
||||
tinit.Stop();
|
||||
|
||||
if (meshing.GetProjectionType() == PLANESPACE)
|
||||
PrintMessage (2, "Face ", k, " / ", mesh.GetNFD(), " (plane space projection)");
|
||||
@ -676,20 +678,20 @@ namespace netgen
|
||||
|
||||
// Meshing2OCCSurfaces meshing(f2, bb);
|
||||
meshing.SetStartTime (starttime);
|
||||
|
||||
//(*testout) << "Face " << k << endl << endl;
|
||||
|
||||
|
||||
if (meshing.GetProjectionType() == PLANESPACE)
|
||||
{
|
||||
static Timer t("MeshSurface: Find edges and points - Physical"); RegionTimer r(t);
|
||||
int cntp = 0;
|
||||
glob2loc = 0;
|
||||
for (i = 1; i <= mesh.GetNSeg(); i++)
|
||||
for (int i = 1; i <= mesh.GetNSeg(); i++)
|
||||
{
|
||||
Segment & seg = mesh.LineSegment(i);
|
||||
if (seg.si == k)
|
||||
{
|
||||
for (j = 1; j <= 2; j++)
|
||||
for (int j = 1; j <= 2; j++)
|
||||
{
|
||||
int pi = (j == 1) ? seg[0] : seg[1];
|
||||
if (!glob2loc.Get(pi))
|
||||
@ -702,7 +704,7 @@ namespace netgen
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 1; i <= mesh.GetNSeg(); i++)
|
||||
for (int i = 1; i <= mesh.GetNSeg(); i++)
|
||||
{
|
||||
Segment & seg = mesh.LineSegment(i);
|
||||
if (seg.si == k)
|
||||
@ -722,9 +724,11 @@ namespace netgen
|
||||
}
|
||||
else
|
||||
{
|
||||
static Timer t("MeshSurface: Find edges and points - Parameter"); RegionTimer r(t);
|
||||
|
||||
int cntp = 0;
|
||||
|
||||
for (i = 1; i <= mesh.GetNSeg(); i++)
|
||||
for (int i = 1; i <= mesh.GetNSeg(); i++)
|
||||
if (mesh.LineSegment(i).si == k)
|
||||
cntp+=2;
|
||||
|
||||
@ -734,7 +738,7 @@ namespace netgen
|
||||
gis.SetAllocSize (cntp);
|
||||
gis.SetSize (0);
|
||||
|
||||
for (i = 1; i <= mesh.GetNSeg(); i++)
|
||||
for (int i = 1; i <= mesh.GetNSeg(); i++)
|
||||
{
|
||||
Segment & seg = mesh.LineSegment(i);
|
||||
if (seg.si == k)
|
||||
@ -748,7 +752,7 @@ namespace netgen
|
||||
|
||||
int locpnum[2] = {0, 0};
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
PointGeomInfo gi = (j == 0) ? gi0 : gi1;
|
||||
|
||||
@ -798,6 +802,7 @@ namespace netgen
|
||||
MESHING2_RESULT res;
|
||||
|
||||
try {
|
||||
static Timer t("GenerateMesh"); RegionTimer reg(t);
|
||||
res = meshing.GenerateMesh (mesh, mparam, maxh, k);
|
||||
}
|
||||
|
||||
@ -814,6 +819,7 @@ namespace netgen
|
||||
}
|
||||
|
||||
projecttype = PARAMETERSPACE;
|
||||
static Timer t1("rest of loop"); RegionTimer reg1(t1);
|
||||
|
||||
if (res != MESHING2_OK)
|
||||
{
|
||||
@ -846,7 +852,7 @@ namespace netgen
|
||||
|
||||
notrys = 1;
|
||||
|
||||
for (i = oldnf+1; i <= mesh.GetNSE(); i++)
|
||||
for (int i = oldnf+1; i <= mesh.GetNSE(); i++)
|
||||
mesh.SurfaceElement(i).SetIndex (k);
|
||||
|
||||
}
|
||||
@ -905,7 +911,7 @@ namespace netgen
|
||||
static Timer timer_opt2d("Optimization 2D");
|
||||
timer_opt2d.Start();
|
||||
|
||||
for (k = 1; k <= mesh.GetNFD(); k++)
|
||||
for (int k = 1; k <= mesh.GetNFD(); k++)
|
||||
{
|
||||
// if (k != 42) continue;
|
||||
// if (k != 36) continue;
|
||||
@ -916,7 +922,7 @@ namespace netgen
|
||||
FaceDescriptor & fd = mesh.GetFaceDescriptor(k);
|
||||
|
||||
PrintMessage (1, "Optimize Surface ", k);
|
||||
for (i = 1; i <= mparam.optsteps2d; i++)
|
||||
for (int i = 1; i <= mparam.optsteps2d; i++)
|
||||
{
|
||||
// (*testout) << "optstep " << i << endl;
|
||||
if (multithread.terminate) return;
|
||||
|
@ -171,10 +171,8 @@ namespace netgen
|
||||
{
|
||||
public:
|
||||
Point<3> p0, p1;
|
||||
|
||||
double Dist (Line l);
|
||||
|
||||
double Length ();
|
||||
double Length () { return (p1-p0).Length(); }
|
||||
};
|
||||
|
||||
|
||||
@ -250,21 +248,21 @@ namespace netgen
|
||||
|
||||
DLL_HEADER void BuildFMap();
|
||||
|
||||
Box<3> GetBoundingBox()
|
||||
Box<3> GetBoundingBox() const
|
||||
{ return boundingbox; }
|
||||
|
||||
int NrSolids()
|
||||
int NrSolids() const
|
||||
{ return somap.Extent(); }
|
||||
|
||||
// Philippose - 17/01/2009
|
||||
// Total number of faces in the geometry
|
||||
int NrFaces()
|
||||
int NrFaces() const
|
||||
{ return fmap.Extent(); }
|
||||
|
||||
void SetCenter()
|
||||
{ center = boundingbox.Center(); }
|
||||
|
||||
Point<3> Center()
|
||||
Point<3> Center() const
|
||||
{ return center; }
|
||||
|
||||
void Project (int surfi, Point<3> & p) const;
|
||||
@ -347,9 +345,7 @@ namespace netgen
|
||||
// Returns the index of the currently selected face
|
||||
int SelectedFace()
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 1; i <= fmap.Extent(); i++)
|
||||
for(int i = 1; i <= fmap.Extent(); i++)
|
||||
{
|
||||
if(face_sel_status[i-1])
|
||||
{
|
||||
|
@ -55,6 +55,7 @@ protected:
|
||||
public:
|
||||
OCCSurface (const TopoDS_Face & aface, int aprojecttype)
|
||||
{
|
||||
static Timer t("occurface ctor"); RegionTimer r(t);
|
||||
topods_face = aface;
|
||||
occface = BRep_Tool::Surface(topods_face);
|
||||
orient = topods_face.Orientation();
|
||||
|
Loading…
x
Reference in New Issue
Block a user