mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 13:30:34 +05:00
more use of PointIndex
This commit is contained in:
parent
e4a6d127fd
commit
4c32c2ac25
@ -617,7 +617,9 @@ namespace netgen
|
||||
(*testout) << "Point on edge" << endl
|
||||
<< "seg = " << i2 << ", p = " << pi << endl
|
||||
<< "pos = " << p << ", projected = " << hp << endl
|
||||
<< "seg is = " << mesh.Point(i2.I1()) << " - " << mesh.Point(i2.I2()) << endl;
|
||||
<< "seg is = "
|
||||
<< mesh.Point(PointIndex(i2.I1())) << " - "
|
||||
<< mesh.Point(PointIndex(i2.I2())) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -760,7 +760,8 @@ namespace netgen
|
||||
<< "points: " << mesh->GetNP() << endl;
|
||||
#endif
|
||||
|
||||
if (mparam.uselocalh && 0)
|
||||
/*
|
||||
if (mparam.uselocalh)
|
||||
{
|
||||
mesh->CalcLocalH(mparam.grading);
|
||||
mesh->DeleteMesh();
|
||||
@ -773,6 +774,7 @@ namespace netgen
|
||||
MeshSurface (geom, *mesh, mparam);
|
||||
if (multithread.terminate) return TCL_OK;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef LOG_STREAM
|
||||
(*logout) << "Surfaces remeshed" << endl
|
||||
|
@ -130,18 +130,18 @@ namespace netgen
|
||||
int hasp = 0;
|
||||
for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
|
||||
{
|
||||
const TriangleApproximation & ta =
|
||||
*geometry->GetTriApprox(i);
|
||||
if (!&ta) continue;
|
||||
const TriangleApproximation * ta =
|
||||
geometry->GetTriApprox(i);
|
||||
if (!ta) continue;
|
||||
|
||||
for (int j = 0; j < ta.GetNP(); j++)
|
||||
for (int j = 0; j < ta->GetNP(); j++)
|
||||
{
|
||||
if (hasp)
|
||||
box.Add (ta.GetPoint(j));
|
||||
box.Add (ta->GetPoint(j));
|
||||
else
|
||||
{
|
||||
hasp = 1;
|
||||
box.Set (ta.GetPoint(j));
|
||||
box.Set (ta->GetPoint(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,18 +167,18 @@ namespace netgen
|
||||
trilists.Append (glGenLists (1));
|
||||
glNewList (trilists.Last(), GL_COMPILE);
|
||||
glEnable (GL_NORMALIZE);
|
||||
const TriangleApproximation & ta =
|
||||
*geometry->GetTriApprox(i);
|
||||
if (&ta)
|
||||
const TriangleApproximation * ta =
|
||||
geometry->GetTriApprox(i);
|
||||
if (ta)
|
||||
{
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3, GL_DOUBLE, 0, &ta.GetPoint(0)(0));
|
||||
glVertexPointer(3, GL_DOUBLE, 0, &ta->GetPoint(0)(0));
|
||||
|
||||
glEnableClientState(GL_NORMAL_ARRAY);
|
||||
glNormalPointer(GL_DOUBLE, 0, &ta.GetNormal(0)(0));
|
||||
glNormalPointer(GL_DOUBLE, 0, &ta->GetNormal(0)(0));
|
||||
|
||||
for (int j = 0; j < ta.GetNT(); j++)
|
||||
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, & (ta.GetTriangle(j)[0]));
|
||||
for (int j = 0; j < ta->GetNT(); j++)
|
||||
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, & (ta->GetTriangle(j)[0]));
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_NORMAL_ARRAY);
|
||||
@ -383,12 +383,19 @@ namespace netgen
|
||||
glDisable (GL_LIGHTING);
|
||||
glDisable (GL_CLIP_PLANE0);
|
||||
|
||||
/*
|
||||
for (int i = 1; i <= mesh -> GetNP(); i++)
|
||||
{
|
||||
const Point3d & p = mesh -> Point(i);
|
||||
glRasterPos3d (p.X(), p.Y(), p.Z());
|
||||
glBitmap (7, 7, 3, 3, 0, 0, &knoedel[0]);
|
||||
}
|
||||
*/
|
||||
for (const Point3d & p : mesh->Points())
|
||||
{
|
||||
glRasterPos3d (p.X(), p.Y(), p.Z());
|
||||
glBitmap (7, 7, 3, 3, 0, 0, &knoedel[0]);
|
||||
}
|
||||
}
|
||||
|
||||
if (vispar.drawedpointnrs)
|
||||
@ -403,7 +410,8 @@ namespace netgen
|
||||
// glListBase (fontbase);
|
||||
|
||||
char buf[20];
|
||||
for (int i = 1; i <= mesh->GetNP(); i++)
|
||||
// for (int i = 1; i <= mesh->GetNP(); i++)
|
||||
for (auto i : mesh->Points().Range())
|
||||
{
|
||||
const Point3d & p = mesh->Point(i);
|
||||
glRasterPos3d (p.X(), p.Y(), p.Z());
|
||||
|
@ -38,7 +38,8 @@
|
||||
|
||||
|
||||
|
||||
|
||||
// #define BASE0
|
||||
// #define DEBUG
|
||||
|
||||
|
||||
#define noDEMOVERSION
|
||||
|
@ -14,6 +14,9 @@
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
|
||||
static constexpr int POINTINDEX_BASE = 1;
|
||||
|
||||
struct T_EDGE2
|
||||
{
|
||||
// int orient:1;
|
||||
@ -37,7 +40,7 @@ namespace netgen
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return num; }
|
||||
int operator[] (int i) const { return ptr[i]-1; }
|
||||
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
};
|
||||
|
||||
|
||||
@ -48,7 +51,7 @@ namespace netgen
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return num; }
|
||||
int operator[] (int i) const { return ptr[i]-1; }
|
||||
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
};
|
||||
|
||||
class Ng_Edges
|
||||
@ -145,7 +148,7 @@ namespace netgen
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return 2; }
|
||||
int operator[] (int i) const { return ptr[i]-1; }
|
||||
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
};
|
||||
|
||||
|
||||
@ -165,7 +168,7 @@ namespace netgen
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return nv; }
|
||||
int operator[] (int i) const { return ptr[i]-1; }
|
||||
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
};
|
||||
|
||||
class Ng_Edges
|
||||
|
@ -1,6 +1,6 @@
|
||||
NGX_INLINE DLL_HEADER Ng_Point Ngx_Mesh :: GetPoint (int nr) const
|
||||
{
|
||||
return Ng_Point (&mesh->Point(nr + PointIndex::BASE)(0));
|
||||
return Ng_Point (&mesh->Point(PointIndex(nr+PointIndex::BASE))(0));
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ void WriteJCMFormat (const Mesh & mesh,
|
||||
int np = mesh.GetNP();
|
||||
|
||||
// Identic points
|
||||
Array<int,1> identmap1, identmap2, identmap3;
|
||||
Array<int,PointIndex::BASE> identmap1, identmap2, identmap3;
|
||||
mesh.GetIdentifications().GetMap(1, identmap1);
|
||||
mesh.GetIdentifications().GetMap(2, identmap2);
|
||||
mesh.GetIdentifications().GetMap(3, identmap3);
|
||||
|
@ -35,7 +35,7 @@
|
||||
///
|
||||
FrontPoint2 ()
|
||||
{
|
||||
globalindex = -1;
|
||||
globalindex.Invalidate(); // = -1;
|
||||
nlinetopoint = 0;
|
||||
frontnr = INT_MAX-10; // attention: overflow on calculating INT_MAX + 1
|
||||
mgi = NULL;
|
||||
|
@ -9,7 +9,7 @@ namespace netgen
|
||||
|
||||
FrontPoint3 :: FrontPoint3 ()
|
||||
{
|
||||
globalindex = -1;
|
||||
globalindex.Invalidate(); // = -1;
|
||||
nfacetopoint = 0;
|
||||
frontnr = 1000;
|
||||
cluster = 0;
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
void AddFace ()
|
||||
{ nfacetopoint++; }
|
||||
|
||||
///
|
||||
/// if last face is removed, then point is invalidated
|
||||
void RemoveFace()
|
||||
{
|
||||
nfacetopoint--;
|
||||
@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
///
|
||||
int Valid () const
|
||||
bool Valid () const
|
||||
{ return nfacetopoint >= 0; }
|
||||
|
||||
///
|
||||
@ -74,7 +74,7 @@ class MiniElement2d
|
||||
{
|
||||
protected:
|
||||
int np;
|
||||
PointIndex pnum[4];
|
||||
PointIndex pnum[4]; // can be global or local nums
|
||||
bool deleted;
|
||||
public:
|
||||
MiniElement2d ()
|
||||
@ -89,8 +89,8 @@ public:
|
||||
const PointIndex PNum (int i) const { return pnum[i-1]; }
|
||||
PointIndex & PNum (int i) { return pnum[i-1]; }
|
||||
const PointIndex PNumMod (int i) const { return pnum[(i-1)%np]; }
|
||||
|
||||
void Delete () { deleted = 1; pnum[0] = pnum[1] = pnum[2] = pnum[3] = PointIndex::BASE-1; }
|
||||
auto PNums() const { return FlatArray<const PointIndex> (np, &pnum[0]); }
|
||||
void Delete () { deleted = true; for (PointIndex & p : pnum) p.Invalidate(); }
|
||||
bool IsDeleted () const { return deleted; }
|
||||
};
|
||||
|
||||
@ -208,7 +208,7 @@ int rebuildcounter;
|
||||
int lasti;
|
||||
/// minimal selection-value of baseelements
|
||||
int minval;
|
||||
Array<int, PointIndex::BASE, PointIndex> invpindex;
|
||||
Array<PointIndex, PointIndex::BASE, PointIndex> invpindex;
|
||||
Array<char> pingroup;
|
||||
|
||||
///
|
||||
|
@ -3873,7 +3873,7 @@ namespace netgen
|
||||
Mat<DIM_SPACE,2,T> _dxdxi;
|
||||
if (!EvaluateMapping (info, _xi, _x, _dxdxi))
|
||||
{ ok = false; break; }
|
||||
// cout << "x = " << _x << ", dxdxi = " << _dxdxi << endl;
|
||||
// *testout << "x = " << _x << ", dxdxi = " << _dxdxi << endl;
|
||||
if (x)
|
||||
for (int j = 0; j < DIM_SPACE; j++)
|
||||
x[i*sx+j] = _x[j];
|
||||
|
@ -415,9 +415,9 @@ namespace netgen
|
||||
|
||||
INDEX_3 i3 = tempels.Get(helind).GetFace (k-1);
|
||||
|
||||
const Point3d & p1 = mesh.Point ( i3.I1());
|
||||
const Point3d & p2 = mesh.Point ( i3.I2());
|
||||
const Point3d & p3 = mesh.Point ( i3.I3());
|
||||
const Point3d & p1 = mesh.Point ( PointIndex (i3.I1()) );
|
||||
const Point3d & p2 = mesh.Point ( PointIndex (i3.I2()) );
|
||||
const Point3d & p3 = mesh.Point ( PointIndex (i3.I3()) );
|
||||
|
||||
|
||||
Vec3d v1(p1, p2);
|
||||
@ -612,17 +612,17 @@ namespace netgen
|
||||
for (int i = 1; i <= adfront->GetNF(); i++)
|
||||
{
|
||||
const MiniElement2d & face = adfront->GetFace(i);
|
||||
for (int j = 0; j < face.GetNP(); j++)
|
||||
for (PointIndex pi : face.PNums())
|
||||
{
|
||||
pmin.SetToMin (mesh.Point (face[j]));
|
||||
pmax.SetToMax (mesh.Point (face[j]));
|
||||
pmin.SetToMin (mesh.Point (pi));
|
||||
pmax.SetToMax (mesh.Point (pi));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < mesh.LockedPoints().Size(); i++)
|
||||
for (PointIndex pi : mesh.LockedPoints())
|
||||
{
|
||||
pmin.SetToMin (mesh.Point (mesh.LockedPoints()[i]));
|
||||
pmax.SetToMax (mesh.Point (mesh.LockedPoints()[i]));
|
||||
pmin.SetToMin (mesh.Point (pi));
|
||||
pmax.SetToMax (mesh.Point (pi));
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,8 +216,10 @@ namespace netgen
|
||||
|
||||
int GetNP () const { return points.Size(); }
|
||||
|
||||
// [[deprecated("Use Point(PointIndex) instead of int !")]]
|
||||
MeshPoint & Point(int i) { return points.Elem(i); }
|
||||
MeshPoint & Point(PointIndex pi) { return points[pi]; }
|
||||
// [[deprecated("Use Point(PointIndex) instead of int !")]]
|
||||
const MeshPoint & Point(int i) const { return points.Get(i); }
|
||||
const MeshPoint & Point(PointIndex pi) const { return points[pi]; }
|
||||
|
||||
@ -231,8 +233,8 @@ namespace netgen
|
||||
DLL_HEADER SegmentIndex AddSegment (const Segment & s);
|
||||
void DeleteSegment (int segnr)
|
||||
{
|
||||
segments.Elem(segnr)[0] = PointIndex::BASE-1;
|
||||
segments.Elem(segnr)[1] = PointIndex::BASE-1;
|
||||
segments.Elem(segnr)[0].Invalidate();
|
||||
segments.Elem(segnr)[1].Invalidate();
|
||||
}
|
||||
void FullDeleteSegment (int segnr) // von wem ist das ???
|
||||
{
|
||||
@ -257,9 +259,9 @@ namespace netgen
|
||||
void DeleteSurfaceElement (int eli)
|
||||
{
|
||||
surfelements.Elem(eli).Delete();
|
||||
surfelements.Elem(eli).PNum(1) = -1;
|
||||
surfelements.Elem(eli).PNum(2) = -1;
|
||||
surfelements.Elem(eli).PNum(3) = -1;
|
||||
surfelements.Elem(eli).PNum(1).Invalidate();
|
||||
surfelements.Elem(eli).PNum(2).Invalidate();
|
||||
surfelements.Elem(eli).PNum(3).Invalidate();
|
||||
timestamp = NextTimeStamp();
|
||||
}
|
||||
|
||||
@ -290,7 +292,9 @@ namespace netgen
|
||||
|
||||
int GetNE () const { return volelements.Size(); }
|
||||
|
||||
// [[deprecated("Use VolumeElement(ElementIndex) instead of int !")]]
|
||||
Element & VolumeElement(int i) { return volelements.Elem(i); }
|
||||
// [[deprecated("Use VolumeElement(ElementIndex) instead of int !")]]
|
||||
const Element & VolumeElement(int i) const { return volelements.Get(i); }
|
||||
Element & VolumeElement(ElementIndex i) { return volelements[i]; }
|
||||
const Element & VolumeElement(ElementIndex i) const { return volelements[i]; }
|
||||
|
@ -538,6 +538,9 @@ namespace netgen
|
||||
shape(3) = (1-p(0))* p(1) ;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
throw NgException ("illegal element type in GetShapeNew");
|
||||
}
|
||||
}
|
||||
|
||||
@ -562,6 +565,8 @@ namespace netgen
|
||||
shape(3) = (1-p(0))* p(1) ;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw NgException ("illegal element type in GetShapeNew");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,6 +125,8 @@ namespace netgen
|
||||
PointIndex operator-- (int) { PointIndex hi(*this); i--; return hi; }
|
||||
PointIndex operator++ () { i++; return *this; }
|
||||
PointIndex operator-- () { i--; return *this; }
|
||||
void Invalidate() { i = PointIndex::BASE-1; }
|
||||
bool IsValid() const { return i != PointIndex::BASE-1; }
|
||||
#ifdef BASE0
|
||||
enum { BASE = 0 };
|
||||
#else
|
||||
@ -134,7 +136,7 @@ namespace netgen
|
||||
|
||||
inline istream & operator>> (istream & ist, PointIndex & pi)
|
||||
{
|
||||
int i; ist >> i; pi = i; return ist;
|
||||
int i; ist >> i; pi = PointIndex(i); return ist;
|
||||
}
|
||||
|
||||
inline ostream & operator<< (ostream & ost, const PointIndex & pi)
|
||||
@ -472,7 +474,13 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
void Delete () { deleted = 1; pnum[0] = pnum[1] = pnum[2] = pnum[3] = PointIndex::BASE-1; }
|
||||
void Delete ()
|
||||
{
|
||||
deleted = 1;
|
||||
for (PointIndex & p : pnum)
|
||||
p.Invalidate();
|
||||
}
|
||||
|
||||
bool IsDeleted () const
|
||||
{
|
||||
#ifdef DEBUG
|
||||
|
@ -1422,19 +1422,18 @@ void Mesh :: ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal)
|
||||
|
||||
if(lochfunc)
|
||||
{
|
||||
for(int i=1; i<=points.Size(); i++)
|
||||
pointh[i] = GetH(points.Get(i));
|
||||
for (PointIndex pi : points.Range())
|
||||
pointh[pi] = GetH(points[pi]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pointh = 0;
|
||||
for(int i=0; i<GetNE(); i++)
|
||||
for (Element & el : VolumeElements())
|
||||
{
|
||||
const Element & el = VolumeElement(i+1);
|
||||
double h = pow(el.Volume(points),1./3.);
|
||||
for(int j=1; j<=el.GetNV(); j++)
|
||||
if(h > pointh[el.PNum(j)])
|
||||
pointh[el.PNum(j)] = h;
|
||||
for (PointIndex pi : el.PNums())
|
||||
if (h > pointh[pi])
|
||||
pointh[pi] = h;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1456,20 +1455,14 @@ void Mesh :: ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal)
|
||||
const char * savetask = multithread.task;
|
||||
multithread.task = "Smooth Mesh";
|
||||
|
||||
for (PointIndex pi = points.Begin(); pi < points.End(); pi++)
|
||||
for (PointIndex pi : points.Range())
|
||||
if ( (*this)[pi].Type() == INNERPOINT && perrs[pi] > 0.01 * badmax)
|
||||
{
|
||||
if (multithread.terminate)
|
||||
throw NgException ("Meshing stopped");
|
||||
|
||||
multithread.percent = 100.0 * (pi+1-PointIndex::BASE) / points.Size();
|
||||
/*
|
||||
if (points.Size() < 1000)
|
||||
PrintDot ();
|
||||
else
|
||||
if ( (i+1-PointIndex::BASE) % 10 == 0)
|
||||
PrintDot ('+');
|
||||
*/
|
||||
|
||||
if ( (pi+1-PointIndex::BASE) % printmod == 0) PrintDot (printdot);
|
||||
|
||||
double lh = pointh[pi];
|
||||
@ -1503,7 +1496,6 @@ void Mesh :: ImproveMesh (const MeshingParameters & mp, OPTIMIZEGOAL goal)
|
||||
}
|
||||
PrintDot ('\n');
|
||||
|
||||
|
||||
delete pf;
|
||||
|
||||
multithread.task = savetask;
|
||||
|
@ -63,8 +63,8 @@ namespace netgen
|
||||
|
||||
int VisualScene :: selface;
|
||||
int VisualScene :: selelement;
|
||||
int VisualScene :: selpoint;
|
||||
int VisualScene :: selpoint2;
|
||||
PointIndex VisualScene :: selpoint;
|
||||
PointIndex VisualScene :: selpoint2;
|
||||
int VisualScene :: locpi;
|
||||
int VisualScene :: seledge;
|
||||
|
||||
|
@ -26,8 +26,8 @@ namespace netgen
|
||||
|
||||
static int DLL_HEADER selface;
|
||||
static int selelement;
|
||||
static int DLL_HEADER selpoint;
|
||||
static int selpoint2;
|
||||
static PointIndex DLL_HEADER selpoint;
|
||||
static PointIndex selpoint2;
|
||||
static int locpi;
|
||||
static int DLL_HEADER seledge;
|
||||
|
||||
@ -235,8 +235,8 @@ namespace netgen
|
||||
const Point3d & center,
|
||||
const double rad,
|
||||
const int displaylist,
|
||||
int & selelement, int & selface, int & seledge, int & selpoint,
|
||||
int & selpoint2, int & locpi);
|
||||
int & selelement, int & selface, int & seledge, PointIndex & selpoint,
|
||||
PointIndex & selpoint2, int & locpi);
|
||||
|
||||
|
||||
}
|
||||
|
@ -3343,8 +3343,8 @@ namespace netgen
|
||||
const Point3d & center,
|
||||
const double rad,
|
||||
const int displaylist,
|
||||
int & selelement, int & selface, int & seledge, int & selpoint,
|
||||
int & selpoint2, int & locpi)
|
||||
int & selelement, int & selface, int & seledge, PointIndex & selpoint,
|
||||
PointIndex & selpoint2, int & locpi)
|
||||
{
|
||||
auto mesh = vsmesh.GetMesh();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user