Commit 604fc47d authored by Beuster's avatar Beuster
Browse files

Add TestExampleAABB

Test for model with Error RingSelfInt. Gets Vertices and BoundingBox
parent 3d6aafce
Pipeline #11355 passed with stage
in 1 minute and 35 seconds
/*-
* 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.check;
import java.util.Collections;
import java.util.Set;
/**
*
* This class serves as a Parent for non-validating checks that want to use the CheckEngine's Visitor-pattern for the
* implementation of utility functions like e.g. collecting the sub-CityObjects in a Feature.
*
*
* @author Matthias Betz
*
*/
public abstract class AbstractCheck extends Check {
@Override
public Set<Requirement> appliesToRequirements() {
return Collections.emptySet();
}
@Override
public CheckId getCheckId() {
return null;
}
@Override
public RequirementType getType() {
return null;
}
@Override
public Check createNewInstance() {
return null;
}
@Override
public final boolean isValidator() {
return false;
}
}
package de.hft.stuttgart.citydoctor2.utils.visitors.bht;
import de.hft.stuttgart.citydoctor2.check.AbstractVisitor;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import java.util.HashSet;
import java.util.Set;
/**
* This Visitor collects all sub-CityObjects that are in the datastructure of a CityObject (including itself) in a Set.
*/
public class PolygonCollector extends AbstractVisitor {
// private final Set<CityObject> objects = new HashSet<>();
//
// /**
// * Returns the collected CityObjects.
// *
// * @return A set of CityObjects
// */
// public Set<CityObject> getCityObjects() {
// return objects;
// }
//
// @Override
// public void check(CityObject co) {
// objects.add(co);
// }
}
...@@ -3,6 +3,17 @@ package de.hft.stuttgart.citydoctor2.healer.bht; ...@@ -3,6 +3,17 @@ package de.hft.stuttgart.citydoctor2.healer.bht;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.*; import java.util.*;
import de.hft.stuttgart.citydoctor2.edge.Point3d;
import de.hft.stuttgart.citydoctor2.edge.GmPlane;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.math.UnitVector3d;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.math.Edge2d;
public class HealingBySweepPlanarity { public class HealingBySweepPlanarity {
// public static void main(String[] args) { // public static void main(String[] args) {
...@@ -14,8 +25,8 @@ public class HealingBySweepPlanarity { ...@@ -14,8 +25,8 @@ public class HealingBySweepPlanarity {
// boolean IgnoreMultiplePoints; // boolean IgnoreMultiplePoints;
double Eps_PlanarityTolerance; double Eps_PlanarityTolerance;
// public boolean isPointInPlane(GmPlane plane, Point3d point, double tolerance) public boolean isPointInPlane(GmPlane plane, Point3d point, double tolerance)
// { {
// Point3d foot = plane.project(point); // Point3d foot = plane.project(point);
// double dist = (point - foot).getLength(); // double dist = (point - foot).getLength();
// //
...@@ -24,50 +35,50 @@ public class HealingBySweepPlanarity { ...@@ -24,50 +35,50 @@ public class HealingBySweepPlanarity {
// return false; // return false;
// } // }
// //
// return true; return true;
// } }
// //
// public Point3dList getComplexPoints(Face cpFace) // public List<Point3d> getComplexPoints(Face Face)
// { // {
// //
// Point3dList multiplePoints = new Point3dList(); // List<Point3d> multiplePoints = new ArrayList<>();
// //
// VertexList vertices = getAllVerticesForFace(cpFace); // List<Vertex> vertices = getAllVerticesForFace(Face);
// //
// for (Vertex pVertex : vertices) // for (Vertex Vertex : vertices)
// { // {
// Point3d point = pVertex.getPositionOnGeometry(); // Point3d point = Vertex.getPositionOnGeometry();
// LinkedList<Edge > otherEdges = getOtherEdges(pVertex, cpFace); // LinkedList<Edge > otherEdges = getOtherEdges(Vertex, Face);
// //
// if (otherEdges.size() >= 2) // if (otherEdges.size() >= 2)
// { // {
// multiplePoints.push_back(pVertex.getPositionOnGeometry()); // multiplePoints.push_back(Vertex.getPositionOnGeometry());
// } // }
// } // }
// //
// return new Point3dList(multiplePoints); // return new List<Point3d>(multiplePoints);
// //
// } // }
// //
// public LinkedList<Vertex > splitVertexCut(Vertex pVertexToSplit, Face pSweepFace) // public LinkedList<Vertex > splitVertexCut(Vertex VertexToSplit, Face SweepFace)
// { // {
// //
// LinkedList<Vertex > allSplitVertices = new LinkedList<Vertex >(); // LinkedList<Vertex > allSplitVertices = new LinkedList<Vertex >();
// //
// LinkedList<Face > allFacesOfVertex = getFacesForVertex(pVertexToSplit); // LinkedList<Face > allFacesOfVertex = getFacesForVertex(VertexToSplit);
// LinkedList<SplitCutTriple> unsortedTriple = new LinkedList<SplitCutTriple>(); // LinkedList<SplitCutTriple> unsortedTriple = new LinkedList<SplitCutTriple>();
// for (Face middleFace : allFacesOfVertex) // for (Face middleFace : allFacesOfVertex)
// { // {
// //
// SplitCutTriple aTriple = new SplitCutTriple(); // SplitCutTriple aTriple = new SplitCutTriple();
// //
// aTriple.pFace_center = middleFace; // aTriple.Face_center = middleFace;
// //
// LinkedList<Edge > faceEdges = getAllEdgesForFace(pVertexToSplit, middleFace); // LinkedList<Edge > faceEdges = getAllEdgesForFace(VertexToSplit, middleFace);
// if (faceEdges.size() != 2) // if (faceEdges.size() != 2)
// { // {
// EDGE_ERROR << "there should be two edges. faceEdges.size() = " << faceEdges.size() << EDGE_ENDL; // EDGE_ERROR << "there should be two edges. faceEdges.size() = " << faceEdges.size() << EDGE_ENDL;
...@@ -75,38 +86,38 @@ public class HealingBySweepPlanarity { ...@@ -75,38 +86,38 @@ public class HealingBySweepPlanarity {
// System.out.print(faceEdges.size()); // System.out.print(faceEdges.size());
// System.out.println(); // System.out.println();
// //
// for (Edge pTempEdge : faceEdges) // for (Edge TempEdge : faceEdges)
// { // {
// System.out.print(" "); // System.out.print(" ");
// System.out.print(pTempEdge); // System.out.print(TempEdge);
// System.out.println(); // System.out.println();
// } // }
// //
// return new LinkedList<Vertex>(); // return new LinkedList<Vertex>();
// } // }
// //
// aTriple.pEdge_left = faceEdges.getFirst(); // aTriple.Edge_left = faceEdges.getFirst();
// aTriple.pEdge_rigth = faceEdges.getLast(); // aTriple.Edge_rigth = faceEdges.getLast();
// //
// aTriple.pFace_left = (Face)getFacePartner(faceEdges.getFirst(), middleFace); // aTriple.Face_left = (Face)getFacePartner(faceEdges.getFirst(), middleFace);
// aTriple.pFace_rigth = (Face)getFacePartner(faceEdges.getLast(), middleFace); // aTriple.Face_rigth = (Face)getFacePartner(faceEdges.getLast(), middleFace);
// //
// unsortedTriple.addLast(aTriple); // unsortedTriple.addLast(aTriple);
// } // }
// //
// LinkedList<SplitCutTriple> sortedTriples = sortSplitCutTriples(unsortedTriple, pSweepFace); // LinkedList<SplitCutTriple> sortedTriples = sortSplitCutTriples(unsortedTriple, SweepFace);
// //
// //
// // only output // // only output
// //
// /* cout << "main Face : " << pSweepFace << "\n"; // /* cout << "main Face : " << SweepFace << "\n";
// System.out.print("main vertex : "); // System.out.print("main vertex : ");
// System.out.print(pVertexToSplit); // System.out.print(VertexToSplit);
// System.out.println(); // System.out.println();
// for (Face pFaceOfAll : allFacesOfVertex) // for (Face FaceOfAll : allFacesOfVertex)
// { // {
// System.out.print(" one of the faces : "); // System.out.print(" one of the faces : ");
// System.out.print(pFaceOfAll); // System.out.print(FaceOfAll);
// ystem.out.println(); // ystem.out.println();
// } // }
// for (SplitCutTriple aTriple : sortedTriples) // for (SplitCutTriple aTriple : sortedTriples)
...@@ -114,19 +125,19 @@ public class HealingBySweepPlanarity { ...@@ -114,19 +125,19 @@ public class HealingBySweepPlanarity {
// System.out.print(" Triple "); // System.out.print(" Triple ");
// System.out.println(); // System.out.println();
// System.out.print(" right Face : "); // System.out.print(" right Face : ");
// System.out.print(aTriple.pFace_left); // System.out.print(aTriple.Face_left);
// System.out.println(); // System.out.println();
// System.out.print(" middle Face : "); // System.out.print(" middle Face : ");
// System.out.print(aTriple.pFace_center); // System.out.print(aTriple.Face_center);
// System.out.println(); // System.out.println();
// System.out.print(" left Face : "); // System.out.print(" left Face : ");
// System.out.print(aTriple.pFace_rigth); // System.out.print(aTriple.Face_rigth);
// System.out.println(); // System.out.println();
// System.out.print(" right Edge : "); // System.out.print(" right Edge : ");
// System.out.print(aTriple.pEdge_left); // System.out.print(aTriple.Edge_left);
// System.out.println(); // System.out.println();
// System.out.print(" left Edge : "); // System.out.print(" left Edge : ");
// System.out.print(aTriple.pFace_rigth); // System.out.print(aTriple.Face_rigth);
// System.out.println(); // System.out.println();
// //
// }*/ // }*/
...@@ -134,57 +145,57 @@ public class HealingBySweepPlanarity { ...@@ -134,57 +145,57 @@ public class HealingBySweepPlanarity {
// // only output end // // only output end
// //
// LinkedList<Edge> allUnprocessedEdgesOfVertex; // LinkedList<Edge> allUnprocessedEdgesOfVertex;
// for (Base baseElement : pVertexToSplit.getEdges()) // for (Base baseElement : VertexToSplit.getEdges())
// { // {
// allUnprocessedEdgesOfVertex.push_back((Edge)baseElement); // allUnprocessedEdgesOfVertex.push_back((Edge)baseElement);
// } // }
// //
// Vertex pLastVertex = pVertexToSplit; // Vertex LastVertex = VertexToSplit;
// Point3d pointCopy = pVertexToSplit.getPositionOnGeometry(); // Point3d pointCopy = VertexToSplit.getPositionOnGeometry();
// //
// CoEdge pNewCenterCoEdge = null; // CoEdge NewCenterCoEdge = null;
// CoEdge pNewMainCoEdge = null; // CoEdge NewMainCoEdge = null;
// //
// for (SplitCutTriple aTriple : sortedTriples) // for (SplitCutTriple aTriple : sortedTriples)
// { // {
// if (aTriple.pFace_rigth == pSweepFace || aTriple.pFace_center == pSweepFace) // if (aTriple.Face_rigth == SweepFace || aTriple.Face_center == SweepFace)
// { // {
// //System.out.print("don't have to process first and last triple"); // //System.out.print("don't have to process first and last triple");
// //System.out.println(); // //System.out.println();
// allUnprocessedEdgesOfVertex.remove(aTriple.pEdge_rigth); // allUnprocessedEdgesOfVertex.remove(aTriple.Edge_rigth);
// } // }
// else if (aTriple.pFace_left == pSweepFace) // else if (aTriple.Face_left == SweepFace)
// { // {
// //System.out.print("don't have to process second triple - just to push the first pair<Vertex *, Edge *>"); // //System.out.print("don't have to process second triple - just to push the first pair<Vertex *, Edge *>");
// //System.out.println(); // //System.out.println();
// allSplitVertices.addLast(pLastVertex); // allSplitVertices.addLast(LastVertex);
// allUnprocessedEdgesOfVertex.remove(aTriple.pEdge_rigth); // allUnprocessedEdgesOfVertex.remove(aTriple.Edge_rigth);
// } // }
// else // else
// { // {
// //
// // duplicate vertex // // duplicate vertex
// Vertex pNewVertex = new Vertex(pointCopy); // Vertex NewVertex = new Vertex(pointCopy);
// allSplitVertices.addLast(pNewVertex); // allSplitVertices.addLast(pNewVertex);
// //System.out.print("duplicated vertex "); // //System.out.print("duplicated vertex ");
// //System.out.print(pNewVertex); // //System.out.print(NewVertex);
// //System.out.println(); // //System.out.println();
// //
// // set some of the edgepoints to duplicated one // // set some of the edgepoints to duplicated one
// for (Edge pEdgeToSet : allUnprocessedEdgesOfVertex) // for (Edge pEdgeToSet : allUnprocessedEdgesOfVertex)
// { // {
// //System.out.print("start : "); // //System.out.print("start : ");
// //System.out.print(pEdgeToSet.getStartVertex()); // //System.out.print(EdgeToSet.getStartVertex());
// //System.out.print(" end : "); // //System.out.print(" end : ");
// //System.out.print(pEdgeToSet.getEndVertex()); // //System.out.print(EdgeToSet.getEndVertex());
// //System.out.println(); // //System.out.println();
// if (pEdgeToSet.getStartVertex() == pLastVertex) // if (EdgeToSet.getStartVertex() == LastVertex)
// { // {
// pEdgeToSet.setStartVertex(pNewVertex); // pEdgeToSet.setStartVertex(NewVertex);
// } // }
// else if (pEdgeToSet.getEndVertex() == pLastVertex) // else if (EdgeToSet.getEndVertex() == LastVertex)
// { // {
// pEdgeToSet.setEndVertex(pNewVertex); // EdgeToSet.setEndVertex(NewVertex);
// } // }
// else // else
// { // {
...@@ -193,41 +204,41 @@ public class HealingBySweepPlanarity { ...@@ -193,41 +204,41 @@ public class HealingBySweepPlanarity {
// } // }
// //
// // create Edge (between last and new vertex) and CoEdges // // create Edge (between last and new vertex) and CoEdges
// GmStraight gmStraight = new GmStraight(pLastVertex.getPositionOnGeometry(), pNewVertex.getPositionOnGeometry()); // GmStraight gmStraight = new GmStraight(LastVertex.getPositionOnGeometry(), NewVertex.getPositionOnGeometry());
// Straight straight = new Straight(gmStraight); // Straight straight = new Straight(gmStraight);
// Edge pNewEdge = new Edge(straight, Topology.FORWARD, pLastVertex, pNewVertex); // Edge NewEdge = new Edge(straight, Topology.FORWARD, LastVertex, NewVertex);
// //
// // get the two loops // // get the two loops
// Loop pLoopCenter = (Loop)aTriple.pFace_center.getLoop(); // Loop LoopCenter = (Loop)aTriple.Face_center.getLoop();
// Loop pLoopMain = (Loop)pSweepFace.getLoop(); // Loop LoopMain = (Loop)SweepFace.getLoop();
// //
// // get the corresponding coedges of the loops // // get the corresponding coedges of the loops
// CoEdge pCoEdgeCenterRight = getCorrespondingCoEdge(aTriple.pEdge_rigth, aTriple.pFace_center); // CoEdge pCoEdgeCenterRight = getCorrespondingCoEdge(aTriple.Edge_rigth, aTriple.Face_center);
// CoEdge pCoEdgeCenterLeft = getCorrespondingCoEdge(aTriple.pEdge_left, aTriple.pFace_center); // CoEdge pCoEdgeCenterLeft = getCorrespondingCoEdge(aTriple.Edge_left, aTriple.Face_center);
// CoEdge pCoEdgeMainRight = getCorrespondingCoEdge(sortedTriples.getFirst().pEdge_rigth, pSweepFace); // CoEdge pCoEdgeMainRight = getCorrespondingCoEdge(sortedTriples.getFirst().Edge_rigth, SweepFace);
// CoEdge pCoEdgeMainLeft = getCorrespondingCoEdge(sortedTriples.getFirst().pEdge_left, pSweepFace); // CoEdge pCoEdgeMainLeft = getCorrespondingCoEdge(sortedTriples.getFirst().Edge_left, SweepFace);
// if (pNewMainCoEdge != null) // if (NewMainCoEdge != null)
// { // {
// pCoEdgeMainRight = pNewMainCoEdge; // CoEdgeMainRight = NewMainCoEdge;
// } // }
// //
// // get the previous and next coedge as well as the sense for the new center coEdge // // get the previous and next coedge as well as the sense for the new center coEdge
// CoEdge pCoEdgeCenterNext = null; // CoEdge CoEdgeCenterNext = null;
// CoEdge pCoEdgeCenterPrev = null; // CoEdge CoEdgeCenterPrev = null;
// Topology.Sense centerSense = Topology.UNKNOWN; // Topology.Sense centerSense = Topology.UNKNOWN;
// Topology.Sense mainSense = Topology.UNKNOWN; // Topology.Sense mainSense = Topology.UNKNOWN;
// //
// if (pCoEdgeCenterRight.getPrevious() == pCoEdgeCenterLeft) // if (CoEdgeCenterRight.getPrevious() == CoEdgeCenterLeft)
// { // {
// pCoEdgeCenterPrev = pCoEdgeCenterLeft; // CoEdgeCenterPrev = CoEdgeCenterLeft;
// pCoEdgeCenterNext = pCoEdgeCenterRight; // CoEdgeCenterNext = CoEdgeCenterRight;
// centerSense = Topology.FORWARD; // centerSense = Topology.FORWARD;
// mainSense = Topology.REVERSED; // mainSense = Topology.REVERSED;
// } // }
// else if (pCoEdgeCenterRight.getNext() == pCoEdgeCenterLeft) // else if (CoEdgeCenterRight.getNext() == CoEdgeCenterLeft)
// { // {
// pCoEdgeCenterNext = pCoEdgeCenterLeft; // CoEdgeCenterNext = CoEdgeCenterLeft;
// pCoEdgeCenterPrev = pCoEdgeCenterRight; // CoEdgeCenterPrev = CoEdgeCenterRight;
// centerSense = Topology.REVERSED; // centerSense = Topology.REVERSED;
// mainSense = Topology.FORWARD; // mainSense = Topology.FORWARD;
// } // }
...@@ -237,18 +248,18 @@ public class HealingBySweepPlanarity { ...@@ -237,18 +248,18 @@ public class HealingBySweepPlanarity {
// } // }
// //
// // ..same for the new main coEdge // // ..same for the new main coEdge
// CoEdge pCoEdgeMainNext = null; // CoEdge CoEdgeMainNext = null;
// CoEdge pCoEdgeMainPrev = null; // CoEdge CoEdgeMainPrev = null;
// //
// if (pCoEdgeMainRight.getPrevious() == pCoEdgeMainLeft) // if (CoEdgeMainRight.getPrevious() == CoEdgeMainLeft)
// { // {
// pCoEdgeMainPrev = pCoEdgeMainLeft; // CoEdgeMainPrev = CoEdgeMainLeft;
// pCoEdgeMainNext = pCoEdgeMainRight; // CoEdgeMainNext = CoEdgeMainRight;
// } // }
// else if (pCoEdgeMainRight.getNext() == pCoEdgeMainLeft) // else if (CoEdgeMainRight.getNext() == CoEdgeMainLeft)
// { // {
// pCoEdgeMainNext = pCoEdgeMainLeft; // CoEdgeMainNext = CoEdgeMainLeft;
// pCoEdgeMainPrev = pCoEdgeMainRight; // CoEdgeMainPrev = CoEdgeMainRight;
// } // }
// else // else
// { // {
...@@ -256,49 +267,49 @@ public class HealingBySweepPlanarity { ...@@ -256,49 +267,49 @@ public class HealingBySweepPlanarity {
// } // }
// //
// // create the new coedges and set relations to other coedges // // create the new coedges and set relations to other coedges
// pNewCenterCoEdge = new CoEdge(pNewEdge, centerSense); // NewCenterCoEdge = new CoEdge(NewEdge, centerSense);
// pNewMainCoEdge = new CoEdge(pNewEdge, mainSense); // NewMainCoEdge = new CoEdge(NewEdge, mainSense);
// setGeometryForCoEdge(pNewCenterCoEdge); // setGeometryForCoEdge(NewCenterCoEdge);
// setGeometryForCoEdge(pNewMainCoEdge); // setGeometryForCoEdge(NewMainCoEdge);
// //
// pNewCenterCoEdge.setPartner(pNewMainCoEdge); // NewCenterCoEdge.setPartner(NewMainCoEdge);
// pNewMainCoEdge.setPartner(pNewCenterCoEdge); // NewMainCoEdge.setPartner(NewCenterCoEdge);
// //
// pNewCenterCoEdge.setNext(pCoEdgeCenterNext); // NewCenterCoEdge.setNext(CoEdgeCenterNext);
// pNewCenterCoEdge.setPrevious(pCoEdgeCenterPrev); // NewCenterCoEdge.setPrevious(CoEdgeCenterPrev);
// //
// pNewMainCoEdge.setNext(pCoEdgeMainNext); // NewMainCoEdge.setNext(CoEdgeMainNext);
// pNewMainCoEdge.setPrevious(pCoEdgeMainPrev); // NewMainCoEdge.setPrevious(CoEdgeMainPrev);
// //
// // add CoEdges to loop // // add CoEdges to loop
// pLoopCenter.addCoEdge(pNewCenterCoEdge); // LoopCenter.addCoEdge(NewCenterCoEdge);
// pLoopMain.addCoEdge(pNewMainCoEdge); // LoopMain.addCoEdge(NewMainCoEdge);
// //
// //
// // output // // output
// if (mPrintInfo) // if (mPrintInfo)
// { // {
// System.out.print(" SPLIT VERTEX (CUT) "); // System.out.print(" SPLIT VERTEX (CUT) ");
// System.out.print(pLastVertex); // System.out.print(LastVertex);
// System.out.print(" NEW VERTEX : "); // System.out.print(" NEW VERTEX : ");
// System.out.print(pNewVertex); // System.out.print(NewVertex);
// System.out.print(" NEW EDGE : "); // System.out.print(" NEW EDGE : ");
// System.out.print(pNewEdge); // System.out.print(NewEdge);
// System.out.println(); // System.out.println();
// } // }
// //
// //
// // set up for next iteration // // set up for next iteration
// //cout << "allUnprocessedEdgesOfVertex.size before " << allUnprocessedEdgesOfVertex.size() << endl; // //cout << "allUnprocessedEdgesOfVertex.size before " << allUnprocessedEdgesOfVertex.size() << endl;
// allUnprocessedEdgesOfVertex.remove(aTriple.pEdge_rigth); // allUnprocessedEdgesOfVertex.remove(aTriple.Edge_rigth);
// //cout << "allUnprocessedEdgesOfVertex.size after " << allUnprocessedEdgesOfVertex.size() << endl; // //cout << "allUnprocessedEdgesOfVertex.size after " << allUnprocessedEdgesOfVertex.size() << endl;
// pLastVertex = pNewVertex; // LastVertex = NewVertex;
// //
// // save changes in Trackchanges // // save changes in Trackchanges
// mpBuilding.getTrackChanges().addNewVertex(pNewVertex); // Building.getTrackChanges().addNewVertex(NewVertex);
// for (Face cpFace : getFacesForVertex(pNewVertex)) // for (Face Face : getFacesForVertex(NewVertex))
// { // {
// mpBuilding.getTrackChanges().changeFace((Face)cpFace); // Building.getTrackChanges().changeFace((Face)cpFace);
// } // }
// } // }
// //
...@@ -319,7 +330,7 @@ public class HealingBySweepPlanarity { ...@@ -319,7 +330,7 @@ public class HealingBySweepPlanarity {
// //
// for (SplitCutTriple aTriple : unsortedTriples) // for (SplitCutTriple aTriple : unsortedTriples)
// { // {
// if (aTriple.pFace_center == pMainFace) // if (aTriple.Face_center == MainFace)
// { // {
// sortedTriples.addLast(aTriple); // sortedTriples.addLast(aTriple);
// unsortedTriples.remove(aTriple); // unsortedTriples.remove(aTriple);
...@@ -327,30 +338,30 @@ public class HealingBySweepPlanarity { ...@@ -327,30 +338,30 @@ public class HealingBySweepPlanarity {
// } // }
// } // }
// //
// Face pCurrFace = sortedTriples.getFirst().pFace_center; // Face CurrFace = sortedTriples.getFirst().Face_center;
// Face pNextFace = sortedTriples.getFirst().pFace_rigth; // Face NextFace = sortedTriples.getFirst().Face_rigth;
// //
// while (unsortedTriples.size() != 0) // while (unsortedTriples.size() != 0)
// { // {
// //
// for (SplitCutTriple aTriple : unsortedTriples) // for (SplitCutTriple aTriple : unsortedTriples)
// { // {
// if (aTriple.pFace_center == pNextFace) // if (aTriple.Face_center == NextFace)
// { // {
// //
// if (aTriple.pFace_rigth == pCurrFace) // if (aTriple.Face_rigth == CurrFace)
// { // {
// Edge pTempEdge = aTriple.pEdge_left; // Edge TempEdge = aTriple.Edge_left;
// aTriple.pEdge_left = aTriple.pEdge_rigth; // aTriple.Edge_left = aTriple.Edge_rigth;
// aTriple.pEdge_rigth = pTempEdge; // aTriple.Edge_rigth = TempEdge;
// //
// Face pTempFace = aTriple.pFace_left; // Face pTempFace = aTriple.Face_left;
// aTriple.pFace_left = aTriple.pFace_rigth; // aTriple.Face_left = aTriple.Face_rigth;
// aTriple.pFace_rigth = pTempFace; // aTriple.Face_rigth = TempFace;
// } // }
// //
// pNextFace = aTriple.pFace_rigth; // NextFace = aTriple.Face_rigth;
// pCurrFace = aTriple.pFace_center; // CurrFace = aTriple.Face_center;
// //
// sortedTriples.addLast(aTriple); // sortedTriples.addLast(aTriple);
// unsortedTriples.remove(aTriple); // unsortedTriples.remove(aTriple);
...@@ -367,7 +378,7 @@ public class HealingBySweepPlanarity { ...@@ -367,7 +378,7 @@ public class HealingBySweepPlanarity {
// //
// public Vertex splitVertexPull(Vertex pVertexToSplit, Face pFaceToSweep, final LinkedList<Face> newNeighborFaces, LinkedList<Edge > edgesToElongateList) // public Vertex splitVertexPull(Vertex pVertexToSplit, Face FaceToSweep, final LinkedList<Face> newNeighborFaces, LinkedList<Edge > edgesToElongateList)
// { // {
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// // check if there are 2 neighbor faces of pFaceToSweep that are connected to the vertex // // check if there are 2 neighbor faces of pFaceToSweep that are connected to the vertex
...@@ -376,30 +387,30 @@ public class HealingBySweepPlanarity { ...@@ -376,30 +387,30 @@ public class HealingBySweepPlanarity {
// if (newNeighborFaces.size() != 2) // if (newNeighborFaces.size() != 2)
// { // {
// EDGE_WARNING << " size of newNeighborFaces should be 2 - this case is not handled yet " << EDGE_ENDL; // EDGE_WARNING << " size of newNeighborFaces should be 2 - this case is not handled yet " << EDGE_ENDL;
// EDGE_WARNING << " this occures for face " << pFaceToSweep << " and vertex " << pVertexToSplit << "." << EDGE_ENDL; // EDGE_WARNING << " this occures for face " << FaceToSweep << " and vertex " << VertexToSplit << "." << EDGE_ENDL;
// } // }
// //
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// // get the two planes of the neighbor faces // // get the two planes of the neighbor faces
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// //
// Face cpNeighborFace1 = newNeighborFaces.getFirst(); // Face NeighborFace1 = newNeighborFaces.getFirst();
// Face cpNeighborFace2 = newNeighborFaces.getLast(); // Face cpNeighborFace2 = newNeighborFaces.getLast();
// Surface cpSurface1 = cpNeighborFace1.getGeometry(); // Surface Surface1 = NeighborFace1.getGeometry();
// Surface cpSurface2 = cpNeighborFace2.getGeometry(); // Surface Surface2 = NeighborFace2.getGeometry();
// if (!cpSurface1.isOfType(Plane.getClassTypeId())) // if (!Surface1.isOfType(Plane.getClassTypeId()))
// { // {
// EDGE_ERROR << " Face " << cpNeighborFace1 << " has no Plane" << EDGE_ENDL; // EDGE_ERROR << " Face " << NeighborFace1 << " has no Plane" << EDGE_ENDL;
// } // }
// if (!cpSurface1.isOfType(Plane.getClassTypeId())) // if (!Surface1.isOfType(Plane.getClassTypeId()))
// { // {
// EDGE_ERROR << " Face " << cpNeighborFace2 << " has no Plane" << EDGE_ENDL; // EDGE_ERROR << " Face " << NeighborFace2 << " has no Plane" << EDGE_ENDL;
// } // }
// //
// Plane pPlane1 = (Plane)cpSurface1; // Plane Plane1 = (Plane)Surface1;
// GmPlane gmPlane1 = pPlane1.getEquation(); // GmPlane gmPlane1 = Plane1.getEquation();
// Plane pPlane2 = (Plane)cpSurface2; // Plane Plane2 = (Plane)Surface2;
// GmPlane gmPlane2 = pPlane2.getEquation(); // GmPlane gmPlane2 = Plane2.getEquation();
// //
// //
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
...@@ -420,11 +431,11 @@ public class HealingBySweepPlanarity { ...@@ -420,11 +431,11 @@ public class HealingBySweepPlanarity {
// UnitVector3d intersetionDirection = interesctionStraight.getDir(); // UnitVector3d intersetionDirection = interesctionStraight.getDir();
// //
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// // create new pNewVertex // // create new NewVertex
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// //
// Point3d pointCopy = pVertexToSplit.getPositionOnGeometry(); // Point3d pointCopy = VertexToSplit.getPositionOnGeometry();
// Vertex pNewVertex = new Vertex(pointCopy); // Vertex NewVertex = new Vertex(pointCopy);
// //
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// // create new Edge and connect pVertex with pNewVertex ( use straight from above) // // create new Edge and connect pVertex with pNewVertex ( use straight from above)
...@@ -432,54 +443,54 @@ public class HealingBySweepPlanarity { ...@@ -432,54 +443,54 @@ public class HealingBySweepPlanarity {
// //
// GmStraight gmStraight = new GmStraight(pVertexToSplit.getPositionOnGeometry(), intersetionDirection); // GmStraight gmStraight = new GmStraight(pVertexToSplit.getPositionOnGeometry(), intersetionDirection);
// Straight straight = new Straight(gmStraight); // TODO : simply use method getIntersectionStraight // Straight straight = new Straight(gmStraight); // TODO : simply use method getIntersectionStraight
// Edge pNewEdge = new Edge(straight, Topology.FORWARD, pVertexToSplit, pNewVertex); // Edge pNewEdge = new Edge(straight, Topology.FORWARD, VertexToSplit, NewVertex);
// //
// //
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// / get the two neighbor loops // / get the two neighbor loops
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// //
// Loop pLoop1 = (Loop)cpNeighborFace1.getLoop(); // Loop pLoop1 = (Loop)NeighborFace1.getLoop();
// Loop pLoop2 = (Loop)cpNeighborFace2.getLoop(); // Loop pLoop2 = (Loop)NeighborFace2.getLoop();
// //
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// // get the corresponding coEdges of the loops where the new Coedges should be placed // // get the corresponding coEdges of the loops where the new Coedges should be placed
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// //
// CoEdge pPrevCoEdge1; // CoEdge PrevCoEdge1;
// CoEdge pNextCoEdge1; // CoEdge NextCoEdge1;
// CoEdge pPrevCoEdge2; // CoEdge PrevCoEdge2;
// CoEdge pNextCoEdge2; // CoEdge NextCoEdge2;
// findPrevAndNextCoEdge(pVertexToSplit, pLoop1, pPrevCoEdge1, pNextCoEdge1); // findPrevAndNextCoEdge(VertexToSplit, Loop1, PrevCoEdge1, NextCoEdge1);
// findPrevAndNextCoEdge(pVertexToSplit, pLoop2, pPrevCoEdge2, pNextCoEdge2); // findPrevAndNextCoEdge(VertexToSplit, Loop2, PrevCoEdge2, NextCoEdge2);
// //
// //
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// // set new relationship between pNewVertex and edges // // set new relationship between NewVertex and edges
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// for (Edge pTempEdge : getAllEdgesForVertex(pVertexToSplit)) // for (Edge TempEdge : getAllEdgesForVertex(VertexToSplit))
// { // {
// // the two edges of the sweepface will get the pNewVertex (all other edges with that vertex will keep it) // // the two edges of the sweepface will get the NewVertex (all other edges with that vertex will keep it)
// if (pTempEdge == pNewEdge) // if (TempEdge == NewEdge)
// { // {
// // pTempEdge is pNewEdge -> ignore // // TempEdge is NewEdge -> ignore
// continue; // continue;
// } // }
// //
// if (edgesToElongateList.contains(pTempEdge)) // if (edgesToElongateList.contains(TempEdge))
// { // {
// // pTempEdge is elongated edge -> ignore // // TempEdge is elongated edge -> ignore
// continue; // continue;
// } // }
// //
// if (pTempEdge.getStartVertex() == pVertexToSplit) // if (TempEdge.getStartVertex() == VertexToSplit)
// { // {
// //
// ((Edge)pTempEdge).setStartVertex(pNewVertex); // ((Edge)TempEdge).setStartVertex(NewVertex);
// } // }
// else if (pTempEdge.getEndVertex() == pVertexToSplit) // else if (TempEdge.getEndVertex() == VertexToSplit)
// { // {
// ((Edge)pTempEdge).setEndVertex(pNewVertex); // ((Edge)TempEdge).setEndVertex(NewVertex);
// } // }
// else // else
// { // {
...@@ -491,56 +502,56 @@ public class HealingBySweepPlanarity { ...@@ -491,56 +502,56 @@ public class HealingBySweepPlanarity {
// // create coEdges; the two faces are the corresponding faces to the coEdges // // create coEdges; the two faces are the corresponding faces to the coEdges
// // -------------------------------------------------------------------- // // --------------------------------------------------------------------
// //
// CoEdge pNewCoEdge1; // CoEdge NewCoEdge1;
// if (pPrevCoEdge1.getEndVertex() == pNewEdge.getStartVertex() || pPrevCoEdge1.getStartVertex() == pNewEdge.getEndVertex()) // if (PrevCoEdge1.getEndVertex() == NewEdge.getStartVertex() || PrevCoEdge1.getStartVertex() == NewEdge.getEndVertex())
// { // {
// pNewCoEdge1 = new CoEdge(pNewEdge, Topology.FORWARD); // NewCoEdge1 = new CoEdge(NewEdge, Topology.FORWARD);
// } // }
// else if (pPrevCoEdge1.getEndVertex() == pNewEdge.getEndVertex() || pPrevCoEdge1.getStartVertex() == pNewEdge.getStartVertex()) // else if (PrevCoEdge1.getEndVertex() == NewEdge.getEndVertex() || PrevCoEdge1.getStartVertex() == NewEdge.getStartVertex())
// { // {
// pNewCoEdge1 = new CoEdge(pNewEdge, Topology.REVERSED); // NewCoEdge1 = new CoEdge(NewEdge, Topology.REVERSED);
// } // }
// setGeometryForCoEdge(pNewCoEdge1); // setGeometryForCoEdge(NewCoEdge1);
// //
// CoEdge pNewCoEdge2; // CoEdge NewCoEdge2;
// if (pPrevCoEdge2.getEndVertex() == pNewEdge.getStartVertex() || pPrevCoEdge2.getStartVertex() == pNewEdge.getEndVertex()) // if (PrevCoEdge2.getEndVertex() == NewEdge.getStartVertex() || PrevCoEdge2.getStartVertex() == NewEdge.getEndVertex())
// { // {
// pNewCoEdge2 = new CoEdge(pNewEdge, Topology.FORWARD); // NewCoEdge2 = new CoEdge(NewEdge, Topology.FORWARD);
// } // }
// else if (pPrevCoEdge2.getEndVertex() == pNewEdge.getEndVertex() || pPrevCoEdge2.getStartVertex() == pNewEdge.getStartVertex()) // else if (PrevCoEdge2.getEndVertex() == NewEdge.getEndVertex() || PrevCoEdge2.getStartVertex() == NewEdge.getStartVertex())
// { // {
// pNewCoEdge2 = new CoEdge(pNewEdge, Topology.REVERSED); // NewCoEdge2 = new CoEdge(NewEdge, Topology.REVERSED);
// } // }
// setGeometryForCoEdge(pNewCoEdge2); // setGeometryForCoEdge(NewCoEdge2);
// //
// pNewCoEdge1.setPartner(pNewCoEdge2); // NewCoEdge1.setPartner(NewCoEdge2);
// pNewCoEdge2.setPartner(pNewCoEdge1); // NewCoEdge2.setPartner(NewCoEdge1);
// pNewCoEdge1.setPrevious(pPrevCoEdge1); // NewCoEdge1.setPrevious(PrevCoEdge1);
// pNewCoEdge1.setNext(pNextCoEdge1); // NewCoEdge1.setNext(NextCoEdge1);
// pNewCoEdge2.setPrevious(pPrevCoEdge2); // NewCoEdge2.setPrevious(PrevCoEdge2);
// pNewCoEdge2.setNext(pNextCoEdge2); // NewCoEdge2.setNext(NextCoEdge2);
// //
// pLoop1.addCoEdge(pNewCoEdge1); // Loop1.addCoEdge(NewCoEdge1);
// pLoop2.addCoEdge(pNewCoEdge2); // Loop2.addCoEdge(NewCoEdge2);
// //
// if (mPrintInfo) // if (mPrintInfo)
// { // {
// System.out.print(" SPLIT VERTEX (PULL) "); // System.out.print(" SPLIT VERTEX (PULL) ");
// System.out.print(pVertexToSplit); // System.out.print(VertexToSplit);
// System.out.print(" NEW VERTEX : "); // System.out.print(" NEW VERTEX : ");
// System.out.print(pNewVertex); // System.out.print(NewVertex);
// System.out.print(" NEW EDGE : "); // System.out.print(" NEW EDGE : ");
// System.out.print(pNewEdge); // System.out.print(NewEdge);
// System.out.println(); // System.out.println();
// } // }
// //
// // save changes in Trackchanges // // save changes in Trackchanges
// mpBuilding.getTrackChanges().addNewVertex(pNewVertex); // Building.getTrackChanges().addNewVertex(NewVertex);
// for (Face cpFace : getFacesForVertex(pNewVertex)) // for (Face Face : getFacesForVertex(NewVertex))
// { // {
// mpBuilding.getTrackChanges().changeFace((Face)cpFace); // mpBuilding.getTrackChanges().changeFace((Face)Face);
// } // }
// return pNewVertex; // return NewVertex;
// //
// } // }
......
package de.hft.stuttgart.citydoctor2.healer.bht; package de.hft.stuttgart.citydoctor2.healer.bht;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.math.Edge2d;
public class SplitCutTriple { public class SplitCutTriple {
// public static void main(String[] args) { // public static void main(String[] args) {
...@@ -7,15 +10,15 @@ public class SplitCutTriple { ...@@ -7,15 +10,15 @@ public class SplitCutTriple {
// //
// } // }
// public Face pFace_left; // public Face Face_left;
// public Edge pEdge_left; public Edge Edge_left;
// public Face pFace_center; // public Face Face_center;
// public Edge pEdge_rigth; public Edge Edge_rigth;
// public Face pFace_rigth; // public Face Face_rigth;
//
// public boolean equalsTo(SplitCutTriple st) // public boolean equalsTo(SplitCutTriple st)
// { // {
// if (st.pFace_center == pFace_center) // if (st.Face_center == Face_center)
// { // {
// return true; // return true;
// } // }
......
...@@ -3,22 +3,28 @@ package de.hft.stuttgart.citydoctor2.healing.bht; ...@@ -3,22 +3,28 @@ package de.hft.stuttgart.citydoctor2.healing.bht;
import java.io.IOException; import java.io.IOException;
//import java.io.InputStream; //new //import java.io.InputStream; //new
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.Scanner; //new import java.util.Scanner; //new
import org.junit.Test; import org.junit.Test;
import de.hft.stuttgart.citydoctor2.check.AbstractVisitor; import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.check.CheckableVisitor;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration; import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.datastructure.Building; import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel; import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon; import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry; import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon; import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing; import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing.LinearRingType;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException; import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.healing.TestUtil; import de.hft.stuttgart.citydoctor2.healing.TestUtil;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException; import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
...@@ -33,107 +39,196 @@ public class TestExample { ...@@ -33,107 +39,196 @@ public class TestExample {
public static void main(String[] args) throws CityGmlParseException, IOException, InvalidGmlFileException { public static void main(String[] args) throws CityGmlParseException, IOException, InvalidGmlFileException {
System.out.println("Start TestExample... \n"); //new System.out.println("Start TestExample... \n"); //new
// String path = args[0]; // String path = args[0];
// String path = "src/test/resources/SimpleSolid_SrefBS.gml"; //new // String path = "src/test/resources/SimpleSolid_SrefBS.gml"; //new valid LoD2 model
String path = "src/test/resources/TestBuilding1.gml"; //new // String path = "src/test/resources/TestBuilding1.gml"; //new block model
String path = "src/test/resources/bht/SimpleSolid_SrefBS-GE-gml-PO-0001-T0002.gml"; //new valid model with inner rings
// String path = "src/test/resources/bht/KreishausFeuerwache.gml"; // too big, main gets terminated
// String path = "src/test/resources/bht/TestBuilding_SelfInt.gml";
ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig(); ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig();
CityDoctorModel model = TestUtil.loadCityModel(path, config); CityDoctorModel model = TestUtil.loadCityModel(path, config);
System.out.println("\nModel has been loaded..."); //new System.out.println("\nModel has been loaded..."); //new
// //inside class Geometry
// @Override
// public void accept(Check c) {
// super.accept(c);
// if (c.canExecute(this)) {
// c.check(this);
// }
// for (Polygon p : polygons) {
// p.accept(c);
// }
// }
// visitor // visitor
// filter duplicate polygons out // filter duplicate polygons out
Set<ConcretePolygon> allBuildingPolygons = new HashSet<>(); Set<ConcretePolygon> allBuildingPolygons = new HashSet<>();
for (Building b : model.getBuildings()) { for (Building b : model.getBuildings()) {
b.accept(new AbstractVisitor() { b.accept(new CheckableUtilsVisitor() {
public void check(Polygon poly) { public void check(Polygon poly) {
allBuildingPolygons.add(poly.getOriginal()); allBuildingPolygons.add(poly.getOriginal());
} }
}); });
} }
System.out.println("\nConcretePolygon HashSet elements:" + allBuildingPolygons); //new System.out.println("\nPolygons via visitor:" + allBuildingPolygons); //new
// for loop // // for loop
List<Polygon> allBuildingPolygons2 = new ArrayList<>(); // List<Polygon> allBuildingPolygons2 = new ArrayList<>();
// for (Building b : model.getBuildings()) {
// for (Geometry geom : b.getGeometries()) {
// for (Polygon p : geom.getPolygons()) {
// allBuildingPolygons2.add(p);
//// allBuildingPolygons2.add(p.getOriginal()); //new
// }
// }
// }
// System.out.println("\nPolygon List:" + allBuildingPolygons2); //new
// new: LinearRings
// visitor
// filter duplicate linear rings out
Set<LinearRing> allBuildingLinearRings = new HashSet<>();
for (Building b : model.getBuildings()) { for (Building b : model.getBuildings()) {
for (Geometry geom : b.getGeometries()) { b.accept(new CheckableUtilsVisitor() {
for (Polygon p : geom.getPolygons()) { public void check(LinearRing ring) {
allBuildingPolygons2.add(p); allBuildingLinearRings.add(ring);
} }
}
});
} }
System.out.println("\nPolygon List:" + allBuildingPolygons2); //new System.out.println("\nLinearRings via visitor:" + allBuildingLinearRings); //new
// //inside class ConcretePolygon
// @Override // new: ExteriorRings
// public void accept(Check c) { // visitor
// super.accept(c); // filter duplicate exterior rings out
// if (c.canExecute(this)) { Set<LinearRing> allBuildingExteriorRings = new HashSet<>();
// c.check(this); for (Building b : model.getBuildings()) {
// } b.accept(new CheckableUtilsVisitor() {
// if (exterior != null) { public void check(LinearRing ring) {
// exterior.accept(c); allBuildingExteriorRings.add(ring.getParent().getExteriorRing());
// } }
// if (innerRings != null) { });
// for (LinearRing lr : innerRings) { }
// lr.accept(c); System.out.println("\nExteriorRings via visitor:" + allBuildingExteriorRings); //new
// // new: ExteriorRings (List)
// // for loop
// List<LinearRing> allBuildingExteriorRings2 = new ArrayList<>();
// for (Building b : model.getBuildings()) {
// for (Geometry geom : b.getGeometries()) {
// for (Polygon p : geom.getPolygons()) {
// allBuildingExteriorRings2.add(p.getOriginal().getExteriorRing());
// } // }
// } // }
// } // }
// System.out.println("\nExteriorRing List:" + allBuildingExteriorRings2); //new
// new: InnerRings
// visitor // visitor
// filter duplicate polygons out // filter duplicate inner rings out
Set<ConcretePolygon> allBuildingInnerRings = new HashSet<>(); Set<LinearRing> allBuildingInnerRings = new HashSet<>();
for (Building b : model.getBuildings()) { for (Building b : model.getBuildings()) {
b.accept(new AbstractVisitor() { b.accept(new CheckableUtilsVisitor() {
public void check(Polygon poly) { public void check(Polygon poly) {
allBuildingInnerRings.add(poly.getOriginal()); allBuildingInnerRings.addAll(poly.getOriginal().getInnerRings());
} }
}); });
} }
System.out.println("\nConcretePolygon HashSet elements:" + allBuildingInnerRings); //new System.out.println("\nInnerRings via visitor:" + allBuildingInnerRings); //new
// new: LinearRing from ConcretePolygon // // new: InnerRings (List)
// for loop // // for loop
List<LinearRing> allBuildingInnerRings2 = new ArrayList<>(); // List<LinearRing> allBuildingInnerRings2 = new ArrayList<>();
for (Building b : model.getBuildings()) { // for (Building b : model.getBuildings()) {
for (Geometry geom : b.getGeometries()) { // for (Geometry geom : b.getGeometries()) {
for (Polygon p : geom.getPolygons()) { // for (Polygon p : geom.getPolygons()) {
for (LinearRing lr : p.getInnerRings()) { // for (LinearRing lr : p.getInnerRings()) {
allBuildingInnerRings2.add(lr); // allBuildingInnerRings2.add(lr);
}
// for (LinearRing extRing : p.getExteriorRing()) {
//allBuildingInnerRings.add(extRing);
// for (LinearRing lr : extRing.getLinearRings()) {
// allBuildingInnerRings.add(lr);
// }
// } // }
} //
} // }
} // }
System.out.println("\nInnerRing List:" + allBuildingInnerRings2); //new // }
// System.out.println("\nInnerRing List:" + allBuildingInnerRings2); //new
}
// //@Test
// public void testMain() throws CityGmlParseException, IOException, InvalidGmlFileException {
// TestExample.main(new String[]{});
// }
// // get Vertices for LinearRing, ExteriorRing and InteriorRing
// // new: LinearRingVertices
// // visitor
// // filter duplicate linear rings out
// Set<Vertex> allBuildingLinearRingVertices = new HashSet<>();
// for (Building b : model.getBuildings()) {
// b.accept(new CheckableUtilsVisitor() {
// public void check(LinearRing ring) {
// allBuildingLinearRingVertices.addAll(ring.getVertices());
// }
//
// });
// }
// System.out.println("\nLinearRingVertices via visitor:" + allBuildingLinearRingVertices); //new
// // new: ExteriorRingVertices
// // visitor
// // filter duplicate exterior rings out
// Set<Vertex> allBuildingExteriorRingVertices = new HashSet<>();
// for (Building b : model.getBuildings()) {
// b.accept(new CheckableUtilsVisitor() {
// public void check(LinearRing ring) {
// allBuildingExteriorRingVertices.addAll(ring.getParent().getOriginal().getExteriorRing().getVertices());
// }
//
// });
// }
// System.out.println("\nExteriorRingVertices via visitor:" + allBuildingExteriorRingVertices); //new
// // new: ExteriorRingVertices (List)
// // for loop
// List<Vertex> allBuildingExteriorRingVertices2 = new ArrayList<>();
// for (Building b : model.getBuildings()) {
// for (Geometry geom : b.getGeometries()) {
// for (Polygon p : geom.getPolygons()) {
// for (Vertex v : p.getOriginal().getExteriorRing().getVertices()) {
// allBuildingExteriorRingVertices2.add(v);
// }
// }
// }
// }
// System.out.println("\nExteriorRingVertices List:" + allBuildingExteriorRingVertices2); //new
// // new: InnerRingVertices
// // visitor
// // filter duplicate linear vertices out
// Set<Vertex> allBuildingInnerRingVertices = new HashSet<>();
// for (Building b : model.getBuildings()) {
// b.accept(new CheckableUtilsVisitor() {
// public void check(Polygon poly) {
// poly.getOriginal().getInnerRings().forEach(ring->allBuildingInnerRingVertices.addAll(ring.getVertices()));
// }
// });
// }
// System.out.println("\nInnerRingVertices via visitor:" + allBuildingInnerRingVertices); //new
// // new: InnerRingVertices (List)
// // for loop
// List<Vertex> allInnerRingVertices2 = new ArrayList<>();
// for (Building b : model.getBuildings()) {
// for (Geometry geom : b.getGeometries()) {
// for (Polygon p : geom.getPolygons()) {
// for (LinearRing lr : p.getInnerRings()) {
// for (Vertex v : lr.getVertices()) {
// allInnerRingVertices2.add(v);
// }
// }
//
// }
// }
// }
// System.out.println("\nInnerRingVertices List:" + allInnerRingVertices2); //new
// // TODO: HashMap to show Ring and gmlId
// Map<LinearRing, Set<Vertex>> test = new HashMap<>();
}
} }
Supports Markdown
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