From 3b5c59eca31e9db10c1a1dc6d244d6fd4f3578a2 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Mon, 5 Aug 2019 15:32:55 +0300 Subject: [PATCH] Support for reversible in-line components gitlab #13 Change-Id: I2348320a5bba2b8d86b7a0bcc118d85f81023186 --- .../graph/plant3d.pgraph | 4 +- .../graph/plant3d_builtins.pgraph | 1 + .../plant3d/scenegraph/InlineComponent.java | 28 +++++++++++ .../controlpoint/ControlPointFactory.java | 7 +++ .../controlpoint/PipeControlPoint.java | 50 +++++++++++++++++-- .../scenegraph/controlpoint/PipingRules.java | 7 ++- 6 files changed, 90 insertions(+), 7 deletions(-) diff --git a/org.simantics.plant3d.ontology/graph/plant3d.pgraph b/org.simantics.plant3d.ontology/graph/plant3d.pgraph index d7dce09e..46a6a34b 100644 --- a/org.simantics.plant3d.ontology/graph/plant3d.pgraph +++ b/org.simantics.plant3d.ontology/graph/plant3d.pgraph @@ -69,7 +69,9 @@ P3D.SizeChangeComponent MathTools.NEAR_ZERO) + dir.normalize(); + Quat4d q = getControlPointOrientationQuat(dir, angle); + if (reversed) { + Quat4d q2 = new Quat4d(); + q2.set(new AxisAngle4d(MathTools.Y_AXIS, Math.PI)); + q.mulInverse(q2); + } + return q; + } else { + Vector3d dir = getPathLegDirection(Direction.PREVIOUS); + dir.negate(); + if (dir.lengthSquared() > MathTools.NEAR_ZERO) + dir.normalize(); + return getControlPointOrientationQuat(dir, turnAxis, angle); + } + } - public static Quat4d getControlPointOrientationQuat(Vector3d dir, double angle) { + public static Quat4d getControlPointOrientationQuat(Vector3d dir, double angle) { if (dir.lengthSquared() < MathTools.NEAR_ZERO) return MathTools.getIdentityQuat(); 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 ea8a512b..3fc04881 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 @@ -1476,8 +1476,11 @@ public class PipingRules { double angle = 0.0; if (angleO != null) angle = angleO; - - Quat4d q = pcp.getControlPointOrientationQuat(angle); + Boolean reversedO = pcp.getReversed(); + boolean reversed = false; + if (reversedO != null) + reversed = reversedO; + Quat4d q = pcp.getControlPointOrientationQuat(angle, reversed); pcp.setWorldOrientation(q); } -- 2.47.1