2022-02-25 20:50:26 +05:00
|
|
|
#include "meshing.hpp"
|
|
|
|
|
|
|
|
namespace netgen
|
|
|
|
{
|
2022-02-28 21:24:44 +05:00
|
|
|
|
2022-02-25 20:50:26 +05:00
|
|
|
static inline Point<2> P2( Point<3> p )
|
|
|
|
{
|
|
|
|
return {p[0], p[1]};
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Point<3> P3( Point<2> p )
|
|
|
|
{
|
|
|
|
return {p[0], p[1], 0};
|
|
|
|
}
|
|
|
|
|
|
|
|
class DelaunayTrig
|
|
|
|
{
|
|
|
|
PointIndex pnums[3];
|
|
|
|
Point<2> c;
|
|
|
|
|
|
|
|
public:
|
|
|
|
double r;
|
|
|
|
double rad2;
|
|
|
|
DelaunayTrig () = default;
|
|
|
|
DelaunayTrig (int p1, int p2, int p3)
|
|
|
|
{
|
|
|
|
pnums[0] = p1;
|
|
|
|
pnums[1] = p2;
|
|
|
|
pnums[2] = p3;
|
|
|
|
}
|
|
|
|
|
|
|
|
PointIndex & operator[] (int j) { return pnums[j]; }
|
|
|
|
const PointIndex & operator[] (int j) const { return pnums[j]; }
|
|
|
|
|
|
|
|
void CalcCenter (FlatArray<Point<2>, PointIndex> points);
|
|
|
|
|
|
|
|
Point<2> Center() const { return c; }
|
|
|
|
double Radius2() const { return rad2; }
|
|
|
|
Box<2> BoundingBox() const { return Box<2> (c-Vec<2>(r,r), c+Vec<2>(r,r)); }
|
|
|
|
|
|
|
|
mutable PointIndex visited_pi = -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DelaunayMesh
|
|
|
|
{
|
2024-02-12 11:36:15 +05:00
|
|
|
ngcore::ClosedHashTable<IVec<2>, IVec<2>> edge_to_trig;
|
2022-02-25 20:50:26 +05:00
|
|
|
Array<DelaunayTrig> trigs;
|
|
|
|
unique_ptr<DelaunayTree<2>> tree;
|
|
|
|
Array<Point<2>, PointIndex> & points;
|
|
|
|
|
|
|
|
Array<int> closeels;
|
|
|
|
Array<int> intersecting;
|
2024-02-12 11:36:15 +05:00
|
|
|
Array<IVec<2>> edges;
|
2022-02-25 20:50:26 +05:00
|
|
|
|
|
|
|
int GetNeighbour( int eli, int edge );
|
|
|
|
|
|
|
|
void SetNeighbour( int eli, int edge );
|
|
|
|
|
|
|
|
void UnsetNeighbours( int eli );
|
|
|
|
|
|
|
|
void AppendTrig( int pi0, int pi1, int pi2 );
|
|
|
|
|
|
|
|
public:
|
|
|
|
DelaunayMesh( Array<Point<2>, PointIndex> & points_, Box<2> box );
|
|
|
|
|
|
|
|
void CalcIntersecting( PointIndex pi_new );
|
|
|
|
void CalcWeights( PointIndex pi_new, std::map<PointIndex, double> & weights );
|
2022-03-01 18:56:01 +05:00
|
|
|
void AddPoint( PointIndex pi_new );
|
2022-02-25 20:50:26 +05:00
|
|
|
Array<DelaunayTrig> & GetElements() { return trigs; }
|
2022-03-02 00:18:05 +05:00
|
|
|
unique_ptr<Mesh> GetMesh(PointIndex pi_new); // for debugging purposes
|
2022-02-25 20:50:26 +05:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace netgen
|