X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2Fcontrolpoint%2FPipeControlPoint.java;h=8219c1d686d146ba60c982658ab419e07b0d375b;hb=a1e1faa6915445e786f482170576b9c9d0f5d982;hp=b3bc2e1e09b757499e2adaccb819f2f3a0b5c006;hpb=43b9a071783377f64924bb0c2f1930fb49316f6f;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index b3bc2e1e..8219c1d6 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -35,12 +35,12 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { private PipelineComponent component; private PointType type; - private boolean isFixed = true; - private boolean isRotate = false; - private boolean isReverse = false; - private boolean isDeletable = true; - private boolean isSizeChange = false; - private boolean isSub = false; + private boolean isFixed = true; // In-line: fixed-length Turn: fixed-angle + private boolean isRotate = false; // rotates around path leg axis. + private boolean isReverse = false; // definition direction can be swapped + private boolean isDeletable = true; // can be removed by rules + private boolean isSizeChange = false; // changes size of the pipe. The next control point / component is on different PipeRun + private boolean isSub = false; // child point public PipeControlPoint(PipelineComponent component) { this.component = component; @@ -85,7 +85,6 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return isFixed; } - public void setFixed(boolean fixed) { this.isFixed = fixed; } @@ -137,10 +136,20 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return type == PointType.INLINE; } + /** + * True for end components, if control point defines absolute position direction, which rules cannot modify. + * This is typical for nozzles. + * @return + */ public boolean isDirected() { return isFixed && isEnd(); } + /** + * True for end components, if control is opposite to directed, and rules can modify position and orientation. + * This is typical for caps, and other end components. + * @return + */ public boolean isNonDirected() { return !isFixed && isEnd(); } @@ -148,10 +157,35 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { public boolean isVariableLength() { return !isFixed && isInline(); } + + /** + * Fixed length in-line component is such that piping rules cannot modify the length. + * @return + */ + public boolean isFixedLength() { + return isFixed && isInline(); + } public boolean isVariableAngle() { return !isFixed && isTurn(); } + + /** + * Fixed angle turn component is such that piping rules cannot modify the angle. + * @return + */ + public boolean isFixedAngle() { + return isFixed && isTurn(); + } + + /** + * Does the turn behave like fixed angle? + * For variable angle turns, the turn angle is defined by connected components, and without them, we must handle the component as fixed angle. + * @return + */ + public boolean asFixedAngle() { + return isTurn() && (isFixed || next == null || previous == null); + } public boolean isBranchEnd() { return isDeletable && isEnd(); @@ -628,7 +662,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { public Vector3d getDirection(Direction direction) { if (isDirected()) return getDirectedControlPointDirection(); - if (isTurn() && isFixed()) { + if (isTurn() && asFixedAngle()) { if (direction == Direction.NEXT) { if (previous != null) { PipeControlPoint pcp = this; @@ -687,7 +721,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return getDirectedControlPointDirection(); } else { - if (isVariableAngle()) + if (isVariableAngle() && !asFixedAngle()) throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point " + this); if (isInline()) { PipeControlPoint pcp = this; @@ -703,7 +737,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { Vector3d v = new Vector3d(); v.sub(getWorldPosition(),previous.getWorldPosition()); return v; - } else if (isTurn() && isFixed() && !_getReversed()) { + } else if (isTurn() && asFixedAngle() && !_getReversed()) { return getDirection(Direction.NEXT); } throw new RuntimeException("Missing implementation " + this); @@ -725,7 +759,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { v.negate(); return v; } else { - if (isVariableAngle()) + if (isVariableAngle() && !asFixedAngle()) throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point " + this); if (isInline()) { PipeControlPoint pcp = this; @@ -743,7 +777,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { Vector3d v = new Vector3d(); v.sub(getWorldPosition(),next.getWorldPosition()); return v; - } else if (isTurn() && isFixed() && _getReversed()) { + } else if (isTurn() && asFixedAngle() && _getReversed()) { return getDirection(Direction.PREVIOUS); } throw new RuntimeException("Missing implementation " + this); @@ -768,7 +802,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public void getControlPointEnds(Tuple3d p1, Tuple3d p2) { - PipeControlPoint sub = isAxial() ? this : getSubPoint().get(0); + PipeControlPoint sub = isAxial() || isDirected() || isTurn() ? this : getSubPoint().get(0); Vector3d pos = getWorldPosition(), pos2 = sub == this ? pos : sub.getWorldPosition(); Vector3d dir1 = getPathLegDirection(Direction.PREVIOUS); @@ -1160,7 +1194,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { PipeRun previousRun = previous.getPipeRun(); nextPipeRun.setPipeDiameter(previousRun.getPipeDiameter()); - nextPipeRun.setTurnRadius(previousRun.getTurnRadius()); + nextPipeRun.setTurnRadiusArray(previousRun.getTurnRadiusArray()); PipelineComponent n = next.getPipelineComponent(); while (n != null) {