]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Flat nozzles 60/3360/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 17 Oct 2019 13:50:31 +0000 (16:50 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 17 Oct 2019 13:50:31 +0000 (16:50 +0300)
gitlab #34

Change-Id: Iba887aef0a3abb9528d02c5c8a0321050700278f

org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph
org.simantics.plant3d/src/org/simantics/plant3d/geometry/FlatNozzleGeometryProvider.java [new file with mode: 0644]
org.simantics.plant3d/src/org/simantics/plant3d/geometry/PumpGeometryProvider.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java

index a26abde450c5e2e0309051da91d0c6470f5bafef..84e0b67414dd39f54c1dc1cd773d84054fc82558 100644 (file)
@@ -5,6 +5,7 @@ P3D = <http://www.simantics.org/Plant3D-0.1>
 P3D.Builtin : L0.Library
 
 P3D.Builtin.NozzleGeometryProvider : P3D.GeometryProvider
+P3D.Builtin.FlatNozzleGeometryProvider : P3D.GeometryProvider
 P3D.Builtin.HorizontalTankGeometryProvider : P3D.GeometryProvider
 P3D.Builtin.VerticalTankGeometryProvider : P3D.GeometryProvider
 P3D.Builtin.StraightGeometryProvider : P3D.GeometryProvider
@@ -68,6 +69,13 @@ P3D.Builtin.BranchSplitComponent <T P3D.InlineComponent : P3D.InlineComponent
     
 P3D.Builtin.Nozzle <T P3D.Nozzle : P3D.Nozzle
       @L0.assert P3D.hasGeometry P3D.Builtin.NozzleGeometryProvider
+      @L0.assert P3D.hasParameter
+         _ :P3D.Parameter
+           L0.HasName "length" : L0.String
+           P3D.hasParameterValue 0.1 : L0.Double
+P3D.Builtin.FlatNozzle <T P3D.Nozzle : P3D.Nozzle
+      @L0.assert P3D.hasGeometry P3D.Builtin.FlatNozzleGeometryProvider
+      
 P3D.Builtin.HorizontalTank <T P3D.Equipment : P3D.Equipment
      @L0.assert P3D.hasGeometry P3D.Builtin.HorizontalTankGeometryProvider
      @L0.assert P3D.hasParameter
diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/geometry/FlatNozzleGeometryProvider.java b/org.simantics.plant3d/src/org/simantics/plant3d/geometry/FlatNozzleGeometryProvider.java
new file mode 100644 (file)
index 0000000..82ddb70
--- /dev/null
@@ -0,0 +1,37 @@
+package org.simantics.plant3d.geometry;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import org.jcae.opencascade.jni.TopoDS_Shape;
+import org.simantics.db.Resource;
+import org.simantics.g3d.math.MathTools;
+import org.simantics.opencascade.OccTriangulator;
+
+public class FlatNozzleGeometryProvider extends BuiltinGeometryProvider  {
+       
+       public FlatNozzleGeometryProvider(Resource resource) {
+               super(resource);
+       }
+
+       private double radius = 0.01;
+       
+       @Override
+       public Collection<TopoDS_Shape> getModel() throws Exception {
+               if (radius < MathTools.NEAR_ZERO)
+                       return Collections.emptyList();
+               double length = 0.01;
+               TopoDS_Shape shape = OccTriangulator.makeCylinder(new double[] {0.0, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, length);
+               return Collections.singletonList(shape);
+       }
+       
+       @Override
+       public void setProperties(Map<String, Object> props) {
+               if (props.containsKey("radius")) {
+                       radius = (Double)props.get("radius");
+               }
+               
+       }
+
+}
index a34e34689361884f3af8be0a929711410a476ca7..89fe4b3074edf282e2fe96805916b5661302d10c 100644 (file)
@@ -74,9 +74,9 @@ public class PumpGeometryProvider extends BuiltinGeometryProvider  implements Fi
        
        @Override
        public void updateNozzlePosition(int index, Nozzle nozzle) {
-               Double fl = nozzle.getFlowLength();
+               Double fl = (Double)nozzle.getParameterMap().get("length");
                if (fl == null)
-                       fl = 0.1;
+                       fl = 0.0;
                if (index == 0) {
                        nozzle.setPosition(new Vector3d(-length*0.5- fl,width*0.6,0.0));
                        nozzle.setOrientation(MathTools.getQuat(new AxisAngle4d(0,1,0,Math.PI)));
index fb18406846c2d81721811f1102018801c676cde5..55773f0f6a682921b01feef89d0697e1ac7624c5 100644 (file)
@@ -134,7 +134,7 @@ public class Nozzle extends PipelineComponent {
                
                PipeRun pipeRun = getPipeRun();
                if (pipeRun != null) {
-                       map.put("length", pipeRun.getPipeDiameter() * 2.0);
+                       //map.put("length", pipeRun.getPipeDiameter() * 2.0);
                        map.put("radius", pipeRun.getPipeDiameter() * 0.5);
                }
                return map;
index 3f393364e3ccf456cc9ab63b53b8c01927ee6278..fd085db11bb530f4007fbd1fabda812166a9c24b 100644 (file)
@@ -1,15 +1,21 @@
 package org.simantics.plant3d.scenegraph;
 
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.vecmath.Quat4d;
 import javax.vecmath.Tuple3d;
 import javax.vecmath.Vector3d;
 
 import org.simantics.g3d.math.MathTools;
+import org.simantics.g3d.property.annotations.CompoundGetPropertyValue;
+import org.simantics.g3d.property.annotations.CompoundSetPropertyValue;
 import org.simantics.g3d.property.annotations.GetPropertyValue;
 import org.simantics.g3d.property.annotations.PropertyContributor;
+import org.simantics.objmap.graph.annotations.CompoundRelatedGetValue;
+import org.simantics.objmap.graph.annotations.CompoundRelatedSetValue;
 import org.simantics.objmap.graph.annotations.RelatedGetObj;
 import org.simantics.objmap.graph.annotations.RelatedSetObj;
 import org.simantics.plant3d.ontology.Plant3D;
@@ -83,6 +89,37 @@ public abstract class PipelineComponent extends GeometryNode {
                super.updateParameters();
        }
        
+       @Override
+    @CompoundRelatedGetValue(objRelation=Plant3D.URIs.hasParameter,objType=Plant3D.URIs.Parameter,valRelation=Plant3D.URIs.hasParameterValue)
+    @CompoundGetPropertyValue(name="Parameters",tabId="Parameters",value="parameters")
+    public Map<String, Object> getParameterMap() {
+        return super.getParameterMap();
+    }
+       
+    @Override
+    @CompoundRelatedSetValue(Plant3D.URIs.hasParameter)
+    public void setParameterMap(Map<String, Object> parameters) {
+        super.setParameterMap(parameters);
+    }
+    
+    @CompoundGetPropertyValue(name="Parameters",tabId="Parameters",value="parameters")
+    public Map<String,Object> getParameterMapUI() {
+        // TODO : how to filter parameters that are calculated by geometry provider?
+        Map<String,Object> map = new HashMap<String, Object>(getParameterMap());
+        map.remove("radius");
+        return map;
+    }
+    
+    @CompoundSetPropertyValue(value="parameters")
+    public void setParameterMapUI(Map<String, Object> parameters) { 
+        Map<String, Object> curr = getParameterMap();
+        for (Entry<String, Object> entry : curr.entrySet()) {
+            if (!parameters.containsKey(entry.getKey()))
+                parameters.put(entry.getKey(), entry.getValue());
+        }
+        setParameterMap(parameters);
+    }
+       
        public abstract void setType(String typeURI) throws Exception;
        
        @RelatedGetObj(Plant3D.URIs.HasNext)