- Vector3d branchLegEnd = p.getWorldPosition();
- Vector3d dir2 = new Vector3d(inlinePoint);
- dir2.sub(branchLegEnd);
- Vector3d dir1 = new Vector3d(nextPoint);
- dir1.sub(prevPoint);
- newInlinePoint = new Vector3d();
- double mu[] = new double[2];
- MathTools.intersectStraightStraight(new Vector3d(prevPoint), dir1, new Vector3d(branchLegEnd), dir2, newInlinePoint, new Vector3d(), mu);
- if (DEBUG)
- System.out.println(mu[0]);
- // FIXME : reserve space
- if (mu[0] < 0.0) {
- newInlinePoint = new Vector3d(prevPoint);
- } else if (mu[0] > 1.0) {
- newInlinePoint = new Vector3d(nextPoint);
+
+ // FIXME : can only handle one branch
+ PipeControlPoint p = null;
+ if (becp.getNext() != null) {
+ p = becp.findNextEnd();
+ } else if (becp.getPrevious() != null) {
+ p = becp.findPreviousEnd();
+ }
+ if (p == null) {
+ newInlinePoint = MathTools.closestPointOnEdge(new Vector3d(inlinePoint), prevPoint, nextPoint);
+ } else if (canCalc){
+ Vector3d branchLegEnd = p.getWorldPosition();
+ Vector3d dir2 = new Vector3d(inlinePoint);
+ dir2.sub(branchLegEnd);
+ Vector3d dir1 = new Vector3d(nextPoint);
+ dir1.sub(prevPoint);
+ newInlinePoint = new Vector3d();
+ double mu[] = new double[2];
+ MathTools.intersectStraightStraight(new Vector3d(prevPoint), dir1, new Vector3d(branchLegEnd), dir2, newInlinePoint, new Vector3d(), mu);
+ if (DEBUG)
+ System.out.println(mu[0]);
+ // FIXME : reserve space
+ if (mu[0] < 0.0) {
+ newInlinePoint = new Vector3d(prevPoint);
+ } else if (mu[0] > 1.0) {
+ newInlinePoint = new Vector3d(nextPoint);
+ }