From bd522622ca0d62dff1b2025680b042e7ffebc279 Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Mon, 9 Mar 2020 11:20:27 +0200 Subject: [PATCH] Use inside diameter for eccentric reducer offset calculation gitlab #104 Change-Id: I60b7056ac1bc30ecb85e46fd2b3cff4e3fcaf71d --- .../simantics/plant3d/scenegraph/InlineComponent.java | 2 +- .../src/org/simantics/plant3d/scenegraph/PipeRun.java | 4 ++++ .../plant3d/scenegraph/PipelineComponent.java | 10 +++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java index ca4ba836..ed4917df 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/InlineComponent.java @@ -157,7 +157,7 @@ public class InlineComponent extends PipelineComponent { private void updateOffset() { if (!componentCalculatedOffset && getControlPoint().isOffset()) { - getControlPoint().setOffset(getPipeRun().getPipeDiameter()*0.5 - getAlternativePipeRun().getPipeDiameter()*0.5); + getControlPoint().setOffset(getPipeRun().getInsideDiameter()*0.5 - getAlternativePipeRun().getInsideDiameter()*0.5); } } diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java index 0284d1c7..0a6e58c0 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipeRun.java @@ -120,6 +120,10 @@ public class PipeRun extends P3DParentNode { firePropertyChanged(Plant3D.URIs.HasPipeThickness); } + public double getInsideDiameter() { + return pipeDiameter - 2 * pipeThickness; + } + @RelatedElementsAdd(Plant3D.URIs.children) public void addChild(PipelineComponent node) { addNode(Plant3D.URIs.children,node); diff --git a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java index f0621fdd..6afa937d 100644 --- a/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java +++ b/org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/PipelineComponent.java @@ -616,8 +616,8 @@ public abstract class PipelineComponent extends GeometryNode { } // Calculate center of mass for the frustum - double r1 = getPipeRun().getPipeDiameter(); - double r2 = getAlternativePipeRun().getPipeDiameter(); + double r1 = getPipeRun().getInsideDiameter(); + double r2 = getAlternativePipeRun().getInsideDiameter(); Vector3d p1 = new Vector3d(), p2 = new Vector3d(); pcp.getInlineControlPointEnds(p1, p2); @@ -646,7 +646,7 @@ public abstract class PipelineComponent extends GeometryNode { double r = ((TurnComponent)this).getTurnRadius(); double a = pcp.getTurnAngle(); - double pipeRadius = pcp.getPipeRun().getPipeDiameter() / 2; + double pipeRadius = pcp.getPipeRun().getInsideDiameter() / 2; // Unit vector in inlet flow direction Vector3d inletDir = pcp.getPathLegDirection(Direction.PREVIOUS); @@ -686,7 +686,7 @@ public abstract class PipelineComponent extends GeometryNode { if (pcp == null) throw new IllegalStateException("No centroid defined"); - double pipeRadius = getPipeRun().getPipeDiameter() / 2; + double pipeRadius = getPipeRun().getInsideDiameter() / 2; switch (pcp.getType()) { case INLINE: @@ -698,7 +698,7 @@ public abstract class PipelineComponent extends GeometryNode { // Calculate center of mass for the frustum double r1 = pipeRadius; - double r2 = getAlternativePipeRun().getPipeDiameter() / 2; + double r2 = getAlternativePipeRun().getInsideDiameter() / 2; return pcp.getLength() * Math.PI * (r1*r1 + r1*r2 + r2*r2) / 4; case TURN: { double r = ((TurnComponent)this).getTurnRadius(); -- 2.47.1