From: Marko Luukkainen Date: Tue, 3 Dec 2019 13:59:37 +0000 (+0200) Subject: Fix path leg updates when reducer is the first or the last component. X-Git-Tag: v1.43.0~103 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=8277a382f15615044cfaeb87a2088417bb079eab;p=simantics%2F3d.git Fix path leg updates when reducer is the first or the last component. Additionally fixed control removal on reducer boundary. gitlab #61 Change-Id: Iadcb1b410acde45e23e4cd9a4a592fb6b8e6d294 (cherry picked from commit dc44eb5c7d3c8f35faf9bab80b9432d60ea203ea) --- diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index abd899ac..c5d780c3 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -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"); } 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 b64a9e93..10cf23e3 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 @@ -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 list, Vector3d dir, Vector3d offset) { + private static boolean calculateOffset(Vector3d startPoint, Vector3d endPoint, PipeControlPoint start, ArrayList list, PipeControlPoint end, Vector3d dir, Vector3d offset) { boolean hasOffsets = false; List offsets = new ArrayList(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 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; }