import javax.vecmath.AxisAngle4d;
import javax.vecmath.Matrix3d;
+import javax.vecmath.Point3d;
import javax.vecmath.Quat4d;
import javax.vecmath.Tuple3d;
import javax.vecmath.Vector3d;
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 boolean fixed = true;
- private boolean rotate = false;
- private boolean reverse = false;
- private boolean deletable = true;
- private boolean sub = false;
+ 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;
public PipeControlPoint(PipelineComponent component) {
this.component = component;
return component;
}
- public Type getType() {
+ public PointType getType() {
return type;
}
- public void setType(Type type) {
+ public void setType(PointType type) {
this.type = type;
}
@GetPropertyValue(name="Fixed",tabId="Debug",value="fixed")
public boolean isFixed() {
- return fixed;
+ return isFixed;
}
public void setFixed(boolean fixed) {
- this.fixed = fixed;
+ this.isFixed = fixed;
}
@GetPropertyValue(name="Rotate",tabId="Debug",value="rotate")
public boolean isRotate() {
- return rotate;
+ return isRotate;
}
public void setRotate(boolean rotate) {
- this.rotate = rotate;
+ this.isRotate = rotate;
}
@GetPropertyValue(name="Reverse",tabId="Debug",value="reverse")
public boolean isReverse() {
- return reverse;
+ return isReverse;
}
public void setReverse(boolean reverse) {
- this.reverse = reverse;
+ this.isReverse = reverse;
}
public void setSub(boolean sub) {
- this.sub = sub;
+ this.isSub = sub;
}
@GetPropertyValue(name="Deletable",tabId="Debug",value="deletable")
public boolean isDeletable() {
- return deletable;
+ return isDeletable;
}
public void setDeletable(boolean deletable) {
- this.deletable = deletable;
+ this.isDeletable = deletable;
}
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() {
- return fixed && isEnd();
+ return isFixed && isEnd();
}
public boolean isNonDirected() {
- return !fixed && isEnd();
+ return !isFixed && isEnd();
}
public boolean isVariableLength() {
- return !fixed && isInline();
+ return !isFixed && isInline();
}
public boolean isVariableAngle() {
- return !fixed && isTurn();
+ return !isFixed && isTurn();
}
public boolean isBranchEnd() {
- return deletable && isEnd();
+ return isDeletable && isEnd();
}
public boolean isOffset() {
}
public boolean isDualSub() {
- return parent != null && sub;
+ return parent != null && isSub;
}
public boolean isDualInline() {
}
public boolean isSizeChange() {
- if (children.size() == 0)
- return false;
- if (!isDualInline())
- return false;
- return getPipeRun() != children.get(0).getPipeRun();
+ return isSizeChange;
+// if (children.size() == 0)
+// return false;
+// if (!isDualInline())
+// return false;
+// return getPipeRun() != children.get(0).getPipeRun();
}
+
+ public void setSizeChange(boolean isSizeChange) {
+ this.isSizeChange = isSizeChange;
+ }
private PipeControlPoint next;
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 == this)
+ throw new RuntimeException("Cannot connect to self");
if (this.next == next)
return;
if (DEBUG) System.out.println(this + " next " + next);
this.next = next;
if (component != null) {
- if (parent == null || sub)
+ if (parent == null || isSub)
component.setNext(next != null ? next.component : null);
else
component.setBranch0(next != null ? next.component : null);
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 == this)
+ throw new RuntimeException("Cannot connect to self");
if (this.previous == previous)
return;
if (DEBUG) System.out.println(this + " previous " + previous);
this.previous = previous;
if (component != null) {
- if (parent == null || sub)
+ if (parent == null || isSub)
component.setPrevious(previous != null ? previous.component : null);
else
component.setBranch0(previous != null ? previous.component : null);
}
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)
dir.normalize();
Quat4d q = getControlPointOrientationQuat(dir, angle);
if (reversed) {
- Quat4d q2 = new Quat4d();
+ Quat4d q2 = new Quat4d();
q2.set(new AxisAngle4d(MathTools.Y_AXIS, Math.PI));
q.mulInverse(q2);
}
}
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;
}
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.
ocp.removeComponent();
sccp.removeComponent();
- p1.remChild(ocp);
- p2.remChild(sccp);
+ if (p1 != null)
+ p1.remChild(ocp);
+ if (p2 != null)
+ p2.remChild(sccp);
// TODO : now we assume that this is size change, and we do
if (ocp.next != null)
sccp.setNext(null);
sccp.setPrevious(null);
- checkRemove(p1);
- checkRemove(p2);
+ if (p1 != null)
+ checkRemove(p1);
+ if (p2 != null)
+ checkRemove(p2);
}
private void removeSubPoints() {
}
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);
}