]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Support for inline component rotations 22/3022/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 16 Jul 2019 16:25:00 +0000 (19:25 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 16 Jul 2019 16:25:00 +0000 (19:25 +0300)
* P3D.RotateComponent tag
* P3D.HasRotationAngle property relation
* PipeControlPoint rotate flag
* InlineComponent get/set RotationAngle methods
* Gate Valve inline component for testing the feature

gitlab #13

Change-Id: I2a1fb87a5de312d2870189b0e81791feeec1f652

org.simantics.plant3d.ontology/graph/plant3d.pgraph
org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph
org.simantics.plant3d.ontology/src/org/simantics/plant3d/ontology/Plant3D.java
org.simantics.plant3d/adapters.xml
org.simantics.plant3d/src/org/simantics/plant3d/geometry/GateValveGeometryProvider.java [new file with mode: 0644]
org.simantics.plant3d/src/org/simantics/plant3d/geometry/PumpGeometryProvider.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/ControlPointFactory.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java
org.simantics.plant3d/src/org/simantics/plant3d/utils/ComponentUtils.java

index 8edc9f61e77e31d1ec07dc035e66ac2eb3692d6e..d7dce09ee57cb2c5856987bc352022323cac3240 100644 (file)
@@ -67,9 +67,11 @@ P3D.VariableAngleTurnComponent <R P3D.PipelineComponentTag
 P3D.SizeChangeComponent <R P3D.PipelineComponentTag
     L0.HasDescription "Component that changes pipe run along main pipeline. (Spec change)" : L0.String
 P3D.OffsetComponent<R P3D.PipelineComponentTag
-    L0.HasDescription "Component that offsets the center of piperun." : L0.String  
+    L0.HasDescription "Component that offsets the center of piperun." : L0.String
+P3D.RotateComponent<R P3D.PipelineComponentTag
+    L0.HasDescription "Inline Component that can be rotated around pipe axis." : L0.String    
 P3D.CodeComponent <T P3D.PipelineComponentTag
-    L0.HasDescription "Compoenent that cannot be added directly by user" : L0.String
+    L0.HasDescription "Component that cannot be added directly by user" : L0.String
 P3D.NonVisibleComponent <R P3D.PipelineComponentTag
     L0.HasDescription "(Pseudo) Component that cannot bee seen." : L0.String
 
@@ -105,8 +107,8 @@ P3D.HasPipeDiameter <R G3D.hasNonTransformation
 //    L0.HasRange L0.Double
 //P3D.HasTurnAngle <R G3D.hasNonTransformation
 //    L0.HasRange L0.Double
-//P3D.HasRotationAngle <R G3D.hasTransformation
-//    L0.HasRange L0.Double
+P3D.HasRotationAngle <R G3D.hasTransformation
+    L0.HasRange L0.Double
 //P3D.HasOffset <R L0.HasProperty
 //    L0.HasRange L0.Double
 //HasRelativePosition <R HasProperty
index 49bec3ea8cc8de2dfd6a44d1f2e4fb2ccbf3275f..a8f2a5bbe25f78aa9c4429426b7a061c7605720e 100644 (file)
@@ -14,6 +14,7 @@ P3D.Builtin.ReducerGeometryProvider : P3D.Builtin.GeometryProvider
 P3D.Builtin.PumpGeometryProvider : P3D.Builtin.GeometryProvider
 P3D.Builtin.BallValveGeometryProvider : P3D.Builtin.GeometryProvider
 P3D.Builtin.CheckValveGeometryProvider : P3D.Builtin.GeometryProvider
+P3D.Builtin.GateValveGeometryProvider : P3D.Builtin.GeometryProvider
 P3D.Builtin.CapGeometryProvider : P3D.Builtin.GeometryProvider
 
  
@@ -31,6 +32,7 @@ P3D.Builtin.EccentricReducer <T P3D.InlineComponent : P3D.InlineComponent
     @L0.tag P3D.SizeChangeComponent
     @L0.tag P3D.FixedLengthInlineComponent
     @L0.tag P3D.DualConnectedComponent
+    @L0.tag P3D.RotateComponent
 //  HasRotationAngle "0.0" : Double
 //  HasControlPoint 
 //    _ : SizeChangeControlPoint : OffsettingPoint
@@ -116,6 +118,16 @@ P3D.Builtin.CheckValve <T P3D.InlineComponent : P3D.InlineComponent
            L0.HasName "radius" : L0.String
            P3D.hasParameterValue 0.1 : L0.Double
            
+P3D.Builtin.GateValve <T P3D.InlineComponent : P3D.InlineComponent
+    @L0.tag P3D.DualConnectedComponent
+    @L0.tag P3D.FixedLengthInlineComponent
+    @L0.tag P3D.RotateComponent
+    @L0.assert P3D.hasGeometry P3D.Builtin.GateValveGeometryProvider
+    @L0.assert P3D.hasParameter
+         _ :P3D.Parameter
+           L0.HasName "radius" : L0.String
+           P3D.hasParameterValue 0.1 : L0.Double
+           
 P3D.Builtin.Cap <T P3D.EndComponent : P3D.InlineComponent
     @L0.assert P3D.hasGeometry P3D.Builtin.CapGeometryProvider
     @L0.assert P3D.hasParameter
index 394da93787550476955478aab009bbf968e106ac..e8558f2864fbfded90c5f26b81a86cd46e23ed32 100644 (file)
@@ -22,6 +22,8 @@ public class Plant3D {
     public final Resource Builtin_EccentricReducer;
     public final Resource Builtin_Elbow;
     public final Resource Builtin_ElbowGeometryProvider;
+    public final Resource Builtin_GateValve;
+    public final Resource Builtin_GateValveGeometryProvider;
     public final Resource Builtin_GeometryProvider;
     public final Resource Builtin_HorizontalTank;
     public final Resource Builtin_HorizontalTankGeometryProvider;
@@ -64,6 +66,8 @@ public class Plant3D {
     public final Resource HasPipeDiameter_Inverse;
     public final Resource HasPipeRun;
     public final Resource HasPrevious;
+    public final Resource HasRotationAngle;
+    public final Resource HasRotationAngle_Inverse;
     public final Resource HasTurnAxis;
     public final Resource HasTurnAxis_Inverse;
     public final Resource HasTurnRadius;
@@ -98,6 +102,7 @@ public class Plant3D {
     public final Resource PipelineComponentTag;
     public final Resource Plant;
     public final Resource PreviousInverse;
+    public final Resource RotateComponent;
     public final Resource SingleConnectedComponent;
     public final Resource SizeChangeComponent;
     public final Resource TurnComponent;
@@ -122,6 +127,8 @@ public class Plant3D {
         public static final String Builtin_EccentricReducer = "http://www.simantics.org/Plant3D-0.1/Builtin/EccentricReducer";
         public static final String Builtin_Elbow = "http://www.simantics.org/Plant3D-0.1/Builtin/Elbow";
         public static final String Builtin_ElbowGeometryProvider = "http://www.simantics.org/Plant3D-0.1/Builtin/ElbowGeometryProvider";
+        public static final String Builtin_GateValve = "http://www.simantics.org/Plant3D-0.1/Builtin/GateValve";
+        public static final String Builtin_GateValveGeometryProvider = "http://www.simantics.org/Plant3D-0.1/Builtin/GateValveGeometryProvider";
         public static final String Builtin_GeometryProvider = "http://www.simantics.org/Plant3D-0.1/Builtin/GeometryProvider";
         public static final String Builtin_HorizontalTank = "http://www.simantics.org/Plant3D-0.1/Builtin/HorizontalTank";
         public static final String Builtin_HorizontalTankGeometryProvider = "http://www.simantics.org/Plant3D-0.1/Builtin/HorizontalTankGeometryProvider";
@@ -164,6 +171,8 @@ public class Plant3D {
         public static final String HasPipeDiameter_Inverse = "http://www.simantics.org/Plant3D-0.1/HasPipeDiameter/Inverse";
         public static final String HasPipeRun = "http://www.simantics.org/Plant3D-0.1/HasPipeRun";
         public static final String HasPrevious = "http://www.simantics.org/Plant3D-0.1/HasPrevious";
+        public static final String HasRotationAngle = "http://www.simantics.org/Plant3D-0.1/HasRotationAngle";
+        public static final String HasRotationAngle_Inverse = "http://www.simantics.org/Plant3D-0.1/HasRotationAngle/Inverse";
         public static final String HasTurnAxis = "http://www.simantics.org/Plant3D-0.1/HasTurnAxis";
         public static final String HasTurnAxis_Inverse = "http://www.simantics.org/Plant3D-0.1/HasTurnAxis/Inverse";
         public static final String HasTurnRadius = "http://www.simantics.org/Plant3D-0.1/HasTurnRadius";
@@ -198,6 +207,7 @@ public class Plant3D {
         public static final String PipelineComponentTag = "http://www.simantics.org/Plant3D-0.1/PipelineComponentTag";
         public static final String Plant = "http://www.simantics.org/Plant3D-0.1/Plant";
         public static final String PreviousInverse = "http://www.simantics.org/Plant3D-0.1/PreviousInverse";
+        public static final String RotateComponent = "http://www.simantics.org/Plant3D-0.1/RotateComponent";
         public static final String SingleConnectedComponent = "http://www.simantics.org/Plant3D-0.1/SingleConnectedComponent";
         public static final String SizeChangeComponent = "http://www.simantics.org/Plant3D-0.1/SizeChangeComponent";
         public static final String TurnComponent = "http://www.simantics.org/Plant3D-0.1/TurnComponent";
@@ -232,6 +242,8 @@ public class Plant3D {
         Builtin_EccentricReducer = getResourceOrNull(graph, URIs.Builtin_EccentricReducer);
         Builtin_Elbow = getResourceOrNull(graph, URIs.Builtin_Elbow);
         Builtin_ElbowGeometryProvider = getResourceOrNull(graph, URIs.Builtin_ElbowGeometryProvider);
+        Builtin_GateValve = getResourceOrNull(graph, URIs.Builtin_GateValve);
+        Builtin_GateValveGeometryProvider = getResourceOrNull(graph, URIs.Builtin_GateValveGeometryProvider);
         Builtin_GeometryProvider = getResourceOrNull(graph, URIs.Builtin_GeometryProvider);
         Builtin_HorizontalTank = getResourceOrNull(graph, URIs.Builtin_HorizontalTank);
         Builtin_HorizontalTankGeometryProvider = getResourceOrNull(graph, URIs.Builtin_HorizontalTankGeometryProvider);
@@ -274,6 +286,8 @@ public class Plant3D {
         HasPipeDiameter_Inverse = getResourceOrNull(graph, URIs.HasPipeDiameter_Inverse);
         HasPipeRun = getResourceOrNull(graph, URIs.HasPipeRun);
         HasPrevious = getResourceOrNull(graph, URIs.HasPrevious);
+        HasRotationAngle = getResourceOrNull(graph, URIs.HasRotationAngle);
+        HasRotationAngle_Inverse = getResourceOrNull(graph, URIs.HasRotationAngle_Inverse);
         HasTurnAxis = getResourceOrNull(graph, URIs.HasTurnAxis);
         HasTurnAxis_Inverse = getResourceOrNull(graph, URIs.HasTurnAxis_Inverse);
         HasTurnRadius = getResourceOrNull(graph, URIs.HasTurnRadius);
@@ -308,6 +322,7 @@ public class Plant3D {
         PipelineComponentTag = getResourceOrNull(graph, URIs.PipelineComponentTag);
         Plant = getResourceOrNull(graph, URIs.Plant);
         PreviousInverse = getResourceOrNull(graph, URIs.PreviousInverse);
+        RotateComponent = getResourceOrNull(graph, URIs.RotateComponent);
         SingleConnectedComponent = getResourceOrNull(graph, URIs.SingleConnectedComponent);
         SizeChangeComponent = getResourceOrNull(graph, URIs.SizeChangeComponent);
         TurnComponent = getResourceOrNull(graph, URIs.TurnComponent);
index ba4cd10cd7d96a53adcfa7f4f841be2003937bf9..a3f17be39d70963c8fa3e95e895673c894d38545 100644 (file)
  <resource uri="http://www.simantics.org/Plant3D-0.1/Builtin/CheckValveGeometryProvider"
   class="org.simantics.plant3d.geometry.CheckValveGeometryProvider">
   <this />
+ </resource>
+ <resource uri="http://www.simantics.org/Plant3D-0.1/Builtin/GateValveGeometryProvider"
+  class="org.simantics.plant3d.geometry.GateValveGeometryProvider">
+  <this />
  </resource>
   <resource uri="http://www.simantics.org/Plant3D-0.1/Builtin/CapGeometryProvider"
   class="org.simantics.plant3d.geometry.CapGeometryProvider">
diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/geometry/GateValveGeometryProvider.java b/org.simantics.plant3d/src/org/simantics/plant3d/geometry/GateValveGeometryProvider.java
new file mode 100644 (file)
index 0000000..90c3936
--- /dev/null
@@ -0,0 +1,58 @@
+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 GateValveGeometryProvider extends BuiltinGeometryProvider {
+       
+       public GateValveGeometryProvider(Resource resource) {
+               super(resource);
+       }
+
+       private double radius = 0.01;
+       
+       @Override
+       public Collection<TopoDS_Shape> getModel() throws Exception {
+               
+               TopoDS_Shape con = OccTriangulator.makeCone(new double[] {-radius, 0.0, 0.0}, new double[] { 1.0, 0.0, 0.0 }, radius, radius*0.1,radius);
+               TopoDS_Shape con2 = OccTriangulator.makeCone(new double[] {radius, 0.0, 0.0}, new double[] { -1.0, 0.0, 0.0 }, radius, radius*0.1,radius);
+               //TopoDS_Shape sph = OccTriangulator.makeSphere(0, 0, 0, radius*0.75);
+               //TopoDS_Shape cyl = OccTriangulator.makeCylinder(new double[] {0.0, 0.0, 0.0}, new double[] { 0.0, 1.0, 0.0 }, radius*0.75, radius*2);
+               TopoDS_Shape cyl = OccTriangulator.makeFillet(OccTriangulator.makeBox(-radius*0.5, -radius*0.5, -radius*0.75, radius*0.5, radius*1.25, radius*0.75), radius*0.25);
+               //TopoDS_Shape cyl = OccTriangulator.makeChamfer(OccTriangulator.makeBox(-radius*0.5, -radius*0.5, -radius*0.75, radius*0.5, radius*1.25, radius*0.75), radius*0.25);
+               TopoDS_Shape cyl2 = OccTriangulator.makeCylinder(new double[] {0.0, 0.0, 0.0}, new double[] { 0.0, 1.0, 0.0 }, radius*0.125, radius*2);
+               TopoDS_Shape tor = OccTriangulator.makeTorus(new double[] { 0.0, radius*2, 0.0}, new double[] { 0.0, 1.0, 0.0 }, radius*0.5, radius*0.125);
+               
+               TopoDS_Shape shape = OccTriangulator.makeCompound(new TopoDS_Shape[] {con,con2,cyl,cyl2,tor});
+               cyl.delete();
+               con.delete();
+               con2.delete();
+               //sph.delete();
+               tor.delete();
+               return Collections.singletonList(shape);
+       }
+       
+       @Override
+       public void setProperties(Map<String, Object> props) {
+               if (props.containsKey("radius")) {
+                       radius = (Double)props.get("radius");
+               }
+               if (radius < MathTools.NEAR_ZERO)
+                       radius = MathTools.NEAR_ZERO;
+               
+       }
+       
+       @Override
+       public void updateCalculatedProperties(Map<String, Object> returnProps) {
+               returnProps.put("length", radius*2);
+               
+       }
+
+
+}
index a7c32a66aabab76a5badf9b70e95ef323ac493b1..29a6869f74334ad8b1a8ca5e69595536e2c6e595 100644 (file)
@@ -4,16 +4,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
-import org.jcae.opencascade.jni.BRepBuilderAPI_MakeEdge;
-import org.jcae.opencascade.jni.BRepBuilderAPI_MakeFace;
-import org.jcae.opencascade.jni.BRepBuilderAPI_MakeWire;
-import org.jcae.opencascade.jni.BRepPrimAPI_MakeRevol;
-import org.jcae.opencascade.jni.GC_MakeArcOfCircle;
-import org.jcae.opencascade.jni.GC_MakeSegment;
-import org.jcae.opencascade.jni.TopoDS_Edge;
-import org.jcae.opencascade.jni.TopoDS_Face;
 import org.jcae.opencascade.jni.TopoDS_Shape;
-import org.jcae.opencascade.jni.TopoDS_Wire;
 import org.simantics.db.Resource;
 import org.simantics.opencascade.OccTriangulator;
 
index a1558c8642f4f527abc13cda702c8484db441aa1..e098de63a637303a787aca53f85db0259380f845 100644 (file)
@@ -3,13 +3,19 @@ package org.simantics.plant3d.scenegraph;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.simantics.g3d.math.MathTools;
+import org.simantics.g3d.property.annotations.GetPropertyValue;
+import org.simantics.g3d.property.annotations.SetPropertyValue;
 import org.simantics.g3d.scenegraph.base.ParentNode;
 import org.simantics.objmap.graph.annotations.DynamicGraphType;
 import org.simantics.objmap.graph.annotations.GetType;
+import org.simantics.objmap.graph.annotations.RelatedGetValue;
+import org.simantics.objmap.graph.annotations.RelatedSetValue;
 import org.simantics.objmap.graph.annotations.SetType;
 import org.simantics.plant3d.ontology.Plant3D;
 import org.simantics.plant3d.scenegraph.controlpoint.ControlPointFactory;
 import org.simantics.plant3d.scenegraph.controlpoint.PipeControlPoint;
+import org.simantics.plant3d.scenegraph.controlpoint.PipingRules;
 
 @DynamicGraphType(Plant3D.URIs.InlineComponent)
 public class InlineComponent extends PipelineComponent {
@@ -45,6 +51,37 @@ public class InlineComponent extends PipelineComponent {
                return !controlPoint.isFixed();
        }
        
+       @RelatedGetValue(Plant3D.URIs.HasRotationAngle)
+       @GetPropertyValue(name="Rotation Angle", value=Plant3D.URIs.HasRotationAngle, tabId = "Default")
+       public Double getRotationAngle() {
+               if (!controlPoint.isRotate())
+                       return null;
+               Double d = controlPoint.getRotationAngle();
+               if (d == null)
+                       return 0.0;
+               return MathTools.radToDeg(d);
+       }
+       @RelatedSetValue(Plant3D.URIs.HasRotationAngle)
+       @SetPropertyValue(value=Plant3D.URIs.HasRotationAngle)
+       public void setRotationAngle(Double angle) {
+               if (!controlPoint.isRotate())
+                       return;
+               
+               if (angle == null || Double.isInfinite(angle) || Double.isNaN(angle)) {
+                       return;
+               }
+               angle = MathTools.degToRad(angle);
+               if (controlPoint.getRotationAngle() != null && Math.abs(controlPoint.getRotationAngle()-angle) < MathTools.NEAR_ZERO)
+                       return;
+               controlPoint.setRotationAngle(angle);
+               try {
+                       PipingRules.requestUpdate(getControlPoint());
+               } catch (Exception e) {
+                       // TODO Auto-generated catch block
+                       e.printStackTrace();
+               }       
+       }
+       
        @Override
        public void updateParameters() {
                super.updateParameters();
index a6d1eb26880e7faed3b609181569980d2228e89f..824f74d6741e9e07643fdc197b10b63b9d03e190 100644 (file)
@@ -45,6 +45,7 @@ public class ControlPointFactory {
                PipeControlPoint pcp = new PipeControlPoint(component);
                pcp.setType(inst.type);
                pcp.setFixed(inst.fixed);
+               pcp.setRotate(inst.isRotate);
                switch(inst.type) {
                case END:
                        
@@ -77,7 +78,7 @@ public class ControlPointFactory {
                boolean fixed;
                boolean isOffset;
                boolean isSizeChange;
-               
+               boolean isRotate;
                
        }
        
@@ -91,6 +92,7 @@ public class ControlPointFactory {
                                i.fixed = false;
                                i.isOffset = false;
                                i.isSizeChange = false;
+                               i.isRotate = false;
                                i.type = Type.INLINE;
                                if (graph.isInheritedFrom(res, p3d.Nozzle)) {
                                        i.fixed = true;
@@ -113,6 +115,9 @@ public class ControlPointFactory {
                                        if (graph.hasStatement(res,p3d.OffsetComponent)) {
                                                i.isOffset = true;
                                        }
+                                       if (graph.hasStatement(res,p3d.RotateComponent)) {
+                                               i.isRotate = true;
+                                       }
                                        
                                } else if (graph.isInheritedFrom(res, p3d.TurnComponent)) {
                                        i.type = Type.TURN;
index 21f2564d781e87b44fc1713264cf0640e002a618..b822b2f3535ebf0c85f6302e9fb53706e0902234 100644 (file)
@@ -30,6 +30,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        
        private Type type;
        private boolean fixed = true;
+       private boolean rotate = false;
        private boolean deletable = true;
        private boolean sub = false;
        
@@ -81,6 +82,16 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
                this.fixed = fixed;
        }
        
+       @GetPropertyValue(name="Rotate",tabId="Debug",value="rotate")
+       public boolean isRotate() {
+               return rotate;
+       }
+       
+       
+       public void setRotate(boolean rotate) {
+               this.rotate = rotate;
+       }
+       
        public void setSub(boolean sub) {
                this.sub = sub;
        }
index b08c04cb41a2b4cace86fd1b683e29b705a4fa7f..2644ab0f33003ba9580c6d1b26ad9b9cfb75734d 100644 (file)
@@ -36,7 +36,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);