]> gerrit.simantics Code Review - simantics/3d.git/commitdiff
Improve elbow placement when dual directed pathleg is no loner aligned 43/3143/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 22 Aug 2019 09:48:21 +0000 (12:48 +0300)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Thu, 22 Aug 2019 09:48:21 +0000 (12:48 +0300)
gitlab #14

Change-Id: If1cecdafe12b27a9836f1e39297eb4d19bd37db1

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

index fd50bf7b4b1c26ed9e8757855f547d818464ec4d..6a5d04fb345731d9fb88cbbc86c7494611bc4f9c 100644 (file)
@@ -1004,17 +1004,27 @@ public class PipingRules {
                                }
                                
                                p1 = dcp.getWorldPosition();
-                               // FIXME: calculate position of the elbows properly.
+                               Vector3d v = new Vector3d();
                                if (!u.reversed)
-                                       p1.add(dir1);
+                                   v.set(dir1);
                                else
-                                       p1.add(dir2);
+                                       v.set(dir2);
+                               
+                               // Reserve space for 90 deg elbow
+                               double off = dcp1.getPipeRun().getTurnRadius();
+                               v.scale(off);
+                               p1.add(v);
 
                                if (!u.reversed)
                                        p2 = MathTools.closestPointOnStraight(new Point3d(p1), position2, dir2);
                                else
                                        p2 = MathTools.closestPointOnStraight(new Point3d(p1), position1, 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)
+                               if (MathTools.distance(p1, p2) < off*2.05) {
+                                   p2.add(v);
+                               }
                                
                                PipeControlPoint tcp1 = insertElbow(dcp, next, p1);
                                PipeControlPoint tcp2 = insertElbow(tcp1, next, p2);