Thread: [Bprocessor-commit] /model/src/net/sourceforge/bprocessor/model/modellor TileModellor.java, 1.3, 1
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-04-16 09:08:54
|
Update of /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/modellor In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv17774/src/net/sourceforge/bprocessor/model/modellor Modified Files: TileModellor.java Modellor.java Log Message: now the surface is covered with tiles Index: TileModellor.java =================================================================== RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/modellor/TileModellor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TileModellor.java 14 Apr 2007 15:05:38 -0000 1.3 --- TileModellor.java 16 Apr 2007 09:08:46 -0000 1.4 *************** *** 9,16 **** --- 9,18 ---- import java.awt.Dimension; import java.util.ArrayList; + import java.util.LinkedList; import java.util.List; import org.apache.log4j.Logger; + import net.sourceforge.bprocessor.model.Attribute; import net.sourceforge.bprocessor.model.CoordinateSystem; import net.sourceforge.bprocessor.model.Edge; *************** *** 34,40 **** private Dimension tileSize = new Dimension(100, 100); ! /** The width of the joint between tiles */ private static int jointSize = 3; private Material tileColor = new Material("White", new float[]{1.0f, 1.0f, 1.0f}); --- 36,44 ---- private Dimension tileSize = new Dimension(100, 100); ! /** The width of the joint between tiles in mm*/ private static int jointSize = 3; + private int height = 0; + private Material tileColor = new Material("White", new float[]{1.0f, 1.0f, 1.0f}); *************** *** 83,86 **** --- 87,144 ---- space.add(startPoint); CoordinateSystem cs = startPoint; + //find outer borders + double maxX = Double.MIN_VALUE, maxY = Double.MIN_VALUE, + minX = Double.MAX_VALUE, minY = Double.MAX_VALUE; + for (Vertex v : surface.collect()) { + Vertex translated = cs.translate(v); + if (translated.getX() > maxX) { + maxX = translated.getX(); + } + if (translated.getX() < minX) { + minX = translated.getX(); + } + if (translated.getY() > maxY) { + maxY = translated.getY(); + } + if (translated.getY() < minY) { + minY = translated.getY(); + } + } + List<Surface> tiles = new LinkedList<Surface>(); + CoordinateSystem insertPoint = cs.copy(); + insertPoint.setOrigin(cs.unTranslate(new Vertex(minX + jointSize / 2000, + minY + jointSize / 2000, + 0))); + Vertex orig = insertPoint.center(); + if (height > 0) { + maxY = height / 1000; + } + Vertex horizontalAdd = insertPoint.unTranslate(new Vertex(tileSize.getWidth() / 1000.0 + jointSize / 2000.0, 0, 0)).minus(orig); + do { + Vertex verticalAdd = insertPoint.unTranslate(new Vertex(0, tileSize.getHeight() / 1000.0 + jointSize / 2000.0, 0)).minus(orig); + int iterations = 0; + do { + tiles.add(drawTile(insertPoint, tileColor)); + orig = orig.add(verticalAdd); + insertPoint.setOrigin(orig); + iterations++; + } while (cs.translate(orig.copy()).getY() < maxY); + orig = orig.add(horizontalAdd); + Vertex tmp = verticalAdd.copy(); + tmp.scale(iterations); + orig = orig.minus(tmp); + insertPoint.setOrigin(orig); + } while (cs.translate(orig.copy()).getX() < maxX); + + for (Surface s : tiles) { + List<Surface> extrusion = new ArrayList<Surface>(); + Surface back = s.extrusion(-tileThickness / 1000.0, extrusion); + extrusion.add(back); + extrusion.add(s); + space.addAll(extrusion); + } + } + + private Surface drawTile(CoordinateSystem cs, Material color) { Space tile = new Space("Tile", Space.CONSTRUCTION, Space.PART_LEVEL, true); space.add(tile); *************** *** 101,114 **** edges.add(e4); Surface front = new Surface(edges); ! front.setFrontMaterial(tileColor); front.setBackDomain(tile); ! List<Surface> extrusion = new ArrayList<Surface>(); ! Surface back = front.extrusion(-tileThickness / 1000.0, extrusion); ! extrusion.add(back); ! extrusion.add(front); ! space.addAll(extrusion); ! } /** * {@inheritDoc} --- 159,193 ---- edges.add(e4); Surface front = new Surface(edges); ! front.setFrontMaterial(color); front.setBackDomain(tile); ! return front; } + /** {@inheritDoc} */ + @Override + public List<Attribute> getAttributes() { + List<Attribute> atrib = super.getAttributes(); + + atrib.add(new Attribute("Tilewidth", new Double(tileSize.width))); + atrib.add(new Attribute("Tileheight", new Double(tileSize.height))); + atrib.add(new Attribute("Joint width", new Double(jointSize))); + atrib.add(new Attribute("Material", tileColor)); + atrib.add(new Attribute("Surface", surface)); + atrib.add(new Attribute("Setting height", new Double(height))); + return atrib; + } + + /** {@inheritDoc} */ + @Override + public void setAttributes(List<Attribute> attributes) { + super.setAttributes(attributes); + for (Attribute a : attributes) { + if (a.getName().equals("Setting height")) { + height = ((Double)a.getValue()).intValue(); + update(null); + } + } + } + /** * {@inheritDoc} Index: Modellor.java =================================================================== RCS file: /cvsroot/bprocessor//model/src/net/sourceforge/bprocessor/model/modellor/Modellor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Modellor.java 15 Apr 2007 11:12:57 -0000 1.8 --- Modellor.java 16 Apr 2007 09:08:46 -0000 1.9 *************** *** 160,164 **** * @return the attributes */ ! public List getAttributes() { List<Attribute> l = new LinkedList<Attribute>(); l.add(new Attribute("Active", Boolean.valueOf(active), true)); --- 160,164 ---- * @return the attributes */ ! public List<Attribute> getAttributes() { List<Attribute> l = new LinkedList<Attribute>(); l.add(new Attribute("Active", Boolean.valueOf(active), true)); |