47 #pragma package(smart_init)
95 return sqrt(dxyz[0]*dxyz[0]+dxyz[1]*dxyz[1]+dxyz[2]*dxyz[2]);
154 double tStart=(t1<t2)?t1:t2;
155 double tEnd=(t1>t2)?t1:t2;
169 double edge_length =
t_max;
172 for (std::vector<MG_SOMMET *>::iterator it_vertex =
lst_vertices.begin();
176 double vertex_point [3];
180 for (j = 0; j < 3; j++)
181 if (fabs(vertex_point[j] - __point[j]) > edge_length*precision)
186 unsigned iVertex = std::distance (
lst_vertices.begin(), it_vertex );
188 for (
unsigned k = 0; k < iVertex; k++)
199 unsigned iClosestEdge;
200 double tClosestEdge = 0;
201 double min_distance = 1E99;
203 for (std::vector <MG_ARETE *>::iterator it_edge =
lst_ref_edges.begin();
211 t_edge = func.
Find();
213 if (xEdge>1) t_edge = edge->
get_tmax();
214 if (xEdge<0) t_edge = edge->
get_tmin();
216 edge->
evaluer (t_edge, point );
218 if (distance < min_distance)
220 min_distance = distance;
221 iClosestEdge = std::distance (
lst_ref_edges.begin(), it_edge );
222 tClosestEdge = t_edge;
235 std::cout <<
" *** PolyCurve::est_sur_courbe : FONCTION NON IMPLEMENTE ***" << std::endl;
261 for (
int i=0;i<N;i++)
270 double *__t,
double *__dt,
bool __curvilinearLength
288 if ( __curvilinearLength ==
false )
290 *__dt = (t2 - t1) /
GetLength( __iEdge );
291 *__t = t1 + __s * (*__dt);
297 double increment = s/
t_max*(t2-t1)/40;
298 if (increment < 1E-4 * (t2-t1))
300 *__dt = (t2 - t1) /
GetLength( __iEdge );
301 *__t = t1 + __s * (*__dt);
306 *__dt = (*__t - t1) / s;
313 double *__s,
bool __curvilinearLength
326 if (__t < t1 - period*1E-6)
330 if ( __curvilinearLength ==
false)
333 *__s =
lst_length[__iEdge] * (__t-t1)/(t2-t1);
335 *__s =
lst_length[__iEdge] * (__t-t2)/(t1-t2);
370 std::vector<MG_SOMMET*>::iterator itV[2];
371 for (
int i=0; i<2; i++)
394 if ( iV[i] != 0 && iV[i]+1 != (
int)
lst_vertices.size() )
410 printf (
" Error in PolyCurve::InsertCurve : the curve requested to append is not connected to the existing polycurve\n");
414 if ( iV [iiVc] == 0 )
429 printf(
"PolyCurve::InsertCurve Error : the edge %lu is neither adjacent to end vertex nor to start vertex of polycurve %lu\n", __edge->
get_id(),
get_id());
431 printf(
"Edge Start vertex = %lu, End vertex = %lu\n",
V[0]->
get_id(),
V[1]->
get_id());
437 for (std::vector<double>::const_iterator it_length =
lst_length.begin();
440 t_max += (*it_length);
460 RefEdge_GetT(i, __s - s, __t, __dt, __curvilinearLength);
495 for (
unsigned k = 0; k < i; k++)
508 bool curvilinearLength =
false;
509 evaluer(__s, __X, curvilinearLength);
534 bool curvilinearLength =
false;
535 deriver(__s, __X, curvilinearLength);
543 for (
int i=0;i<3;i++) __X[i] = 1;
557 for (
int i = 0; i<3; i++)
565 bool curvilinearLength =
false;
578 if (__ddxyz)
for (
int i=0;i<3;i++) __ddxyz[i]=1;
579 if (__dxyz)
for (
int i=0;i<3;i++) __dxyz[i]=1;
589 for (
int i=0; i<3; i++)
595 for (
int i = 0; i<3; i++)
609 for (std::vector < MG_ARETE * >::const_iterator it = __polycurve.
lst_ref_edges.begin();
616 for (std::vector < MG_ARETE * >::reverse_iterator it = __polycurve.
lst_ref_edges.rbegin();
623 for (std::vector < MG_ARETE * >::const_iterator it = __polycurve.
lst_ref_edges.begin();
630 printf(
"PolyCurve::Merge Error : the polycurve %lu is neither adjacent to end vertex nor to start vertex of polycurve %lu\n", __polycurve.
get_id(),
get_id());
644 std::vector<MG_ARETE*> e;
645 std::vector<MG_SOMMET*> v;
646 std::vector<double> l;
649 for (
unsigned i=0; i<N; i++)
651 unsigned m = (i+k)%N;
652 unsigned n = (i+k+1)%N;
654 MG_SOMMET * lastV = (v.size()) ? v[v.size()-1] : 0;
655 if ( lastV && lastV == tempv )
659 for (
unsigned i=0; i+1<N; i++)
661 for (
unsigned i=0; i+1<N; i++)
672 if ( __s_min >= 0 && __s_max >= 0 )
673 return fabs (__s_min - __s_max);
719 bool curvilinearLength =
false;
721 inverser(__t, __point, precision, curvilinearLength);
761 o <<
"));" << std::endl;
769 std::vector<MG_ARETE*> &
786 std::ostringstream idoriginal;
787 idoriginal <<
"Vertex of "<< splitEdge->
get_idoriginal() <<
" split at t="<<tSplit;
789 *__splitVertex = splitVertex;
798 vertices[0][1] = splitVertex;
799 vertices[1][0] = splitVertex;
802 curves[0] = curves[1] = splitEdge->
get_courbe();
804 double verticesT[2][2];
805 verticesT[0][0] = splitEdge->
get_tmin();
806 verticesT[1][1] = splitEdge->
get_tmax();
807 verticesT[0][1] = verticesT[1][0] = tSplit;
815 std::ostringstream idoriginal;
817 idoriginal <<
" split with t0 " << verticesT[i][0] <<
" t1 " << verticesT[i][1];
818 edges[i] =
new MG_ARETE (idoriginal.str(), 0, curves[i], orientation);
831 int nb_split_edge_loops = 0;
832 MG_COARETE * split_edge_coedges[10], * coedges[20];
833 int nb_split_edge_coedges = 0, nb_coedges = 0;
839 for (
unsigned it_shells = 0; it_shells < nb_shells; it_shells++)
844 for (
unsigned it_coface = 0; it_coface < nb_coface; it_coface++)
850 for (
unsigned it_loop = 0; it_loop < nb_loop; it_loop++)
855 for (
unsigned it_edge = 0; it_edge < nb_edge; it_edge++)
861 if (edge == splitEdge)
863 split_edge_loops[ nb_split_edge_loops++ ] = loop;
864 split_edge_coedges[ nb_split_edge_coedges++ ] = coedge;
891 *__splitRefVertex = NULL;
892 __splitRefEdges[0]=__splitRefEdges[1]=NULL;
896 __polyCurve->
inverser(sSplitVertex,__xyz,1E-6);
899 double tEdge, dtEdge;
901 *__origRefEdge = __polyCurve->
GetRefEdge(index);
921 *__origRefEdge = NULL;
922 *__splitRefVertex = v[i];
923 __splitRefEdges[0] = __polyCurve->
GetRefEdge(index-1+i);
924 __splitRefEdges[1] = __polyCurve->
GetRefEdge(index+i);
927 for (
int k=0; k<2; k++)
930 __result[k] =
new PolyCurve ( __splitRefEdges[k] );
932 for (j = (k==0)?index-2+i:index+i+1; j >= 0 && j < __polyCurve->
GetRefEdgeCount(); j += -1+2*k)
933 __result[k]->InsertCurve(__polyCurve->
GetRefEdge(j));
939 if (*__splitRefVertex == NULL)
941 CAD4FE::SplitRefEdge(*__origRefEdge, v[0], v[1], __xyz, __refBody, __geom, __splitRefEdges, __splitRefVertex);
943 if ( __splitRefEdges[0]->get_cosommet1()->get_sommet() != v[0] && __splitRefEdges[0]->get_cosommet2()->get_sommet() != v[0] )
944 std::swap(__splitRefEdges[0], __splitRefEdges[1] );
950 __result[i] =
new PolyCurve ( __splitRefEdges[i] );
952 for (j = index-1+2*i; j >= 0 && j < __polyCurve->
GetRefEdgeCount(); j += -1+2*i)
953 __result[i]->InsertCurve(__polyCurve->
GetRefEdge(j));
957 if (__result[0]->get_sommet1() !=__result[1]->get_sommet1() &&__result[0]->get_sommet1() !=__result[1]->get_sommet2() &&
958 __result[0]->get_sommet2() !=__result[1]->get_sommet1() &&__result[0]->get_sommet2() !=__result[1]->get_sommet2())