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

remove low memory mode

parent 8536ec35
Pipeline #12291 failed with stage
in 1 minute and 15 seconds
......@@ -91,9 +91,6 @@ public class IntersectionErrorsTest {
geom.addPolygon(p1);
geom.addPolygon(p2);
geom.prepareForChecking();
System.out.println();
for (Vertex v : p1.getExteriorRing().getVertices()) {
System.out.println(v);
......
......@@ -24,17 +24,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
import de.hft.stuttgart.citydoctor2.utils.CheckErrorFound;
import de.hft.stuttgart.citydoctor2.utils.visitors.CheckableErrorCollector;
import de.hft.stuttgart.citydoctor2.utils.visitors.ClearResultsVisitor;
import de.hft.stuttgart.citydoctor2.utils.visitors.ClearMetaInformationVisitor;
import de.hft.stuttgart.citydoctor2.utils.visitors.ContainsAnyErrorVisitor;
import de.hft.stuttgart.citydoctor2.utils.visitors.ContainsErrorVisitor;
import de.hft.stuttgart.citydoctor2.utils.visitors.PrepareForCheckingVisitor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.datastructure.GmlId;
/**
* Interface to indicate that this object can be checked by Checks.
......@@ -91,23 +89,6 @@ public abstract class Checkable implements Serializable {
*/
public abstract GmlId getGmlId();
/**
* This should be called before executing a check if low memory consumption
* method has been enabled. Creates edges and additional meta
* information necessary to perform checks.
*/
public void prepareForChecking() {
this.accept(new PrepareForCheckingVisitor());
}
/**
* This should be called after checking has been done. Removes any
* created meta information like edges to free up memory.
*/
public void clearMetaInformation() {
this.accept(new ClearMetaInformationVisitor());
}
/**
* Checks if the object, or any object in its datastructure, has a specific error or is not fulfilling the dependencies
* of it.
......
......@@ -362,15 +362,6 @@ public class Geometry extends GmlElement {
return false;
}
public void clearMetaData() {
if (vertices != null) {
adjacentRingsOfVertices = new HashMap<>();
vertices = null;
}
edges = null;
edgeMap = null;
}
public Color getRenderColor() {
return parent.getRenderColor();
}
......
......@@ -121,14 +121,6 @@ public class ImplicitGeometryHolder extends Geometry {
LibraryObject.preparePrototypeGeometriesForChecking();
}
/**
* Clears metadata creating for checking of prototype geometries and releases the metadata lock
*/
public static void clearMetaDataOfPrototypeGeometries(){
RelativeGeometry.clearMetaDataOfPrototypeGeometries();
LibraryObject.clearMetaDataOfPrototypeGeometries();
}
@Override
public void accept(CheckableVisitor c) {
prototypeGeometry.accept(c);
......
......@@ -89,11 +89,6 @@ public class LibraryObject extends Geometry {
metadataLocked = true;
}
public static void clearMetaDataOfPrototypeGeometries() {
metadataLocked = false;
libraryObjects.values().forEach(LibraryObject::clearMetaData);
}
@Override
public void updateEdgesAndVertices(){
if (!metadataLocked) {
......@@ -101,11 +96,4 @@ public class LibraryObject extends Geometry {
}
}
@Override
public void clearMetaData(){
if (!metadataLocked) {
super.clearMetaData();
}
}
}
......@@ -45,22 +45,10 @@ public class RelativeGeometry extends Geometry {
metadataLocked = true;
}
public static void clearMetaDataOfPrototypeGeometries() {
metadataLocked = false;
relativeGeometries.values().forEach(RelativeGeometry::clearMetaData);
}
@Override
public void updateEdgesAndVertices(){
if (!metadataLocked) {
super.updateEdgesAndVertices();
}
}
@Override
public void clearMetaData(){
if (!metadataLocked) {
super.clearMetaData();
}
}
}
......@@ -24,11 +24,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import java.util.function.Function;
import de.hft.stuttgart.citydoctor2.database.FeatureCache;
import de.hft.stuttgart.citydoctor2.database.UnconnectedCache;
import de.hft.stuttgart.citydoctor2.datastructure.OtherConstructionObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.CityGMLVersion;
......@@ -113,6 +109,8 @@ import org.xmlobjects.gml.model.geometry.primitives.Solid;
import org.xmlobjects.gml.model.geometry.primitives.SolidProperty;
import org.xmlobjects.gml.model.geometry.primitives.SurfaceProperty;
import de.hft.stuttgart.citydoctor2.database.FeatureCache;
import de.hft.stuttgart.citydoctor2.database.UnconnectedCache;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractBuilding;
import de.hft.stuttgart.citydoctor2.datastructure.AbstractTunnel;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
......@@ -142,6 +140,7 @@ import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.LinkedPolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Opening;
import de.hft.stuttgart.citydoctor2.datastructure.OtherConstructionObject;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.RelativeGeometry;
import de.hft.stuttgart.citydoctor2.datastructure.ReliefObject;
......@@ -162,7 +161,6 @@ import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
import de.hft.stuttgart.citydoctor2.math.graph.KDTree;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.Localization;
public class Citygml3FeatureMapper extends ObjectWalker {
......@@ -172,7 +170,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private final CityDoctorModel model;
private final ParserConfiguration config;
private final Path directory;
private final double neighborDistance;
private final double neighborDistance;
private Map<String, ConcretePolygon> polygonMap = new HashMap<>();
private Map<String, CompositeCollection> compositeMap = new HashMap<>();;
private List<ResolvableReference> references = new ArrayList<>();
......@@ -181,19 +179,19 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private Map<String, List<GmlId>> unresolvedPolyRefIDMap = new HashMap<>();
private Map<String, GmlId> parsedPolygonsIdMap = new HashMap<>();
public Citygml3FeatureMapper(ParserConfiguration config, Path path, boolean unconnected) {
this.config = config;
this.directory = path.getParent();
public Citygml3FeatureMapper(ParserConfiguration config, Path path, boolean unconnected) {
this.config = config;
this.directory = path.getParent();
if (unconnected){
if (unconnected) {
model = new CityDoctorModel(config, path.toFile(), new UnconnectedCache());
} else {
featureCache.resetCache();
ImplicitGeometryHolder.resetObjectMaps();
model = new CityDoctorModel(config, path.toFile(), featureCache);
}
neighborDistance = 1.8d / Math.pow(10, config.getNumberOfRoundingPlaces());
}
neighborDistance = 1.8d / Math.pow(10, config.getNumberOfRoundingPlaces());
}
public static void parseId(AbstractGML gml, GmlElement gmlElement) {
String id = gml.getId();
......@@ -217,22 +215,23 @@ public class Citygml3FeatureMapper extends ObjectWalker {
StringJoiner joiner = new StringJoiner(", ");
gmlIds.forEach(gmlId -> joiner.add(gmlId.toString()));
GmlId crossFeatureId = parsedPolygonsIdMap.get(id);
//TODO: Localize String
logger.warn("Polygon {} of Feature {} is being referenced in other Features: {}", id, crossFeatureId, joiner);
// TODO: Localize String
logger.warn("Polygon {} of Feature {} is being referenced in other Features: {}", id, crossFeatureId,
joiner);
crossRefs.add(id);
}
}
if (xLinkGlobalError) {
//TODO: Localize String
logger.warn("Model has Features containing cross-feature references without their own copies of the referenced polygons");
// TODO: Localize String
logger.warn(
"Model has Features containing cross-feature references without their own copies of the referenced polygons");
}
crossRefs.forEach(unresolvedPolyRefIDMap::remove);
if(!unresolvedPolyRefIDMap.isEmpty()) {
if (!unresolvedPolyRefIDMap.isEmpty()) {
logger.warn("Model contains polygon references that could not be found");
}
}
@Override
public void visit(AbstractSpace space) {
// if we are here, an AbstractSpace thing was read that is not handled in the
......@@ -241,7 +240,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
@Override
public void visit(OtherConstruction gmlOc){
public void visit(OtherConstruction gmlOc) {
OtherConstructionObject oco = new OtherConstructionObject();
oco.setGmlObject(gmlOc);
mapAbstractOccupiedSpace(gmlOc, oco, Orientation.OUTWARD);
......@@ -368,17 +367,17 @@ public class Citygml3FeatureMapper extends ObjectWalker {
@Override
public void visit(MassPointRelief rel) {
//Method stub for implementation if requested
// Method stub for implementation if requested
}
@Override
public void visit(BreaklineRelief rel) {
//Method stub for implementation if requested
// Method stub for implementation if requested
}
@Override
public void visit(RasterRelief rel) {
//Method stub for implementation if requested
// Method stub for implementation if requested
}
};
......@@ -391,11 +390,11 @@ public class Citygml3FeatureMapper extends ObjectWalker {
public void mapTINRelief(TINRelief relief, ReliefObject reliefObject) {
TinObject to = new TinObject(relief);
Lod reliefLod = switch (relief.getLod()) {
case 1 -> Lod.LOD1;
case 2 -> Lod.LOD2;
case 3 -> Lod.LOD3;
case 4 -> null;
default -> throw new IllegalStateException("TINRelief has unexpected LOD value: " + relief.getLod());
case 1 -> Lod.LOD1;
case 2 -> Lod.LOD2;
case 3 -> Lod.LOD3;
case 4 -> null;
default -> throw new IllegalStateException("TINRelief has unexpected LOD value: " + relief.getLod());
};
if (reliefLod == null) {
logger.warn("IllegalState: TINRelief {} has LOD value 4!", relief.getId());
......@@ -428,14 +427,14 @@ public class Citygml3FeatureMapper extends ObjectWalker {
veg.setGmlObject(solitaryVegetationObject);
mapAbstractVegetationObject(solitaryVegetationObject, veg);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod1Geometry(), Lod.LOD1,
veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod2Geometry(), Lod.LOD2,
veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod3Geometry(), Lod.LOD3,
veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod4Geometry(), Lod.LOD4,
veg, Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod1Geometry(), Lod.LOD1, veg,
Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod2Geometry(), Lod.LOD2, veg,
Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod3Geometry(), Lod.LOD3, veg,
Orientation.OUTWARD);
parseAndAddAbstractGeometry(solitaryVegetationObject.getDeprecatedProperties().getLod4Geometry(), Lod.LOD4, veg,
Orientation.OUTWARD);
finishCityObjectConstruction(veg);
model.addVegetation(veg);
......@@ -647,7 +646,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void parseTunnelConstructiveElements(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
private void parseTunnelConstructiveElements(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel,
AbstractTunnel cdTunnel) {
for (TunnelConstructiveElementProperty teProp : gmlTunnel.getTunnelConstructiveElements()) {
var gmlTc = teProp.getObject();
if (gmlTc == null) {
......@@ -658,7 +658,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void parseTunnelFurniture(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
private void parseTunnelFurniture(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel,
AbstractTunnel cdTunnel) {
for (TunnelFurnitureProperty tfProp : gmlTunnel.getTunnelFurniture()) {
var gmlTf = tfProp.getObject();
if (gmlTf == null) {
......@@ -680,7 +681,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void parseTunnelInstallations(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel, AbstractTunnel cdTunnel) {
private void parseTunnelInstallations(org.citygml4j.core.model.tunnel.AbstractTunnel gmlTunnel,
AbstractTunnel cdTunnel) {
for (TunnelInstallationProperty tiProp : gmlTunnel.getTunnelInstallations()) {
var gmlTi = tiProp.getObject();
if (gmlTi == null) {
......@@ -703,7 +705,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
GeometryProperty<?> lod4Prop = gmlTi.getDeprecatedProperties().getLod4Geometry();
parseAndAddAbstractGeometry(lod4Prop, Lod.LOD4, ti, orientation);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlTi.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -900,7 +901,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
finishTransportationMapping(top);
}
private void mapAbstractThematicSurface(AbstractThematicSurface ats, CityObject co) {
mapAbstractSpaceBoundary(ats, co);
parseAndAddMultiSurface(ats.getLod0MultiSurface(), Lod.LOD0, co);
......@@ -930,7 +930,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseId(ag, to);
}
private void finishTransportationMapping(TransportationObject to) {
finishCityObjectConstruction(to);
model.addTransportation(to);
......@@ -954,15 +953,16 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
for (AuxiliaryTrafficSpaceProperty atsp : ats.getAuxiliaryTrafficSpaces()) {
if (atsp.isSetObject()) {
TrafficSpaceObject atso = new TrafficSpaceObject(TrafficSpaceObject.TrafficSpaceType.AUXILIARY_TRAFFIC_SPACE);
TrafficSpaceObject atso = new TrafficSpaceObject(
TrafficSpaceObject.TrafficSpaceType.AUXILIARY_TRAFFIC_SPACE);
mapAuxiliaryTrafficSpace(atsp.getObject(), atso);
trsp.addAuxTrafficSpace(atso);
}
}
}
private void mapSectionsAndIntersections(List<SectionProperty> sectionProps, List<IntersectionProperty> intersectionProps,
TopLevelTransportFeature top) {
private void mapSectionsAndIntersections(List<SectionProperty> sectionProps,
List<IntersectionProperty> intersectionProps, TopLevelTransportFeature top) {
for (SectionProperty sectionProp : sectionProps) {
if (sectionProp.isSetObject()) {
TransportSection sect = new TransportSection(TransportSection.SectionType.SECTION);
......@@ -983,7 +983,6 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void mapTrafficSpace(TrafficSpace ts, TrafficSpaceObject tso) {
tso.setGmlObject(ts);
mapAbstractUnoccupiedSpace(ts, tso, Orientation.OUTWARD);
......@@ -1049,15 +1048,15 @@ public class Citygml3FeatureMapper extends ObjectWalker {
co.addGeometry(geom);
}
private void parseAndAddSolid(SolidProperty sp, Lod lod, CityObject co, Orientation orientation) {
if (sp == null || sp.getObject() == null) {
return;
}
Geometry geom = parseSolid(sp.getObject(), lod, orientation);
if (geom != null) {
co.addGeometry(geom);
}
}
private void parseAndAddSolid(SolidProperty sp, Lod lod, CityObject co, Orientation orientation) {
if (sp == null || sp.getObject() == null) {
return;
}
Geometry geom = parseSolid(sp.getObject(), lod, orientation);
if (geom != null) {
co.addGeometry(geom);
}
}
private void parseImplicitGeometry(AbstractOccupiedSpace aos, CityObject co, Orientation orientation) {
for (int i = 1; i <= 3; i++) {
......@@ -1084,10 +1083,10 @@ public class Citygml3FeatureMapper extends ObjectWalker {
ImplicitGeometryHolder igh = null;
if (ig.getLibraryObject() != null) {
LibraryObject libObj = null;
if (directory != null){
Path libraryObjectPath = directory.resolve(ig.getLibraryObject());
libObj = LibraryObject.of(libraryObjectPath, config);
}
if (directory != null) {
Path libraryObjectPath = directory.resolve(ig.getLibraryObject());
libObj = LibraryObject.of(libraryObjectPath, config);
}
if (libObj != null) {
igh = new ImplicitGeometryHolder(ig, libObj);
}
......@@ -1143,7 +1142,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
handlePolygonReference(href, geom);
}
}
for(String polygonId: polygonMap.keySet()){
for (String polygonId : polygonMap.keySet()) {
parsedPolygonsIdMap.put(polygonId, co.getGmlId());
}
......@@ -1156,7 +1155,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
private void handlePolygonReference(String href, Geometry geom) {
ConcretePolygon concPoly = polygonMap.get(href);
if (concPoly == null) {
List<GmlId> featureList = unresolvedPolyRefIDMap.computeIfAbsent(href, k -> new ArrayList<>());
List<GmlId> featureList = unresolvedPolyRefIDMap.computeIfAbsent(href, k -> new ArrayList<>());
GmlId featureId = geom.getParent().getTopLevelCityObject().getGmlId();
featureList.add(featureId);
// if (logger.isWarnEnabled()) {
......@@ -1191,7 +1190,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
parseBuildingFurniture(gmlAb, cdBuilding);
}
private void parseBuildingFurniture(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void parseBuildingFurniture(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
for (BuildingFurnitureProperty bfProp : gmlAb.getBuildingFurniture()) {
var gmlBf = bfProp.getObject();
if (gmlBf == null) {
......@@ -1202,7 +1202,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void parseBoundarySurfaces(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void parseBoundarySurfaces(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : gmlAb.getBoundaries()) {
if (!surfaceProp.isSetObject()) {
......@@ -1221,7 +1222,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void parseBuildingSubdivisions(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void parseBuildingSubdivisions(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
for (AbstractBuildingSubdivisionProperty abs : gmlAb.getBuildingSubdivisions()) {
var gmlABS = abs.getObject();
if (gmlABS == null) {
......@@ -1237,20 +1239,22 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void parseBuildingConstructiveElements(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void parseBuildingConstructiveElements(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
for (BuildingConstructiveElementProperty bceProp : gmlAb.getBuildingConstructiveElements()) {
var gmlBCE = bceProp.getObject();
if (gmlBCE == null) {
continue;
}
de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement bce =
new de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement(gmlBCE);
de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement bce = new de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement(
gmlBCE);
mapBuildingConstructiveElement(bce, gmlBCE);
cdBuilding.addConstructiveElement(bce);
}
}
private void parseBuildingRooms(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void parseBuildingRooms(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
for (BuildingRoomProperty brProp : gmlAb.getBuildingRooms()) {
var gmlBr = brProp.getObject();
if (gmlBr == null) {
......@@ -1261,7 +1265,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
}
private void parseBuildingInstallations(org.citygml4j.core.model.building.AbstractBuilding gmlAb, AbstractBuilding cdBuilding) {
private void parseBuildingInstallations(org.citygml4j.core.model.building.AbstractBuilding gmlAb,
AbstractBuilding cdBuilding) {
for (BuildingInstallationProperty biProp : gmlAb.getBuildingInstallations()) {
var gmlBi = biProp.getObject();
if (gmlBi == null) {
......@@ -1348,7 +1353,9 @@ public class Citygml3FeatureMapper extends ObjectWalker {
}
private void mapBuildingConstructiveElement(de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement bce, BuildingConstructiveElement ele) {
private void mapBuildingConstructiveElement(
de.hft.stuttgart.citydoctor2.datastructure.BuildingConstructiveElement bce,
BuildingConstructiveElement ele) {
mapAbstractOccupiedSpace(ele, bce, Orientation.OUTWARD);
SurfaceMapper surfaceMapper = new SurfaceMapper(polygonMap, references, compositeMap, vertexMap, config);
for (AbstractSpaceBoundaryProperty surfaceProp : ele.getBoundaries()) {
......@@ -1457,7 +1464,8 @@ public class Citygml3FeatureMapper extends ObjectWalker {
return bi;
}
private void parseAndAddAbstractGeometry(GeometryProperty<?> geomProp, Lod lod, CityObject co, Orientation orientation) {
private void parseAndAddAbstractGeometry(GeometryProperty<?> geomProp, Lod lod, CityObject co,
Orientation orientation) {
if (geomProp == null || geomProp.getObject() == null) {
return;
}
......@@ -1547,11 +1555,7 @@ public class Citygml3FeatureMapper extends ObjectWalker {
updateRing(tree, innerRing);
}
}
if (!config.useLowMemoryConsumption()) {
// no low memory consumption mode meaning create all meta information in
// geometry
geom.updateEdgesAndVertices();
}
geom.updateEdgesAndVertices();
}
}
......
......@@ -149,9 +149,6 @@ public class Triangle3d implements Serializable {
|| checkTriangleLineIntersection(this, other.p1, other.p2)
|| checkTriangleLineIntersection(this, other.p1, other.p3)
|| checkTriangleLineIntersection(this, other.p2, other.p3);
if (intersects) {
System.out.println();
}
return intersects;
}
......@@ -180,11 +177,7 @@ public class Triangle3d implements Serializable {
private boolean doesIntersectCoplanarTriangle(Triangle3d other) {
Triangle2d t1 = projectTo2d();
Triangle2d t2 = other.projectTo2d();
boolean intersects = t1.intersects(t2);
if (intersects) {
System.out.println();
}
return intersects;
return t1.intersects(t2);
}
public Triangle2d projectTo2d() {
......
......@@ -48,21 +48,15 @@ public class ParserConfiguration implements Serializable {
private String targetTransformString;
private String originalTransformString;
private boolean hasTransformation = false;
private boolean useLowMemoryConsumption = false;
private transient double fromMeters = 1.0;
public ParserConfiguration(int numberOfRoundingPlaces, boolean validate) {
this(numberOfRoundingPlaces, validate, false);
}
public ParserConfiguration(int numberOfRoundingPlaces, boolean validate, boolean lowMemory) {
if (numberOfRoundingPlaces < 0) {
throw new IllegalArgumentException("Number of rounding places must be a positive value");
}
roundingPlaces = numberOfRoundingPlaces;
this.validate = validate;
useLowMemoryConsumption = lowMemory;
}
public boolean getValidate() {
......@@ -115,13 +109,5 @@ public class ParserConfiguration implements Serializable {
public double getFromMeters() {
return fromMeters;
}
public boolean useLowMemoryConsumption() {
return useLowMemoryConsumption;
}
public void setUseLowMemoryConsumption(boolean useLowMemoryConsumption) {
this.useLowMemoryConsumption = useLowMemoryConsumption;
}
}
package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
/**
* This Visitor removes the metadata created by the {@link PrepareForCheckingVisitor} for the low-memory consumption mode.
*/
public class ClearMetaInformationVisitor extends CheckableUtilsVisitor {
@Override
public void check(Geometry geometry) {
geometry.clearMetaData();
}
}
package de.hft.stuttgart.citydoctor2.utils.visitors;
import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
/**
* This Visitor prepares the {@link Geometry Geometries} in a Checkable for low-memory consumption mode.
*/
public class PrepareForCheckingVisitor extends CheckableUtilsVisitor {
@Override
public void check(Geometry geom) {
geom.updateEdgesAndVertices();
}
}
......@@ -30,9 +30,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import de.hft.stuttgart.citydoctor2.utils.visitors.ClearResultsVisitor;
import de.hft.stuttgart.citydoctor2.utils.visitors.GmlGeometryRebuilder;
import de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor;
import org.citygml4j.core.model.construction.AbstractConstructionSurface;
import org.citygml4j.core.model.construction.WallSurface;
import org.citygml4j.core.model.core.AbstractThematicSurface;
......@@ -41,13 +38,15 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.xmlobjects.gml.model.geometry.aggregates.MultiSurfaceProperty;
import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry.Orientation;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.visitors.ClearResultsVisitor;
import de.hft.stuttgart.citydoctor2.utils.visitors.GmlGeometryRebuilder;
import de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor;
public class BoundarySurfaceTest {
......@@ -100,16 +99,6 @@ public class BoundarySurfaceTest {
assertEquals(0, bsCounter.intValue());
}
@Test
public void testPrepareForChecking() {
BoundarySurface bs = new BoundarySurface(BoundarySurfaceType.WALL, null);
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2, Orientation.OUTWARD);
Geometry spyGeom = Mockito.spy(geom);
bs.addGeometry(spyGeom);
bs.prepareForChecking();
verify(spyGeom).updateEdgesAndVertices();
}
@Test
public void testContainsError() {
BoundarySurface bs = new BoundarySurface(BoundarySurfaceType.WALL, null);
......
......@@ -37,7 +37,6 @@ import org.citygml4j.core.model.deprecated.bridge.DeprecatedPropertiesOfAbstract
import org.citygml4j.core.util.geometry.GeometryFactory;
import org.citygml4j.core.visitor.ObjectVisitor;
import org.junit.Test;
import org.mockito.Mockito;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
......@@ -45,7 +44,6 @@ import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.CheckableUtilsVisitor;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject.BridgeType;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry.Orientation;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.utils.visitors.UnsetGeometriesVisitor;
......@@ -114,18 +112,6 @@ public class BridgeObjectTest {
verify(geomMock).accept(c);
}
@Test
public void testPrepareForChecking() {
BridgeObject bo = new BridgeObject(mock(AbstractBridge.class));
Geometry geom = new Geometry(GeometryType.MULTI_SURFACE, Lod.LOD2, Orientation.OUTWARD);
Geometry spyGeom = Mockito.spy(geom);
bo.addGeometry(spyGeom);
bo.prepareForChecking();
verify(spyGeom).updateEdgesAndVertices();
}
@Test
public void testContainsError() {
BridgeObject bo = new BridgeObject(mock(AbstractBridge.class));
......@@ -173,6 +159,8 @@ public class BridgeObjectTest {
@Test
public void testReCreateGeometriesSolid() {
org.citygml4j.core.model.bridge.AbstractBridge gmlBr = new AbstractBridge() {
private static final long serialVersionUID = -6057032019199660174L;
@Override
public void accept(ObjectVisitor visitor) {
......@@ -196,6 +184,8 @@ public class BridgeObjectTest {
@Test
public void testReCreateGeometriesMultiSurface() {
org.citygml4j.core.model.bridge.AbstractBridge gmlBr = new AbstractBridge() {
private static final long serialVersionUID = -423198873081228195L;
@Override
public void accept(ObjectVisitor visitor) {
......
......@@ -76,7 +76,6 @@ public class BuildingTest {
assertEquals(b.getGmlId(), copy.getGmlId());
copy.prepareForChecking();
Geometry copyGeom = copy.getGeometries().get(0);
assertNotSame(geom, copyGeom);
......
......@@ -252,7 +252,6 @@ public class GeometryTest {
public void testUpdateEdges() {
Geometry geom = GeometryTestUtils.createDummyGeometryWithInnerRingWithNeighboringPolygon(GeometryType.SOLID,
Lod.LOD2);
geom.clearMetaInformation();
assertNull(geom.getEdges());
geom.updateEdges();
List<Edge> edges = geom.getEdges();
......@@ -454,17 +453,4 @@ public class GeometryTest {
assertFalse(geom.containsPolygon(cdPoly4));
}
@Test
public void testClearMetaInformation() {
Geometry geom = GeometryTestUtils.createDummyGeometryWithInnerRingWithNeighboringPolygon(GeometryType.SOLID,
Lod.LOD0);
assertNotNull(geom.getVertices());
geom.clearMetaInformation();
assertNull(geom.getVertices());
assertNull(geom.getEdges());
geom.clearMetaInformation();
assertNull(geom.getVertices());
assertNull(geom.getEdges());
}
}
......@@ -714,7 +714,6 @@ public class Checker {
List<Future<GmlId>> futures = runChecksOnFeatures(exec, cache, features, checkedCount, l);
List<GmlId> missedFeatures = getMissedFeatures(futures);
ImplicitGeometryHolder.clearMetaDataOfPrototypeGeometries();
if (!missedFeatures.isEmpty()){
logger.error(Localization.getText("Checker.dbUnresponsive"));
if (logger.isDebugEnabled()){
......@@ -765,9 +764,7 @@ public class Checker {
Thread.currentThread().interrupt();
return null;
}
co.prepareForChecking();
executeChecksForCityObject(co);
co.clearMetaInformation();
cache.put(co);
checkedCount.incrementAndGet();
if (l!=null){
......
......@@ -24,16 +24,7 @@ import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.ValidationConfiguration;
import de.hft.stuttgart.citydoctor2.checkresult.utility.CheckReportWriteException;
import de.hft.stuttgart.citydoctor2.checks.Checks;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityFurniture;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.GenericCityObject;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.Tunnel;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
/**
*
......
......@@ -118,13 +118,7 @@ public class CityDoctorController {
this.renderer = renderer;
}
public void loadCityGml(String path, int numberOfRoundingPlaces, ProgressListener l, boolean useValidation)
throws CityGmlParseException, InvalidGmlFileException {
loadCityGml(path, numberOfRoundingPlaces, l, useValidation, false);
}
public void loadCityGml(String path, int numberOfRoundingPlaces, ProgressListener l, boolean useValidation,
boolean lowMemory) throws CityGmlParseException, InvalidGmlFileException {
public void loadCityGml(String path, int numberOfRoundingPlaces, ProgressListener l, boolean useValidation) throws CityGmlParseException, InvalidGmlFileException {
try {
Platform.runLater(() -> {
mainWindow.getOpenBtn().setDisable(true);
......@@ -137,7 +131,7 @@ public class CityDoctorController {
mainWindow.resetFilterComboBox();
});
currentChecker = null;
currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory);
currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation);
model = CityGmlParser.parseCityGmlFile(path, currentConfig, l);
mainWindow.getClickHandler().setConfig(currentConfig);
......
......@@ -68,12 +68,6 @@ public class OpenFileDialog {
@FXML
private Label xmlValidationLabel;
@FXML
private Label lowMemoryLabel;
@FXML
private CheckBox lowMemoryBox;
private CityDoctorController controller;
private ExceptionDialog exDialog;
private FileChooser fc;
......@@ -112,7 +106,6 @@ public class OpenFileDialog {
roundingPlacesLabel.setText(Localization.getText("OpenFileDialog.roundingPlacesLabel"));
xmlValidationLabel.setText(Localization.getText("OpenFileDialog.xmlValidationLabel"));
cancelBtn.setText(Localization.getText("OpenFileDialog.cancelBtn"));
lowMemoryLabel.setText(Localization.getText("OpenFileDialog.lowMemoryLabel"));
}
private void setupSelectButton() {
......@@ -143,7 +136,6 @@ public class OpenFileDialog {
loadBtn.setOnAction(ae -> {
int numberOfRoundingPlaces = Integer.parseInt(precisionField.getText());
boolean useValidation = useValidationBox.isSelected();
boolean lowMemory = lowMemoryBox.isSelected();
String path = pathField.getText();
cancelBtn.setDisable(true);
loadBtn.setDisable(true);
......@@ -153,8 +145,7 @@ public class OpenFileDialog {
Thread t = new Thread(() -> {
try {
controller.loadCityGml(path, numberOfRoundingPlaces, progress::setProgress, useValidation,
lowMemory);
controller.loadCityGml(path, numberOfRoundingPlaces, progress::setProgress, useValidation);
Platform.runLater(() -> stage.close());
} catch (Exception e) {
if (logger.isErrorEnabled()) {
......
package de.hft.stuttgart.citydoctor2.gui;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.utils.visitors.CityObjectCollector;
import de.hft.stuttgart.citydoctor2.datastructure.*;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurface;
import de.hft.stuttgart.citydoctor2.datastructure.BoundarySurfaceType;
import de.hft.stuttgart.citydoctor2.datastructure.BoundingBox;
import de.hft.stuttgart.citydoctor2.datastructure.BridgeObject;
import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import de.hft.stuttgart.citydoctor2.datastructure.CityFurniture;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import de.hft.stuttgart.citydoctor2.datastructure.ConcretePolygon;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
import de.hft.stuttgart.citydoctor2.datastructure.GenericAttribute;
import de.hft.stuttgart.citydoctor2.datastructure.Geometry;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
import de.hft.stuttgart.citydoctor2.datastructure.Lod;
import de.hft.stuttgart.citydoctor2.datastructure.Polygon;
import de.hft.stuttgart.citydoctor2.datastructure.TransportationObject;
import de.hft.stuttgart.citydoctor2.datastructure.Tunnel;
import de.hft.stuttgart.citydoctor2.datastructure.Vegetation;
import de.hft.stuttgart.citydoctor2.datastructure.Vertex;
import de.hft.stuttgart.citydoctor2.datastructure.WaterObject;
import de.hft.stuttgart.citydoctor2.gui.filter.ViewFilter;
import de.hft.stuttgart.citydoctor2.gui.tree.*;
import de.hft.stuttgart.citydoctor2.gui.tree.ErrorItemVisitor;
import de.hft.stuttgart.citydoctor2.gui.tree.Renderable;
import de.hft.stuttgart.citydoctor2.gui.tree.node.EdgeNode;
import de.hft.stuttgart.citydoctor2.gui.tree.node.ErrorNode;
import de.hft.stuttgart.citydoctor2.gui.tree.node.GenericAttributeNode;
......@@ -13,23 +42,18 @@ import de.hft.stuttgart.citydoctor2.gui.tree.node.LinearRingNode;
import de.hft.stuttgart.citydoctor2.gui.tree.node.PolygonNode;
import de.hft.stuttgart.citydoctor2.gui.tree.node.VertexNode;
import de.hft.stuttgart.citydoctor2.math.Triangle3d;
import de.hft.stuttgart.citydoctor2.utils.visitors.CityObjectCollector;
import javafx.application.Platform;
import javafx.scene.control.TreeItem;
import javafx.scene.paint.Color;
import javafx.scene.shape.CullFace;
import javafx.scene.shape.DrawMode;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.util.*;
public class Renderer {
private static final Logger logger = LogManager.getLogger(Renderer.class);
private TriangulatedGeometry currentTriGeom;
private Geometry currentGeometry;
private CullFace currentCulling = CullFace.NONE;
private DrawMode currentDrawMode = DrawMode.FILL;
......@@ -245,20 +269,9 @@ public class Renderer {
refresher = () -> {
Platform.runLater(this::clearGeometryTrees);
currentTriGeom = TriangulatedGeometry.of(geom);
if (geom.getEdges() == null && currentGeometry != null) {
// if there are no edges available low memory mode is enabled
// clear the old geometry of all meta information
currentGeometry.clearMetaData();
}
errVisitor.setGeometry(currentTriGeom);
Platform.runLater(() -> {
setupRenderState();
if (geom.getEdges() == null) {
// create edges and vertices so they can be listed in the gui
geom.prepareForChecking();
// remember the geometry, so it can be cleared if another is displayed
currentGeometry = geom;
}
addGeometryDataToView(geom);
addGenericAttributesToView(geom.getParent());
mainWindow.zoomOutForBoundingBox(BoundingBox.of(geom.getPolygons()));
......
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