/** * General constructor. * * @param element {@link GeoElement} * @param scope {@link EquationScope} */ public EquationPolygon(final GeoElement element, final EquationScope scope) { super(element, scope); GeoPolygon polygon = (GeoPolygon) element; this.setSegments(polygon.getSegments()); }
/** * Return the edges of a polygon * * @param poly the polygon * @return and array with all the edges of the polygon */ public static GeoSegment[] getPolygonEdges(GeoPolygon poly) { GeoSegmentND[] nd_edges = poly.getSegments(); GeoSegment[] edges = new GeoSegment[nd_edges.length]; for (int i = 0; i < nd_edges.length; i++) { edges[i] = (GeoSegment) nd_edges[i]; } return edges; }
@Override protected void updateOutput() { if (isOldFileVersion()) { // add polyhedron's segments and polygons, without setting this algo as algoparent int index = 0; if (!bottomAsInput) { // check bottom outputPolygonsBottom.addOutput(polyhedron.getFace(index), false); index++; for (int i = 0; i < bottomPointsLength; i++) outputSegmentsBottom.addOutput( (GeoSegment3D) polyhedron.getSegment(points[i], points[(i + 1) % bottomPointsLength]), false); } // sides for (int i = 0; i < bottomPointsLength; i++) { outputPolygonsSide.addOutput(polyhedron.getFace(index), false); index++; outputSegmentsSide.addOutput( (GeoSegment3D) polyhedron.getSegment(points[i], points[i + bottomPointsLength]), false); } // top outputPolygonsTop.addOutput(polyhedron.getFace(index), false); for (int i = 0; i < bottomPointsLength; i++) outputSegmentsTop.addOutput( (GeoSegment3D) polyhedron.getSegment( points[bottomPointsLength + i], points[bottomPointsLength + ((i + 1) % bottomPointsLength)]), false); } else { // Application.debug("ici"); Collection<GeoPolygon3D> faces = polyhedron.getFacesCollection(); int top = faces.size(); int step = 1; for (GeoPolygon polygon : faces) { GeoSegmentND[] segments = polygon.getSegments(); if (step == 1 && !bottomAsInput) { // bottom outputPolygonsBottom.addOutput((GeoPolygon3D) polygon, false); for (int i = 0; i < segments.length; i++) outputSegmentsBottom.addOutput((GeoSegment3D) segments[i], false); step++; continue; } else if (step == top) { // top outputPolygonsTop.addOutput((GeoPolygon3D) polygon, false); for (int i = 0; i < segments.length; i++) outputSegmentsTop.addOutput((GeoSegment3D) segments[i], false); step++; continue; } // sides outputPolygonsSide.addOutput((GeoPolygon3D) polygon, false); outputSegmentsSide.addOutput((GeoSegment3D) polygon.getSegments()[3], false); step++; } } refreshOutput(); }