use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class Roof method insideWalls.
public boolean insideWalls(final double x, final double y, final boolean init) {
if (walls.isEmpty()) {
return false;
}
if (init) {
if (underlyingWallVerticesOnFoundation == null) {
underlyingWallVerticesOnFoundation = new ArrayList<Vector2>();
} else {
underlyingWallVerticesOnFoundation.clear();
}
walls.get(0).visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall currentWall, final Snap prev, final Snap next) {
int pointIndex = 0;
if (next != null) {
pointIndex = next.getSnapPointIndexOf(currentWall);
}
pointIndex++;
addUnderlyingWallVertex(currentWall.getAbsPoint(pointIndex == 1 ? 3 : 1));
addUnderlyingWallVertex(currentWall.getAbsPoint(pointIndex));
}
private void addUnderlyingWallVertex(final ReadOnlyVector3 v3) {
final Vector2 v2 = new Vector2(v3.getX(), v3.getY());
boolean b = false;
for (final Vector2 x : underlyingWallVerticesOnFoundation) {
if (Util.isEqual(x, v2)) {
b = true;
break;
}
}
if (!b) {
underlyingWallVerticesOnFoundation.add(v2);
}
}
});
if (underlyingWallPath == null) {
underlyingWallPath = new Path2D.Double();
} else {
underlyingWallPath.reset();
}
final Vector2 v0 = underlyingWallVerticesOnFoundation.get(0);
underlyingWallPath.moveTo(v0.getX(), v0.getY());
for (int i = 1; i < underlyingWallVerticesOnFoundation.size(); i++) {
final Vector2 v = underlyingWallVerticesOnFoundation.get(i);
underlyingWallPath.lineTo(v.getX(), v.getY());
}
underlyingWallPath.lineTo(v0.getX(), v0.getY());
underlyingWallPath.closePath();
}
return underlyingWallPath != null ? underlyingWallPath.contains(x, y) : false;
}
use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class Floor method exploreWallNeighbors.
protected ArrayList<PolygonPoint> exploreWallNeighbors(final Wall startWall) {
final ArrayList<PolygonPoint> poly = new ArrayList<PolygonPoint>();
startWall.visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall currentWall, final Snap prev, final Snap next) {
int pointIndex = 0;
if (next != null) {
pointIndex = next.getSnapPointIndexOf(currentWall);
}
pointIndex = pointIndex + 1;
final ReadOnlyVector3 p1 = currentWall.getAbsPoint(pointIndex == 1 ? 3 : 1);
final ReadOnlyVector3 p2 = currentWall.getAbsPoint(pointIndex);
addPointToPolygon(poly, p1);
addPointToPolygon(poly, p2);
wallUpperVectors.add(p1);
wallUpperVectors.add(p2);
}
});
return poly;
}
use of org.concord.energy3d.util.WallVisitor in project energy3d by concord-consortium.
the class HousePart method pickContainer.
protected PickedHousePart pickContainer(final int x, final int y, final Class<?>[] typesOfHousePart) {
final HousePart previousContainer = container;
final PickedHousePart picked;
if (!firstPointInserted || container == null) {
picked = SelectUtil.pickPart(x, y, typesOfHousePart);
} else {
picked = SelectUtil.pickPart(x, y, container);
}
if (!firstPointInserted && picked != null) {
UserData userData = null;
if (picked != null) {
userData = picked.getUserData();
}
if (container == null || userData == null || container != userData.getHousePart()) {
if (container != null) {
container.getChildren().remove(this);
if (this instanceof Roof) {
((Wall) container).visitNeighbors(new WallVisitor() {
@Override
public void visit(final Wall wall, final Snap prev, final Snap next) {
wall.setRoof(null);
}
});
}
}
if (userData != null && userData.getHousePart().isDrawCompleted()) {
if (!(userData.getHousePart() instanceof FoundationPolygon) && (!(this instanceof Roof) || ((Wall) userData.getHousePart()).getRoof() == null)) {
container = userData.getHousePart();
container.getChildren().add(this);
}
} else {
container = null;
}
}
}
if (previousContainer != container) {
if (previousContainer == null) {
SceneManager.getInstance().setGridsVisible(false);
} else if (container != null) {
previousContainer.gridsMesh.getSceneHints().setCullHint(CullHint.Always);
}
if (container != null && !(this instanceof Roof)) {
if (Scene.getInstance().isSnapToGrids()) {
setGridsVisible(true);
} else {
setLinePatternVisible(true);
}
} else if (this instanceof Foundation) {
SceneManager.getInstance().setGridsVisible(true);
}
}
return picked;
}
Aggregations