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=fc78f1b97647efc3cfceb510a6bfd9010240f026;hb=b8221b6f5e0b6ced872c0b760d796a4c205476af;hp=22c58ddb160be1a1f43303b34e63d1dd3614bc17;hpb=923dc84d6d22c7b80039dd4e07bec088ab78ea33;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 22c58ddb..fc78f1b9 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 @@ -22,6 +22,8 @@ import vtk.vtkRenderer; public class PipeControlPoint extends G3DNode implements IP3DNode { + + private static boolean DEBUG = false; public enum Type{INLINE,TURN,END}; public enum Direction{NEXT,PREVIOUS}; @@ -186,8 +188,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { public void setNext(PipeControlPoint next) { if (isEnd() && previous != null && next != null) throw new RuntimeException("End control points are allowed to have only one connection"); -// if (next != null && getPipeRun() == null) -// throw new RuntimeException("Cannot connect control point befor piperun has been set"); + if (this.next == next) + return; + if (DEBUG) System.out.println(this + " next " + next); this.next = next; if (component != null) { if (parent == null || sub) @@ -202,8 +205,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { public void setPrevious(PipeControlPoint previous) { if (isEnd() && next != null && previous != null) throw new RuntimeException("End control points are allowed to have only one connection"); -// if (previous != null && getPipeRun() == null) -// throw new RuntimeException("Cannot connect control point befor piperun has been set"); + if (this.previous == previous) + return; + if (DEBUG) System.out.println(this + " previous " + previous); this.previous = previous; if (component != null) { if (parent == null || sub) @@ -225,14 +229,8 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { public PipeControlPoint getParentPoint() { return parent; } - - - - - - private double length; private Double turnAngle; private Vector3d turnAxis; @@ -300,7 +298,9 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { } public void setTurnAxis(Vector3d turnAxis) { - this.turnAxis = turnAxis; + if (this.turnAxis != null && MathTools.equals(turnAxis, this.turnAxis)) + return; + this.turnAxis = turnAxis; firePropertyChanged("turnAxis"); } @@ -483,6 +483,8 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { dir.sub(pcp.getWorldPosition(),previous.getWorldPosition()); if (dir.lengthSquared() > MathTools.NEAR_ZERO) dir.normalize(); + else + return null; Quat4d q = getControlPointOrientationQuat(dir, pcp.getRotationAngle() != null ? pcp.getRotationAngle() : 0.0); AxisAngle4d aa = new AxisAngle4d(MathTools.Y_AXIS,pcp.getTurnAngle() == null ? 0.0 : pcp.getTurnAngle()); Quat4d q2 = MathTools.getQuat(aa); @@ -499,6 +501,8 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { dir.sub(next.getWorldPosition(),pcp.getWorldPosition()); if (dir.lengthSquared() > MathTools.NEAR_ZERO) dir.normalize(); + else + return null; Quat4d q = getControlPointOrientationQuat(dir, pcp.getRotationAngle() != null ? pcp.getRotationAngle() : 0.0); AxisAngle4d aa = new AxisAngle4d(MathTools.Y_AXIS,pcp.getTurnAngle() == null ? 0.0 : pcp.getTurnAngle()); Quat4d q2 = MathTools.getQuat(aa); @@ -1149,18 +1153,34 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { if (component == null) return; PipelineComponent next = component.getNext(); - PipelineComponent prev = component.getNext(); + PipelineComponent prev = component.getPrevious(); + PipelineComponent br0 = component.getBranch0(); + component.setNext(null); + component.setPrevious(null); + component.setBranch0(null); if (next != null) { if (next.getNext() == component) next.setNext(null); else if (next.getPrevious() == component) next.setPrevious(null); + else if (next.getBranch0() == component) + next.setBranch0(null); } if (prev != null) { if (prev.getNext() == component) prev.setNext(null); else if (prev.getPrevious() == component) prev.setPrevious(null); + else if (prev.getBranch0() == component) + prev.setBranch0(null); + } + if (br0 != null) { + if (br0.getNext() == component) + prev.setNext(null); + else if (br0.getPrevious() == component) + prev.setPrevious(null); + else if (br0.getBranch0() == component) + br0.setBranch0(null); } PipelineComponent comp = component; component = null;