From c44f3e6a480f19b26a586a271ac200f051c60cf2 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Thu, 17 Oct 2019 16:50:31 +0300 Subject: [PATCH] Flat nozzles gitlab #34 Change-Id: Iba887aef0a3abb9528d02c5c8a0321050700278f --- .../graph/plant3d_builtins.pgraph | 8 ++++ .../geometry/FlatNozzleGeometryProvider.java | 37 +++++++++++++++++++ .../geometry/PumpGeometryProvider.java | 4 +- .../simantics/plant3d/scenegraph/Nozzle.java | 2 +- .../plant3d/scenegraph/PipelineComponent.java | 37 +++++++++++++++++++ 5 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 org.simantics.plant3d/src/org/simantics/plant3d/geometry/FlatNozzleGeometryProvider.java diff --git a/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph b/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph index a26abde4..84e0b674 100644 --- a/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph +++ b/org.simantics.plant3d.ontology/graph/plant3d_builtins.pgraph @@ -5,6 +5,7 @@ P3D = 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 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 props) { + if (props.containsKey("radius")) { + radius = (Double)props.get("radius"); + } + + } + +} diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/geometry/PumpGeometryProvider.java b/org.simantics.plant3d/src/org/simantics/plant3d/geometry/PumpGeometryProvider.java index a34e3468..89fe4b30 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/geometry/PumpGeometryProvider.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/geometry/PumpGeometryProvider.java @@ -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))); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java index fb184068..55773f0f 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/Nozzle.java @@ -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; diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java index 3f393364..fd085db1 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -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 getParameterMap() { + return super.getParameterMap(); + } + + @Override + @CompoundRelatedSetValue(Plant3D.URIs.hasParameter) + public void setParameterMap(Map parameters) { + super.setParameterMap(parameters); + } + + @CompoundGetPropertyValue(name="Parameters",tabId="Parameters",value="parameters") + public Map getParameterMapUI() { + // TODO : how to filter parameters that are calculated by geometry provider? + Map map = new HashMap(getParameterMap()); + map.remove("radius"); + return map; + } + + @CompoundSetPropertyValue(value="parameters") + public void setParameterMapUI(Map parameters) { + Map curr = getParameterMap(); + for (Entry 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) -- 2.47.1