[Wsplgen-commits] r59 - trunk/src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Sep 11 08:03:15 CEST 2006
Author: mrchip
Date: 2006-09-11 08:03:14 +0200 (Mon, 11 Sep 2006)
New Revision: 59
Modified:
trunk/src/file.cpp
trunk/src/shape.cpp
trunk/src/tools.cpp
trunk/src/tri.cpp
trunk/src/wsplgen.cpp
trunk/src/wsplgen.h
trunk/src/xy.cpp
trunk/src/xy.h
Log:
Es wurde in Fehler beim Erzeugen der D?\195?\164mme und Gr?\195?\164ben behoben.
Modified: trunk/src/file.cpp
===================================================================
--- trunk/src/file.cpp 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/file.cpp 2006-09-11 06:03:14 UTC (rev 59)
@@ -2743,7 +2743,7 @@
}
//---------------------------------------------------------------------------
-int OutElement(int AnzPolygone, TElement *Element, int TopoDiff, DBFHandle PolygonDBFHandle, SHPHandle PolygonSHPHandle)
+int OutElement(int AnzPolygone, TElement *Element, int TopoDiff, DBFHandle PolygonDBFHandle, SHPHandle PolygonSHPHandle, SHPObject *psShape, double *x, double *y, double *z)
{
if (Element->Typ == TRI)
{
@@ -2783,9 +2783,6 @@
if (Depth < TopoDiff) Depth = TopoDiff;
- double x[4];
- double y[4];
- double z[4];
double win = ThreeToWin (Node2->X, Node2->Y, Node1->X, Node1->Y, Node3->X, Node3->Y, 0);
@@ -2819,9 +2816,7 @@
z[2] = 0.0;
z[3] = 0.0;
- SHPObject *psShape = SHPCreateSimpleObject(SHPT_POLYGON, 4, x, y, z);
SHPWriteObject(PolygonSHPHandle, -1, psShape);
- SHPDestroyObject(psShape);
DBFWriteDoubleAttribute(PolygonDBFHandle, AnzPolygone, 0, Topo);
DBFWriteDoubleAttribute(PolygonDBFHandle, AnzPolygone, 1, Wsp);
@@ -2839,11 +2834,11 @@
TElement *TempElement = 0;
TempElement = new TElement(Node1, Node2, Node3);
- AnzPolygone = OutElement(AnzPolygone, TempElement, TopoDiff, PolygonDBFHandle, PolygonSHPHandle);
+ AnzPolygone = OutElement(AnzPolygone, TempElement, TopoDiff, PolygonDBFHandle, PolygonSHPHandle, psShape, x, y, z);
delete TempElement;
TempElement = new TElement(Node1, Node3, Node4);
- AnzPolygone = OutElement(AnzPolygone, TempElement, TopoDiff, PolygonDBFHandle, PolygonSHPHandle);
+ AnzPolygone = OutElement(AnzPolygone, TempElement, TopoDiff, PolygonDBFHandle, PolygonSHPHandle, psShape, x, y, z);
delete TempElement;
}
@@ -2883,6 +2878,12 @@
SHPHandle SHPHandle = SHPCreate(FileName.c_str(), SHPT_POLYGON);
+ double x[4];
+ double y[4];
+ double z[4];
+
+ SHPObject *psShape = SHPCreateSimpleObject(SHPT_POLYGON, 4, x, y, z);
+
int AnzPolygone = 0;
for (TElementList::iterator i=ElementList->begin(); i != ElementList->end(); i++)
{
@@ -2893,13 +2894,16 @@
TElement *Element = *i;
- AnzPolygone = OutElement(AnzPolygone, Element, TopoDiff, DBFHandle, SHPHandle);
+ AnzPolygone = OutElement(AnzPolygone, Element, TopoDiff, DBFHandle, SHPHandle, psShape, x, y, z);
}
- write_fortschritt("%d von %d Elementen gespeichert\n", AnzPolygone, ElementList->size());
+ SHPDestroyObject(psShape);
+
SHPClose(SHPHandle);
DBFClose(DBFHandle);
+ write_fortschritt("%d von %d Elementen gespeichert\n", AnzPolygone, ElementList->size());
+
write_fortschritt("<-Speichern der Elemente beendet\n");
return (true);
@@ -2938,6 +2942,12 @@
SHPHandle SHPHandle = SHPCreate(FileName.c_str(), SHPT_POINT);
+ double X = 0.0;
+ double Y = 0.0;
+ double Z = 0.0;
+
+ SHPObject *psShape = SHPCreateSimpleObject(SHPT_POINT, 1, &X, &Y, &Z);
+
int AnzNodes = NodeList->size();
int Count = 0;
for (TNodeList::iterator i=NodeList->begin(); i != NodeList->end(); i++)
@@ -2951,13 +2961,11 @@
if (Node->Z != NoZ)
{
- double X = Node->X / 100.0;
- double Y = Node->Y / 100.0;
- double Z = 0.0;
+ X = Node->X / 100.0;
+ Y = Node->Y / 100.0;
+ Z = 0.0;
- SHPObject *psShape = SHPCreateSimpleObject(SHPT_POINT, 1, &X, &Y, &Z);
SHPWriteObject(SHPHandle, -1, psShape);
- SHPDestroyObject(psShape);
DBFWriteDoubleAttribute(DBFHandle, Count, 0, Node->Z / 100.0);
@@ -2979,11 +2987,14 @@
AnzNodes--;
}
}
- write_fortschritt("%d von %d Knoten gespeichert\n", Count, AnzNodes);
+ SHPDestroyObject(psShape);
+
SHPClose(SHPHandle);
DBFClose(DBFHandle);
+ write_fortschritt("%d von %d Knoten gespeichert\n", Count, AnzNodes);
+
write_fortschritt("<-Speichern der Knoten beendet\n");
return (true);
@@ -3027,9 +3038,15 @@
double y[2];
double z[2];
+ x[0] = 0.0;
+ x[1] = 0.0;
+ y[0] = 0.0;
+ y[1] = 0.0;
z[0] = 0.0;
z[1] = 0.0;
+ SHPObject *psShape = SHPCreateSimpleObject(SHPT_ARC, 2, x, y, z);
+
int Count = 0;
for (TEdgeVector::iterator i = EdgeList->EdgeVector.begin(); i != EdgeList->EdgeVector.end(); i++)
{
@@ -3051,9 +3068,7 @@
x[1] = Node2->X / 100.0;
y[1] = Node2->Y / 100.0;
- SHPObject *psShape = SHPCreateSimpleObject(SHPT_ARC, 2, x, y, z);
SHPWriteObject(SHPHandle, -1, psShape);
- SHPDestroyObject(psShape);
DBFWriteIntegerAttribute(DBFHandle, Count, 0, Nr1);
DBFWriteIntegerAttribute(DBFHandle, Count, 1, Nr2);
@@ -3062,11 +3077,13 @@
Count++;
}
- write_fortschritt("%d von %d Kanten gespeichert\n", Count, EdgeList->EdgeVector.size());
+ SHPDestroyObject(psShape);
DBFClose(DBFHandle);
SHPClose(SHPHandle);
+ write_fortschritt("%d von %d Kanten gespeichert\n", Count, EdgeList->EdgeVector.size());
+
write_fortschritt("<-Speichern der Kanten beendet\n");
return (true);
Modified: trunk/src/shape.cpp
===================================================================
--- trunk/src/shape.cpp 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/shape.cpp 2006-09-11 06:03:14 UTC (rev 59)
@@ -664,7 +664,7 @@
/* 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 SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject)
+int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject* psObject)
{
int nRecordOffset, i, nRecordSize;
uchar *pabyRec;
@@ -948,9 +948,9 @@
/* -------------------------------------------------------------------- */
if( fseek(psSHP->fpSHP, nRecordOffset, 0) != 0 || fwrite(pabyRec, nRecordSize, 1, psSHP->fpSHP) < 1 )
{
- printf( "Error in fseek() or fwrite().\n" );
- free(pabyRec);
- return (-1);
+ free(pabyRec);
+ dump_error(__FILE__, __LINE__, "Error in fseek() or fwrite().\n");
+ return (-1);
}
free(pabyRec);
Modified: trunk/src/tools.cpp
===================================================================
--- trunk/src/tools.cpp 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/tools.cpp 2006-09-11 06:03:14 UTC (rev 59)
@@ -1985,6 +1985,11 @@
{
TProfil* Profil = *i;
+ if (P0x < Profil->MinX && P1x < Profil->MinX) continue;
+ if (P0x > Profil->MaxX && P1x > Profil->MaxX) continue;
+ if (P0y < Profil->MinY && P1y < Profil->MinY) continue;
+ if (P0y > Profil->MaxY && P1y > Profil->MaxY) continue;
+
TPoint* S0 = 0;
TPoint* S1 = 0;
Modified: trunk/src/tri.cpp
===================================================================
--- trunk/src/tri.cpp 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/tri.cpp 2006-09-11 06:03:14 UTC (rev 59)
@@ -400,6 +400,9 @@
// SaveNet("_tmp.2dm", NodeList, ElementList, DebugLevel);
+
+ write_fortschritt("->Löschen der überschüssigen Elemente gestartet\n");
+
int Count = 0;
for (TElementList::iterator i=ElementList->begin(); i != ElementList->end(); i++)
{
@@ -453,6 +456,8 @@
}
}
+ write_fortschritt("<-Löschen der überschüssigen Elemente beendet\n");
+
write_fortschritt("<-Triangulierung der Knoten beendet\n");
return (true);
Modified: trunk/src/wsplgen.cpp
===================================================================
--- trunk/src/wsplgen.cpp 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/wsplgen.cpp 2006-09-11 06:03:14 UTC (rev 59)
@@ -128,7 +128,7 @@
InterpolateWsp(&ProfilList, WspProfilList, Parameter.DebugLevel);
delete WspProfilList;
- WspProfilList = 0;
+ WspProfilList = 0;
// if (Parameter.DebugLevel >= 5) SaveProfile("debug_output_02_Profile_ORIGINAL_mit_WSP.shp", &ProfilList, Parameter.DebugLevel);
@@ -170,8 +170,10 @@
{
if (false == Triangulate (&NodeList, ElementList, &BegrenzungsPolygon, Parameter.DebugLevel)) return (false);
- std::string TriNetzFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_trianguliertes_netz.2dm");
+ std::string TriNetzFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_tri.2dm");
if (Parameter.IsSetSaveTri) SaveNet(TriNetzFileName, &NodeList, ElementList, Parameter.DebugLevel);
+ std::string TriElementFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_tri.shp");
+ if (Parameter.IsSetSaveTri) SaveElements(TriElementFileName, ElementList, 0, Parameter.DebugLevel);
}
NodeList.SortByNr();
Modified: trunk/src/wsplgen.h
===================================================================
--- trunk/src/wsplgen.h 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/wsplgen.h 2006-09-11 06:03:14 UTC (rev 59)
@@ -10,8 +10,14 @@
// Read the file COPYING coming with WSPLGEN for details.
//
-const char Version[] = "0.9.16 r2";
+const char Version[] = "0.9.17 r1";
+// Ein Fehler bei der Erzeugung von Dämmen und Gräben wurde behoben (entartete Elemente).
+// Die triangulierten Netze werden jetzt auch als SHP-Datei gespeichert.
+// Die Speicherverwaltung beim Speichern von Elementen, Knoten und Kanten wurde verbessert.
+
+// const char Version[] = "0.9.16 r2";
+
// Ein Fehler bei der Erzeugung von Dämmen und Gräben wurde behoben.
// Kleine Änderungen bei den Fortschrittsanzeigen (u.a. Dauerberechnung der Triangulierung)
Modified: trunk/src/xy.cpp
===================================================================
--- trunk/src/xy.cpp 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/xy.cpp 2006-09-11 06:03:14 UTC (rev 59)
@@ -1038,10 +1038,14 @@
int MaxNodeNr = NodeList->MaxNr;
int ChangeCount = 0;
-
int Count = 0;
for (unsigned int i = 0; i < size(); i++)
{
+ TElement* Element = (*this)[i];
+
+ // Hier werden die zum Löschen markierten Elemente ignoriert.
+ if (Element->Typ == NO_ELEMENT) continue;
+
Count++;
if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 5000 == 0) || (Count % 50000 == 0))
@@ -1049,11 +1053,6 @@
write_fortschritt("%d von %d Elementen, %d Elemente angepasst\n", Count, size(), ChangeCount);
}
- TElement* Element = (*this)[i];
-
- // Hier werden die zum löschen markierten Elemente ignoriert.
- if (Element->Typ == NO_ELEMENT) continue;
-
// Hier werden die neuen Elemente wieder auf einen korrekten Typ gesetzt und dann ignoriert.
if (Element->Typ == NEWTRI)
{
@@ -1074,20 +1073,22 @@
double dummyMeter = 0.0;
-
if (Node1->X == Node2->X && Node1->Y == Node2->Y)
{
- write_error(3214, "Knotenabstand (%.3f %.3f) - (%.3f %.3f) ist zu klein\n", Node1->X / 100.0, Node1->Y / 100.0, Node2->X / 100.0, Node2->Y / 100.0);
+ Element->Typ = NO_ELEMENT;
+ continue;
}
if (Node2->X == Node3->X && Node2->Y == Node3->Y)
{
- write_error(3214, "Knotenabstand (%.3f %.3f) - (%.3f %.3f) ist zu klein\n", Node2->X / 100.0, Node2->Y / 100.0, Node3->X / 100.0, Node3->Y / 100.0);
+ Element->Typ = NO_ELEMENT;
+ continue;
}
if (Node3->X == Node1->X && Node3->Y == Node1->Y)
{
- write_error(3214, "Knotenabstand (%.3f %.3f) - (%.3f %.3f) ist zu klein\n", Node3->X / 100.0, Node3->Y / 100.0, Node1->X / 100.0, Node1->Y / 100.0);
+ Element->Typ = NO_ELEMENT;
+ continue;
}
double XD12 = 0.0;
@@ -1127,7 +1128,7 @@
if (Node1->X == Node->X && Node1->Y == Node->Y)
{
Node->Z = ZWert;
- Schnitt12 = false;
+ Schnitt12 = false;
}
else if (Node2->X == Node->X && Node2->Y == Node->Y)
{
@@ -1745,6 +1746,11 @@
Wsp = wsp;
PointList = 0;
+
+ MinX = 0;
+ MaxX = 0;
+ MinY = 0;
+ MaxY = 0;
}
//---------------------------------------------------------------------
@@ -1762,6 +1768,12 @@
PointList->insert(NewPoint);
}
+
+ MinX = 0;
+ MaxX = 0;
+ MinY = 0;
+ MaxY = 0;
+
}
//---------------------------------------------------------------------
@@ -1776,6 +1788,11 @@
}
delete PointList;
}
+
+ MinX = 0;
+ MaxX = 0;
+ MinY = 0;
+ MaxY = 0;
}
//---------------------------------------------------------------------
@@ -1800,7 +1817,27 @@
// so wurde der Punkt auch nicht hinzugefügt
// -> er muss wieder gelöscht werden
- if (PointList->size() == Anz) delete NewPoint;
+ if (PointList->size() == Anz)
+ {
+ delete NewPoint;
+ }
+ else
+ {
+ if (PointList->size() == 1)
+ {
+ MinX = NewPoint->X;
+ MaxX = NewPoint->X;
+ MinY = NewPoint->Y;
+ MaxY = NewPoint->Y;
+ }
+ else
+ {
+ if (MinX > NewPoint->X) MinX = NewPoint->X;
+ if (MaxX < NewPoint->X) MaxX = NewPoint->X;
+ if (MinY > NewPoint->Y) MinY = NewPoint->Y;
+ if (MaxY < NewPoint->Y) MaxY = NewPoint->Y;
+ }
+ }
}
//---------------------------------------------------------------------
@@ -1838,6 +1875,21 @@
TPoint* NewPoint = new TPoint(x, y, z, Meter);
PointList->insert(NewPoint);
+
+ if (PointList->size() == 1)
+ {
+ MinX = NewPoint->X;
+ MaxX = NewPoint->X;
+ MinY = NewPoint->Y;
+ MaxY = NewPoint->Y;
+ }
+ else
+ {
+ if (MinX > NewPoint->X) MinX = NewPoint->X;
+ if (MaxX < NewPoint->X) MaxX = NewPoint->X;
+ if (MinY > NewPoint->Y) MinY = NewPoint->Y;
+ if (MaxY < NewPoint->Y) MaxY = NewPoint->Y;
+ }
}
//---------------------------------------------------------------------
@@ -2009,6 +2061,11 @@
{
TGewaesserAchse* GewaesserAchse = *g;
+ if (MaxX < GewaesserAchse->MinX) continue;
+ if (MinX > GewaesserAchse->MaxX) continue;
+ if (MaxY < GewaesserAchse->MinY) continue;
+ if (MinY > GewaesserAchse->MaxY) continue;
+
TPoint* P0 = 0;
TPoint* P1 = 0;
for (TPointList::iterator p = PointList->begin(); p != PointList->end(); p++)
Modified: trunk/src/xy.h
===================================================================
--- trunk/src/xy.h 2006-09-05 20:55:00 UTC (rev 58)
+++ trunk/src/xy.h 2006-09-11 06:03:14 UTC (rev 59)
@@ -348,6 +348,10 @@
class TProfil
{
public:
+ long MinX;
+ long MaxX;
+ long MinY;
+ long MaxY;
int Station;
TPointList* PointList;
More information about the Wsplgen-commits
mailing list