X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2Fcontrolpoint%2FPipeControlPoint.java;h=086bdb2b5d408de5fcc8109dba50eae6ea8ca452;hb=eb67906ff85a83b2f71b823110e5c3d12da8bfc2;hp=8219c1d686d146ba60c982658ab419e07b0d375b;hpb=a1e1faa6915445e786f482170576b9c9d0f5d982;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 8219c1d6..086bdb2b 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 @@ -240,6 +240,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { if (this.next == next) return; if (DEBUG) System.out.println(this + " next " + next); + if (next == null && isVariableAngle() && previous != null && !isRemoved()) { + convertVariableAngleToFixed(Direction.NEXT); + } this.next = next; if (component != null) { if (parent == null || isSub) @@ -248,7 +251,6 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { component.setBranch0(next != null ? next.component : null); updateSubPoint(); } - } public void setPrevious(PipeControlPoint previous) { @@ -259,6 +261,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { if (this.previous == previous) return; if (DEBUG) System.out.println(this + " previous " + previous); + if (previous == null && isVariableAngle() && next != null && !isRemoved()) { + convertVariableAngleToFixed(Direction.PREVIOUS); + } this.previous = previous; if (component != null) { if (parent == null || isSub) @@ -267,7 +272,32 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { component.setBranch0(previous != null ? previous.component : null); updateSubPoint(); } - + } + + private void convertVariableAngleToFixed(Direction direction) { + // We are removing reference, which transforms variable angle to fixed angle. + // Since fixed angle is defined differently, we need to calculate fixed angle parameters based on current data + // We need to calculate turnAngle and rotationAngle + Vector3d dirOut = getPathLegDirection(direction == Direction.NEXT ? Direction.NEXT : Direction.PREVIOUS); + Vector3d dir = getPathLegDirection(direction == Direction.NEXT ? Direction.PREVIOUS : Direction.NEXT); + dir.negate(); + dirOut.normalize(); + dir.normalize(); + double angle = dir.angle(dirOut); + //super._setNext(null); + if (direction == Direction.NEXT) + next = null; + else + previous = null; + setRotationAngle(0.0); + setReversed(direction == Direction.NEXT ? false : true); + Vector3d dirOutN = getPathLegDirection(direction == Direction.NEXT ? Direction.NEXT : Direction.PREVIOUS); + dirOutN.normalize(); + AxisAngle4d aa = new AxisAngle4d(); + if (MathTools.createRotation(dirOutN, dirOut, dir, aa)) { + setRotationAngle(aa.angle); + setTurnAngle(angle); + } } public PipeControlPoint parent; @@ -324,7 +354,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { @GetPropertyValue(name="Rotation Angle",tabId="Debug",value="rotationAngle") public Double getRotationAngle() { - return rotationAngle; + if (asFixedAngle()) + return rotationAngle; + return null; } @GetPropertyValue(name="Reversed",tabId="Debug",value="reversed") @@ -996,6 +1028,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { PipeControlPoint additionalRemove = null; if (!PipingRules.isEnabled()) { + component = null; setPrevious(null); setNext(null); } else { @@ -1311,6 +1344,10 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { private void removeParentPoint() { throw new RuntimeException("Child points cannot be removed directly"); } + + public boolean isRemoved() { + return component == null; + } private void removeComponent() { if (component == null)