[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Cylinder.java, NONE, 1.1
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2006-10-30 10:34:26
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25126/src/net/sourceforge/bprocessor/model Added Files: Cylinder.java Log Message: refactored cylinder out of SpaceTool and changede som mouse checks to use isPopuptrigger instead of third button and isctrlpressed. THERE ARE SOME PROBLEMS ON MAC IF RIGHT CLICK IS ACHIEVED WITH CTRL MODIFIER BUT EXTERNAL MOUSE SHOULD BE USED NOT A TRACKPAD. --- NEW FILE: Cylinder.java --- //--------------------------------------------------------------------------------- // $Id: Cylinder.java,v 1.1 2006/10/30 10:34:21 rimestad Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import net.sourceforge.bprocessor.model.modellor.Modellor; /** * The cylinder class parametrically generates a cylinder. */ public class Cylinder extends Modellor { /** Default */ private static final long serialVersionUID = 1L; /** radius */ private double radius = 1.0; /** height */ private double height = 1.0; /** axis divisions */ private int axisDivisions = 12; /*** * Generate a Cylinder * @param entity Changed entity */ public void update(Object entity) { /** Origin */ Vertex o = new Vertex(0, 0, 0); /** Bottom vertices */ Vertex[] bv = new Vertex[axisDivisions]; /** Top vertices */ Vertex[] tv = new Vertex[axisDivisions]; /** Bottom edges */ Edge[] be = new Edge[axisDivisions]; /** Top edges */ Edge te[] = new Edge[axisDivisions]; /** Side edges */ Edge se[] = new Edge[axisDivisions]; /** Side faces */ Surface sf[] = new Surface[axisDivisions]; Surface top; Surface bottom; Space space = Project.getInstance().world(); for (int i = 0; i < axisDivisions; i++) { double angle = ((2 * Math.PI) * i) / (double) axisDivisions; double x = radius * Math.cos(angle) + o.getX(); double y = radius * Math.sin(angle) + o.getY(); double z = o.getZ(); bv[i] = new Vertex(x, y, z); tv[i] = new Vertex(x, y, z + height); space.add(bv[i]); space.add(tv[i]); } for (int i = 0; i < axisDivisions; i++) { be[i] = new Edge(bv[i], bv[(i + 1) % axisDivisions]); space.add(be[i]); } for (int i = 0; i < axisDivisions; i++) { te[i] = new Edge(tv[i], tv[(i + 1) % axisDivisions]); space.add(te[i]); } for (int i = 0; i < axisDivisions; i++) { se[i] = new Edge(bv[i], tv[i]); space.add(se[i]); } for (int i = 0; i < axisDivisions; i++) { List edges = new LinkedList(); edges.add(be[i]); edges.add(se[(i + 1) % axisDivisions]); edges.add(te[i]); edges.add(se[i]); sf[i] = new Surface(edges); space.add(sf[i]); } { List edges = new LinkedList(Arrays.asList(be)); bottom = new Surface(edges); space.add(bottom); } { List edges = new LinkedList(Arrays.asList(te)); top = new Surface(edges); space.add(top); } } /** * Return null for center * @return Center */ public Vertex center() { return null; } /** * FIXME: empty implementation to make compile * (pfff make sure stuff compiles before you check in please) */ public void delete() { return; } /** @see net.sourceforge.bprocessor.model.Parametric#setAttributes(List) */ public void setAttributes(List attributes) { // TODO Auto-generated method stub } /** @see net.sourceforge.bprocessor.model.Parametric#getGeneralName() */ public List getAttributes() { // TODO Auto-generated method stub return null; } /** @see net.sourceforge.bprocessor.model.modellor.Modellor#newInstance(Space) */ public Modellor newInstance(Space s) { // TODO Auto-generated method stub return null; } /** @see net.sourceforge.bprocessor.model.modellor.Modellor#setContent(Map) */ public void setContent(Map m) { axisDivisions = ((Integer)m.get("Axis")).intValue(); height = ((Double)m.get("Height")).doubleValue(); radius = ((Double)m.get("Radius")).doubleValue(); } /** @see net.sourceforge.bprocessor.model.modellor.Modellor#getContent() */ public Map getContent() { Map m = new HashMap(); m.put("Axis", new Integer(axisDivisions)); m.put("Height", new Double(height)); m.put("Radius", new Double(radius)); return m; } } |