]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Piping rules seemed to be executed while editor was loading data 04/3404/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 24 Oct 2019 10:26:52 +0000 (13:26 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 24 Oct 2019 10:26:52 +0000 (13:26 +0300)
gitlab #35

Change-Id: Iff74082d21753d391017be1742db836c35075d5f

org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java
org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java

index b3bc2e1e09b757499e2adaccb819f2f3a0b5c006..6c932ad853fac389f56c2a444264151afb76705e 100644 (file)
@@ -768,7 +768,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        }
 
        public void getControlPointEnds(Tuple3d p1, Tuple3d p2) {
-               PipeControlPoint sub = isAxial() ? this : getSubPoint().get(0);
+               PipeControlPoint sub = isAxial() || isDirected() || isTurn() ? this : getSubPoint().get(0);
                Vector3d pos = getWorldPosition(), pos2 = sub == this ? pos : sub.getWorldPosition();
                
                Vector3d dir1 = getPathLegDirection(Direction.PREVIOUS);
index a0ff359e8479a8c0f2b23889aee55ef7dd28018e..6c121d80857da7b7c920c37f73d774b14d191b62 100644 (file)
@@ -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);
        }
 
@@ -1629,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()) {
@@ -1800,11 +1814,19 @@ public class PipingRules {
                }
                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) {