view.lock();
node.visualize(view);
-
- for (vtkProp3D act : node.getActors()) {
- nodeToActor.add(node, act);
- actorToNode.put(act, node);
- }
+
+ map(node, node.getActors());
view.unlock();
private boolean hasActor(ICSGnode node) {
- List<vtkProp> list = nodeToActor.getValues(node);
+ Collection<vtkProp> list = getRenderObjects(node);
if (list == null || list.size() == 0)
return false;
return true;
if (Thread.currentThread() != view.getThreadQueue().getThread())
throw new RuntimeException("Illegal thread.");
- List<vtkProp> list = nodeToActor.getValues(node);
- if (list != null) {
- for (vtkProp obj : list) {
- actorToNode.remove(obj);
- }
- nodeToActor.remove(node);
+ Collection<vtkProp> list = getRenderObjects(node);
+ if (list.size() > 0) {
+ removeMap(node);
view.lock();
-
node.stopVisualize();
-
view.unlock();
}
}
protected IMapping<DBObject,E> mapping;
protected VtkView view;
- protected MapList<E, vtkProp> nodeToActor = new MapList<E, vtkProp>();
- protected Map<vtkProp,E> actorToNode = new HashMap<vtkProp, E>();
+ private MapList<E, vtkProp> nodeToActor = new MapList<E, vtkProp>();
+ private Map<vtkProp,E> actorToNode = new HashMap<vtkProp, E>();
protected ParentNode<E> rootNode;
e.printStackTrace();
}
}
-
-
-
+
protected abstract void addActor(E node);
protected abstract void removeActor(E node);
protected abstract void updateActor(E node,Set<String> ids);
return nodeToActor.getValues((E)node);
}
+ protected <T extends vtkProp> void map(E node, Collection<T> props) {
+ for (vtkProp p : props) {
+ nodeToActor.add(node, p);
+ actorToNode.put(p, node);
+ }
+ }
+
+ protected void removeMap(E node) {
+ Collection<vtkProp> coll = nodeToActor.getValuesUnsafe(node);
+ for (vtkProp p : coll) {
+ actorToNode.remove(p);
+ }
+ nodeToActor.remove(node);
+ }
+
@SuppressWarnings("unchecked")
@Override
public ParentNode<E> getRootNode() {
added.add(new Pair<E, String>(node, id));
rangeModified = true;
}
- view.refresh();
+ repaint();
}
@SuppressWarnings("unchecked")
/**
* When objects are removed (either from Java or Graph), after remove processing the Java objects remain in mapping cache.
- * This causes problems with Undo and Redo, whcih the end up re-using the removed objects from mapping cache.
+ * This causes problems with Undo and Redo, which cause re-using the removed objects from mapping cache.
*
* This code here synchronizes removed and added objects to collect deletable objects. (a deletable object is one which is removed but not added).
*
P3D.HasTurnAngle <R G3D.hasNonTransformation
L0.HasRange L0.Double
-//P3D.HasOffset <R L0.HasProperty
-// L0.HasRange L0.Double
-//HasRelativePosition <R HasProperty
-// HasRange [Position]
-//HasRelativeDirection <R HasProperty
-// HasRange [Tuple3]
-//HasDirection <R HasProperty
-// HasRange [Tuple3]
+
P3D.HasTurnRadius <R G3D.hasNonTransformation
- L0.HasRange L0.Double
+ L0.HasRange L0.Double
+ @L0.tag L0.Deprecated
+P3D.HasTurnRadiusArray <R G3D.hasNonTransformation
+ L0.HasRange L0.DoubleArray
+P3D.HasTurnRadiusIndex <R G3D.hasNonTransformation
+ L0.HasRange L0.Integer
P3D.IsReversed <R L0.HasProperty
L0.HasRange L0.Boolean
P3D.HasTurnAxis <R G3D.hasTransformation
L0.HasRange G3D.Tuple3D
-//P3D.HasNozzleDefinition <R L0.HasProperty
-// L0.HasDomain P3D.Equipment
-// L0.HasRange P3D.Nozzle
-// L0.HasDescription "This relation is used to connect nozzles to equipment in the template. For instantiated equipment nozzles must be connected with HasNozzle relation." : L0.String
P3D.HasNozzle <R G3D.children
L0.InverseOf P3D.NozzleOf
L0.HasDomain P3D.Equipment
L0.HasRange P3D.Nozzle
L0.HasDescription "Used to connect nozzles to equipment." : L0.String
-//P3D.HasNozzleRestriction <R L0.HasProperty
-// L0.HasDescription "Used in template equipment to restrict amount of nozzles. If template has as many nozzleDefinitions that maximum count in this restriction, user cannot add new nozzles to the equipment instance." : L0.String
P3D.HasFixedNozzles <R L0.HasProperty
L0.HasDescription "Number of fixed nozzles" : L0.String
L0.HasDomain P3D.Equipment
public final Resource HasTurnAngle_Inverse;
public final Resource HasTurnAxis;
public final Resource HasTurnAxis_Inverse;
- public final Resource HasTurnRadius;
+ @Deprecated public final Resource HasTurnRadius;
+ public final Resource HasTurnRadiusArray;
+ public final Resource HasTurnRadiusArray_Inverse;
+ public final Resource HasTurnRadiusIndex;
+ public final Resource HasTurnRadiusIndex_Inverse;
public final Resource HasTurnRadius_Inverse;
public final Resource Images;
public final Resource Images_Component;
public static final String HasTurnAngle_Inverse = "http://www.simantics.org/Plant3D-0.1/HasTurnAngle/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";
+ @Deprecated public static final String HasTurnRadius = "http://www.simantics.org/Plant3D-0.1/HasTurnRadius";
+ public static final String HasTurnRadiusArray = "http://www.simantics.org/Plant3D-0.1/HasTurnRadiusArray";
+ public static final String HasTurnRadiusArray_Inverse = "http://www.simantics.org/Plant3D-0.1/HasTurnRadiusArray/Inverse";
+ public static final String HasTurnRadiusIndex = "http://www.simantics.org/Plant3D-0.1/HasTurnRadiusIndex";
+ public static final String HasTurnRadiusIndex_Inverse = "http://www.simantics.org/Plant3D-0.1/HasTurnRadiusIndex/Inverse";
public static final String HasTurnRadius_Inverse = "http://www.simantics.org/Plant3D-0.1/HasTurnRadius/Inverse";
public static final String Images = "http://www.simantics.org/Plant3D-0.1/Images";
public static final String Images_Component = "http://www.simantics.org/Plant3D-0.1/Images/Component";
HasTurnAxis = getResourceOrNull(graph, URIs.HasTurnAxis);
HasTurnAxis_Inverse = getResourceOrNull(graph, URIs.HasTurnAxis_Inverse);
HasTurnRadius = getResourceOrNull(graph, URIs.HasTurnRadius);
+ HasTurnRadiusArray = getResourceOrNull(graph, URIs.HasTurnRadiusArray);
+ HasTurnRadiusArray_Inverse = getResourceOrNull(graph, URIs.HasTurnRadiusArray_Inverse);
+ HasTurnRadiusIndex = getResourceOrNull(graph, URIs.HasTurnRadiusIndex);
+ HasTurnRadiusIndex_Inverse = getResourceOrNull(graph, URIs.HasTurnRadiusIndex_Inverse);
HasTurnRadius_Inverse = getResourceOrNull(graph, URIs.HasTurnRadius_Inverse);
Images = getResourceOrNull(graph, URIs.Images);
Images_Component = getResourceOrNull(graph, URIs.Images_Component);
if (ids.contains(id)) {
node.visualize(view);
updateRenderObjectsFor(node);
- updateTransform(node);
+ //updateTransform(node);
break;
}
}
for (PipeControlPoint pcp : run.getControlPoints()) {
updateActor(pcp, ids2);
}
- }
+ }
if (ids.contains(G3D.URIs.hasPosition) ||
ids.contains(G3D.URIs.hasOrientation) ||
ids.contains(G3D.URIs.hasWorldOrientation)) {
updateTransform(node);
}
+ if (ids.contains(Plant3D.URIs.HasTurnRadiusIndex)) {
+ node.visualize(view);
+ updateRenderObjectsFor(node);
+ }
}
private void updateTransform(IP3DNode node) {
node.visualize(view);
- for (vtkProp3D act : node.getActors()) {
- nodeToActor.add(node, act);
- actorToNode.put(act, node);
- }
+ map(node, node.getActors());
+
if (DEBUG) System.out.println("Added " + node.getActors().size() + " actors");
if (node instanceof P3DParentNode<?>) {
private boolean hasActor(IP3DVisualNode node) {
- List<vtkProp> list = nodeToActor.getValues(node);
+ Collection<vtkProp> list = getRenderObjects(node);
if (list == null || list.size() == 0)
return false;
return true;
if (Thread.currentThread() != view.getThreadQueue().getThread())
throw new RuntimeException("Illegal thread.");
- List<vtkProp> list = nodeToActor.getValues(node);
- if (list != null) {
- for (vtkProp obj : list) {
- actorToNode.remove(obj);
- }
- nodeToActor.remove(node);
- view.lock();
-
- node.stopVisualize();
-
- view.unlock();
+ Collection<vtkProp> list = getRenderObjects(node);
+ if (list.size() > 0) {
+ removeMap(node);
+ view.lock();
+ node.stopVisualize();
+ view.unlock();
}
}
Object newValue = parameters.get(id);
if (currentValue == newValue)
continue;
+ if (newValue == null) {
+ continue;
+ }
if (currentValue instanceof Double) {
if (Math.abs((Double)currentValue-(Double)newValue) < MathTools.NEAR_ZERO)
continue;
public class PipeRun extends P3DParentNode<IP3DNode> {
private double pipeDiameter = 0.1;
- private double turnRadius = 0.2;
+ private double[] turnRadius = new double[] {0.2};
@Override
public void update(vtkRenderer ren) {
@RelatedGetValue(Plant3D.URIs.HasTurnRadius)
@GetPropertyValue(value=Plant3D.URIs.HasTurnRadius, name = "Elbow radius")
public double getTurnRadius() {
- return turnRadius;
+ return turnRadius[0];
}
@RelatedSetValue(Plant3D.URIs.HasTurnRadius)
@SetPropertyValue(Plant3D.URIs.HasTurnRadius)
public void setTurnRadius(double turnRadius) {
- this.turnRadius = turnRadius;
+ this.turnRadius[0] = turnRadius;
firePropertyChanged(Plant3D.URIs.HasTurnRadius);
- }
+ firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray);
+ }
+
+ @RelatedGetValue(Plant3D.URIs.HasTurnRadiusArray)
+ @GetPropertyValue(value=Plant3D.URIs.HasTurnRadiusArray, name = "Elbow radius array")
+ public double[] getTurnRadiusArray() {
+ return turnRadius;
+ }
+
+ @RelatedSetValue(Plant3D.URIs.HasTurnRadiusArray)
+ @SetPropertyValue(Plant3D.URIs.HasTurnRadiusArray)
+ public void setTurnRadiusArray(double[] turnRadiusArray) {
+ if (turnRadiusArray == null || turnRadiusArray.length == 0)
+ return;
+ this.turnRadius = turnRadiusArray;
+ firePropertyChanged(Plant3D.URIs.HasTurnRadiusArray);
+ }
@RelatedGetValue(Plant3D.URIs.HasPipeDiameter)
@GetPropertyValue(value=Plant3D.URIs.HasPipeDiameter, name = "Diameter")
public boolean equalSpecs(PipeRun other) {
if (!MathTools.equals(pipeDiameter,other.pipeDiameter))
return false;
- if (!MathTools.equals(turnRadius,other.turnRadius))
- return false;
+ if (turnRadius.length != other.turnRadius.length)
+ return false;
+ for (int i = 0; i < turnRadius.length; i++) {
+ if (!MathTools.equals(turnRadius[i],other.turnRadius[i]))
+ return false;
+ }
return true;
}
super.setOrientation(orientation);
if (getControlPoint() != null) {
getControlPoint()._setWorldOrientation(getWorldOrientation());
- try {
- PipingRules.requestUpdate(getControlPoint());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ PipingRules.requestUpdate(getControlPoint());
}
}
super.setPosition(position);
if (getControlPoint() != null) {
getControlPoint()._setWorldPosition(getWorldPosition());
- try {
- PipingRules.requestUpdate(getControlPoint());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ PipingRules.requestUpdate(getControlPoint());
}
}
case END:
return null;
case TURN: {
- double r = getPipeRun().getTurnRadius();
+ double r = ((TurnComponent)this).getTurnRadius();
double a = pcp.getTurnAngle();
return a*r;
}
}
}
+ /**
+ * Returns diameter of the pipe
+ * @return
+ */
+ public Double getDiameter() {
+ return getPipeRun().getPipeDiameter();
+ }
+
+ /**
+ * Returns secondary diameter of the pipe for size change components
+ * @return
+ */
+ public Double getDiameter2() {
+ if (getAlternativePipeRun() == null)
+ return null;
+ return getAlternativePipeRun().getPipeDiameter();
+ }
+
public void getEnds(Tuple3d p1, Tuple3d p2) {
getControlPoint().getControlPointEnds(p1, p2);
}
case TURN: {
Vector3d loc = pcp.getRealPosition(PositionType.PREVIOUS);
- double r = getPipeRun().getTurnRadius();
+ double r = ((TurnComponent)this).getTurnRadius();
double a = pcp.getTurnAngle();
double pipeRadius = pcp.getPipeRun().getPipeDiameter() / 2;
double r2 = getAlternativePipeRun().getPipeDiameter() / 2;
return pcp.getLength() * Math.PI * (r1*r1 + r1*r2 + r2*r2) / 4;
case TURN: {
- double r = getPipeRun().getTurnRadius();
+ double r = ((TurnComponent)this).getTurnRadius();
double a = pcp.getTurnAngle();
return r * a * Math.PI * pipeRadius * pipeRadius;
}
private String type;
private PipeControlPoint controlPoint;
+ private Integer turnRadiusIndex;
@GetType(Plant3D.URIs.TurnComponent)
public String getType() {
public Map<String, Object> updateParameterMap() {
Map<String,Object> map = new HashMap<String, Object>();
- PipeRun pipeRun = getPipeRun();
- if (pipeRun != null) {
- map.put("turnRadius", pipeRun.getTurnRadius());
- map.put("radius", pipeRun.getPipeDiameter() * 0.5);
+ if (getPipeRun() != null) {
+ map.put("turnRadius", getTurnRadius());
+ map.put("radius", getDiameter() * 0.5);
}
if (controlPoint != null && controlPoint.getTurnAngle() != null && !Double.isNaN(controlPoint.getTurnAngle())) {
map.put("turnAngle", controlPoint.getTurnAngle());
return getControlPoint().getTurnAxis();
}
+ @GetPropertyValue(name="Turn Radius", value=Plant3D.URIs.HasTurnRadius, tabId = "Default")
+ public Double getTurnRadius() {
+ if (turnRadiusIndex != null)
+ return getPipeRun().getTurnRadiusArray()[turnRadiusIndex];
+ return getPipeRun().getTurnRadiusArray()[0];
+ }
+
+ @RelatedGetValue(Plant3D.URIs.HasTurnRadiusIndex)
+ @GetPropertyValue(name="Turn Radius Index", value=Plant3D.URIs.HasTurnRadiusIndex, tabId = "Default")
+ public Integer getTurnRadiusIndex()
+ {
+ // TODO: For backwards compatibility, we do not accept null values.
+ // One development path would allow null index, and setting custom turn radius for the component.
+ if (turnRadiusIndex == null)
+ return 0;
+ return turnRadiusIndex;
+ }
+
+ @RelatedSetValue(Plant3D.URIs.HasTurnRadiusIndex)
+ @SetPropertyValue(value=Plant3D.URIs.HasTurnRadiusIndex)
+ public void setTurnRadiusIndex(Integer turnRadiusIndex) {
+ if (this.turnRadiusIndex == turnRadiusIndex)
+ return;
+ if (turnRadiusIndex == null)
+ return;
+ if (turnRadiusIndex != null) {
+ if (getPipeRun().getTurnRadiusArray().length <= turnRadiusIndex)
+ return;
+ }
+ this.turnRadiusIndex = turnRadiusIndex;
+ firePropertyChanged(Plant3D.URIs.HasTurnRadiusIndex);
+ PipingRules.requestUpdate(getControlPoint());
+ }
+
@RelatedGetValue(Plant3D.URIs.HasRotationAngle)
@GetPropertyValue(name="Rotation Angle", value=Plant3D.URIs.HasRotationAngle, tabId = "Default")
public Double getRotationAngle() {
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();
- }
+ PipingRules.requestUpdate(getControlPoint());
}
@RelatedGetValue(Plant3D.URIs.IsReversed)
return d;
}
@RelatedSetValue(Plant3D.URIs.IsReversed)
- //@SetPropertyValue(value=Plant3D.URIs.IsReversed)
public void setReversed(Boolean reverse) {
if (!controlPoint.isFixed())
return;
return;
}
controlPoint.setReversed(reverse);
- try {
- PipingRules.requestUpdate(getControlPoint());
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ PipingRules.requestUpdate(getControlPoint());
}
@Override
PipeRun previousRun = previous.getPipeRun();
nextPipeRun.setPipeDiameter(previousRun.getPipeDiameter());
- nextPipeRun.setTurnRadius(previousRun.getTurnRadius());
+ nextPipeRun.setTurnRadiusArray(previousRun.getTurnRadiusArray());
PipelineComponent n = next.getPipelineComponent();
while (n != null) {
// TODO : this returns now space for 90 deg turn.
// The challenge: position of tcp affects the turn angle, which then affects the required space. Perhaps we need to iterate...
// Additionally, if the path legs contain offset, using just positions of opposite path leg ends is not enough,
- return tcp.getPipeRun().getTurnRadius();
+ return ((TurnComponent)tcp.getPipelineComponent()).getTurnRadius();
}
private static void insertElbowUpdate(UpdateStruct2 u, PipeControlPoint dcp, PipeControlPoint next, boolean dcpStart, Vector3d position, Vector3d directedDirection) throws Exception{
Vector3d turnAxis = new Vector3d();
turnAxis.cross(prev, next);
if (turnAxis.lengthSquared() > MathTools.NEAR_ZERO) {
- double elbowRadius = tcp.getPipelineComponent().getPipeRun().getTurnRadius();
+ double elbowRadius = ((TurnComponent)tcp.getPipelineComponent()).getTurnRadius();
double R = elbowRadius / Math.tan(angle * 0.5);
turnAxis.normalize();