rename INT to IVec (avoiding windows name conflict)

This commit is contained in:
Joachim Schoeberl 2024-02-12 07:36:15 +01:00
parent 759b66fb69
commit c87aea14eb
8 changed files with 131 additions and 135 deletions

View File

@ -41,39 +41,39 @@ namespace ngcore
/// N integers /// N integers
template <int N, typename T = int> template <int N, typename T = int>
class INT class IVec
{ {
/// data /// data
T i[(N>0)?N:1]; T i[(N>0)?N:1];
public: public:
/// ///
NETGEN_INLINE INT () { } NETGEN_INLINE IVec () { }
/// init all /// init all
NETGEN_INLINE INT (T ai1) NETGEN_INLINE IVec (T ai1)
{ {
for (int j = 0; j < N; j++) { i[j] = ai1; } for (int j = 0; j < N; j++) { i[j] = ai1; }
} }
/// init i[0], i[1] /// init i[0], i[1]
constexpr NETGEN_INLINE INT (T ai1, T ai2) constexpr NETGEN_INLINE IVec (T ai1, T ai2)
: i{ai1, ai2} { ; } : i{ai1, ai2} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
constexpr NETGEN_INLINE INT (T ai1, T ai2, T ai3) constexpr NETGEN_INLINE IVec (T ai1, T ai2, T ai3)
: i{ai1, ai2, ai3} { ; } : i{ai1, ai2, ai3} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
constexpr NETGEN_INLINE INT (T ai1, T ai2, T ai3, T ai4) constexpr NETGEN_INLINE IVec (T ai1, T ai2, T ai3, T ai4)
: i{ai1, ai2, ai3, ai4} { ; } : i{ai1, ai2, ai3, ai4} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
constexpr NETGEN_INLINE INT (T ai1, T ai2, T ai3, T ai4, T ai5) constexpr NETGEN_INLINE IVec (T ai1, T ai2, T ai3, T ai4, T ai5)
: i{ai1, ai2, ai3, ai4, ai5} { ; } : i{ai1, ai2, ai3, ai4, ai5} { ; }
/// init i[0], i[1], i[2] /// init i[0], i[1], i[2]
NETGEN_INLINE INT (T ai1, T ai2, T ai3, T ai4, T ai5, T ai6, T ai7, T ai8, T ai9) NETGEN_INLINE IVec (T ai1, T ai2, T ai3, T ai4, T ai5, T ai6, T ai7, T ai8, T ai9)
: i{ai1, ai2, ai3, ai4, ai5, ai6, ai7, ai8, ai9 } { ; } : i{ai1, ai2, ai3, ai4, ai5, ai6, ai7, ai8, ai9 } { ; }
template <typename ARCHIVE> template <typename ARCHIVE>
@ -83,7 +83,7 @@ namespace ngcore
} }
template <int N2, typename T2> template <int N2, typename T2>
NETGEN_INLINE INT (const INT<N2,T2> & in2) NETGEN_INLINE IVec (const IVec<N2,T2> & in2)
{ {
if (N2 <= N) if (N2 <= N)
{ {
@ -100,7 +100,7 @@ namespace ngcore
} }
template <typename T2> template <typename T2>
NETGEN_INLINE INT (const BaseArrayObject<T2> & ao) NETGEN_INLINE IVec (const BaseArrayObject<T2> & ao)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
i[j] = ao.Spec()[j]; i[j] = ao.Spec()[j];
@ -108,7 +108,7 @@ namespace ngcore
NETGEN_INLINE size_t Size() const { return N; } NETGEN_INLINE size_t Size() const { return N; }
/// all ints equal ? /// all ints equal ?
NETGEN_INLINE bool operator== (const INT & in2) const NETGEN_INLINE bool operator== (const IVec & in2) const
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
if (i[j] != in2.i[j]) return 0; if (i[j] != in2.i[j]) return 0;
@ -116,7 +116,7 @@ namespace ngcore
} }
/// any ints unequal ? /// any ints unequal ?
NETGEN_INLINE bool operator!= (const INT & in2) const NETGEN_INLINE bool operator!= (const IVec & in2) const
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
if (i[j] != in2.i[j]) return 1; if (i[j] != in2.i[j]) return 1;
@ -124,7 +124,7 @@ namespace ngcore
} }
/// sort integers /// sort integers
NETGEN_INLINE INT & Sort () & NETGEN_INLINE IVec & Sort () &
{ {
for (int k = 0; k < N; k++) for (int k = 0; k < N; k++)
for (int l = k+1; l < N; l++) for (int l = k+1; l < N; l++)
@ -133,7 +133,7 @@ namespace ngcore
return *this; return *this;
} }
NETGEN_INLINE INT Sort () && NETGEN_INLINE IVec Sort () &&
{ {
for (int k = 0; k < N; k++) for (int k = 0; k < N; k++)
for (int l = k+1; l < N; l++) for (int l = k+1; l < N; l++)
@ -155,7 +155,7 @@ namespace ngcore
operator FlatArray<T> () { return FlatArray<T> (N, &i[0]); } operator FlatArray<T> () { return FlatArray<T> (N, &i[0]); }
NETGEN_INLINE INT<N,T> & operator= (T value) NETGEN_INLINE IVec<N,T> & operator= (T value)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
i[j] = value; i[j] = value;
@ -163,7 +163,7 @@ namespace ngcore
} }
template <typename T2> template <typename T2>
NETGEN_INLINE INT<N,T> & operator= (INT<N,T2> v2) NETGEN_INLINE IVec<N,T> & operator= (IVec<N,T2> v2)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
i[j] = v2[j]; i[j] = v2[j];
@ -186,14 +186,14 @@ namespace ngcore
/// sort 2 integers /// sort 2 integers
template <> template <>
NETGEN_INLINE INT<2> & INT<2>::Sort () & NETGEN_INLINE IVec<2> & IVec<2>::Sort () &
{ {
if (i[0] > i[1]) Swap (i[0], i[1]); if (i[0] > i[1]) Swap (i[0], i[1]);
return *this; return *this;
} }
template <> template <>
NETGEN_INLINE INT<2> INT<2>::Sort () && NETGEN_INLINE IVec<2> IVec<2>::Sort () &&
{ {
if (i[0] > i[1]) Swap (i[0], i[1]); if (i[0] > i[1]) Swap (i[0], i[1]);
return *this; return *this;
@ -201,7 +201,7 @@ namespace ngcore
/// sort 3 integers /// sort 3 integers
template <> template <>
NETGEN_INLINE INT<3> INT<3>::Sort () && NETGEN_INLINE IVec<3> IVec<3>::Sort () &&
{ {
if (i[0] > i[1]) Swap (i[0], i[1]); if (i[0] > i[1]) Swap (i[0], i[1]);
if (i[1] > i[2]) Swap (i[1], i[2]); if (i[1] > i[2]) Swap (i[1], i[2]);
@ -211,7 +211,7 @@ namespace ngcore
/// Print integers /// Print integers
template <int N, typename T> template <int N, typename T>
inline ostream & operator<<(ostream & s, const INT<N,T> & i2) inline ostream & operator<<(ostream & s, const IVec<N,T> & i2)
{ {
for (int j = 0; j < N; j++) for (int j = 0; j < N; j++)
s << (int) i2[j] << " "; s << (int) i2[j] << " ";
@ -219,15 +219,15 @@ namespace ngcore
} }
template <int N, typename T> template <int N, typename T>
auto begin(const INT<N,T> & ind) auto begin(const IVec<N,T> & ind)
{ {
return AOWrapperIterator<INT<N,T>> (ind, 0); return AOWrapperIterator<IVec<N,T>> (ind, 0);
} }
template <int N, typename T> template <int N, typename T>
auto end(const INT<N,T> & ind) auto end(const IVec<N,T> & ind)
{ {
return AOWrapperIterator<INT<N,T>> (ind, N); return AOWrapperIterator<IVec<N,T>> (ind, N);
} }
@ -236,9 +236,9 @@ namespace ngcore
template <int N, typename TI> template <int N, typename TI>
NETGEN_INLINE size_t HashValue (const INT<N,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<N,TI> & ind, size_t size)
{ {
INT<N,size_t> lind = ind; IVec<N,size_t> lind = ind;
size_t sum = 0; size_t sum = 0;
for (int i = 0; i < N; i++) for (int i = 0; i < N; i++)
sum += lind[i]; sum += lind[i];
@ -247,24 +247,24 @@ namespace ngcore
/// hash value of 1 int /// hash value of 1 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<1,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<1,TI> & ind, size_t size)
{ {
return ind[0] % size; return ind[0] % size;
} }
/// hash value of 2 int /// hash value of 2 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<2,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<2,TI> & ind, size_t size)
{ {
INT<2,size_t> lind = ind; IVec<2,size_t> lind = ind;
return (113*lind[0]+lind[1]) % size; return (113*lind[0]+lind[1]) % size;
} }
/// hash value of 3 int /// hash value of 3 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<3,TI> & ind, size_t size) NETGEN_INLINE size_t HashValue (const IVec<3,TI> & ind, size_t size)
{ {
INT<3,size_t> lind = ind; IVec<3,size_t> lind = ind;
return (113*lind[0]+59*lind[1]+lind[2]) % size; return (113*lind[0]+59*lind[1]+lind[2]) % size;
} }
@ -284,9 +284,9 @@ namespace ngcore
template <int N, typename TI> template <int N, typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<N,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<N,TI> & ind, size_t mask)
{ {
INT<N,size_t> lind = ind; IVec<N,size_t> lind = ind;
size_t sum = 0; size_t sum = 0;
for (int i = 0; i < N; i++) for (int i = 0; i < N; i++)
sum += lind[i]; sum += lind[i];
@ -295,24 +295,24 @@ namespace ngcore
/// hash value of 1 int /// hash value of 1 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<1,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<1,TI> & ind, size_t mask)
{ {
return ind[0] & mask; return ind[0] & mask;
} }
/// hash value of 2 int /// hash value of 2 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<2,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<2,TI> & ind, size_t mask)
{ {
INT<2,size_t> lind = ind; IVec<2,size_t> lind = ind;
return (113*lind[0]+lind[1]) & mask; return (113*lind[0]+lind[1]) & mask;
} }
/// hash value of 3 int /// hash value of 3 int
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue2 (const INT<3,TI> & ind, size_t mask) NETGEN_INLINE size_t HashValue2 (const IVec<3,TI> & ind, size_t mask)
{ {
INT<3,size_t> lind = ind; IVec<3,size_t> lind = ind;
return (113*lind[0]+59*lind[1]+lind[2]) & mask; return (113*lind[0]+59*lind[1]+lind[2]) & mask;
} }
@ -332,7 +332,7 @@ namespace ngcore
// using ngstd::max; // using ngstd::max;
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE T Max (const INT<D,T> & i) NETGEN_INLINE T Max (const IVec<D,T> & i)
{ {
if (D == 0) return 0; if (D == 0) return 0;
T m = i[0]; T m = i[0];
@ -342,7 +342,7 @@ namespace ngcore
} }
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE T Min (const INT<D,T> & i) NETGEN_INLINE T Min (const IVec<D,T> & i)
{ {
if (D == 0) return 0; if (D == 0) return 0;
T m = i[0]; T m = i[0];
@ -352,18 +352,18 @@ namespace ngcore
} }
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE INT<D,T> Max (INT<D,T> i1, INT<D,T> i2) NETGEN_INLINE IVec<D,T> Max (IVec<D,T> i1, IVec<D,T> i2)
{ {
INT<D,T> tmp; IVec<D,T> tmp;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
tmp[i] = std::max(i1[i], i2[i]); tmp[i] = std::max(i1[i], i2[i]);
return tmp; return tmp;
} }
template <int D, typename T> template <int D, typename T>
NETGEN_INLINE INT<D,T> operator+ (INT<D,T> i1, INT<D,T> i2) NETGEN_INLINE IVec<D,T> operator+ (IVec<D,T> i1, IVec<D,T> i2)
{ {
INT<D,T> tmp; IVec<D,T> tmp;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
tmp[i] = i1[i]+i2[i]; tmp[i] = i1[i]+i2[i];
return tmp; return tmp;
@ -828,21 +828,21 @@ namespace ngcore
} }
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<3,TI> ind) NETGEN_INLINE size_t HashValue (const IVec<3,TI> ind)
{ {
INT<3,size_t> lind = ind; IVec<3,size_t> lind = ind;
return 113*lind[0]+59*lind[1]+lind[2]; return 113*lind[0]+59*lind[1]+lind[2];
} }
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<2,TI> ind) NETGEN_INLINE size_t HashValue (const IVec<2,TI> ind)
{ {
INT<2,size_t> lind = ind; IVec<2,size_t> lind = ind;
return 113*lind[0]+lind[1]; return 113*lind[0]+lind[1];
} }
template <typename TI> template <typename TI>
NETGEN_INLINE size_t HashValue (const INT<1,TI> ind) NETGEN_INLINE size_t HashValue (const IVec<1,TI> ind)
{ {
return ind[0]; return ind[0];
} }
@ -1075,7 +1075,7 @@ namespace ngcore
#ifdef PARALLEL #ifdef PARALLEL
namespace ngcore { namespace ngcore {
template<int S, typename T> template<int S, typename T>
class MPI_typetrait<ngcore::INT<S, T> > class MPI_typetrait<ngcore::IVec<S, T> >
{ {
public: public:
/// gets the MPI datatype /// gets the MPI datatype
@ -1099,7 +1099,7 @@ namespace ngcore
template<typename T> struct MPI_typetrait; template<typename T> struct MPI_typetrait;
template<int S, typename T> template<int S, typename T>
struct MPI_typetrait<INT<S, T> > { struct MPI_typetrait<IVec<S, T> > {
static auto MPIType () { static auto MPIType () {
return MPI_typetrait<std::array<T,S>>::MPIType(); return MPI_typetrait<std::array<T,S>>::MPIType();
} }
@ -1112,8 +1112,8 @@ namespace std
{ {
// structured binding support // structured binding support
template <auto N, typename T> template <auto N, typename T>
struct tuple_size<ngcore::INT<N,T>> : std::integral_constant<std::size_t, N> {}; struct tuple_size<ngcore::IVec<N,T>> : std::integral_constant<std::size_t, N> {};
template<size_t N, auto M, typename T> struct tuple_element<N,ngcore::INT<M,T>> { using type = T; }; template<size_t N, auto M, typename T> struct tuple_element<N,ngcore::IVec<M,T>> { using type = T; };
} }
#endif #endif

View File

@ -12,8 +12,6 @@
namespace netgen namespace netgen
{ {
using ngcore::INT;
constexpr static double EPSILON=0.000000001; constexpr static double EPSILON=0.000000001;
void ComputeWeight( Spline & s, Point<2> p ) void ComputeWeight( Spline & s, Point<2> p )
@ -2037,13 +2035,13 @@ shared_ptr<netgen::SplineGeometry2d> CSG2d :: GenerateSplineGeometry()
} }
netgen::BoxTree <2> solid_tree(box); netgen::BoxTree <2> solid_tree(box);
Array<INT<2>> loop_list; Array<IVec<2>> loop_list;
for(auto i : Range(solids)) for(auto i : Range(solids))
for(auto li : Range(solids[i].polys)) for(auto li : Range(solids[i].polys))
{ {
solid_tree.Insert(solids[i].polys[li].GetBoundingBox(), loop_list.Size()); solid_tree.Insert(solids[i].polys[li].GetBoundingBox(), loop_list.Size());
loop_list.Append(INT<2>(i, li)); loop_list.Append(IVec<2>(i, li));
} }
for(auto i1 : Range(solids)) for(auto i1 : Range(solids))

View File

@ -840,12 +840,12 @@ namespace netgen
tets_with_3_bnd_points.SetSize(cnt); tets_with_3_bnd_points.SetSize(cnt);
static Timer t1("Build face table"); t1.Start(); static Timer t1("Build face table"); t1.Start();
ngcore::ClosedHashTable< ngcore::INT<3>, int > face_table( 4*cnt + 3 ); ngcore::ClosedHashTable< ngcore::IVec<3>, int > face_table( 4*cnt + 3 );
for(auto ei : tets_with_3_bnd_points) for(auto ei : tets_with_3_bnd_points)
for(auto j : Range(4)) for(auto j : Range(4))
{ {
auto i3_ = tempels[ei].GetFace (j); auto i3_ = tempels[ei].GetFace (j);
ngcore::INT<3> i3 = {i3_[0], i3_[1], i3_[2]}; ngcore::IVec<3> i3 = {i3_[0], i3_[1], i3_[2]};
if(bnd_points[i3[0]] && bnd_points[i3[1]] && bnd_points[i3[2]]) if(bnd_points[i3[0]] && bnd_points[i3[1]] && bnd_points[i3[2]])
{ {
i3.Sort(); i3.Sort();
@ -860,7 +860,7 @@ namespace netgen
for (int i = 1; i <= mesh.GetNOpenElements(); i++) for (int i = 1; i <= mesh.GetNOpenElements(); i++)
{ {
const Element2d & tri = mesh.OpenElement(i); const Element2d & tri = mesh.OpenElement(i);
ngcore::INT<3> i3(tri[0], tri[1], tri[2]); ngcore::IVec<3> i3(tri[0], tri[1], tri[2]);
i3.Sort(); i3.Sort();
if(!face_table.Used(i3)) if(!face_table.Used(i3))
openels.Append(i); openels.Append(i);

View File

@ -38,7 +38,7 @@ namespace netgen
if(p1<p0) if(p1<p0)
Swap(p0,p1); Swap(p0,p1);
INT<2> hash = {p0,p1}; IVec<2> hash = {p0,p1};
auto pos = edge_to_trig.Position(hash); auto pos = edge_to_trig.Position(hash);
if (pos == -1) return -1; if (pos == -1) return -1;
@ -53,7 +53,7 @@ namespace netgen
if(p1<p0) if(p1<p0)
Swap(p0,p1); Swap(p0,p1);
INT<2> hash = {p0,p1}; IVec<2> hash = {p0,p1};
auto pos = edge_to_trig.Position(hash); auto pos = edge_to_trig.Position(hash);
if (pos == -1) if (pos == -1)
edge_to_trig[hash] = {eli, -1}; edge_to_trig[hash] = {eli, -1};
@ -80,7 +80,7 @@ namespace netgen
if(p1<p0) if(p1<p0)
Swap(p0,p1); Swap(p0,p1);
INT<2> hash = {p0,p1}; IVec<2> hash = {p0,p1};
auto pos = edge_to_trig.Position(hash); auto pos = edge_to_trig.Position(hash);
auto i2 = edge_to_trig.GetData(pos); auto i2 = edge_to_trig.GetData(pos);
@ -256,7 +256,7 @@ namespace netgen
{ {
int p1 = trig[k]; int p1 = trig[k];
int p2 = trig[(k+1)%3]; int p2 = trig[(k+1)%3];
INT<2> edge{p1,p2}; IVec<2> edge{p1,p2};
edge.Sort(); edge.Sort();
bool found = false; bool found = false;
for (int l = 0; l < edges.Size(); l++) for (int l = 0; l < edges.Size(); l++)
@ -801,13 +801,13 @@ namespace netgen
// Mark edges and trigs as inside or outside, starting with boundary edges // Mark edges and trigs as inside or outside, starting with boundary edges
enum POSITION { UNKNOWN, BOUNDARY, INSIDE, OUTSIDE }; enum POSITION { UNKNOWN, BOUNDARY, INSIDE, OUTSIDE };
Array<POSITION, SurfaceElementIndex> trig_pos(tempmesh.SurfaceElements().Size()); Array<POSITION, SurfaceElementIndex> trig_pos(tempmesh.SurfaceElements().Size());
ngcore::ClosedHashTable<INT<2>, POSITION> edge_pos(3*tempmesh.SurfaceElements().Size()); ngcore::ClosedHashTable<IVec<2>, POSITION> edge_pos(3*tempmesh.SurfaceElements().Size());
trig_pos = UNKNOWN; trig_pos = UNKNOWN;
for (auto & seg : tempmesh.LineSegments()) for (auto & seg : tempmesh.LineSegments())
{ {
ArrayMem<SurfaceElementIndex, 2> els; ArrayMem<SurfaceElementIndex, 2> els;
INT<2> edge{seg[0], seg[1]}; IVec<2> edge{seg[0], seg[1]};
edge.Sort(); edge.Sort();
edge_pos[edge] = BOUNDARY; edge_pos[edge] = BOUNDARY;
@ -828,8 +828,8 @@ namespace netgen
else else
pos = OUTSIDE; pos = OUTSIDE;
INT<2> e1{seg[0], pi2}; IVec<2> e1{seg[0], pi2};
INT<2> e2{seg[1], pi2}; IVec<2> e2{seg[1], pi2};
e1.Sort(); e1.Sort();
e2.Sort(); e2.Sort();
if(!edge_pos.Used(e1)) if(!edge_pos.Used(e1))
@ -857,7 +857,7 @@ namespace netgen
// any edge of unknown trig already marked? // any edge of unknown trig already marked?
for(auto i : IntRange(3)) for(auto i : IntRange(3))
{ {
INT<2> edge{el[(i+1)%3], el[(i+2)%3]}; IVec<2> edge{el[(i+1)%3], el[(i+2)%3]};
edge.Sort(); edge.Sort();
if(edge_pos.Used(edge) && edge_pos[edge]!=BOUNDARY) if(edge_pos.Used(edge) && edge_pos[edge]!=BOUNDARY)
{ {
@ -871,7 +871,7 @@ namespace netgen
if(trig_pos[sei] != UNKNOWN) if(trig_pos[sei] != UNKNOWN)
for(auto i : IntRange(3)) for(auto i : IntRange(3))
{ {
INT<2> edge{el[(i+1)%3], el[(i+2)%3]}; IVec<2> edge{el[(i+1)%3], el[(i+2)%3]};
edge.Sort(); edge.Sort();
if(!edge_pos.Used(edge) || edge_pos[edge]==BOUNDARY) if(!edge_pos.Used(edge) || edge_pos[edge]==BOUNDARY)
edge_pos[edge] = trig_pos[sei]; edge_pos[edge] = trig_pos[sei];

View File

@ -2,7 +2,6 @@
namespace netgen namespace netgen
{ {
using ngcore::INT;
static inline Point<2> P2( Point<3> p ) static inline Point<2> P2( Point<3> p )
{ {
@ -44,14 +43,14 @@ namespace netgen
class DelaunayMesh class DelaunayMesh
{ {
ngcore::ClosedHashTable<INT<2>, INT<2>> edge_to_trig; ngcore::ClosedHashTable<IVec<2>, IVec<2>> edge_to_trig;
Array<DelaunayTrig> trigs; Array<DelaunayTrig> trigs;
unique_ptr<DelaunayTree<2>> tree; unique_ptr<DelaunayTree<2>> tree;
Array<Point<2>, PointIndex> & points; Array<Point<2>, PointIndex> & points;
Array<int> closeels; Array<int> closeels;
Array<int> intersecting; Array<int> intersecting;
Array<INT<2>> edges; Array<IVec<2>> edges;
int GetNeighbour( int eli, int edge ); int GetNeighbour( int eli, int edge );

View File

@ -5,7 +5,6 @@ namespace netgen
{ {
using ngcore::ParallelForRange; using ngcore::ParallelForRange;
using ngcore::ParallelFor; using ngcore::ParallelFor;
using ngcore::INT;
using ngcore::TasksPerThread; using ngcore::TasksPerThread;
/* /*
@ -699,20 +698,20 @@ namespace netgen
// edge is splitting edge in middle of triangle: // edge is splitting edge in middle of triangle:
for (int j = 1; j <= 2; j++) for (int j = 1; j <= 2; j++)
{ {
INT<2> paedge1, paedge2, paedge3; IVec<2> paedge1, paedge2, paedge3;
int orient_inner = 0; int orient_inner = 0;
if (j == 1) if (j == 1)
{ {
paedge1 = INT<2> (pa0[0], verts[1]); paedge1 = IVec<2> (pa0[0], verts[1]);
paedge2 = INT<2> (pa0[1], verts[1]); paedge2 = IVec<2> (pa0[1], verts[1]);
paedge3 = INT<2> (pa0[0], pa0[1]); paedge3 = IVec<2> (pa0[0], pa0[1]);
orient_inner = 0; orient_inner = 0;
} }
else else
{ {
paedge1 = INT<2> (pa1[0], verts[0]); paedge1 = IVec<2> (pa1[0], verts[0]);
paedge2 = INT<2> (pa1[1], verts[0]); paedge2 = IVec<2> (pa1[1], verts[0]);
paedge3 = INT<2> (pa1[0], pa1[1]); paedge3 = IVec<2> (pa1[0], pa1[1]);
orient_inner = 1; orient_inner = 1;
} }
if (paedge1[0] > paedge1[1]) if (paedge1[0] > paedge1[1])
@ -752,21 +751,21 @@ namespace netgen
if (!bisect_edge) // not a bisect edge (then a red edge) if (!bisect_edge) // not a bisect edge (then a red edge)
{ {
INT<2> paedge1, paedge2, paedge3; IVec<2> paedge1, paedge2, paedge3;
int orient1 = 0, orient2 = 0, orient3=0; int orient1 = 0, orient2 = 0, orient3=0;
// int orient_inner = 0; // int orient_inner = 0;
paedge1 = INT<2> (pa0[0], pa0[1]); paedge1 = IVec<2> (pa0[0], pa0[1]);
paedge2 = INT<2> (pa1[0], pa1[1]); paedge2 = IVec<2> (pa1[0], pa1[1]);
// find common vertex and the third pa edge // find common vertex and the third pa edge
if (pa0[0]==pa1[0]){// 00 if (pa0[0]==pa1[0]){// 00
//orient1 = 0; //orient1 = 0;
orient2 = 1; orient2 = 1;
if (pa0[1]<pa1[1]){ if (pa0[1]<pa1[1]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[1], pa1[1]); paedge3 = IVec<2> (pa0[1], pa1[1]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[1], pa0[1]); paedge3 = IVec<2> (pa1[1], pa0[1]);
} }
} }
else if (pa0[0]==pa1[1]){//01 else if (pa0[0]==pa1[1]){//01
@ -774,10 +773,10 @@ namespace netgen
//orient2 = 0; //orient2 = 0;
if (pa0[1]<pa1[0]){ if (pa0[1]<pa1[0]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[1], pa1[0]); paedge3 = IVec<2> (pa0[1], pa1[0]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[0], pa0[1]); paedge3 = IVec<2> (pa1[0], pa0[1]);
} }
} }
else if (pa0[1]==pa1[0]){//10 else if (pa0[1]==pa1[0]){//10
@ -785,10 +784,10 @@ namespace netgen
orient2 = 1; orient2 = 1;
if (pa0[0]<pa1[1]){ if (pa0[0]<pa1[1]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[0], pa1[1]); paedge3 = IVec<2> (pa0[0], pa1[1]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[1], pa0[0]); paedge3 = IVec<2> (pa1[1], pa0[0]);
} }
} }
else if (pa0[1]==pa1[1]){//11 else if (pa0[1]==pa1[1]){//11
@ -796,10 +795,10 @@ namespace netgen
//orient2 = 0; //orient2 = 0;
if (pa0[0]<pa1[0]){ if (pa0[0]<pa1[0]){
orient3 = 1; orient3 = 1;
paedge3 = INT<2> (pa0[0], pa1[0]); paedge3 = IVec<2> (pa0[0], pa1[0]);
}else{ }else{
//orient3 = 0; //orient3 = 0;
paedge3 = INT<2> (pa1[0], pa0[0]); paedge3 = IVec<2> (pa1[0], pa0[0]);
} }
} }
@ -832,16 +831,16 @@ namespace netgen
pa1[1] != pa2[1]) pa1[1] != pa2[1])
for (int j = 1; j <= 2; j++) for (int j = 1; j <= 2; j++)
{ {
INT<2> paedge1, paedge2; IVec<2> paedge1, paedge2;
if (j == 1) if (j == 1)
{ {
paedge1 = INT<2> (pa1[0], pa2[0]); paedge1 = IVec<2> (pa1[0], pa2[0]);
paedge2 = INT<2> (pa1[1], pa2[1]); paedge2 = IVec<2> (pa1[1], pa2[1]);
} }
else else
{ {
paedge1 = INT<2> (pa1[0], pa2[1]); paedge1 = IVec<2> (pa1[0], pa2[1]);
paedge2 = INT<2> (pa1[1], pa2[0]); paedge2 = IVec<2> (pa1[1], pa2[0]);
} }
int paedgenr1 = 0, paedgenr2 = 0; int paedgenr1 = 0, paedgenr2 = 0;
@ -877,7 +876,7 @@ namespace netgen
for (int j = 0; j < 2; j++) for (int j = 0; j < 2; j++)
for (int k = 0; k < 2; k++) for (int k = 0; k < 2; k++)
{ {
INT<2> paedge (pa1[1-j], pa2[1-k]); IVec<2> paedge (pa1[1-j], pa2[1-k]);
int orientpa = 1; int orientpa = 1;
if (paedge[0] > paedge[1]) if (paedge[0] > paedge[1])
{ {
@ -909,12 +908,12 @@ namespace netgen
// edge hashtable:: needed for getting parent faces // edge hashtable:: needed for getting parent faces
ngcore::ClosedHashTable<INT<2>, int> v2e(nv); ngcore::ClosedHashTable<IVec<2>, int> v2e(nv);
if (build_parent_faces) if (build_parent_faces)
for (auto i : Range(edge2vert)) for (auto i : Range(edge2vert))
{ {
auto edge = edge2vert[i]; auto edge = edge2vert[i];
INT<2> e2(edge[0], edge[1]); IVec<2> e2(edge[0], edge[1]);
e2.Sort(); e2.Sort();
v2e[e2] = i; v2e[e2] = i;
} }
@ -947,7 +946,7 @@ namespace netgen
vert2oldface.AddSave (face2vert[i][0], i); vert2oldface.AddSave (face2vert[i][0], i);
// find all potential intermediate faces // find all potential intermediate faces
Array<INT<3>> intermediate_faces; Array<IVec<3>> intermediate_faces;
if (build_parent_faces) if (build_parent_faces)
{ {
for (ElementIndex ei = 0; ei < ne; ei++) for (ElementIndex ei = 0; ei < ne; ei++)
@ -957,7 +956,7 @@ namespace netgen
// cout << "element: " << (*mesh)[ei].PNums() << endl; // cout << "element: " << (*mesh)[ei].PNums() << endl;
(*mesh)[ei].GetFace(i+1, face); (*mesh)[ei].GetFace(i+1, face);
// cout << "face " << face.PNums() << endl; // cout << "face " << face.PNums() << endl;
INT<3,PointIndex> f3 = { face[0], face[1], face[2] }; IVec<3,PointIndex> f3 = { face[0], face[1], face[2] };
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
PointIndex v = f3[j]; PointIndex v = f3[j];
@ -973,10 +972,10 @@ namespace netgen
PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0;
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
INT<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
parentedge.Sort(); parentedge.Sort();
if (v2e.Used(parentedge)){ if (v2e.Used(parentedge)){
INT<3> cf3 = { v0, v1, v2 }; IVec<3> cf3 = { v0, v1, v2 };
cf3.Sort(); cf3.Sort();
// cout << "intermediate: " << cf3 << " of " << f3 << endl; // cout << "intermediate: " << cf3 << " of " << f3 << endl;
intermediate_faces.Append (cf3); intermediate_faces.Append (cf3);
@ -988,7 +987,7 @@ namespace netgen
for (SurfaceElementIndex sei = 0; sei < nse; sei++) for (SurfaceElementIndex sei = 0; sei < nse; sei++)
{ {
const Element2d & sel = (*mesh)[sei]; const Element2d & sel = (*mesh)[sei];
INT<3,PointIndex> f3 = { sel[0], sel[1], sel[2] }; IVec<3,PointIndex> f3 = { sel[0], sel[1], sel[2] };
for (int j = 0; j < 3; j++) for (int j = 0; j < 3; j++)
{ {
PointIndex v = f3[j]; PointIndex v = f3[j];
@ -1004,10 +1003,10 @@ namespace netgen
PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0; PointIndex v2 = f3[0]+f3[1]+f3[2] - v - v0;
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
INT<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
parentedge.Sort(); parentedge.Sort();
if (v2e.Used(parentedge)){ if (v2e.Used(parentedge)){
INT<3> cf3 = { v0, v1, v2 }; IVec<3> cf3 = { v0, v1, v2 };
cf3.Sort(); cf3.Sort();
// cout << "intermediate: " << cf3 << " of " << f3 << endl; // cout << "intermediate: " << cf3 << " of " << f3 << endl;
intermediate_faces.Append (cf3); intermediate_faces.Append (cf3);
@ -1377,11 +1376,11 @@ namespace netgen
// cout << "f2v = " << face2vert << endl; // cout << "f2v = " << face2vert << endl;
ngcore::ClosedHashTable<INT<3>, int> v2f(nv); ngcore::ClosedHashTable<IVec<3>, int> v2f(nv);
for (auto i : Range(face2vert)) for (auto i : Range(face2vert))
{ {
auto face = face2vert[i]; auto face = face2vert[i];
INT<3> f3(face[0], face[1], face[2]); IVec<3> f3(face[0], face[1], face[2]);
f3.Sort(); f3.Sort();
v2f[f3] = i; v2f[f3] = i;
} }
@ -1393,7 +1392,7 @@ namespace netgen
for (auto i : Range(nfa)) for (auto i : Range(nfa))
{ {
INT<3,PointIndex> f3(face2vert[i][0], face2vert[i][1], face2vert[i][2]); IVec<3,PointIndex> f3(face2vert[i][0], face2vert[i][1], face2vert[i][2]);
// face on coarses level ? // face on coarses level ?
@ -1433,10 +1432,10 @@ namespace netgen
// if there is an edge connecting v1 and v2, accept // if there is an edge connecting v1 and v2, accept
// the new face // the new face
INT<2> parentedge(v1, v2); IVec<2> parentedge(v1, v2);
parentedge.Sort(); parentedge.Sort();
if (v2e.Used(parentedge)){ if (v2e.Used(parentedge)){
INT<3> parentverts(v0, v1, v2); IVec<3> parentverts(v0, v1, v2);
parentverts.Sort(); parentverts.Sort();
int classnr = 0; int classnr = 0;
@ -1476,13 +1475,13 @@ namespace netgen
PointIndex v1 = parents[1]; PointIndex v1 = parents[1];
PointIndex v2 = f3[(k+1)%3]; PointIndex v2 = f3[(k+1)%3];
PointIndex v3 = f3[(k+2)%3]; PointIndex v3 = f3[(k+2)%3];
INT<3> parentedge1(v0, v2); IVec<3> parentedge1(v0, v2);
parentedge1.Sort(); parentedge1.Sort();
INT<3> parentedge2(v0, v3); IVec<3> parentedge2(v0, v3);
parentedge2.Sort(); parentedge2.Sort();
INT<3> parentedge3(v1, v2); IVec<3> parentedge3(v1, v2);
parentedge3.Sort(); parentedge3.Sort();
INT<3> parentedge4(v1, v3); IVec<3> parentedge4(v1, v3);
parentedge4.Sort(); parentedge4.Sort();
// if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists // if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists
// then vb is the bisecting edge // then vb is the bisecting edge
@ -1507,13 +1506,13 @@ namespace netgen
// by default v0 < v1 < vb < v2 < v3 // by default v0 < v1 < vb < v2 < v3
classnr=9; classnr=9;
} }
INT<3> parentverts1(v0, v2, v3); IVec<3> parentverts1(v0, v2, v3);
parentverts1.Sort(); parentverts1.Sort();
INT<3> parentverts2(v1, v2, v3); IVec<3> parentverts2(v1, v2, v3);
parentverts2.Sort(); parentverts2.Sort();
INT<3> parentverts3(v0, v1, v2); IVec<3> parentverts3(v0, v1, v2);
parentverts3.Sort(); parentverts3.Sort();
INT<3> parentverts4(v0, v1, v3); IVec<3> parentverts4(v0, v1, v3);
parentverts4.Sort(); parentverts4.Sort();
int pafacenr1=-1, pafacenr2=-1, pafacenr3=-1, pafacenr4=-1; int pafacenr1=-1, pafacenr2=-1, pafacenr3=-1, pafacenr4=-1;
if (v2f.Used(parentverts1)) if (v2f.Used(parentverts1))
@ -1561,13 +1560,13 @@ namespace netgen
PointIndex v1 = parents[1]; PointIndex v1 = parents[1];
PointIndex v2 = f3[(k+1)%3]; PointIndex v2 = f3[(k+1)%3];
PointIndex v3 = f3[(k+2)%3]; PointIndex v3 = f3[(k+2)%3];
INT<2> parentedge1(v0, v2); IVec<2> parentedge1(v0, v2);
parentedge1.Sort(); parentedge1.Sort();
INT<2> parentedge2(v0, v3); IVec<2> parentedge2(v0, v3);
parentedge2.Sort(); parentedge2.Sort();
INT<2> parentedge3(v1, v2); IVec<2> parentedge3(v1, v2);
parentedge3.Sort(); parentedge3.Sort();
INT<2> parentedge4(v1, v3); IVec<2> parentedge4(v1, v3);
parentedge4.Sort(); parentedge4.Sort();
// if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists // if edges [v0,v2], [v0, v3], [v1,v2], [v1,v3] exists
@ -1595,13 +1594,13 @@ namespace netgen
} }
// cout << "classnr = " << classnr << endl; // cout << "classnr = " << classnr << endl;
INT<3> parentverts1(v1, v2, v3); IVec<3> parentverts1(v1, v2, v3);
parentverts1.Sort(); parentverts1.Sort();
INT<3> parentverts2(v0, v2, v3); IVec<3> parentverts2(v0, v2, v3);
parentverts2.Sort(); parentverts2.Sort();
INT<3> parentverts3(v0, v1, v3); IVec<3> parentverts3(v0, v1, v3);
parentverts3.Sort(); parentverts3.Sort();
INT<3> parentverts4(v0, v1, v2); IVec<3> parentverts4(v0, v1, v2);
parentverts4.Sort(); parentverts4.Sort();
if (!v2f.Used(parentverts1) || !v2f.Used(parentverts2) || if (!v2f.Used(parentverts1) || !v2f.Used(parentverts2) ||
@ -1634,17 +1633,17 @@ namespace netgen
// v0 is a coarse vertex ==> f3 is a boundary face // v0 is a coarse vertex ==> f3 is a boundary face
if (v0==pa1[0] || v0==pa1[1]){ if (v0==pa1[0] || v0==pa1[1]){
if (pa1[0]==v0){// type 0: bottom left corner if (pa1[0]==v0){// type 0: bottom left corner
INT<3> parentverts(v0, pa1[1], pa2[1]); IVec<3> parentverts(v0, pa1[1], pa2[1]);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 16, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 16, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "A" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "A" <<endl;
}else if (pa2[0]==v0) {// type 1: bottom right corner }else if (pa2[0]==v0) {// type 1: bottom right corner
INT<3> parentverts(pa1[0], v0, pa2[1]); IVec<3> parentverts(pa1[0], v0, pa2[1]);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 17, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 17, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "B" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "B" <<endl;
}else if (pa1[1]==v0){// type 2: top left corner }else if (pa1[1]==v0){// type 2: top left corner
INT<3> parentverts(pa1[0], pa2[0], v0); IVec<3> parentverts(pa1[0], pa2[0], v0);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 18, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 18, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "C" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "C" <<endl;
@ -1655,7 +1654,7 @@ namespace netgen
else{// all vertices are on fine level [fff] else{// all vertices are on fine level [fff]
// Here we only work with boundary fff face // Here we only work with boundary fff face
if (pa0[0]==pa1[0] && pa0[1]==pa2[0] && pa1[1]==pa2[1]){//type 3 bdry face if (pa0[0]==pa1[0] && pa0[1]==pa2[0] && pa1[1]==pa2[1]){//type 3 bdry face
INT<3> parentverts(pa0[0], pa0[1], pa1[1]); IVec<3> parentverts(pa0[0], pa0[1], pa1[1]);
int pafacenr = v2f[parentverts]; int pafacenr = v2f[parentverts];
parent_faces[i] = { 19, { pafacenr, -1, -1, -1} }; parent_faces[i] = { 19, { pafacenr, -1, -1, -1} };
//cout << "f "<<i<<":pf "<< pafacenr<< "D" <<endl; //cout << "f "<<i<<":pf "<< pafacenr<< "D" <<endl;

View File

@ -239,7 +239,7 @@ namespace netgen
bool SelectSurfaceElement (int px, int py, Point<3> &p, bool select_on_clipping_plane); bool SelectSurfaceElement (int px, int py, Point<3> &p, bool select_on_clipping_plane);
bool Unproject(int px, int py, Point<3> &p); bool Unproject(int px, int py, Point<3> &p);
ngcore::INT<2> Project(Point<3> p); ngcore::IVec<2> Project(Point<3> p);
}; };
NGGUI_API extern VisualSceneMesh vsmesh; NGGUI_API extern VisualSceneMesh vsmesh;

View File

@ -3405,13 +3405,13 @@ namespace netgen
return pz<1 && pz>0; return pz<1 && pz>0;
} }
ngcore::INT<2> VisualSceneMesh :: Project(Point<3> p) ngcore::IVec<2> VisualSceneMesh :: Project(Point<3> p)
{ {
Point<3> pwin; Point<3> pwin;
gluProject(p[0], p[1], p[2], transformationmat, select.projmat, select.viewport, gluProject(p[0], p[1], p[2], transformationmat, select.projmat, select.viewport,
&pwin[0], &pwin[1], &pwin[2]); &pwin[0], &pwin[1], &pwin[2]);
return ngcore::INT<2>(pwin[0]+0.5, select.viewport[3]-pwin[1]+0.5); return ngcore::IVec<2>(pwin[0]+0.5, select.viewport[3]-pwin[1]+0.5);
} }