17 : _mb(
mb ), _set( curve ), _gtt( gTool )
55 if( vsets.
size() == 1 )
95 if(
_leng <= 0 )
return 0;
96 return u_root + arc_leng /
_leng;
112 double prevFraction = 0;
117 double t = ( u - prevFraction ) / ( nextFraction - prevFraction );
131 double dtdu = 1 / ( nextFraction - prevFraction );
132 tg[0] = tangent[0] * dtdu;
133 tg[1] = tangent[1] * dtdu;
134 tg[2] = tangent[2] * dtdu;
177 std::vector< EntityHandle > nodesConnec;
178 nodesConnec.resize( nbNodes );
182 std::cout <<
"error in getting connectivity\n";
186 for(
int k = 0; k < nbNodes / 2; k++ )
188 nodesConnec[k + 1] = nodesConnec[2 * k + 1];
190 int numNodes = nbNodes / 2 + 1;
191 std::vector< CartVect > coordNodes;
192 coordNodes.resize( numNodes );
194 rval =
_mb->
get_coords( &( nodesConnec[0] ), numNodes, (
double*)&( coordNodes[0] ) );
197 std::cout <<
"error in getting node positions\n";
203 double minDist = 1.e30;
205 for(
int i = 0; i < numNodes; i++ )
207 double d1 = ( initialPos - coordNodes[i] ).
length();
218 v = nodesConnec[indexNode];
228 edgeIndex = indexNode;
229 if( edgeIndex == numNodes - 1 )
237 CartVect prevNodePos = coordNodes[edgeIndex - 1];
238 CartVect nextNodePos = coordNodes[edgeIndex + 1];
239 if( ( prevNodePos - initialPos ).length_squared() < ( nextNodePos - initialPos ).
length_squared() )
253 double t4, t3, t2, one_minus_t, one_minus_t2, one_minus_t3, one_minus_t4;
255 P[0] = coordNodes[edgeIndex];
256 P[1] = coordNodes[edgeIndex + 1];
270 int maxIterations = 10;
277 while( iterations < maxIterations )
283 one_minus_t = 1. - tt;
284 one_minus_t2 = one_minus_t * one_minus_t;
285 one_minus_t3 = one_minus_t2 * one_minus_t;
286 one_minus_t4 = one_minus_t3 * one_minus_t;
288 outv = one_minus_t4 * P[0] + 4. * one_minus_t3 * tt * controlPoints[0] +
289 6. * one_minus_t2 * t2 * controlPoints[1] + 4. * one_minus_t * t3 * controlPoints[2] + t4 * P[1];
291 CartVect out_tangent = -4. * one_minus_t3 * P[0] +
292 4. * ( one_minus_t3 - 3. * tt * one_minus_t2 ) * controlPoints[0] +
293 12. * ( tt * one_minus_t2 - t2 * one_minus_t ) * controlPoints[1] +
294 4. * ( 3. * t2 * one_minus_t - t3 ) * controlPoints[2] + 4. * t3 * P[1];
297 12. * one_minus_t2 * P[0] +
298 4. * ( -3. * one_minus_t2 - 3. * one_minus_t2 + 6. * tt * one_minus_t ) * controlPoints[0] +
299 12. * ( one_minus_t2 - 4 * tt * one_minus_t + t2 ) * controlPoints[1] +
300 4. * ( 6. * tt - 12 * t2 ) * controlPoints[2] + 12. * t2 * P[1];
302 double F_d = out_tangent % diff;
305 if( 0 == F_dd )
break;
307 double delta_t = -F_d / F_dd;
309 if( fabs( delta_t ) < 0.000001 )
break;
314 v = nodesConnec[edgeIndex];
320 v = nodesConnec[edgeIndex + 1];
327 double prevFraction = 0;
328 if( edgeIndex > 0 ) prevFraction =
_fractions[edgeIndex - 1];
330 u = prevFraction + tt * (
_fractions[edgeIndex] - prevFraction );
388 std::vector< EntityHandle >
entities;
404 for(
int i = 1; i < nbEdges; i++ )
421 previousEdge = currentEdge;
429 std::map< EntityHandle, SmoothFace* >& mapSurfaces,
430 Tag controlPointsTag,
440 std::vector< EntityHandle > faces;
441 std::vector< int > senses;
446 unsigned int numSurfacesAdjacent = faces.size();
456 std::vector< SmoothFace* > smoothFaceArray;
458 for( i = 0; i < numSurfacesAdjacent; i++ )
461 smoothFaceArray.push_back( sms );
468 CartVect ctrlP[3] = { zero, zero, zero };
475 if( rval !=
MB_SUCCESS || 2 != nnodes )
return;
500 for( i = 0; i < numSurfacesAdjacent; i++ )
503 rval = smoothFaceArray[i]->get_normals_for_vertices( conn2, N );
506 rval = smoothFaceArray[i]->init_edge_control_points( P[0], P[1], N[0], N[1], T[0], T[1], controlForEdge );
510 for(
int j = 0; j < 3; j++ )
512 ctrlP[j] += controlForEdge[j];
516 for(
int j = 0; j < 3; j++ )
518 ctrlP[j] /= numSurfacesAdjacent;
528 unsigned char used = 1;
532 assert(
_leng > 0. );
541 double t4, t3, t2, one_minus_t, one_minus_t2, one_minus_t3, one_minus_t4;
546 if( tt <= 0.0 ) tt = 0.0;
547 if( tt >= 1.0 ) tt = 1.0;
568 one_minus_t = 1. - tt;
569 one_minus_t2 = one_minus_t * one_minus_t;
570 one_minus_t3 = one_minus_t2 * one_minus_t;
571 one_minus_t4 = one_minus_t3 * one_minus_t;
573 outv = one_minus_t4 * P[0] + 4. * one_minus_t3 * tt * controlPoints[0] + 6. * one_minus_t2 * t2 * controlPoints[1] +
574 4. * one_minus_t * t3 * controlPoints[2] + t4 * P[1];
576 out_tangent = -4. * one_minus_t3 * P[0] + 4. * ( one_minus_t3 - 3. * tt * one_minus_t2 ) * controlPoints[0] +
577 12. * ( tt * one_minus_t2 - t2 * one_minus_t ) * controlPoints[1] +
578 4. * ( 3. * t2 * one_minus_t - t3 ) * controlPoints[2] + 4. * t3 * P[1];