} else if (toPcp.isTurn() && toPcp.isFixed()) {
dir = new Vector3d(toPcp.getDirection(position == PositionType.NEXT ? Direction.NEXT : Direction.PREVIOUS));
pos = new Vector3d(toPcp.getWorldPosition());
- if (!lengthAdjustable || insertPosition == PositionType.NEXT) {
+ if (!lengthAdjustable) {
Vector3d v = new Vector3d(dir);
v.scale(toPcp.getInlineLength());
pos.add(v);
+ } else {
+ if (insertPosition == PositionType.NEXT) {
+ Vector3d v = new Vector3d(dir);
+ v.scale(toPcp.getInlineLength());
+ pos.add(v);
+ } else if (insertPosition == PositionType.SPLIT) {
+ // scale 0.5*length so that we don't remove the length twice from the new component
+ Vector3d v = new Vector3d(dir);
+ v.scale(toPcp.getInlineLength()*0.5);
+ pos.add(v);
+ }
}
}
* Updates tool graphics for current point
*/
private void updateCurrentPoint() {
-// PipeComponentProvider.createStraightEdges(pipeShapes.get(pipeShapes.size() - 1), controlPoints.get(controlPoints.size() - 1), currentPoint, pipeDiameter*0.5);
InlineComponent straight = (InlineComponent)added.get(added.size()-1);
- // FIXME : does not take account space the the previous elbow reserves.
+ // TODO: the inline length is from previous update step.
+ double l = straight.getPrevious().getControlPoint().getInlineLength();
Vector3d v = new Vector3d();
v.sub(currentPosition, previousPosition);
double length = v.length();
- v.scale(0.5);
- v.add(previousPosition);
- straight.getControlPoint().setWorldPosition(v);
- straight.getControlPoint().setLength(length);
+ if (length > MathTools.NEAR_ZERO) {
+ v.scale(1.0/length);
+ v.scale(0.5*(length+l));
+ v.add(previousPosition);
+ straight.getControlPoint().setWorldPosition(v);
+ straight.getControlPoint().setLength(length);
+ }
try {
PipingRules.positionUpdate(straight.getControlPoint(),false);
} catch (Exception e) {
import javax.vecmath.AxisAngle4d;
import javax.vecmath.Matrix3d;
+import javax.vecmath.Point3d;
import javax.vecmath.Quat4d;
import javax.vecmath.Tuple3d;
import javax.vecmath.Vector3d;
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.
}
private static void updateVariableLengthEnd(PipeControlPoint icp, PipeControlPoint prev) {
- double currentLength = icp.getLength();
- Vector3d currentPos = icp.getWorldPosition();
- Vector3d prevPos = prev.getWorldPosition();
-
- Vector3d dir = new Vector3d();
- dir.sub(currentPos, prevPos);
-
- if (currentLength < MathTools.NEAR_ZERO) {
- currentLength = (dir.length() - prev.getInlineLength()) * 2.0;
- }
-
- if (dir.lengthSquared() > MathTools.NEAR_ZERO)
- dir.normalize();
- Point3d endPos = new Point3d(dir);
- endPos.scale(currentLength * 0.5);
- endPos.add(currentPos); // this is the free end of the
- // component
-
- double offset = prev.getInlineLength();
- Point3d beginPos = new Point3d(dir);
- beginPos.scale(offset);
- beginPos.add(prevPos); // this is the connected end of
- // the component
-
- double l = beginPos.distance(endPos);
-
- if (Double.isNaN(l))
- System.out.println("Length for " + icp + " is NaN");
-
- dir.scale(l * 0.5);
- beginPos.add(dir); // center position
-
- if (DEBUG)
- System.out.println("PipingRules.updateInlineControlPoints() setting variable length to " + l);
- icp.setLength(l);
-
- icp.setWorldPosition(new Vector3d(beginPos));
+ Vector3d currentPos = icp.getWorldPosition();
+ Vector3d prevPos = prev.getWorldPosition();
+
+ Vector3d dir = new Vector3d();
+ dir.sub(currentPos, prevPos);
+
+ boolean simple = true;
+ if (simple) {
+ double currentLength = (dir.length() - prev.getInlineLength()) * 2.0;
+ icp.setLength(currentLength);
+ } else {
+ double currentLength = icp.getLength();
+ if (currentLength < MathTools.NEAR_ZERO) {
+ currentLength = (dir.length() - prev.getInlineLength()) * 2.0;
+ }
+
+ if (dir.lengthSquared() > MathTools.NEAR_ZERO)
+ dir.normalize();
+ Point3d endPos = new Point3d(dir);
+ endPos.scale(currentLength * 0.5);
+ endPos.add(currentPos); // this is the free end of the component
+
+ double offset = prev.getInlineLength();
+ Point3d beginPos = new Point3d(dir);
+ beginPos.scale(offset);
+ beginPos.add(prevPos); // this is the connected end of the component
+
+ double l = beginPos.distance(endPos);
+
+ if (Double.isNaN(l))
+ System.out.println("Length for " + icp + " is NaN");
+
+ dir.scale(l * 0.5);
+ beginPos.add(dir); // center position
+
+ if (DEBUG)
+ System.out.println("PipingRules.updateInlineControlPoints() setting variable length to " + l);
+ icp.setLength(l);
+
+ icp.setWorldPosition(new Vector3d(beginPos));
+ }
}
private static void ppNoOffset(UpdateStruct2 u) throws Exception {
info.getEnd()._remove();
}
}
- // ControlPointTools.removeControlPoint may remove mo0re than one
- // CP;
+ // ControlPointTools.removeControlPoint may remove more than one CP;
// we must populate inline CP list again.
u.list.clear();
u.start.findNextEnd( u.list);
return;
Collection<PipeControlPoint> pcps = pipeRun.getControlPoints();
int count = 0;
+ //System.out.println("Validate " + pipeRun.getName());
for (PipeControlPoint pcp : pcps) {
if (pcp.getParentPoint() == null || pcp.getParentPoint().getPipeRun() != pipeRun)
count++;