]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Fix handling offset in dual directed path leg updates 68/3868/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Thu, 13 Feb 2020 10:13:30 +0000 (12:13 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Thu, 13 Feb 2020 10:13:46 +0000 (12:13 +0200)
gitlab #79

Change-Id: I1e42037ec8832751e4a92eaca84f47479c35aaa7

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

index 100852bf5fe01aeeb59e1caec34323c43a48606b..50b22571874c46482359ec8b2472e4ce7673f28f 100644 (file)
@@ -1203,14 +1203,19 @@ public class PipingRules {
                PipeControlPoint dcp2 = u.end;
                Point3d position1 = new Point3d(u.startPoint);
                Point3d position2 = new Point3d(u.endPoint);
+               
+               Vector3d dir = new Vector3d(), offset = new Vector3d();
+               calculateDirectedOffset(new Vector3d(position1), new Vector3d(position2), u.start, u.list, u.end, dir, offset);
+               
                Point3d position1offset = new Point3d(position1);
-               position1offset.sub(u.offset);
+               position1offset.add(offset);
                Point3d position2offset = new Point3d(position2);
-               position2offset.add(u.offset);
+               position2offset.sub(offset);
                Vector3d dir1 = direction(dcp1, Direction.NEXT);
                Vector3d dir2 = direction(dcp2, Direction.PREVIOUS);
-               Vector3d p1 = MathTools.closestPointOnStraight(position1offset, position2, dir2);
-               Vector3d p2 = MathTools.closestPointOnStraight(position2offset, position1, dir1);
+               
+               Vector3d p1 = MathTools.closestPointOnStraight(position1, position2offset, dir2);
+               Vector3d p2 = MathTools.closestPointOnStraight(position2, position1offset, dir1);
                double d1 = position1.distance(new Point3d(p1));
                double d2 = position2.distance(new Point3d(p2));
 
@@ -1250,9 +1255,9 @@ public class PipingRules {
                                p1.add(v);
 
                                if (!u.reversed)
-                                       p2 = MathTools.closestPointOnStraight(new Point3d(p1), position2, dir2);
+                                       p2 = MathTools.closestPointOnStraight(new Point3d(p1), position2offset, dir2);
                                else
-                                       p2 = MathTools.closestPointOnStraight(new Point3d(p1), position1, dir1);
+                                       p2 = MathTools.closestPointOnStraight(new Point3d(p1), position1offset, dir1);
 
                                // By default, the elbows are placed next to each other, by using 90 deg angles.
                                // If the distance between elbows is not enough, we must move the other elbow (and create more shallow angle elbows)