private static Object ruleMutex = new Object();
public static void requestUpdate(PipeControlPoint pcp) {
+ if (!PipingRules.enabled)
+ return;
if (DEBUG) System.out.println("PipingRules request " + pcp);
synchronized (updateMutex) {
if (!requestUpdates.contains(pcp))
}
public static boolean update() throws Exception {
+ if (!PipingRules.enabled)
+ return false;
+
if (requestUpdates.size() == 0)
return false;
else if (us.end.equals(updated))
lengthChange = PathLegUpdateType.PREV;
}
+ if (us == null) {
+ System.out.println("Null update struct " + start);
+ return;
+ }
updatePathLeg(us, lengthChange);
}
// else if (us.end.equals(updated))
// lengthChange = PathLegUpdateType.PREV;
// }
+ if (us == null) {
+ System.out.println("Null update struct " + start);
+ return;
+ }
updatePathLeg(us, lengthChange);
}
private static boolean asDirected(PipeControlPoint pcp, Direction direction) {
if (pcp.isDirected())
return true;
- if (pcp.isTurn() && pcp.isFixed()) {
+ if (pcp.asFixedAngle()) {
if (!pcp._getReversed())
return direction == Direction.NEXT;
else
if (DEBUG)
System.out.println("PipingRules.updateFreePipeRun " + u + " " + lengthChange);
checkExpandPathLeg(u, lengthChange);
- if (u.start.isInline() || u.end.isInline() || u.start.isFixed() || u.end.isFixed())
+ if (u.start.isInline() || u.end.isInline() || u.start.asFixedAngle()|| u.end.asFixedAngle())
processPathLeg(u, true, false);
}
double distance = t.length();
boolean aligned = (distance < ALLOWED_OFFSET);
if (aligned) {
- if (u.start.isInline() || u.end.isInline() || u.start.isFixed() || u.end.isFixed())
+ if (u.start.isInline() || u.end.isInline() || u.start.asFixedAngle() || u.end.asFixedAngle())
processPathLeg(u, true, false);
checkExpandPathLeg(u, lengthChange, inlineEnd);
if (other.isVariableAngle()) {
// TODO calculate needed space from next run end.
- if (mu[0] < 1.0) {
+ double space = spaceForTurn(other);
+ if (mu[0] < space) {
if (dcpStart) {
closest.set(u.startPoint);
} else {
closest.set(u.endPoint);
}
Vector3d v = new Vector3d(directedDirection);
- v.scale(spaceForTurn(other));
+ v.scale(space);
closest.add(v);
}
// TODO : this returns now space for 90 deg turn.
// The challenge: position of tcp affects the turn angle, which then affects the required space. Perhaps we need to iterate...
// Additionally, if the path legs contain offset, using just positions of opposite path leg ends is not enough,
- return tcp.getPipeRun().getTurnRadius();
+ return ((TurnComponent)tcp.getPipelineComponent()).getTurnRadius();
}
private static void insertElbowUpdate(UpdateStruct2 u, PipeControlPoint dcp, PipeControlPoint next, boolean dcpStart, Vector3d position, Vector3d directedDirection) throws Exception{
private static void updateEndComponentControlPoint(PipeControlPoint ecp, Vector3d start, Vector3d end) throws Exception {
if (DEBUG)
System.out.println("PipingRules.updateEndComponentControlPoint() " + ecp);
- // PipeControlPoint next = ecp.getNext();
- // PipeControlPoint prev = ecp.getPrevious();
- // if (next != null) {
- // end = G3DTools.getPoint(next.getLocalPosition());
- // start = G3DTools.getPoint(ecp.getLocalPosition());
- // } else if (prev != null) {
- // end = G3DTools.getPoint(ecp.getLocalPosition());
- // start = G3DTools.getPoint(prev.getLocalPosition());
- // } else {
- // // TODO : warning?
- // return;
- // }
- // Vector3d dir = new Vector3d (end);
- // dir.sub(start);
- // dir.normalize();
- // G3DTools.setTuple(ecp.getDirection(), dir);
- if (!ecp.isFixed())
- updateControlPointOrientation(ecp);
+ //FIXME : end control point cannot be fixed!
+ //if (!ecp.isFixed())
+ updateControlPointOrientation(ecp);
for (PipeControlPoint pcp : ecp.getSubPoint()) {
// TODO update position
}
}
- if (!tcp.isFixed()) {
+ if (!tcp.asFixedAngle()) {
if (next == null || prev == null) {
Vector3d turnAxis = new Vector3d();
turnAxis.cross(prev, next);
if (turnAxis.lengthSquared() > MathTools.NEAR_ZERO) {
- double elbowRadius = tcp.getPipelineComponent().getPipeRun().getTurnRadius();
+ double elbowRadius = ((TurnComponent)tcp.getPipelineComponent()).getTurnRadius();
double R = elbowRadius / Math.tan(angle * 0.5);
turnAxis.normalize();
PipeControlPoint pcp = pipeRun.getControlPoints().iterator().next();
while (pcp.getPrevious() != null) {
PipeControlPoint prev = pcp.getPrevious();
- if (prev.getPipeRun() != pipeRun)
- break;
+ if (prev.getPipeRun() != pipeRun && prev.getPipeRun() != null) { // bypass possible corruption
+ break;
+ }
pcp = prev;
}
if (pcp.isDualSub()) {
}
}
- if (current.isTurn() && current.isFixed()) {
+ //if (current.isTurn() && current.isFixed()) {
+ if (current.asFixedAngle()) {
current.setReversed(!current._getReversed());
}
if (current.isInline() && current.isReverse()) {
}
List<PipeControlPoint> runPcps = getControlPoints(pipeRun);
if (runPcps.size() != count) {
- System.out.println("Run " + pipeRun.getName() + " contains unconnected control points");
+ System.out.println("Run " + pipeRun.getName() + " contains unconnected control points, found " + runPcps.size() + " connected, " + pcps.size() + " total.");
+ for (PipeControlPoint pcp : pcps) {
+ if (!runPcps.contains(pcp)) {
+ System.out.println("Unconnected " + pcp + " " + pcp.getPipelineComponent());
+ }
+ }
}
for (PipeControlPoint pcp : pcps) {
+ if (pcp.getPipeRun() == null) {
+ System.out.println("PipeRun ref missing " + pcp + " " + pcp.getPipelineComponent());
+ }
if (!pcp.isDirected() && pcp.getNext() == null && pcp.getPrevious() == null)
- System.out.println("Orphan undirected " + pcp);
+ System.out.println("Orphan undirected " + pcp + " " + pcp.getPipelineComponent());
}
for (PipeControlPoint pcp : pcps) {
if (pcp.getParentPoint() == null) {
}
public static void splitVariableLengthComponent(PipelineComponent newComponent, InlineComponent splittingComponent, boolean assignPos) throws Exception{
- assert(!splittingComponent.getControlPoint().isFixed());
- assert(!(newComponent instanceof InlineComponent && !newComponent.getControlPoint().isFixed()));
+ assert(!splittingComponent.getControlPoint().isFixedLength());
+ assert(!(newComponent instanceof InlineComponent && !newComponent.getControlPoint().isFixedLength()));
PipeControlPoint newCP = newComponent.getControlPoint();
PipeControlPoint splittingCP = splittingComponent.getControlPoint();
PipeControlPoint nextCP = splittingCP.getNext();