]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipingRules.java
Yesterdays change introduced infinite loop for directed path leg updates
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / scenegraph / controlpoint / PipingRules.java
index 4f95e7964c8194db3df5afc950e043748efba808..57ee4ba86a382e9ac49ed7253ccdaf03f0a248e4 100644 (file)
@@ -447,7 +447,6 @@ public class PipingRules {
                Vector3d endPoint = end.getWorldPosition();
                Vector3d dir = new Vector3d();
                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);
        }
        
@@ -865,7 +864,8 @@ public class PipingRules {
                double l2next = icp.getInlineLength();
                double l2 = l2prev + l2next;
                double l2s = l2 * l2;
-               if (l > l2s) {
+               double diff = l - l2s;
+               if (diff >= MIN_INLINE_LENGTH) {
                        if (allowInsertRemove) {
                                dir.normalize();
                                double length = Math.sqrt(l) - l2; // true length of the variable length component
@@ -989,16 +989,19 @@ public class PipingRules {
                        other = u.end;
                        position = u.startPoint;
                        dcpStart = true;
+                       if (!u.reversed)
+                canMoveOther = true;
                        inlineEnd = u.end.isInline();
                                
                } else {
                        dcp = u.end;
                        other = u.start;
                        position = u.endPoint;
+                       if (u.reversed)
+                canMoveOther = true;
                        inlineEnd = u.start.isInline();
                }
-               canMoveOther = !(other == u.updated);
-
+               
                Vector3d directedDirection = direction(dcp, dcpStart ? Direction.NEXT : Direction.PREVIOUS);
                if (directedDirection == null) {
                        //updateTurnControlPointTurn(dcp, dcp.getPrevious(), dcp.getNext());
@@ -1010,7 +1013,7 @@ public class PipingRules {
                }
                Point3d directedEndPoint = new Point3d(u.endPoint);
                if (u.hasOffsets)
-                       directedEndPoint.add(u.offset);
+                       directedEndPoint.sub(u.offset);
 
                double mu[] = new double[2];
 
@@ -1262,7 +1265,6 @@ public class PipingRules {
                return tr; // space for 90 deg
            Vector3d dir = dcp.getDirectedControlPointDirection();
            Vector3d dp = dcp.getWorldPosition();
-           //Vector3d tp = tcp.getWorldPosition();
            Vector3d op = other.getWorldPosition();
            double u[] = new double[1];
            Vector3d closest = MathTools.closestPointOnStraight(op, dp, dir,u);
@@ -1288,7 +1290,7 @@ public class PipingRules {
                    R = tr / t;
                if (R <= curr)
                    break;
-               curr = R*1.01;
+               curr = R*1.001;
                iter--;
            }
            return curr;
@@ -1893,7 +1895,6 @@ public class PipingRules {
                                List<PipeControlPoint> list2 = pcps.get(i+1);
                                PipeControlPoint prev = list.get(list.size()-1);
                                PipeControlPoint next = list2.get(0);
-                               System.out.println();
                                if (prev == next) {
                                        // Reverse the component on the boundary.
                                        InlineComponent ic = (InlineComponent)prev.getPipelineComponent();