[Wsplgen-commits] r42 - trunk/src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Apr 5 08:25:27 CEST 2006
Author: mrchip
Date: 2006-04-05 08:25:27 +0200 (Wed, 05 Apr 2006)
New Revision: 42
Modified:
trunk/src/file.cpp
trunk/src/tools.cpp
trunk/src/tools.h
trunk/src/wsplgen.cpp
trunk/src/xy.cpp
trunk/src/xy.h
Log:
Br?\195?\188che anders implementiert und diverses Feintuning. Ausgaben usw.
Modified: trunk/src/file.cpp
===================================================================
--- trunk/src/file.cpp 2006-03-31 05:43:15 UTC (rev 41)
+++ trunk/src/file.cpp 2006-04-05 06:25:27 UTC (rev 42)
@@ -73,25 +73,27 @@
if (ToUpperCase(Ext) == ".ADF")
{
AnzScheiben = LoadDGMTIN(FileName, NodeList, ElementList, XyList, MaxNodesPerSlice, DebugLevel);
+ CheckForDuplicates(NodeList, ElementList, DebugLevel);
}
else if (ToUpperCase(Ext) == ".2DM")
{
AnzScheiben = LoadDGM2DM(FileName, NodeList, ElementList, XyList, MaxNodesPerSlice, DebugLevel);
+ CheckForDuplicates(NodeList, ElementList, DebugLevel);
}
else if (ToUpperCase(Ext) == ".GRD")
{
AnzScheiben = LoadDGMGRD(FileName, NodeList, ElementList, XyList, MaxNodesPerSlice, DebugLevel);
- CheckForDuplicates(NodeList, DebugLevel);
+ CheckForDuplicates(NodeList, ElementList, DebugLevel);
}
else if (ToUpperCase(Ext) == ".XYZ")
{
AnzScheiben = LoadDGMXYZ(FileName, NodeList, XyList, MaxNodesPerSlice, DebugLevel);
- CheckForDuplicates(NodeList, DebugLevel);
+ CheckForDuplicates(NodeList, ElementList, DebugLevel);
}
else if (ToUpperCase(Ext) == ".SHP")
{
AnzScheiben = LoadDGMSHP(FileName, NodeList, XyList, MaxNodesPerSlice, DebugLevel);
- CheckForDuplicates(NodeList, DebugLevel);
+ CheckForDuplicates(NodeList, ElementList, DebugLevel);
}
else
{
@@ -1917,6 +1919,11 @@
TElement *Element = (*ElementList)[i];
+ if (Element->Typ == NO_ELEMENT)
+ {
+ continue;
+ }
+
if (Element->Typ != TRI)
{
dump_error(__FILE__, __LINE__, "Ein Element hat nicht genau 3 Knoten\n");
Modified: trunk/src/tools.cpp
===================================================================
--- trunk/src/tools.cpp 2006-03-31 05:43:15 UTC (rev 41)
+++ trunk/src/tools.cpp 2006-04-05 06:25:27 UTC (rev 42)
@@ -121,15 +121,17 @@
void write_fortschritt(char *format, ...)
{
struct timeb Now;
- ftime (&Now);
-
+ ftime (&Now);
+
long Secs = Now.time;
- long Mins = Secs / 60; Secs = Secs - Mins * 60;
- long Hours = Mins / 60; Mins = Mins - Hours * 60;
- long Days = Hours / 24; Hours = Hours - Days * 24;
+ long Mins = Secs / 60;
+ Secs = Secs - Mins * 60;
+ long Hours = Mins / 60;
+ Mins = Mins - Hours * 60;
+ long Days = Hours / 24;
+ Hours = Hours - Days * 24 - Now.timezone / 60;
+ if (Now.dstflag == 1) Hours = Hours + 1;
Hours = Hours % 24;
- if (Now.dstflag == 1) Hours = Hours + 1;
-
va_list argptr;
va_start(argptr, format);
fprintf(fhlog, "%02ld:%02ld:%02ld: ", Hours, Mins, Secs);
@@ -685,7 +687,7 @@
}
write_fortschritt("%d Begrenzungspunkte erzeugt\n", XyList->size());
- if (DebugLevel >= 6)
+ if (DebugLevel >= 8)
{
write_fortschritt("Polygon:\n");
for (TXYList::iterator j = XyList->begin(); j != XyList->end(); j++)
@@ -699,56 +701,164 @@
}
//---------------------------------------------------------------------------
-void CheckForDuplicates(TNodeList *NodeList, int DebugLevel)
+void CheckForDuplicates(TNodeList *NodeList, TElementList *ElementList, int DebugLevel)
{
write_fortschritt ("->Doppelte Knoten werden gesucht\n");
write_fortschritt ("%d Knoten vorhanden\n", NodeList->size());
- NodeList->SortByX();
+ int KnotenGeloescht = 0;
+ int ElementeGeloescht = 0;
- int AnzDeleted = 0;
- TNode* FirstNode = 0;
- TNode* NextNode = 0;
- for (TNodeList::iterator i = NodeList->begin(); i != NodeList->end(); i++)
+ if (ElementList && ElementList->size() > 0)
{
- if (FirstNode == 0)
+ bool NetChanged = false;
+ do
{
- FirstNode = *i;
- continue;
- }
- else if (NextNode == 0)
+ NodeList->SortByXY();
+
+ NetChanged = false;
+
+ for (TElementList::iterator i = ElementList->begin(); i != ElementList->end(); i++)
+ {
+ TElement *Element = *i;
+
+ TNode *Node1 = Element->Node1;
+ if (Node1->Nr != 0)
+ {
+ TNode *Node2 = NodeList->FindByXY(Node1->X, Node1->Y, 0.01);
+
+ if (Node2->Nr != 0)
+ {
+ if (Node1->Nr != Node2->Nr)
+ {
+ if (DebugLevel >= 3)
+ {
+ write_fortschritt("Lösche Knoten %d (%.2f, %.2f)\nEr ist ident mit Knoten %d (%.2f, %.2f)\n", Node2->Nr, Node2->X, Node2->Y, Node1->Nr, Node1->X, Node1->Y);
+ }
+
+ for (TElementList::iterator k = ElementList->begin(); k != ElementList->end(); k++)
+ {
+ TElement *Element2 = *k;
+
+ if (Element2->Node1 == Node2) Element2->Node1 = Node1;
+ if (Element2->Node2 == Node2) Element2->Node2 = Node1;
+ if (Element2->Node3 == Node2) Element2->Node3 = Node1;
+ }
+ Node2->Nr = 0;
+ }
+ }
+ }
+
+ Node1 = Element->Node2;
+ if (Node1->Nr != 0)
+ {
+ TNode *Node2 = NodeList->FindByXY(Node1->X, Node1->Y, 0.01);
+
+ if (Node2->Nr != 0)
+ {
+ if (Node1->Nr != Node2->Nr)
+ {
+ if (DebugLevel >= 3)
+ {
+ write_fortschritt("Lösche Knoten %d (%.2f, %.2f)\nEr ist ident mit Knoten %d (%.2f, %.2f)\n", Node2->Nr, Node2->X, Node2->Y, Node1->Nr, Node1->X, Node1->Y);
+ }
+ for (TElementList::iterator k = ElementList->begin(); k != ElementList->end(); k++)
+ {
+ TElement *Element2 = *k;
+
+ if (Element2->Node1 == Node2) Element2->Node1 = Node1;
+ if (Element2->Node2 == Node2) Element2->Node2 = Node1;
+ if (Element2->Node3 == Node2) Element2->Node3 = Node1;
+ }
+ Node2->Nr = 0;
+ }
+ }
+ }
+
+ Node1 = Element->Node3;
+ if (Node1->Nr != 0)
+ {
+ TNode *Node2 = NodeList->FindByXY(Node1->X, Node1->Y, 0.01);
+
+ if (Node2->Nr != 0)
+ {
+ if (Node1->Nr != Node2->Nr)
+ {
+ if (DebugLevel >= 3)
+ {
+ write_fortschritt("Lösche Knoten %d (%.2f, %.2f)\nEr ist ident mit Knoten %d (%.2f, %.2f)\n", Node2->Nr, Node2->X, Node2->Y, Node1->Nr, Node1->X, Node1->Y);
+ }
+ for (TElementList::iterator k = ElementList->begin(); k != ElementList->end(); k++)
+ {
+ TElement *Element2 = *k;
+
+ if (Element2->Node1 == Node2) Element2->Node1 = Node1;
+ if (Element2->Node2 == Node2) Element2->Node2 = Node1;
+ if (Element2->Node3 == Node2) Element2->Node3 = Node1;
+ }
+ Node2->Nr = 0;
+ }
+ }
+ }
+ }
+
+ for (TNodeList::iterator i = NodeList->begin(); i != NodeList->end(); i++)
+ {
+ TNode *Node = *i;
+
+ if (Node->Nr == 0)
+ {
+ NodeList->erase(i);
+ KnotenGeloescht++;
+ NetChanged = true;
+ }
+ }
+ } while (NetChanged);
+
+ NetChanged = false;
+ do
{
- NextNode = *i;
- }
- else
- {
- FirstNode = NextNode;
- NextNode = *i;
- }
+ NetChanged = false;
- double FX = FirstNode->X;
- double FY = FirstNode->Y;
+ for (TElementList::iterator i = ElementList->begin(); i != ElementList->end(); i++)
+ {
+ TElement *Element = *i;
- double NX = NextNode->X;
- double NY = NextNode->Y;
+ TNode *Node1 = Element->Node1;
+ TNode *Node2 = Element->Node2;
+ TNode *Node3 = Element->Node3;
- double Dx = NX - FX;
- double Dy = NY - FY;
+ if (Node1 == Node2 || Node1 == Node3 || Node2 == Node3)
+ {
+ Element->Typ = NO_ELEMENT;
+ ElementeGeloescht++;
+ NetChanged = true;
+ i = ElementList->begin();
+ break;
+ }
+ }
+ } while (NetChanged);
+ }
+ else
+ {
+ NodeList->SortByXY();
- if (Dx < 0.01 && Dx > -0.01 && Dy < 0.01 && Dy > -0.01)
+ int KnotenGeloescht = 0;
+ for (TNodeList::iterator i = NodeList->begin(); i != NodeList->end(); i++)
{
- if (DebugLevel >= 3)
+ TNode *Node1 = *i;
+ TNode *Node2 = NodeList->FindByXY(Node1->X, Node1->Y, 0.01);
+
+ if (Node1->Nr != Node2->Nr)
{
- write_fortschritt("Lösche Knoten %d (%.2f, %.2f)\Er ist ident mit Knoten %d (%.2f, %.2f)\n", FirstNode->Nr, FirstNode->X, FirstNode->Y, NextNode->Nr, NextNode->X, NextNode->Y);
+ NodeList->erase(i);
+ KnotenGeloescht++;
}
- NodeList->erase(i);
- NextNode = 0;
- AnzDeleted++;
}
}
- write_fortschritt ("%d Knoten gelöscht, %d Knoten vorhanden\n", AnzDeleted, NodeList->size());
+ write_fortschritt ("%d Knoten gelöscht, %d Elemente gelöscht\n", KnotenGeloescht, ElementeGeloescht);
write_fortschritt ("Doppelte Knoten wurden gesucht<-\n");
}
@@ -1247,7 +1357,7 @@
{
write_error(3207, "Profil-Punktabstand (%.3f %.3f) - (%.3f %.3f) ist zu klein\n", P0x, P0y, P1x, P1y);
}
- else if (fabs(SDx) < 0.00000001 && fabs(SDy) < 0.00000001)
+ else if (fabs(SDx) < 0.001 && fabs(SDy) < 0.001)
{
write_error(3208, "GewaesserAchse-Punktabstand (%.3f %.3f) - (%.3f %.3f) ist zu klein\n", S0x, S0y, S1x, S1y);
}
@@ -1273,13 +1383,12 @@
LambdaS = (P0y - S0y) / SDy;
LambdaP = ((S0x + LambdaS * SDx) - P0x) / PDx;
}
- else if (fabs((SDy / PDy) - (SDx / PDx)) < 0.00000001)
+ else if (fabs((SDy / PDy) - (SDx / PDx)) < 0.0001)
{
// Spur-Segment und PaPe->Abschnitt sind parallel
// fabs((SDy / PDy) - (SDx / PDx)) < 0.00001 entspricht
// SDy / PDy = SDx / PDx entspricht
// SDy / SDx = PDy / PDx (P-Steigung gleich S-Steigung) entspricht
- // SDy / SDx = PDy / PDx entspricht
// SDy / PDy = SDx / PDx entspricht
// SDy / PDy * PDx = SDx entspricht
// 0 = SDx - SDy / PDy * PDx (siehe unten !!!!)
@@ -1348,6 +1457,7 @@
if (Found)
{
*meter = S0->Meter + LambdaS * (S1->Meter - S0->Meter);
+
return (true);
}
}
@@ -1470,7 +1580,7 @@
if (Edge->Node1->Wsp - Edge->Node1->Z < -Eps)
{
- dump_error(__FILE__, __LINE__, "Der eigentlich nasse erste Knoten (Nr %d) einer Kanter (%d - %d) ist trocken", Edge->Node1->Nr, Edge->Node1->Nr, Edge->Node2->Nr);
+ dump_error(__FILE__, __LINE__, "Der eigentlich nasse erste Knoten (Nr %d) einer Kante (%d - %d) ist trocken", Edge->Node1->Nr, Edge->Node1->Nr, Edge->Node2->Nr);
}
return (true);
}
@@ -1480,7 +1590,7 @@
if (Edge->Node2->Wsp - Edge->Node2->Z < -Eps)
{
- dump_error(__FILE__, __LINE__, "Der eigentlich nasse zweite Knoten (Nr %d) einer Kanter (%d - %d) ist trocken", Edge->Node2->Nr, Edge->Node1->Nr, Edge->Node2->Nr);
+ dump_error(__FILE__, __LINE__, "Der eigentlich nasse zweite Knoten (Nr %d) einer Kante (%d - %d) ist trocken", Edge->Node2->Nr, Edge->Node1->Nr, Edge->Node2->Nr);
}
return (true);
@@ -1584,7 +1694,8 @@
{
TNode *Node = *n++;
TNode *SaveNode = *s++;
- Node->Z = SaveNode->Z + DeltaTopo;
+ if (SaveNode->Z > -9999 && SaveNode->Z < 9999) Node->Z = SaveNode->Z + DeltaTopo;
+ else Node->Z = SaveNode->Z;
if (SaveNode->Wsp > Node->Z + Eps)
{
Node->Wsp = SaveNode->Wsp;
@@ -1812,40 +1923,47 @@
if (Wsp1 - Z1 <= 0.0 && Wsp2 - Z2 > 0.0 ||
Wsp1 - Z1 > 0.0 && Wsp2 - Z2 <= 0.0)
{
- double Dx = Edge->Node1->X - Edge->Node2->X;
- double Dy = Edge->Node1->Y - Edge->Node2->Y;
- double D1 = 0.0;
- double D2 = 0.0;
+ double Dx = Edge->Node1->X - Edge->Node2->X;
+ double Dy = Edge->Node1->Y - Edge->Node2->Y;
+ double D1 = 0.0;
+ double D2 = 0.0;
- if (Wsp1 - Z1 <= 0.0 && Wsp2 - Z2 > 0.0)
- {
- D1 = Z1 - Wsp1;
- D2 = Wsp2 - Z2;
- }
- else
- {
- D1 = Wsp1 - Z1;
- D2 = Z2 - Wsp2;
- }
+ if (Wsp1 - Z1 <= 0.0 && Wsp2 - Z2 > 0.0)
+ {
+ D1 = Z1 - Wsp1;
+ D2 = Wsp2 - Z2;
+ }
+ else
+ {
+ D1 = Wsp1 - Z1;
+ D2 = Z2 - Wsp2;
+ }
- if (D1 < 0.0 || D2 < 0.0)
- {
- dump_error(__FILE__, __LINE__, "Zwei Knoten sind trocken, aber einer sollte nass sein: Kante %d - %d Differenzen %lf %lf\n", Edge->Node1->Nr, Edge->Node2->Nr, D1, D2);
- }
+ if (D1 < 0.0 || D2 < 0.0)
+ {
+ dump_error(__FILE__, __LINE__, "Zwei Knoten sind trocken, aber einer sollte nass sein: Kante %d - %d Differenzen %lf %lf\n", Edge->Node1->Nr, Edge->Node2->Nr, D1, D2);
+ }
- double Faktor;
+ double Faktor = 0.0;
- if (fabs(D2) < 0.0001) Faktor = 0;
- else Faktor = 1 / (1 + D1/D2);
+ if (fabs(D2) >= 0.00001) Faktor = 1 / (1 + D1/D2);
- double X = Edge->Node2->X + Dx * Faktor;
- double Y = Edge->Node2->Y + Dy * Faktor;
+ if (Z1 < -9999 || Z1 > 9999)
+ {
+ Faktor = 0.99;
+ }
+ else if (Z2 < -9999 || Z2 > 9999)
+ {
+ Faktor = 0.01;
+ }
+ double X = Edge->Node2->X + Dx * Faktor;
+ double Y = Edge->Node2->Y + Dy * Faktor;
- Edge->X = X;
- Edge->Y = Y;
+ Edge->X = X;
+ Edge->Y = Y;
- FoundWetDry++;
- }
+ FoundWetDry++;
+ }
}
// Jetzt sind alle Nass/Trockenübergänge bestimmt
Modified: trunk/src/tools.h
===================================================================
--- trunk/src/tools.h 2006-03-31 05:43:15 UTC (rev 41)
+++ trunk/src/tools.h 2006-04-05 06:25:27 UTC (rev 42)
@@ -67,7 +67,7 @@
TProfilMap BuildGewaesserListen(TProfilList *ProfilList, int DebugLevel);
void BuildPolygon(TProfilList *ProfilList, TXYList *XyList, int DebugLevel);
void EqualizeProfil(TProfil *ProfilOne, TProfil *ProfilTwo);
-void CheckForDuplicates(TNodeList *NodeList, int DebugLevel);
+void CheckForDuplicates(TNodeList *NodeList, TElementList *ElementList, int DebugLevel);
void BuildEdgeList(TEdgeList* EdgeList, TElementList* ElementList, int DebugLevel);
void BuildProfilNodeList(TProfilList *ProfilList, TNodeList *NodeList, TGewaesserAchseList *GewaesserAchseList, TProfilList *SperrenList, TNodeList *ProfilNodeList, double AvgDistance, bool Sperre, int DebugLevel);
void TransferWsp(TNodeList *ProfilNodeList, TNodeList *NodeList, TProfilList* SperrenList, double AvgDistance, int DebugLevel);
Modified: trunk/src/wsplgen.cpp
===================================================================
--- trunk/src/wsplgen.cpp 2006-03-31 05:43:15 UTC (rev 41)
+++ trunk/src/wsplgen.cpp 2006-04-05 06:25:27 UTC (rev 42)
@@ -170,6 +170,7 @@
write_fortschritt("->Ermitteln der maximalen DGM-Knotenanzahl\n");
// Eine rein empirische Formel
int MaxNodesPerSlice = Speed * 10;
+ // MaxNodesPerSlice = 20000;
write_fortschritt("Es können nur ca. %d DGM-Punkte eingelesen werden\n", MaxNodesPerSlice);
write_fortschritt("Ermitteln der maximalen DGM-Knotenanzahl beendet<-\n");
@@ -273,10 +274,14 @@
// Das DGM sollte einigermassen homogen sein
// Jetzt die gesperrten Elemente entfernen
- ElementList.EraseElements(&SperrenList, Parameter.DebugLevel);
+ ElementList.ChangeElements(&NodeList, &SperrenList, &BruchList, Parameter.DebugLevel);
- if (Parameter.DebugLevel >= 5) SaveElements("debug_output\\09_" + Gewaesser + "_Elements_" + VC + NC + ".shp", &ElementList, true);
+ CheckForDuplicates(&NodeList, &ElementList, Parameter.DebugLevel);
+ if (Parameter.DebugLevel >= 7) SaveNet("debug_output\\09_" + Gewaesser + "_Net_" + VC + NC + ".2dm", &NodeList, &ElementList, true);
+ if (Parameter.DebugLevel >= 5) SaveNodes("debug_output\\10_" + Gewaesser + "_Nodes_" + VC + NC + ".shp", &NodeList, true);
+ if (Parameter.DebugLevel >= 5) SaveElements("debug_output\\11_" + Gewaesser + "_Elements_" + VC + NC + ".shp", &ElementList, true);
+
// Hier werden die Kanten drin verwaltet
// Die Kanten werden im Moment noch aus den Elementen generiert
// Dieser Umweg ist eingendlich nicht notwendig
@@ -292,7 +297,7 @@
// Einen neuen Knoten Kanten Index aufbauen
EdgeList->BuildEdgeIndex();
- if (Parameter.DebugLevel >= 4) SaveEdges("debug_output\\10_" + Gewaesser + "_Edges_" + VC + NC + ".shp", EdgeList, Parameter.DebugLevel);
+ if (Parameter.DebugLevel >= 4) SaveEdges("debug_output\\12_" + Gewaesser + "_Edges_" + VC + NC + ".shp", EdgeList, Parameter.DebugLevel);
// Nachdem die durchschnittliche Kantenlänge bekannt ist,
// wird sie für die spätere Verwendung zwischengespeichert
@@ -307,22 +312,23 @@
TempProfilList->InterpoliereProfile(AvgDistance * 10.0);
// Mal wieder Zwischenergebnisse produzieren
- if (Parameter.DebugLevel >= 5) SaveProfile("debug_output\\11_" + Gewaesser + "_Profile_all_" + VC + NC + ".shp", TempProfilList, Parameter.DebugLevel);
+ if (Parameter.DebugLevel >= 5) SaveProfile("debug_output\\13_" + Gewaesser + "_Profile_all_" + VC + NC + ".shp", TempProfilList, Parameter.DebugLevel);
// Jetzt die Stützstellen auffüllen
TempProfilList->FillProfile(AvgDistance / 2.0, -1, Parameter.DebugLevel);
// Mal wieder Zwischenergebnisse produzieren
- if (Parameter.DebugLevel >= 7) SaveProfile("debug_output\\12_" + Gewaesser + "_Profile_fill_" + VC + NC + ".shp", TempProfilList, Parameter.DebugLevel);
+ if (Parameter.DebugLevel >= 7) SaveProfile("debug_output\\14_" + Gewaesser + "_Profile_fill_" + VC + NC + ".shp", TempProfilList, Parameter.DebugLevel);
// Jetzt eine neue Knotenliste aus den Profilen generienen
BuildProfilNodeList(TempProfilList, &NodeList, &GewaesserAchseList, &SperrenList, &ProfilNodeList, AvgDistance * 2.0, Parameter.Sperre, Parameter.DebugLevel);
- if (Parameter.DebugLevel >= 4) SaveNodes("debug_output\\13_" + Gewaesser + "_ProfilNodes_" + VC + NC + ".shp", &ProfilNodeList, true);
+ if (Parameter.DebugLevel >= 4) SaveNodes("debug_output\\15_" + Gewaesser + "_ProfilNodes_" + VC + NC + ".shp", &ProfilNodeList, true);
// Jetzt die Wasserstände übertragen
- TransferWsp(&ProfilNodeList, &NodeList, &SperrenList, AvgDistance, Parameter.DebugLevel);
+ TransferWsp(&ProfilNodeList, &NodeList, &SperrenList, AvgDistance / 2.0, Parameter.DebugLevel);
+/*
if (BruchList.size() > 0)
{
// Mit Stützstellen auffüllen
@@ -331,16 +337,17 @@
// Jetzt den Wasserstand aus der Node_List extrahieren
GetWspFromNodeList(&BruchList, &NodeList, &SperrenList, AvgDistance / 2.0, Parameter.DebugLevel);
- if (Parameter.DebugLevel >= 7) SaveProfile("debug_output\\14_" + Gewaesser + "_Bruch_ohne_Wsp_" + VC + NC + ".shp", &BruchList, Parameter.DebugLevel);
+ if (Parameter.DebugLevel >= 7) SaveProfile("debug_output\\15_" + Gewaesser + "_Bruch_ohne_Wsp_" + VC + NC + ".shp", &BruchList, Parameter.DebugLevel);
// Jetzt eine neue Knotenliste aus den Brüchen generienen
BuildProfilNodeList(&BruchList, &NodeList, &GewaesserAchseList, 0, &BruchNodeList, AvgDistance * 2.0, false, Parameter.DebugLevel);
- if (Parameter.DebugLevel >= 6) SaveNodes("debug_output\\15_" + Gewaesser + "_Bruch_mit_Wsp_" + VC + NC + ".shp", &BruchNodeList, true);
+ if (Parameter.DebugLevel >= 6) SaveNodes("debug_output\\16_" + Gewaesser + "_Bruch_mit_Wsp_" + VC + NC + ".shp", &BruchNodeList, true);
// Jetzt die Wasserstände übertragen
TransferWsp(&BruchNodeList, &NodeList, &SperrenList, AvgDistance / 2.0, Parameter.DebugLevel);
}
+*/
ProfilNodeList.Clear();
Modified: trunk/src/xy.cpp
===================================================================
--- trunk/src/xy.cpp 2006-03-31 05:43:15 UTC (rev 41)
+++ trunk/src/xy.cpp 2006-04-05 06:25:27 UTC (rev 42)
@@ -651,12 +651,6 @@
}
//---------------------------------------------------------------------
-void TNodeList::SortByX(void)
-{
- std::sort(this->begin(), this->end(), TNodeSortByX());
-}
-
-//---------------------------------------------------------------------
void TNodeList::SortByXY(void)
{
std::sort(this->begin(), this->end(), TNodeSortByXY());
@@ -944,7 +938,7 @@
double WspSumme = 0.0;
if (TLNode != 0)
{
- TLD = sqrt(TLD);
+ TLD = TLD * TLD;
ZSumme = ZSumme + 1 / TLD;
ZAnzahl++;
@@ -956,7 +950,7 @@
}
if (TRNode != 0)
{
- TRD = sqrt(TRD);
+ TRD = TRD * TRD;
ZSumme = ZSumme + 1 / TRD;
ZAnzahl++;
@@ -968,7 +962,7 @@
}
if (BLNode != 0)
{
- BLD = sqrt(BLD);
+ BLD = BLD * BLD;
ZSumme = ZSumme + 1 / BLD;
ZAnzahl++;
@@ -980,7 +974,7 @@
}
if (BRNode != 0)
{
- BRD = sqrt(BRD);
+ BRD = BRD * BRD;
ZSumme = ZSumme + 1 / BRD;
ZAnzahl++;
@@ -1107,6 +1101,34 @@
}
//---------------------------------------------------------------------
+double TNodeList::GetMaxZ(bool Debug)
+{
+ write_fortschritt("->Maximale Geländehöhe wird ermittelt\n");
+
+ double MaxZ = 0.0;
+ int Count = 0;
+ for (iterator i = begin(); i != end(); i++)
+ {
+ if (Debug && Count % 10000 == 0) write_fortschritt("Knoten %d von %d wird untersucht.\n", Count, size());
+ else if (Count > 0 && Count % 100000 == 0) write_fortschritt("Knoten %d von %d wird untersucht.\n", Count, size());
+
+ TNode* Node = *i;
+
+ double Z = Node->Z;
+
+ if (Count == 0 || Z > MaxZ) MaxZ = Z;
+
+ Count++;
+ }
+ write_fortschritt("Knoten %d von %d wird untersucht.\n", Count, size());
+
+ write_fortschritt("Maximale Geländehöhe: %.3f.\n", MaxZ);
+
+ write_fortschritt("Maximale Geländehöhe ermittelt<-\n");
+
+ return (MaxZ);
+}
+//---------------------------------------------------------------------
// TElementList
//---------------------------------------------------------------------
@@ -1128,101 +1150,268 @@
}
//---------------------------------------------------------------------------
-void TElementList::EraseElements(TProfilList *SperrenList, int DebugLevel)
+void TElementList::ChangeElements(TNodeList *NodeList, TProfilList *SperrenList, TProfilList *BruchList, int DebugLevel)
{
- write_fortschritt("->Gesperrte Elemente werden gelöscht\n");
+ write_fortschritt("->Elemente werden an Sperren und Brüche angepasst\n");
+ write_fortschritt("->Elemente werden an Sperren\n");
+
+ int ChangeCount = 0;
+
+ double SperrZ = 9999.9;
+ double BruchZ = -9999.9;
+
int Count = 0;
- int DelCount = 0;
for (TElementList::iterator i = begin(); i != end(); i++)
{
if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 1000 == 0) || (Count > 0 && Count % 10000 == 0))
{
- write_fortschritt("%d von %d Elemente auf Sperren getestet, %d Elemente gelöscht\n", Count, size(), DelCount);
+ write_fortschritt("%d von %d Elemente auf Sperren getestet, %d Elemente angepasst\n", Count, size(), ChangeCount);
}
TElement* Element = *i;
+ if (Element->Typ == QUAD)
+ {
+ dump_error(__FILE__, __LINE__, "Viereckselemente werden im Moment noch nicht unterstützt");
+ }
+
TNode* Node1 = Element->Node1;
TNode* Node2 = Element->Node2;
TNode* Node3 = Element->Node3;
+ TElement* NewElement = 0;
+
+ double Lambda = 0.0;
+ double Meter = 0.0;
double X = 0.0;
double Y = 0.0;
- double Lambda = 0.0;
- double Meter = 0.0;
- bool Schnitt = false;
- Schnitt = CalcProfilSchnitt(Node1->X, Node1->Y, Node2->X, Node2->Y, SperrenList, &X, &Y, &Lambda, &Meter);
- if (Schnitt)
+ if (CalcProfilSchnitt(Node1->X, Node1->Y, Node2->X, Node2->Y, SperrenList, &X, &Y, &Lambda, &Meter))
{
- // Das Element wird invalidiert
- if (DebugLevel >= 6) write_fortschritt("Element %d : %d - %d - %d wird gelöscht\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
- Element->Typ = NO_ELEMENT;
- DelCount++;
- Count++;
- continue;
+ if (fabs(Node1->X - X) < 0.1 && fabs(Node1->Y - Y) < 0.1)
+ {
+ Node1->Z = SperrZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird erhöht (Lambda = %.5f)\n", Node1->Nr, Lambda);
+ }
+ else if (fabs(Node2->X - X) < 0.1 && fabs(Node2->Y - Y) < 0.1)
+ {
+ Node2->Z = SperrZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird erhöht (Lambda = %.5f)\n", Node2->Nr, Lambda);
+ }
+ else
+ {
+ TNode* Node = new TNode(NodeList->size()+1, X, Y, SperrZ);
+ NodeList->push_back(Node);
+
+ NewElement = new TElement(Node1, Node, Node3);
+ push_back(NewElement);
+
+ NewElement = new TElement(Node2, Node3, Node);
+ push_back(NewElement);
+
+ if (DebugLevel >= 8) write_fortschritt("Element %d : %d - %d - %d wird geändert\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+
+ Element->Typ = NO_ELEMENT;
+ ChangeCount++;
+ continue;
+ }
}
- Schnitt = CalcProfilSchnitt(Node2->X, Node2->Y, Node3->X, Node3->Y, SperrenList, &X, &Y, &Lambda, &Meter);
- if (Schnitt)
+ if (CalcProfilSchnitt(Node2->X, Node2->Y, Node3->X, Node3->Y, SperrenList, &X, &Y, &Lambda, &Meter))
{
- // Das Element wird invalidiert
- if (DebugLevel >= 6) write_fortschritt("Element %d : %d - %d - %d wird gelöscht\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
- Element->Typ = NO_ELEMENT;
- DelCount++;
- Count++;
- continue;
+ if (fabs(Node2->X - X) < 0.1 && fabs(Node2->Y - Y) < 0.1)
+ {
+ Node2->Z = SperrZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird erhöht (Lambda = %.5f)\n", Node2->Nr, Lambda);
+ }
+ else if (fabs(Node3->X - X) < 0.1 && fabs(Node3->Y - Y) < 0.1)
+ {
+ Node3->Z = SperrZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird erhöht (Lambda = %.5f)\n", Node3->Nr, Lambda);
+ }
+ else
+ {
+ TNode* Node = new TNode(NodeList->size()+1, X, Y, SperrZ);
+ NodeList->push_back(Node);
+
+ NewElement = new TElement(Node2, Node, Node1);
+ push_back(NewElement);
+
+ NewElement = new TElement(Node3, Node1, Node);
+ push_back(NewElement);
+
+ if (DebugLevel >= 8) write_fortschritt("Element %d : %d - %d - %d wird geändert\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+
+ Element->Typ = NO_ELEMENT;
+ ChangeCount++;
+ continue;
+ }
}
- if (Element->Typ == TRI)
+ if (CalcProfilSchnitt(Node3->X, Node3->Y, Node1->X, Node1->Y, SperrenList, &X, &Y, &Lambda, &Meter))
{
- Schnitt = CalcProfilSchnitt(Node3->X, Node3->Y, Node1->X, Node1->Y, SperrenList, &X, &Y, &Lambda, &Meter);
- if (Schnitt)
+ if (fabs(Node3->X - X) < 0.1 && fabs(Node3->Y - Y) < 0.1)
{
- // Das Element wird invalidiert
- if (DebugLevel >= 6) write_fortschritt("Element %d : %d - %d - %d wird gelöscht\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+ Node3->Z = SperrZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird erhöht (Lambda = %.5f)\n", Node3->Nr, Lambda);
+ }
+ else if (fabs(Node1->X - X) < 0.1 && fabs(Node1->Y - Y) < 0.1)
+ {
+ Node1->Z = SperrZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird erhöht (Lambda = %.5f)\n", Node1->Nr, Lambda);
+ }
+ else
+ {
+ TNode* Node = new TNode(NodeList->size()+1, X, Y, SperrZ);
+ NodeList->push_back(Node);
+
+ NewElement = new TElement(Node3, Node, Node2);
+ push_back(NewElement);
+
+ NewElement = new TElement(Node1, Node2, Node);
+ push_back(NewElement);
+
+ if (DebugLevel >= 8) write_fortschritt("Element %d : %d - %d - %d wird geändert\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+
Element->Typ = NO_ELEMENT;
- DelCount++;
- Count++;
+ ChangeCount++;
continue;
}
}
- else if (Element->Typ == QUAD)
+
+ Count++;
+ }
+ write_fortschritt("%d von %d Elemente auf Sperren getestet, %d Elemente geändert\n", Count, size(), ChangeCount);
+ write_fortschritt("Elemente wurden an Sperren angepasst<-\n");
+
+ write_fortschritt("->Elemente werden an Brüche angepasst\n");
+
+ Count = 0;
+ for (TElementList::iterator i = begin(); i != end(); i++)
+ {
+ if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 1000 == 0) || (Count > 0 && Count % 10000 == 0))
{
- TNode* Node4 = Element->Node4;
+ write_fortschritt("%d von %d Elemente auf Brüche getestet, %d Elemente geändert\n", Count, size(), ChangeCount);
+ }
- Schnitt = CalcProfilSchnitt(Node3->X, Node3->Y, Node4->X, Node4->Y, SperrenList, &X, &Y, &Lambda, &Meter);
- if (Schnitt)
+ TElement* Element = *i;
+
+ if (Element->Typ == QUAD)
+ {
+ dump_error(__FILE__, __LINE__, "Viereckselemente werden im Moment noch nicht unterstützt");
+ }
+
+ TNode* Node1 = Element->Node1;
+ TNode* Node2 = Element->Node2;
+ TNode* Node3 = Element->Node3;
+
+ TElement* NewElement = 0;
+
+ double Lambda = 0.0;
+ double Meter = 0.0;
+ double X = 0.0;
+ double Y = 0.0;
+
+ if (CalcProfilSchnitt(Node1->X, Node1->Y, Node2->X, Node2->Y, BruchList, &X, &Y, &Lambda, &Meter))
+ {
+ if (fabs(Node1->X - X) < 0.1 && fabs(Node1->Y - Y) < 0.1)
{
- // Das Element wird invalidiert
+ Node1->Z = BruchZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird abgesenkt (Lambda = %.5f)\n", Node1->Nr, Lambda);
+ }
+ else if (fabs(Node2->X - X) < 0.1 && fabs(Node2->Y - Y) < 0.1)
+ {
+ Node2->Z = BruchZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird abgesenkt (Lambda = %.5f)\n", Node2->Nr, Lambda);
+ }
+ else
+ {
+ TNode* Node = new TNode(NodeList->size()+1, X, Y, BruchZ);
+ NodeList->push_back(Node);
+
+ NewElement = new TElement(Node1, Node, Node3);
+ push_back(NewElement);
+
+ NewElement = new TElement(Node2, Node3, Node);
+ push_back(NewElement);
+
+ if (DebugLevel >= 8) write_fortschritt("Element %d : %d - %d - %d wird geändert\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+
Element->Typ = NO_ELEMENT;
- DelCount++;
- Count++;
+ ChangeCount++;
continue;
}
+ }
- Schnitt = CalcProfilSchnitt(Node4->X, Node4->Y, Node1->X, Node1->Y, SperrenList, &X, &Y, &Lambda, &Meter);
- if (Schnitt)
+ if (CalcProfilSchnitt(Node2->X, Node2->Y, Node3->X, Node3->Y, BruchList, &X, &Y, &Lambda, &Meter))
+ {
+ if (fabs(Node2->X - X) < 0.1 && fabs(Node2->Y - Y) < 0.1)
{
- // Das Element wird invalidiert
- if (DebugLevel >= 6) write_fortschritt("Element %d : %d - %d - %d wird gelöscht\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+ Node2->Z = BruchZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird abgesenkt (Lambda = %.5f)\n", Node2->Nr, Lambda);
+ }
+ else if (fabs(Node3->X - X) < 0.1 && fabs(Node3->Y - Y) < 0.1)
+ {
+ Node3->Z = BruchZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird erhöht (Lambda = %.5f)\n", Node3->Nr, Lambda);
+ }
+ else
+ {
+ TNode* Node = new TNode(NodeList->size()+1, X, Y, BruchZ);
+ NodeList->push_back(Node);
+
+ NewElement = new TElement(Node2, Node, Node1);
+ push_back(NewElement);
+
+ NewElement = new TElement(Node3, Node1, Node);
+ push_back(NewElement);
+
+ if (DebugLevel >= 8) write_fortschritt("Element %d : %d - %d - %d wird geändert\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+
Element->Typ = NO_ELEMENT;
- DelCount++;
- Count++;
+ ChangeCount++;
continue;
}
}
- else
+
+ if (CalcProfilSchnitt(Node3->X, Node3->Y, Node1->X, Node1->Y, BruchList, &X, &Y, &Lambda, &Meter))
{
- dump_error(__FILE__, __LINE__, "Ungültiger ElementTyp\nElement %d : %d - %d - %d sollte getestet werden\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+ if (fabs(Node3->X - X) < 0.1 && fabs(Node3->Y - Y) < 0.1)
+ {
+ Node3->Z = BruchZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird abgesenkt (Lambda = %.5f)\n", Node3->Nr, Lambda);
+ }
+ else if (fabs(Node1->X - X) < 0.1 && fabs(Node1->Y - Y) < 0.1)
+ {
+ Node1->Z = BruchZ;
+ if (DebugLevel >= 8) write_fortschritt("Knoten %d wird abgesenkt (Lambda = %.5f)\n", Node1->Nr, Lambda);
+ }
+ else
+ {
+ TNode* Node = new TNode(NodeList->size()+1, X, Y, BruchZ);
+ NodeList->push_back(Node);
+
+ NewElement = new TElement(Node3, Node, Node2);
+ push_back(NewElement);
+
+ NewElement = new TElement(Node1, Node2, Node);
+ push_back(NewElement);
+
+ if (DebugLevel >= 8) write_fortschritt("Element %d : %d - %d - %d wird geändert\n", Count, Node1->Nr, Node2->Nr, Node3->Nr);
+
+ Element->Typ = NO_ELEMENT;
+ ChangeCount++;
+ continue;
+ }
}
Count++;
}
- write_fortschritt("%d von %d Elemente auf Sperren getestet, %d Elemente gelöscht\n", Count, size(), DelCount);
+ write_fortschritt("%d von %d Elemente auf Brüche getestet, %d Elemente geändert\n", Count, size(), ChangeCount);
+ write_fortschritt("Elemente wurden an Brüche angepasst<-\n");
- write_fortschritt("Gesperrte Elemente wurden gelöscht<-\n");
+ write_fortschritt("Elemente wurden an Sperren und Brüche angepasst<-\n");
}
//---------------------------------------------------------------------
@@ -2195,6 +2384,7 @@
if (P == Start) dump_error(__FILE__, __LINE__, "Bin nicht von der Stelle gekommen\n");
+/*
if ((*T)->Station - SollStation < SollStation - (*P)->Station)
{
(*this)[Start] = T;
@@ -2205,6 +2395,9 @@
(*this)[Start] = P;
Start = P;
}
+*/
+ (*this)[Start] = T;
+ Start = P;
}
}
Modified: trunk/src/xy.h
===================================================================
--- trunk/src/xy.h 2006-03-31 05:43:15 UTC (rev 41)
+++ trunk/src/xy.h 2006-04-05 06:25:27 UTC (rev 42)
@@ -448,7 +448,6 @@
void Clear(void);
TNodeList* Copy(void);
- void SortByX(void);
void SortByXY(void);
void SortByNr(void);
TNode* FindByXY(double X, double Y, double Eps = 0.01);
@@ -458,6 +457,7 @@
void ClearEdgeIndex(void);
double GetMaxDepth(bool Debug);
double GetMaxWsp(bool Debug);
+ double GetMaxZ(bool Debug);
};
//----------------------------------------------------------------------------
@@ -466,7 +466,7 @@
public:
~TElementList(void);
void Clear(void);
- void EraseElements(TProfilList *SperrenList, int DebugLevel);
+ void ChangeElements(TNodeList* NodeList, TProfilList *SperrenList, TProfilList *BruchList, int DebugLevel);
};
More information about the Wsplgen-commits
mailing list