Skip to content

Commit

Permalink
merge refl fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-f committed Oct 15, 2024
1 parent 0bc9f87 commit 49b57e7
Show file tree
Hide file tree
Showing 5 changed files with 232 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ public CnossosPath computeHEdgeDiffraction(CutProfile cutProfile , boolean bodyB
}
else if(pt.wallId != -1) {
pt.alphaWall = data.profileBuilder.getWall(pt.wallId).getAlphas();
ProfileBuilder.Wall wall = data.profileBuilder.getWall(pt.wallId);
Wall wall = data.profileBuilder.getWall(pt.wallId);
pt.setObstacleZ(Vertex.interpolateZ(pt.coordinate, wall.p0, wall.p1));
}
}
Expand Down Expand Up @@ -1234,19 +1234,19 @@ public static org.apache.commons.math3.geometry.euclidean.threed.Vector3D coordi
return new org.apache.commons.math3.geometry.euclidean.threed.Vector3D(p.x, p.y, p.z);
}

private void updateReflectionPathAttributes(PointPath reflectionPoint, MirrorReceiverResult mirrorReceiverResult) {
private void updateReflectionPathAttributes(PointPath reflectionPoint, MirrorReceiver MirrorReceiver) {
reflectionPoint.setType(PointPath.POINT_TYPE.REFL);
if(mirrorReceiverResult.getType().equals(BUILDING)) {
reflectionPoint.setBuildingId(mirrorReceiverResult.getBuildingId());
if(MirrorReceiver.getType().equals(BUILDING)) {
reflectionPoint.setBuildingId(MirrorReceiver.getBuildingId());
reflectionPoint.obstacleZ = data.profileBuilder.getBuilding(reflectionPoint.getBuildingId()).getZ();
reflectionPoint.setAlphaWall(data.profileBuilder.getBuilding(reflectionPoint.getBuildingId()).getAlphas());
} else {
ProfileBuilder.Wall wall = mirrorReceiverResult.getWall();
Wall wall = MirrorReceiver.getWall();
reflectionPoint.obstacleZ = Vertex.interpolateZ(reflectionPoint.coordinate, wall.p0, wall.p1);
reflectionPoint.setWallId(wall.getProcessedWallIndex());
reflectionPoint.setAlphaWall(wall.getAlphas());
}
reflectionPoint.altitude = data.profileBuilder.getZGround(mirrorReceiverResult.getReceiverPos());
reflectionPoint.altitude = data.profileBuilder.getZGround(MirrorReceiver.getReceiverPos());
}


Expand Down Expand Up @@ -1362,18 +1362,15 @@ public List<CnossosPath> computeReflexion(Coordinate rcvCoord, Coordinate srcCoo
List<SegmentPath> segments = new ArrayList<>();
SegmentPath srPath = null;
List<Integer> reflIdx = new ArrayList<>();
//CnossosPathParameters proPathParameters = new CnossosPathParameters(favorable, points, segments, srPath, Angle.angle(rcvCoord, srcCoord));
CnossosPath pathParameters = new CnossosPath();
//(favorable=false, points, segments, srSeg, Angle.angle(rcvCut.getCoordinate(), srcCut.getCoordinate()));
pathParameters.setFavorable(favorable);
pathParameters.setPointList(points);
pathParameters.setSegmentList(segments);
pathParameters.setSRSegment(srPath); //null
// pathParameters.init(8);
pathParameters.setSRSegment(srPath);
pathParameters.angle=Angle.angle(rcvCoord, srcCoord);
pathParameters.refPoints = reflIdx;
// Compute direct path between source and first reflection point, add profile to the data
computeReflexionOverBuildings(srcCoord, rayPath.get(0).getReceiverPos(), points, segments, data, orientation, proPath.difHPoints, proPath.difVPoints);
computeReflexionOverBuildings(srcCoord, rayPath.get(0).getReceiverPos(), points, segments, data, orientation, pathParameters.difHPoints, pathParameters.difVPoints);
if (points.isEmpty()) { // no valid path between the two points
continue;
}
Expand All @@ -1382,11 +1379,11 @@ public List<CnossosPath> computeReflexion(Coordinate rcvCoord, Coordinate srcCoo
updateReflectionPathAttributes(reflPoint, rayPath.get(0));
// Add intermediate reflections
for (int idPt = 0; idPt < rayPath.size() - 1; idPt++) {
MirrorReceiverResult firstPoint = rayPath.get(idPt);
MirrorReceiverResult secondPoint = rayPath.get(idPt + 1);
MirrorReceiver firstPoint = rayPath.get(idPt);
MirrorReceiver secondPoint = rayPath.get(idPt + 1);
int previousPointSize = points.size();
computeReflexionOverBuildings(firstPoint.getReceiverPos(), secondPoint.getReceiverPos(),
points, segments, data, orientation, proPath.difHPoints, proPath.difVPoints);
points, segments, data, orientation, pathParameters.difHPoints, pathParameters.difVPoints);
if(points.size() == previousPointSize) { // no visibility between the two reflection coordinates
// (maybe there is a blocking building, and we disabled diffraction)
continue;
Expand All @@ -1403,7 +1400,8 @@ public List<CnossosPath> computeReflexion(Coordinate rcvCoord, Coordinate srcCoo
}
// Compute direct path between receiver and last reflection point, add profile to the data
int previousPointSize = points.size();
computeReflexionOverBuildings(rayPath.get(rayPath.size() - 1).getReceiverPos(), rcvCoord, points, segments, data, orientation, proPath.difHPoints, proPath.difVPoints);
computeReflexionOverBuildings(rayPath.get(rayPath.size() - 1).getReceiverPos(), rcvCoord, points,
segments, data, orientation, pathParameters.difHPoints, pathParameters.difVPoints);
if(points.size() == previousPointSize) { // no visibility between the last reflection coordinate and the receiver
// (maybe there is a blocking building, and we disabled diffraction)
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.noise_planet.noisemodelling.pathfinder.path;

import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Polygon;
import org.noise_planet.noisemodelling.pathfinder.profilebuilder.ProfileBuilder;
import org.noise_planet.noisemodelling.pathfinder.profilebuilder.Wall;

Expand All @@ -21,36 +22,45 @@
*/
public class MirrorReceiver {

private Coordinate receiverPos;
private final MirrorReceiver parentMirror;
private final Wall wall;

private Coordinate receiverPos;
private final MirrorReceiver parentMirror;
private final Wall wall;
private final int buildingId; // building that belongs to this wall
private final ProfileBuilder.IntersectionType type;
/**
* This data is not stored in the RTREE as it is not used after the creation of the index
*/
Polygon imageReceiverVisibilityCone;

/**
* @return coordinate of mirrored receiver
*/
public Coordinate getReceiverPos() {
return receiverPos;
}
public Coordinate getReceiverPos() {
return receiverPos;
}

public void setReceiverPos(Coordinate receiverPos) {
this.receiverPos = receiverPos;
}

public MirrorReceiver copyWithoutCone() {
return new MirrorReceiver(receiverPos, parentMirror == null ? null : parentMirror.copyWithoutCone(),
wall, buildingId, type);
}
/**
* @return Other MirrorReceiverResult index, -1 for the first reflexion
* @return Other MirrorReceiver index, -1 for the first reflexion
*/
public MirrorReceiver getParentMirror() {
return parentMirror;
}
public MirrorReceiver getParentMirror() {
return parentMirror;
}

/**
* @return Wall index of the last mirrored processed
*/
public Wall getWall() {
return wall;
}
public Wall getWall() {
return wall;
}

/**
* @return building that belongs to this wall
Expand All @@ -61,16 +71,27 @@ public int getBuildingId() {

/**
* @param receiverPos coordinate of mirrored receiver
* @param mirrorResultId Other MirrorReceiver index, -1 for the first reflexion
* @param wallId Wall index of the last mirrored processed
* @param buildingId building that belongs to this wall
*/
public MirrorReceiver(Coordinate receiverPos, MirrorReceiver parentMirror, Wall wall, int buildingId, ProfileBuilder.IntersectionType type) {
public MirrorReceiver(Coordinate receiverPos, MirrorReceiver parentMirror, Wall wall, int buildingId,
ProfileBuilder.IntersectionType type) {
this.receiverPos = receiverPos;
this.parentMirror = parentMirror;
this.wall = wall;
this.buildingId = buildingId;
this.type = type;
}

public Polygon getImageReceiverVisibilityCone() {
return imageReceiverVisibilityCone;
}

public void setImageReceiverVisibilityCone(Polygon imageReceiverVisibilityCone) {
this.imageReceiverVisibilityCone = imageReceiverVisibilityCone;
}

/**
* Copy constructor
* @param cpy ref
Expand All @@ -83,11 +104,6 @@ public MirrorReceiver(MirrorReceiver cpy) {
this.type = cpy.type;
}

/**
* Compare to instance of MirrorReceiver
* @param o
* @return a boolean
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand Down
Loading

0 comments on commit 49b57e7

Please sign in to comment.