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=26e2bb52de68974d253cd4befea10e7e26fd9bd6;hb=178e59c935e6c4eaa7897d9bf8c5113ee822878b;hp=8cbe5a8ae997e9808df5a34e37cf587af2d625c5;hpb=9e1e51825bfdcd72d7006e1bff703e7eb52919c6;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 8cbe5a8a..26e2bb52 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 @@ -92,10 +92,10 @@ public class PipingRules { validate(pcp.getPipeRun()); if (pcp.isPathLegEnd()) { updatePathLegEndControlPoint(pcp); // FXIME: Rules won't work properly, if they are not run twice. - updatePathLegEndControlPoint(pcp); + //updatePathLegEndControlPoint(pcp); } else { updateInlineControlPoint(pcp); - updateInlineControlPoint(pcp); + //updateInlineControlPoint(pcp); } validate(pcp.getPipeRun()); if (!allowInsertRemove) @@ -345,8 +345,8 @@ public class PipingRules { ErrorLogger.defaultLogError("Updating pipe run, found offset controlpoint " + icp, new Exception("ASSERT!")); } if (offsets.size() == 0) { - dir.set(startPoint); - dir.sub(endPoint); + dir.set(endPoint); + dir.sub(startPoint); double l = dir.lengthSquared(); if (l > MathTools.NEAR_ZERO) dir.scale(1.0/Math.sqrt(l)); @@ -355,8 +355,8 @@ public class PipingRules { } else { Vector3d sp = new Vector3d(startPoint); Point3d ep = new Point3d(endPoint); - dir.set(sp); - dir.sub(ep); + dir.set(ep); + dir.sub(sp); double l = dir.lengthSquared(); if (l > MathTools.NEAR_ZERO) dir.scale(1.0/Math.sqrt(l)); @@ -375,8 +375,8 @@ public class PipingRules { break; } ep = nep; - dir.set(sp); - dir.sub(ep); + dir.set(ep); + dir.sub(sp); l = dir.lengthSquared(); if (l > MathTools.NEAR_ZERO) dir.scale(1.0/Math.sqrt(l)); @@ -668,7 +668,7 @@ public class PipingRules { double l = beginPos.distance(endPos); if (Double.isNaN(l)) - System.out.println(); + System.out.println("Length for " + icp + " is NaN"); dir.scale(l * 0.5); beginPos.add(dir); // center position @@ -708,24 +708,24 @@ public class PipingRules { } private static void checkExpandPathLeg(UpdateStruct2 u, PathLegUpdateType lengthChange) throws Exception { - checkExpandPathLeg(u, lengthChange, false); + checkExpandPathLeg(u, lengthChange, u.updated.isInline() && u.updated.isOffset()); } - private static void checkExpandPathLeg(UpdateStruct2 u, PathLegUpdateType lengthChange, boolean forceUpdate) throws Exception { + private static void checkExpandPathLeg(UpdateStruct2 u, PathLegUpdateType lengthChange, boolean updateEnds) throws Exception { if (DEBUG) System.out.println("PipingRules.checkExpandPathLeg() " + u + " " + lengthChange); if (lengthChange != PathLegUpdateType.NONE) { // FIXME : turns cannot be checked before inline cps are updated, // since their position affects calculation of turns - processPathLeg(u, forceUpdate, false); + processPathLeg(u, updateEnds, false); int type = checkTurns(u, lengthChange); if (type == REMOVE_NONE) { - processPathLeg(u, forceUpdate, true); + processPathLeg(u, updateEnds, true); } else { expandPathLeg(u, type); } } else { - processPathLeg(u, forceUpdate, true); + processPathLeg(u, updateEnds, true); } } @@ -1011,7 +1011,7 @@ public class PipingRules { a = updateTurnControlPointTurn(u.start, startPrev, u.end); } else { Vector3d ep = new Vector3d(u.endPoint); - ep.add(u.offset); + ep.sub(u.offset); a = updateTurnControlPointTurn(u.start, u.startPoint, startPrev.getPosition(), ep); } @@ -1036,7 +1036,7 @@ public class PipingRules { a = updateTurnControlPointTurn(u.end, u.start, endNext); } else { Vector3d sp = new Vector3d(u.startPoint); - sp.sub(u.offset); + sp.add(u.offset); a = updateTurnControlPointTurn(u.end, u.endPoint, sp, endNext.getPosition()); } if (a < MIN_TURN_ANGLE && u.end.isDeletable()) @@ -1601,6 +1601,11 @@ public class PipingRules { if (runPcps.size() != count) { System.out.println("Run is not connected"); } + for (PipeControlPoint pcp : pcps) { + if (!pcp.isDirected()) + if (pcp.getNext() == null && pcp.getPrevious() == null) + System.out.println("Orphan " + pcp); + } for (PipeControlPoint pcp : pcps) { if (pcp.getParentPoint() == null) { PipeControlPoint sub = null;