]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Fix path leg updates when reducer is the first or the last component. 64/3664/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 3 Dec 2019 13:59:37 +0000 (15:59 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Tue, 3 Dec 2019 13:59:37 +0000 (15:59 +0200)
Additionally fixed control removal on reducer boundary.

gitlab #61

Change-Id: Iadcb1b410acde45e23e4cd9a4a592fb6b8e6d294

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

index abd899ac23ae0af43f07b3020894fa29b9b0bfc9..c5d780c36b8d5f2dc3b4d0abf5642410509614f3 100644 (file)
@@ -1228,7 +1228,7 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
                        } else if (currentNext != null) {
                                if (currentNext.isDualInline()) {
                                        PipeControlPoint sccp = currentNext;
-                                       PipeControlPoint ocp = getDualSub();
+                                       PipeControlPoint ocp = currentNext.getDualSub();
                                        if (ocp == null) {
                                                throw new RuntimeException("Removing PipeControlPoint " + this+ " structure damaged, no offset control point");
                                        }
index b64a9e93cce04a303747931499753e76d002645b..10cf23e37537561774f08aaf04ed3a57f67a8397 100644 (file)
@@ -117,6 +117,8 @@ public class PipingRules {
                        allowInsertRemove = allowIR;
                        triedIR = false;
                        validate(pcp.getPipeRun());
+                       if (pcp.getParentPoint() != null)
+                           pcp = pcp.getParentPoint();
                        if (pcp.asPathLegEnd()) {
                                updatePathLegEndControlPoint(pcp); // FIXME: Rules won't work properly, if they are not run twice.
                                //updatePathLegEndControlPoint(pcp);
@@ -362,9 +364,12 @@ public class PipingRules {
        }
 
        @SuppressWarnings("unused")
-       private static boolean calculateOffset(Vector3d startPoint, Vector3d endPoint, ArrayList<PipeControlPoint> list, Vector3d dir, Vector3d offset) {
+       private static boolean calculateOffset(Vector3d startPoint, Vector3d endPoint, PipeControlPoint start, ArrayList<PipeControlPoint> list, PipeControlPoint end, Vector3d dir, Vector3d offset) {
                boolean hasOffsets = false;
                List<PipeControlPoint> offsets = new ArrayList<PipeControlPoint>(list.size());
+               // Only start offset affects the calculation
+               if (start.isOffset())
+                   offsets.add(start);
                for (PipeControlPoint icp : list) {
                        if (icp.isOffset()) {
                                offsets.add(icp);
@@ -441,7 +446,8 @@ public class PipingRules {
                Vector3d startPoint = start.getWorldPosition();
                Vector3d endPoint = end.getWorldPosition();
                Vector3d dir = new Vector3d();
-               hasOffsets = calculateOffset(startPoint, endPoint, list, dir, offset);
+               hasOffsets = calculateOffset(startPoint, endPoint, start, list, end, dir, offset);
+               System.out.println();
                return new UpdateStruct2(start, startPoint, list, end, endPoint, dir, offset, hasOffsets, iter, direction == Direction.PREVIOUS, toRemove, updated);
        }
        
@@ -526,7 +532,13 @@ public class PipingRules {
                Vector3d ep = new Vector3d(end);
                ep.sub(u.offset);
                
-       
+               if (u.start.isOffset()) {
+                   Vector3d offset = u.start.getSizeChangeOffsetVector(u.dir);
+                   updateOffsetPoint(u.start, offset);
+            sp.add(offset);
+            ep.add(offset);
+               }
+                   
                for (PipeControlPoint icp : u.list) {
                        updateInlineControlPoint(icp, sp, ep, u.dir);
                        if (icp.isOffset()) {
@@ -937,7 +949,7 @@ public class PipingRules {
                // FIXME : extra loop (dir should be calculated here)
                Vector3d dir = new Vector3d();
                Vector3d offset = new Vector3d();
-               hasOffsets = calculateOffset(startPoint, endPoint, list, dir, offset);
+               hasOffsets = calculateOffset(startPoint, endPoint, start, list, end, dir, offset);
                ppNoOffset(new UpdateStruct2(start, startPoint, list, end, endPoint, dir, null, hasOffsets, iter, reversed, toRemove, updated));
        }
 
@@ -1795,7 +1807,10 @@ public class PipingRules {
                        List<PipeControlPoint> points = getControlPoints(pipeRun);
                        PipeControlPoint pcp = points.get(0);
                        if (pcp.isSizeChange() && pcp.getChildPoints().size() > 0) {
-                               pipeRun = pcp.getPipeRun();
+                               PipeRun pr = pcp.getPipeRun();
+                               if (pr != pipeRun)
+                                   pipeRun = pr;
+                               else break;
                        } else {
                                break;
                        }