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=660558652c47c03c1897b7aa1a53761e6795a206;hb=refs%2Fchanges%2F31%2F3131%2F1;hp=fc78f1b97647efc3cfceb510a6bfd9010240f026;hpb=62fb6eb651ae640336d71746d7bfa79bcfa211df;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 fc78f1b9..66055865 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 @@ -7,6 +7,7 @@ import java.util.List; import javax.vecmath.AxisAngle4d; import javax.vecmath.Matrix3d; +import javax.vecmath.Point3d; import javax.vecmath.Quat4d; import javax.vecmath.Tuple3d; import javax.vecmath.Vector3d; @@ -25,13 +26,13 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { private static boolean DEBUG = false; - public enum Type{INLINE,TURN,END}; + public enum PointType{INLINE,TURN,END}; public enum Direction{NEXT,PREVIOUS}; public enum PositionType {SPLIT,NEXT,PREVIOUS,PORT} private PipelineComponent component; - private Type type; + private PointType type; private boolean fixed = true; private boolean rotate = false; private boolean reverse = false; @@ -68,11 +69,11 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { return component; } - public Type getType() { + public PointType getType() { return type; } - public void setType(Type type) { + public void setType(PointType type) { this.type = type; } @@ -118,19 +119,19 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public boolean isPathLegEnd() { - return type != Type.INLINE; + return type != PointType.INLINE; } public boolean isEnd() { - return type == Type.END; + return type == PointType.END; } public boolean isTurn() { - return type == Type.TURN; + return type == PointType.TURN; } public boolean isInline() { - return type == Type.INLINE; + return type == PointType.INLINE; } public boolean isDirected() { @@ -288,7 +289,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public void setTurnAngle(Double turnAngle) { - if (Double.isInfinite(turnAngle) || Double.isNaN(turnAngle)) { + if (turnAngle == null || Double.isInfinite(turnAngle) || Double.isNaN(turnAngle)) { return; } if (this.turnAngle != null && Math.abs(this.turnAngle-turnAngle) < MathTools.NEAR_ZERO) @@ -795,9 +796,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public double getInlineLength() { - if (type == Type.TURN) + if (type == PointType.TURN) return length; - else if (type == Type.INLINE) + else if (type == PointType.INLINE) return length * 0.5; return 0; } @@ -1013,7 +1014,19 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { if (currentNext.isVariableLength() && currentPrev.isVariableLength()) { // we have to join them into single variable length component. additionalRemove = currentPrev; - //currentPrev.remove(); + // combine lengths and set the location of remaining control point to the center. + Point3d ps = new Point3d(); + Point3d pe = new Point3d(); + Point3d ns = new Point3d(); + Point3d ne = new Point3d(); + currentPrev.getInlineControlPointEnds(ps, pe); + currentNext.getInlineControlPointEnds(ns, ne); + double l = currentPrev.getLength() + currentNext.getLength(); + Vector3d cp = new Vector3d(); + cp.add(ps, ne); + cp.scale(0.5); + currentNext.setLength(l); + currentNext.setWorldPosition(cp); } } else { // FIXME : pipe run must be split into two parts, since the control point structure is no more continuous. @@ -1176,9 +1189,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } if (br0 != null) { if (br0.getNext() == component) - prev.setNext(null); + br0.setNext(null); else if (br0.getPrevious() == component) - prev.setPrevious(null); + br0.setPrevious(null); else if (br0.getBranch0() == component) br0.setBranch0(null); }