Search in sources :

Example 36 with Roof

use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.

the class PrintController method computePageDimension.

private void computePageDimension() {
    spaceBetweenParts = Scene.getInstance().areAnnotationsVisible() ? 3.0 : 0;
    double fromPageToWorldCoord;
    if (!isScaleToFit) {
        fromPageToWorldCoord = exactFromPageToWorldCoord / (Scene.getInstance().getAnnotationScale() / 10.0);
    } else {
        double maxWidth = 0;
        double maxHeight = 0;
        for (final HousePart printPart : printParts) {
            if (printPart.isPrintable()) {
                if (printPart instanceof Roof) {
                    for (final Spatial roofPartNode : ((Roof) printPart).getRoofPartsRoot().getChildren()) {
                        if (roofPartNode.getSceneHints().getCullHint() != CullHint.Always) {
                            final OrientedBoundingBox boundingBox = (OrientedBoundingBox) ((Node) roofPartNode).getChild(0).getWorldBound().asType(Type.OBB);
                            final double width = Math.min(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                            final double height = Math.max(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                            if (width > maxWidth) {
                                maxWidth = width;
                            }
                            if (height > maxHeight) {
                                maxHeight = height;
                            }
                        }
                    }
                } else {
                    final OrientedBoundingBox boundingBox = (OrientedBoundingBox) printPart.getMesh().getWorldBound().asType(Type.OBB);
                    final double width = Math.min(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                    final double height = Math.max(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                    if (width > maxWidth) {
                        maxWidth = width;
                    }
                    if (height > maxHeight) {
                        maxHeight = height;
                    }
                }
            }
        }
        maxWidth *= 2;
        maxHeight *= 2;
        maxWidth += 2 * spaceBetweenParts;
        maxHeight += 2 * spaceBetweenParts;
        final double ratio = pageFormat.getImageableWidth() / pageFormat.getImageableHeight();
        if (maxWidth / maxHeight > ratio) {
            pageWidth = ratio < 1 ? Math.min(maxWidth, maxHeight) : Math.max(maxWidth, maxHeight);
            pageHeight = pageWidth / ratio;
        } else {
            pageHeight = ratio < 1 ? Math.max(maxWidth, maxHeight) : Math.min(maxWidth, maxHeight);
            pageWidth = pageHeight * ratio;
        }
        fromPageToWorldCoord = pageWidth / pageFormat.getImageableWidth();
    }
    pageLeft = pageFormat.getImageableX() * fromPageToWorldCoord + spaceBetweenParts / 2.0;
    pageRight = (pageFormat.getImageableX() + pageFormat.getImageableWidth()) * fromPageToWorldCoord - spaceBetweenParts / 2.0;
    pageTop = pageFormat.getImageableY() * fromPageToWorldCoord + spaceBetweenParts / 2.0;
    if (labelHeight == 0.0) {
        final BMText label = Annotation.makeNewLabel(1);
        label.setFontScale(0.5);
        labelHeight = label.getHeight();
    }
    pageBottom = (pageFormat.getImageableY() + pageFormat.getImageableHeight()) * fromPageToWorldCoord;
    pageWidth = pageFormat.getWidth() * fromPageToWorldCoord;
    pageHeight = pageFormat.getHeight() * fromPageToWorldCoord;
}
Also used : Roof(org.concord.energy3d.model.Roof) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) Spatial(com.ardor3d.scenegraph.Spatial) BMText(com.ardor3d.ui.text.BMText) HousePart(org.concord.energy3d.model.HousePart)

Example 37 with Roof

use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.

the class PrintController method computePrintCenters.

private void computePrintCenters(final ArrayList<ArrayList<Spatial>> pages) {
    for (final HousePart printPart : printParts) {
        if (printPart.isPrintable()) {
            printPart.getRoot().updateWorldTransform(true);
            printPart.getRoot().updateWorldBound(true);
            if (printPart instanceof Roof) {
                final Roof roof = (Roof) printPart;
                for (final Spatial roofPart : roof.getRoofPartsRoot().getChildren()) {
                    if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                        final Mesh mesh = (Mesh) ((Node) roofPart).getChild(0);
                        roof.setPrintVertical(roofPart, decideVertical(mesh));
                        computePrintCenterOf(mesh, pages);
                    }
                }
            } else {
                final Mesh mesh = printPart.getMesh();
                printPart.setPrintVertical(decideVertical(mesh));
                computePrintCenterOf(mesh, pages);
            }
        }
    }
}
Also used : Roof(org.concord.energy3d.model.Roof) Spatial(com.ardor3d.scenegraph.Spatial) Mesh(com.ardor3d.scenegraph.Mesh) HousePart(org.concord.energy3d.model.HousePart)

Example 38 with Roof

use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.

the class GroupAnnualAnalysis method toJson.

@Override
public String toJson() {
    String type = "Unknown";
    final ArrayList<String> names = new ArrayList<String>();
    for (final HousePart p : selectedParts) {
        if (p instanceof SolarPanel) {
            names.add("Solar " + p.getId());
            type = "Solar Panel";
        } else if (p instanceof Rack) {
            names.add("Solar " + p.getId());
            type = "Rack";
        } else if (p instanceof Mirror) {
            names.add("Solar " + p.getId());
            type = "Mirror";
        } else if (p instanceof ParabolicTrough) {
            names.add("Solar " + p.getId());
            type = "Parabolic Trough";
        } else if (p instanceof ParabolicDish) {
            names.add("Solar " + p.getId());
            type = "Parabolic Dish";
        } else if (p instanceof FresnelReflector) {
            names.add("Solar " + p.getId());
            type = "Fresnel Reflector";
        } else if (p instanceof Wall) {
            names.add("Heat Gain " + p.getId());
            type = "Wall";
        } else if (p instanceof Roof) {
            names.add("Heat Gain " + p.getId());
            type = "Roof";
        } else if (p instanceof Door) {
            names.add("Heat Gain " + p.getId());
            type = "Door";
        } else if (p instanceof Window) {
            names.add("Solar " + p.getId());
            names.add("Heat Gain " + p.getId());
            type = "Window";
        } else if (p instanceof Foundation) {
            final Foundation foundation = (Foundation) p;
            switch(foundation.getProjectType()) {
                case Foundation.TYPE_PV_PROJECT:
                    names.add("PV " + p.getId());
                    break;
                case Foundation.TYPE_CSP_PROJECT:
                    names.add("CSP " + p.getId());
                    break;
                case Foundation.TYPE_BUILDING:
                    names.add("Building " + p.getId());
                    break;
            }
            type = "Foundation";
        }
    }
    String s = "{\"Type\": \"" + type + "\", \"Months\": " + getNumberOfDataPoints();
    for (final String name : names) {
        final List<Double> data = graph.getData(name);
        if (data == null) {
            continue;
        }
        s += ", \"" + name + "\": {";
        s += "\"Monthly\": [";
        for (final Double x : data) {
            s += Graph.ENERGY_FORMAT.format(x) + ",";
        }
        s = s.substring(0, s.length() - 1);
        s += "]\n";
        s += ", \"Total\": " + Graph.ENERGY_FORMAT.format(getResult(name));
        s += "}";
    }
    s += "}";
    return s;
}
Also used : Window(org.concord.energy3d.model.Window) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) ArrayList(java.util.ArrayList) Door(org.concord.energy3d.model.Door) ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 39 with Roof

use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.

the class GroupDailyAnalysis method toJson.

@Override
public String toJson() {
    String type = "Unknown";
    final ArrayList<String> names = new ArrayList<String>();
    for (final HousePart p : selectedParts) {
        if (p instanceof SolarPanel) {
            names.add("Solar " + p.getId());
            type = "Solar Panel";
        } else if (p instanceof Rack) {
            names.add("Solar " + p.getId());
            type = "Rack";
        } else if (p instanceof Mirror) {
            names.add("Solar " + p.getId());
            type = "Mirror";
        } else if (p instanceof ParabolicTrough) {
            names.add("Solar " + p.getId());
            type = "Parabolic Trough";
        } else if (p instanceof ParabolicDish) {
            names.add("Solar " + p.getId());
            type = "Parabolic Dish";
        } else if (p instanceof FresnelReflector) {
            names.add("Solar " + p.getId());
            type = "Fresnel Reflector";
        } else if (p instanceof Wall) {
            names.add("Heat Gain " + p.getId());
            type = "Wall";
        } else if (p instanceof Roof) {
            names.add("Heat Gain " + p.getId());
            type = "Roof";
        } else if (p instanceof Door) {
            names.add("Heat Gain " + p.getId());
            type = "Door";
        } else if (p instanceof Window) {
            names.add("Solar " + p.getId());
            names.add("Heat Gain " + p.getId());
            type = "Window";
        } else if (p instanceof Foundation) {
            final Foundation foundation = (Foundation) p;
            switch(foundation.getProjectType()) {
                case Foundation.TYPE_PV_PROJECT:
                    names.add("PV " + p.getId());
                    break;
                case Foundation.TYPE_CSP_PROJECT:
                    names.add("CSP " + p.getId());
                    break;
                case Foundation.TYPE_BUILDING:
                    names.add("Building " + p.getId());
                    break;
            }
            type = "Foundation";
        }
    }
    String s = "{\"Type\": \"" + type + "\"";
    for (final String name : names) {
        final List<Double> data = graph.getData(name);
        if (data == null) {
            continue;
        }
        s += ", \"" + name + "\": {";
        s += "\"Hourly\": [";
        for (final Double x : data) {
            s += Graph.FIVE_DECIMALS.format(x) + ",";
        }
        s = s.substring(0, s.length() - 1);
        s += "]\n";
        s += ", \"Total\": " + Graph.ENERGY_FORMAT.format(getResult(name));
        s += "}";
    }
    s += "}";
    return s;
}
Also used : Window(org.concord.energy3d.model.Window) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) ArrayList(java.util.ArrayList) Door(org.concord.energy3d.model.Door) ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Example 40 with Roof

use of org.concord.energy3d.model.Roof in project energy3d by concord-consortium.

the class GroupDailyAnalysis method updateGraph.

@Override
public void updateGraph() {
    final int n = (int) Math.round(60.0 / Scene.getInstance().getTimeStep());
    for (int i = 0; i < 24; i++) {
        SolarRadiation.getInstance().computeEnergyAtHour(i);
        for (final HousePart p : selectedParts) {
            final String customText = p.getLabelCustomText();
            if (p instanceof Window) {
                final Window window = (Window) p;
                final double solar = p.getSolarPotentialNow() * window.getSolarHeatGainCoefficient();
                graph.addData("Solar " + p.getId(), solar);
                final double[] loss = p.getHeatLoss();
                final int t0 = n * i;
                double sum = 0;
                for (int k = t0; k < t0 + n; k++) {
                    sum += loss[k];
                }
                graph.addData("Heat Gain " + p.getId(), -sum);
            } else if (p instanceof Wall || p instanceof Roof) {
                final double[] loss = p.getHeatLoss();
                final int t0 = n * i;
                double sum = 0;
                for (int k = t0; k < t0 + n; k++) {
                    sum += loss[k];
                }
                graph.addData("Heat Gain " + p.getId(), -sum);
            } else if (p instanceof SolarPanel) {
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, ((SolarPanel) p).getYieldNow());
                } else {
                    graph.addData("Solar " + p.getId(), ((SolarPanel) p).getYieldNow());
                }
            } else if (p instanceof Rack) {
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, ((Rack) p).getYieldNow());
                } else {
                    graph.addData("Solar " + p.getId(), ((Rack) p).getYieldNow());
                }
            } else if (p instanceof Mirror) {
                final Mirror mirror = (Mirror) p;
                final double solar = mirror.getSolarPotentialNow() * mirror.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof ParabolicTrough) {
                final ParabolicTrough trough = (ParabolicTrough) p;
                final double solar = trough.getSolarPotentialNow() * trough.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof ParabolicDish) {
                final ParabolicDish dish = (ParabolicDish) p;
                final double solar = dish.getSolarPotentialNow() * dish.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof FresnelReflector) {
                final FresnelReflector reflector = (FresnelReflector) p;
                final double solar = reflector.getSolarPotentialNow() * reflector.getSystemEfficiency();
                if (customText != null) {
                    graph.addData("Solar " + p.getId() + graph.getDataNameDelimiter() + customText, solar);
                } else {
                    graph.addData("Solar " + p.getId(), solar);
                }
            } else if (p instanceof Foundation) {
                final boolean mean = group.getType().endsWith("(Mean)");
                final Foundation foundation = (Foundation) p;
                switch(foundation.getProjectType()) {
                    case Foundation.TYPE_PV_PROJECT:
                        double pv = foundation.getPhotovoltaicNow();
                        if (mean) {
                            pv /= foundation.getNumberOfSolarPanels();
                            if (customText != null) {
                                graph.addData("PV " + p.getId() + graph.getDataNameDelimiter() + customText + " mean", pv);
                            } else {
                                graph.addData("PV " + p.getId() + " mean", pv);
                            }
                        } else {
                            if (customText != null) {
                                graph.addData("PV " + p.getId() + graph.getDataNameDelimiter() + customText, pv);
                            } else {
                                graph.addData("PV " + p.getId(), pv);
                            }
                        }
                        break;
                    case Foundation.TYPE_CSP_PROJECT:
                        double csp = foundation.getCspNow();
                        if (mean) {
                            csp /= foundation.countParts(new Class[] { Mirror.class, ParabolicTrough.class, ParabolicDish.class });
                            if (customText != null) {
                                graph.addData("CSP " + p.getId() + graph.getDataNameDelimiter() + customText + " mean", csp);
                            } else {
                                graph.addData("CSP " + p.getId() + " mean", csp);
                            }
                        } else {
                            if (customText != null) {
                                graph.addData("CSP " + p.getId() + graph.getDataNameDelimiter() + customText, csp);
                            } else {
                                graph.addData("CSP " + p.getId(), csp);
                            }
                        }
                        break;
                    case Foundation.TYPE_BUILDING:
                        final double totalEnergy = foundation.getTotalEnergyNow();
                        graph.addData("Building " + p.getId(), totalEnergy);
                        break;
                }
            }
        }
    }
    graph.repaint();
}
Also used : Window(org.concord.energy3d.model.Window) ParabolicTrough(org.concord.energy3d.model.ParabolicTrough) FresnelReflector(org.concord.energy3d.model.FresnelReflector) Wall(org.concord.energy3d.model.Wall) ParabolicDish(org.concord.energy3d.model.ParabolicDish) Rack(org.concord.energy3d.model.Rack) Roof(org.concord.energy3d.model.Roof) SolarPanel(org.concord.energy3d.model.SolarPanel) Foundation(org.concord.energy3d.model.Foundation) Mirror(org.concord.energy3d.model.Mirror) HousePart(org.concord.energy3d.model.HousePart)

Aggregations

Roof (org.concord.energy3d.model.Roof)51 HousePart (org.concord.energy3d.model.HousePart)47 Foundation (org.concord.energy3d.model.Foundation)38 Wall (org.concord.energy3d.model.Wall)31 Window (org.concord.energy3d.model.Window)28 Rack (org.concord.energy3d.model.Rack)25 SolarPanel (org.concord.energy3d.model.SolarPanel)24 Door (org.concord.energy3d.model.Door)21 ArrayList (java.util.ArrayList)15 List (java.util.List)12 Floor (org.concord.energy3d.model.Floor)11 Mirror (org.concord.energy3d.model.Mirror)11 ParabolicTrough (org.concord.energy3d.model.ParabolicTrough)10 Spatial (com.ardor3d.scenegraph.Spatial)9 FresnelReflector (org.concord.energy3d.model.FresnelReflector)9 ParabolicDish (org.concord.energy3d.model.ParabolicDish)9 Tree (org.concord.energy3d.model.Tree)9 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)8 CullHint (com.ardor3d.scenegraph.hint.CullHint)8 ActionEvent (java.awt.event.ActionEvent)8