]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java
First version of fixed nozzle positions
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / utils / ComponentUtils.java
index b08c04cb41a2b4cace86fd1b683e29b705a4fa7f..fdd5b5bbe8d89c3c4c8a3f4204ae6c618a36186d 100644 (file)
@@ -14,9 +14,11 @@ import org.simantics.g3d.scenegraph.GeometryProvider;
 import org.simantics.layer0.Layer0;
 import org.simantics.plant3d.ontology.Plant3D;
 import org.simantics.plant3d.scenegraph.EndComponent;
+import org.simantics.plant3d.scenegraph.Equipment;
 import org.simantics.plant3d.scenegraph.InlineComponent;
 import org.simantics.plant3d.scenegraph.Nozzle;
 import org.simantics.plant3d.scenegraph.P3DRootNode;
+import org.simantics.plant3d.scenegraph.PipeRun;
 import org.simantics.plant3d.scenegraph.PipelineComponent;
 import org.simantics.plant3d.scenegraph.TurnComponent;
 
@@ -36,7 +38,7 @@ public class ComponentUtils {
                                types.add(Plant3D.URIs.Builtin_Elbow);
                                types.add(Plant3D.URIs.Builtin_ConcentricReducer);
                                types.add(Plant3D.URIs.Builtin_BranchSplitComponent);
-//                             types.add(Plant3D.URIs.Builtin_EccentricReducer);
+                               types.add(Plant3D.URIs.Builtin_EccentricReducer);
                                
                                for (String typeURI : types) {
                                        load(graph, typeURI);
@@ -85,7 +87,7 @@ public class ComponentUtils {
                GeometryProvider provider = getProvider(graph, type);
                if (provider != null || graph.hasStatement(type,p3d.NonVisibleComponent)) {
                        providers.put(typeURI, provider);
-                       ComponentUtils.clazzes.put(typeURI,getClazz(graph, type));
+                       clazzes.put(typeURI,getClazz(graph, type));
                        return;
                }
                throw new DatabaseException("Cannot find component for " + typeURI);
@@ -151,4 +153,33 @@ public class ComponentUtils {
                component.setType(Plant3D.URIs.Builtin_BranchSplitComponent);
                return component;
        }
+       
+       public static Equipment createEquipment(P3DRootNode root, Item equipmentType) throws Exception {
+           Equipment equipment = root.createEquipment();
+        equipment.setType(equipmentType.getUri());
+        String n = root.getUniqueName(equipmentType.getName());
+        equipment.setName(n);
+        root.addChild(equipment);
+        return equipment;
+       }
+       
+       public static Nozzle createDefaultNozzle(P3DRootNode root, Equipment equipment) throws Exception {
+           return createNozzle(root, equipment, new Item(Plant3D.URIs.Builtin_Nozzle, "Nozzle"));
+       }
+       
+       public static Nozzle createNozzle(P3DRootNode root, Equipment equipment, Item nozzleType) throws Exception {
+           Nozzle nozzle = root.createNozzle();
+        nozzle.setType(nozzleType.getUri());
+        String n = root.getUniqueName(nozzleType.getName());
+        nozzle.setName(n);
+        PipeRun pipeRun = new PipeRun();
+        n = root.getUniqueName("PipeRun");
+        pipeRun.setName(n);
+        nozzle.setPipeRun(pipeRun);
+        
+        equipment.addChild(nozzle);
+        root.addChild(pipeRun);
+        // root.getNodeMap().commit("Add nozzle " + n);
+        return nozzle;
+       }
 }