use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class Scene method deleteAllConnectedWalls.
public void deleteAllConnectedWalls(final Wall w) {
final List<HousePart> copy = new ArrayList<HousePart>();
w.visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall currentWall, final Snap prev, final Snap next) {
copy.add(currentWall);
}
});
final RemoveMultiplePartsCommand c = new RemoveMultiplePartsCommand(copy);
for (final HousePart p : copy) {
remove(p, false);
}
SceneManager.getInstance().getUndoManager().addEdit(c);
edited = true;
SceneManager.getInstance().refresh();
}
use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class Scene method setHeightOfConnectedWalls.
public void setHeightOfConnectedWalls(final Wall w, final double height) {
w.visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall w, final Snap prev, final Snap next) {
w.setHeight(height, true);
}
});
redrawAllWallsNow();
final Foundation foundation = w.getTopContainer();
if (foundation.hasSolarReceiver()) {
foundation.drawSolarReceiver();
for (final HousePart x : Scene.getInstance().getParts()) {
if (x instanceof FresnelReflector) {
final FresnelReflector reflector = (FresnelReflector) x;
if (foundation == reflector.getReceiver() && reflector.isSunBeamVisible()) {
reflector.drawSunBeam();
}
} else if (x instanceof Mirror) {
final Mirror heliostat = (Mirror) x;
if (foundation == heliostat.getReceiver() && heliostat.isSunBeamVisible()) {
heliostat.drawSunBeam();
}
}
}
}
}
use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class Roof method initWallUpperPoints.
private void initWallUpperPoints(final Wall startWall, final List<Wall> walls, final List<ReadOnlyVector3> wallUpperPoints, final List<ReadOnlyVector3> wallNormals) {
walls.clear();
wallUpperPoints.clear();
wallNormals.clear();
startWall.visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall currentWall, final Snap prevSnap, final Snap nextSnap) {
if (currentWall.isFirstPointInserted()) {
walls.add(currentWall);
currentWall.setRoof(Roof.this);
final int pointIndex2 = nextSnap != null ? nextSnap.getSnapPointIndexOf(currentWall) + 1 : 1;
final int pointIndex1 = pointIndex2 == 1 ? 3 : 1;
final Vector3 p1 = currentWall.getAbsPoint(pointIndex1);
final Vector3 p2 = currentWall.getAbsPoint(pointIndex2);
final ReadOnlyVector3 normal = currentWall.getNormal();
addPointToPolygon(p1, normal, wallUpperPoints, wallNormals);
addPointToPolygon(p2, normal, wallUpperPoints, wallNormals);
}
}
});
}
use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class Roof method computeDashPoints.
public List<ReadOnlyVector3> computeDashPoints(final Mesh roofPartMesh) {
if (dashPointsCache.get(roofPartMesh) == null) {
final ArrayList<ReadOnlyVector3> resultBeforeBreak = new ArrayList<ReadOnlyVector3>();
final ArrayList<ReadOnlyVector3> resultAfterBreak = new ArrayList<ReadOnlyVector3>();
final boolean[] foundBreak = { false };
((Wall) container).visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall currentWall, final Snap prevSnap, final Snap nextSnap) {
final int indexP1, indexP2;
if (nextSnap != null) {
indexP2 = nextSnap.getSnapPointIndexOf(currentWall);
indexP1 = indexP2 == 2 ? 0 : 2;
} else if (prevSnap != null) {
indexP1 = prevSnap.getSnapPointIndexOf(currentWall);
indexP2 = indexP1 == 2 ? 0 : 2;
} else {
indexP1 = 0;
indexP2 = 2;
}
final ArrayList<ReadOnlyVector3> array = foundBreak[0] ? resultAfterBreak : resultBeforeBreak;
final int orgSize = array.size();
stretchToRoof(array, roofPartMesh, currentWall.getAbsPoint(indexP1), currentWall.getAbsPoint(indexP2), currentWall.points.get(1).getZ());
if (!foundBreak[0] && array.size() == orgSize) {
foundBreak[0] = true;
}
}
});
if (foundBreak[0]) {
resultAfterBreak.addAll(resultBeforeBreak);
dashPointsCache.put(roofPartMesh, resultAfterBreak);
} else {
dashPointsCache.put(roofPartMesh, resultBeforeBreak);
}
}
return dashPointsCache.get(roofPartMesh);
}
use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class Wall method computeInsideDirectionOfAttachedWalls.
public void computeInsideDirectionOfAttachedWalls(final boolean drawNeighborWalls) {
if (this.thicknessNormal != null) {
return;
}
final ArrayList<Wall> walls;
if (drawNeighborWalls) {
walls = new ArrayList<Wall>();
} else {
walls = null;
}
final double[] side = new double[] { 0.0 };
Wall.clearVisits();
visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall wall, final Snap prev, final Snap next) {
if (next != null) {
final int indexP2 = next.getSnapPointIndexOf(wall);
final ReadOnlyVector3 p1 = wall.getAbsPoint(indexP2 == 0 ? 2 : 0);
final ReadOnlyVector3 p2 = wall.getAbsPoint(indexP2);
final ReadOnlyVector3 p3 = next.getNeighborOf(wall).getAbsPoint(next.getSnapPointIndexOfNeighborOf(wall) == 0 ? 2 : 0);
final ReadOnlyVector3 p1_p2 = p2.subtract(p1, null).normalizeLocal();
final ReadOnlyVector3 p2_p3 = p3.subtract(p2, null).normalizeLocal();
side[0] += Util.angleBetween(p1_p2, p2_p3, Vector3.UNIT_Z);
}
if (drawNeighborWalls && wall != Wall.this && !walls.contains(wall)) {
walls.add(wall);
}
}
});
Wall.clearVisits();
visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall wall, final Snap prev, final Snap next) {
if (next != null) {
final int indexP2 = next.getSnapPointIndexOf(wall);
final Vector3 p1 = wall.getAbsPoint(indexP2 == 0 ? 2 : 0);
final Vector3 p2 = wall.getAbsPoint(indexP2);
final Vector3 p1_p2 = p2.subtract(p1, null);
wall.thicknessNormal = p1_p2.cross(Vector3.UNIT_Z, null).normalizeLocal().multiplyLocal(wall.getThickness());
if (side[0] > 0) {
wall.thicknessNormal.negateLocal();
}
} else if (prev != null) {
final int indexP2 = prev.getSnapPointIndexOf(wall);
final Vector3 p2 = wall.getAbsPoint(indexP2);
final Vector3 p3 = wall.getAbsPoint(indexP2 == 0 ? 2 : 0);
final Vector3 p2_p3 = p3.subtract(p2, null);
wall.thicknessNormal = p2_p3.cross(Vector3.UNIT_Z, null).normalizeLocal().multiplyLocal(wall.getThickness());
if (side[0] > 0) {
wall.thicknessNormal.negateLocal();
}
}
}
});
if (drawNeighborWalls) {
for (final HousePart wall : walls) {
wall.draw();
wall.drawChildren();
}
}
}
Aggregations