Path: blob/devel/ElmerGUI/netgen/libsrc/meshing/adfront3.hpp
3206 views
#ifndef FILE_ADFRONT31#define FILE_ADFRONT323/**************************************************************************/4/* File: adfront3.hh */5/* Author: Joachim Schoeberl */6/* Date: 01. Okt. 95 */7/**************************************************************************/89/*10Advancing front class for volume meshing11*/12131415/// Point in advancing front16class FrontPoint317{18/// coordinates19Point<3> p;20/// global node index21PointIndex globalindex;22/// number of faces connected to point23int nfacetopoint;24/// distance to original boundary25int frontnr;26///27int cluster;28public:29///30FrontPoint3 ();31///32FrontPoint3 (const Point<3> & ap, PointIndex agi);3334///35const Point<3> & P () const36{ return p; }37///38PointIndex GlobalIndex () const39{ return globalindex; }4041///42void AddFace ()43{ nfacetopoint++; }4445///46void RemoveFace()47{48nfacetopoint--;49if (nfacetopoint == 0) nfacetopoint = -1;50}5152///53int Valid () const54{ return nfacetopoint >= 0; }5556///57void DecFrontNr (int afrontnr)58{59if (frontnr > afrontnr) frontnr = afrontnr;60}6162///63int FrontNr () const64{ return frontnr; }6566///67friend class AdFront3;68};69707172class MiniElement2d73{74protected:75int np;76PointIndex pnum[4];77bool deleted;78public:79MiniElement2d ()80{ np = 3; deleted = 0; }81MiniElement2d (int anp)82{ np = anp; deleted = 0; }8384int GetNP() const { return np; }85PointIndex & operator[] (int i) { return pnum[i]; }86const PointIndex operator[] (int i) const { return pnum[i]; }8788const PointIndex PNum (int i) const { return pnum[i-1]; }89PointIndex & PNum (int i) { return pnum[i-1]; }90const PointIndex PNumMod (int i) const { return pnum[(i-1)%np]; }9192void Delete () { deleted = 1; pnum[0] = pnum[1] = pnum[2] = pnum[3] = PointIndex::BASE-1; }93bool IsDeleted () const { return deleted; }94};959697inline ostream & operator<<(ostream & s, const MiniElement2d & el)98{99s << "np = " << el.GetNP();100for (int j = 0; j < el.GetNP(); j++)101s << " " << el[j];102return s;103}104105106107108/// Face in advancing front109class FrontFace110{111private:112///113MiniElement2d f;114///115int qualclass;116///117char oldfront;118///119int hashvalue;120///121int cluster;122123public:124///125FrontFace ();126///127FrontFace (const MiniElement2d & af);128///129const MiniElement2d & Face () const130{ return f; }131132///133int QualClass () const134{ return qualclass; }135136///137void IncrementQualClass ()138{ qualclass++; }139140///141void ResetQualClass ()142{143if (qualclass > 1)144{145qualclass = 1;146oldfront = 0;147}148}149150///151bool Valid () const152{ return !f.IsDeleted(); }153154///155void Invalidate ();156157///158int HashValue() const159{ return hashvalue; }160161///162void SetHashValue(int hv)163{ hashvalue = hv; }164165///166friend class AdFront3;167168int Cluster () const { return cluster; }169};170171172173174/// Advancing front, 3D.175class AdFront3176{177///178ARRAY<FrontPoint3, PointIndex::BASE> points;179///180ARRAY<FrontFace> faces;181///182ARRAY<PointIndex> delpointl;183184/// which points are connected to pi ?185TABLE<int, PointIndex::BASE> * connectedpairs;186187/// number of total front faces;188int nff;189/// number of quads in front190int nff4;191192///193double vol;194195///196GeomSearch3d hashtable;197198///199int hashon;200201///202int hashcreated;203204/// counter for rebuilding internal tables205int rebuildcounter;206/// last base element207int lasti;208/// minimal selection-value of baseelements209int minval;210211///212class Box3dTree * facetree;213public:214215///216AdFront3 ();217///218~AdFront3 ();219///220void GetPoints (ARRAY<Point<3> > & apoints) const;221///222int GetNP() const223{ return points.Size(); }224///225const Point<3> & GetPoint (PointIndex pi) const226{ return points[pi].P(); }227///228int GetNF() const229{ return nff; }230///231const MiniElement2d & GetFace (int i) const232{ return faces.Get(i).Face(); }233///234void Print () const;235///236bool Empty () const237{ return nff == 0; }238///239bool Empty (int elnp) const240{241if (elnp == 4)242return (nff4 == 0);243return (nff - nff4 == 0);244}245///246int SelectBaseElement ();247248///249void CreateTrees ();250251///252void GetIntersectingFaces (const Point<3> & pmin, const Point<3> & pmax,253ARRAY<int> & ifaces) const;254255///256void GetFaceBoundingBox (int i, Box3d & box) const;257258///259int GetLocals (int baseelement,260ARRAY<Point3d > & locpoints,261ARRAY<MiniElement2d> & locfaces, // local index262ARRAY<PointIndex> & pindex,263ARRAY<INDEX> & findex,264INDEX_2_HASHTABLE<int> & connectedpairs,265float xh,266float relh,267INDEX& facesplit);268269///270void GetGroup (int fi,271ARRAY<MeshPoint> & grouppoints,272ARRAY<MiniElement2d> & groupelements,273ARRAY<PointIndex> & pindex,274ARRAY<INDEX> & findex275) const;276277///278void DeleteFace (INDEX fi);279///280PointIndex AddPoint (const Point<3> & p, PointIndex globind);281///282INDEX AddFace (const MiniElement2d & e);283///284INDEX AddConnectedPair (const INDEX_2 & pair);285///286void IncrementClass (INDEX fi)287{ faces.Elem(fi).IncrementQualClass(); }288289///290void ResetClass (INDEX fi)291{ faces.Elem(fi).ResetQualClass(); }292293///294void SetStartFront (int baseelnp = 0);295296/// is Point p inside Surface ?297bool Inside (const Point<3> & p) const;298/// both points on same side ?299int SameSide (const Point<3> & lp1, const Point<3> & lp2,300const ARRAY<int> * testfaces = NULL) const;301302303///304PointIndex GetGlobalIndex (PointIndex pi) const305{ return points[pi].GlobalIndex(); }306///307double Volume () const308{ return vol; }309310311private:312void RebuildInternalTables();313};314315316317318#endif319320321