if (DEBUG)
System.out.println("PipingRules.updateInlineControlPoints() " + u);
+ boolean recalcline = false;
if (!u.hasOffsets) {
Vector3d start = new Vector3d(u.startPoint);
if (icp.isVariableLength()) {
if (i != pathLegPoints.size() - 1) {
PipeControlPoint next = pathLegPoints.get(i + 1);
- updateVariableLength(icp, prev, next);
+ recalcline = recalcline | updateVariableLength(icp, prev, next);
} else {
// this is variable length component at the end of the
// space between them.
// I there is, we'll have to create new variable length
// component between them.
- Vector3d currentPos = icp.getWorldPosition();
- Vector3d prevPos = prev.getWorldPosition();
- Vector3d dir = new Vector3d(currentPos);
- dir.sub(prevPos);
- double l = dir.lengthSquared();
- double l2prev = prev.getInlineLength();
- double l2next = icp.getInlineLength();
- double l2 = l2prev + l2next;
- double l2s = l2 * l2;
- if (l > l2s) {
- if (allowInsertRemove) {
- dir.normalize();
- double length = Math.sqrt(l) - l2; // true length of the
- // variable length
- // component
- dir.scale(length * 0.5 + l2prev); // calculate center
- // position of the
- // component
- dir.add(prevPos);
- PipeControlPoint scp = insertStraight(prev, icp, dir, length);
- } else {
- triedIR = true;
- }
- }
+ recalcline = recalcline | possibleVaribleLengthInsert(icp, prev);
}
}
} else { // with offset
}
pathLegPoints.add(u.end);
+ if (!checkSizes)
+ return;
+
sp = new Vector3d(u.startPoint);
ep = new Vector3d(u.endPoint);
ep.sub(u.offset);
if (i != pathLegPoints.size() - 1) {
PipeControlPoint next;
next = pathLegPoints.get(i + 1);
- updateVariableLength(icp, prev, next);
+ recalcline = recalcline | updateVariableLength(icp, prev, next);
} else {
// this is variable length component at the end of the
// place, but center of the component must be moved.
updateVariableLengthEnd(icp, prev);
}
- } else if (icp.isOffset()) {
+ } else if (!prev.isVariableLength()) {
+ // If this and previous control point are not variable
+ // length pcps, we'll have to check if there is no empty
+ // space between them.
+ // I there is, we'll have to create new variable length
+ // component between them.
+ recalcline = recalcline | possibleVaribleLengthInsert(icp, prev);
+ }
+ if (icp.isOffset()) {
// TODO : offset vector is already calculated and should be
// cached
Vector3d offset = icp.getSizeChangeOffsetVector(u.dir);
}
}
}
+ if (recalcline) {
+ u.list.clear();
+ u.start.findNextEnd(u.list);
+ }
}
- private static void updateVariableLength(PipeControlPoint icp, PipeControlPoint prev, PipeControlPoint next) {
+ private static boolean updateVariableLength(PipeControlPoint icp, PipeControlPoint prev, PipeControlPoint next) {
Vector3d prevPos = prev.getWorldPosition();
Vector3d nextPos = next.getWorldPosition();
dir.add(prevPos);
icp.setWorldPosition(dir);
icp.setLength(length);
+ return false;
} else {
// components leave no space to the component and it
// must be removed
if (DEBUG)
System.out.println("PipingRules.updateVariableLength removing " + icp);
icp._remove();
+ return true;
+ }
+ return false;
+ }
+ }
+
+ private static boolean possibleVaribleLengthInsert(PipeControlPoint icp, PipeControlPoint prev) throws Exception{
+ Vector3d currentPos = icp.getWorldPosition();
+ Vector3d prevPos = prev.getWorldPosition();
+ Vector3d dir = new Vector3d(currentPos);
+ dir.sub(prevPos);
+ double l = dir.lengthSquared();
+ double l2prev = prev.getInlineLength();
+ double l2next = icp.getInlineLength();
+ double l2 = l2prev + l2next;
+ double l2s = l2 * l2;
+ if (l > l2s) {
+ if (allowInsertRemove) {
+ dir.normalize();
+ double length = Math.sqrt(l) - l2; // true length of the
+ // variable length
+ // component
+ dir.scale(length * 0.5 + l2prev); // calculate center
+ // position of the
+ // component
+ dir.add(prevPos);
+ PipeControlPoint scp = insertStraight(prev, icp, dir, length);
+ return true;
+ } else {
+ triedIR = true;
}
}
+ return false;
}
private static void updateVariableLengthEnd(PipeControlPoint icp, PipeControlPoint prev) {
System.out.println("Run is not connected");
}
for (PipeControlPoint pcp : pcps) {
- if (!pcp.isDirected())
- if (pcp.getNext() == null && pcp.getPrevious() == null)
- System.out.println("Orphan " + pcp);
+ if (!pcp.isDirected() && pcp.getNext() == null && pcp.getPrevious() == null)
+ System.out.println("Orphan undirected " + pcp);
}
for (PipeControlPoint pcp : pcps) {
if (pcp.getParentPoint() == null) {