From 5303ddc439764f9263054f519deab7f9f350d561 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Thu, 12 Mar 2020 15:39:46 +0200 Subject: [PATCH] Introduce orientToDirection() method to pipe control point gitlab #107 Change-Id: I5aacab0b0a25e5dcd695bfb92beeda24ddb37adc --- .../controlpoint/PipeControlPoint.java | 15 +++++++++++ .../scenegraph/controlpoint/PipingRules.java | 27 +++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java index c5bf29dd..fdb413ee 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java @@ -1614,6 +1614,21 @@ public class PipeControlPoint extends G3DNode implements IP3DNode { updateSubPoint(); } + public void orientToDirection(Vector3d dir) { + Double angleO = getRotationAngle(); + double angle = 0.0; + if (angleO != null) + angle = angleO; + boolean reversed = _getReversed(); + Quat4d q = null; + if (dir != null) { + q = getControlPointOrientationQuat(dir, angle, reversed); + } else { + q = getControlPointOrientationQuat(angle, reversed); + } + setWorldOrientation(q); + } + @Override public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()); 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 542534c3..776d38ab 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 @@ -294,7 +294,7 @@ public class PipingRules { scp.setWorldPosition(pos); Vector3d dir = new Vector3d(); dir.sub(pcp2.getWorldPosition(), pcp1.getWorldPosition()); - updateControlPointOrientation(scp, dir); + scp.orientToDirection(dir); scp.setLength(length); validate(scp.getPipeRun()); return scp; @@ -1638,7 +1638,7 @@ public class PipingRules { } else if (u.start.isEnd()) { updateEndComponentControlPoint(u.start, u.dir); } else if (u.start.isInline()) { - updateControlPointOrientation(u.start, u.dir); + u.start.orientToDirection(u.dir); } if (u.end.isTurn()) { //updateTurnControlPointTurn(u.end, u.end.getPrevious(), u.end.getNext()); @@ -1647,7 +1647,7 @@ public class PipingRules { } else if (u.end.isEnd()) { updateEndComponentControlPoint(u.end, u.dir); } else if (u.end.isInline()) { - updateControlPointOrientation(u.end, u.dir); + u.end.orientToDirection(u.dir); } } else { @@ -1776,7 +1776,7 @@ public class PipingRules { System.out.println(" " + newInlinePoint); icp.setWorldPosition(newInlinePoint); - updateControlPointOrientation(icp, dir); + icp.orientToDirection(dir); } /** @@ -1793,7 +1793,7 @@ public class PipingRules { System.out.println("PipingRules.updateEndComponentControlPoint() " + ecp); if (!ecp.isFixed()) // prevent overriding nozzle orientations.. - updateControlPointOrientation(ecp, dir); + ecp.orientToDirection(dir); for (PipeControlPoint pcp : ecp.getChildPoints()) { // TODO update position @@ -1801,21 +1801,6 @@ public class PipingRules { } } - private static void updateControlPointOrientation(PipeControlPoint pcp, Vector3d dir) { - Double angleO = pcp.getRotationAngle(); - double angle = 0.0; - if (angleO != null) - angle = angleO; - boolean reversed = pcp._getReversed(); - Quat4d q = null; - if (dir != null) { - q = pcp.getControlPointOrientationQuat(dir, angle, reversed); - } else { - q = pcp.getControlPointOrientationQuat(angle, reversed); - } - pcp.setWorldOrientation(q); - } - /** * Updates all branches when branch's position has been changed * @@ -1881,7 +1866,7 @@ public class PipingRules { tcp.setTurnAxis(new Vector3d(MathTools.Y_AXIS)); } - updateControlPointOrientation(tcp,prev); + tcp.orientToDirection(prev); if (DEBUG) System.out.println("PipingTools.updateTurnControlPointTurn " + prev + " " + next + " " + turnAngle + " " + turnAxis); -- 2.47.1