more STLPointId ...

This commit is contained in:
Joachim Schöberl 2019-09-21 01:06:49 +02:00
parent f22cb48832
commit 9b13bde72b
7 changed files with 124 additions and 127 deletions

View File

@ -1499,7 +1499,7 @@ void STLGeometry :: PrintSelectInfo()
, " (=", int(GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig())), ")"); , " (=", int(GetTriangle(GetSelectTrig()).PNum(GetNodeOfSelTrig())), ")");
if (AtlasMade() && GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT()) if (AtlasMade() && GetSelectTrig() >= 1 && GetSelectTrig() <= GetNT())
{ {
PrintMessage(1," chartnum=",GetChartNr(GetSelectTrig())); PrintMessage(1," chartnum=", int(GetChartNr(GetSelectTrig())));
/* /*
PointBetween(Center(Center(GetPoint(GetTriangle(270).PNum(1)), PointBetween(Center(Center(GetPoint(GetTriangle(270).PNum(1)),
GetPoint(GetTriangle(270).PNum(2))), GetPoint(GetTriangle(270).PNum(2))),
@ -1517,7 +1517,7 @@ void STLGeometry :: ShowSelectedTrigChartnum()
int st = GetSelectTrig(); int st = GetSelectTrig();
if (st >= 1 && st <= GetNT() && AtlasMade()) if (st >= 1 && st <= GetNT() && AtlasMade())
PrintMessage(1,"selected trig ", st, " has chartnumber ", GetChartNr(st)); PrintMessage(1,"selected trig ", st, " has chartnumber ", int(GetChartNr(st)));
} }
void STLGeometry :: ShowSelectedTrigCoords() void STLGeometry :: ShowSelectedTrigCoords()
@ -2689,10 +2689,10 @@ void STLGeometry :: AddFaceEdges()
double maxlen = -1; double maxlen = -1;
for (int j = 1; j <= c.GetNChartT(); j++) for (int j = 1; j <= c.GetNChartT(); j++)
{ {
const STLTriangle& t1 = GetTriangle(c.GetChartTrig(j)); const STLTriangle& t1 = GetTriangle(c.GetChartTrig1(j));
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
int nt = NeighbourTrig(c.GetChartTrig(j),k); int nt = NeighbourTrig(c.GetChartTrig1(j),k);
if (GetChartNr(nt) != chartindex.Get(i)) if (GetChartNr(nt) != chartindex.Get(i))
{ {
t1.GetNeighbourPoints(GetTriangle(nt),ap1,ap2); t1.GetNeighbourPoints(GetTriangle(nt),ap1,ap2);
@ -3153,7 +3153,7 @@ void STLGeometry :: AddConeAndSpiralEdges(const STLParameters& stlparam)
STLChart& chart = GetChart(i); STLChart& chart = GetChart(i);
for (j = 1; j <= chart.GetNChartT(); j++) for (j = 1; j <= chart.GetNChartT(); j++)
{ {
int t = chart.GetChartTrig(j); STLTrigId t = chart.GetChartTrig1(j);
const STLTriangle& tt = GetTriangle(t); const STLTriangle& tt = GetTriangle(t);
for (k = 1; k <= 3; k++) for (k = 1; k <= 3; k++)
@ -3172,7 +3172,7 @@ void STLGeometry :: AddConeAndSpiralEdges(const STLParameters& stlparam)
AddEdgePP(np2,edgenum); AddEdgePP(np2,edgenum);
//changed = 1; //changed = 1;
PrintWarning("Found a spiral like structure: chart=", i, PrintWarning("Found a spiral like structure: chart=", i,
", trig=", t, ", p1=", np1, ", p2=", np2); ", trig=", int(t), ", p1=", np1, ", p2=", np2);
cnt++; cnt++;
} }
} }
@ -3214,7 +3214,7 @@ void STLGeometry :: AddConeAndSpiralEdges(const STLParameters& stlparam)
STLChart& chart = GetChart(i); STLChart& chart = GetChart(i);
for (j = 1; j <= chart.GetNChartT(); j++) for (j = 1; j <= chart.GetNChartT(); j++)
{ {
int t = chart.GetChartTrig(j); STLTrigId t = chart.GetChartTrig1(j);
const STLTriangle& tt = GetTriangle(t); const STLTriangle& tt = GetTriangle(t);
for (k = 1; k <= 3; k++) for (k = 1; k <= 3; k++)
@ -3363,7 +3363,7 @@ void STLGeometry :: AddConeAndSpiralEdges(const STLParameters& stlparam)
STLChart& chart = GetChart(i); STLChart& chart = GetChart(i);
for (j = 1; j <= chart.GetNChartT(); j++) for (j = 1; j <= chart.GetNChartT(); j++)
{ {
int t = chart.GetChartTrig(j); STLTrigId t = chart.GetChartTrig1(j);
const STLTriangle& tt = GetTriangle(t); const STLTriangle& tt = GetTriangle(t);
for (k = 1; k <= 3; k++) for (k = 1; k <= 3; k++)

View File

@ -141,7 +141,7 @@ namespace netgen
// //
Array<unique_ptr<STLChart>, ChartId> atlas; Array<unique_ptr<STLChart>, ChartId> atlas;
//marks all already charted trigs with chartnumber //marks all already charted trigs with chartnumber
NgArray<ChartId> chartmark; Array<ChartId, STLTrigId> chartmark;
//outerchartspertrig, ascending sorted //outerchartspertrig, ascending sorted
TABLE<int> outerchartspertrig; TABLE<int> outerchartspertrig;
@ -368,7 +368,7 @@ namespace netgen
void AddConeAndSpiralEdges(const STLParameters& stlparam); void AddConeAndSpiralEdges(const STLParameters& stlparam);
void AddFaceEdges(); //each face should have at least one starting edge (outherwise it won't be meshed) void AddFaceEdges(); //each face should have at least one starting edge (outherwise it won't be meshed)
void GetDirtyChartTrigs(int chartnum, STLChart& chart, const NgArray<ChartId>& outercharttrigs, void GetDirtyChartTrigs(int chartnum, STLChart& chart, const Array<ChartId, STLTrigId>& outercharttrigs,
NgArray<ChartId>& chartpointchecked, NgArray<int>& dirtytrigs); NgArray<ChartId>& chartpointchecked, NgArray<int>& dirtytrigs);
void ClearSpiralPoints(); void ClearSpiralPoints();
@ -394,11 +394,10 @@ namespace netgen
int TrigIsInOC(int tn, int ocn) const; int TrigIsInOC(int tn, int ocn) const;
//get chart number of a trig or 0 if unmarked //get chart number of a trig or 0 if unmarked
int GetChartNr(int i) const; ChartId GetChartNr(STLTrigId i) const;
ChartId GetMarker(int i) const ChartId GetMarker(STLTrigId i) const { return chartmark[i]; }
{ return chartmark.Get(i); } void SetMarker(STLTrigId nr, ChartId m);
void SetMarker(int nr, ChartId m); size_t GetNOCharts() const { return atlas.Size(); }
int GetNOCharts() const { return atlas.Size(); }
//get a chart from atlas //get a chart from atlas
const STLChart& GetChart(ChartId nr) const { return *atlas[nr];}; const STLChart& GetChart(ChartId nr) const { return *atlas[nr];};
STLChart & GetChart(ChartId nr) { return *atlas[nr];}; STLChart & GetChart(ChartId nr) { return *atlas[nr];};

View File

@ -69,13 +69,13 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
double sinchartangle = sin(chartangle); double sinchartangle = sin(chartangle);
double sinouterchartangle = sin(outerchartangle); double sinouterchartangle = sin(outerchartangle);
NgArray<ChartId> outermark(GetNT()); //marks all trigs form actual outer region Array<ChartId,STLTrigId> outermark(GetNT()); //marks all trigs form actual outer region
NgArray<ChartId> outertested(GetNT()); //marks tested trigs for outer region Array<ChartId,STLTrigId> outertested(GetNT()); //marks tested trigs for outer region
NgArray<ChartId> pointstochart(GetNP()); //point in chart becomes chartnum Array<ChartId,STLPointId> pointstochart(GetNP()); //point in chart becomes chartnum
NgArray<ChartId> innerpointstochart(GetNP()); //point in chart becomes chartnum Array<ChartId,STLPointId> innerpointstochart(GetNP()); //point in chart becomes chartnum
NgArray<int> chartpoints; //point in chart becomes chartnum Array<STLPointId> chartpoints; //point in chart becomes chartnum
NgArray<int> innerchartpoints; Array<STLPointId> innerchartpoints;
NgArray<Point<3>> innerchartpts; Array<Point<3>> innerchartpts;
NgArray<int> dirtycharttrigs; NgArray<int> dirtycharttrigs;
NgArray<int> chartdistacttrigs (GetNT()); //outercharttrigs NgArray<int> chartdistacttrigs (GetNT()); //outercharttrigs
@ -107,7 +107,7 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
double workedarea = 0; double workedarea = 0;
double showinc = 100.*5000./(double)GetNT(); double showinc = 100.*5000./(double)GetNT();
double nextshow = 0; double nextshow = 0;
int lastunmarked = 1; STLTrigId lastunmarked = 1;
PrintMessage(5,"one dot per 5000 triangles: "); PrintMessage(5,"one dot per 5000 triangles: ");
@ -126,10 +126,10 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
STLChart & chart = *atlas.Last(); STLChart & chart = *atlas.Last();
//find unmarked trig //find unmarked trig
int prelastunmarked = lastunmarked; STLTrigId prelastunmarked = lastunmarked;
bool found = false; bool found = false;
for (int j = lastunmarked; j <= GetNT(); j++) for (STLTrigId j = lastunmarked; j <= GetNT(); j++)
if (!GetMarker(j)) if (!GetMarker(j))
{ {
found = true; found = true;
@ -145,11 +145,11 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
chartbound.BuildSearchTree(); // different !!! chartbound.BuildSearchTree(); // different !!!
if (!found) { throw Exception("Make Atlas, no starttrig found"); } if (!found) throw Exception("Make Atlas, no starttrig found");
//find surrounding trigs //find surrounding trigs
// int starttrig = j; // int starttrig = j;
int starttrig = lastunmarked; STLTrigId starttrig = lastunmarked;
Point<3> startp = GetPoint(GetTriangle(starttrig)[0]); Point<3> startp = GetPoint(GetTriangle(starttrig)[0]);
@ -168,12 +168,13 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
workedarea += GetTriangle(starttrig).Area(points); workedarea += GetTriangle(starttrig).Area(points);
for (int i = 1; i <= 3; i++) for (int i = 0; i < 3; i++)
{ {
innerpointstochart.Elem(GetTriangle(starttrig).PNum(i)) = chartnum; STLPointId pi = GetTriangle(starttrig)[i];
pointstochart.Elem(GetTriangle(starttrig).PNum(i)) = chartnum; innerpointstochart[pi] = chartnum;
chartpoints.Append(GetTriangle(starttrig).PNum(i)); pointstochart[pi] = chartnum;
innerchartpoints.Append(GetTriangle(starttrig).PNum(i)); chartpoints.Append(pi);
innerchartpoints.Append(pi);
} }
bool changed = true; bool changed = true;
@ -191,7 +192,7 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
// for (ic = oldstartic2; ic <= chart->GetNT(); ic++) // for (ic = oldstartic2; ic <= chart->GetNT(); ic++)
for (int ic = oldstartic2; ic <= oldstartic; ic++) for (int ic = oldstartic2; ic <= oldstartic; ic++)
{ {
int i = chart.GetTrig(ic); STLTrigId i = chart.GetTrig1(ic);
if (GetMarker(i) == chartnum) if (GetMarker(i) == chartnum)
{ {
for (int j = 1; j <= NONeighbourTrigs(i); j++) for (int j = 1; j <= NONeighbourTrigs(i); j++)
@ -273,11 +274,11 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
if (innerpointstochart.Get(GetTriangle(nt).PNum(k)) if (innerpointstochart[GetTriangle(nt).PNum(k)]
!= chartnum) != chartnum)
{ {
innerpointstochart.Elem(GetTriangle(nt).PNum(k)) = chartnum; innerpointstochart[GetTriangle(nt).PNum(k)] = chartnum;
pointstochart.Elem(GetTriangle(nt).PNum(k)) = chartnum; pointstochart[GetTriangle(nt).PNum(k)] = chartnum;
chartpoints.Append(GetTriangle(nt).PNum(k)); chartpoints.Append(GetTriangle(nt).PNum(k));
innerchartpoints.Append(GetTriangle(nt).PNum(k)); innerchartpoints.Append(GetTriangle(nt).PNum(k));
} }
@ -304,7 +305,7 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
// warum, ic-bound auf edge macht Probleme js ??? // warum, ic-bound auf edge macht Probleme js ???
outermark.Elem(starttrig) = chartnum; outermark[starttrig] = chartnum;
//chart->AddOuterTrig(starttrig); //chart->AddOuterTrig(starttrig);
changed = true; changed = true;
oldstartic = 1; oldstartic = 1;
@ -316,13 +317,13 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
for (int ic = oldstartic2; ic <= oldstartic; ic++) for (int ic = oldstartic2; ic <= oldstartic; ic++)
{ {
int i = chart.GetTrig(ic); STLTrigId i = chart.GetTrig1(ic);
if (outermark.Get(i) != chartnum) continue; if (outermark[i] != chartnum) continue;
for (int j = 1; j <= NONeighbourTrigs(i); j++) for (int j = 1; j <= NONeighbourTrigs(i); j++)
{ {
int nt = NeighbourTrig(i,j); STLTrigId nt = NeighbourTrig(i,j);
if (outermark.Get(nt) == chartnum) continue; if (outermark[nt] == chartnum) continue;
const STLTriangle & ntrig = GetTriangle(nt); const STLTriangle & ntrig = GetTriangle(nt);
int np1, np2; int np1, np2;
@ -335,7 +336,7 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
if (outertested.Get(nt) == chartnum) if (outertested.Get(nt) == chartnum)
continue; continue;
*/ */
outertested.Elem(nt) = chartnum; outertested[nt] = chartnum;
Vec<3> n2 = GetTriangle(nt).Normal(); Vec<3> n2 = GetTriangle(nt).Normal();
@ -362,9 +363,9 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
// NgProfiler::StartTimer (timer4b); // NgProfiler::StartTimer (timer4b);
int nnt = NeighbourTrig(nt,k); STLTrigId nnt = NeighbourTrig(nt,k);
if (outermark.Elem(nnt) != chartnum) if (outermark[nnt] != chartnum)
{ {
// NgProfiler::StartTimer (timer4c); // NgProfiler::StartTimer (timer4c);
int nnp1, nnp2; int nnp1, nnp2;
@ -406,7 +407,7 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
accepted = false; accepted = false;
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
if (innerpointstochart.Get(ntrig.PNum(k)) == chartnum) if (innerpointstochart[ntrig.PNum(k)] == chartnum)
{ {
accepted = true; accepted = true;
break; break;
@ -451,7 +452,7 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
if (accepted) if (accepted)
{ {
changed = true; changed = true;
outermark.Elem(nt) = chartnum; outermark[nt] = chartnum;
if (GetMarker(nt) != chartnum) if (GetMarker(nt) != chartnum)
{ {
@ -459,10 +460,10 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
chart.AddOuterTrig(nt); chart.AddOuterTrig(nt);
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
if (pointstochart.Get(GetTriangle(nt).PNum(k)) if (pointstochart[GetTriangle(nt).PNum(k)]
!= chartnum) != chartnum)
{ {
pointstochart.Elem(GetTriangle(nt).PNum(k)) = chartnum; pointstochart[GetTriangle(nt).PNum(k)] = chartnum;
chartpoints.Append(GetTriangle(nt).PNum(k)); chartpoints.Append(GetTriangle(nt).PNum(k));
} }
} }
@ -491,8 +492,8 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
} }
for (int k = 1; k <= dirtycharttrigs.Size(); k++) for (int k = 1; k <= dirtycharttrigs.Size(); k++)
{ {
int tn = chart.GetChartTrig(dirtycharttrigs.Get(k)); STLTrigId tn = chart.GetChartTrig1(dirtycharttrigs.Get(k));
outermark.Elem(tn) = 0; //not necessary, for later use outermark[tn] = 0; //not necessary, for later use
SetMarker(tn, 0); SetMarker(tn, 0);
markedtrigcnt--; markedtrigcnt--;
workedarea -= GetTriangle(tn).Area(points); workedarea -= GetTriangle(tn).Area(points);
@ -534,7 +535,7 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons
{ {
for (int j = 1; j <= GetChart(i).GetNT(); j++) for (int j = 1; j <= GetChart(i).GetNT(); j++)
{ {
int tn = GetChart(i).GetTrig(j); STLTrigId tn = GetChart(i).GetTrig1(j);
AddOCPT(tn,i); AddOCPT(tn,i);
} }
@ -611,14 +612,14 @@ int STLGeometry::TrigIsInOC(int tn, int ocn) const
return GetOCPT(tn, start) == ocn; return GetOCPT(tn, start) == ocn;
} }
int STLGeometry :: GetChartNr(int i) const ChartId STLGeometry :: GetChartNr(STLTrigId i) const
{ {
if (i > chartmark.Size()) if (i > chartmark.Size())
{ {
PrintSysError("GetChartNr(", i, ") not possible!!!"); PrintSysError("GetChartNr(", int(i), ") not possible!!!");
i = 1; i = 1;
} }
return chartmark.Get(i); return chartmark[i];
} }
/* /*
int STLGeometry :: GetMarker(int i) const int STLGeometry :: GetMarker(int i) const
@ -626,9 +627,9 @@ int STLGeometry :: GetMarker(int i) const
return chartmark.Get(i); return chartmark.Get(i);
} }
*/ */
void STLGeometry :: SetMarker(int nr, ChartId m) void STLGeometry :: SetMarker(STLTrigId nr, ChartId m)
{ {
chartmark.Elem(nr) = m; chartmark[nr] = m;
} }
int STLGeometry :: AtlasMade() const int STLGeometry :: AtlasMade() const
@ -653,21 +654,19 @@ int AddIfNotExists(NgArray<int>& list, int x)
void STLGeometry :: GetInnerChartLimes(NgArray<twoint>& limes, ChartId chartnum) void STLGeometry :: GetInnerChartLimes(NgArray<twoint>& limes, ChartId chartnum)
{ {
int j, k; int np1, np2;
int t, nt, np1, np2;
limes.SetSize(0); limes.SetSize(0);
STLChart& chart = GetChart(chartnum); STLChart& chart = GetChart(chartnum);
for (j = 1; j <= chart.GetNChartT(); j++) for (int j = 1; j <= chart.GetNChartT(); j++)
{ {
t = chart.GetChartTrig(j); STLTrigId t = chart.GetChartTrig1(j);
const STLTriangle& tt = GetTriangle(t); const STLTriangle& tt = GetTriangle(t);
for (k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
nt = NeighbourTrig(t,k); STLTrigId nt = NeighbourTrig(t,k);
if (GetChartNr(nt) != chartnum) if (GetChartNr(nt) != chartnum)
{ {
tt.GetNeighbourPoints(GetTriangle(nt),np1,np2); tt.GetNeighbourPoints(GetTriangle(nt),np1,np2);
@ -712,26 +711,26 @@ void STLGeometry :: GetInnerChartLimes(NgArray<twoint>& limes, ChartId chartnum)
void STLGeometry :: GetDirtyChartTrigs(int chartnum, STLChart& chart, void STLGeometry :: GetDirtyChartTrigs(int chartnum, STLChart& chart,
const NgArray<ChartId>& outercharttrigs, const Array<ChartId,STLTrigId>& outercharttrigs,
NgArray<ChartId>& chartpointchecked, NgArray<ChartId>& chartpointchecked,
NgArray<int>& dirtytrigs) NgArray<int>& dirtytrigs)
{ {
dirtytrigs.SetSize(0); dirtytrigs.SetSize(0);
int j,k,n;
int np1, np2, nt;
int cnt = 0; int cnt = 0;
for (j = 1; j <= chart.GetNChartT(); j++) for (int j = 1; j <= chart.GetNChartT(); j++)
{ {
int t = chart.GetChartTrig(j); STLTrigId t = chart.GetChartTrig1(j);
const STLTriangle& tt = GetTriangle(t); const STLTriangle& tt = GetTriangle(t);
for (k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
nt = NeighbourTrig(t,k); STLTrigId nt = NeighbourTrig(t,k);
if (GetChartNr(nt) != chartnum && outercharttrigs.Get(nt) != chartnum) if (GetChartNr(nt) != chartnum && outercharttrigs[nt] != chartnum)
{ {
int np1, np2;
tt.GetNeighbourPoints(GetTriangle(nt),np1,np2); tt.GetNeighbourPoints(GetTriangle(nt),np1,np2);
if (!IsEdge(np1,np2)) if (!IsEdge(np1,np2))
{ {
@ -747,23 +746,23 @@ void STLGeometry :: GetDirtyChartTrigs(int chartnum, STLChart& chart,
int ap1, ap2, tn1, tn2, l, problem, pn; int ap1, ap2, tn1, tn2, l, problem, pn;
NgArray<int> trigsaroundp; NgArray<int> trigsaroundp;
for (j = chart.GetNChartT(); j >= 1; j--) for (int j = chart.GetNChartT(); j >= 1; j--)
{ {
int t = chart.GetChartTrig(j); STLTrigId t = chart.GetChartTrig1(j);
const STLTriangle& tt = GetTriangle(t); const STLTriangle& tt = GetTriangle(t);
for (k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
pn = tt.PNum(k); pn = tt.PNum(k);
//if (chartpointchecked.Get(pn) == chartnum) //if (chartpointchecked.Get(pn) == chartnum)
//{continue;} //{continue;}
int checkpoint = 0; int checkpoint = 0;
for (n = 1; n <= trigsperpoint.EntrySize(pn); n++) for (int n = 1; n <= trigsperpoint.EntrySize(pn); n++)
{ {
if (trigsperpoint.Get(pn,n) != t && //ueberfluessig??? if (trigsperpoint.Get(pn,n) != t && //ueberfluessig???
GetChartNr(trigsperpoint.Get(pn,n)) != chartnum && GetChartNr(trigsperpoint.Get(pn,n)) != chartnum &&
outercharttrigs.Get(trigsperpoint.Get(pn,n)) != chartnum) {checkpoint = 1;}; outercharttrigs[trigsperpoint.Get(pn,n)] != chartnum) {checkpoint = 1;};
} }
if (checkpoint) if (checkpoint)
{ {
@ -783,7 +782,7 @@ void STLGeometry :: GetDirtyChartTrigs(int chartnum, STLChart& chart,
t1.GetNeighbourPoints(t2, ap1, ap2); t1.GetNeighbourPoints(t2, ap1, ap2);
if (IsEdge(ap1,ap2)) break; if (IsEdge(ap1,ap2)) break;
if (GetChartNr(tn2) != chartnum && outercharttrigs.Get(tn2) != chartnum) {problem = 1;} if (GetChartNr(tn2) != chartnum && outercharttrigs[tn2] != chartnum) {problem = 1;}
} }
//backwards: //backwards:
@ -796,7 +795,7 @@ void STLGeometry :: GetDirtyChartTrigs(int chartnum, STLChart& chart,
t1.GetNeighbourPoints(t2, ap1, ap2); t1.GetNeighbourPoints(t2, ap1, ap2);
if (IsEdge(ap1,ap2)) break; if (IsEdge(ap1,ap2)) break;
if (GetChartNr(tn2) != chartnum && outercharttrigs.Get(tn2) != chartnum) {problem = 1;} if (GetChartNr(tn2) != chartnum && outercharttrigs[tn2] != chartnum) {problem = 1;}
} }
// if (problem && !IsInArray(j,dirtytrigs)) // if (problem && !IsInArray(j,dirtytrigs))
if (problem && !dirtytrigs.Contains(j)) if (problem && !dirtytrigs.Contains(j))

View File

@ -462,7 +462,7 @@ void STLGeometry :: ToPlane (const Point<3> & locpoint, int * trigs,
else else
{ {
NgArray<int> trigsinbox; NgArray<STLTrigId> trigsinbox;
if (!geomsearchtreeon) if (!geomsearchtreeon)
{ {
@ -563,7 +563,7 @@ int STLGeometry :: Project(Point<3> & p3d) const
for (j = 1; j <= nt; j++) for (j = 1; j <= nt; j++)
{ {
i = chart.GetTrig(j); i = chart.GetTrig1(j);
const Point<3> & c = GetTriangle(i).center; const Point<3> & c = GetTriangle(i).center;
/* /*
@ -687,12 +687,12 @@ int STLGeometry :: ProjectNearest(Point<3> & p3d) const
for (i = 1; i <= chart.GetNT(); i++) for (i = 1; i <= chart.GetNT(); i++)
{ {
p = p3d; p = p3d;
dist = GetTriangle(chart.GetTrig(i)).GetNearestPoint(points, p); dist = GetTriangle(chart.GetTrig1(i)).GetNearestPoint(points, p);
if (dist < nearest) if (dist < nearest)
{ {
pf = p; pf = p;
nearest = dist; nearest = dist;
ft = chart.GetTrig(i); ft = chart.GetTrig1(i);
} }
} }
p3d = pf; p3d = pf;
@ -1163,7 +1163,7 @@ void STLGeometry :: RestrictHChartDistOneChart(ChartId chartnum, NgArray<int>& a
for (int j = 1; j <= chart.GetNChartT(); j++) for (int j = 1; j <= chart.GetNChartT(); j++)
{ {
int t = chart.GetChartTrig(j); int t = chart.GetChartTrig1(j);
tt = GetTriangle(t); tt = GetTriangle(t);
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {
@ -1213,11 +1213,11 @@ void STLGeometry :: RestrictHChartDistOneChart(ChartId chartnum, NgArray<int>& a
NgProfiler::StartTimer (timer2); NgProfiler::StartTimer (timer2);
for (int j = 1; j <= chart.GetNT(); j++) for (int j = 1; j <= chart.GetNT(); j++)
acttrigs.Elem(chart.GetTrig(j)) = chartnum; acttrigs.Elem(chart.GetTrig1(j)) = chartnum;
for (int j = 1; j <= chart.GetNOuterT(); j++) for (int j = 1; j <= chart.GetNOuterT(); j++)
{ {
int t = chart.GetOuterTrig(j); int t = chart.GetOuterTrig1(j);
tt = GetTriangle(t); tt = GetTriangle(t);
for (int k = 1; k <= 3; k++) for (int k = 1; k <= 3; k++)
{ {

View File

@ -619,7 +619,7 @@ STLChart :: STLChart(STLGeometry * ageometry, const STLParameters& astlparam)
{ {
Box<3> box = geometry->GetBoundingBox(); Box<3> box = geometry->GetBoundingBox();
box.Increase (0.2*box.Diam()+1e-12); box.Increase (0.2*box.Diam()+1e-12);
searchtree = new BoxTree<3> (box); searchtree = new BoxTree<3,STLTrigId> (box);
/* /*
searchtree = new BoxTree<3> (geometry->GetBoundingBox().PMin() - Vec3d(1,1,1), searchtree = new BoxTree<3> (geometry->GetBoundingBox().PMin() - Vec3d(1,1,1),
geometry->GetBoundingBox().PMax() + Vec3d(1,1,1)); geometry->GetBoundingBox().PMax() + Vec3d(1,1,1));
@ -634,7 +634,7 @@ STLChart :: ~STLChart()
delete searchtree; delete searchtree;
} }
void STLChart :: AddChartTrig(int i) void STLChart :: AddChartTrig(STLTrigId i)
{ {
// static int timer = NgProfiler::CreateTimer ("STLChart::AddChartTrig"); // static int timer = NgProfiler::CreateTimer ("STLChart::AddChartTrig");
// NgProfiler::RegionTimer reg(timer); // NgProfiler::RegionTimer reg(timer);
@ -666,7 +666,7 @@ void STLChart :: AddChartTrig(int i)
} }
} }
void STLChart :: AddOuterTrig(int i) void STLChart :: AddOuterTrig(STLTrigId i)
{ {
// static int timer = NgProfiler::CreateTimer ("STLChart::AddOuterTrig"); // static int timer = NgProfiler::CreateTimer ("STLChart::AddOuterTrig");
// NgProfiler::RegionTimer reg(timer); // NgProfiler::RegionTimer reg(timer);
@ -690,18 +690,17 @@ void STLChart :: AddOuterTrig(int i)
bool STLChart :: IsInWholeChart(int nr) const bool STLChart :: IsInWholeChart(int nr) const
{ {
for (int i = 1; i <= charttrigs.Size(); i++) // for (int i = 1; i <= charttrigs.Size(); i++)
if (charttrigs.Get(i) == nr) return true; // if (charttrigs.Get(i) == nr) return true;
// for (int i = 1; i <= outertrigs.Size(); i++)
for (int i = 1; i <= outertrigs.Size(); i++) // if (outertrigs.Get(i) == nr) return true;
if (outertrigs.Get(i) == nr) return true; // return false;
return charttrigs.Contains(nr) || outertrigs.Contains(nr);
return false;
} }
void STLChart :: GetTrianglesInBox (const Point3d & pmin, void STLChart :: GetTrianglesInBox (const Point3d & pmin,
const Point3d & pmax, const Point3d & pmax,
NgArray<int> & trias) const NgArray<STLTrigId> & trias) const
{ {
if (geomsearchtreeon) {PrintMessage(5,"geomsearchtreeon is set!!!");} if (geomsearchtreeon) {PrintMessage(5,"geomsearchtreeon is set!!!");}
@ -717,7 +716,7 @@ void STLChart :: GetTrianglesInBox (const Point3d & pmin,
int nt = GetNT(); int nt = GetNT();
for (int i = 1; i <= nt; i++) for (int i = 1; i <= nt; i++)
{ {
int trignum = GetTrig(i); STLTrigId trignum = GetTrig1(i);
const STLTriangle & trig = geometry->GetTriangle(trignum); const STLTriangle & trig = geometry->GetTriangle(trignum);
Box<3> box2(geometry->GetPoint (trig.PNum(1)), Box<3> box2(geometry->GetPoint (trig.PNum(1)),
geometry->GetPoint (trig.PNum(2)), geometry->GetPoint (trig.PNum(2)),
@ -735,9 +734,9 @@ void STLChart :: MoveToOuterChart(const NgArray<int>& trigs)
if (!trigs.Size()) return; if (!trigs.Size()) return;
for (int i = 1; i <= trigs.Size(); i++) for (int i = 1; i <= trigs.Size(); i++)
{ {
if (charttrigs.Get(trigs.Get(i)) != -1) if (charttrigs[trigs.Get(i)-1] != -1)
{AddOuterTrig(charttrigs.Get(trigs.Get(i)));} AddOuterTrig(charttrigs[trigs.Get(i)-1]);
charttrigs.Elem(trigs.Get(i)) = -1; charttrigs[trigs.Get(i)-1] = -1;
} }
DelChartTrigs(trigs); DelChartTrigs(trigs);
} }
@ -748,15 +747,15 @@ void STLChart :: DelChartTrigs(const NgArray<int>& trigs)
if (!trigs.Size()) return; if (!trigs.Size()) return;
for (int i = 1; i <= trigs.Size(); i++) for (int i = 1; i <= trigs.Size(); i++)
charttrigs.Elem(trigs.Get(i)) = -1; charttrigs[trigs.Get(i)-1] = -1;
int cnt = 0; int cnt = 0;
for (int i = 1; i <= charttrigs.Size(); i++) for (int i = 1; i <= charttrigs.Size(); i++)
{ {
if (charttrigs.Elem(i) == -1) if (charttrigs[i-1] == -1)
cnt++; cnt++;
if (cnt != 0 && i < charttrigs.Size()) if (cnt != 0 && i < charttrigs.Size())
charttrigs.Elem(i-cnt+1) = charttrigs.Get(i+1); charttrigs[i-cnt] = charttrigs[i];
} }
int i = charttrigs.Size() - trigs.Size(); int i = charttrigs.Size() - trigs.Size();
@ -766,7 +765,7 @@ void STLChart :: DelChartTrigs(const NgArray<int>& trigs)
{ {
PrintMessage(7, "Warning: unsecure routine due to first use of searchtrees!!!"); PrintMessage(7, "Warning: unsecure routine due to first use of searchtrees!!!");
//bould new searchtree!!! //bould new searchtree!!!
searchtree = new BoxTree<3> (geometry->GetBoundingBox().PMin() - Vec3d(1,1,1), searchtree = new BoxTree<3,STLTrigId> (geometry->GetBoundingBox().PMin() - Vec3d(1,1,1),
geometry->GetBoundingBox().PMax() + Vec3d(1,1,1)); geometry->GetBoundingBox().PMax() + Vec3d(1,1,1));
for (int i = 1; i <= charttrigs.Size(); i++) for (int i = 1; i <= charttrigs.Size(); i++)

View File

@ -69,9 +69,9 @@ class STLChart
{ {
private: private:
STLGeometry * geometry; STLGeometry * geometry;
NgArray<int> charttrigs; // trigs which only belong to this chart Array<STLTrigId> charttrigs; // trigs which only belong to this chart
NgArray<int> outertrigs; // trigs which belong to other charts Array<STLTrigId> outertrigs; // trigs which belong to other charts
BoxTree<3> * searchtree; // ADT containing outer trigs BoxTree<3,STLTrigId> * searchtree; // ADT containing outer trigs
NgArray<twoint> olimit; //outer limit of outer chart NgArray<twoint> olimit; //outer limit of outer chart
NgArray<twoint> ilimit; //outer limit of inner chart NgArray<twoint> ilimit; //outer limit of inner chart
@ -82,35 +82,35 @@ public:
STLChart(STLGeometry * ageometry, const STLParameters& astlparam); STLChart(STLGeometry * ageometry, const STLParameters& astlparam);
~STLChart(); ~STLChart();
void AddChartTrig(int i); void AddChartTrig(STLTrigId i);
void AddOuterTrig(int i); void AddOuterTrig(STLTrigId i);
bool IsInWholeChart(int nr) const; bool IsInWholeChart(int nr) const;
int GetChartTrig(int i) const {return charttrigs.Get(i);} STLTrigId GetChartTrig1(int i) const {return charttrigs[i-1];}
int GetOuterTrig(int i) const {return outertrigs.Get(i);} STLTrigId GetOuterTrig1(int i) const {return outertrigs[i-1];}
//get all trigs: //get all trigs:
int GetTrig(int i) const STLTrigId GetTrig1(int i) const
{ {
if (i <= charttrigs.Size()) {return charttrigs.Get(i);} if (i <= charttrigs.Size()) {return charttrigs[i-1];}
else {return outertrigs.Get(i-charttrigs.Size());} else {return outertrigs[i-charttrigs.Size()-1];}
} }
int GetNChartT() const {return charttrigs.Size();} size_t GetNChartT() const {return charttrigs.Size();}
int GetNOuterT() const {return outertrigs.Size();} size_t GetNOuterT() const {return outertrigs.Size();}
int GetNT() const {return charttrigs.Size()+outertrigs.Size(); } size_t GetNT() const {return charttrigs.Size()+outertrigs.Size(); }
void GetTrianglesInBox (const Point3d & pmin, void GetTrianglesInBox (const Point3d & pmin,
const Point3d & pmax, const Point3d & pmax,
NgArray<int> & trias) const; NgArray<STLTrigId> & trias) const;
void AddOLimit(twoint l) {olimit.Append(l);} void AddOLimit(twoint l) {olimit.Append(l);}
void AddILimit(twoint l) {ilimit.Append(l);} void AddILimit(twoint l) {ilimit.Append(l);}
void ClearOLimit() {olimit.SetSize(0);} void ClearOLimit() {olimit.SetSize(0);}
void ClearILimit() {ilimit.SetSize(0);} void ClearILimit() {ilimit.SetSize(0);}
int GetNOLimit() const {return olimit.Size();} size_t GetNOLimit() const {return olimit.Size();}
int GetNILimit() const {return ilimit.Size();} size_t GetNILimit() const {return ilimit.Size();}
twoint GetOLimit(int i) const {return olimit.Get(i);} twoint GetOLimit(int i) const {return olimit.Get(i);}
twoint GetILimit(int i) const {return ilimit.Get(i);} twoint GetILimit(int i) const {return ilimit.Get(i);}

View File

@ -544,10 +544,10 @@ void VisualSceneSTLMeshing :: DrawScene ()
else else
{glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbrown);} {glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colbrown);}
*/ */
const STLTriangle& st = stlgeometry -> GetTriangle(chart.GetChartTrig(j)); const STLTriangle& st = stlgeometry -> GetTriangle(chart.GetChartTrig1(j));
const Vec3d & n = stlgeometry->GetTriangle(chart.GetChartTrig(j)).Normal(); const Vec3d & n = stlgeometry->GetTriangle(chart.GetChartTrig1(j)).Normal();
glNormal3f (n.X(), n.Y(), n.Z()); glNormal3f (n.X(), n.Y(), n.Z());
/* /*
const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(chart.GetChartTrig(j)); const STLReadTriangle& tria = stlgeometry -> GetReadTriangle(chart.GetChartTrig(j));
@ -567,9 +567,9 @@ void VisualSceneSTLMeshing :: DrawScene ()
for (j = 1; j <= chart.GetNOuterT(); j++) for (j = 1; j <= chart.GetNOuterT(); j++)
{ {
const STLTriangle& st = stlgeometry -> GetTriangle(chart.GetOuterTrig(j)); const STLTriangle& st = stlgeometry -> GetTriangle(chart.GetOuterTrig1(j));
const Vec3d & n = stlgeometry->GetTriangle(chart.GetOuterTrig(j)).Normal(); const Vec3d & n = stlgeometry->GetTriangle(chart.GetOuterTrig1(j)).Normal();
glNormal3f (n.X(), n.Y(), n.Z()); glNormal3f (n.X(), n.Y(), n.Z());