compare PointIndex only with PointIndex

This commit is contained in:
Joachim Schoeberl 2024-12-28 22:58:44 +01:00
parent 75032f9905
commit a5ce9915d1
24 changed files with 135 additions and 116 deletions

View File

@ -319,8 +319,9 @@ namespace ngcore
.def ("__getitem__",
[](TFlat & self, TIND i) -> T&
{
static constexpr int base = IndexBASE<TIND>();
if (i < base || i >= self.Size()+base)
// static constexpr int base = IndexBASE<TIND>();
auto reli = i - IndexBASE<TIND>();
if (reli < 0 || reli >= self.Size())
throw py::index_error();
return self[i];
},
@ -328,8 +329,9 @@ namespace ngcore
.def ("__setitem__",
[](TFlat & self, TIND i, T val) -> T&
{
static constexpr int base = IndexBASE<TIND>();
if (i < base || i >= self.Size()+base)
// static constexpr int base = IndexBASE<TIND>();
auto reli = i - IndexBASE<TIND>();
if (reli < 0 || reli >= self.Size())
throw py::index_error();
self[i] = val;
return self[i];

View File

@ -567,7 +567,7 @@ namespace netgen
{
// int i, j;
SegmentIndex si;
PointIndex pi;
// PointIndex pi;
NgArray<int> osedges(cntedge);
INDEX_2_HASHTABLE<int> osedgesht (cntedge+1);
@ -610,7 +610,7 @@ namespace netgen
for (int i = 1; i <= osedgesht.GetNBags(); i++)
for (int j = 1; j <= osedgesht.GetBagSize(i); j++)
{
INDEX_2 i2;
PointIndices<2> i2;
int val;
osedgesht.GetData (i, j, i2, val);
@ -619,8 +619,8 @@ namespace netgen
Vec<3> v = p2 - p1;
double vlen = v.Length();
v /= vlen;
for (pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>();
pi < mesh.GetNP()+IndexBASE<PointIndex>(); pi++)
if (pi != i2.I1() && pi != i2.I2())
{
@ -1371,8 +1371,8 @@ namespace netgen
lastpi = PointIndex::INVALID;
/*
for (pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
for (pi = IndexBASE<PointIndex>();
pi < mesh.GetNP()+IndexBASE<PointIndex>(); pi++)
if (Dist (mesh[pi], p) < 1e-6)
{
lastpi = pi;
@ -1414,8 +1414,8 @@ namespace netgen
if (i == ne)
{
/*
for (pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
for (pi = IndexBASE<PointIndex>();
pi < mesh.GetNP()+IndexBASE<PointIndex>(); pi++)
if (Dist(mesh[pi], np) < 1e-6)
thispi = pi;
*/
@ -1539,8 +1539,8 @@ namespace netgen
// generate initial point
Point<3> p = edgepoints[0];
PointIndex pi1 = PointIndex::INVALID;
for (pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>();
pi < mesh.GetNP()+IndexBASE<PointIndex>(); pi++)
if (Dist (mesh[pi], p) < 1e-6*geometry.MaxSize())
{
@ -1557,8 +1557,8 @@ namespace netgen
p = edgepoints.Last();
PointIndex pi2 = PointIndex::INVALID;
for (pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
for (pi = IndexBASE<PointIndex>();
pi < mesh.GetNP()+IndexBASE<PointIndex>(); pi++)
if (Dist (mesh[pi], p) < 1e-6*geometry.MaxSize())
{
@ -1646,7 +1646,7 @@ namespace netgen
Mesh & mesh)
{
int k;
PointIndex pi;
// PointIndex pi;
double size = geometry.MaxSize();
@ -1660,8 +1660,8 @@ namespace netgen
PointIndex frompi = PointIndex::INVALID;
PointIndex topi = PointIndex::INVALID;
for (pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>();
pi < mesh.GetNP()+IndexBASE<PointIndex>(); pi++)
{
if (Dist2 (mesh[pi], fromp) <= 1e-16*size)
frompi = pi;

View File

@ -443,7 +443,7 @@ namespace netgen
meshing.SetStartTime (starttime);
double eps = 1e-8 * geom.MaxSize();
for (PointIndex pi = PointIndex::BASE; pi < noldp+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>(); pi < noldp+IndexBASE<PointIndex>(); pi++)
{
// if(surf->PointOnSurface(mesh[pi]))
meshing.AddPoint (mesh[pi], pi, NULL,

View File

@ -153,8 +153,8 @@ void SingularPoint :: FindPoints (class Mesh & mesh)
NgArray<int> surfk, surf;
for (PointIndex pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>();
pi < mesh.GetNP()+IndexBASE<PointIndex>(); pi++)
{
if (mesh[pi].Type() != FIXEDPOINT) continue;
const Point<3> p = mesh[pi];

View File

@ -472,7 +472,8 @@ namespace netgen
box = Box3d (Point3d (0,0,0), Point3d (1,1,1));
}
if (zoomall == 2 && ((vispar.centerpoint >= 1 && vispar.centerpoint <= mesh->GetNP()) ||
if (zoomall == 2 && ((vispar.centerpoint-IndexBASE<PointIndex>() >= 0 &&
vispar.centerpoint-IndexBASE<PointIndex>() < mesh->GetNP()) ||
vispar.use_center_coords))
{
if (vispar.use_center_coords)

View File

@ -465,8 +465,8 @@ namespace netgen
PointIndex mpi(0);
Point<2> gp = geometry.GetPoint(i);
Point<3> gp3(gp(0), gp(1), 0);
for (PointIndex pi = PointIndex::BASE;
pi < mesh->GetNP()+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>();
pi < mesh->GetNP()+IndexBASE<PointIndex>(); pi++)
if (Dist2(gp3, (*mesh)[pi]) < mindist)
{
mpi = pi;

View File

@ -507,7 +507,7 @@ NG_ELEMENT_TYPE Ng_GetSurfaceElement (int ei, int * epi, int * np)
{
const Segment & seg = mesh->LineSegment (ei);
if (seg[2] < 0)
if (!seg[2].IsValid())
{
epi[0] = seg[0];
epi[1] = seg[1];
@ -866,7 +866,7 @@ NG_ELEMENT_TYPE Ng_GetSegment (int ei, int * epi, int * np)
epi[0] = seg[0];
epi[1] = seg[1];
if (seg[2] < 0)
if (!seg[2].IsValid())
{
if (np) *np = 2;
return NG_SEGM;
@ -1945,8 +1945,10 @@ int Ng_GetVertex_Elements( int vnr, int* elems )
}
///// Added by Roman Stainko ....
int Ng_GetVertex_SurfaceElements( int vnr, int* elems )
int Ng_GetVertex_SurfaceElements( int vnr_, int* elems )
{
PointIndex vnr = vnr_ + IndexBASE<PointIndex>()-1;
switch (mesh->GetDimension())
{
case 3:
@ -1994,8 +1996,9 @@ int Ng_GetVertex_NElements( int vnr )
}
///// Added by Roman Stainko ....
int Ng_GetVertex_NSurfaceElements( int vnr )
int Ng_GetVertex_NSurfaceElements( int vnr_ )
{
PointIndex vnr = vnr_ + IndexBASE<PointIndex>()-1;
switch (mesh->GetDimension())
{
case 3:

View File

@ -92,7 +92,8 @@ void WriteDiffPackFormat (const Mesh & mesh,
}
for (int i = 1; i <= np; i++)
// for (int i = 1; i <= np; i++)
for (PointIndex i : mesh.Points().Range())
{
const Point3d & p = mesh.Point(i);
@ -244,7 +245,8 @@ void WriteDiffPackFormat (const Mesh & mesh,
" - the boundary indicators that are set (ON) if any.\n"
"#\n";
for (i = 1; i <= np; i++)
// for (i = 1; i <= np; i++)
for (PointIndex i : mesh.Points().Range())
{
const Point3d & p = mesh.Point(i);

View File

@ -259,7 +259,7 @@ void MergeAndAddSegments (Mesh& mesh, FlatArray<Segment> segments, FlatArray<Seg
mesh.LineSegments().SetSize0();
auto addSegment = [&] (const auto& seg) {
INDEX_2 i2(seg[0], seg[1]);
PointIndices<2> i2(seg[0], seg[1]);
i2.Sort();
if (!already_added.Used(i2))
{
@ -297,6 +297,7 @@ BoundaryLayerTool::BoundaryLayerTool(Mesh& mesh_,
segments = mesh.LineSegments();
np = mesh.GetNP();
npi = IndexBASE<PointIndex>()+np;
ne = mesh.GetNE();
nse = mesh.GetNSE();
nseg = segments.Size();
@ -626,7 +627,9 @@ void BoundaryLayerTool ::InsertNewElements(
};
// insert new points
for (PointIndex pi = 1; pi <= np; pi++)
// for (PointIndex pi = 1; pi <= np; pi++)
for (PointIndex pi = IndexBASE<PointIndex>();
pi < IndexBASE<PointIndex>()+np; pi++)
{
if (growthvectors[pi].Length2() != 0)
{

View File

@ -58,6 +58,7 @@ public:
Array<int> new_mat_nrs;
BitArray moved_surfaces;
int np, nseg, nse, ne;
PointIndex npi; // IndexBASE<PointIndex>+np
double total_height;
Array<POINTTYPE, PointIndex> point_types;

View File

@ -283,7 +283,7 @@ namespace netgen
}
{
FaceDescriptor new_fd(0, 0, 0, -1);
FaceDescriptor new_fd(0, 0, 0, -1);
new_fd.SetBCProperty(new_domain);
// int new_fd_index =
mesh.AddFaceDescriptor(new_fd);

View File

@ -85,14 +85,16 @@ struct GrowthVectorLimiter
double GetLimit (PointIndex pi)
{
if (pi <= tool.np)
// if (pi <= tool.np)
if (pi < tool.npi)
return limits[pi];
return limits[map_from[pi]];
}
bool SetLimit (PointIndex pi, double new_limit)
{
double& limit = (pi <= tool.np) ? limits[pi] : limits[map_from[pi]];
// double& limit = (pi <= tool.np) ? limits[pi] : limits[map_from[pi]];
double& limit = (pi < tool.npi) ? limits[pi] : limits[map_from[pi]];
if (limit <= new_limit)
return false;
limit = new_limit;
@ -101,7 +103,8 @@ struct GrowthVectorLimiter
bool ScaleLimit (PointIndex pi, double factor)
{
double& limit = (pi <= tool.np) ? limits[pi] : limits[map_from[pi]];
// double& limit = (pi <= tool.np) ? limits[pi] : limits[map_from[pi]];
double& limit = (pi < tool.npi) ? limits[pi] : limits[map_from[pi]];
return SetLimit(pi, limit * factor);
}
@ -115,7 +118,8 @@ struct GrowthVectorLimiter
Point<3> GetPoint (PointIndex pi_to, double shift = 1., bool apply_limit = false)
{
if (pi_to <= tool.np || tool.growth_vector_map.count(pi_to) == 0)
// if (pi_to <= tool.np || tool.growth_vector_map.count(pi_to) == 0)
if (pi_to < tool.npi || tool.growth_vector_map.count(pi_to) == 0)
return mesh[pi_to];
return mesh[pi_to] + GetVector(pi_to, shift, apply_limit);
@ -286,7 +290,8 @@ struct GrowthVectorLimiter
RegionTimer reg(t);
if (factor == 0.0)
return;
for (PointIndex pi : IntRange(tool.np, mesh.GetNP()))
// for (PointIndex pi : IntRange(tool.np, mesh.GetNP()))
for (PointIndex pi : mesh.Points().Range().Modify(tool.np,0))
{
// auto pi_from = map_from[pi];
std::set<PointIndex> pis;
@ -331,7 +336,8 @@ struct GrowthVectorLimiter
auto np = sel.GetNP();
for (auto i : Range(np))
{
if (sel[i] > tool.np)
// if (sel[i] > tool.np)
if (sel[i] >= tool.npi)
return false;
if (tool.mapto[sel[i]].Size() == 0)
return false;
@ -428,6 +434,7 @@ struct GrowthVectorLimiter
Intersection_ isIntersectingTrig (PointIndex pi_from, PointIndex pi_to, SurfaceElementIndex sei, double shift = 0.0)
{
// JS: where is that GetSeg function ?
return isIntersectingTrig(GetSeg(pi_from, pi_to), GetTrig(sei, shift));
}
@ -460,7 +467,8 @@ struct GrowthVectorLimiter
}
template <typename TFunc>
void FindTreeIntersections (double trig_shift, double seg_shift, TFunc f, BitArray* relevant_points = nullptr)
void FindTreeIntersections (double trig_shift, double seg_shift, TFunc f,
TBitArray<PointIndex> * relevant_points = nullptr)
{
static Timer t("GrowthVectorLimiter::FindTreeIntersections");
RegionTimer rt(t);
@ -469,7 +477,7 @@ struct GrowthVectorLimiter
// int counter = 0;
for (auto i : IntRange(tool.np, np_new))
{
PointIndex pi_to = i + PointIndex::BASE;
PointIndex pi_to = i + IndexBASE<PointIndex>();
PointIndex pi_from = map_from[pi_to];
if (!pi_from.IsValid())
throw Exception("Point not mapped");
@ -558,7 +566,8 @@ struct GrowthVectorLimiter
PointIndex pi_max_limit = PointIndex::INVALID;
for (PointIndex pi :
{tri[0], tri[1], tri[2], tri2[0], tri2[1], tri2[2]})
if (pi > tool.np && (!pi_max_limit.IsValid() || GetLimit(pi) > GetLimit(pi_max_limit)))
// if (pi > tool.np && (!pi_max_limit.IsValid() || GetLimit(pi) > GetLimit(pi_max_limit)))
if (pi >= tool.npi && (!pi_max_limit.IsValid() || GetLimit(pi) > GetLimit(pi_max_limit)))
pi_max_limit = map_from[pi];
if (!pi_max_limit.IsValid())
@ -623,8 +632,8 @@ struct GrowthVectorLimiter
double seg_shift = safety;
size_t limit_counter = 1;
BitArray relevant_points, relevant_points_next;
relevant_points.SetSize(mesh.Points().Size() + 1);
TBitArray<PointIndex> relevant_points, relevant_points_next;
relevant_points.SetSize(mesh.Points().Size() + 1);
relevant_points_next.SetSize(mesh.Points().Size() + 1);
relevant_points.Set();
@ -647,7 +656,8 @@ struct GrowthVectorLimiter
for (auto pi : sel.PNums())
{
relevant_points_next.SetBit(pi);
if (pi >= tool.np)
// if (pi >= tool.np) // was this correct (JS) ?
if (pi >= tool.npi)
relevant_points_next.SetBit(map_from[pi]);
else
relevant_points_next.SetBit(map_from[pi]);
@ -656,7 +666,8 @@ struct GrowthVectorLimiter
for (auto pi : sel.PNums())
{
if (pi >= tool.np)
//if (pi >= tool.np) // was this correct (JS) ?
if (pi >= tool.npi)
return;
if (tool.mapto[pi].Size() == 0)
return;

View File

@ -229,13 +229,11 @@ namespace netgen
friend constexpr PointIndex operator+ (size_t, PointIndex);
friend constexpr PointIndex operator- (PointIndex, int);
friend constexpr int operator- (PointIndex, PointIndex);
/*
friend bool operator< (PointIndex a, PointIndex b);
friend bool operator> (PointIndex a, PointIndex b);
friend bool operator>= (PointIndex a, PointIndex b);
friend constexpr bool operator== (PointIndex a, PointIndex b);
friend constexpr bool operator!= (PointIndex a, PointIndex b);
*/
public:
constexpr PointIndex (t_invalid inv) : i(long(PointIndex::BASE)-1) { ; }
@ -266,15 +264,12 @@ namespace netgen
constexpr inline PointIndex operator+ (int i, PointIndex pi) { return PointIndex(pi.i+i); }
constexpr inline PointIndex operator+ (size_t i, PointIndex pi) { return PointIndex(pi.i+i); }
constexpr inline PointIndex operator- (PointIndex pi, int i) { return PointIndex(pi.i-i); }
constexpr inline int operator- (PointIndex pa, PointIndex pb) { return PointIndex(pa.i-pb.i); }
/*
inline bool operator< (PointIndex a, PointIndex b) { return a.i < b.i; }
inline bool operator> (PointIndex a, PointIndex b) { return a.i > b.i; }
inline bool operator>= (PointIndex a, PointIndex b) { return a.i >= b.i; }
constexpr inline int operator- (PointIndex pa, PointIndex pb) { return pa.i-pb.i; }
inline bool operator< (PointIndex a, PointIndex b) { return a.i-b.i < 0; }
inline bool operator> (PointIndex a, PointIndex b) { return a.i-b.i > 0; }
inline bool operator>= (PointIndex a, PointIndex b) { return a.i-b.i >= 0; }
inline constexpr bool operator== (PointIndex a, PointIndex b) { return a.i == b.i; }
inline constexpr bool operator!= (PointIndex a, PointIndex b) { return a.i != b.i; }
*/
}
namespace ngcore

View File

@ -1161,7 +1161,7 @@ namespace netgen
seg.domin = seg.surfnr1;
seg.domout = seg.surfnr2;
if ( seg.pnums[0] >0 && seg.pnums[1] > 0 )
if ( seg.pnums[0].IsValid() && seg.pnums[1].IsValid() )
{
paralleltop-> SetLoc2Glob_Segm ( segi, globsegi );

View File

@ -436,7 +436,7 @@ namespace netgen
for (int dist : GetDistantProcs(pi))
dest2vert.Add (dist, pi);
for (PointIndex pi = PointIndex::BASE; pi < newnv+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>(); pi < newnv+IndexBASE<PointIndex>(); pi++)
if (auto [v1,v2] = mesh.mlbetweennodes[pi]; v1.IsValid())
{
auto procs1 = GetDistantProcs(v1);

View File

@ -457,7 +457,7 @@ int Meshing3 :: ApplyRules
if (locpi.IsValid())
pused[locpi]--;
while (!ok && locpi < lpoints.Size()-1+PointIndex::BASE)
while (!ok && locpi < lpoints.Size()-1+IndexBASE<PointIndex>())
{
ok = 1;
locpi++;

View File

@ -513,8 +513,8 @@ namespace netgen
auto end = r.Next();
// INDEX_CLOSED_HASHTABLE<int> v2eht(2*max_edge_on_vertex+10);
ngcore::ClosedHashTable<int, int> v2eht(2*max_edge_on_vertex+10);
for (PointIndex v = begin+PointIndex::BASE;
v < end+PointIndex::BASE; v++)
for (PointIndex v = begin+IndexBASE<PointIndex>();
v < end+IndexBASE<PointIndex>(); v++)
{
v2eht.DeleteData();
for (int ednr : vert2edge[v])
@ -553,7 +553,7 @@ namespace netgen
// INDEX_CLOSED_HASHTABLE<int> v2eht(2*max_edge_on_vertex+10);
// NgArray<int> vertex2;
// for (PointIndex v = PointIndex::BASE; v < nv+PointIndex::BASE; v++)
// for (PointIndex v = IndexBASE<PointIndex>(); v < nv+IndexBASE<PointIndex>(); v++)
ParallelForRange
(mesh->GetNV(), // Points().Size(),
@ -565,8 +565,8 @@ namespace netgen
ngcore::ClosedHashTable<int, int> v2eht(2*max_edge_on_vertex+10);
Array<int> vertex2;
for (PointIndex v = begin+PointIndex::BASE;
v < end+PointIndex::BASE; v++)
for (PointIndex v = begin+IndexBASE<PointIndex>();
v < end+IndexBASE<PointIndex>(); v++)
{
int ned = cnt[v];
v2eht.DeleteData();
@ -659,8 +659,8 @@ namespace netgen
{
auto verts = edge2vert[i]; // 2 vertices of edge
if (verts[0] >= mesh->mlbetweennodes.Size()+PointIndex::BASE ||
verts[1] >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
if (verts[0] >= mesh->mlbetweennodes.Size()+IndexBASE<PointIndex>() ||
verts[1] >= mesh->mlbetweennodes.Size()+IndexBASE<PointIndex>())
continue;
auto pa0 = mesh->mlbetweennodes[verts[0]]; // two parent vertices of v0
@ -960,7 +960,7 @@ namespace netgen
for (int j = 0; j < 3; j++)
{
PointIndex v = f3[j];
if (v >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
if (v >= mesh->mlbetweennodes.Size()+IndexBASE<PointIndex>())
continue;
auto pa = mesh->mlbetweennodes[v];
@ -991,7 +991,7 @@ namespace netgen
for (int j = 0; j < 3; j++)
{
PointIndex v = f3[j];
if (v >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
if (v >= mesh->mlbetweennodes.Size()+IndexBASE<PointIndex>())
continue;
auto pa = mesh->mlbetweennodes[v];
@ -1031,7 +1031,7 @@ namespace netgen
int max_face_on_vertex = 0;
for (int i = PointIndex::BASE; i < nv+PointIndex::BASE; i++)
for (PointIndex i = IndexBASE<PointIndex>(); i < nv+IndexBASE<PointIndex>(); i++)
{
int onv = vert2oldface[i].Size() + vert2element[i].Size() + vert2surfelement[i].Size();
max_face_on_vertex = max (onv, max_face_on_vertex);
@ -1335,7 +1335,7 @@ namespace netgen
<< endl;
(*testout) << "pos = ";
for (int j = 0; j < 4; j++)
if (face2vert[i][j] >= 1)
if (face2vert[i][j].IsValid())
(*testout) << (*mesh)[(PointIndex)face2vert[i][j]] << " ";
(*testout) << endl;
@ -1400,10 +1400,10 @@ namespace netgen
for (int k = 0; k < 3; k++)
{
PointIndex vb = f3[k];
if (vb >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
if (vb >= mesh->mlbetweennodes.Size()+IndexBASE<PointIndex>())
continue;
auto parents = mesh->mlbetweennodes[vb];
if (parents[0] >= PointIndex::BASE)
if (parents[0] >= IndexBASE<PointIndex>())
all_vert_coarse = false;
}
if (all_vert_coarse) continue;
@ -1415,7 +1415,7 @@ namespace netgen
for (int k = 0; k < 3; k++)
{
PointIndex vb = f3[k]; // assume vb as the new bisect vert
if (vb >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
if (vb >= mesh->mlbetweennodes.Size()+IndexBASE<PointIndex>())
continue;
auto parents = mesh->mlbetweennodes[vb];
@ -1552,7 +1552,7 @@ namespace netgen
for (int k = 0; k < 3; k++)
{
PointIndex vb = f3[k]; // assume vb as the new bisect vert
if (vb >= mesh->mlbetweennodes.Size()+PointIndex::BASE)
if (vb >= mesh->mlbetweennodes.Size()+IndexBASE<PointIndex>())
continue;
auto parents = mesh->mlbetweennodes[vb];

View File

@ -20,11 +20,11 @@ namespace netgen
{
backup[i] = new Point<3>(mesh.Point(i+1));
if(isnewpoint.Test(i+PointIndex::BASE) &&
mesh.mlbetweennodes[i+PointIndex::BASE][0] > 0)
if(isnewpoint.Test(i+IndexBASE<PointIndex>()) &&
mesh.mlbetweennodes[i+IndexBASE<PointIndex>()][0].IsValid())
{
mesh.Point(i+1) = Center(mesh.Point(mesh.mlbetweennodes[i+PointIndex::BASE][0]),
mesh.Point(mesh.mlbetweennodes[i+PointIndex::BASE][1]));
mesh.Point(i+1) = Center(mesh.Point(mesh.mlbetweennodes[i+IndexBASE<PointIndex>()][0]),
mesh.Point(mesh.mlbetweennodes[i+IndexBASE<PointIndex>()][1]));
}
}
for (ElementIndex i = 0; i < mesh.GetNE(); i++)
@ -254,15 +254,16 @@ namespace netgen
*should[i] = mesh.Point(i+1);
for(int i=0; i<np; i++)
// for(int i=0; i<np; i++)
for (PointIndex i = IndexBASE<PointIndex>(); i < IndexBASE<PointIndex>()+np; i++)
{
if(isnewpoint.Test(i+PointIndex::BASE) &&
if(isnewpoint.Test(i) &&
//working_points.Test(i+PointIndex::BASE) &&
mesh.mlbetweennodes[i+PointIndex::BASE][0] > 0)
*can[i] = Center(*can[mesh.mlbetweennodes[i+PointIndex::BASE][0]-IndexBASE<PointIndex>()],
*can[mesh.mlbetweennodes[i+PointIndex::BASE][1]-IndexBASE<PointIndex>()]);
mesh.mlbetweennodes[i][0].IsValid())
*can[i-IndexBASE<PointIndex>()] = Center(*can[mesh.mlbetweennodes[i][0]-IndexBASE<PointIndex>()],
*can[mesh.mlbetweennodes[i][1]-IndexBASE<PointIndex>()]);
else
*can[i] = mesh.Point(i+1);
*can[i-IndexBASE<PointIndex>()] = mesh[i];
}

View File

@ -94,7 +94,7 @@ void VisualSceneMeshDoctor :: DrawScene ()
glPopName();
if (selpoint > 0 && selpoint <= mesh->GetNP())
if (selpoint-IndexBASE<PointIndex>() >= 0 && selpoint-IndexBASE<PointIndex>() < mesh->GetNP())
{
GLfloat matcolblue[] = { 0, 0, 1, 1 };
@ -376,8 +376,8 @@ void VisualSceneMeshDoctor :: BuildScene (int zoomall)
const Point3d & p1 = mesh->Point(seg[0]);
const Point3d & p2 = mesh->Point(seg[1]);
if (edgedist.Get(seg[0]) <= markedgedist &&
edgedist.Get(seg[1]) <= markedgedist)
if (edgedist[seg[0]] <= markedgedist &&
edgedist[seg[1]] <= markedgedist)
{
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
matcolseledge);
@ -518,8 +518,7 @@ void VisualSceneMeshDoctor :: UpdateTables ()
edgedist.SetSize(mesh->GetNP());
int i, changed;
for (i = 1; i <= mesh->GetNP(); i++)
edgedist.Elem(i) = 10000;
edgedist = 10000;
for (i = 1; i <= mesh->GetNSeg(); i++)
{
@ -527,8 +526,8 @@ void VisualSceneMeshDoctor :: UpdateTables ()
if ( (seg[0] == selpoint && seg[1] == selpoint2) ||
(seg[1] == selpoint && seg[0] == selpoint2) )
{
edgedist.Elem(selpoint) = 1;
edgedist.Elem(selpoint2) = 1;
edgedist[selpoint] = 1;
edgedist[selpoint2] = 1;
}
}
@ -540,17 +539,17 @@ void VisualSceneMeshDoctor :: UpdateTables ()
{
const Segment & seg = mesh->LineSegment(i);
int edist = min2 (edgedist.Get(seg[0]), edgedist.Get(seg[1]));
int edist = min2 (edgedist[seg[0]], edgedist[seg[1]]);
edist++;
if (edgedist.Get(seg[0]) > edist)
if (edgedist[seg[0]] > edist)
{
edgedist.Elem(seg[0]) = edist;
edgedist[seg[0]] = edist;
changed = 1;
}
if (edgedist.Get(seg[1]) > edist)
if (edgedist[seg[1]] > edist)
{
edgedist.Elem(seg[1]) = edist;
edgedist[seg[1]] = edist;
changed = 1;
}
}
@ -561,8 +560,8 @@ void VisualSceneMeshDoctor :: UpdateTables ()
int VisualSceneMeshDoctor :: IsSegmentMarked (int segnr) const
{
const Segment & seg = mesh->LineSegment(segnr);
return (edgedist.Get(seg[0]) <= markedgedist &&
edgedist.Get(seg[1]) <= markedgedist);
return (edgedist[seg[0]] <= markedgedist &&
edgedist[seg[1]] <= markedgedist);
}
}

View File

@ -9,10 +9,10 @@ class VisualSceneMeshDoctor : public VisualScene
int edgelist;
int selelement, locpi;
int selpoint, selpoint2;
PointIndex selpoint, selpoint2;
// for edgemarking:
NgArray<int> edgedist;
Array<int,PointIndex> edgedist;
int markedgedist;

View File

@ -292,11 +292,11 @@ namespace netgen
center.Y() = vispar.centery;
center.Z() = vispar.centerz;
}
else if (selpoint >= 1 && zoomall==2)
else if (selpoint-IndexBASE<PointIndex>() >= 1 && zoomall==2)
center = mesh->Point (selpoint);
else if (marker && zoomall==2)
center = *marker;
else if (vispar.centerpoint >= 1 && zoomall==2)
else if (vispar.centerpoint-IndexBASE<PointIndex>() >= 0 && zoomall==2)
center = mesh->Point (vispar.centerpoint);
else
center = Center (pmin, pmax);

View File

@ -232,7 +232,7 @@ namespace netgen
<< "DATASET UNSTRUCTURED_GRID\n\n";
surf_ost << "POINTS " << mesh->GetNP() << " float\n";
for (PointIndex pi = PointIndex::BASE; pi < mesh->GetNP()+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>(); pi < mesh->GetNP()+IndexBASE<PointIndex>(); pi++)
{
const MeshPoint & mp = (*mesh)[pi];
surf_ost << mp(0) << " " << mp(1) << " " << mp(2) << "\n";
@ -275,7 +275,7 @@ namespace netgen
<< "DATASET UNSTRUCTURED_GRID\n\n";
ost << "POINTS " << mesh->GetNP() << " float\n";
for (PointIndex pi = PointIndex::BASE; pi < mesh->GetNP()+PointIndex::BASE; pi++)
for (PointIndex pi = IndexBASE<PointIndex>(); pi < mesh->GetNP()+IndexBASE<PointIndex>(); pi++)
{
const MeshPoint & mp = (*mesh)[pi];
ost << mp(0) << " " << mp(1) << " " << mp(2) << "\n";
@ -3891,12 +3891,13 @@ namespace netgen
return def;
}
void VisualSceneSolution :: GetPointDeformation (int pnum, Point<3> & p,
void VisualSceneSolution :: GetPointDeformation (PointIndex pnum, Point<3> & p,
SurfaceElementIndex elnr) const
{
shared_ptr<Mesh> mesh = GetMesh();
p = mesh->Point (pnum+1);
auto pnum_ = pnum-IndexBASE<PointIndex>();
p = mesh->Point (pnum);
if (deform && vecfunction != -1)
{
const SolData * vsol = soldata[vecfunction];
@ -3904,15 +3905,15 @@ namespace netgen
Vec<3> v(0,0,0);
if (vsol->soltype == SOL_NODAL)
{
v = Vec3d(vsol->data[pnum * vsol->dist],
vsol->data[pnum * vsol->dist+1],
vsol->data[pnum * vsol->dist+2]);
v = Vec3d(vsol->data[pnum_ * vsol->dist],
vsol->data[pnum_ * vsol->dist+1],
vsol->data[pnum_ * vsol->dist+2]);
}
else if (vsol->soltype == SOL_SURFACE_NONCONTINUOUS)
{
const Element2d & el = (*mesh)[elnr];
for (int j = 0; j < el.GetNP(); j++)
if (el[j] == pnum+1)
if (el[j] == pnum)
{
int base = (4*elnr+j-1) * vsol->dist;
v = Vec3d(vsol->data[base],

View File

@ -319,7 +319,7 @@ private:
Vec<3> GetDeformation (ElementIndex elnr, const Point<3> & p) const;
Vec<3> GetSurfDeformation (SurfaceElementIndex selnr, int facetnr, double lam1, double lam2) const;
void GetPointDeformation (int pnum, Point<3> & p, SurfaceElementIndex elnr = -1) const;
void GetPointDeformation (PointIndex pnum, Point<3> & p, SurfaceElementIndex elnr = -1) const;
public:
/// draw elements (build lists)

View File

@ -70,12 +70,12 @@ TEST_CASE("Array")
// pointindex is still 1 based
Array<double, netgen::PointIndex> piarray(2);
i = 1;
netgen::PointIndex pi = IndexBASE<netgen::PointIndex>();
for(auto j : Range(piarray))
CHECK(j == i++);
i = 1;
CHECK(j == pi++);
pi = IndexBASE<netgen::PointIndex>();
for(auto j : piarray.Range())
CHECK(j == i++);
CHECK(j == pi++);
// a class can implement index_type and Size as well.
ClsWithIndexType<int> clsi(3);
CHECK(typeid(Range(clsi)) == typeid(T_Range<int>));