[Wsplgen-commits] r90 - trunk/src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sun Jul 15 20:01:24 CEST 2007
Author: mrchip
Date: 2007-07-15 20:01:23 +0200 (Sun, 15 Jul 2007)
New Revision: 90
Modified:
trunk/src/file.cpp
trunk/src/file.h
trunk/src/parameter.cpp
trunk/src/parameter.h
trunk/src/shape.cpp
trunk/src/shape.h
trunk/src/test_file.cpp
trunk/src/test_qhull.cpp
trunk/src/test_tools.cpp
trunk/src/tools.cpp
trunk/src/tools.h
trunk/src/wsplgen.cpp
trunk/src/wsplgen.h
trunk/src/xy.cpp
trunk/src/xy.h
Log:
Dies ist nur eine Zwischensicherung, die noch nicht ausreichend getestet wurde. Die wichtigsten Ver?\195?\164nderungen sind, TIN mit H?\195?\188lle einlesen und Speichern der Polygone mit deutlich verbessertem Speichermanagement.
Modified: trunk/src/file.cpp
===================================================================
--- trunk/src/file.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/file.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -216,44 +216,119 @@
}
//---------------------------------------------------------------------------
-bool LoadDGMTIN(std::string FileName, TNodeList *NodeList, TElementList *ElementList, TXYList *XyList, int DebugLevel)
+bool LoadDGMTIN(std::string FileName, TNodeList *NodeList, TElementList *ElementList, TXYList *Begrenzung, int DebugLevel)
{
write_fortschritt("->Laden des DGM in Datei '%s' als TIN gestartet\n", FileName.c_str());
- std::string XyFileName = GetFilePath(FileName) + "tnxy.adf";
- std::string ZFileName = GetFilePath(FileName) + "tnz.adf";
- std::string OdFileName = GetFilePath(FileName) + "tnod.adf";
+ std::string TnxyFileName = GetFilePath(FileName) + "tnxy.adf";
+ std::string TnzFileName = GetFilePath(FileName) + "tnz.adf";
+ std::string TnodFileName = GetFilePath(FileName) + "tnod.adf";
+ std::string TedgFileName = GetFilePath(FileName) + "tedg.adf";
+ std::string ThulFileName = GetFilePath(FileName) + "thul.adf";
- FILE *fhxy = 0;
- FILE *fhz = 0;
- FILE *fhod = 0;
+ FILE *fhtnxy = 0;
+ FILE *fhtnz = 0;
+ FILE *fhtnod = 0;
+ FILE *fhtedg = 0;
+ FILE *fhthul = 0;
- unsigned int AnzKnoten = 0;
- unsigned int AnzWerte = 0;
-
try
{
- fhxy = fopen(XyFileName.c_str(), "rb");
- fhz = fopen(ZFileName.c_str(), "rb");
+ write_fortschritt("->Laden der Umhüllung gestartet\n");
- if (fhxy == 0)
+ TXYList Huelle;
+
+ fhthul = fopen(ThulFileName.c_str(), "rb");
+
+ if (fhthul == 0)
{
- write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", XyFileName.c_str());
+ write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", ThulFileName.c_str());
}
- if (fhz == 0)
+ fhtnxy = fopen(TnxyFileName.c_str(), "rb");
+
+ if (fhtnxy == 0)
{
- write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", ZFileName.c_str());
+ write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", TnxyFileName.c_str());
}
- double X;
- double Y;
- float Z;
+ int Nr = 0;
+ // Zuerst kommt scheinbar die Umhüllung aller Knoten
+ // Also auch oder besser gesagt genau der Wächterknoten
+ do
+ {
+ fread(&Nr, sizeof(Nr), 1, fhthul);
+ Swap4Bytes(&Nr);
+ } while (Nr > 0);
+
+ // Jetzt die eigentlichen Knoten
+
+ unsigned int AnzHul = 0;
+
+ while (1 == fread(&Nr, sizeof(Nr), 1, fhthul))
+ {
+ Swap4Bytes(&Nr);
+
+ AnzHul++;
+
+ double X = 0.0;
+ double Y = 0.0;
+
+ fseek (fhtnxy, (Nr-1) * (sizeof(X) + sizeof (Y)), SEEK_SET);
+
+ if (1 != fread(&X, sizeof(X), 1, fhtnxy) || 1 != fread(&Y, sizeof(Y), 1, fhtnxy))
+ {
+ write_error(8888, "Konnte keine 2 Werte für den Knoten %d lesen\n", Nr);
+ }
+
+ Swap8Bytes(&X);
+ Swap8Bytes(&Y);
+
+ long XL = (long)(X * 100.0 + 0.5);
+ long YL = (long)(Y * 100.0 + 0.5);
+
+ Huelle.Add(XL, YL);
+
+ if (DebugLevel >= 9 || (DebugLevel >= 1 && AnzHul % 100 == 0) || (AnzHul > 0 && AnzHul % 1000 == 0))
+ {
+ write_fortschritt("%d Stütztellen gelesen\n", AnzHul);
+ }
+ }
+
+ write_fortschritt("%d Stützstellen gelesen\n", AnzHul);
+
+ fclose(fhtnxy);
+ fclose(fhthul);
+
+ write_fortschritt("<-Laden der Umhüllung beendet\n");
+
+ // SavePolygon("Huelle.shp", &Huelle, 8);
+
write_fortschritt("->Laden der Knoten gestartet\n");
- while (1 == fread(&X, sizeof(X), 1, fhxy) && fread(&Y, sizeof(Y), 1, fhxy) && 1 == fread(&Z, sizeof(Z), 1, fhz))
+ fhtnxy = fopen(TnxyFileName.c_str(), "rb");
+ fhtnz = fopen(TnzFileName.c_str(), "rb");
+
+ if (fhtnxy == 0)
{
+ write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", TnxyFileName.c_str());
+ }
+
+ if (fhtnz == 0)
+ {
+ write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", TnzFileName.c_str());
+ }
+
+ int AnzKnoten = 0;
+ int AnzWerte = 0;
+
+ double X = 0.0;
+ double Y = 0.0;
+ float Z = (float)0.0;
+
+ while (1 == fread(&X, sizeof(X), 1, fhtnxy) && fread(&Y, sizeof(Y), 1, fhtnxy) && 1 == fread(&Z, sizeof(Z), 1, fhtnz))
+ {
Swap8Bytes(&X);
Swap8Bytes(&Y);
Swap4Bytes(&Z);
@@ -271,67 +346,136 @@
long YL = (long)(Y * 100.0 + 0.5);
int ZI = (long)(Z * 100.0 + 0.5);
- TInsideTyp InsideTyp = INSIDE;
- if (XyList) InsideTyp = XyList->IsInsideXYList(XL, YL);
- if (InsideTyp == INSIDE || InsideTyp == ON_LINE)
+ TInsideTyp InsideBegrenzung = INSIDE;
+ if (Begrenzung) InsideBegrenzung = Begrenzung->IsInsideXYList(XL, YL);
+ if (InsideBegrenzung == INSIDE || InsideBegrenzung == ON_LINE)
{
- AnzKnoten++;
+ TInsideTyp InsideHuelle = Huelle.IsInsideXYList(XL, YL);
+ if (InsideHuelle != NOT_INSIDE)
+ {
+ AnzKnoten++;
- TNode *Node = new TNode(AnzWerte, XL, YL, ZI);
- NodeList->Add(Node);
+ TNode *Node = new TNode(AnzWerte, XL, YL, ZI);
+ NodeList->Add(Node);
+ }
}
}
}
write_fortschritt("%d Werten gelesen, %d von %d Knoten im Speicher\n", AnzWerte, NodeList->size(), AnzKnoten);
- fclose(fhxy);
- fclose(fhz);
+ fclose(fhtnxy);
+ fclose(fhtnz);
write_fortschritt("<-Laden der Knoten beendet\n");
+ write_fortschritt("->Laden der Elemente gestartet\n");
+ fhtnod = fopen(TnodFileName.c_str(), "rb");
+ fhtedg = fopen(TedgFileName.c_str(), "rb");
- fhod = fopen(OdFileName.c_str(), "rb");
+ if (fhtnod == 0)
+ {
+ write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", TnodFileName.c_str());
+ }
- if (fhod == 0)
+
+ if (fhtedg == 0)
{
- write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", OdFileName.c_str());
+ write_error(2201, "Konnte '%s' nicht zum Lesen öffnen\n", TedgFileName.c_str());
}
- int Nr1;
- int Nr2;
- int Nr3;
- write_fortschritt("->Laden der Elemente gestartet\n");
+ int Nr1 = -1;
+ int Nr2 = -1;
+ int Nr3 = -1;
+ int Ei1 = -1;
+ int Ei2 = -1;
+ int Ei3 = -1;
+
int AnzElements = 0;
- AnzWerte = 0;
- while (1 == fread(&Nr1, sizeof(Nr1), 1, fhod) && fread(&Nr2, sizeof(Nr2), 1, fhod) && 1 == fread(&Nr3, sizeof(Nr3), 1, fhod))
+ while (1 == fread(&Nr1, sizeof(Nr1), 1, fhtnod) && fread(&Nr2, sizeof(Nr2), 1, fhtnod) && 1 == fread(&Nr3, sizeof(Nr3), 1, fhtnod) && 1 == fread(&Ei1, sizeof(Ei1), 1, fhtedg) && fread(&Ei2, sizeof(Ei2), 1, fhtedg) && 1 == fread(&Ei3, sizeof(Ei3), 1, fhtedg))
+// while (1 == fread(&Nr1, sizeof(Nr1), 1, fhtnod) && fread(&Nr2, sizeof(Nr2), 1, fhtnod) && 1 == fread(&Nr3, sizeof(Nr3), 1, fhtnod))
{
Swap4Bytes((byte *)&Nr1);
Swap4Bytes((byte *)&Nr2);
Swap4Bytes((byte *)&Nr3);
+ Swap4Bytes((byte *)&Ei1);
+ Swap4Bytes((byte *)&Ei2);
+ Swap4Bytes((byte *)&Ei3);
- AnzWerte++;
-
- if (DebugLevel >= 9 || (DebugLevel >= 1 && AnzWerte % 10000 == 0) || (AnzWerte > 0 && AnzWerte % 100000 == 0))
+ AnzElements++;
+
+ if (DebugLevel >= 9 || (DebugLevel >= 1 && AnzElements % 10000 == 0) || (AnzElements > 0 && AnzElements % 100000 == 0))
{
- write_fortschritt("%d Werte geladen, %d von %d Elementen im Speicher\n", AnzWerte, ElementList->size(), AnzElements);
+ write_fortschritt("%d von %d Elementen im Speicher\n", ElementList->size(), AnzElements);
}
+ TTinTyp TinTyp = TTREGULAR;
+
+ if (Ei1 < 0)
+ {
+ Ei1 = -Ei1;
+ int Typ = Ei1 & 0x40000000;
+
+ if (Typ == 0x00000000) TinTyp = TTSOFT;
+ else TinTyp = TTHARD;
+ }
+
+ if (Ei2 < 0)
+ {
+ Ei2 = -Ei2;
+ int Typ = Ei2 & 0x40000000;
+
+ if (Typ == 0x00000000) TinTyp = TTSOFT;
+ else TinTyp = TTHARD;
+ }
+
+ if (Ei3 < 0)
+ {
+ Ei3 = -Ei3;
+ int Typ = Ei3 & 0x40000000;
+
+ if (Typ == 0x00000000) TinTyp = TTSOFT;
+ else TinTyp = TTHARD;
+ }
+
TNode *Node1 = NodeList->FindByNr(Nr1);
TNode *Node2 = NodeList->FindByNr(Nr2);
TNode *Node3 = NodeList->FindByNr(Nr3);
if (Node1 && Node2 && Node3)
{
+ long X12 = (Node1->X + Node2->X) / 2;
+ long Y12 = (Node1->Y + Node2->Y) / 2;
+ long X23 = (Node2->X + Node3->X) / 2;
+ long Y23 = (Node2->Y + Node3->Y) / 2;
+ long X31 = (Node3->X + Node1->X) / 2;
+ long Y31 = (Node3->Y + Node1->Y) / 2;
+
+ TInsideTyp WhereIs = Huelle.IsInsideXYList(X12, Y12);
+ if (WhereIs == NOT_INSIDE)
+ {
+ continue;
+ }
+ if (WhereIs != INSIDE) WhereIs = Huelle.IsInsideXYList(X23, Y23);
+ if (WhereIs == NOT_INSIDE)
+ {
+ continue;
+ }
+ if (WhereIs != INSIDE) WhereIs = Huelle.IsInsideXYList(X31, Y31);
+ if (WhereIs == NOT_INSIDE)
+ {
+ continue;
+ }
+
TElement *Element = new TElement(Node1, Node2, Node3);
ElementList->Add(Element);
}
- AnzElements++;
}
- fclose(fhod);
+// fclose(fhtedg);
+ fclose(fhtnod);
write_fortschritt("%d Werte geladen, %d von %d Elementen im Speicher\n", AnzWerte, ElementList->size(), AnzElements);
@@ -339,9 +483,9 @@
}
catch(...)
{
- if (fhxy) fclose(fhxy);
- if (fhz) fclose(fhz);
- if (fhod) fclose(fhod);
+ if (fhtnxy) fclose(fhtnxy);
+ if (fhtnz) fclose(fhtnz);
+ if (fhtnod) fclose(fhtnod);
write_error(2299, "Es hat einen nicht näher bestimmten Eingabefehler gegeben.\nDer Datenträger könnte beschädigt sein\n");
}
@@ -1683,7 +1827,13 @@
TProfil* Profil = new TProfil(Station, Wsp);
+ unsigned int Anz = ProfilList->size();
ProfilList->insert(Profil);
+ if (ProfilList->size() == Anz)
+ {
+ write_warning(8888, "Für den Flusskilometer %.4f wurde der Wasserstand mehrmals angegeben\n", Profil->Station / 10000.0);
+ delete Profil;
+ }
if (DebugLevel >= 9 || (DebugLevel >= 1 && AktZeile % 100 == 0) || (AktZeile > 0 && AktZeile % 1000 == 0))
{
@@ -1883,7 +2033,13 @@
TProfil* Profil = new TProfil(Station, Wsp);
+ unsigned int Anz = ProfilList->size();
ProfilList->insert(Profil);
+ if (ProfilList->size() == Anz)
+ {
+ write_warning(8888, "Für den Flusskilometer %.4f wurde der Wasserstand mehrmals angegeben\n", Profil->Station / 10000.0);
+ delete Profil;
+ }
if (DebugLevel >= 9 || (DebugLevel >= 1 && AktZeile % 100 == 0) || (AktZeile > 0 && AktZeile % 1000 == 0))
{
@@ -2059,7 +2215,13 @@
TProfil* Profil = new TProfil(Station, Wsp);
+ unsigned int Anz = ProfilList->size();
ProfilList->insert(Profil);
+ if (ProfilList->size() == Anz)
+ {
+ write_warning(8888, "Für den Flusskilometer %.4f wurde der Wasserstand mehrmals angegeben\n", Profil->Station / 10000.0);
+ delete Profil;
+ }
Count++;
@@ -2584,13 +2746,8 @@
int AnzPoint = 0;
for (TXYList::iterator i = XyList->begin(); i != XyList->end(); i++)
{
- TXY* Xy = *i;
-
- double X = Xy->X / 100.0;
- double Y = Xy->Y / 100.0;
-
- x[AnzPoint] = X;
- y[AnzPoint] = Y;
+ x[AnzPoint] = (*i)->X / 100.0;
+ y[AnzPoint] = (*i)->Y / 100.0;
z[AnzPoint] = 0.0;
AnzPoint++;
@@ -2602,13 +2759,8 @@
}
TXYList::iterator i = XyList->begin();
- TXY* Xy = *i;
-
- double X = Xy->X / 100.0;
- double Y = Xy->Y / 100.0;
-
- x[AnzPoint] = X;
- y[AnzPoint] = Y;
+ x[AnzPoint] = (*i)->X / 100.0;
+ y[AnzPoint] = (*i)->Y / 100.0;
z[AnzPoint] = 0.0;
AnzPoint++;
@@ -2634,6 +2786,46 @@
}
//---------------------------------------------------------------------------
+void CreatePolygon(SHPObject* psObject, int nParts, int* panPartStart, int* panPartType, int nVertices, double* padfX, double* padfY)
+{
+ psObject->nSHPType = SHPT_POLYGON;
+ psObject->nShapeId = -1;
+
+ psObject->nParts = nParts;
+
+ psObject->panPartStart = panPartStart;
+ psObject->panPartType = panPartType;
+
+ psObject->padfX = padfX;
+ psObject->padfY = padfY;
+ psObject->padfZ = 0;
+ psObject->padfM = 0;
+
+ /* -------------------------------------------------------------------- */
+ /* Compute the extents. */
+ /* -------------------------------------------------------------------- */
+ psObject->nVertices = nVertices;
+
+ /* -------------------------------------------------------------------- */
+ /* Build extents for this object. */
+ /* -------------------------------------------------------------------- */
+ psObject->dfZMin = psObject->dfZMax = 0;
+ psObject->dfMMin = psObject->dfMMax = 0;
+
+ psObject->dfXMin = psObject->dfXMax = psObject->padfX[0];
+ psObject->dfYMin = psObject->dfYMax = psObject->padfY[0];
+
+ for (int i = 1; i < psObject->nVertices; i++)
+ {
+ if (psObject->dfXMin > psObject->padfX[i]) psObject->dfXMin = psObject->padfX[i];
+ if (psObject->dfYMin > psObject->padfY[i]) psObject->dfYMin = psObject->padfY[i];
+
+ if (psObject->dfXMax < psObject->padfX[i]) psObject->dfXMax = psObject->padfX[i];
+ if (psObject->dfYMax < psObject->padfY[i]) psObject->dfYMax = psObject->padfY[i];
+ }
+}
+
+//---------------------------------------------------------------------------
bool SavePolygone(std::string FileName, TErgebnisPolygonList *PolygonList, int DebugLevel)
{
write_fortschritt("->Speichern der Ergebnispolygone gestartet\n");
@@ -2652,83 +2844,100 @@
write_error(4204, "Kann bei Datei '%s' das Attribut 'DIFF' nicht erzeugen\n", FileName.c_str());
}
- TErgebnisPolygonList *ErgebnisPolygonList = PolygonList->Copy();
-
write_fortschritt("->Löschen der zu kleinen Ringe gestartet\n");
int Count = 0;
int DelCount = 0;
double MinArea = -1;
- TErgebnisPolygonList::iterator j = ErgebnisPolygonList->begin();
- while (j != ErgebnisPolygonList->end())
+
+ for (TErgebnisPolygonList::iterator j = PolygonList->begin(); j != PolygonList->end(); j++)
{
+ Count++;
+
+ if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 10000 == 0) || (Count > 0 && Count % 100000 == 0))
+ {
+ write_fortschritt("%d von %d Polygonen, %d Polygone gelöscht\n", Count, PolygonList->size(), DelCount);
+ }
+
TErgebnisPolygon* EP1 = *j;
double Area = fabs(EP1->Area());
if (MinArea < 0 || MinArea > Area) MinArea = Area;
+ // 10000 entspricht 100 cm * 100 cm
if (Area < 10000.0)
{
- delete EP1;
- ErgebnisPolygonList->erase(j);
DelCount++;
- j = ErgebnisPolygonList->begin();
- continue;
+
+ EP1->Diff = NotValid;
}
- j++;
-
- Count++;
-
- if (Count % 10000 == 0) write_fortschritt("Ring %d von %d überprüft\n", Count, ErgebnisPolygonList->size());
}
write_fortschritt("%d Ringe gelöscht\n", DelCount);
- write_fortschritt("kleinste Ringfläche: %.3f\n", MinArea);
+ write_fortschritt("kleinste Ringfläche: %.3f\n", MinArea / 10000.0);
write_fortschritt("<-Löschen der zu kleinen Ringe beendet\n");
SHPHandle SHPHandle = SHPCreate(FileName.c_str(), SHPT_POLYGON);
+ int *ps = 0;
+ int *pt = 0;
+ double *x = 0;
+ double *y = 0;
+
+ size_t OldPartSize = 0;
+ size_t OldPointSize = 0;
+
Count = 0;
- TErgebnisPolygonList::iterator i = ErgebnisPolygonList->begin();
- while (i != ErgebnisPolygonList->end())
+ TErgebnisPolygonList::iterator i = PolygonList->begin();
+ while (i != PolygonList->end())
{
TErgebnisPolygon* ErgebnisPolygon = *i;
+ if (ErgebnisPolygon->Diff == NotValid)
+ {
+ // Dieses Polygon wird nicht mehr gebraucht
+ i++;
+ continue;
+ }
+
double AktDiff = ErgebnisPolygon->Diff;
- size_t Size = 0;
-
- int *ps = 0;
- int *pt = 0;
- double *x = 0;
- double *y = 0;
- double *z = 0;
- double *m = 0;
-
+ size_t PointSize = 0;
int AnzPolyParts = 0;
int AnzPolyPoints = 0;
- for (TErgebnisPolygonList::iterator j = ErgebnisPolygonList->begin(); j != ErgebnisPolygonList->end(); j++)
+ for (TErgebnisPolygonList::iterator j = PolygonList->begin(); j != PolygonList->end(); j++)
{
TErgebnisPolygon* EP1 = *j;
+ if (EP1->Diff == NotValid)
+ {
+ // Dieses Polygon wird nicht mehr gebraucht
+ continue;
+ }
+
if (EP1->Diff != AktDiff)
{
- // Dieses Polygon wird im Moment noch nicht bearbeitet
+ // Andere Diffs werden im Moment nicht bearbeitet
continue;
}
TXYList::iterator First = EP1->begin();
-
TXY *Xy = *First;
+ long X = Xy->X;
+ long Y = Xy->Y;
- long X = Xy->X;
- long Y = Xy->Y;
-
+ // Jetzt wird getestet, ob der erste Punkt innerhalb liegt
bool IsInnerRing = false;
- for (TErgebnisPolygonList::iterator k = ErgebnisPolygonList->begin(); k != ErgebnisPolygonList->end(); k++)
+ for (TErgebnisPolygonList::iterator k = PolygonList->begin(); k != PolygonList->end(); k++)
{
TErgebnisPolygon* EP2 = *k;
+ if (EP2->Diff == NotValid)
+ {
+ // Dieses Polygon wird nicht mehr gebraucht
+ continue;
+ }
+
if (EP2 == EP1)
{
// Nur mit anderen Polygonen vergleichen
@@ -2737,7 +2946,7 @@
if (EP2->Diff != AktDiff)
{
- // Andere Diffs werden im Moment noch nicht bearbeitet
+ // Andere Diffs werden im Moment nicht bearbeitet
continue;
}
@@ -2748,38 +2957,55 @@
}
}
+ // Dieses Polygon ist ein neuer Ring
AnzPolyParts++;
- // Jetzt holen wird uns den Speicher dafür
- ps = (int *)SfRealloc(ps, sizeof(int) * AnzPolyParts);
- pt = (int *)SfRealloc(pt, sizeof(int) * AnzPolyParts);
+ size_t PartSize = sizeof(int) * AnzPolyParts;
+ if (PartSize > OldPartSize)
+ {
+ OldPartSize = PartSize * 2;
+ ps = (int *)SfRealloc(ps, OldPartSize);
+ pt = (int *)SfRealloc(pt, OldPartSize);
+ }
- Size = Size + sizeof(double) * EP1->size();
+ // Alle Punkte und der erste nochmal am Ende
+ PointSize = PointSize + sizeof(double) * (EP1->size() + 1);
+ if (PointSize > OldPointSize)
+ {
+ OldPointSize = PointSize * 2;
- x = (double *)SfRealloc(x, Size);
- y = (double *)SfRealloc(y, Size);
- z = (double *)SfRealloc(z, Size);
- m = (double *)SfRealloc(m, Size);
+ x = (double *)SfRealloc(x, OldPointSize);
+ y = (double *)SfRealloc(y, OldPointSize);
+ }
ps[AnzPolyParts-1] = AnzPolyPoints;
if (IsInnerRing) pt[AnzPolyParts-1] = SHPP_INNERRING;
else pt[AnzPolyParts-1] = SHPP_RING;
- for (TErgebnisPolygon::iterator i = EP1->begin(); i != EP1->end(); i++)
+ for (TErgebnisPolygon::iterator m = EP1->begin(); m != EP1->end(); m++)
{
- TXY *Xy = *i;
+ x[AnzPolyPoints] = (*m)->X / 100.0;
+ y[AnzPolyPoints] = (*m)->Y / 100.0;
- double X = Xy->X / 100.0;
- double Y = Xy->Y / 100.0;
+ if (DebugLevel == 9)
+ {
+ if (DebugLevel == 9)
+ {
+ write_fortschritt("%.2f %.2f\n", x[AnzPolyPoints], y[AnzPolyPoints]);
+ }
+ }
- x[AnzPolyPoints] = X;
- y[AnzPolyPoints] = Y;
- z[AnzPolyPoints] = 0.0;
- m[AnzPolyPoints] = 0.0;
-
AnzPolyPoints++;
}
+
+ TXYList::iterator m = EP1->begin();
+ x[AnzPolyPoints] = (*m)->X / 100.0;
+ y[AnzPolyPoints] = (*m)->Y / 100.0;
+
+ write_fortschritt("%.2f %.2f\n\n", x[AnzPolyPoints], y[AnzPolyPoints]);
+
+ AnzPolyPoints++;
}
write_fortschritt("%d. Ergebnispolygon (Wassertiefe %.2f, %d Ringe, %d Stützstellen)\n", Count+1, AktDiff / 100.0, AnzPolyParts, AnzPolyPoints);
@@ -2788,40 +3014,36 @@
{
DBFWriteDoubleAttribute(DBFHandle, Count, 0, AktDiff / 100.0);
- SHPObject *psShape = SHPCreateObject(SHPT_POLYGON, -1, AnzPolyParts, ps, NULL, AnzPolyPoints, x, y, z, m);
+ SHPObject *psShape = (SHPObject *) SfCalloc(1, sizeof(SHPObject));
+
+ CreatePolygon(psShape, AnzPolyParts, ps, pt, AnzPolyPoints, x, y);
+
SHPRewindObject(SHPHandle, psShape);
- SHPWriteObject(SHPHandle, -1, psShape);
- SHPDestroyObject(psShape);
+ SHPWritePolygon(SHPHandle, psShape);
+ free (psShape);
+
Count++;
}
- free(ps);
- free(pt);
- free(x);
- free(y);
- free(z);
- free(m);
- TErgebnisPolygonList::iterator j = ErgebnisPolygonList->begin();
- while (j != ErgebnisPolygonList->end())
+ for (TErgebnisPolygonList::iterator j = PolygonList->begin(); j != PolygonList->end(); j++)
{
TErgebnisPolygon* EP1 = *j;
+
if (EP1->Diff == AktDiff)
{
- delete EP1;
- ErgebnisPolygonList->erase(j);
- j = ErgebnisPolygonList->begin();
- continue;
-
+ EP1->Diff = NotValid;
}
- j++;
}
- i = ErgebnisPolygonList->begin();
+ i = PolygonList->begin();
}
- delete ErgebnisPolygonList;
+ free(ps);
+ free(pt);
+ free(x);
+ free(y);
DBFClose(DBFHandle);
SHPClose(SHPHandle);
@@ -3016,13 +3238,12 @@
{
double X = Node->X / 100.0;
double Y = Node->Y / 100.0;
- double Z = 0.0;
-// SHPWritePoint(SHPHandle, X, Y);
+ SHPWritePoint(SHPHandle, X, Y);
- SHPObject *psShape = SHPCreateSimpleObject(SHPT_POINT, 1, &X, &Y, &Z);
- SHPWriteObject(SHPHandle, -1, psShape);
- SHPDestroyObject(psShape);
+// SHPObject *psShape = SHPCreateSimpleObject(SHPT_POINT, 1, &X, &Y, &Z);
+// SHPWriteObject(SHPHandle, -1, psShape);
+// SHPDestroyObject(psShape);
DBFWriteDoubleAttribute(DBFHandle, Count, 0, Node->Z / 100.0);
Modified: trunk/src/file.h
===================================================================
--- trunk/src/file.h 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/file.h 2007-07-15 18:01:23 UTC (rev 90)
@@ -19,6 +19,9 @@
#include "xy.h"
//----------------------------------------------------------------------------
+typedef enum { TTUNKNOWN, TTREGULAR, TTHARD, TTSOFT, TTOUTSIDE } TTinTyp;
+
+//----------------------------------------------------------------------------
bool LoadPar(std::string FileName, std::vector<std::string> *ParList);
bool LoadPRJ(std::string FileName, int DebugLevel);
Modified: trunk/src/parameter.cpp
===================================================================
--- trunk/src/parameter.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/parameter.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -66,6 +66,8 @@
BisKm = +9999.9;
IsSetSaveTri = false;
+ IsSetSave2DM = false;
+ IsSetSaveSol = false;
IsSetAusgabe = false;
FileNameAusgabe = "WSPLGEN.SHP";
@@ -230,6 +232,40 @@
write_fortschritt("Triangulation wird gespeichert\n");
}
+ else if (Parameter.substr(0, 8) == "-SAVE2DM" || Parameter.substr(0, 8) == "-save2dm")
+ {
+ ///////////////////////////////////////////////
+ // SAVE2DM
+ ///////////////////////////////////////////////
+ if (IsSetDebug) write_fortschritt("Parameter -SAVE2DM erkannt.\n");
+
+ if (IsSetSave2DM)
+ {
+ write_warning(1106, "Der Parameter -SAVE2DM wurde mehrfach angegeben.\n");
+ continue;
+ }
+
+ IsSetSave2DM = true;
+
+ write_fortschritt("2DM-Netz wird gespeichert\n");
+ }
+ else if (Parameter.substr(0, 8) == "-SAVESOL" || Parameter.substr(0, 8) == "-savesol")
+ {
+ ///////////////////////////////////////////////
+ // SAVESOL
+ ///////////////////////////////////////////////
+ if (IsSetDebug) write_fortschritt("Parameter -SAVESOL erkannt.\n");
+
+ if (IsSetSaveSol)
+ {
+ write_warning(1106, "Der Parameter -SAVESOL wurde mehrfach angegeben.\n");
+ continue;
+ }
+
+ IsSetSaveSol = true;
+
+ write_fortschritt("Wasserstände werden als SOL-Datei gespeichert\n");
+ }
else if (Parameter.substr(0, 6) == "-DELTA" || Parameter.substr(0, 6) == "-delta")
{
///////////////////////////////////////////////
Modified: trunk/src/parameter.h
===================================================================
--- trunk/src/parameter.h 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/parameter.h 2007-07-15 18:01:23 UTC (rev 90)
@@ -11,8 +11,8 @@
//
//----------------------------------------------------------------------------
-#ifndef WSPLGENH
-#define WSPLGENH
+#ifndef PARAMETERH
+#define PARAMETERH
//---------------------------------------------------------------------------
#include <string>
@@ -69,6 +69,8 @@
double BisKm;
bool IsSetSaveTri;
+ bool IsSetSave2DM;
+ bool IsSetSaveSol;
bool IsSetAusgabe;
std::string FileNameAusgabe;
Modified: trunk/src/shape.cpp
===================================================================
--- trunk/src/shape.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/shape.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -974,7 +974,7 @@
/* Expand file wide bounds based on this shape. */
/* -------------------------------------------------------------------- */
if (psSHP->adBoundsMin[0] == 0.0 && psSHP->adBoundsMax[0] == 0.0 && psSHP->adBoundsMin[1] == 0.0 && psSHP->adBoundsMax[1] == 0.0)
- {
+ {
psSHP->adBoundsMin[0] = XMin;
psSHP->adBoundsMin[1] = YMin;
psSHP->adBoundsMax[0] = XMax;
@@ -994,6 +994,142 @@
/************************************************************************/
+/* SHPWritePolygon() */
+/* */
+/* Write out the vertices of a new structure. Note that it is */
+/* only possible to write vertices at the end of the file. */
+/************************************************************************/
+int SHPAPI_CALL SHPWritePolygon(SHPHandle psSHP, SHPObject* psObject)
+{
+ psSHP->bUpdated = TRUE;
+
+ /* -------------------------------------------------------------------- */
+ /* Ensure that shape object matches the type of the file it is */
+ /* being written to. */
+ /* -------------------------------------------------------------------- */
+ assert(psObject->nSHPType == psSHP->nShapeType || psObject->nSHPType == SHPT_NULL);
+
+ int nShapeId = -1;
+
+ /* -------------------------------------------------------------------- */
+ /* Add the new entity to the in memory index. */
+ /* -------------------------------------------------------------------- */
+ if (nShapeId == -1 && psSHP->nRecords + 1 > psSHP->nMaxRecords)
+ {
+ psSHP->nMaxRecords =(int)(psSHP->nMaxRecords * 1.3 + 100);
+ psSHP->panRecOffset = (int *)SfRealloc(psSHP->panRecOffset, sizeof(int) * psSHP->nMaxRecords);
+ psSHP->panRecSize = (int *)SfRealloc(psSHP->panRecSize, sizeof(int) * psSHP->nMaxRecords);
+ }
+
+ /* -------------------------------------------------------------------- */
+ /* Initialize record. */
+ /* -------------------------------------------------------------------- */
+ uchar* pabyRec = (uchar *)SfMalloc(psObject->nVertices * 4 * sizeof(double) + psObject->nParts * 8 + 128);
+
+ /* -------------------------------------------------------------------- */
+ /* Extract vertices for a Polygon or Arc. */
+ /* -------------------------------------------------------------------- */
+
+ int32 nPoints = psObject->nVertices;
+ int32 nParts = psObject->nParts;
+
+ _SHPSetBounds( pabyRec + 12, psObject );
+
+ if( bBigEndian ) Swap4Bytes(&nPoints );
+ if( bBigEndian ) Swap4Bytes(&nParts );
+
+ ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
+ ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
+
+ int nRecordSize = 52;
+
+ // Write part start positions.
+ ByteCopy( psObject->panPartStart, pabyRec + 44 + 8, 4 * psObject->nParts );
+ for(int i = 0; i < psObject->nParts; i++ )
+ {
+ if( bBigEndian ) Swap4Bytes(pabyRec + 44 + 8 + 4*i );
+ nRecordSize += 4;
+ }
+
+ // Write the (x,y) vertex values.
+ for(int i = 0; i < psObject->nVertices; i++ )
+ {
+ ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 );
+ ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 );
+
+ if (bBigEndian) Swap8Bytes(pabyRec + nRecordSize );
+
+ if (bBigEndian) Swap8Bytes(pabyRec + nRecordSize + 8 );
+
+ nRecordSize = nRecordSize + 2 * 8;
+ }
+
+ /* -------------------------------------------------------------------- */
+ /* Establish where we are going to put this record. If we are */
+ /* rewriting and existing record, and it will fit, then put it */
+ /* back where the original came from. Otherwise write at the end. */
+ /* -------------------------------------------------------------------- */
+ nShapeId = psSHP->nRecords++;
+
+ int nRecordOffset = psSHP->nFileSize;
+ psSHP->panRecOffset[nShapeId] = nRecordOffset;
+ psSHP->panRecSize[nShapeId] = nRecordSize-8;
+ psSHP->nFileSize += nRecordSize;
+
+ /* -------------------------------------------------------------------- */
+ /* Set the shape type, record number, and record size. */
+ /* -------------------------------------------------------------------- */
+ int32 i32 = 0;
+
+ i32 = nShapeId+1; /* record # */
+ if( !bBigEndian ) Swap4Bytes(&i32 );
+ ByteCopy( &i32, pabyRec, 4 );
+
+ i32 = (nRecordSize-8)/2; /* record size */
+ if( !bBigEndian ) Swap4Bytes(&i32 );
+ ByteCopy( &i32, pabyRec + 4, 4 );
+
+ i32 = psObject->nSHPType; /* shape type */
+ if( bBigEndian ) Swap4Bytes(&i32 );
+ ByteCopy( &i32, pabyRec + 8, 4 );
+
+ /* -------------------------------------------------------------------- */
+ /* Write out record. */
+ /* -------------------------------------------------------------------- */
+ if( fseek(fpSHP, nRecordOffset, 0) != 0 || fwrite(pabyRec, nRecordSize, 1, fpSHP) < 1 )
+ {
+ free(pabyRec);
+ dump_error(__FILE__, __LINE__, "Error in fseek() or fwrite().\n");
+ return (-1);
+ }
+
+ free(pabyRec);
+
+ /* -------------------------------------------------------------------- */
+ /* Expand file wide bounds based on this shape. */
+ /* -------------------------------------------------------------------- */
+ if (psSHP->adBoundsMin[0] == 0.0 && psSHP->adBoundsMax[0] == 0.0 && psSHP->adBoundsMin[1] == 0.0 && psSHP->adBoundsMax[1] == 0.0)
+ {
+ psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0];
+ psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0];
+ psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = 0;
+ psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = 0;
+ }
+
+ for (int i = 0; i < psObject->nVertices; i++ )
+ {
+ if (psSHP->adBoundsMin[0] > psObject->padfX[i]) psSHP->adBoundsMin[0] = psObject->padfX[i];
+ if (psSHP->adBoundsMin[1] > psObject->padfY[i]) psSHP->adBoundsMin[1] = psObject->padfY[i];
+
+ if (psSHP->adBoundsMax[0] < psObject->padfX[i]) psSHP->adBoundsMax[0] = psObject->padfX[i];
+ if (psSHP->adBoundsMax[1] < psObject->padfY[i]) psSHP->adBoundsMax[1] = psObject->padfY[i];
+ }
+
+ return(nShapeId);
+}
+
+
+/************************************************************************/
/* SHPWriteObject() */
/* */
/* Write out the vertices of a new structure. Note that it is */
@@ -1071,7 +1207,7 @@
if( psObject->nSHPType == SHPT_MULTIPATCH )
{
memcpy( pabyRec + nRecordSize, psObject->panPartType, 4*psObject->nParts );
- for( i = 0; i < psObject->nParts; i++ )
+ for( i = 0; i < psObject->nParts; i++ )
{
if( bBigEndian ) Swap4Bytes(pabyRec + nRecordSize );
nRecordSize += 4;
@@ -1109,7 +1245,7 @@
ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
if( bBigEndian ) Swap8Bytes(pabyRec + nRecordSize );
nRecordSize += 8;
- }
+ }
}
/*
@@ -1185,7 +1321,7 @@
if( psObject->nSHPType == SHPT_MULTIPOINTZ
|| psObject->nSHPType == SHPT_MULTIPOINTM )
- {
+ {
ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
if( bBigEndian ) Swap8Bytes(pabyRec + nRecordSize );
nRecordSize += 8;
@@ -1240,7 +1376,7 @@
else
{
/* unknown type */
- dump_error(__FILE__, __LINE__, "Unbekannter Shape-Typ %d\n", psObject->nSHPType);
+ dump_error(__FILE__, __LINE__, "Unbekannter Shape-Typ %d\n", psObject->nSHPType);
return (0);
}
@@ -1261,7 +1397,7 @@
{
nRecordOffset = psSHP->panRecOffset[nShapeId];
}
-
+
/* -------------------------------------------------------------------- */
/* Set the shape type, record number, and record size. */
/* -------------------------------------------------------------------- */
@@ -1296,7 +1432,7 @@
{
psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0];
psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0];
- psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0];
+ psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0];
psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0];
}
@@ -1325,19 +1461,19 @@
SHPObject SHPAPI_CALL1(*) SHPReadObject( SHPHandle psSHP, int hEntity )
{
- SHPObject *psShape;
+ SHPObject *psShape;
/* -------------------------------------------------------------------- */
/* Validate the record/entity number. */
/* -------------------------------------------------------------------- */
- if( hEntity < 0 || hEntity >= psSHP->nRecords )
- return( NULL );
+ if( hEntity < 0 || hEntity >= psSHP->nRecords )
+ return( NULL );
/* -------------------------------------------------------------------- */
/* Ensure our record buffer is large enough. */
/* -------------------------------------------------------------------- */
- if( psSHP->panRecSize[hEntity]+8 > psSHP->nBufSize )
- {
+ if( psSHP->panRecSize[hEntity]+8 > psSHP->nBufSize )
+ {
psSHP->nBufSize = psSHP->panRecSize[hEntity]+8;
psSHP->pabyRec = (uchar *) SfRealloc(psSHP->pabyRec,psSHP->nBufSize);
}
@@ -1810,7 +1946,7 @@
int iNext;
if( iEdge < nVertCount-1 )
- iNext = iEdge+1;
+ iNext = iEdge+1;
else
iNext = 0;
@@ -1834,7 +1970,7 @@
/* Determine the current order of this ring so we will know if */
/* it has to be reversed. */
/* -------------------------------------------------------------------- */
- nVertStart = psObject->panPartStart[iOpRing];
+ nVertStart = psObject->panPartStart[iOpRing];
if( iOpRing == psObject->nParts-1 )
nVertCount = psObject->nVertices - psObject->panPartStart[iOpRing];
@@ -1845,7 +1981,7 @@
dfSum = 0.0;
for( iVert = nVertStart; iVert < nVertStart+nVertCount-1; iVert++ )
{
- dfSum += psObject->padfX[iVert] * psObject->padfY[iVert+1]
+ dfSum += psObject->padfX[iVert] * psObject->padfY[iVert+1]
- psObject->padfY[iVert] * psObject->padfX[iVert+1];
}
@@ -1859,7 +1995,7 @@
{
int i;
- bAltered++;
+ bAltered++;
for( i = 0; i < nVertCount/2; i++ )
{
double dfSaved;
Modified: trunk/src/shape.h
===================================================================
--- trunk/src/shape.h 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/shape.h 2007-07-15 18:01:23 UTC (rev 90)
@@ -180,6 +180,7 @@
int SHPAPI_CALL SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
int SHPAPI_CALL SHPWritePoint(SHPHandle psSHP, double X, double Y);
int SHPAPI_CALL SHPWriteElement(SHPHandle psSHP, double X1, double Y1, double X2, double Y2, double X3, double Y3);
+int SHPAPI_CALL SHPWritePolygon(SHPHandle psSHP, SHPObject* psObject);
void SHPAPI_CALL SHPDestroyObject( SHPObject * psObject );
void SHPAPI_CALL SHPComputeExtents( SHPObject * psObject );
Modified: trunk/src/test_file.cpp
===================================================================
--- trunk/src/test_file.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/test_file.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -24,7 +24,10 @@
//----------------------------------------------------------------------------
#ifdef __BORLANDC__
+#define POLYGONFILE "test_daten\\ergebnispolygone.shp"
#define DGMTINFILE "test_daten\\dgmtin\\tnxy.adf"
+#define DGMTINFILE2 "test_daten\\dgmtin2\\tnxy.adf"
+#define DGMTINFILE3 "test_daten\\dgmtin3\\tnxy.adf"
#define DGMGRDFILE "test_daten\\dgm.grd"
#define DGMXYZFILE "test_daten\\dgm.xyz"
#define DGMXYZFILE2 "test_daten\\dgm_gross.xyz"
@@ -46,7 +49,10 @@
#define GRENZEFILE "test_daten\\hydgrenze.shp"
#define GRENZEFILE2 "test_daten\\hydgrenze2.shp"
#else
+#define POLYGONFILE "test_daten/ergebnispolygone.shp"
#define DGMTINFILE "test_daten/dgmtin/tnxy.adf"
+#define DGMTINFILE2 "test_daten/dgmtin2/tnxy.adf"
+#define DGMTINFILE3 "test_daten/dgmtin3/tnxy.adf"
#define DGMGRDFILE "test_daten/dgm.grd"
#define DGMXYZFILE "test_daten/dgm.xyz"
#define DGMXYZFILE2 "test_daten/dgm_gross.xyz"
@@ -79,6 +85,100 @@
printf ("Test Datei Ein- und Ausgabe\n");
/////////////////////////////////////////////////
+ // Test von Ergebnispolygon schreiben
+ /////////////////////////////////////////////////
+
+ {
+ printf ("Test Ergebnispolygon schreiben: ");
+
+ TErgebnisPolygonList *PolygonList = new TErgebnisPolygonList;
+
+ TErgebnisPolygon* EP1 = new TErgebnisPolygon(0);
+ TXY *XY1 = new TXY(10000, 10000);
+ EP1->Add(XY1);
+ TXY *XY2 = new TXY(30000, 10000);
+ EP1->Add(XY2);
+ TXY *XY3 = new TXY(30000, 30000);
+ EP1->Add(XY3);
+ TXY *XY4 = new TXY(10000, 30000);
+ EP1->Add(XY4);
+ PolygonList->push_back(EP1);
+
+ TErgebnisPolygon* EP2 = new TErgebnisPolygon(0);
+ TXY *XY5 = new TXY(15000, 15000);
+ EP2->Add(XY5);
+ TXY *XY6 = new TXY(25000, 15000);
+ EP2->Add(XY6);
+ TXY *XY7 = new TXY(25000, 25000);
+ EP2->Add(XY7);
+ TXY *XY8 = new TXY(15000, 25000);
+ EP2->Add(XY8);
+ TXY *XY9 = new TXY(20000, 20000);
+ EP2->Add(XY9);
+ PolygonList->push_back(EP2);
+
+ TErgebnisPolygon* EP3 = new TErgebnisPolygon(0);
+ TXY *XY10 = new TXY(45000, 25000);
+ EP3->Add(XY10);
+ TXY *XY11 = new TXY(55000, 25000);
+ EP3->Add(XY11);
+ TXY *XY12 = new TXY(55000, 15000);
+ EP3->Add(XY12);
+ PolygonList->push_back(EP3);
+
+ SavePolygone(POLYGONFILE, PolygonList, 9);
+
+ delete PolygonList;
+ }
+
+ /////////////////////////////////////////////////
+ // Test von Ergebnispolygon schreiben
+ /////////////////////////////////////////////////
+
+ {
+ printf ("Test Ergebnispolygon schreiben: ");
+
+ TErgebnisPolygonList *PolygonList = new TErgebnisPolygonList;
+
+ TErgebnisPolygon* EP1 = new TErgebnisPolygon(0);
+ TXY *XY1 = new TXY(10000, 10000);
+ EP1->Add(XY1);
+ TXY *XY2 = new TXY(30000, 10000);
+ EP1->Add(XY2);
+ TXY *XY3 = new TXY(30000, 30000);
+ EP1->Add(XY3);
+ TXY *XY4 = new TXY(10000, 30000);
+ EP1->Add(XY4);
+ PolygonList->push_back(EP1);
+
+ TErgebnisPolygon* EP2 = new TErgebnisPolygon(0);
+ TXY *XY5 = new TXY(15000, 15000);
+ EP2->Add(XY5);
+ TXY *XY6 = new TXY(25000, 15000);
+ EP2->Add(XY6);
+ TXY *XY7 = new TXY(25000, 25000);
+ EP2->Add(XY7);
+ TXY *XY8 = new TXY(15000, 25000);
+ EP2->Add(XY8);
+ TXY *XY9 = new TXY(20000, 20000);
+ EP2->Add(XY9);
+ PolygonList->push_back(EP2);
+
+ TErgebnisPolygon* EP3 = new TErgebnisPolygon(0);
+ TXY *XY10 = new TXY(45000, 25000);
+ EP3->Add(XY10);
+ TXY *XY11 = new TXY(55000, 25000);
+ EP3->Add(XY11);
+ TXY *XY12 = new TXY(55000, 15000);
+ EP3->Add(XY12);
+ PolygonList->push_back(EP3);
+
+ SavePolygone(POLYGONFILE, PolygonList, 8);
+
+ delete PolygonList;
+ }
+
+ /////////////////////////////////////////////////
// Test von Parameterdatei laden
/////////////////////////////////////////////////
@@ -159,6 +259,48 @@
}
/////////////////////////////////////////////////
+ // Test von DGM-TIN2 ohne Begrenzungspolygon laden
+ /////////////////////////////////////////////////
+
+ {
+ printf ("Test DGM-TIN2 ohne Begrenzungspolygon laden: ");
+
+ TNodeList *NodeList = new TNodeList();
+ TElementList *ElementList = new TElementList();
+
+ LoadDGM(DGMTINFILE2, NodeList, ElementList, 0, 8);
+
+ if (NodeList->size() != 19) printf("Failed\n");
+ else if (ElementList->size() != 28) printf("Failed\n");
+ else printf("Pass\n");
+
+ delete NodeList;
+ delete ElementList;
+ }
+
+ /////////////////////////////////////////////////
+ // Test von DGM-TIN3 ohne Begrenzungspolygon laden
+ /////////////////////////////////////////////////
+
+ {
+ printf ("Test DGM-TIN3 ohne Begrenzungspolygon laden: ");
+
+ TNodeList *NodeList = new TNodeList();
+ TElementList *ElementList = new TElementList();
+
+ LoadDGM(DGMTINFILE3, NodeList, ElementList, 0, 8);
+
+// SaveNet("test.2dm", NodeList, ElementList, 8);
+
+ if (NodeList->size() != 52) printf("Failed\n");
+ else if (ElementList->size() != 72) printf("Failed\n");
+ else printf("Pass\n");
+
+ delete NodeList;
+ delete ElementList;
+ }
+
+ /////////////////////////////////////////////////
// Test von DGM-GRD mit Begrenzungspolygon laden
/////////////////////////////////////////////////
@@ -379,6 +521,7 @@
else if (GradientenList->size() != 0) printf("Failed\n");
else printf("Pass\n");
+ delete GradientenList;
delete RohreList;
delete GrabenList;
delete SperrenList;
@@ -496,6 +639,9 @@
else printf("Pass\n");
delete WspList1;
+ delete WspList2;
+ delete WspList3;
+ delete WspList4;
}
////////////////////////////////////////
Modified: trunk/src/test_qhull.cpp
===================================================================
--- trunk/src/test_qhull.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/test_qhull.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -32,7 +32,7 @@
printf ("Test Konvexe Hülle\n");
{
- printf ("Test QHull 3 Knoten: ");
+ printf ("Test QHull 3 Knoten: ");
// Zuerst ein paar Punkte generieren
TXY *Xy1 = new TXY(1, 1);
@@ -59,7 +59,7 @@
}
{
- printf ("Test QHull 5 Knoten: ");
+ printf ("Test QHull 5 Knoten: ");
// Zuerst ein paar Punkte generieren
TXY *Xy1 = new TXY(1, 1);
@@ -90,7 +90,7 @@
}
{
- printf ("Test QHull 5 Knoten (Quadrat): ");
+ printf ("Test QHull 5 Knoten (Quadrat): ");
// Zuerst ein paar Punkte generieren
TXY *Xy1 = new TXY(1, 1);
@@ -121,7 +121,7 @@
}
{
- printf ("Test QHull 5 Knoten (Raute): ");
+ printf ("Test QHull 5 Knoten (Raute): ");
// Zuerst ein paar Punkte generieren
TXY *Xy1 = new TXY(1, 1);
Modified: trunk/src/test_tools.cpp
===================================================================
--- trunk/src/test_tools.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/test_tools.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -251,56 +251,7 @@
else printf("Pass\n");
}
-
////////////////////////////////////////
- // Test der XYKombination
- ////////////////////////////////////////
-
- {
- printf ("Test XYKombination: ");
-
- unsigned INT64 XYKombi = INT64SUFF(0);
-
- XYKombi = CalcXYKombi(0.0, 0.0);
- std::string XYKombiStr1 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(1.0, 0.0);
- std::string XYKombiStr2 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(0.0, 1.0);
- std::string XYKombiStr3 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(1.0, 1.0);
- std::string XYKombiStr4 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(10.0, 10.0);
- std::string XYKombiStr5 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(100.0, 100.0);
- std::string XYKombiStr6 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(10000.0, 10000.0);
- std::string XYKombiStr7 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(6000000.0, 6000000.0);
- std::string XYKombiStr8 = UnsignedInt64ToBin(XYKombi);
-
- XYKombi = CalcXYKombi(0x7FFFFFFFL, 0x7FFFFFFFL);
- std::string XYKombiStr9 = UnsignedInt64ToBin(XYKombi);
-
- if (XYKombiStr1 != "0000000000000000000000000000000000000000000000000000000000000000") printf("Failed\n");
- else if (XYKombiStr2 != "0000000000000000000000000000000000000000000000000000000000000010") printf("Failed\n");
- else if (XYKombiStr3 != "0000000000000000000000000000000000000000000000000000000000000001") printf("Failed\n");
- else if (XYKombiStr4 != "0000000000000000000000000000000000000000000000000000000000000011") printf("Failed\n");
- else if (XYKombiStr5 != "0000000000000000000000000000000000000000000000000000000011001100") printf("Failed\n");
- else if (XYKombiStr6 != "0000000000000000000000000000000000000000000000000011110000110000") printf("Failed\n");
- else if (XYKombiStr7 != "0000000000000000000000000000000000001100001111110000001100000000") printf("Failed\n");
- else if (XYKombiStr8 != "0000000000000000001100111100111111000000111100111100000000000000") printf("Failed\n");
- else if (XYKombiStr9 != "0011111111111111111111111111111111111111111111111111111111111111") printf("Failed\n");
- else printf("Pass\n");
- }
-
- ////////////////////////////////////////
// Test der Funktion IsInside
////////////////////////////////////////
Modified: trunk/src/tools.cpp
===================================================================
--- trunk/src/tools.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/tools.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -270,96 +270,6 @@
}
//---------------------------------------------------------------------------
-std::string UnsignedInt32ToBin (unsigned long Value, char *Spaces)
-{
- std::string Line = "";
- unsigned long Mask = 0x80000000L;
- for (unsigned int i=32; i>0; i--)
- {
- if ((Value & Mask) != 0L) Line = Line + "1";
- else Line = Line + "0";
-
- Line = Line + Spaces;
-
- Mask = Mask / 2;
- }
- return (Line);
-}
-
-//---------------------------------------------------------------------------
-std::string UnsignedInt64ToBin (unsigned INT64 Value)
-{
- std::string Line = "";
- unsigned INT64 Mask = INT64SUFF(0x8000000000000000);
- for (unsigned int i=64; i>0; i--)
- {
- if ((Value & Mask) != 0L) Line = Line + "1";
- else Line = Line + "0";
-
- Mask = Mask / 2;
- }
- return (Line);
-}
-
-//---------------------------------------------------------------------------
-std::string UnsignedInt64ToDez (unsigned INT64 Value)
-{
- std::string Line = "";
- for (unsigned int i=0; i<21; i++)
- {
- int Ziffer = (int)(Value % 10);
-
- switch (Ziffer)
- {
- case 0: Line = "0" + Line; break;
- case 1: Line = "1" + Line; break;
- case 2: Line = "2" + Line; break;
- case 3: Line = "3" + Line; break;
- case 4: Line = "4" + Line; break;
- case 5: Line = "5" + Line; break;
- case 6: Line = "6" + Line; break;
- case 7: Line = "7" + Line; break;
- case 8: Line = "8" + Line; break;
- case 9: Line = "9" + Line; break;
- }
-
- Value = Value / 10;
- }
- return (Line);
-}
-
-//---------------------------------------------------------------------------
-unsigned INT64 CalcXYKombi (double X, double Y)
-{
- if ((X > 0x7FFFFFFFL) || (Y > 0x7FFFFFFFL))
- {
- dump_error(__FILE__, __LINE__, "Die Werte für die X und Y Koordinaten sind zu groß\nX = %f\nX = %f\n", X, Y);
- }
-
- if ((X < 0.0) || (Y < 0.0))
- {
- dump_error(__FILE__, __LINE__, "Die Werte für die X und Y Koordinaten sind negativ\nX = %f\nX = %f\n", X, Y);
- }
-
- unsigned INT64 Xl = (INT64)X;
- unsigned INT64 Yl = (INT64)Y;
-
- unsigned INT64 Kombi = INT64SUFF(0);
- unsigned INT64 Mask = INT64SUFF(0x40000000);
- for (int i=30; i>=0; i--)
- {
- Kombi = Kombi * 2;
- if (Xl & Mask) Kombi = Kombi + 1;
-
- Kombi = Kombi * 2;
- if (Yl & Mask) Kombi = Kombi + 1;
-
- Mask = Mask / 2;
- }
-
- return (Kombi);
-}
-//---------------------------------------------------------------------------
void* SfRealloc(void *Mem, int NewSize)
{
void* MemoryPointer = 0;
@@ -924,9 +834,9 @@
{
write_fortschritt ("->Suche nach doppelten Knoten gestartet\n");
- int SollKnotenGeloescht = 0;
int KnotenGeloescht = 0;
int ElementeGeloescht = 0;
+ int SollKnotenGeloescht = 0;
if (ElementList && ElementList->size() > 0)
{
@@ -935,6 +845,8 @@
bool NetChanged = false;
do
{
+ SollKnotenGeloescht = 0;
+
NodeList->SortByXY();
NetChanged = false;
@@ -949,7 +861,7 @@
{
TNode *Node2 = NodeList->FindByXY(Node1->X, Node1->Y);
- if (Node1->Nr != Node2->Nr)
+ if (Node2->Nr != 0 && Node1->Nr != Node2->Nr)
{
if (DebugLevel >= 9)
{
@@ -974,7 +886,7 @@
{
TNode *Node2 = NodeList->FindByXY(Node1->X, Node1->Y);
- if (Node1->Nr != Node2->Nr)
+ if (Node2->Nr != 0 && Node1->Nr != Node2->Nr)
{
if (DebugLevel >= 9)
{
@@ -989,7 +901,7 @@
if (Element2->Node3 == Node1) Element2->Node3 = Node2;
}
Node1->Nr = 0;
- KnotenGeloescht++;
+ SollKnotenGeloescht++;
}
}
@@ -998,7 +910,7 @@
{
TNode *Node2 = NodeList->FindByXY(Node1->X, Node1->Y);
- if (Node1->Nr != Node2->Nr)
+ if (Node2->Nr != 0 && Node1->Nr != Node2->Nr)
{
if (DebugLevel >= 9)
{
@@ -1013,44 +925,64 @@
if (Element2->Node3 == Node1) Element2->Node3 = Node2;
}
Node1->Nr = 0;
- KnotenGeloescht++;
+ SollKnotenGeloescht++;
}
}
Count++;
if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 10000 == 0) || (Count > 0 && Count % 100000 == 0))
{
- write_fortschritt("%d von %d Elementen, %d/%d Knoten und %d Elemente gelöscht\n", Count, ElementList->size(), KnotenGeloescht, SollKnotenGeloescht, ElementeGeloescht);
+ write_fortschritt("%d von %d Elementen, %d doppelte Knoten gefunden\n", Count, ElementList->size(), SollKnotenGeloescht);
}
}
if (SollKnotenGeloescht > 0)
{
+ int AnzNodes = NodeList->size();
Count = 0;
- for (TNodeList::iterator i = NodeList->begin(); i != NodeList->end(); i++)
+ TNodeList::iterator SaveI = NodeList->begin();
+ TNodeList::iterator i = NodeList->begin();
+ while (i != NodeList->end())
{
Count++;
if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 10000 == 0) || (Count > 0 && Count % 100000 == 0))
{
- write_fortschritt("%d von %d Elementen, %d/%d Knoten und %d Elemente gelöscht\n", Count, ElementList->size(), KnotenGeloescht, SollKnotenGeloescht, ElementeGeloescht);
+ write_fortschritt("%d von %d Knoten, %d von %d Knoten gelöscht\n", Count, AnzNodes, KnotenGeloescht, SollKnotenGeloescht);
}
TNode *Node = *i;
if (Node->Nr == 0)
{
- NodeList->erase(i);
KnotenGeloescht++;
NetChanged = true;
+
+
+ delete Node;
+ NodeList->erase(i);
+
+ i = SaveI;
}
+ else
+ {
+ SaveI = i;
+ i++;
+ }
}
}
} while (NetChanged);
if (KnotenGeloescht > 0)
{
+ int Count = 0;
for (TElementList::iterator i = ElementList->begin(); i != ElementList->end(); i++)
{
+ Count++;
+ if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 10000 == 0) || (Count > 0 && Count % 100000 == 0))
+ {
+ write_fortschritt("%d von %d Elementen, %d Elemente gelöscht\n", Count, ElementList->size(), ElementeGeloescht);
+ }
+
TElement *Element = *i;
TNode *Node1 = Element->Node1;
@@ -1087,6 +1019,7 @@
if (Node1->Nr != Node2->Nr)
{
+ delete Node1;
NodeList->erase(i);
KnotenGeloescht++;
}
@@ -2252,61 +2185,6 @@
}
//---------------------------------------------------------------------------
-bool FindFirstWetBoundaryEdge(TEdgeVector::iterator *Start, TEdgeList *EdgeList, TEdge **edge, TNode **node)
-{
- for (TEdgeVector::iterator i = *Start; i != EdgeList->EdgeVector.end(); i++)
- {
- TEdge *Edge = *i;
-
- if (Edge->Ready) continue;
-
- if (Edge->IsBoundary && Edge->Node1->Wsp > Edge->Node1->Z && Edge->Node2->Wsp > Edge->Node2->Z)
- {
- Edge->Ready = true;
- *edge = Edge;
- *node = Edge->Node1;
- *Start = i;
- return (true);
- }
- }
-
- *Start = EdgeList->EdgeVector.end();
-
- return (false);
-}
-//---------------------------------------------------------------------------
-bool FindNextWetBoundaryEdge(TEdge **edge, TNode **node)
-{
- do
- {
- TEdge *Edge = FindNextAntiClockwiseEdge (edge, node);
-
- if (Edge->Ready) return (false);
-
- if (Edge->IsBoundary && Edge->Node1->Wsp > Edge->Node1->Z && Edge->Node2->Wsp > Edge->Node2->Z)
- {
- if (Edge->Node1 == *node)
- {
- Edge->Ready = true;
- *edge = Edge;
- *node = Edge->Node2;
- }
- else
- {
- Edge->Ready = true;
- *edge = Edge;
- *node = Edge->Node1;
- }
- return (true);
- }
- else
- {
- *edge = Edge;
- }
- } while (true);
-}
-
-//---------------------------------------------------------------------------
void NassTrockenBerechnung(TNodeList *NodeList, TEdgeList *EdgeList, TErgebnisPolygonList* ErgebnisPolygone, TProfilList* RohreList, TProfilList* GradientenList, double AvgDistance, int Von, int Bis, int Diff, int DebugLevel)
{
write_fortschritt("->Ermittlung der Überschwemmungsgrenzen gestartet\n");
@@ -2388,7 +2266,7 @@
// Es waren nur geliehene Kanten
TempEdgeList->Empty();
- // Alle bisher ermittelten Wechsel-Kanten übertragen
+ // Alle bisher ermittelten Kanten überprüfen und die Kanten mit Ausbreitung eintragen
for (TEdgeVector::iterator i = Temp2EdgeList->EdgeVector.begin(); i != Temp2EdgeList->EdgeVector.end(); i++)
{
TEdge *Edge = *i;
@@ -2401,6 +2279,14 @@
{
TempEdgeList->Add(Edge);
}
+ else if (Edge->Node1->Wsp <= Edge->Node1->Z && Edge->Node2->Wsp != NoWsp && Edge->Node2->Wsp > Edge->Node2->Z && Edge->Node2->Wsp > Edge->Node1->Z)
+ {
+ TempEdgeList->Add(Edge);
+ }
+ else if (Edge->Node2->Wsp <= Edge->Node2->Z && Edge->Node1->Wsp != NoWsp && Edge->Node1->Wsp > Edge->Node1->Z && Edge->Node1->Wsp > Edge->Node2->Z)
+ {
+ TempEdgeList->Add(Edge);
+ }
}
// Hier nur die Verwaltungsinformationen, aber nicht die richtigen Kanten löschen
@@ -2412,7 +2298,7 @@
{
TEdge *Edge = *i;
- if (Edge->Node1->Wsp == NoWsp && Edge->Node2->Wsp != NoWsp)
+ if (Edge->Node1->Wsp == NoWsp && Edge->Node2->Wsp != NoWsp && Edge->Node2->Wsp > Edge->Node2->Z)
{
if (Edge->Node2->Wsp <= Edge->Node2->Z)
{
@@ -2434,7 +2320,7 @@
Changed++;
}
- else if (Edge->Node2->Wsp == NoWsp && Edge->Node1->Wsp != NoWsp)
+ else if (Edge->Node2->Wsp == NoWsp && Edge->Node1->Wsp != NoWsp && Edge->Node1->Wsp > Edge->Node1->Z)
{
if (Edge->Node1->Wsp <= Edge->Node1->Z)
{
@@ -2456,6 +2342,55 @@
Changed++;
}
+ else if (Edge->Node1->Wsp <= Edge->Node1->Z && Edge->Node2->Wsp != NoWsp && Edge->Node2->Wsp > Edge->Node2->Z && Edge->Node2->Wsp > Edge->Node1->Z)
+ {
+ if (Edge->Node2->Wsp <= Edge->Node2->Z)
+ {
+ dump_error(__FILE__, __LINE__, "Der Kantenendknoten %d ist unter Gelände aber nass", Edge->Node2->Nr);
+ }
+
+ // Der bisher trockene Knoten hatte schon einen Wasserstand, er bekommt nun einen neuen
+ Edge->Node1->Wsp = Edge->Node1->Z + 1;
+
+ // Hier jetzt neue potentielle Kanten aufnehmen
+ TEdgeIndex *AktEdgeIndex = Edge->Node1->EdgeIndex;
+ while (AktEdgeIndex)
+ {
+ TEdgeIndex *NextEdgeIndex = AktEdgeIndex->NextEdgeIndex;
+
+ Temp2EdgeList->Add(AktEdgeIndex->Edge);
+
+ AktEdgeIndex = NextEdgeIndex;
+ }
+
+ Changed++;
+ }
+ else if (Edge->Node2->Wsp <= Edge->Node2->Z && Edge->Node1->Wsp != NoWsp && Edge->Node1->Wsp > Edge->Node1->Z && Edge->Node1->Wsp > Edge->Node2->Z)
+ {
+ if (Edge->Node1->Wsp <= Edge->Node1->Z)
+ {
+ dump_error(__FILE__, __LINE__, "Der Kantenstartknoten %d ist unter Gelände aber nass", Edge->Node1->Nr);
+ }
+
+ Edge->Node2->Wsp = Edge->Node2->Z + 1;
+
+ // Hier jetzt neue potentielle Kanten aufnehmen
+ TEdgeIndex *AktEdgeIndex = Edge->Node2->EdgeIndex;
+ while (AktEdgeIndex)
+ {
+ TEdgeIndex *NextEdgeIndex = AktEdgeIndex->NextEdgeIndex;
+
+ Temp2EdgeList->Add(AktEdgeIndex->Edge);
+
+ AktEdgeIndex = NextEdgeIndex;
+ }
+
+ Changed++;
+ }
+ else
+ {
+ // Eine Bedingung wurde geändert
+ }
}
} while (Changed > 0);
@@ -2501,26 +2436,25 @@
// Testen wir mal, ob es hier einen Übergang gibt
- if (Wsp1 - Z1 <= 0 && Wsp2 - Z2 > 0 ||
- Wsp1 - Z1 > 0 && Wsp2 - Z2 <= 0)
+ if ((Wsp1 - Z1 <= 0 && Wsp2 - Z2 > 0) || (Wsp1 - Z1 > 0 && Wsp2 - Z2 <= 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 && Wsp2 - Z2 > 0)
- {
- D1 = Z1 - Wsp1;
- D2 = Wsp2 - Z2;
- }
+ if (Wsp1 - Z1 <= 0 && Wsp2 - Z2 > 0)
+ {
+ D1 = Z1 - Wsp1;
+ D2 = Wsp2 - Z2;
+ }
else
- {
+ {
D1 = Wsp1 - Z1;
D2 = Z2 - Wsp2;
}
- if (D1 < 0.0 || D2 < 0.0)
+ 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);
}
Modified: trunk/src/tools.h
===================================================================
--- trunk/src/tools.h 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/tools.h 2007-07-15 18:01:23 UTC (rev 90)
@@ -21,15 +21,6 @@
#include "shape.h"
#include "xy.h"
-
-#ifdef __BORLANDC__
-#define INT64 __int64
-#define INT64SUFF(x) x##L
-#else
-#define INT64 long long int
-#define INT64SUFF(x) x##ULL
-#endif
-
typedef unsigned char byte;
//---------------------------------------------------------------------------
@@ -49,10 +40,6 @@
void write_warning(int WarningNr, char *format, ...);
void write_fortschritt(char *format, ...);
void GetTimeAndDate(long* Secs, long* Mins, long* Hours, long* Days = 0, long* Months = 0, long* Years = 0);
-std::string UnsignedInt32ToBin (unsigned long Value, char *Spaces);
-std::string UnsignedInt64ToBin (unsigned INT64 Value);
-std::string UnsignedInt64ToDez (unsigned INT64 Value);
-unsigned INT64 CalcXYKombi (double X, double Y);
void Swap2Bytes(void *Bytes);
void Swap4Bytes(void *Bytes);
void Swap8Bytes(void *Bytes);
Modified: trunk/src/wsplgen.cpp
===================================================================
--- trunk/src/wsplgen.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/wsplgen.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -186,13 +186,19 @@
if (ElementList->size() == 0)
{
if (false == Triangulate (NodeList, ElementList, BegrenzungsPolygon, Parameter.DebugLevel)) return (false);
+ }
- std::string TriElementFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_tri.shp");
- if (Parameter.IsSetSaveTri && Parameter.DebugLevel >= 8) SaveElements(TriElementFileName, ElementList, 0, Parameter.DebugLevel);
+ if (Parameter.IsSetSaveTri)
+ {
+ std::string FileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_elements-tri.shp");
+ SaveElements(FileName, ElementList, 0, Parameter.DebugLevel);
}
- std::string TriNetzFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_tri.2dm");
- if (Parameter.IsSetSaveTri) SaveNet(TriNetzFileName, NodeList, ElementList, Parameter.DebugLevel);
+ if (Parameter.IsSetSave2DM)
+ {
+ std::string TriNetzFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_input.2dm");
+ SaveNet(TriNetzFileName, NodeList, ElementList, Parameter.DebugLevel);
+ }
delete BegrenzungsPolygon;
@@ -213,7 +219,7 @@
// Hier werden die Kanten drin verwaltet
// Die Kanten werden im Moment noch aus den Elementen generiert
- // Dieser Umweg ist eigendlich nicht notwendig
+ // Dieser Umweg ist eigentlich nicht notwendig
// Der durchschnittliche Abstand der Knoten (bzw. die Kantenlänge) wird dabei mit ermittelt.
// Das DGM sollte einigermassen homogen sein
TEdgeList* EdgeList = new TEdgeList;
@@ -235,14 +241,14 @@
// werden die Profile entsprechend fein interpoliert
// Dabei muss der Faktor zwischen Kantenlänge in Metern
// und Station in Centimetern beachtet werden
- ProfilList->InterpoliereProfile(AvgDistance * 8.0);
+ ProfilList->InterpoliereProfile(AvgDistance * 4.0);
// if (ProfilList->size() < 200) ProfilList->InterpoliereProfile(AvgDistance * 4.0);
// if (ProfilList->size() < 200) ProfilList->InterpoliereProfile(AvgDistance * 2.0);
// if (ProfilList->size() < 200) ProfilList->InterpoliereProfile(AvgDistance * 1.0);
// Jetzt die Stützstellen auffüllen
- ProfilList->FillProfile(AvgDistance / 4.0, -1, Parameter.DebugLevel);
+ ProfilList->FillProfile(AvgDistance / 2.0, -1, Parameter.DebugLevel);
// Mal wieder Zwischenergebnisse produzieren
std::string ProfilFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_interpolierte_profile.shp");
@@ -333,6 +339,15 @@
std::string ElementeFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_elemente.shp");
SaveElements(ElementeFileName, ElementList, Parameter.Von, Parameter.DebugLevel);
+ if (Parameter.IsSetSaveSol)
+ {
+ std::string FileName = ExchangeFileExt(Parameter.FileNameAusgabe, ".2dm");
+ SaveNet(FileName, NodeList, ElementList, Parameter.DebugLevel);
+
+ std::string SolFileName = ExchangeFileExt(Parameter.FileNameAusgabe, ".sol");
+ SaveSol(SolFileName, NodeList, Parameter.DebugLevel);
+ }
+
write_fortschritt("->Freigeben des Speichers der Elemente gestartet\n");
delete ElementList;
ElementList = 0;
@@ -343,9 +358,6 @@
std::string KnotenFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_knoten.shp");
SaveNodes(KnotenFileName, NodeList, Parameter.DebugLevel);
- std::string SolFileName = ExchangeFileExt(Parameter.FileNameAusgabe, ".sol");
- SaveSol(SolFileName, NodeList, Parameter.DebugLevel);
-
// Speichern der Ergebnispolygone
SavePolygone(Parameter.FileNameAusgabe, ErgebnisPolygone, Parameter.DebugLevel);
Modified: trunk/src/wsplgen.h
===================================================================
--- trunk/src/wsplgen.h 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/wsplgen.h 2007-07-15 18:01:23 UTC (rev 90)
@@ -10,8 +10,19 @@
// Read the file COPYING coming with WSPLGEN for details.
//
-const char Version[] = "1.1.0";
+const char Version[] = "1.1.1";
+// Es wird die Umhüllung bei TINs gelesen und benutzt um inaktive Kanten zu eleminieren
+
+// Falls das Begrenzungpolygon nicht beschnitten werden muss,
+// wird trotzdem die entsprechende Endmeldung ausgegeben
+
+// Parameter SAVESOL eingeführt
+
+// Man kann jetzt auch die eingelesenen Knoten speichern
+
+// const char Version[] = "1.1.0";
+
// Das Begrenzungspolygon wird nun als konvexe Hülle generiert (qhull.cpp ist neu)
// Es wird nicht mehr versucht mindestens 200 interpolierte Profile zu erzeugen (siehe wsplgen.cpp drei Zeilen mit Kommentaren)
Modified: trunk/src/xy.cpp
===================================================================
--- trunk/src/xy.cpp 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/xy.cpp 2007-07-15 18:01:23 UTC (rev 90)
@@ -340,7 +340,7 @@
if (alpha == 0) return (NOT_INSIDE); // not inside
if (alpha == 4) return (INSIDE); // inside
if (alpha == -4) return (INSIDE); // inside
- if (alpha == -1) return (ON_LINE); // on line
+ if (alpha == -1) return (ON_LINE); // on line
if (alpha == 2) return (ON_LINE); // on line twisted
if (alpha == -2) return (ON_LINE); // on line twisted
@@ -390,7 +390,7 @@
{
write_fortschritt("->Beschneiden des Begrenzungspolygon gestartet\n");
- write_fortschritt("Beschneidung mit Profil %.4f\n", CutProfil->Station / 10000);
+ write_fortschritt("Beschneidung mit Profil %.4f\n", CutProfil->Station / 10000.0);
// Zuerst (wenn notwendig )den ersten Punkt am Ende hinzufügen
TXY* XyFirst = *begin();
@@ -620,11 +620,13 @@
i++;
}
+ write_fortschritt("<-Beschneiden des Begrenzungspolygon beendet\n");
+
return (SideZero);
}
else if (After0 == -1 || After1 == -1)
{
- dump_error(__FILE__, __LINE__, "Es wurden keine zwei Schnittpunkte gefunden.\n");
+ dump_error(__FILE__, __LINE__, "Es wurden nur ein Schnittpunkt gefunden.\n");
return (0);
}
@@ -1480,7 +1482,7 @@
if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 5000 == 0) || (Count % 50000 == 0))
{
- write_fortschritt("%d von %d Elementen, %d Elemente angepasst\n", Count, size(), ChangeCount);
+ write_fortschritt("%d von %d Elementen, %d Elemente angepasst\n", Count, size(), ChangeCount);
}
// Hier werden die zum Löschen markierten Elemente ignoriert.
Modified: trunk/src/xy.h
===================================================================
--- trunk/src/xy.h 2007-06-07 08:48:39 UTC (rev 89)
+++ trunk/src/xy.h 2007-07-15 18:01:23 UTC (rev 90)
@@ -33,6 +33,7 @@
const int NoZ = -1000000;
const int GrabenZ = -999999;
const int DammZ = 999999;
+const int NotValid = -999999;
//----------------------------------------------------------------------------
class TXY;
More information about the Wsplgen-commits
mailing list