[Wsplgen-commits] r87 - trunk/src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jun 7 10:36:14 CEST 2007
Author: mrchip
Date: 2007-06-07 10:36:13 +0200 (Thu, 07 Jun 2007)
New Revision: 87
Added:
trunk/src/qhull.cpp
trunk/src/qhull.h
trunk/src/test_qhull.cpp
Modified:
trunk/src/Makefile
trunk/src/file.cpp
trunk/src/test.cpp
trunk/src/test.h
trunk/src/tools.cpp
trunk/src/tri.cpp
trunk/src/wsplgen.cpp
trunk/src/wsplgen.h
trunk/src/xy.cpp
Log:
Es wird nun die konvexe H?\195?\188lle benutzt, um das Begrenzungspolygon zu bilden.
Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/Makefile 2007-06-07 08:36:13 UTC (rev 87)
@@ -9,8 +9,8 @@
LDFLAGS=
LIBS=-lstdc++
-OBJFILES1=tools.o xy.o tri.o parameter.o file.o shape.o quadtree.o
-OBJFILES2=test_profil.o test_tools.o test_xy.o test_tri.o test_file.o test_nodes.o test_quadtree.o
+OBJFILES1=tools.o xy.o tri.o parameter.o file.o shape.o quadtree.o qhull.o
+OBJFILES2=test_profil.o test_tools.o test_xy.o test_tri.o test_file.o test_nodes.o test_quadtree.o test_qhull.o
all: ../bin/test.exe ../bin/wsplgen.exe
Modified: trunk/src/file.cpp
===================================================================
--- trunk/src/file.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/file.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -1330,7 +1330,7 @@
double Y = 0.0;
if (Calc2Schnitt(VP1->X, VP1->Y, VP2->X, VP2->Y, NP1->X, NP1->Y, NP2->X, NP2->Y, &X, &Y))
{
- write_warning(3117, "Die Profile %d unf %d schneiden sich bei (%.2f, %.2f)\n", VorProfil->Station / 1000, NachProfil->Station / 1000, X, Y);
+ write_warning(3117, "Die Profile %d und %d schneiden sich bei (%.2f, %.2f)\n", VorProfil->Station / 1000, NachProfil->Station / 1000, X, Y);
}
k++;
}
Added: trunk/src/qhull.cpp
===================================================================
--- trunk/src/qhull.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/qhull.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -0,0 +1,146 @@
+//
+// $Id$
+//
+// Copyright (C) 2005 STADT-LAND-FLUSS INGENIEURDIENSTE GmbH
+//
+// Authors:
+// Ulrich Kiel <u.kiel at S-L-F.de>
+//
+// This program is free software under the GPL (>=v2)
+// Read the file COPYING coming with WSPLGEN for details.
+//
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+//---------------------------------------------------------------------
+#include "tools.h"
+#include "qhull.h"
+
+//---------------------------------------------------------------------
+double DistanceBetween(TXY* SXy, TXY* EXy, TXY* Xy)
+{
+ double X1 = SXy->X;
+ double Y1 = SXy->Y;
+ double X2 = EXy->X;
+ double Y2 = EXy->Y;
+ double Xp = Xy->X;
+ double Yp = Xy->Y;
+
+ if (fabs(X2 - X1) < 0.0001 && fabs(Y2 - Y1) < 0.0001)
+ {
+ write_error(9999, "Die Punkte liegen zu dicht zusammen");
+ }
+ else if (fabs(X2 - X1) < 0.0001)
+ {
+ double D = Xp - X1;
+ if (Y2 > Y1) D = -D;
+ return (D);
+ }
+ else if (fabs(Y2 - Y1) < 0.0001)
+ {
+ double D = Yp - Y1;
+ if (X2 < X1) D = -D;
+ return (D);
+ }
+
+ // Die Gerade waagerecht um den Punkt X1,Y1 drehen
+ // und den Punkt Xp,Yp, mitnehmen
+
+ double alpha = atan((Y2 - Y1) / (X2 - X1));
+
+ if (X2 - X1 < 0.0) alpha = alpha + M_PI;
+ if (alpha < 0.0) alpha = alpha + 2 * M_PI;
+ if (alpha >= 2 * M_PI) alpha = alpha - 2 * M_PI;
+
+ alpha = -alpha;
+
+ // Verschiebung damit X1,Y1 Drehurprung ist
+ {
+ X2 = X2 - X1;
+ Y2 = Y2 - Y1;
+ double Xd = X2 * cos(alpha) - Y2 * sin(alpha);
+ double Yd = X2 * sin(alpha) + Y2 * cos(alpha);
+ X2 = Xd + X1;
+ Y2 = Yd + Y1;
+ }
+
+ {
+ Xp = Xp - X1;
+ Yp = Yp - Y1;
+ double Xd = Xp * cos(alpha) - Yp * sin(alpha);
+ double Yd = Xp * sin(alpha) + Yp * cos(alpha);
+ Xp = Xd + X1;
+ Yp = Yd + Y1;
+ }
+
+ double D = Yp - Y1;
+
+ return (D);
+}
+
+//---------------------------------------------------------------------
+TXY* FindPointBetween(TXYList *XYList, TXY* SXy, TXY* EXy)
+{
+ double MaxD = 0.0001;
+ TXY* MaxXy = 0;
+
+ for (TXYList::iterator i = XYList->begin(); i != XYList->end(); i++)
+ {
+ TXY* Xy = *i;
+
+ double D = DistanceBetween(SXy, EXy, Xy);
+
+ if (D > MaxD)
+ {
+ MaxD = D;
+ MaxXy = Xy;
+ }
+ }
+
+ return (MaxXy);
+}
+
+//---------------------------------------------------------------------
+void ExpandQHull(TXYList *XYList, TXYList *QHull, TXY* SXy, TXY* EXy)
+{
+ TXY* Xy = FindPointBetween(XYList, SXy, EXy);
+
+ if (Xy == 0) return;
+
+ ExpandQHull(XYList, QHull, SXy, Xy);
+ QHull->Add(Xy);
+ ExpandQHull(XYList, QHull, Xy, EXy);
+}
+
+//---------------------------------------------------------------------
+void QHull(TXYList *XYList, TXYList* QHull, int DebugLevel)
+{
+ write_fortschritt("->Erzeugen des Begrenzungspolygons gestartet\n");
+
+ if (XYList->size() < 3)
+ {
+ write_error(9999, "Es sind in der Punktliste nur %d Stützstellen vorhanden.\nEs werden aber mindestens 3 Knoten benötigt\n", XYList->size());
+ }
+
+ // Den linkesten und rechtesten Punkt suchen
+ // Die gehören beide zur konvexen Hülle
+
+ TXY* LXy = 0;
+ TXY* RXy = 0;
+ for (TXYList::iterator i = XYList->begin(); i != XYList->end(); i++)
+ {
+ TXY* Xy = *i;
+
+ if (LXy == 0 || Xy->X < LXy->X) LXy = Xy;
+ if (RXy == 0 || Xy->X > RXy->X) RXy = Xy;
+ }
+
+ QHull->Add(LXy);
+ ExpandQHull(XYList, QHull, LXy, RXy);
+ QHull->Add(RXy);
+ ExpandQHull(XYList, QHull, RXy, LXy);
+
+ write_fortschritt("<-Erzeugen des Begrenzungspolygons beendet\n");
+}
Property changes on: trunk/src/qhull.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Added: trunk/src/qhull.h
===================================================================
--- trunk/src/qhull.h 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/qhull.h 2007-06-07 08:36:13 UTC (rev 87)
@@ -0,0 +1,25 @@
+//
+// $Id$
+//
+// Copyright (C) 2005 STADT-LAND-FLUSS INGENIEURDIENSTE GmbH
+//
+// Authors:
+// Ulrich Kiel <u.kiel at S-L-F.de>
+//
+// This program is free software under the GPL (>=v2)
+// Read the file COPYING coming with WSPLGEN for details.
+//
+
+//---------------------------------------------------------------------------
+#ifndef QHULLH
+#define QHULLH
+
+//----------------------------------------------------------------------------
+#include <string>
+#include "xy.h"
+
+//---------------------------------------------------------------------------
+void QHull(TXYList *XYList, TXYList* QHull, int DebugLevel);
+
+//---------------------------------------------------------------------------
+#endif
Property changes on: trunk/src/qhull.h
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/test.cpp
===================================================================
--- trunk/src/test.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/test.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -39,6 +39,7 @@
if (argc <= 1 || strncmp(argv[1], "quadtree", 8) == 0) test_quadtree();
if (argc <= 1 || strncmp(argv[1], "file", 4) == 0) test_file();
if (argc <= 1 || strncmp(argv[1], "tri", 3) == 0) test_tri();
+ if (argc <= 1 || strncmp(argv[1], "qhull", 5) == 0) test_qhull();
}
catch (const std::runtime_error& e)
{
Modified: trunk/src/test.h
===================================================================
--- trunk/src/test.h 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/test.h 2007-06-07 08:36:13 UTC (rev 87)
@@ -20,8 +20,9 @@
extern void test_xy(void);
extern void test_profil(void);
extern void test_nodes(void);
+extern void test_quadtree(void);
extern void test_tri(void);
-extern void test_quadtree(void);
+extern void test_qhull(void);
//----------------------------------------------------------------------------
#endif
Added: trunk/src/test_qhull.cpp
===================================================================
--- trunk/src/test_qhull.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/test_qhull.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -0,0 +1,156 @@
+//
+// $Id$
+//
+// Copyright (C) 2005 STADT-LAND-FLUSS INGENIEURDIENSTE GmbH
+//
+// Authors:
+// Ulrich Kiel <u.kiel at S-L-F.de>
+//
+// This program is free software under the GPL (>=v2)
+// Read the file COPYING coming with WSPLGEN for details.
+//
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+//---------------------------------------------------------------------------
+#include <stdio.h>
+
+#include "xy.h"
+#include "file.h"
+#include "qhull.h"
+
+//---------------------------------------------------------------------
+void test_qhull(void)
+{
+ ////////////////////////////////////////
+ // Test der Bildung der konvexen Hülle
+ ////////////////////////////////////////
+
+ printf ("*************************************************************************\n");
+ printf ("Test Konvexe Hülle\n");
+
+ {
+ printf ("Test QHull 3 Knoten: ");
+
+ // Zuerst ein paar Punkte generieren
+ TXY *Xy1 = new TXY(1, 1);
+ TXY *Xy2 = new TXY(2, 9);
+ TXY *Xy3 = new TXY(3, 5);
+
+ TXYList *XyList = new TXYList();
+
+ XyList->push_back(Xy1);
+ XyList->push_back(Xy2);
+ XyList->push_back(Xy3);
+
+ TXYList* Polygon = new TXYList();
+ QHull(XyList, Polygon, 8);
+
+ if (Polygon->size() != 3) printf("Failed\n");
+ else printf("Pass\n");
+
+// SavePolygon("Ergebnisse\\Test.shp", Polygon, 8);
+
+ delete XyList;
+ Polygon->clear();
+ delete Polygon;
+ }
+
+ {
+ printf ("Test QHull 5 Knoten: ");
+
+ // Zuerst ein paar Punkte generieren
+ TXY *Xy1 = new TXY(1, 1);
+ TXY *Xy2 = new TXY(2, 9);
+ TXY *Xy3 = new TXY(3, 5);
+ TXY *Xy4 = new TXY(2, 4);
+ TXY *Xy5 = new TXY(5, 3);
+
+ TXYList *XyList = new TXYList();
+
+ XyList->push_back(Xy1);
+ XyList->push_back(Xy2);
+ XyList->push_back(Xy3);
+ XyList->push_back(Xy4);
+ XyList->push_back(Xy5);
+
+ TXYList* Polygon = new TXYList();
+ QHull(XyList, Polygon, 8);
+
+ if (Polygon->size() != 3) printf("Failed\n");
+ else printf("Pass\n");
+
+// SavePolygon("Ergebnisse\\Test.shp", Polygon, 8);
+
+ delete XyList;
+ Polygon->clear();
+ delete Polygon;
+ }
+
+ {
+ printf ("Test QHull 5 Knoten (Quadrat): ");
+
+ // Zuerst ein paar Punkte generieren
+ TXY *Xy1 = new TXY(1, 1);
+ TXY *Xy2 = new TXY(3, 1);
+ TXY *Xy3 = new TXY(3, 3);
+ TXY *Xy4 = new TXY(1, 3);
+ TXY *Xy5 = new TXY(2, 2);
+
+ TXYList *XyList = new TXYList();
+
+ XyList->push_back(Xy1);
+ XyList->push_back(Xy2);
+ XyList->push_back(Xy3);
+ XyList->push_back(Xy4);
+ XyList->push_back(Xy5);
+
+ TXYList* Polygon = new TXYList();
+ QHull(XyList, Polygon, 8);
+
+ if (Polygon->size() != 4) printf("Failed\n");
+ else printf("Pass\n");
+
+// SavePolygon("Ergebnisse\\Test.shp", Polygon, 8);
+
+ delete XyList;
+ Polygon->clear();
+ delete Polygon;
+ }
+
+ {
+ printf ("Test QHull 5 Knoten (Raute): ");
+
+ // Zuerst ein paar Punkte generieren
+ TXY *Xy1 = new TXY(1, 1);
+ TXY *Xy2 = new TXY(3, 1);
+ TXY *Xy3 = new TXY(2, 3);
+ TXY *Xy4 = new TXY(0, 3);
+ TXY *Xy5 = new TXY(2, 2);
+
+ TXYList *XyList = new TXYList();
+
+ XyList->push_back(Xy1);
+ XyList->push_back(Xy2);
+ XyList->push_back(Xy3);
+ XyList->push_back(Xy4);
+ XyList->push_back(Xy5);
+
+ TXYList* Polygon = new TXYList();
+ QHull(XyList, Polygon, 8);
+
+ if (Polygon->size() != 4) printf("Failed\n");
+ else printf("Pass\n");
+
+// SavePolygon("Ergebnisse\\Test.shp", Polygon, 8);
+
+ delete XyList;
+ Polygon->clear();
+ delete Polygon;
+ }
+
+ printf ("*************************************************************************\n");
+
+}
Property changes on: trunk/src/test_qhull.cpp
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: trunk/src/tools.cpp
===================================================================
--- trunk/src/tools.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/tools.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -23,6 +23,7 @@
#include <sys/timeb.h>
#include "tools.h"
+#include "qhull.h"
//---------------------------------------------------------------------------
extern int ReturnCode;
@@ -816,7 +817,7 @@
}
//---------------------------------------------------------------------------
-void BuildPolygon(TProfilList *ProfilList, TXYList *XyList, int DebugLevel)
+void BuildPolygon(TProfilList *ProfilList, TXYList *Polygon, int DebugLevel)
{
write_fortschritt ("->Erzeugung des Begrenzungspolygons gestartet\n");
@@ -825,8 +826,25 @@
write_error(3205, "Es gibt für das Gewaesser nur %d Querprofilspuren.\nEs werden aber mindestens 2 benötigt.\n", ProfilList->size());
}
- XyList->Clear();
+ Polygon->Clear();
+ TXYList* XyList = new TXYList();
+
+ for (TProfilList::iterator i = ProfilList->begin(); i != ProfilList->end(); i++)
+ {
+ TProfil* Profil = *i;
+
+ for (TPointList::iterator j = Profil->PointList->begin(); j != Profil->PointList->end(); j++)
+ {
+ TPoint* Point = *j;
+
+ XyList->Add(Point->X, Point->Y);
+ }
+ }
+
+ QHull(XyList, Polygon, DebugLevel);
+
+/*
int Count = 0;
TProfilList::iterator ProfilIter = ProfilList->begin();
for (unsigned int i = 0; i < ProfilList->size()-1; i++)
@@ -883,12 +901,15 @@
write_fortschritt("%d Begrenzungspunkte erzeugt\n", XyList->size());
}
}
- write_fortschritt("%d Begrenzungspunkte erzeugt\n", XyList->size());
+*/
+ write_fortschritt("%d Begrenzungspunkte erzeugt\n", Polygon->size());
+
+
if (DebugLevel >= 9)
{
write_fortschritt("Polygon:\n");
- for (TXYList::iterator j = XyList->begin(); j != XyList->end(); j++)
+ for (TXYList::iterator j = Polygon->begin(); j != Polygon->end(); j++)
{
TXY* Xy = *j;
write_fortschritt("%.3f %.3f\n", Xy->X, Xy->Y);
@@ -1028,28 +1049,20 @@
if (KnotenGeloescht > 0)
{
- do
+ for (TElementList::iterator i = ElementList->begin(); i != ElementList->end(); i++)
{
- NetChanged = false;
+ TElement *Element = *i;
- for (TElementList::iterator i = ElementList->begin(); i != ElementList->end(); i++)
+ TNode *Node1 = Element->Node1;
+ TNode *Node2 = Element->Node2;
+ TNode *Node3 = Element->Node3;
+
+ if (Node1 == Node2 || Node1 == Node3 || Node2 == Node3)
{
- TElement *Element = *i;
-
- TNode *Node1 = Element->Node1;
- TNode *Node2 = Element->Node2;
- TNode *Node3 = Element->Node3;
-
- if (Node1 == Node2 || Node1 == Node3 || Node2 == Node3)
- {
- Element->Typ = NO_ELEMENT;
- ElementeGeloescht++;
- NetChanged = true;
- i = ElementList->begin();
- break;
- }
+ Element->Typ = NO_ELEMENT;
+ ElementeGeloescht++;
}
- } while (NetChanged);
+ }
}
}
else
Modified: trunk/src/tri.cpp
===================================================================
--- trunk/src/tri.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/tri.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -416,57 +416,57 @@
int Count = 0;
for (TElementList::iterator i=ElementList->begin(); i != ElementList->end(); i++)
- {
- TElement *Element = *i;
-
- if (Element->Node1->Z == NoZ || Element->Node2->Z == NoZ || Element->Node3->Z == NoZ)
- {
- Element->Typ = NO_ELEMENT;
- continue;
- }
-
- if (BegrenzungsPolygon)
- {
- TNode* Node1 = Element->Node1;
- TNode* Node2 = Element->Node2;
- TNode* Node3 = Element->Node3;
-
- long X12 = (Node1->X + Node2->X) / 2;
- long Y12 = (Node1->Y + Node2->Y) / 2;
-
- if (!BegrenzungsPolygon->IsInsideXYList(X12, Y12))
- {
- Element->Typ = NO_ELEMENT;
- continue;
- }
-
- long X23 = (Node2->X + Node3->X) / 2;
- long Y23 = (Node2->Y + Node3->Y) / 2;
-
- if (!BegrenzungsPolygon->IsInsideXYList(X23, Y23))
- {
- Element->Typ = NO_ELEMENT;
- continue;
- }
-
- long X31 = (Node3->X + Node1->X) / 2;
- long Y31 = (Node3->Y + Node1->Y) / 2;
-
- if (!BegrenzungsPolygon->IsInsideXYList(X31, Y31))
- {
- Element->Typ = NO_ELEMENT;
- continue;
- }
- }
-
- Count++;
-
- if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 5000 == 0) || (Count % 50000 == 0))
- {
- write_fortschritt("%d von %d Elementen überprüft\n", Count, ElementList->size());
- }
- }
+ {
+ TElement *Element = *i;
+ if (Element->Node1->Z == NoZ || Element->Node2->Z == NoZ || Element->Node3->Z == NoZ)
+ {
+ Element->Typ = NO_ELEMENT;
+ continue;
+ }
+
+ if (BegrenzungsPolygon)
+ {
+ TNode* Node1 = Element->Node1;
+ TNode* Node2 = Element->Node2;
+ TNode* Node3 = Element->Node3;
+
+ long X12 = (Node1->X + Node2->X) / 2;
+ long Y12 = (Node1->Y + Node2->Y) / 2;
+
+ if (!BegrenzungsPolygon->IsInsideXYList(X12, Y12))
+ {
+ Element->Typ = NO_ELEMENT;
+ continue;
+ }
+
+ long X23 = (Node2->X + Node3->X) / 2;
+ long Y23 = (Node2->Y + Node3->Y) / 2;
+
+ if (!BegrenzungsPolygon->IsInsideXYList(X23, Y23))
+ {
+ Element->Typ = NO_ELEMENT;
+ continue;
+ }
+
+ long X31 = (Node3->X + Node1->X) / 2;
+ long Y31 = (Node3->Y + Node1->Y) / 2;
+
+ if (!BegrenzungsPolygon->IsInsideXYList(X31, Y31))
+ {
+ Element->Typ = NO_ELEMENT;
+ continue;
+ }
+ }
+
+ Count++;
+
+ if (DebugLevel >= 9 || (DebugLevel >= 1 && Count % 5000 == 0) || (Count % 50000 == 0))
+ {
+ write_fortschritt("%d von %d Elementen überprüft\n", Count, ElementList->size());
+ }
+ }
+
write_fortschritt("<-Löschen der überschüssigen Elemente beendet\n");
write_fortschritt("<-Triangulierung der Knoten beendet\n");
Modified: trunk/src/wsplgen.cpp
===================================================================
--- trunk/src/wsplgen.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/wsplgen.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -163,7 +163,7 @@
BuildPolygon(ProfilList, ProfilPolygon, Parameter.DebugLevel);
TProfil* FirstProfil = *ProfilList->begin();
- TXYList* Tmp2BegrenzungsPolygon = Tmp1BegrenzungsPolygon->Cut(ProfilPolygon, FirstProfil);
+ TXYList* Tmp2BegrenzungsPolygon = Tmp1BegrenzungsPolygon->Cut(ProfilPolygon, FirstProfil);
TProfil* LastProfil = *ProfilList->rbegin();
BegrenzungsPolygon = Tmp2BegrenzungsPolygon->Cut(ProfilPolygon, LastProfil);
@@ -187,12 +187,13 @@
{
if (false == Triangulate (NodeList, ElementList, BegrenzungsPolygon, Parameter.DebugLevel)) return (false);
- 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 && Parameter.DebugLevel >= 8) SaveElements(TriElementFileName, ElementList, 0, Parameter.DebugLevel);
}
+ std::string TriNetzFileName = ExchangeFileExt(Parameter.FileNameAusgabe, "_tri.2dm");
+ if (Parameter.IsSetSaveTri) SaveNet(TriNetzFileName, NodeList, ElementList, Parameter.DebugLevel);
+
delete BegrenzungsPolygon;
NodeList->SortByNr();
@@ -236,9 +237,9 @@
// und Station in Centimetern beachtet werden
ProfilList->InterpoliereProfile(AvgDistance * 8.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);
+// 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);
@@ -342,6 +343,9 @@
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 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/wsplgen.h 2007-06-07 08:36:13 UTC (rev 87)
@@ -10,8 +10,21 @@
// Read the file COPYING coming with WSPLGEN for details.
//
-const char Version[] = "1.0.0";
+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)
+
+// const char Version[] = "1.0.1";
+
+// Fehler beim Löschen der doppelten Knoten behoben (Endlosschleife)
+
+// const char Version[] = "1.0.0 sol";
+
+// Mit Speichern der Sols
+
+// const char Version[] = "1.0.0";
+
// Keine Änderungen
// const char Version[] = "1.0.0 rc4";
Modified: trunk/src/xy.cpp
===================================================================
--- trunk/src/xy.cpp 2006-11-29 19:25:38 UTC (rev 86)
+++ trunk/src/xy.cpp 2007-06-07 08:36:13 UTC (rev 87)
@@ -388,6 +388,10 @@
//---------------------------------------------------------------------
TXYList* TXYList::Cut(TXYList* ProfilPolygon, TProfil* CutProfil)
{
+ write_fortschritt("->Beschneiden des Begrenzungspolygon gestartet\n");
+
+ write_fortschritt("Beschneidung mit Profil %.4f\n", CutProfil->Station / 10000);
+
// Zuerst (wenn notwendig )den ersten Punkt am Ende hinzufügen
TXY* XyFirst = *begin();
TXY* XyLast = *rbegin();
@@ -624,135 +628,135 @@
return (0);
}
- else
+
+ // Damit die Reihenfolge stimmt evtl. vertauschen
+ if (After0 > After1)
{
- // Damit die Reihenfolge stimmt evtl. vertauschen
- if (After0 > After1)
- {
- int TempAfter = After0;
- double TempSX = SX0;
- double TempSY = SY0;
+ int TempAfter = After0;
+ double TempSX = SX0;
+ double TempSY = SY0;
- After0 = After1;
- SX0 = SX1;
- SY0 = SY1;
+ After0 = After1;
+ SX0 = SX1;
+ SY0 = SY1;
- After1 = TempAfter;
- SX1 = TempSX;
- SY1 = TempSY;
- }
+ After1 = TempAfter;
+ SX1 = TempSX;
+ SY1 = TempSY;
+ }
- TXYList* SideZero = new TXYList();
- TXYList* SideOne = new TXYList();
+ TXYList* SideZero = new TXYList();
+ TXYList* SideOne = new TXYList();
- TXYList::iterator iter=begin();
- unsigned int i = 0;
- while (i < (unsigned int)After0)
- {
- TXY *Xy = *iter++;
+ TXYList::iterator iter=begin();
+ unsigned int i = 0;
+ while (i < (unsigned int)After0)
+ {
+ TXY *Xy = *iter++;
- SideZero->Add(Xy->X, Xy->Y);
+ SideZero->Add(Xy->X, Xy->Y);
- i++;
- }
+ i++;
+ }
- long LSX0 = (long)(SX0 + 0.5);
- long LSY0 = (long)(SY0 + 0.5);
- SideZero->Add(LSX0, LSY0);
+ long LSX0 = (long)(SX0 + 0.5);
+ long LSY0 = (long)(SY0 + 0.5);
+ SideZero->Add(LSX0, LSY0);
- SideOne->Add(LSX0, LSY0);
+ SideOne->Add(LSX0, LSY0);
- while (i < (unsigned int)After1)
- {
- TXY *Xy = *iter++;
+ while (i < (unsigned int)After1)
+ {
+ TXY *Xy = *iter++;
- SideOne->Add(Xy->X, Xy->Y);
+ SideOne->Add(Xy->X, Xy->Y);
- i++;
- }
+ i++;
+ }
- long LSX1 = (long)(SX1 + 0.5);
- long LSY1 = (long)(SY1 + 0.5);
- SideOne->Add(LSX1, LSY1);
+ long LSX1 = (long)(SX1 + 0.5);
+ long LSY1 = (long)(SY1 + 0.5);
+ SideOne->Add(LSX1, LSY1);
- SideZero->Add(LSX1, LSY1);
+ SideZero->Add(LSX1, LSY1);
- while (i < size())
- {
- TXY *Xy = *iter++;
+ while (i < size())
+ {
+ TXY *Xy = *iter++;
- SideZero->Add(Xy->X, Xy->Y);
+ SideZero->Add(Xy->X, Xy->Y);
- i++;
- }
+ i++;
+ }
/*
- write_fortschritt("\n");
+ write_fortschritt("\n");
- int Count = 0;
- for (TXYList::iterator i=SideZero->begin(); i != SideZero->end(); i++)
- {
- TXY* Xy = *i;
+ int Count = 0;
+ for (TXYList::iterator i=SideZero->begin(); i != SideZero->end(); i++)
+ {
+ TXY* Xy = *i;
- write_fortschritt("%d %d %d\n", ++Count, Xy->X, Xy->Y);
- }
- write_fortschritt("\n");
+ write_fortschritt("%d %d %d\n", ++Count, Xy->X, Xy->Y);
+ }
+ write_fortschritt("\n");
- Count = 0;
- for (TXYList::iterator i=SideOne->begin(); i != SideOne->end(); i++)
- {
- TXY* Xy = *i;
+ Count = 0;
+ for (TXYList::iterator i=SideOne->begin(); i != SideOne->end(); i++)
+ {
+ TXY* Xy = *i;
- write_fortschritt("%d %d %d\n", ++Count, Xy->X, Xy->Y);
- }
- write_fortschritt("\n");
+ write_fortschritt("%d %d %d\n", ++Count, Xy->X, Xy->Y);
+ }
+ write_fortschritt("\n");
*/
- // Nun haben wir 2 Polygone
- // Als nächstes wird getestet, welches das richtige ist.
+ // Nun haben wir 2 Polygone
+ // Als nächstes wird getestet, welches das richtige ist.
- // Falls das ProfilPolygon größer als das Begrenzungspolygon ist,
- // werden hier die Punkte innerhalb gezählt
- int IsInsideZeroCount = 0;
- for (TXYList::iterator i=SideZero->begin(); i != SideZero->end(); i++)
- {
- TXY* Xy = *i;
+ // Falls das ProfilPolygon größer als das Begrenzungspolygon ist,
+ // werden hier die Punkte innerhalb gezählt
+ int IsInsideZeroCount = 0;
+ for (TXYList::iterator i=SideZero->begin(); i != SideZero->end(); i++)
+ {
+ TXY* Xy = *i;
- if (ProfilPolygon->IsInsideXYList(Xy->X, Xy->Y)) IsInsideZeroCount++;
- }
+ if (ProfilPolygon->IsInsideXYList(Xy->X, Xy->Y)) IsInsideZeroCount++;
+ }
- int IsInsideOneCount = 0;
- for (TXYList::iterator i=SideOne->begin(); i != SideOne->end(); i++)
- {
- TXY* Xy = *i;
+ int IsInsideOneCount = 0;
+ for (TXYList::iterator i=SideOne->begin(); i != SideOne->end(); i++)
+ {
+ TXY* Xy = *i;
- if (ProfilPolygon->IsInsideXYList(Xy->X, Xy->Y)) IsInsideOneCount++;
- }
+ if (ProfilPolygon->IsInsideXYList(Xy->X, Xy->Y)) IsInsideOneCount++;
+ }
- // Falls das ProfilPolygon kleiner als das Begrenzungspolygon ist,
- // werden hier die Punkte innerhalb gezählt
- for (TXYList::iterator i=ProfilPolygon->begin(); i != ProfilPolygon->end(); i++)
- {
- TXY* Xy = *i;
+ // Falls das ProfilPolygon kleiner als das Begrenzungspolygon ist,
+ // werden hier die Punkte innerhalb gezählt
+ for (TXYList::iterator i=ProfilPolygon->begin(); i != ProfilPolygon->end(); i++)
+ {
+ TXY* Xy = *i;
- if (SideZero->IsInsideXYList(Xy->X, Xy->Y)) IsInsideZeroCount++;
- if (SideOne->IsInsideXYList(Xy->X, Xy->Y)) IsInsideOneCount++;
- }
+ if (SideZero->IsInsideXYList(Xy->X, Xy->Y)) IsInsideZeroCount++;
+ if (SideOne->IsInsideXYList(Xy->X, Xy->Y)) IsInsideOneCount++;
+ }
- delete CutXyList;
+ delete CutXyList;
- if (IsInsideZeroCount > IsInsideOneCount)
- {
- delete SideOne;
- return (SideZero);
- }
- else
- {
- delete SideZero;
- return (SideOne);
- }
+ write_fortschritt("<-Beschneiden des Begrenzungspolygon beendet\n");
+
+ if (IsInsideZeroCount > IsInsideOneCount)
+ {
+ delete SideOne;
+ return (SideZero);
}
+ else
+ {
+ delete SideZero;
+ return (SideOne);
+ }
}
//---------------------------------------------------------------------
@@ -1383,7 +1387,7 @@
MinY = MinY - DiffY;
MaxY = MaxY - DiffY;
- for (iterator i = begin(); i != end(); i++)
+ for (iterator i = begin(); i != end(); i++)
{
TNode* Node = *i;
More information about the Wsplgen-commits
mailing list