X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.plant3d%2Fsrc%2Forg%2Fsimantics%2Fplant3d%2Fscenegraph%2Fcontrolpoint%2FPipingRules.java;h=727cf1a882e8d513fa1ab583ef2584a692054954;hb=7a6193c2806c1755ad127eb479e871b2008df856;hp=854b265d3a09e7c00ae370a5c93460a4b99ef020;hpb=53d55c24c779745f188bdb18d32f71d20acb61b2;p=simantics%2F3d.git diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java index 854b265d..727cf1a8 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java @@ -51,6 +51,8 @@ public class PipingRules { 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)) @@ -59,6 +61,9 @@ public class PipingRules { } public static boolean update() throws Exception { + if (!PipingRules.enabled) + return false; + if (requestUpdates.size() == 0) return false; @@ -304,6 +309,10 @@ public class PipingRules { else if (us.end.equals(updated)) lengthChange = PathLegUpdateType.PREV; } + if (us == null) { + System.out.println("Null update struct " + start); + return; + } updatePathLeg(us, lengthChange); } @@ -316,6 +325,10 @@ public class PipingRules { // else if (us.end.equals(updated)) // lengthChange = PathLegUpdateType.PREV; // } + if (us == null) { + System.out.println("Null update struct " + start); + return; + } updatePathLeg(us, lengthChange); } @@ -882,14 +895,15 @@ public class PipingRules { 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); } @@ -1069,7 +1083,7 @@ public class PipingRules { // 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{ @@ -1565,7 +1579,7 @@ public class PipingRules { 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(); @@ -1628,8 +1642,9 @@ public class PipingRules { 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()) { @@ -1799,11 +1814,19 @@ public class PipingRules { } List 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) {