From: Marko Luukkainen Date: Thu, 22 Aug 2019 09:48:21 +0000 (+0300) Subject: Improve elbow placement when dual directed pathleg is no loner aligned X-Git-Tag: v1.43.0~204^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F3143%2F1;p=simantics%2F3d.git Improve elbow placement when dual directed pathleg is no loner aligned gitlab #14 Change-Id: If1cecdafe12b27a9836f1e39297eb4d19bd37db1 --- 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);