- Timestamp:
- 01/09/13 13:00:20 (12 years ago)
- Location:
- java/main/src
- Files:
-
- 1 added
- 2 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/examples/GenotypeBrowser.java
r78 r79 37 37 38 38 registry.putInfoIntoCache(new FramsClass("ModelBuilderRoot", "ModelBuilderRoot", null) 39 .append(new ParamBuilder().setType("o Model").setId("f0genotype").setName("f0genotype").build()) 40 .append(new ParamBuilder().setType("o F0Model").setId("f0model").setName("f0model").build()) 39 .append(new ParamBuilder().setType("o Model").setId("model").setName("model").build()) 41 40 ); 42 41 root = new Node((CompositeParam)new ParamBuilder().setType("o ModelBuilderRoot").setId(name).setName("Instance").build(), PropertiesAccess.createPropertiesMap()); … … 50 49 List<AccessInterface> accesses = new F0Parser(schema, GenotypeBrowser.class.getResourceAsStream("/examples/f0_example.txt")).parse(); 51 50 List<Object> objects = Util.stripAccessInterface(accesses); 52 F0Genotype f0Genotype = F0Genotype.build(objects); 53 F0Model f0Model = F0Model.build(f0Genotype); 51 Model model = Model.build(objects); 54 52 55 for (String n : new String[] {"MechPart", "MechJoint", "Neuro"}) {56 registry.putInfoIntoCache(FramsClass.readFromStream(GenotypeBrowser.class.getResourceAsStream("/info/" + n + ".info")));57 }58 53 AccessInterface rootAccess = bindAccess(new Path(this, "/")); 59 54 60 rootAccess.set("f0genotype", f0Genotype); 61 rootAccess.set("f0model", f0Model); 55 rootAccess.set("model", model); 62 56 63 57 } catch (Exception e) { -
java/main/src/main/java/com/framsticks/model/BasePart.java
r78 r79 1 1 package com.framsticks.model; 2 2 3 import com.framsticks.util.Orientation; 3 4 import com.framsticks.util.Point3d; 4 5 … … 29 30 30 31 32 public double oxx, oxy, oxz, oyx, oyy, oyz, ozx, ozy, ozz; 33 34 public Orientation getOrientation() { return new Orientation(new Point3d(oxx, oxy, oxz), new Point3d(oyx, oyy, oyz), new Point3d(ozx, ozy, ozz)); } 35 36 public void setOrientation(Orientation o) { 37 oxx = o.x.x; 38 oxy = o.x.y; 39 oxz = o.x.z; 40 oyx = o.y.x; 41 oyy = o.y.y; 42 oyz = o.y.z; 43 ozx = o.z.x; 44 ozy = o.z.y; 45 ozz = o.z.z; 46 } 47 31 48 public void copyFrom(BasePart p) { 32 49 setPosition(p.getPosition()); 50 setOrientation(p.getOrientation()); 33 51 mass = p.mass; 34 52 size = p.size; -
java/main/src/main/java/com/framsticks/model/Creature.java
r78 r79 8 8 import java.util.List; 9 9 10 public class Creature extends F0Model{10 public class Creature { 11 11 public String name; 12 12 … … 147 147 public final List<NeuroDef> neurodefs = new ArrayList<NeuroDef>(); 148 148 149 150 151 149 public final List<Part> getParts() { return parts; } 152 150 public final List<Joint> getJoints() { return joints; } 153 151 public final List<NeuroDef> getNeuroDefs() { return neurodefs; } 152 153 public final List<MechPart> mechparts = new ArrayList<MechPart>(); 154 public final List<MechJoint> mechjoints = new ArrayList<MechJoint>(); 155 public final List<Neuro> neurons = new ArrayList<Neuro>(); 156 157 public final List<MechPart> getMechParts() { return mechparts; } 158 public final List<MechJoint> getMechJoints() { return mechjoints; } 159 public final List<Neuro> getNeurons() { return neurons; } 154 160 155 161 … … 160 166 constructor.field("joints"); 161 167 constructor.field("neurodefs"); 168 constructor.field("mechparts"); 169 constructor.field("mechjoints"); 170 constructor.field("neurons"); 162 171 } 163 172 -
java/main/src/main/java/com/framsticks/model/Genotype.java
r78 r79 4 4 import org.apache.log4j.Logger; 5 5 6 public class Genotype extends F0Genotype{6 public class Genotype extends Model { 7 7 private final static Logger LOGGER = Logger.getLogger(Genotype.class); 8 8 -
java/main/src/main/java/com/framsticks/model/MechPart.java
r78 r79 19 19 public void setVelocity(Point3d v) { vx = v.x; vy = v.y; vz = v.z; } 20 20 21 public double oxx, oxy, oxz, oyx, oyy, oyz, ozx, ozy, ozz;22 23 public Orientation getOrientation() { return new Orientation(new Point3d(oxx, oxy, oxz), new Point3d(oyx, oyy, oyz), new Point3d(ozx, ozy, ozz)); }24 25 public void setOrientation(Orientation o) {26 oxx = o.x.x;27 oxy = o.x.y;28 oxz = o.x.z;29 oyx = o.y.x;30 oyy = o.y.y;31 oyz = o.y.z;32 ozx = o.z.x;33 ozy = o.z.y;34 ozz = o.z.z;35 }36 21 37 22 } -
java/main/src/main/java/com/framsticks/model/Package.java
r78 r79 17 17 registry.registerReflectedClass("NeuroDef", "n", "com.framsticks.model.NeuroDef"); 18 18 registry.registerReflectedClass("Part", "p", "com.framsticks.model.Part"); 19 registry.registerReflectedClass("Model", "m", "com.framsticks.model.F0Genotype"); 20 registry.registerReflectedClass("F0Model", null, "com.framsticks.model.F0Model"); 21 registry.registerReflectedClass("F0Genotype", null, "com.framsticks.model.F0Genotype"); 19 registry.registerReflectedClass("Model", "m", "com.framsticks.model.Model"); 22 20 registry.registerReflectedClass("Creature", null, "com.framsticks.model.Creature"); 23 21 registry.registerReflectedClass("Genotype", null, "com.framsticks.model.Genotype"); 24 22 25 registry.putInfoIntoCache(new FramsClass.Constructor(F0Model.class, "F0Model").getResult());26 23 } 27 24 } -
java/main/src/main/java/com/framsticks/model/Part.java
r78 r79 33 33 public void setDn(Double dn) { density = dn; } 34 34 35 36 35 public Double getIng() { return ingestion; } 37 36 public void setIng(Double ing) { ingestion = ing; } -
java/main/src/main/java/com/framsticks/parsers/F0Parser.java
r78 r79 9 9 import java.util.List; 10 10 11 import com.framsticks.model. F0Genotype;11 import com.framsticks.model.Model; 12 12 import static com.framsticks.params.SimpleAbstractAccess.*; 13 13 … … 109 109 110 110 /** If no 'm' (Model) line was found, than simulate it on the beginning of the result.*/ 111 if (result.isEmpty() || !(result.get(0) instanceof F0Genotype)) {111 if (result.isEmpty() || !(result.get(0) instanceof Model)) { 112 112 result.add(0, processLine("m:")); 113 113 } -
java/main/src/test/java/com/framsticks/parsers/F0ParserTest.java
r78 r79 39 39 { 40 40 assertEquals(12, accesses.size()); 41 assertTrue(accesses.get(0).getSelected() instanceof F0Genotype);41 assertTrue(accesses.get(0).getSelected() instanceof Model); 42 42 assertEquals("1,2,3,\"dsadsa,,,,", accesses.get(5).get("i", String.class)); 43 43 assertEquals("|:p=0.25,r=1", accesses.get(7).get("d", String.class)); … … 52 52 } 53 53 54 F0Genotype f0Genotype = Genotype.build(objects);54 Model model = Model.build(objects); 55 55 { 56 assertEquals(3, f0Genotype.getParts().size());57 assertEquals(6, f0Genotype.getNeuroDefs().size());58 assertEquals(2, f0Genotype.getJoints().size());56 assertEquals(3, model.getParts().size()); 57 assertEquals(6, model.getNeuroDefs().size()); 58 assertEquals(2, model.getJoints().size()); 59 59 60 assertEquals(new Integer(0), f0Genotype.getJoints().get(0).part1); 61 assertEquals(new Integer(1), f0Genotype.getJoints().get(0).part2); 62 assertEquals(new Integer(1), f0Genotype.getNeuroDefs().get(0).part); 63 assertEquals(new Integer(-1), f0Genotype.getNeuroDefs().get(0).joint); 64 assertEquals("|:p=0.25,r=1", f0Genotype.getNeuroDefs().get(1).details); 65 assertEquals("N", f0Genotype.getNeuroDefs().get(3).details); 66 assertEquals(new Integer(-1), f0Genotype.getNeuroDefs().get(4).part); 60 assertEquals(new Integer(0), model.getJoints().get(0).part1); 61 assertEquals(new Integer(1), model.getJoints().get(0).part2); 62 assertEquals(new Integer(1), model.getNeuroDefs().get(0).part); 63 assertEquals(new Integer(-1), model.getNeuroDefs().get(0).joint); 64 assertEquals("|:p=0.25,r=1", model.getNeuroDefs().get(1).details); 65 assertEquals("N", model.getNeuroDefs().get(3).details); 66 assertEquals(new Integer(-1), model.getNeuroDefs().get(4).part); 67 68 assertEquals(2.0, model.getParts().get(1).getPosition().x, 0.0); 69 assertTrue(model.getParts().get(2).getPosition().sub(new Point3d(2.27236, -0.0792596, -0.958924)).length() < 0.0001); 70 assertTrue(model.getParts().get(2).getOrientation().y.sub(new Point3d(0.870277, -0.404792, 0.280644)).length() < 0.0001); 67 71 } 68 72 69 F0Model f0model = F0Model.build(f0Genotype);70 {71 assertEquals(2.0, f0model.getMechParts().get(1).getPosition().x, 0.0);72 assertTrue(f0model.getMechParts().get(2).getPosition().sub(new Point3d(2.27236, -0.0792596, -0.958924)).length() < 0.0001);73 assertTrue(f0model.getMechParts().get(2).getOrientation().y.sub(new Point3d(0.870277, -0.404792, 0.280644)).length() < 0.0001);74 }75 73 76 74 }
Note: See TracChangeset
for help on using the changeset viewer.