"git@transfer.hft-stuttgart.de:m4lab_tv1/project-page.git" did not exist on "0f47047d5a7b9bcf7ca10dc367e4cd5e29ef8ac0"
Commit 01673d2c authored by Riegel's avatar Riegel
Browse files

Fix checks and methods being applied to transformed geom

parent 3f908256
package de.hft.stuttgart.citydoctor2.datastructure; package de.hft.stuttgart.citydoctor2.datastructure;
import de.hft.stuttgart.citydoctor2.check.Check; import de.hft.stuttgart.citydoctor2.check.Check;
import de.hft.stuttgart.citydoctor2.check.CheckError;
import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.math.TransformationMatrix; import de.hft.stuttgart.citydoctor2.math.TransformationMatrix;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.citygml4j.core.model.core.ImplicitGeometry; import org.citygml4j.core.model.core.ImplicitGeometry;
import java.io.Serial; import java.io.Serial;
import java.util.List;
/** /**
* Datastructure for representation and resolving of implicit geometries * Datastructure for representation and resolving of implicit geometries
...@@ -20,59 +23,80 @@ public class ImplicitGeometryHolder extends Geometry { ...@@ -20,59 +23,80 @@ public class ImplicitGeometryHolder extends Geometry {
private static final long serialVersionUID = -8938931081577196349L; private static final long serialVersionUID = -8938931081577196349L;
private ImplicitGeometry cgmlImplicitGeometry = null; private ImplicitGeometry cgmlImplicitGeometry = null;
/*
LibraryObject and RelativeGeometry are mutually exclusive private final PrototypeGeometryType type;
*/ private final Geometry prototypeGeometry;
private final LibraryObject libObject;
private final RelativeGeometry relativeGeom;
public ImplicitGeometryHolder(ImplicitGeometry cgmlImplicitGeometry, LibraryObject libObject) { public ImplicitGeometryHolder(ImplicitGeometry cgmlImplicitGeometry, LibraryObject libObject) {
super(libObject.getType(), libObject.getLod()); super(libObject.getType(), libObject.getLod());
this.libObject = libObject; prototypeGeometry = libObject;
this.relativeGeom = null; type = PrototypeGeometryType.LIBRARY_OBJECT;
this.cgmlImplicitGeometry = cgmlImplicitGeometry; this.cgmlImplicitGeometry = cgmlImplicitGeometry;
applyTransformation(); applyTransformation();
} }
public ImplicitGeometryHolder(ImplicitGeometry cgmlImplicitGeometry, RelativeGeometry relativeGeometry) { public ImplicitGeometryHolder(ImplicitGeometry cgmlImplicitGeometry, RelativeGeometry relativeGeometry) {
super(relativeGeometry.getType(), relativeGeometry.getLod()); super(relativeGeometry.getType(), relativeGeometry.getLod());
this.libObject = null; prototypeGeometry = relativeGeometry;
this.relativeGeom = relativeGeometry; type = PrototypeGeometryType.RELATIVE_GEOMETRY;
this.cgmlImplicitGeometry = cgmlImplicitGeometry; this.cgmlImplicitGeometry = cgmlImplicitGeometry;
applyTransformation(); applyTransformation();
} }
@Override
public void accept(Check c) {
/**
* Checks are only run on the referenced prototypical geometry.
*/
if (relativeGeom != null) {
relativeGeom.accept(c);
}
if (libObject != null) {
libObject.accept(c);
}
}
/** /**
* Applies the transformation matrix of the implicit geometry to a copy of the reference geometry and copies the resulting * Applies the transformation matrix of the implicit geometry to a copy of the reference geometry and copies the resulting
* transformed geometry into this object. * transformed geometry into this object.
*/ */
private void applyTransformation() { private void applyTransformation() {
TransformationMatrix transformMatrix = new TransformationMatrix(cgmlImplicitGeometry); TransformationMatrix transformMatrix = new TransformationMatrix(cgmlImplicitGeometry);
Geometry refGeo = null; Geometry transformedGeom = transformMatrix.transformGeometry(prototypeGeometry);
if (libObject == null) {
refGeo = relativeGeom;
} else if (relativeGeom == null) {
refGeo = libObject;
}
if (refGeo == null) {
throw new NullPointerException("Geometry reference object of ImplicitGeometryHolder is null!");
}
Geometry transformedGeom = transformMatrix.transformGeometry(refGeo);
transformedGeom.getPolygons().forEach(this::addPolygon); transformedGeom.getPolygons().forEach(this::addPolygon);
this.updateEdgesAndVertices(); this.updateEdgesAndVertices();
} }
public PrototypeGeometryType getPrototypeGeometryType() {
return type;
}
@Override
public void accept(Check c) {
prototypeGeometry.accept(c);
}
@Override
public boolean containsError(CheckId checkIdentifier) {
return prototypeGeometry.containsError(checkIdentifier);
}
@Override
public void clearAllContainedCheckResults() {
prototypeGeometry.clearAllContainedCheckResults();
}
@Override
public void collectContainedErrors(List<CheckError> errors) {
prototypeGeometry.clearAllContainedCheckResults();
}
@Override
public boolean containsAnyError() {
return prototypeGeometry.containsAnyError();
}
@Override
public void prepareForChecking() {
this.updateEdgesAndVertices();
prototypeGeometry.prepareForChecking();
}
@Override
public boolean isValidated() {
return prototypeGeometry.isValidated();
}
public enum PrototypeGeometryType {
LIBRARY_OBJECT, RELATIVE_GEOMETRY
}
} }
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