Search in sources :

Example 1 with WallVisitor

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();
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) Wall(org.concord.energy3d.model.Wall) ArrayList(java.util.ArrayList) Snap(org.concord.energy3d.model.Snap) HousePart(org.concord.energy3d.model.HousePart) RemoveMultiplePartsCommand(org.concord.energy3d.undo.RemoveMultiplePartsCommand)

Example 2 with WallVisitor

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();
                }
            }
        }
    }
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) Foundation(org.concord.energy3d.model.Foundation) Snap(org.concord.energy3d.model.Snap) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 3 with WallVisitor

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);
            }
        }
    });
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 4 with WallVisitor

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);
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ArrayList(java.util.ArrayList)

Example 5 with WallVisitor

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();
        }
    }
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint) ArdorVector3Point(org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point) PickingHint(com.ardor3d.scenegraph.hint.PickingHint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point)

Aggregations

WallVisitor (org.concord.energy3d.util.WallVisitor)13 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)6 Snap (org.concord.energy3d.model.Snap)6 Wall (org.concord.energy3d.model.Wall)6 HousePart (org.concord.energy3d.model.HousePart)4 PolygonPoint (org.poly2tri.geometry.polygon.PolygonPoint)4 Vector3 (com.ardor3d.math.Vector3)3 CullHint (com.ardor3d.scenegraph.hint.CullHint)3 ArrayList (java.util.ArrayList)3 Foundation (org.concord.energy3d.model.Foundation)3 TPoint (org.poly2tri.triangulation.point.TPoint)3 PickingHint (com.ardor3d.scenegraph.hint.PickingHint)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 BoxLayout (javax.swing.BoxLayout)2 ButtonGroup (javax.swing.ButtonGroup)2 JDialog (javax.swing.JDialog)2 JOptionPane (javax.swing.JOptionPane)2 JPanel (javax.swing.JPanel)2 JRadioButton (javax.swing.JRadioButton)2