- PipeControlPoint endCP = endTo.getControlPoint();
- boolean reversed;
- if (current.getNext() == null)
- reversed = false;
- else if (current.getPrevious() == null)
- reversed = true;
- else
- return false;
-
- PipeRun pipeRun = current.getPipeRun();
- P3DRootNode root = (P3DRootNode)current.getRootNode();
- PipeControlPoint currentCP = current.getControlPoint();
-
- if (endType == null || endType == PositionType.NEXT || endType == PositionType.PREVIOUS) {
-
-
-
- boolean requiresReverse = false;
- if (!reversed && endCP.getPrevious() != null) {
- if (endCP.getNext() != null)
- return false;
- requiresReverse = true;
- } else if (reversed && endCP.getNext() != null) {
- if (endCP.getPrevious() != null)
- return false;
- requiresReverse = true;
- }
- PipeRun other = endCP.getPipeRun();
- boolean mergeRuns = other == null ? true : pipeRun.equalSpecs(other);
-
- if (requiresReverse) {
- // Pipe line must be traversible with next/previous relations without direction change.
- // Now the component, where we are connecting the created pipeline is defined in different order.
- PipingRules.reverse(other);
-
- }
- if (mergeRuns) {
- // Runs have compatible specs and must be merged
- if (other != null && pipeRun != other)
- PipingRules.merge(pipeRun, other);
- else if (other == null) {
- if (!(endTo instanceof Nozzle)) {
- pipeRun.addChild(endTo);
- } else {
- endTo.setPipeRun(pipeRun);
- }
- }
- if (!reversed) {
- currentCP.setNext(endCP);
- endCP.setPrevious(currentCP);
- } else {
- currentCP.setPrevious(endCP);
- endCP.setNext(currentCP);
- }
- } else {
- // Runs do not have compatible specs, and a reducer must be attached in between.
- InlineComponent reducer = ComponentUtils.createReducer(root);
- PipeControlPoint pcp = reducer.getControlPoint();
- PipeControlPoint ocp = pcp.getSubPoint().get(0);
-
- Vector3d endPos = endCP.getWorldPosition();
- Vector3d currentPos = currentCP.getWorldPosition();
- Vector3d v = new Vector3d(endPos);
- v.sub(currentPos);
- v.scale(0.5);
- v.add(currentPos);
-
- PipingRules.addSizeChange(reversed, pipeRun, other, reducer, currentCP, endCP);
-
- pcp.setWorldPosition(v);
- reducer.updateParameters();
- }
- PipingRules.positionUpdate(endCP);
- return true;
-
- } else if (endType == PositionType.SPLIT) {
- InlineComponent branchSplit = createBranchSplit((InlineComponent)endTo, position);
- if (branchSplit == null)
- return false;
- PipeControlPoint branchSplitCP = branchSplit.getControlPoint();
- PipeControlPoint pcp = new PipeControlPoint(branchSplit,pipeRun);
- branchSplitCP.children.add(pcp);
- pcp.parent = branchSplitCP;
- pcp.setWorldOrientation(branchSplitCP.getWorldOrientation());
- pcp.setWorldPosition(branchSplitCP.getWorldPosition());
-
-
- if(!reversed) {
- pcp.setPrevious(currentCP);
- currentCP.setNext(pcp);
- } else {
- pcp.setNext(currentCP);
- currentCP.setPrevious(pcp);
- }
- PipingRules.positionUpdate(endCP);
- return true;
- }
- return false;
+ PipeControlPoint endCP = endTo.getControlPoint();
+ boolean reversed;
+ if (current.getNext() == null)
+ reversed = false;
+ else if (current.getPrevious() == null)
+ reversed = true;
+ else
+ return false;
+
+ PipeRun pipeRun = current.getPipeRun();
+ P3DRootNode root = (P3DRootNode)current.getRootNode();
+ PipeControlPoint currentCP = current.getControlPoint();
+
+ if (endType == null || endType == PositionType.NEXT || endType == PositionType.PREVIOUS) {
+
+
+
+ boolean requiresReverse = false;
+ if (!reversed && endCP.getPrevious() != null) {
+ if (endCP.getNext() != null)
+ return false;
+ requiresReverse = true;
+ } else if (reversed && endCP.getNext() != null) {
+ if (endCP.getPrevious() != null)
+ return false;
+ requiresReverse = true;
+ }
+ PipeRun other = endCP.getPipeRun();
+ boolean mergeRuns = other == null ? true : pipeRun.equalSpecs(other);
+
+ if (requiresReverse) {
+ // Pipe line must be traversible with next/previous relations without direction change.
+ // Now the component, where we are connecting the created pipeline is defined in different order.
+ PipingRules.reverse(other);
+
+ }
+ if (mergeRuns) {
+ // Runs have compatible specs and must be merged
+ if (other != null && pipeRun != other)
+ PipingRules.merge(pipeRun, other);
+ else if (other == null) {
+ if (!(endTo instanceof Nozzle)) {
+ pipeRun.addChild(endTo);
+ } else {
+ endTo.setPipeRun(pipeRun);
+ }
+ }
+ if (!reversed) {
+ currentCP.setNext(endCP);
+ endCP.setPrevious(currentCP);
+ } else {
+ currentCP.setPrevious(endCP);
+ endCP.setNext(currentCP);
+ }
+ } else {
+ // Runs do not have compatible specs, and a reducer must be attached in between.
+ InlineComponent reducer = ComponentUtils.createReducer(root);
+ PipeControlPoint pcp = reducer.getControlPoint();
+ PipeControlPoint ocp = pcp.getSubPoint().get(0);
+
+ Vector3d endPos = endCP.getWorldPosition();
+ Vector3d currentPos = currentCP.getWorldPosition();
+ Vector3d v = new Vector3d(endPos);
+ v.sub(currentPos);
+ v.scale(0.5);
+ v.add(currentPos);
+
+ PipingRules.addSizeChange(reversed, pipeRun, other, reducer, currentCP, endCP);
+
+ pcp.setWorldPosition(v);
+ reducer.updateParameters();
+ }
+ PipingRules.positionUpdate(endCP);
+ return true;
+
+ } else if (endType == PositionType.SPLIT) {
+ InlineComponent branchSplit = createBranchSplit((InlineComponent)endTo, position);
+ if (branchSplit == null)
+ return false;
+ PipeControlPoint branchSplitCP = branchSplit.getControlPoint();
+ PipeControlPoint pcp = new PipeControlPoint(branchSplit,pipeRun);
+ branchSplitCP.children.add(pcp);
+ pcp.parent = branchSplitCP;
+ pcp.setWorldOrientation(branchSplitCP.getWorldOrientation());
+ pcp.setWorldPosition(branchSplitCP.getWorldPosition());
+
+
+ if(!reversed) {
+ pcp.setPrevious(currentCP);
+ currentCP.setNext(pcp);
+ } else {
+ pcp.setNext(currentCP);
+ currentCP.setPrevious(pcp);
+ }
+ PipingRules.positionUpdate(endCP);
+ return true;
+ }
+ return false;