]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.plant3d/src/org/simantics/plant3d/scenegraph/controlpoint/PipeControlPoint.java
New interfaces for volume and centroid calculation.
[simantics/3d.git] / org.simantics.plant3d / src / org / simantics / plant3d / scenegraph / controlpoint / PipeControlPoint.java
index cb4b57eb898eefcb69d2797ccb3a182570d6c2a9..6e6a595bc3cefddd0fdab8864efec31666ea3618 100644 (file)
@@ -167,6 +167,10 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
                return children.size() == 1 && children.get(0).isDualSub();
        }
 
+       public boolean isAxial() {
+               return isInline() && !isDualInline();
+       }
+
        public boolean isSizeChange() {
                return isSizeChange;
                //              if (children.size() == 0)
@@ -749,21 +753,25 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
        public void getInlineControlPointEnds(Tuple3d p1, Tuple3d p2) {
                assert (isInline());
 
-               Vector3d pos = getWorldPosition();
-               Vector3d dir = getPathLegDirection(Direction.NEXT);
+               PipeControlPoint sub = isAxial() ? this : getSubPoint().get(0);
+               Vector3d pos = getWorldPosition(), pos2 = sub == this ? pos : sub.getWorldPosition();
+               Vector3d dir = sub.getPathLegDirection(Direction.NEXT);
+               
                dir.normalize();
                dir.scale(length * 0.5);
                p1.set(pos);
-               p2.set(pos);
+               p2.set(pos2);
                p1.sub(dir);
                p2.add(dir);
        }
 
        public void getControlPointEnds(Tuple3d p1, Tuple3d p2) {
-               Vector3d pos = getWorldPosition();
+               PipeControlPoint sub = isAxial() ? this : getSubPoint().get(0);
+               Vector3d pos = getWorldPosition(), pos2 = sub == this ? pos : sub.getWorldPosition();
+               
                Vector3d dir1 = getPathLegDirection(Direction.PREVIOUS);
                dir1.normalize();
-               Vector3d dir2 = getPathLegDirection(Direction.NEXT);
+               Vector3d dir2 = sub.getPathLegDirection(Direction.NEXT);
                dir2.normalize();
                if (isInline()) {
                        dir1.scale(length * 0.5);
@@ -773,11 +781,22 @@ public class PipeControlPoint extends G3DNode implements IP3DNode {
                        dir2.scale(length);
                }
                p1.set(pos);
-               p2.set(pos);
+               p2.set(pos2);
                p1.add(dir1);
                p2.add(dir2);
        }
 
+       public void getEndDirections(Tuple3d v1, Tuple3d v2) {
+               PipeControlPoint sub = isAxial() ? this : getSubPoint().get(0);
+               
+               Vector3d dir1 = getPathLegDirection(Direction.PREVIOUS);
+               dir1.normalize();
+               Vector3d dir2 = sub.getPathLegDirection(Direction.NEXT);
+               dir2.normalize();
+               v1.set(dir1);
+               v2.set(dir2);
+       }
+
        public void getInlineControlPointEnds(Tuple3d p1, Tuple3d p2, Vector3d dir) {
                assert (isInline());