Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CityDoctor
CityDoctor2
Commits
0c03ab39
Commit
0c03ab39
authored
Aug 12, 2026
by
Numanoglu
Browse files
Orienation corrected, simplified and getter added
parent
82126347
Pipeline
#12428
failed with stage
in 88 minutes and 25 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CityDoctorParent/Extensions/CityDoctorHealer/src/main/java/de/hft/stuttgart/citydoctor2/healing/SweepEdge.java
View file @
0c03ab39
...
@@ -6,21 +6,11 @@ import de.hft.stuttgart.citydoctor2.math.Plane;
...
@@ -6,21 +6,11 @@ import de.hft.stuttgart.citydoctor2.math.Plane;
import
de.hft.stuttgart.citydoctor2.math.UnitVector3d
;
import
de.hft.stuttgart.citydoctor2.math.UnitVector3d
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
enum
SweepIntersectionPosition
{
ON_EDGE
,
BEFORE_SWEEP_VERTEX
,
BEYOND_OUTGOING_EDGE_TARGET
,
UNKNOWN
}
public
class
SweepEdge
{
public
class
SweepEdge
{
private
Edge
outgoingEdge
;
private
Edge
outgoingEdge
;
private
Vertex
sweepVertex
;
private
Vertex
outgoingEdgeTarget
;
private
Vector3d
referencePoint
;
private
Vector3d
referencePoint
;
private
UnitVector3d
direction
;
private
UnitVector3d
direction
;
private
double
outgoingEdgeLength
;
private
boolean
valid
=
false
;
private
boolean
valid
=
false
;
public
SweepEdge
(
Edge
outgoingEdge
,
Vertex
sweepVertex
,
double
minSweepEdgeLength
)
{
public
SweepEdge
(
Edge
outgoingEdge
,
Vertex
sweepVertex
,
double
minSweepEdgeLength
)
{
...
@@ -29,22 +19,19 @@ public class SweepEdge {
...
@@ -29,22 +19,19 @@ public class SweepEdge {
return
;
return
;
}
}
Vertex
outgoingEdgeTarge
t
=
outgoingEdge
.
getOppositeVertex
(
sweepVertex
);
Vertex
referencePoin
t
=
outgoingEdge
.
getOppositeVertex
(
sweepVertex
);
if
(
outgoingEdgeTarge
t
==
null
)
{
if
(
referencePoin
t
==
null
)
{
return
;
return
;
}
}
Vector3d
edgeVector
=
outgoingEdgeTarget
.
minus
(
sweepVertex
);
Vector3d
edgeVector
=
sweepVertex
.
minus
(
referencePoint
);
if
(
edgeVector
.
getLength
()
<
minSweepEdgeLength
)
{
if
(
edgeVector
.
getLength
()
<
minSweepEdgeLength
)
{
return
;
return
;
}
}
this
.
outgoingEdge
=
outgoingEdge
;
this
.
outgoingEdge
=
outgoingEdge
;
this
.
sweepVertex
=
sweepVertex
;
this
.
referencePoint
=
referencePoint
;
this
.
outgoingEdgeTarget
=
outgoingEdgeTarget
;
this
.
referencePoint
=
sweepVertex
;
this
.
direction
=
edgeVector
.
normalize
();
this
.
direction
=
edgeVector
.
normalize
();
this
.
outgoingEdgeLength
=
edgeVector
.
getLength
();
this
.
valid
=
true
;
this
.
valid
=
true
;
}
}
...
@@ -91,30 +78,25 @@ public class SweepEdge {
...
@@ -91,30 +78,25 @@ public class SweepEdge {
return
true
;
return
true
;
}
}
//------------------------------------------------------------------------------------------------------
public
boolean
isSweepableEdge
(
Vector3d
intersectionPoint
,
double
eps
)
{
// Nicht mehr notwendig wegen Position- Flags- -nur noch Konfort
public
boolean
isOnEdge
(
Vector3d
intersectionPoint
,
double
eps
)
{
return
classifyIntersectionPosition
(
intersectionPoint
,
eps
)
==
SweepIntersectionPosition
.
ON_EDGE
;
}
//-------------------------------------------------------------------------------------------------------
public
SweepIntersectionPosition
classifyIntersectionPosition
(
Vector3d
intersectionPoint
,
double
eps
)
{
if
(!
valid
||
intersectionPoint
==
null
)
{
if
(!
valid
||
intersectionPoint
==
null
)
{
return
SweepIntersectionPosition
.
UNKNOWN
;
return
false
;
}
}
Vector3d
sweep
ToIntersection
=
intersectionPoint
.
minus
(
sweepVertex
);
Vector3d
reference
ToIntersection
=
intersectionPoint
.
minus
(
referencePoint
);
double
lineParameter
=
sweep
ToIntersection
.
dot
(
direction
);
double
lineParameter
=
reference
ToIntersection
.
dot
(
direction
);
if
(
lineParameter
<
-
eps
)
{
/*
return
SweepIntersectionPosition
.
BEFORE_SWEEP_VERTEX
;
* Die Kante ist aus Sicht des festen Bezugspunkts zur urspruenglichen
}
* Position des Sweep-Punktes gerichtet.
if
(
lineParameter
>
outgoingEdgeLength
+
eps
)
{
*
return
SweepIntersectionPosition
.
BEYOND_OUTGOING_EDGE_TARGET
;
* lineParameter zwischen 0 und der urspruenglichen Kantenlaenge bedeutet
}
* Verkuerzen. Ein groesserer lineParameter bedeutet Verlaengern.
return
SweepIntersectionPosition
.
ON_EDGE
;
* lineParameter kleiner eps liegt vor oder zu nah am Bezugspunkt und wird
* nicht als regulaerer Fall-2-Sweep behandelt.
*/
return
lineParameter
>=
eps
;
}
}
Edge
getOutgoingEdge
()
{
Edge
getOutgoingEdge
()
{
...
...
CityDoctorParent/Extensions/CityDoctorHealer/src/main/java/de/hft/stuttgart/citydoctor2/healing/SweepUtilities.java
View file @
0c03ab39
...
@@ -2,55 +2,31 @@ package de.hft.stuttgart.citydoctor2.healing;
...
@@ -2,55 +2,31 @@ package de.hft.stuttgart.citydoctor2.healing;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.logging.log4j.Logger
;
import
de.hft.stuttgart.citydoctor2.check.ModificationListener
;
import
de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonDistancePlaneError
;
import
de.hft.stuttgart.citydoctor2.check.error.NonPlanarPolygonDistancePlaneError
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.LinearRing
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.Polygon
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
import
de.hft.stuttgart.citydoctor2.datastructure.Vertex
;
import
de.hft.stuttgart.citydoctor2.math.Plane
;
import
de.hft.stuttgart.citydoctor2.math.Plane
;
import
de.hft.stuttgart.citydoctor2.math.Vector3d
;
/* todo: in HealPlanarPolygonSweep visit-Methode austauschen
public boolean visit(NonPlanarPolygonDistancePlaneError err, ModificationListener l) {
logger.debug("Executing Repair for NonPlanarPolygonDistancePlaneError");
SweepUtilities utils = new SweepUtilities(err);
todo: Epsilon-Werte setzen
utils.initialize();
if ( utils.calculate() ) {
utils.doHeal();
return true;
}
else {
logger.debug("Repair by Sweep not possible");
return false;
}
}
*/
public
class
SweepUtilities
{
public
class
SweepUtilities
{
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
SweepUtilities
.
class
);
private
static
final
Logger
logger
=
LogManager
.
getLogger
(
SweepUtilities
.
class
);
private
Plane
targetPlane
;
private
Plane
targetPlane
;
private
Polygon
pol
;
private
Polygon
errorPolygon
;
//todo: weitere Attribute hinzufuegen (fuer collectOutgoingEdges, ...)
// todo: Toleranzen passend initialisieren
// todo: Toleranzen passend initialisieren
private
double
minSweepEdgeLength
=
0.001
;
// Mindestlaenge einer Kante
private
double
minSweepEdgeLength
=
0.001
;
// Mindestlaenge einer Kante
private
double
maxPointPlaneDistance
=
0.001
;
// Maximalabstand zur Ebene
private
double
maxPointPlaneDistance
=
0.001
;
// Maximalabstand zur Ebene
// TODO Transformiere mit arcsin() um dem Nenner den kompl.Winkel zuzuordnen
private
double
minLinePlaneAngleRatio
=
0.001
;
// MindestNeigung: vgl. <EbenenenNormale,GeradenRichtVektor>
private
double
minLinePlaneAngleRatio
=
0.001
;
// MindestNeigung: vgl. <EbenenenNormale,GeradenRichtVektor>
private
List
<
SweepVertex
>
vert
s
;
private
List
<
SweepVertex
>
sweepVertice
s
;
public
SweepUtilities
(
NonPlanarPolygonDistancePlaneError
err
)
{
public
SweepUtilities
(
NonPlanarPolygonDistancePlaneError
err
)
{
...
@@ -59,25 +35,25 @@ public class SweepUtilities {
...
@@ -59,25 +35,25 @@ public class SweepUtilities {
}
}
targetPlane
=
err
.
getPlane
();
targetPlane
=
err
.
getPlane
();
pol
=
err
.
getPolygon
();
errorPolygon
=
err
.
getPolygon
();
}
}
public
void
initialize
()
{
public
void
initialize
()
{
if
(
pol
==
null
||
targetPlane
==
null
)
{
if
(
errorPolygon
==
null
||
targetPlane
==
null
)
{
logger
.
error
(
"Cannot initialize sweep: polygon or target plane is null"
);
logger
.
error
(
"Cannot initialize sweep: polygon or target plane is null"
);
vert
s
=
null
;
sweepVertice
s
=
null
;
return
;
return
;
}
}
int
nVerts
=
countSweepVertices
(
pol
);
int
nVerts
=
countSweepVertices
(
errorPolygon
);
vert
s
=
new
ArrayList
<>(
nVerts
);
// <Vertex>??
sweepVertice
s
=
new
ArrayList
<>(
nVerts
);
// <Vertex>??
collectSweepVertices
(
pol
);
collectSweepVertices
(
errorPolygon
);
for
(
SweepVertex
v
:
vert
s
)
{
for
(
SweepVertex
v
:
sweepVertice
s
)
{
v
.
collectOutgoingEdges
(
pol
,
minSweepEdgeLength
);
v
.
collectOutgoingEdges
(
errorPolygon
,
minSweepEdgeLength
);
v
.
initStatus
(
targetPlane
,
maxPointPlaneDistance
);
v
.
initStatus
(
targetPlane
,
maxPointPlaneDistance
);
}
}
...
@@ -85,7 +61,7 @@ public class SweepUtilities {
...
@@ -85,7 +61,7 @@ public class SweepUtilities {
public
boolean
calculate
()
{
public
boolean
calculate
()
{
if
(
vert
s
==
null
||
targetPlane
==
null
)
{
if
(
sweepVertice
s
==
null
||
targetPlane
==
null
)
{
return
false
;
return
false
;
}
}
...
@@ -106,8 +82,8 @@ public class SweepUtilities {
...
@@ -106,8 +82,8 @@ public class SweepUtilities {
}
}
*/
*/
for
(
SweepVertex
v
:
vert
s
)
{
for
(
SweepVertex
v
:
sweepVertice
s
)
{
v
.
calculateNewPoint
(
targetPlane
,
pol
,
minSweepEdgeLength
,
minLinePlaneAngleRatio
);
v
.
calculateNewPoint
(
targetPlane
,
errorPolygon
,
minSweepEdgeLength
,
minLinePlaneAngleRatio
);
}
}
return
canHeal
();
return
canHeal
();
...
@@ -120,14 +96,14 @@ public class SweepUtilities {
...
@@ -120,14 +96,14 @@ public class SweepUtilities {
return
;
return
;
}
}
for
(
SweepVertex
v
:
vert
s
)
{
for
(
SweepVertex
v
:
sweepVertice
s
)
{
v
.
doHeal
();
v
.
doHeal
();
}
}
}
}
private
boolean
canHeal
()
{
private
boolean
canHeal
()
{
for
(
SweepVertex
v
:
vert
s
)
{
for
(
SweepVertex
v
:
sweepVertice
s
)
{
SweepVertexStatus
status
=
v
.
getStatus
();
SweepVertexStatus
status
=
v
.
getStatus
();
switch
(
status
)
{
switch
(
status
)
{
case
ON_PLANE:
case
ON_PLANE:
...
@@ -148,7 +124,7 @@ public class SweepUtilities {
...
@@ -148,7 +124,7 @@ public class SweepUtilities {
private
boolean
hasErrorStatus
()
{
private
boolean
hasErrorStatus
()
{
for
(
SweepVertex
v
:
vert
s
)
{
for
(
SweepVertex
v
:
sweepVertice
s
)
{
SweepVertexStatus
status
=
v
.
getStatus
();
SweepVertexStatus
status
=
v
.
getStatus
();
if
(
status
==
SweepVertexStatus
.
ERROR
||
status
==
SweepVertexStatus
.
NONE
)
{
if
(
status
==
SweepVertexStatus
.
ERROR
||
status
==
SweepVertexStatus
.
NONE
)
{
return
true
;
return
true
;
...
@@ -173,7 +149,7 @@ public class SweepUtilities {
...
@@ -173,7 +149,7 @@ public class SweepUtilities {
if
(
ring
==
null
)
{
if
(
ring
==
null
)
{
return
0
;
return
0
;
}
}
return
Math
.
max
(
0
,
ring
.
getVertices
().
size
()
-
1
);
//redundan
d
e übervorsicht
return
Math
.
max
(
0
,
ring
.
getVertices
().
size
()
-
1
);
//redundan
t
e übervorsicht
}
}
private
void
collectSweepVertices
(
Polygon
p
)
{
private
void
collectSweepVertices
(
Polygon
p
)
{
...
@@ -191,9 +167,12 @@ public class SweepUtilities {
...
@@ -191,9 +167,12 @@ public class SweepUtilities {
}
}
List
<
Vertex
>
vertices
=
ring
.
getVertices
();
List
<
Vertex
>
vertices
=
ring
.
getVertices
();
for
(
int
i
=
0
;
i
<
vertices
.
size
()
-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
vertices
.
size
()
-
1
;
i
++)
{
vert
s
.
add
(
new
SweepVertex
(
vertices
.
get
(
i
)));
sweepVertice
s
.
add
(
new
SweepVertex
(
vertices
.
get
(
i
)));
}
}
}
}
public
List
<
SweepVertex
>
getSweepVertices
(){
return
sweepVertices
;
}
}
}
CityDoctorParent/Extensions/CityDoctorHealer/src/main/java/de/hft/stuttgart/citydoctor2/healing/SweepVertex.java
View file @
0c03ab39
...
@@ -27,25 +27,25 @@ public class SweepVertex {
...
@@ -27,25 +27,25 @@ public class SweepVertex {
private
SweepVertexStatus
status
=
SweepVertexStatus
.
NONE
;
private
SweepVertexStatus
status
=
SweepVertexStatus
.
NONE
;
private
Vertex
v
ert
;
private
Vertex
sweepV
ert
ex
;
private
Vector3d
newPoint
;
private
Vector3d
newPoint
;
private
List
<
Edge
>
outgoingEdges
=
new
LinkedList
<>();
private
List
<
Edge
>
outgoingEdges
=
new
LinkedList
<>();
// TODO ?ist diese Zuweisung stabil?
public
SweepVertex
(
Vertex
v
)
{
public
SweepVertex
(
Vertex
v
)
{
v
ert
=
v
;
sweepV
ert
ex
=
v
;
}
}
public
void
collectOutgoingEdges
(
Polygon
p
ol
,
double
minSweepEdgeLength
)
{
public
void
collectOutgoingEdges
(
Polygon
errorP
ol
y
,
double
minSweepEdgeLength
)
{
outgoingEdges
.
clear
();
outgoingEdges
.
clear
();
if
(
p
ol
==
null
||
v
ert
==
null
)
{
if
(
errorP
ol
y
==
null
||
sweepV
ert
ex
==
null
)
{
logger
.
error
(
"Cannot collect outgoing edges: polygon or vertex is null"
);
logger
.
error
(
"Cannot collect outgoing edges: polygon or vertex is null"
);
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
return
;
return
;
}
}
Geometry
geometry
=
p
ol
.
getParent
();
Geometry
geometry
=
errorP
ol
y
.
getParent
();
if
(
geometry
==
null
)
{
if
(
geometry
==
null
)
{
logger
.
error
(
"Cannot collect outgoing edges: polygon has no parent geometry"
);
logger
.
error
(
"Cannot collect outgoing edges: polygon has no parent geometry"
);
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
...
@@ -55,8 +55,8 @@ public class SweepVertex {
...
@@ -55,8 +55,8 @@ public class SweepVertex {
geometry
.
updateEdgesAndVertices
();
geometry
.
updateEdgesAndVertices
();
}
}
for
(
Edge
edge
:
geometry
.
getEdgesAdjacentTo
(
v
ert
))
{
for
(
Edge
edge
:
geometry
.
getEdgesAdjacentTo
(
sweepV
ert
ex
))
{
if
(
edge
.
getAdjacentPolygons
().
contains
(
p
ol
))
{
if
(
edge
.
getAdjacentPolygons
().
contains
(
errorP
ol
y
))
{
continue
;
continue
;
}
}
if
(
edge
.
getFrom
().
getDistance
(
edge
.
getTo
())
<
minSweepEdgeLength
)
{
if
(
edge
.
getFrom
().
getDistance
(
edge
.
getTo
())
<
minSweepEdgeLength
)
{
...
@@ -70,15 +70,15 @@ public class SweepVertex {
...
@@ -70,15 +70,15 @@ public class SweepVertex {
public
void
initStatus
(
Plane
targetPlane
,
double
maxPointPlaneDistance
)
{
public
void
initStatus
(
Plane
targetPlane
,
double
maxPointPlaneDistance
)
{
if
(
targetPlane
==
null
||
v
ert
==
null
)
{
if
(
targetPlane
==
null
||
sweepV
ert
ex
==
null
)
{
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
return
;
return
;
}
}
if
(
targetPlane
.
getDistance
(
v
ert
)
<
maxPointPlaneDistance
)
{
if
(
targetPlane
.
getDistance
(
sweepV
ert
ex
)
<
maxPointPlaneDistance
)
{
status
=
SweepVertexStatus
.
ON_PLANE
;
status
=
SweepVertexStatus
.
ON_PLANE
;
}
}
else
if
(
outgoingEdges
.
size
()
<
1
)
{
else
if
(
outgoingEdges
.
size
()
==
0
)
{
status
=
SweepVertexStatus
.
PROJECT
;
status
=
SweepVertexStatus
.
PROJECT
;
}
}
/*
/*
...
@@ -119,7 +119,7 @@ public class SweepVertex {
...
@@ -119,7 +119,7 @@ public class SweepVertex {
newPoint
=
null
;
newPoint
=
null
;
if
(
targetPlane
==
null
||
v
ert
==
null
)
{
if
(
targetPlane
==
null
||
sweepV
ert
ex
==
null
)
{
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
return
;
return
;
}
}
...
@@ -129,7 +129,7 @@ public class SweepVertex {
...
@@ -129,7 +129,7 @@ public class SweepVertex {
return
;
return
;
case
PROJECT:
case
PROJECT:
newPoint
=
targetPlane
.
projectPointToPlane
(
v
ert
);
newPoint
=
targetPlane
.
projectPointToPlane
(
sweepV
ert
ex
);
if
(
newPoint
==
null
)
{
if
(
newPoint
==
null
)
{
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
}
}
...
@@ -147,7 +147,7 @@ public class SweepVertex {
...
@@ -147,7 +147,7 @@ public class SweepVertex {
return
;
return
;
}
}
SweepEdge
sweepEdge
=
new
SweepEdge
(
outgoingEdge
,
v
ert
,
minSweepEdgeLength
);
SweepEdge
sweepEdge
=
new
SweepEdge
(
outgoingEdge
,
sweepV
ert
ex
,
minSweepEdgeLength
);
if
(!
sweepEdge
.
valid
())
{
if
(!
sweepEdge
.
valid
())
{
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
return
;
return
;
...
@@ -159,26 +159,14 @@ public class SweepVertex {
...
@@ -159,26 +159,14 @@ public class SweepVertex {
return
;
return
;
}
}
SweepIntersectionPosition
position
=
sweepEdge
.
classifyIntersectionPosition
(
intersectionPoint
,
minSweepEdgeLength
);
if
(!
sweepEdge
.
isSweepableEdge
(
intersectionPoint
,
minSweepEdgeLength
))
{
switch
(
position
)
{
case
ON_EDGE:
case
BEYOND_OUTGOING_EDGE_TARGET:
/*
* Fall 2 nach Piepereit:
* Auf der Kante bedeutet Verkuerzen, hinter dem Kantenziel bedeutet
* Verlaengern. In beiden Faellen ist der Schnittpunkt die neue Position
* des Sweep-Punktes.
*/
newPoint
=
intersectionPoint
;
return
;
case
BEFORE_SWEEP_VERTEX:
case
UNKNOWN:
default
:
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
return
;
return
;
}
}
newPoint
=
intersectionPoint
;
return
;
case
NONE:
case
NONE:
case
ERROR:
case
ERROR:
default
:
default
:
...
@@ -193,14 +181,14 @@ public class SweepVertex {
...
@@ -193,14 +181,14 @@ public class SweepVertex {
return
;
return
;
}
}
if
(
v
ert
==
null
||
newPoint
==
null
)
{
if
(
sweepV
ert
ex
==
null
||
newPoint
==
null
)
{
status
=
SweepVertexStatus
.
ERROR
;
status
=
SweepVertexStatus
.
ERROR
;
return
;
return
;
}
}
v
ert
.
setX
(
newPoint
.
getX
());
sweepV
ert
ex
.
setX
(
newPoint
.
getX
());
v
ert
.
setY
(
newPoint
.
getY
());
sweepV
ert
ex
.
setY
(
newPoint
.
getY
());
v
ert
.
setZ
(
newPoint
.
getZ
());
sweepV
ert
ex
.
setZ
(
newPoint
.
getZ
());
}
}
public
SweepVertexStatus
getStatus
()
{
public
SweepVertexStatus
getStatus
()
{
...
@@ -208,7 +196,19 @@ public class SweepVertex {
...
@@ -208,7 +196,19 @@ public class SweepVertex {
return
status
;
return
status
;
}
}
public
int
getNoOutgoingEdges
()
{
public
Vector3d
getNewPoint
()
{
return
newPoint
;
}
public
List
<
Edge
>
getOutgoingEdges
(){
return
outgoingEdges
;
}
public
Vertex
getSweepVertex
()
{
return
sweepVertex
;
}
public
int
countOutgoingEdges
()
{
return
outgoingEdges
.
size
();
return
outgoingEdges
.
size
();
}
}
...
...
CityDoctorParent/Extensions/CityDoctorHealer/src/test/java/de/hft/stuttgart/citydoctor2/healing/SweepUtilitiesSyntheticTest.java
View file @
0c03ab39
...
@@ -18,10 +18,15 @@ public class SweepUtilitiesSyntheticTest {
...
@@ -18,10 +18,15 @@ public class SweepUtilitiesSyntheticTest {
private
static
final
double
EPS
=
0.000001
;
private
static
final
double
EPS
=
0.000001
;
/**
* Fall 1: Ein Punkt eines Fenster-Innenrings steht aus der Wandebene x = 0
* heraus. Da keine abführende Kante , muss er orthogonal auf die
* Zielebene projiziert werden.
*/
@Test
@Test
public
void
repairsCase1ByOrthogonalProjection
()
{
public
void
repairsCase1ByOrthogonalProjection
()
{
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createWallWithProtrudingWindowInnerRingPoint
();
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createWallWithProtrudingWindowInnerRingPoint
();
Polygon
sweepPolygon
=
getPolygon
(
building
,
0
);
Polygon
sweepPolygon
=
getPolygon
AtIndex
(
building
,
0
);
Vertex
protrudingPoint
=
sweepPolygon
.
getInnerRings
().
get
(
0
).
getVertices
().
get
(
2
);
Vertex
protrudingPoint
=
sweepPolygon
.
getInnerRings
().
get
(
0
).
getVertices
().
get
(
2
);
Plane
targetPlane
=
wallPlaneX0
();
Plane
targetPlane
=
wallPlaneX0
();
...
@@ -33,10 +38,15 @@ public class SweepUtilitiesSyntheticTest {
...
@@ -33,10 +38,15 @@ public class SweepUtilitiesSyntheticTest {
assertEquals
(
0
,
targetPlane
.
getDistance
(
protrudingPoint
),
EPS
);
assertEquals
(
0
,
targetPlane
.
getDistance
(
protrudingPoint
),
EPS
);
}
}
/**
* Fall 2, Verkürzen: Der Schnitt mit x = 0 liegt zwischen referencePoint und
* ursprünglichem Sweep-Punkt. Der Sweep-Punkt bewegt sich also auf der
* bestehenden abführenden Kante zurück.
*/
@Test
@Test
public
void
repairsCase2WhenOutgoingEdgeIsShortened
()
{
public
void
repairsCase2WhenOutgoingEdgeIsShortened
()
{
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2ShorteningEdge
();
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2ShorteningEdge
();
Polygon
sweepPolygon
=
getPolygon
(
building
,
0
);
Polygon
sweepPolygon
=
getPolygon
AtIndex
(
building
,
0
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
Plane
targetPlane
=
wallPlaneX0
();
Plane
targetPlane
=
wallPlaneX0
();
...
@@ -48,10 +58,14 @@ public class SweepUtilitiesSyntheticTest {
...
@@ -48,10 +58,14 @@ public class SweepUtilitiesSyntheticTest {
assertEquals
(
0
,
targetPlane
.
getDistance
(
sweepPoint
),
EPS
);
assertEquals
(
0
,
targetPlane
.
getDistance
(
sweepPoint
),
EPS
);
}
}
/**
* Fall 2, Verlängern: Der Schnitt mit x = 0 liegt hinter dem ursprünglichen
* Sweep-Punkt. Die abführende Kante wird dadurch in Sweep-Richtung verlängert.
*/
@Test
@Test
public
void
repairsCase2WhenOutgoingEdgeIsExtended
()
{
public
void
repairsCase2WhenOutgoingEdgeIsExtended
()
{
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2ExtendingEdge
();
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2ExtendingEdge
();
Polygon
sweepPolygon
=
getPolygon
(
building
,
0
);
Polygon
sweepPolygon
=
getPolygon
AtIndex
(
building
,
0
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
Plane
targetPlane
=
wallPlaneX0
();
Plane
targetPlane
=
wallPlaneX0
();
...
@@ -63,10 +77,15 @@ public class SweepUtilitiesSyntheticTest {
...
@@ -63,10 +77,15 @@ public class SweepUtilitiesSyntheticTest {
assertEquals
(
0
,
targetPlane
.
getDistance
(
sweepPoint
),
EPS
);
assertEquals
(
0
,
targetPlane
.
getDistance
(
sweepPoint
),
EPS
);
}
}
/**
* Fehlerfall: Der Schnitt mit x = 0 liegt vor oder zu nah am referencePoint.
* Vgl. rote Bereich aus der Skizze vom Margitta ist (vorerst?) nicht
* sweepbar.
*/
@Test
@Test
public
void
rejectsCase2WhenIntersectionIsBefore
SweepVertex
()
{
public
void
rejectsCase2WhenIntersectionIsBefore
ReferencePoint
()
{
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2IntersectionBefore
SweepVertex
();
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2IntersectionBefore
ReferencePoint
();
Polygon
sweepPolygon
=
getPolygon
(
building
,
0
);
Polygon
sweepPolygon
=
getPolygon
AtIndex
(
building
,
0
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
assertFalse
(
runSweep
(
sweepPolygon
,
wallPlaneX0
()));
assertFalse
(
runSweep
(
sweepPolygon
,
wallPlaneX0
()));
...
@@ -74,10 +93,14 @@ public class SweepUtilitiesSyntheticTest {
...
@@ -74,10 +93,14 @@ public class SweepUtilitiesSyntheticTest {
assertEquals
(
1
,
sweepPoint
.
getX
(),
EPS
);
assertEquals
(
1
,
sweepPoint
.
getX
(),
EPS
);
}
}
/**
* Fehlerfall: Die abführende Kante verläuft parallel zur Zielebene x = 0.
* Dann gibt es keinen stabilen eindeutigen Schnittpunkt für Fall 2.
*/
@Test
@Test
public
void
rejectsCase2WhenOutgoingEdgeIsParallelToTargetPlane
()
{
public
void
rejectsCase2WhenOutgoingEdgeIsParallelToTargetPlane
()
{
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2ParallelOutgoingEdge
();
Building
building
=
SyntheticSweepPlanarityModelFactory
.
createSweepCase2ParallelOutgoingEdge
();
Polygon
sweepPolygon
=
getPolygon
(
building
,
0
);
Polygon
sweepPolygon
=
getPolygon
AtIndex
(
building
,
0
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
Vertex
sweepPoint
=
sweepPolygon
.
getExteriorRing
().
getVertices
().
get
(
1
);
assertFalse
(
runSweep
(
sweepPolygon
,
wallPlaneX0
()));
assertFalse
(
runSweep
(
sweepPolygon
,
wallPlaneX0
()));
...
@@ -97,7 +120,7 @@ public class SweepUtilitiesSyntheticTest {
...
@@ -97,7 +120,7 @@ public class SweepUtilitiesSyntheticTest {
return
true
;
return
true
;
}
}
private
Polygon
getPolygon
(
Building
building
,
int
index
)
{
private
Polygon
getPolygon
AtIndex
(
Building
building
,
int
index
)
{
Geometry
geometry
=
building
.
getGeometries
().
get
(
0
);
Geometry
geometry
=
building
.
getGeometries
().
get
(
0
);
return
geometry
.
getPolygons
().
get
(
index
);
return
geometry
.
getPolygons
().
get
(
index
);
}
}
...
...
CityDoctorParent/Extensions/CityDoctorHealer/src/test/java/de/hft/stuttgart/citydoctor2/healing/SyntheticSweepPlanarityModelFactory.java
View file @
0c03ab39
...
@@ -220,18 +220,19 @@ public class SyntheticSweepPlanarityModelFactory {
...
@@ -220,18 +220,19 @@ public class SyntheticSweepPlanarityModelFactory {
/**
/**
* Fall 2 model: the faulty sweep point has exactly one outgoing edge. The target
* Fall 2 model: the faulty sweep point has exactly one outgoing edge. The target
* plane x = 0 lies behind the o
utgoing edge targe
t, so the edge is extended.
* plane x = 0 lies behind the o
riginal sweep poin
t, so the edge is extended.
*/
*/
static
Building
createSweepCase2ExtendingEdge
()
{
static
Building
createSweepCase2ExtendingEdge
()
{
return
createSweepCase2SingleOutgoingEdge
(
new
Vertex
(
0.5
,
1
,
0
));
return
createSweepCase2SingleOutgoingEdge
(
new
Vertex
(
2
,
1
,
0
));
}
}
/**
/**
* Fall 2 error model: the line through the outgoing edge hits the target plane
* Fall 2 error model: the line through the outgoing edge hits the target plane
* before the sweep point. The current sweep implementation rejects this case.
* before or too close to the reference point. The current sweep implementation
* rejects this case.
*/
*/
static
Building
createSweepCase2IntersectionBefore
SweepVertex
()
{
static
Building
createSweepCase2IntersectionBefore
ReferencePoint
()
{
return
createSweepCase2SingleOutgoingEdge
(
new
Vertex
(
2
,
1
,
0
));
return
createSweepCase2SingleOutgoingEdge
(
new
Vertex
(
0.5
,
1
,
0
));
}
}
/**
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment