1 package org.simantics.plant3d.scenegraph.controlpoint;
3 import java.util.ArrayList;
4 import java.util.Collection;
7 import javax.vecmath.AxisAngle4d;
8 import javax.vecmath.Matrix3d;
9 import javax.vecmath.Quat4d;
10 import javax.vecmath.Tuple3d;
11 import javax.vecmath.Vector3d;
13 import org.simantics.g3d.math.MathTools;
14 import org.simantics.g3d.property.annotations.GetPropertyValue;
15 import org.simantics.g3d.scenegraph.G3DNode;
16 import org.simantics.plant3d.scenegraph.IP3DNode;
17 import org.simantics.plant3d.scenegraph.PipeRun;
18 import org.simantics.plant3d.scenegraph.PipelineComponent;
20 import vtk.vtkRenderer;
23 public class PipeControlPoint extends G3DNode implements IP3DNode {
25 public enum Type{INLINE,TURN,END};
26 public enum Direction{NEXT,PREVIOUS};
27 public enum PositionType {SPLIT,NEXT,PREVIOUS,PORT}
29 private PipelineComponent component;
32 private boolean fixed = true;
33 private boolean rotate = false;
34 private boolean deletable = true;
35 private boolean sub = false;
37 public PipeControlPoint(PipelineComponent component) {
38 this.component = component;
39 if (component.getPipeRun() != null)
40 component.getPipeRun().addChild(this);
44 public PipeControlPoint(PipelineComponent component, PipeRun piperun) {
45 this.component = component;
46 piperun.addChild(this);
50 public void update(vtkRenderer ren) {
52 PipingRules.requestUpdate(this);
53 } catch (Exception e) {
59 public PipeRun getPipeRun() {
60 return (PipeRun)getParent();
63 public PipelineComponent getPipelineComponent() {
67 public Type getType() {
71 public void setType(Type type) {
75 @GetPropertyValue(name="Fixed",tabId="Debug",value="fixed")
76 public boolean isFixed() {
81 public void setFixed(boolean fixed) {
85 @GetPropertyValue(name="Rotate",tabId="Debug",value="rotate")
86 public boolean isRotate() {
91 public void setRotate(boolean rotate) {
95 public void setSub(boolean sub) {
99 @GetPropertyValue(name="Deletable",tabId="Debug",value="deletable")
100 public boolean isDeletable() {
104 public void setDeletable(boolean deletable) {
105 this.deletable = deletable;
108 public boolean isPathLegEnd() {
109 return type != Type.INLINE;
112 public boolean isEnd() {
113 return type == Type.END;
116 public boolean isTurn() {
117 return type == Type.TURN;
120 public boolean isInline() {
121 return type == Type.INLINE;
124 public boolean isDirected() {
125 return fixed && isEnd();
128 public boolean isNonDirected() {
129 return !fixed && isEnd();
132 public boolean isVariableLength() {
133 return !fixed && isInline();
136 public boolean isVariableAngle() {
137 return !fixed && isTurn();
140 public boolean isBranchEnd() {
141 return deletable && isEnd();
144 public boolean isOffset() {
145 return offset != null;
148 public boolean isDualSub() {
149 return parent != null && sub;
152 public boolean isDualInline() {
153 return children.size() == 1 && children.get(0).isDualSub();
156 public boolean isSizeChange() {
157 if (children.size() == 0)
161 return getPipeRun() != children.get(0).getPipeRun();
165 private PipeControlPoint next;
166 private PipeControlPoint previous;
168 public PipeControlPoint getNext() {
172 public PipeControlPoint getPrevious() {
176 public void setNext(PipeControlPoint next) {
177 if (isEnd() && previous != null && next != null)
178 throw new RuntimeException("End control points are allowed to have only one connection");
179 // if (next != null && getPipeRun() == null)
180 // throw new RuntimeException("Cannot connect control point befor piperun has been set");
182 if (component != null) {
183 if (parent == null || sub)
184 component.setNext(next != null ? next.component : null);
186 component.setBranch0(next != null ? next.component : null);
192 public void setPrevious(PipeControlPoint previous) {
193 if (isEnd() && next != null && previous != null)
194 throw new RuntimeException("End control points are allowed to have only one connection");
195 // if (previous != null && getPipeRun() == null)
196 // throw new RuntimeException("Cannot connect control point befor piperun has been set");
197 this.previous = previous;
198 if (component != null) {
199 if (parent == null || sub)
200 component.setPrevious(previous != null ? previous.component : null);
202 component.setBranch0(previous != null ? previous.component : null);
208 public PipeControlPoint parent;
209 public List<PipeControlPoint> children = new ArrayList<PipeControlPoint>();
211 public List<PipeControlPoint> getSubPoint() {
215 public PipeControlPoint getParentPoint() {
226 private double length;
227 private Double turnAngle;
228 private Vector3d turnAxis;
230 private Double offset;
231 private Double rotationAngle;
233 @GetPropertyValue(name="Length",tabId="Debug",value="length")
234 public double getLength() {
238 public void setLength(double l) {
239 if (Double.isInfinite(l) || Double.isNaN(l)) {
242 if (Math.abs(this.length-l) < MathTools.NEAR_ZERO)
245 firePropertyChanged("length");
247 getSubPoint().get(0).setLength(l);
250 @GetPropertyValue(name="Turn Angle",tabId="Debug",value="turnAngle")
251 public Double getTurnAngle() {
255 @GetPropertyValue(name="Turn Axis",tabId="Debug",value="turnAxis")
256 public Vector3d getTurnAxis() {
260 @GetPropertyValue(name="Offset",tabId="Debug",value="offset")
261 public Double getOffset() {
265 @GetPropertyValue(name="Rotation Angle",tabId="Debug",value="rotationAngle")
266 public Double getRotationAngle() {
267 return rotationAngle;
270 public void setTurnAngle(Double turnAngle) {
271 if (Double.isInfinite(turnAngle) || Double.isNaN(turnAngle)) {
274 if (this.turnAngle != null && Math.abs(this.turnAngle-turnAngle) < MathTools.NEAR_ZERO)
276 this.turnAngle = turnAngle;
277 firePropertyChanged("turnAngle");
280 public void setTurnAxis(Vector3d turnAxis) {
281 this.turnAxis = turnAxis;
282 firePropertyChanged("turnAxis");
285 public void setOffset(Double offset) {
286 if (Double.isInfinite(offset) || Double.isNaN(offset)) {
289 if (this.offset != null && Math.abs(this.offset-offset) < MathTools.NEAR_ZERO)
291 this.offset = offset;
292 firePropertyChanged("offset");
295 public void setRotationAngle(Double rotationAngle) {
296 if (Double.isInfinite(rotationAngle) || Double.isNaN(rotationAngle)) {
299 if (this.rotationAngle != null && Math.abs(this.rotationAngle-rotationAngle) < MathTools.NEAR_ZERO)
301 this.rotationAngle = rotationAngle;
302 firePropertyChanged("rotationAngle");
305 public Vector3d getSizeChangeOffsetVector(Vector3d dir) {
306 if (rotationAngle == null)
308 Quat4d q = getControlPointOrientationQuat(dir, rotationAngle);
309 Vector3d v = new Vector3d(0.0,offset,0.0);
310 Vector3d offset = new Vector3d();
311 MathTools.rotate(q, v, offset);
315 public Vector3d getSizeChangeOffsetVector() {
316 if (rotationAngle == null)
318 Quat4d q = getControlPointOrientationQuat(rotationAngle);
319 Vector3d v = new Vector3d(0.0,offset,0.0);
320 Vector3d offset = new Vector3d();
321 MathTools.rotate(q, v, offset);
325 @GetPropertyValue(name="Next",tabId="Debug",value="next")
326 private String getNextString() {
329 return next.toString();
332 @GetPropertyValue(name="Previous",tabId="Debug",value="previous")
333 private String getPrevString() {
334 if (previous == null)
336 return previous.toString();
339 public Quat4d getControlPointOrientationQuat(double angle) {
341 if (turnAxis == null) {
342 Vector3d dir = getPathLegDirection(Direction.NEXT);
343 if (dir.lengthSquared() > MathTools.NEAR_ZERO)
345 return getControlPointOrientationQuat(dir, angle);
347 Vector3d dir = getPathLegDirection(Direction.PREVIOUS);
349 if (dir.lengthSquared() > MathTools.NEAR_ZERO)
351 return getControlPointOrientationQuat(dir, turnAxis, angle);
357 public static Quat4d getControlPointOrientationQuat(Vector3d dir, double angle) {
358 if (dir.lengthSquared() < MathTools.NEAR_ZERO)
359 return MathTools.getIdentityQuat();
362 Vector3d up = new Vector3d(0.0, 1.0, 0.0);
363 double a = up.angle(dir);
364 if (a < 0.1 || (Math.PI - a) < 0.1) {
365 up.set(1.0, 0.0, 0.0);
369 return getControlPointOrientationQuat(dir, up, angle);
372 public static Quat4d getControlPointOrientationQuat(Vector3d dir, Vector3d up, double angle) {
373 if (dir.lengthSquared() < MathTools.NEAR_ZERO)
374 return MathTools.getIdentityQuat();
376 final Vector3d front = new Vector3d(1.0,0.0,0.0);
378 Quat4d q1 = new Quat4d();
381 Vector3d right = new Vector3d();
383 right.cross(dir, up);
384 up.cross(right, dir);
388 Matrix3d m = new Matrix3d();
399 //q1.set(m); MathTools contains more stable conversion
400 MathTools.getQuat(m, q1);
402 // if (DEBUG) System.out.println("PipingTools.getPipeComponentOrientationQuat() " + dir+ " " + up + " " + right);
404 Quat4d q2 = new Quat4d();
405 q2.set(new AxisAngle4d(front, angle));
410 public Vector3d getDirection() {
411 return getDirectedControlPointDirection();
420 public void insert(PipeControlPoint previous, PipeControlPoint next) {
421 // inserting an offsetpoint is error,
423 throw new RuntimeException();
424 // size change control point cannot be inserted this way, because it ends PipeRun
426 throw new RuntimeException();
427 PipeRun piperun = previous.getPipeRun();
428 // and just to make sure that control point structure is not corrupted
429 if (getPipeRun() != null) {
430 if (piperun != getPipeRun() || piperun != next.getPipeRun())
431 throw new RuntimeException();
433 piperun.addChild(this);
436 // insert new BranchControlPoint between straight's control points
437 PipeControlPoint previousNext = previous.getNext();
438 PipeControlPoint previousPrevious = previous.getPrevious();
440 PipeControlPoint offsetCP = null;
442 offsetCP = getSubPoint().get(0);
444 if (previousNext != null && previousNext == next) {
445 if (previous.isDualInline()) {
446 throw new RuntimeException();
448 if (next.isDualSub()) {
449 throw new RuntimeException();
451 previous.setNext(this);
452 this.setPrevious(previous);
453 if (previous.isDualSub()) {
454 previous.getParentPoint().setNext(this);
458 if (offsetCP == null) {
459 next.setPrevious(this);
461 next.setPrevious(offsetCP);
462 offsetCP.setNext(next);
463 offsetCP.setPrevious(previous);
466 if (next.isDualInline()) {
467 next.getSubPoint().get(0).setPrevious(this);
469 } else if (previousPrevious != null && previousPrevious == next) {
470 // control point were given in reverse order
471 if (next.isDualInline())
472 throw new RuntimeException();
473 if (previous.isDualSub())
474 throw new RuntimeException();
476 this.setNext(previous);
477 if (offsetCP == null) {
478 previous.setNext(this);
480 previous.setPrevious(offsetCP);
481 offsetCP.setNext(previous);
482 offsetCP.setPrevious(next);
484 if (previous.isDualInline()) {
485 previous.getSubPoint().get(0).setPrevious(this);
487 this.setPrevious(next);
489 if (next.isDualSub()) {
490 next.getParentPoint().setNext(this);
494 throw new RuntimeException();
497 PipingRules.validate(piperun);
502 public void insert(PipeControlPoint pcp, Direction direction) {
504 throw new RuntimeException();
505 if (direction == Direction.NEXT) {
506 // if direction is next, user must have given OffsetPoint
507 if (pcp.isDualInline())
508 throw new RuntimeException();
509 // basic next/prev links
511 this.setPrevious(pcp);
512 // and last take care of sizechange / offset points
513 if (pcp.isDualSub()) {
514 pcp.getParentPoint().setNext(this);
516 if (isDualInline()) {
517 getSubPoint().get(0).setPrevious(this);
520 // if direction is previous, user must have given sizechange
522 throw new RuntimeException();
523 // previous direction is more complicated, since if newCP is SizeChangeControlPoint,
524 // we must link pcp to newCP's OffsetPoint
525 PipeControlPoint nocp = null;
526 if (isDualInline()) {
527 nocp = getSubPoint().get(0);
531 pcp.setPrevious(this);
533 pcp.setPrevious(nocp);
536 if (pcp.isDualInline()) {
537 PipeControlPoint ocp = pcp.getSubPoint().get(0);
539 ocp.setPrevious(this);
541 ocp.setPrevious(nocp);
545 PipingRules.validate(getPipeRun());
548 public Vector3d getDirectedControlPointDirection() {
549 assert (isDirected());
550 Vector3d dir = new Vector3d();
551 MathTools.rotate(getWorldOrientation(), new Vector3d(1.0, 0.0, 0.0), dir);
556 public Vector3d getPathLegDirection(Direction direction) {
557 if (direction == Direction.NEXT) {
559 PipeControlPoint pcp = this;
560 if (pcp.isDualInline()) {
561 pcp = pcp.getSubPoint().get(0);
563 Vector3d v = new Vector3d();
564 v.sub(next.getWorldPosition(),pcp.getWorldPosition());
567 if (isVariableAngle())
568 throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point");
569 if (previous == null) {
571 throw new RuntimeException("Cannot calculate path leg direction for unconnected control point");
572 return getDirectedControlPointDirection();
576 PipeControlPoint pcp = this;
577 if (pcp.isDualSub()) {
578 pcp = pcp.getParentPoint();
580 Vector3d v = new Vector3d();
581 v.sub(pcp.getWorldPosition(),previous.getWorldPosition());
583 } else if (isDirected()) {
584 return getDirectedControlPointDirection();
585 } else if (isEnd()) {
586 Vector3d v = new Vector3d();
587 v.sub(getWorldPosition(),previous.getWorldPosition());
590 throw new RuntimeException("Missing implementation");
594 if (previous != null) {
595 PipeControlPoint pcp = this;
597 pcp = getParentPoint();
598 Vector3d v = new Vector3d();
599 v.sub(previous.getWorldPosition(),pcp.getWorldPosition());
602 if (isVariableAngle())
603 throw new RuntimeException("Cannot calculate path leg direction for unconnected variable angle control point");
606 throw new RuntimeException("Cannot calculate path leg direction for unconnected control point");
607 Vector3d v = getDirectedControlPointDirection();
612 PipeControlPoint pcp = this;
613 if (pcp.isDualInline()) {
614 pcp = pcp.getSubPoint().get(0);
616 Vector3d v = new Vector3d();
617 v.sub(pcp.getWorldPosition(),next.getWorldPosition());
619 } else if (isDirected()) {
620 Vector3d v = getDirectedControlPointDirection();
623 } else if (isEnd()) {
624 Vector3d v = new Vector3d();
625 v.sub(getWorldPosition(),next.getWorldPosition());
628 throw new RuntimeException("Missing implementation");
634 public void getInlineControlPointEnds(Tuple3d p1, Tuple3d p2) {
637 Vector3d pos = getWorldPosition();
638 Vector3d dir = getPathLegDirection(Direction.NEXT);
640 dir.scale(length * 0.5);
647 public void getControlPointEnds(Tuple3d p1, Tuple3d p2) {
648 Vector3d pos = getWorldPosition();
649 Vector3d dir1 = getPathLegDirection(Direction.PREVIOUS);
651 Vector3d dir2 = getPathLegDirection(Direction.NEXT);
654 dir1.scale(length * 0.5);
655 dir2.scale(length * 0.5);
666 public void getInlineControlPointEnds(Tuple3d p1, Tuple3d p2, Vector3d dir) {
669 Vector3d pos = getWorldPosition();
670 dir.set(getPathLegDirection(Direction.NEXT));
672 dir.scale(length * 0.5);
679 public void getInlineControlPointEnds(Tuple3d center, Tuple3d p1, Tuple3d p2, Vector3d dir) {
682 Vector3d pos = getWorldPosition();
684 dir.set(getPathLegDirection(Direction.NEXT));
686 dir.scale(length * 0.5);
693 public double getInlineLength() {
694 if (type == Type.TURN)
696 else if (type == Type.INLINE)
701 public Vector3d getRealPosition(PositionType type) {
702 Vector3d pos = getWorldPosition();
705 Vector3d dir = getPathLegDirection(Direction.NEXT);
706 double length = getInlineLength();
713 Vector3d dir = getPathLegDirection(Direction.PREVIOUS);
714 double length = getInlineLength();
721 // IEntity portDir = pcp.getSingleRelatedObject(ProcessResource.plant3Dresource.HasDirection);
722 // TODO : how we calculated needed space for a port; does it has an offset from control point's position or not?
732 public void getInlineMovement(Tuple3d start, Tuple3d end) {
733 // FIXME : check type of neighbor components and allow movement on top of variable length components,
734 // find proper range for movement (pcp's position is not)
735 PipeControlPoint p = previous.getPrevious();
736 PipeControlPoint n = next.getNext();
737 start.set(p.getWorldPosition());
738 end.set(n.getWorldPosition());
741 public PipeControlPoint findNextEnd() {
742 ArrayList<PipeControlPoint> t = new ArrayList<PipeControlPoint>();
743 return findNextEnd( t);
746 public PipeControlPoint findPreviousEnd() {
747 ArrayList<PipeControlPoint> t = new ArrayList<PipeControlPoint>();
748 return findPreviousEnd(t);
751 public PipeControlPoint findNextEnd(List<PipeControlPoint> nextList) {
753 PipeControlPoint pcp = null;
754 PipeControlPoint p = null;
755 if (nextList.size() == 0)
759 p = nextList.get(nextList.size() - 1);
764 if (nextList.size() > 0)
765 nextList.remove(nextList.size() - 1);
766 // if (DEBUG) System.out.println(" " + pcp.getResource() + " not full");
770 if (pcp.isPathLegEnd()) {
771 //if (DEBUG) System.out.println(" " + pcp.getResource());
775 // if (DEBUG) System.out.print(" " + pcp.getResource());
780 public PipeControlPoint findPreviousEnd(List<PipeControlPoint> prevList) {
782 PipeControlPoint pcp = null;
783 PipeControlPoint p = null;
784 if (prevList.size() == 0)
788 p = prevList.get(prevList.size() - 1);
790 pcp = p.getPrevious();
793 if (prevList.size() > 0)
794 prevList.remove(prevList.size() - 1);
795 // if (DEBUG) System.out.println(" " + pcp.getResource() + " not full");
798 if (pcp.isPathLegEnd()) {
799 // if (DEBUG) System.out.println(" " + pcp.getResource());
803 // if (DEBUG)System.out.print(" " + pcp.getResource());
808 public void _remove() {
809 if (component == null && next == null && previous == null)
811 if (isDualInline() || isDualSub()) {
815 PipeRun pipeRun = getPipeRun();
819 PipeControlPoint additionalRemove = null;
820 if (!PipingRules.isEnabled()) {
825 PipeControlPoint currentPrev = previous;
826 PipeControlPoint currentNext = next;
827 if (currentNext == null && currentPrev == null) {
829 pipeRun.remChild(this);
832 if (currentNext != null && currentPrev != null) {
834 if (currentNext.isBranchEnd()) {
836 // currentNext.setPrevious(null);
837 // currentNext.setNext(null);
838 currentNext.remove();
842 if (currentPrev.isBranchEnd()) {
844 // currentPrev.setPrevious(null);
845 // currentPrev.setNext(null);
846 currentPrev.remove();
850 if (link && currentPrev.isDirected() && currentNext.isDirected()) {
853 if (currentNext == null) {
855 } else if (currentNext.isDualInline()) {
856 PipeControlPoint sccp = currentNext;
857 PipeControlPoint ocp = sccp.getSubPoint().get(0);
859 throw new RuntimeException("Removing PipeControlPoint " + this+ " structure damaged, no offset control point");
862 sccp.setPrevious(currentPrev);
863 ocp.setPrevious(currentPrev);
865 sccp.setPrevious(null);
866 ocp.setPrevious(null);
869 } else if (currentNext.isDualSub()) {
870 throw new RuntimeException("Removing PipeControlPoint " + this + " structure damaged, next control point is offset control point");
871 } else if (currentNext.previous == this) {
873 currentNext.setPrevious(currentPrev);
875 currentNext.setPrevious(null);
879 throw new RuntimeException("Removing PipeControlPoint "+ this+ " structure damaged");
881 if (currentPrev == null) {
883 } else if (currentPrev.isDualInline()) {
884 throw new RuntimeException("Removing PipeControlPoint " + this + " structure damaged, previous control point is size change control point");
885 } else if (currentPrev.isDualSub()) {
886 PipeControlPoint ocp = currentPrev;
887 PipeControlPoint sccp = ocp.getParentPoint();
889 throw new RuntimeException("Removing PipeControlPoint " + this + " structure damaged, no size change control point");
891 ocp.setNext(currentNext);
892 sccp.setNext(currentNext);
898 } else if (currentPrev.next == this) {
900 currentPrev.setNext(currentNext);
902 currentPrev.setNext(null);
906 throw new RuntimeException("Removing PipeControlPoint " + this + " structure damaged");
909 if (currentNext.isVariableLength() && currentPrev.isVariableLength()) {
910 // we have to join them into single variable length component.
911 additionalRemove = currentPrev;
912 //currentPrev.remove();
915 // FIXME : pipe run must be split into two parts, since the control point structure is no more continuous.
917 } else if (next != null) {
918 if (next.isDualInline()) {
919 PipeControlPoint sccp = next;
920 PipeControlPoint ocp = sccp.getSubPoint().get(0);
922 throw new RuntimeException("Removing PipeControlPoint " + this+ " structure damaged, no offset control point");
924 sccp.setPrevious(null);
925 ocp.setPrevious(null);
926 } else if (next.isDualSub()) {
927 throw new RuntimeException("Removing PipeControlPoint " + this + " structure damaged, next control point is offset control point");
928 } else if (next.previous == this) {
929 next.setPrevious(null);
931 throw new RuntimeException("Removing PipeControlPoint "+ this+ " structure damaged");
934 } else { //(previous != null)
935 if(previous.isDualInline()) {
936 throw new RuntimeException("Removing PipeControlPoint " + this + " structure damaged, previous control point is size change control point");
937 } else if (previous.isDualSub()) {
938 PipeControlPoint ocp = previous;
939 PipeControlPoint sccp = ocp.getParentPoint();
941 throw new RuntimeException("Removing PipeControlPoint " + this + " structure damaged, no size change control point");
945 } else if (previous.next == this) {
946 previous.setNext(null);
948 throw new RuntimeException("Removing PipeControlPoint "+ this+ " structure damaged");
952 if (children.size() > 0 ) {
954 } else if (parent!= null) {
961 pipeRun.remChild(this);
962 checkRemove(pipeRun);
963 if (PipingRules.isEnabled() && pipeRun.getParent() != null && pipeRun.getControlPoints().size() > 0)
964 PipingRules.validate(pipeRun);
965 if (additionalRemove != null)
966 additionalRemove.remove();
969 public void remove() {
970 PipeControlPoint currentPrev = previous;
971 PipeControlPoint currentNext = next;
974 if (currentNext != null)
975 PipingRules.requestUpdate(currentNext);
976 if (currentPrev != null)
977 PipingRules.requestUpdate(currentPrev);
978 } catch (Exception e) {
983 private void checkRemove(PipeRun pipeRun) {
984 Collection<PipeControlPoint> points = pipeRun.getControlPoints();
985 if (points.size() == 0) {
987 } else if (points.size() == 1) {
988 PipeControlPoint pcp = points.iterator().next();
989 if (pcp.isDeletable())
994 private void removeDualPoint() {
995 if (previous != null)
996 previous.setNext(null);
998 next.setPrevious(null);
999 PipeControlPoint ocp;
1000 PipeControlPoint sccp;
1001 if (isDualInline()) {
1003 ocp = getSubPoint().get(0);
1006 sccp = getParentPoint();
1008 PipeRun p1 = ocp.getPipeRun();
1009 PipeRun p2 = sccp.getPipeRun();
1011 ocp.removeComponent();
1012 sccp.removeComponent();
1018 ocp.setPrevious(null);
1020 sccp.setPrevious(null);
1026 private void removeSubPoints() {
1027 for (PipeControlPoint p : children) {
1028 // TODO : this may affect delete routine, since classification of the point changes.
1035 private void removeParentPoint() {
1036 throw new RuntimeException("Child points cannot be removed directly");
1039 private void removeComponent() {
1040 if (component == null)
1042 PipelineComponent next = component.getNext();
1043 PipelineComponent prev = component.getNext();
1045 if (next.getNext() == component)
1047 else if (next.getPrevious() == component)
1048 next.setPrevious(null);
1051 if (prev.getNext() == component)
1053 else if (prev.getPrevious() == component)
1054 prev.setPrevious(null);
1056 PipelineComponent comp = component;
1062 public void setOrientation(Quat4d orientation) {
1063 if (MathTools.equals(orientation, getOrientation()))
1065 super.setOrientation(orientation);
1066 if (getParentPoint() == null && component != null)
1067 component._setWorldOrientation(getWorldOrientation());
1072 public void setPosition(Vector3d position) {
1073 if (MathTools.equals(position, getPosition()))
1075 super.setPosition(position);
1076 if (getParentPoint() == null && component != null)
1077 component._setWorldPosition(getWorldPosition());
1079 System.out.println();
1083 private void updateSubPoint() {
1085 if (next == null && previous == null) {
1086 for (PipeControlPoint sub : getSubPoint()) {
1087 sub.setWorldPosition(getWorldPosition());
1088 sub.setWorldOrientation(getWorldOrientation());
1092 for (PipeControlPoint sub : getSubPoint()) {
1093 Vector3d wp = getWorldPosition();
1094 wp.add(getSizeChangeOffsetVector());
1095 sub.setWorldPosition(wp);
1096 sub.setWorldOrientation(getWorldOrientation());
1099 for (PipeControlPoint sub : getSubPoint()) {
1100 sub.setWorldPosition(getWorldPosition());
1101 sub.setWorldOrientation(getWorldOrientation());
1107 public void _setWorldPosition(Vector3d position) {
1108 Vector3d localPos = getLocalPosition(position);
1109 super.setPosition(localPos);
1113 public void _setWorldOrientation(Quat4d orientation) {
1114 Quat4d localOr = getLocalOrientation(orientation);
1115 super.setOrientation(localOr);
1120 public String toString() {
1121 return getClass().getName() + "@" + Integer.toHexString(hashCode());