Commit 67343044 authored by Matthias Betz's avatar Matthias Betz
Browse files

replace copy mechanism

logo now in jar, extracted when needed to temp dir
change version to 3.10
parent 3d26f0e9
Pipeline #5579 failed with stage
in 39 seconds
......@@ -5,7 +5,7 @@
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.10.0-SNAPSHOT</version>
<version>3.10.0</version>
</parent>
<artifactId>CityDoctorCheckResult</artifactId>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.10.0-SNAPSHOT</version>
<version>3.10.0</version>
</parent>
<artifactId>CityDoctorEdge</artifactId>
......
......@@ -24,13 +24,15 @@ import java.util.Map;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.math.MovedPolygon;
import de.hft.stuttgart.citydoctor2.math.MovedRing;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
public class CDPolygonNs extends PolygonNs {
private List<List<HalfEdge>> innerHalfEdges = new ArrayList<>();
public static CDPolygonNs of(Polygon p, Map<Vertex, Coordinate3d> pointMap) {
public static CDPolygonNs of(Polygon p, Map<Vector3d, Coordinate3d> pointMap) {
List<List<Coordinate3d>> loopCoordinates = new ArrayList<>();
List<Coordinate3d> edgeExtRing = createCoordinatesFromRing(pointMap, p.getExteriorRing().getVertices());
loopCoordinates.add(edgeExtRing);
......@@ -49,6 +51,25 @@ public class CDPolygonNs extends PolygonNs {
return new CDPolygonNs(halfEdges, p);
}
public static CDPolygonNs of(MovedPolygon mp, Map<Vector3d, Coordinate3d> pointMap) {
List<List<Coordinate3d>> loopCoordinates = new ArrayList<>();
List<Coordinate3d> edgeExtRing = createCoordinatesFromRing(pointMap, mp.getExteriorRing().getVertices());
loopCoordinates.add(edgeExtRing);
for (MovedRing innerRing : mp.getInnerRings()) {
List<Coordinate3d> edgeInnerRing = createCoordinatesFromRing(pointMap, innerRing.getVertices());
loopCoordinates.add(edgeInnerRing);
}
List<List<HalfEdge>> halfEdges = new ArrayList<>();
for (List<Coordinate3d> ringCoordinates : loopCoordinates) {
List<HalfEdge> currHeList = createHalfEdgesFromCoordinates(ringCoordinates);
halfEdges.add(currHeList);
}
return new CDPolygonNs(halfEdges, mp.getOriginal());
}
private static List<HalfEdge> createHalfEdgesFromCoordinates(List<Coordinate3d> ringCoordinates) {
List<HalfEdge> currHeList = new ArrayList<>();
HalfEdge prevHalfEdge = null;
......@@ -75,11 +96,11 @@ public class CDPolygonNs extends PolygonNs {
return currHeList;
}
private static List<Coordinate3d> createCoordinatesFromRing(Map<Vertex, Coordinate3d> pointMap,
List<Vertex> vertices) {
private static List<Coordinate3d> createCoordinatesFromRing(Map<Vector3d, Coordinate3d> pointMap,
List<? extends Vector3d> vertices) {
List<Coordinate3d> edgeRing = new ArrayList<>();
for (int i = 0; i < vertices.size() - 1; i++) {
Vertex v = vertices.get(i);
Vector3d v = vertices.get(i);
Coordinate3d c = pointMap.computeIfAbsent(v, key -> new Coordinate3d(key.getX(), key.getY(), key.getZ()));
edgeRing.add(c);
}
......
......@@ -107,6 +107,22 @@ public class DebugUtils {
}
}
}
public static void printGeoknechtPolygon(EdgePolygon... polys) {
Locale.setDefault(Locale.US);
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(30);
for (EdgePolygon poly : polys) {
List<Coordinate3d> coordinates = poly.getCoordinates();
System.out.print("polygon(");
for (Coordinate3d coord : coordinates) {
Point3d point = coord.getPoint();
writeGeoknechtPoint(nf, point);
}
writeGeoknechtPoint(nf, coordinates.get(0).getPoint());
System.out.println(")");
}
}
private static void writeGeoknechtPoint(NumberFormat nf, Point3d point) {
System.out.print(nf.format(point.getX()));
......@@ -167,4 +183,26 @@ public class DebugUtils {
return coordVarName;
}
public static void printPolygon3d(EdgePolygon polygon1, EdgePolygon polygon2) {
Locale.setDefault(Locale.US);
Map<Point3d, String> pointMap = new IdentityHashMap<>();
int startCounter = 1;
startCounter = printPolygon3d(polygon1, pointMap, startCounter);
printPolygon3d(polygon2, pointMap, startCounter);
}
private static int printPolygon3d(EdgePolygon p, Map<Point3d, String> pointMap, int startCounter) {
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(30);
int counter = polygon3dCounter.getAndIncrement();
int listCounter = coordListCounter.getAndIncrement();
int firstListCounter = listCounter;
HalfEdge firstHalfEdge = p.getFirstHalfEdge();
int[] counterArr = new int[] {startCounter};
System.out.println("Coordinate3dList coords" + firstListCounter + ";");
writeRing(pointMap, nf, listCounter, firstHalfEdge, counterArr);
System.out.println("CDPolygonNs* p" + counter + " = new CDPolygonNs(coords" + firstListCounter + ");");
return counterArr[0];
}
}
......@@ -20,7 +20,6 @@ package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
......@@ -78,12 +77,15 @@ public class EdgePolygon extends BaseEntity {
public List<Coordinate3d> getCoordinates() {
List<Coordinate3d> coords = new ArrayList<>();
HalfEdge firstHE = Objects.requireNonNull(getFirstHalfEdge());
HalfEdge currHE = firstHE;
do {
coords.add(currHE.getStart());
currHE = currHE.getNext();
} while (currHE != firstHE);
for (HalfEdge he : halfEdges) {
coords.add(he.getStart());
}
// HalfEdge firstHE = Objects.requireNonNull(getFirstHalfEdge());
// HalfEdge currHE = firstHE;
// do {
// coords.add(currHE.getStart());
// currHE = currHE.getNext();
// } while (currHE != firstHE);
return coords;
}
......
......@@ -26,7 +26,7 @@ public class Global {
private static double mZeroAngleCosinus = 1.0e-9;
private static double mTolVectorsParallel = 1e-9;
private static double mHighAccuracyTol = DBL_EPSILON * 100;
private static double mHighAccuracyTol = DBL_EPSILON * 5;
private static double mTolPointsEqual = 1e-3;
private Global() {
......
......@@ -146,5 +146,9 @@ public class GmPlane {
return new Polygon2d(halfedges);
}
public Point3d getPoint() {
return x0;
}
}
......
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.edge;
public class GmStraight2d {
private Point2d origin;
private UnitVector2d direction;
public GmStraight2d(Point2d org, UnitVector2d dir) {
this.direction = dir;
this.origin = org;
}
public GmStraight2d(Point2d org, Vector2d dir) {
this.origin = org;
this.direction = dir.normalize();
}
public GmStraight2d(Point2d from, Point2d to) {
origin = from;
direction = to.minus(from).normalize();
}
/**
* Just intersects two GmStraights2d.
*
* <br>
* <br>
* If the two straights are parallel the method will return false, so the user
* has to determine, if the straight are just parallel or identical
*
* @param other First Straight
*
* @return intersection result
*/
public GmStraight2dIntersectionResult intersect(GmStraight2d other) {
Point2d p1 = origin;
UnitVector2d r1 = direction;
Point2d p2 = other.getOrigin();
UnitVector2d r2 = other.getDirection();
Vector2d q = p2.minus(p1);
Vector2d r2Perpendicular = r2.getPerpendicularVector();
double diff = r1.dot(r2Perpendicular);
if (Math.abs(diff) < Global.getZeroAngleCosinus()) {
return GmStraight2dIntersectionResult.parallel(this, other);
} else {
double invR1DotPerpR2 = 1.0 / diff;
double qDotPerpR1 = q.dot(r1.getPerpendicularVector());
double qDotPerpR2 = q.dot(r2Perpendicular);
double rParam1 = qDotPerpR2 * invR1DotPerpR2;
double rParam2 = qDotPerpR1 * invR1DotPerpR2;
return GmStraight2dIntersectionResult.intersecting(rParam1, rParam2, this, other);
}
}
public UnitVector2d getDirection() {
return direction;
}
public Point2d getOrigin() {
return origin;
}
public Point2d evaluate(double param) {
return origin.plus(direction.mult(param));
}
@Override
public String toString() {
return "GmStraight2d [origin=" + origin + ", direction=" + direction + "]";
}
}
/*-
* Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
*
* This file is part of CityDoctor2.
*
* CityDoctor2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CityDoctor2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CityDoctor2. If not, see <https://www.gnu.org/licenses/>.
*/
package de.hft.stuttgart.citydoctor2.edge;
public class GmStraight2d {
private Point2d origin;
private UnitVector2d direction;
public GmStraight2d(Point2d org, UnitVector2d dir) {
this.direction = dir;
this.origin = org;
}
public GmStraight2d(Point2d org, Vector2d dir) {
this.origin = org;
this.direction = dir.normalize();
}
public GmStraight2d(Point2d from, Point2d to) {
origin = from;
direction = to.minus(from).normalize();
}
/**
* Just intersects two GmStraights2d.
*
* <br>
* <br>
* If the two straights are parallel the method will return false, so the user
* has to determine, if the straight are just parallel or identical
*
* @param other First Straight
*
* @return intersection result
*/
public GmStraight2dIntersectionResult intersect(GmStraight2d other) {
Point2d p1 = origin;
UnitVector2d r1 = direction;
Point2d p2 = other.getOrigin();
UnitVector2d r2 = other.getDirection();
Vector2d q = p2.minus(p1);
Vector2d r2Perpendicular = r2.getPerpendicularVector();
double diff = r1.dot(r2Perpendicular);
if (Math.abs(diff) < Global.getZeroAngleCosinus()) {
return GmStraight2dIntersectionResult.parallel(this, other);
} else {
double invR1DotPerpR2 = 1.0 / diff;
double qDotPerpR1 = q.dot(r1.getPerpendicularVector());
double qDotPerpR2 = q.dot(r2Perpendicular);
double rParam1 = qDotPerpR2 * invR1DotPerpR2;
double rParam2 = qDotPerpR1 * invR1DotPerpR2;
return GmStraight2dIntersectionResult.intersecting(rParam1, rParam2, this, other);
}
}
public UnitVector2d getDirection() {
return direction;
}
public Point2d getOrigin() {
return origin;
}
public Point2d evaluate(double param) {
return origin.plus(direction.mult(param));
}
@Override
public String toString() {
return "GmStraight2d [origin=" + origin + ", direction=" + direction + "]";
}
}
......@@ -32,9 +32,9 @@ public class GmStraight2dIntersectionResult {
return new GmStraight2dIntersectionResult(0, 0, s1, s2, true);
}
public static GmStraight2dIntersectionResult intersecting(double rParam1, double rParam2, GmStraight2d s1,
GmStraight2d s2) {
return new GmStraight2dIntersectionResult(rParam1, rParam2, s1, s2, false);
public static GmStraight2dIntersectionResult intersecting(double paramHE, double paramInt, GmStraight2d straightHE,
GmStraight2d straightInt) {
return new GmStraight2dIntersectionResult(paramHE, paramInt, straightHE, straightInt, false);
}
private GmStraight2dIntersectionResult(double paramHE, double paramInt, GmStraight2d straightHE,
......
......@@ -118,6 +118,7 @@ public class IntersectPlanarPolygons {
for (HalfEdge he : polyHEs) {
// only check half edges with partners. NOTE: we are just looking
// for half edges, shared by both polygons!
if (he.getPartner() != null) {
Point3d start = he.getStart().getPoint();
Point3d end = he.getEnd().getPoint();
......@@ -154,8 +155,8 @@ public class IntersectPlanarPolygons {
/**
*
* This method checks if the point is a border point of one of the polygons,
* which should be intersected. If this check is successfull, the method tries
* to find the same point in the other polygon.
* which should be intersected. If this check is successful, the method tries to
* find the same point in the other polygon.
*
* <br>
* Equality in this case means, both polygons sharing the same instance of
......@@ -193,6 +194,25 @@ public class IntersectPlanarPolygons {
return bothPolygonsSharingThisPoint;
}
/**
*
* This method does pretty the same stuff like calculateIntersectionIntervals(),
* with the exception, that the straight and the half edges of the polygon will
* be projected on the plane of the polygon, so the calculation of the
* intersection will be reduced to a 2d problem.
*
* The intersection intervals contains pairs of parameters from the intersection
* straight. If an intersection between the straight and the polygon contains
* only a point, the according interval will contain the same parameter twice
*
* @param p A polygon
*
* @param intersectingStraight The straight, that should be intersected with the
* given polygon
*
* @return rIntersectionIntervals A list parameter intervals, where the straight
* is intersecting the polygon
*/
private static List<Interval> calculateIntersectionIntervals2d(EdgePolygon p, EdgePolygon cpPolygon1,
EdgePolygon cpPolygon2, GmStraight intersectingStraight, double epsilon, double angleEpsilon) {
List<Interval> intersectionIntervals = new ArrayList<>();
......@@ -241,11 +261,11 @@ public class IntersectPlanarPolygons {
}
// The current HalfEdge shares a point with the other polygon and is not
// collinear with the intersection straight. Hence, there is now way, that
// collinear with the intersection straight. Hence, there is no way, that
// this HalfEdge can intersect the other one, because both are planar.
// if (currHESharesAPntWithTheOtherPolygon) {
// continue;
// }
if (currHESharesAPntWithTheOtherPolygon) {
continue;
}
// project straight on plane
GmBoundedStraight2d heStraight2d = polyPlane.projectOn2dStraight(heStraight);
......@@ -386,8 +406,8 @@ public class IntersectPlanarPolygons {
}
/**
* Util method. Checks if the given parameter hase been allready inserted as
* intersction parameter. If this is true, the parameter will be added as
* Util method. Checks if the given parameter has already been inserted as
* intersection parameter. If this is true, the parameter will be added as
* intersected polygon corner point. Otherwise it's just a normal intersection
* parameter till now.
*
......@@ -401,7 +421,7 @@ public class IntersectPlanarPolygons {
private static void assignParameterToCorrectList(double param, TreeSet<Double> intersectionValues,
TreeSet<Double> intersectedPolygonPoints) {
if (!intersectionValues.add(param)) {
// value is allready present ==> this must be a point of the polygon
// value is already present ==> this must be a point of the polygon
// note, it's assumed, that the polygon do not intersect itself
intersectedPolygonPoints.add(param);
}
......@@ -556,7 +576,15 @@ public class IntersectPlanarPolygons {
Polygon2d poly2d1 = new Polygon2dNs(poly2dCoords1, true);
Polygon2d poly2d2 = new Polygon2dNs(poly2dCoords2, true);
List<HalfEdge2d> halfEdges = poly2d1.getHalfEdges();
for (HalfEdge2d he : halfEdges) {
if (he.getPartner() == null) {
}
}
halfEdges = poly2d2.getHalfEdges();
List<PolygonPolygonIntersection> result = new ArrayList<>();
List<Polygon2dPolygon2dInt> ppi2ds = IntersectPolygon2d.getIntersections(poly2d1, poly2d2, epsilon);
for (Polygon2dPolygon2dInt ppi2d : ppi2ds) {
......
......@@ -233,7 +233,8 @@ public class IntersectPolygon2d {
}
private static void checkForDoubleUsedPoints(List<PolyLine2d> orIntPolyLines) {
for (PolyLine2d currPolyLine : orIntPolyLines) {
for (int i = 0; i < orIntPolyLines.size(); i++) {
PolyLine2d currPolyLine = orIntPolyLines.get(i);
List<PolyLineSegment2d> segs = currPolyLine.getSegments();
if (2 == segs.size()) {
PolyLine2d newPolyLine = new PolyLine2d(segs.get(0).getStart(), segs.get(0).getEnd());
......
......@@ -19,13 +19,14 @@
package de.hft.stuttgart.citydoctor2.edge;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.math.MovedPolygon;
import de.hft.stuttgart.citydoctor2.math.Vector3d;
public class MeshSurface {
......@@ -34,19 +35,12 @@ public class MeshSurface {
public static MeshSurface of(Geometry geom) {
List<CDPolygonNs> polygonList = new ArrayList<>();
Map<Vertex, Coordinate3d> pointMap = new IdentityHashMap<>();
Map<Vector3d, Coordinate3d> pointMap = new HashMap<>();
Vector3d moveBy = geom.calculateBoundingBox().getBox()[0];
for (Polygon p : geom.getPolygons()) {
CDPolygonNs poly = CDPolygonNs.of(p, pointMap);
MovedPolygon mp = MovedPolygon.ofPolygon(p, moveBy);
CDPolygonNs poly = CDPolygonNs.of(mp, pointMap);
polygonList.add(poly);
// HalfEdge firstHalfEdge = poly.getFirstHalfEdge();
// System.out.println();
// System.out.println(firstHalfEdge.getStart());
// System.out.println(firstHalfEdge.getEnd());
// HalfEdge next = firstHalfEdge.getNext();
// while (next != firstHalfEdge) {
// System.out.println(next.getEnd());
// next = next.getNext();
// }
}
return new MeshSurface(polygonList);
}
......
......@@ -81,4 +81,36 @@ public class Point3d {
return "Point3d [x=" + x + ", y=" + y + ", z=" + z + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(x);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(y);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(z);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Point3d other = (Point3d) obj;
if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
return false;
if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
return false;
if (Double.doubleToLongBits(z) != Double.doubleToLongBits(other.z))
return false;
return true;
}
}
......
......@@ -159,4 +159,9 @@ public class PolyLine2d extends BaseEntity {
return pRightLine;
}
@Override
public String toString() {
return "PolyLine2d [mpFirst=" + mpFirst + ", mpLast=" + mpLast + "]";
}
}
......@@ -48,4 +48,10 @@ public class Polygon2dPolygon2dInt {
public Polygon2d getPolygon2() {
return mcpPolygon2;
}
@Override
public String toString() {
return "Polygon2dPolygon2dInt [mcpPolygon1=" + mcpPolygon1 + ", mcpPolygon2=" + mcpPolygon2 + ", line=" + line
+ ", intType=" + intType + "]";
}
}
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>de.hft.stuttgart</groupId>
<artifactId>CityDoctorParent</artifactId>
<version>3.10.0-SNAPSHOT</version>
<version>3.10.0</version>
</parent>
<properties>
......
......@@ -84,7 +84,7 @@ public class Requirement implements Serializable {
R_SE_BS_ROOF_UNFRAGMENTED.parameters = Collections.unmodifiableList(defaultParameters);
defaultParameters = new ArrayList<>();
defaultParameters.add(new DefaultParameter(DEGENERATED_RING_TOLERANCE, "0.01", Unit.METER));
defaultParameters.add(new DefaultParameter(DEGENERATED_RING_TOLERANCE, "0", Unit.METER));
R_GE_R_SELF_INTERSECTION.parameters = Collections.unmodifiableList(defaultParameters);
}
......
......@@ -96,7 +96,7 @@ public class NonPlanarPolygonDistancePlaneError implements CheckError {
@Override
public String toString() {
return "DistanceError [p=" + p + ", distance=" + distance + ", v=" + v + ", plane=" + plane + "]";
return "NonPlanarPolygonDistancePlaneError [p=" + p + ", distance=" + distance + ", v=" + v + ", plane=" + plane + "]";
}
@Override
......
......@@ -35,6 +35,8 @@ import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.CityGmlUtils;
import de.hft.stuttgart.citydoctor2.utils.CopyHandler;
import de.hft.stuttgart.citydoctor2.utils.Copyable;
/**
* Container for attributes of an abstract building. It can be a Building or
......@@ -279,4 +281,25 @@ public abstract class AbstractBuilding extends CityObject {
bs.clearMetaInformation();
}
}
@Override
public void collectInstances(CopyHandler handler) {
super.collectInstances(handler);
handler.addInstance(boundarySurfaceList);
handler.addInstance(buildingInstallations);
}
@Override
public void fillValues(Copyable original, CopyHandler handler) {
super.fillValues(original, handler);
AbstractBuilding originalAb = (AbstractBuilding) original;
for (BoundarySurface originalBs : originalAb.boundarySurfaceList) {
boundarySurfaceList.add(handler.getCopyInstance(originalBs));
}
for (BuildingInstallation originalBi : originalAb.buildingInstallations) {
buildingInstallations.add(handler.getCopyInstance(originalBi));
}
ab = originalAb.ab;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment