public POVConeLeafWriter(AbstractExporter exporter /*, Params params*/, Tree tree) { super(); this.exporter = exporter; this.w = exporter.getWriter(); this.tree = tree; this.povrayDeclarationPrefix = tree.getSpecies() + "_" + tree.getSeed() + "_"; }
public void doWrite() { // try { // some declarations in the POV file NumberFormat frm = FloatFormat.getInstance(); // tree scale w.println( "#declare " + povrayDeclarationPrefix + "height = " + frm.format(tree.getHeight()) + ";"); // leaf declaration if (tree.getLeafCount() != 0) writeLeafDeclaration(); // stems progress.beginPhase("writing stem objects", tree.getStemCount()); for (int level = 0; level < tree.getLevels(); level++) { w.println("#declare " + povrayDeclarationPrefix + "stems_" + level + " = union {"); POVConeStemWriter writer = new POVConeStemWriter(this, /*params,*/ level); tree.traverseTree(writer); w.println("}"); } // leaves if (tree.getLeafCount() != 0) { progress.beginPhase("writing leaf objects", tree.getLeafCount()); w.println("#declare " + povrayDeclarationPrefix + "leaves = union {"); POVConeLeafWriter lexporter = new POVConeLeafWriter(this, /*params*/ tree); tree.traverseTree(lexporter); w.println("}"); } else { // empty declaration w.println("#declare " + povrayDeclarationPrefix + "leaves = sphere {<0,0,0>,0}"); } progress.endPhase(); // all stems together w.println("#declare " + povrayDeclarationPrefix + "stems = union {"); for (int level = 0; level < tree.getLevels(); level++) { w.println(" object {" + povrayDeclarationPrefix + "stems_" + level + "}"); } w.println("}"); w.flush(); // } catch (Exception e) { // e.printStackTrace(); // System.err.println(e); // throw new ExportError(e.getMessage()); // } }
/** * Outputs the Povray code for a leaf object * * @param w The output stream */ private void writeLeafDeclaration() { double length = tree.getLeafLength(); double width = tree.getLeafWidth(); w.println("#include \"arbaro.inc\""); w.println( "#declare " + povrayDeclarationPrefix + "leaf = " + "object { Arb_leaf_" + (tree.getLeafShape().equals("0") ? "disc" : tree.getLeafShape()) + " translate " + (tree.getLeafStemLength() + 0.5) + "*y scale <" + width + "," + length + "," + width + "> }"); }
public POVConeExporter(Tree tree /*, Params params*/) { super(); this.tree = tree; // this.params = params; this.povrayDeclarationPrefix = tree.getSpecies() + "_" + tree.getSeed() + "_"; }