From 27d92007b69e2ba74cc96d45668a6c6a99a15a65 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Thu, 22 Aug 2019 12:48:21 +0300 Subject: [PATCH] Improve elbow placement when dual directed pathleg is no loner aligned gitlab #14 Change-Id: If1cecdafe12b27a9836f1e39297eb4d19bd37db1 --- .../scenegraph/controlpoint/PipingRules.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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 fd50bf7b..6a5d04fb 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 @@ -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); -- 2.47.1