netgen/libsrc/meshing/adfront3.hpp

321 lines
6.1 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef FILE_ADFRONT3
#define FILE_ADFRONT3
/**************************************************************************/
/* File: adfront3.hh */
/* Author: Joachim Schoeberl */
/* Date: 01. Okt. 95 */
/**************************************************************************/
/*
Advancing front class for volume meshing
*/
/// Point in advancing front
class FrontPoint3
{
/// coordinates
2016-12-11 16:12:05 +05:00
Point<3> p;
2009-01-13 04:40:13 +05:00
/// global node index
2016-12-11 16:12:05 +05:00
PointIndex globalindex;
2009-01-13 04:40:13 +05:00
/// number of faces connected to point
2016-12-11 16:12:05 +05:00
int nfacetopoint;
2009-01-13 04:40:13 +05:00
/// distance to original boundary
2016-12-11 16:12:05 +05:00
int frontnr;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
int cluster;
2009-01-13 04:40:13 +05:00
public:
///
FrontPoint3 ();
///
FrontPoint3 (const Point<3> & ap, PointIndex agi);
///
const Point<3> & P () const
{ return p; }
///
PointIndex GlobalIndex () const
{ return globalindex; }
///
void AddFace ()
{ nfacetopoint++; }
2016-12-11 16:12:05 +05:00
/// if last face is removed, then point is invalidated
2009-01-13 04:40:13 +05:00
void RemoveFace()
{
nfacetopoint--;
if (nfacetopoint == 0) nfacetopoint = -1;
}
///
2016-12-11 16:12:05 +05:00
bool Valid () const
2009-01-13 04:40:13 +05:00
{ return nfacetopoint >= 0; }
///
void DecFrontNr (int afrontnr)
{
if (frontnr > afrontnr) frontnr = afrontnr;
}
///
int FrontNr () const
{ return frontnr; }
///
friend class AdFront3;
};
class MiniElement2d
{
protected:
int np;
2016-12-11 16:12:05 +05:00
PointIndex pnum[4]; // can be global or local nums
2009-01-13 04:40:13 +05:00
bool deleted;
public:
MiniElement2d ()
{ np = 3; deleted = 0; }
MiniElement2d (int anp)
{ np = anp; deleted = 0; }
int GetNP() const { return np; }
PointIndex & operator[] (int i) { return pnum[i]; }
const PointIndex operator[] (int i) const { return pnum[i]; }
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]; }
2016-12-11 16:12:05 +05:00
auto PNums() const { return FlatArray<const PointIndex> (np, &pnum[0]); }
void Delete () { deleted = true; for (PointIndex & p : pnum) p.Invalidate(); }
2009-01-13 04:40:13 +05:00
bool IsDeleted () const { return deleted; }
};
inline ostream & operator<<(ostream & s, const MiniElement2d & el)
{
s << "np = " << el.GetNP();
for (int j = 0; j < el.GetNP(); j++)
s << " " << el[j];
return s;
}
/// Face in advancing front
class FrontFace
{
private:
///
MiniElement2d f;
///
int qualclass;
///
char oldfront;
///
int hashvalue;
///
int cluster;
2016-12-11 16:12:05 +05:00
2009-01-13 04:40:13 +05:00
public:
///
FrontFace ();
///
FrontFace (const MiniElement2d & af);
///
const MiniElement2d & Face () const
{ return f; }
///
int QualClass () const
{ return qualclass; }
///
void IncrementQualClass ()
{ qualclass++; }
///
void ResetQualClass ()
{
if (qualclass > 1)
{
qualclass = 1;
oldfront = 0;
}
}
///
bool Valid () const
{ return !f.IsDeleted(); }
///
void Invalidate ();
///
int HashValue() const
{ return hashvalue; }
///
void SetHashValue(int hv)
{ hashvalue = hv; }
///
friend class AdFront3;
int Cluster () const { return cluster; }
};
/// Advancing front, 3D.
class AdFront3
{
///
2013-04-03 02:29:53 +06:00
Array<FrontPoint3, PointIndex::BASE, PointIndex> points;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
Array<FrontFace> faces;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
Array<PointIndex> delpointl;
2009-01-13 04:40:13 +05:00
/// which points are connected to pi ?
2016-12-11 16:12:05 +05:00
TABLE<int, PointIndex::BASE> * connectedpairs;
2009-01-13 04:40:13 +05:00
/// number of total front faces;
2016-12-11 16:12:05 +05:00
int nff;
2009-01-13 04:40:13 +05:00
/// number of quads in front
2016-12-11 16:12:05 +05:00
int nff4;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
double vol;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
GeomSearch3d hashtable;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
int hashon;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
int hashcreated;
2009-01-13 04:40:13 +05:00
/// counter for rebuilding internal tables
2016-12-11 16:12:05 +05:00
int rebuildcounter;
2009-01-13 04:40:13 +05:00
/// last base element
2016-12-11 16:12:05 +05:00
int lasti;
2009-01-13 04:40:13 +05:00
/// minimal selection-value of baseelements
2016-12-11 16:12:05 +05:00
int minval;
Array<PointIndex, PointIndex::BASE, PointIndex> invpindex;
2011-07-25 15:38:37 +06:00
Array<char> pingroup;
2009-01-13 04:40:13 +05:00
///
2016-12-11 16:12:05 +05:00
class Box3dTree * facetree;
2009-01-13 04:40:13 +05:00
public:
2016-12-11 16:12:05 +05:00
2009-01-13 04:40:13 +05:00
///
AdFront3 ();
///
~AdFront3 ();
///
2009-01-25 17:35:25 +05:00
void GetPoints (Array<Point<3> > & apoints) const;
2009-01-13 04:40:13 +05:00
///
int GetNP() const
{ return points.Size(); }
///
const Point<3> & GetPoint (PointIndex pi) const
{ return points[pi].P(); }
///
int GetNF() const
{ return nff; }
///
const MiniElement2d & GetFace (int i) const
{ return faces.Get(i).Face(); }
///
void Print () const;
///
bool Empty () const
{ return nff == 0; }
///
bool Empty (int elnp) const
{
if (elnp == 4)
return (nff4 == 0);
return (nff - nff4 == 0);
}
///
int SelectBaseElement ();
///
void CreateTrees ();
///
void GetIntersectingFaces (const Point<3> & pmin, const Point<3> & pmax,
2009-01-25 17:35:25 +05:00
Array<int> & ifaces) const;
2009-01-13 04:40:13 +05:00
///
void GetFaceBoundingBox (int i, Box3d & box) const;
///
int GetLocals (int baseelement,
2016-12-11 22:02:16 +05:00
Array<Point3d, PointIndex::BASE> & locpoints,
2009-01-25 17:35:25 +05:00
Array<MiniElement2d> & locfaces, // local index
2016-12-11 22:02:16 +05:00
Array<PointIndex, PointIndex::BASE> & pindex,
2009-01-25 17:35:25 +05:00
Array<INDEX> & findex,
2009-01-13 04:40:13 +05:00
INDEX_2_HASHTABLE<int> & connectedpairs,
float xh,
float relh,
INDEX& facesplit);
///
void GetGroup (int fi,
2016-12-11 22:02:16 +05:00
Array<MeshPoint, PointIndex::BASE> & grouppoints,
2009-01-25 17:35:25 +05:00
Array<MiniElement2d> & groupelements,
2016-12-11 22:02:16 +05:00
Array<PointIndex, PointIndex::BASE> & pindex,
2011-07-25 15:38:37 +06:00
Array<INDEX> & findex);
2009-01-13 04:40:13 +05:00
///
void DeleteFace (INDEX fi);
///
PointIndex AddPoint (const Point<3> & p, PointIndex globind);
///
INDEX AddFace (const MiniElement2d & e);
///
INDEX AddConnectedPair (const INDEX_2 & pair);
///
void IncrementClass (INDEX fi)
{ faces.Elem(fi).IncrementQualClass(); }
///
void ResetClass (INDEX fi)
{ faces.Elem(fi).ResetQualClass(); }
///
void SetStartFront (int baseelnp = 0);
/// is Point p inside Surface ?
bool Inside (const Point<3> & p) const;
/// both points on same side ?
int SameSide (const Point<3> & lp1, const Point<3> & lp2,
2009-01-25 17:35:25 +05:00
const Array<int> * testfaces = NULL) const;
2009-01-13 04:40:13 +05:00
///
PointIndex GetGlobalIndex (PointIndex pi) const
{ return points[pi].GlobalIndex(); }
///
double Volume () const
{ return vol; }
private:
void RebuildInternalTables();
};
#endif