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=b096266f7af72901d2718812b9dd77d3570d3689;hb=0ad74f024bc769b126a2e46d0015fe0deb30b34c;hp=be66cf1441954cdebad851999b4b58c96599b7c4;hpb=8b06e290cf681e2157824428395988063686e7b3;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 be66cf14..b096266f 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 @@ -708,43 +708,47 @@ public class PipingRules { } private static void updateVariableLengthEnd(PipeControlPoint icp, PipeControlPoint prev) { - double currentLength = icp.getLength(); - Vector3d currentPos = icp.getWorldPosition(); - Vector3d prevPos = prev.getWorldPosition(); - - Vector3d dir = new Vector3d(); - dir.sub(currentPos, prevPos); - - if (currentLength < MathTools.NEAR_ZERO) { - currentLength = (dir.length() - prev.getInlineLength()) * 2.0; - } - - if (dir.lengthSquared() > MathTools.NEAR_ZERO) - dir.normalize(); - Point3d endPos = new Point3d(dir); - endPos.scale(currentLength * 0.5); - endPos.add(currentPos); // this is the free end of the - // component - - double offset = prev.getInlineLength(); - Point3d beginPos = new Point3d(dir); - beginPos.scale(offset); - beginPos.add(prevPos); // this is the connected end of - // the component - - double l = beginPos.distance(endPos); - - if (Double.isNaN(l)) - System.out.println("Length for " + icp + " is NaN"); - - dir.scale(l * 0.5); - beginPos.add(dir); // center position - - if (DEBUG) - System.out.println("PipingRules.updateInlineControlPoints() setting variable length to " + l); - icp.setLength(l); - - icp.setWorldPosition(new Vector3d(beginPos)); + Vector3d currentPos = icp.getWorldPosition(); + Vector3d prevPos = prev.getWorldPosition(); + + Vector3d dir = new Vector3d(); + dir.sub(currentPos, prevPos); + + boolean simple = true; + if (simple) { + double currentLength = (dir.length() - prev.getInlineLength()) * 2.0; + icp.setLength(currentLength); + } else { + double currentLength = icp.getLength(); + if (currentLength < MathTools.NEAR_ZERO) { + currentLength = (dir.length() - prev.getInlineLength()) * 2.0; + } + + if (dir.lengthSquared() > MathTools.NEAR_ZERO) + dir.normalize(); + Point3d endPos = new Point3d(dir); + endPos.scale(currentLength * 0.5); + endPos.add(currentPos); // this is the free end of the component + + double offset = prev.getInlineLength(); + Point3d beginPos = new Point3d(dir); + beginPos.scale(offset); + beginPos.add(prevPos); // this is the connected end of the component + + double l = beginPos.distance(endPos); + + if (Double.isNaN(l)) + System.out.println("Length for " + icp + " is NaN"); + + dir.scale(l * 0.5); + beginPos.add(dir); // center position + + if (DEBUG) + System.out.println("PipingRules.updateInlineControlPoints() setting variable length to " + l); + icp.setLength(l); + + icp.setWorldPosition(new Vector3d(beginPos)); + } } private static void ppNoOffset(UpdateStruct2 u) throws Exception { @@ -1291,8 +1295,7 @@ public class PipingRules { info.getEnd()._remove(); } } - // ControlPointTools.removeControlPoint may remove mo0re than one - // CP; + // ControlPointTools.removeControlPoint may remove more than one CP; // we must populate inline CP list again. u.list.clear(); u.start.findNextEnd( u.list); @@ -1612,7 +1615,7 @@ public class PipingRules { turnAngle = 0.0; tcp.setTurnAngle(0.0); tcp.setLength(0.0); - tcp.setTurnAxis(MathTools.Y_AXIS); + tcp.setTurnAxis(new Vector3d(MathTools.Y_AXIS)); } updateControlPointOrientation(tcp); if (DEBUG) @@ -1725,13 +1728,14 @@ public class PipingRules { return; Collection pcps = pipeRun.getControlPoints(); int count = 0; + //System.out.println("Validate " + pipeRun.getName()); for (PipeControlPoint pcp : pcps) { if (pcp.getParentPoint() == null || pcp.getParentPoint().getPipeRun() != pipeRun) count++; } List runPcps = getControlPoints(pipeRun); if (runPcps.size() != count) { - System.out.println("Run is not connected"); + System.out.println("Run " + pipeRun.getName() + " contains unconnected control points"); } for (PipeControlPoint pcp : pcps) { if (!pcp.isDirected() && pcp.getNext() == null && pcp.getPrevious() == null)