36 #include <strutils.hpp>
39 #include <atl\atlmod.h>
40 #include "smartvars.h"
41 #include "sldworks_tlb.h"
42 #include "swconst_tlb.h"
105 vector<TPL_RELATION_ENTITE<IFace2,MG_FACE> >::iterator i;
107 if ((*i).a==face)
return (*i).b;
113 vector<TPL_RELATION_ENTITE<ISurface,MG_SURFACE> >::iterator i;
115 if ((*i).a==surface)
return (*i).b;
121 vector<TPL_RELATION_ENTITE<IEdge,MG_ARETE> >::iterator i;
123 if ((*i).a==arete)
return (*i).b;
129 vector<TPL_RELATION_ENTITE<ICurve,MG_COURBE> >::iterator i;
131 if ((*i).a==courbe)
return (*i).b;
139 vector<TPL_RELATION_ENTITE<IVertex,MG_SOMMET> >::iterator i;
141 if ((*i).a==sommet)
return (*i).b;
156 CComQIPtr<IPartDoc> swPart;
159 swModel->EditRebuild3(&retour);
164 CComPtr <IModeler> swModeler ;
165 double OldToleranceValue;
167 swApp->IGetModeler(&swModeler);
168 swModeler->SetToleranceValue ( 0, Tolerance, &OldToleranceValue);
169 swModeler->SetToleranceValue ( 1, Tolerance, &OldToleranceValue);
170 swModeler->SetToleranceValue ( 2, Tolerance, &OldToleranceValue);
173 bool NouvelleCourbe =
false;
175 CComVariant vBodyArr;
176 swPart->GetBodies2(swSolidBody, VARIANT_TRUE, &vBodyArr);
177 SAFEARRAY* psaBody = V_ARRAY(&vBodyArr);
178 LPDISPATCH* pBodyDispArray = NULL;
179 long nBodyHighIndex = -1;
180 SafeArrayAccessData(psaBody, (
void **) &pBodyDispArray);
181 SafeArrayGetUBound(psaBody, 1, &nBodyHighIndex);
183 long nb_sld_corps = nBodyHighIndex + 1;
190 std::map < std::string , MG_SOMMET* > lst_vertices;
191 std::map < std::string , MG_SOMMET* >::iterator it_lst_vertices;
192 std::map < std::string , MG_ARETE* > lst_edges;
193 std::map < std::string , MG_ARETE* >::iterator it_lst_edges;
197 for (
long i=0;i<nb_sld_corps;i++)
199 CComQIPtr <IBody2> swBody;
200 swBody = pBodyDispArray[i];
202 swBody->GetType(&tipe);
204 swBody->get_Visible(&visible) ;
205 if (tipe ==0 && visible != 0 )
215 std::multimap < std::string , CComPtr <IFace2> > lst_faces;
216 std::multimap < std::string , CComPtr <IFace2> >::iterator it_face;
219 CComPtr <IFace2> swFace;
220 swBody->IGetFirstFace(&swFace);
223 CComPtr<IFace2> swFace_Next;
224 std::string idoriginal = fonction.
GetID(swFace.p).c_str();
225 if ( lst_faces.find(idoriginal) == lst_faces.end() )
226 lst_faces.insert(std::make_pair( idoriginal , swFace) );
227 swFace->IGetNextFace(&swFace_Next);
229 swFace = swFace_Next;
233 for (it_face = lst_faces.begin(); it_face != lst_faces.end(); it_face++)
235 swFace = it_face->second;
238 CComPtr <ISurface> swSurf ;
239 swFace->IGetSurface(&swSurf);
244 sprintf(
id,
"%s",fonction.
GetID(swFace.p).c_str());
246 CComPtr <IEntity> ent;
248 WideString acstostr(
id);
249 BSTR nom=BSTR(acstostr);
250 CComQIPtr <IPartDoc> swPart;
252 swPart->IGetEntityByName ( nom, swSelFACES , &ent ) ;
260 mgsurface=sldSurface;
268 swFace->FaceInSurfaceSense( &retval ) ;
275 mgface=
new MG_FACE(fonction.
GetID(swFace).c_str(),mgsurface,sens);
281 swFace->GetLoopCount(&nb_loop);
282 CComPtr <ILoop2> swLoop;
283 CComPtr <ILoop2> swNextLoop;
284 swFace->IGetFirstLoop(&swLoop);
286 for (
long k=0;k<nb_loop;k++)
292 CComPtr <ICoEdge> swCoArete;
293 CComPtr <ICoEdge> nextCoArete;
295 swLoop->IGetFirstCoEdge(&swCoArete);
298 swLoop->GetEdgeCount(&nbedge);
299 for (
long l=0;l<nbedge;l++)
301 CComPtr<IEdge> swArete;
302 CComPtr<ICurve> swCourbe;
303 swCoArete->IGetEdge (&swArete);
304 swArete->IGetCurve (&swCourbe);
306 NouvelleCourbe =
false;
310 sprintf(
id,
"%s",fonction.
GetID(swArete.p).c_str());
312 CComPtr<IEdge> swEdgeTemp;
316 if ( swEdgeTemp != 0)
319 sldcourbe=
new SLD_COURBE(
id, fonction, swArete);
324 NouvelleCourbe =
true;
326 CComPtr<IVertex> swSommet1;
327 CComPtr<IVertex> swSommet2;
328 swArete->IGetStartVertex( &swSommet1 );
333 swArete->IGetEndVertex ( &swSommet2 ) ;
338 strcpy(
id,fonction.
GetID(swSommet1.p).c_str());
339 it_lst_vertices = lst_vertices.find(
id);
340 if ( it_lst_vertices != lst_vertices.end())
341 mgsom1 = it_lst_vertices->second;
345 CComPtr<IVertex> swVertexTemp;
347 if (swVertexTemp == 0)
350 swSommet1->GetPoint(&vretval) ;
351 SafeDoubleArray retval(vretval);
352 double xyz[3]={retval[0],retval[1],retval[2]};
365 lst_vertices[id]=mgsom1;
375 strcpy(
id,fonction.
GetID(swSommet2.p).c_str());
376 it_lst_vertices = lst_vertices.find(
id);
377 if ( it_lst_vertices != lst_vertices.end())
378 mgsom2 = it_lst_vertices->second;
382 CComPtr<IVertex> swVertexTemp;
384 if (swVertexTemp == 0)
387 swSommet2->GetPoint(&vretval) ;
388 SafeDoubleArray retval(vretval);
389 double xyz[3]={retval[0],retval[1],retval[2]};
401 lst_vertices[id]=mgsom2;
429 strcpy(
id,fonction.
GetID(swArete.p).c_str());
430 it_lst_edges = lst_edges.find(
id);
431 if (it_lst_edges != lst_edges.end())
432 mgarete = it_lst_edges->second;
439 swArete->IsParamReversed ( &isRev );
445 mgarete=
new MG_ARETE(
id,mgcourbe,sens);
446 lst_edges[id]=mgarete;
458 swCoArete->GetSense(&ret) ;
468 swCoArete->IGetNext(&nextCoArete);
469 swCoArete = nextCoArete;
470 nextCoArete.Release();
475 swLoop->IGetNext(&swNextLoop);
477 swNextLoop.Release();
493 CComPtr <IFeature> swFeat;
494 CComPtr <IFeature> swNextFeat;
495 VARIANT_BOOL bSupprime;
498 CComPtr <IEntity> ent;
500 swPart->IFirstFeature(&swFeat);
504 swFeat->IsSuppressed(&bSupprime);
511 swFeat->GetTypeName(&NomFeat);
513 CComBSTR Compo1 (
"CompositeCurve.");
514 CComBSTR Compo2 (
"3DSplineCurve.");
517 if ((Compo1==NomFeat) || (Compo2==NomFeat))
519 CComPtr <IReferenceCurve> refCourbe;
520 CComPtr <IUnknown> Unk;
522 swFeat->IGetSpecificFeature(&Unk);
523 Unk->QueryInterface( IID_IReferenceCurve, (LPVOID*)&refCourbe);
525 CComPtr<IEdge> swArete;
526 refCourbe->IGetFirstSegment(&swArete);
536 sprintf(id3,
"%s",fonction.
GetID(swArete.p).c_str());
543 CComPtr <ICoEdge> swCoArete;
544 CComPtr<ICurve> swCourbe;
546 swArete->IGetCurve (&swCourbe);
548 NouvelleCourbe =
false;
552 sprintf(id4,
"%s",fonction.
GetID(swArete.p).c_str());
557 NouvelleCourbe =
true;
560 CComPtr<IVertex> swSommet1;
561 CComPtr<IVertex> swSommet2;
562 swArete->IGetStartVertex( &swSommet1 );
573 strcpy(
id,fonction.
GetID(swSommet1.p).c_str());
574 it_lst_vertices = lst_vertices.find(
id);
575 if ( it_lst_vertices != lst_vertices.end())
576 mgsom1 = it_lst_vertices->second;
580 sprintf(
id,
"%s",fonction.
GetID(swSommet1.p).c_str());
590 swArete->IGetEndVertex ( &swSommet2 );
595 strcpy(id22,fonction.
GetID(swSommet2.p).c_str());
596 it_lst_vertices = lst_vertices.find(id22);
597 if ( it_lst_vertices != lst_vertices.end())
598 mgsom2 = it_lst_vertices->second;
633 strcpy(id2,fonction.
GetID(swArete.p).c_str());
634 it_lst_edges = lst_edges.find(id2);
635 if (it_lst_edges != lst_edges.end())
636 mgarete = it_lst_edges->second;
641 swArete->IsParamReversed ( &isRev );
647 mgarete=
new MG_ARETE(id2,mgcourbe,sens);
672 refCourbe->IGetNextSegment(&swArete);
677 swFeat->IGetNextFeature(&swNextFeat);
679 swNextFeat.Release();
698 swPart->GetBodies2(swSheetBody,
true,&vBodyArr) ;
699 psaBody = V_ARRAY(&vBodyArr);
700 pBodyDispArray = NULL;
702 SafeArrayAccessData(psaBody, (
void **) &pBodyDispArray);
703 SafeArrayGetUBound(psaBody, 1, &nBodyHighIndex);
704 long nb_sld_coque = nBodyHighIndex + 1;
706 for (
long i=0;i<nb_sld_coque;i++)
709 CComQIPtr <IBody2> swBody;
710 swBody = pBodyDispArray[i];
720 std::multimap < std::string , CComPtr <IFace2> > lst_facesCoque;
721 std::multimap < std::string , CComPtr <IFace2> >::iterator it_faceCoque;
723 CComPtr <IFace2> swFace;
724 swBody->IGetFirstFace(&swFace);
728 CComPtr<IFace2> swFace_Next;
729 std::string idoriginal = fonction.
GetID(swFace.p).c_str();
730 if ( lst_facesCoque.find(idoriginal) == lst_facesCoque.end() )
731 lst_facesCoque.insert(std::make_pair( idoriginal , swFace) );
732 swFace->IGetNextFace(&swFace_Next);
734 swFace = swFace_Next;
737 for (it_faceCoque = lst_facesCoque.begin(); it_faceCoque != lst_facesCoque.end(); it_faceCoque++)
739 CComPtr <ISurface> swSurf ;
740 swFace = it_faceCoque->second;
741 swFace->IGetSurface(&swSurf);
747 sprintf(id77,
"%s",fonction.
GetID(swFace.p).c_str());
749 mgsurface=sldSurface;
758 swFace->FaceInSurfaceSense( &retval ) ;
765 mgface=
new MG_FACE(fonction.
GetID(swFace).c_str(),mgsurface,sens);
771 swFace->GetLoopCount(&nb_loop);
772 CComPtr <ILoop2> swLoop;
773 CComPtr <ILoop2> swNextLoop;
774 swFace->IGetFirstLoop(&swLoop);
776 for (
long k=0;k<nb_loop;k++)
782 CComPtr <ICoEdge> swCoArete;
783 CComPtr <ICoEdge> nextCoArete;
785 swLoop->IGetFirstCoEdge(&swCoArete);
788 swLoop->GetEdgeCount(&nbedge);
789 for (
long l=0;l<nbedge;l++)
792 CComPtr<IEdge> swArete;
793 CComPtr<ICurve> swCourbe;
794 swCoArete->IGetEdge (&swArete);
795 swArete->IGetCurve (&swCourbe);
797 NouvelleCourbe =
false;
801 sprintf(
id,
"%s",fonction.
GetID(swArete.p).c_str());
806 NouvelleCourbe =
true;
808 CComPtr<IVertex> swSommet1;
809 CComPtr<IVertex> swSommet2;
810 swArete->IGetStartVertex( &swSommet1 );
816 swArete->IGetEndVertex ( &swSommet2 ) ;
821 strcpy(
id,fonction.
GetID(swSommet1.p).c_str());
822 it_lst_vertices = lst_vertices.find(
id);
823 if ( it_lst_vertices != lst_vertices.end())
824 mgsom1 = it_lst_vertices->second;
828 sprintf(
id,
"%s",fonction.
GetID(swSommet1.p).c_str());
842 strcpy(id22,fonction.
GetID(swSommet2.p).c_str());
843 it_lst_vertices = lst_vertices.find(id22);
844 if ( it_lst_vertices != lst_vertices.end())
845 mgsom2 = it_lst_vertices->second;
881 strcpy(id3,fonction.
GetID(swArete.p).c_str());
882 it_lst_edges = lst_edges.find(id3);
883 if (it_lst_edges != lst_edges.end())
884 mgarete = it_lst_edges->second;
889 swArete->IsParamReversed ( &isRev );
895 mgarete=
new MG_ARETE(fonction.
GetID(swArete.p).c_str(),mgcourbe,sens);
907 swCoArete->GetSense(&ret) ;
915 swCoArete->IGetNext(&nextCoArete);
916 swCoArete = nextCoArete;
917 nextCoArete.Release();
920 swLoop->IGetNext(&swNextLoop);
922 swNextLoop.Release();
937 CComQIPtr <IEntity> swEnt;
938 CComPtr <IAttribute> Attribut;
946 CComBSTR nomParam(
"CL.") ;
947 Attribut->IGetParameter ( nomParam, &ParamCL );
949 ParamCL->GetStringValue(&bchaineCL);
953 AnsiString rep(bchaineCL);
962 sscanf(cnombre,
"%ld",&inombre);
963 for (
int CL = 0;CL<inombre;CL++)
971 for (
int j = 0; j<13;j++)
973 ValeurCL[j] = *ptr++;
979 sscanf(ValeurCL,
"%le",&valeur);
994 CComQIPtr <IEntity> swEnt;
995 CComPtr <IAttribute> Attribut;
1003 IParameter* ParamCL;
1004 CComBSTR nomParam(
"CL.") ;
1005 Attribut->IGetParameter ( nomParam, &ParamCL );
1007 ParamCL->GetStringValue(&bchaineCL);
1011 AnsiString rep(bchaineCL);
1016 cnombre[0] = *ptr++;
1017 cnombre[1] = *ptr++;
1020 sscanf(cnombre,
"%ld",&inombre);
1021 for (
int CL = 0;CL<inombre;CL++)
1029 for (
int j = 0; j<13;j++)
1031 ValeurCL[j] = *ptr++;
1035 ValeurCL[13] =
'\0';
1037 sscanf(ValeurCL,
"%le",&valeur);
1044 swEnt->IFindAttribute (
DefAttrRCP1, 0, &Attribut ) ;
1046 if (Attribut !=NULL)
1048 IParameter* ParamAs;
1049 CComBSTR nomParamAs(
"As.") ;
1050 Attribut->IGetParameter ( nomParamAs, &ParamAs );
1052 ParamAs->GetDoubleValue(&valAs);
1054 IParameter* ParamI1;
1055 CComBSTR nomParamI1(
"I1.") ;
1056 Attribut->IGetParameter ( nomParamI1, &ParamI1 );
1058 ParamI1->GetDoubleValue(&valI1);
1060 IParameter* ParamI2;
1061 CComBSTR nomParamI2(
"I2.") ;
1062 Attribut->IGetParameter ( nomParamI2, &ParamI2 );
1064 ParamI2->GetDoubleValue(&valI2);
1070 IParameter* ParamNX;
1071 CComBSTR nomParamNX(
"X3.") ;
1072 Attribut->IGetParameter ( nomParamNX, &ParamNX );
1073 ParamNX->GetDoubleValue(&x);
1075 IParameter* ParamNY;
1076 CComBSTR nomParamNY(
"Y3.") ;
1077 Attribut->IGetParameter ( nomParamNY, &ParamNY );
1078 ParamNY->GetDoubleValue(&y);
1080 IParameter* ParamNZ;
1081 CComBSTR nomParamNZ(
"Z3.") ;
1082 Attribut->IGetParameter ( nomParamNZ, &ParamNZ );
1083 ParamNZ->GetDoubleValue(&z);
1116 CComQIPtr <IEntity> swEnt;
1117 CComPtr <IAttribute> Attribut;
1125 IParameter* ParamCL;
1126 CComBSTR nomParam(
"CL.") ;
1127 Attribut->IGetParameter ( nomParam, &ParamCL );
1129 ParamCL->GetStringValue(&bchaineCL);
1133 AnsiString rep(bchaineCL);
1138 cnombre[0] = *ptr++;
1139 cnombre[1] = *ptr++;
1142 sscanf(cnombre,
"%ld",&inombre);
1143 for (
int CL = 0;CL<inombre;CL++)
1151 for (
int j = 0; j<13;j++)
1153 ValeurCL[j] = *ptr++;
1157 ValeurCL[13] =
'\0';
1159 sscanf(ValeurCL,
"%le",&valeur);
1171 IParameter* ParamEP;
1172 CComBSTR nomParam(
"Ep.") ;
1173 Attribut->IGetParameter ( nomParam, &ParamEP );
1175 ParamEP->GetDoubleValue(&valEP);
1192 IParameter* ParamPo;
1193 CComBSTR nomParam(
"Po.") ;
1194 Attribut->IGetParameter ( nomParam, &ParamPo );
1196 ParamPo->GetDoubleValue(&valPo);
1210 CComQIPtr <IEntity> swEnt;
1211 CComPtr <IAttribute> Attribut;
1214 swEnt->IFindAttribute (
DefAttrRCP1, 0, &Attribut ) ;
1219 IParameter* ParamD1;
1220 CComBSTR nomParam(
"D1.") ;
1221 Attribut->IGetParameter ( nomParam, &ParamD1 );
1222 ParamD1->GetDoubleValue(&D1);
1240 VARIANT_BOOL retval;
1242 CComBSTR nom2 (
"ConditionLimite.");
1244 CComBSTR bCL (
"CL.");
1249 CComBSTR nom3 (
"Poutre1.");
1253 CComBSTR bAs (
"As.");
1254 CComBSTR bI1 (
"I1.");
1255 CComBSTR bI2 (
"I2.");
1256 CComBSTR bD1 (
"D1.");
1257 CComBSTR bD2 (
"D2.");
1258 CComBSTR bD3 (
"D3.");
1259 CComBSTR bD4 (
"D4.");
1260 CComBSTR bD5 (
"D5.");
1261 CComBSTR bD6 (
"D6.");
1262 CComBSTR bN3 (
"N3.");
1263 CComBSTR bX3 (
"X3.");
1264 CComBSTR bY3 (
"Y3.");
1265 CComBSTR bZ3 (
"Z3.");
1266 CComBSTR bFG (
"Flag.");
1286 CComBSTR nom4 (
"Coque.");
1288 CComBSTR bM2 (
"M.");
1289 CComBSTR bep (
"Ep.");
1290 CComBSTR bFl (
"Flag.");
1296 CComBSTR nom5 (
"FaceInterne.");
1298 CComBSTR bFI (
"FI.");
1299 CComBSTR bPo (
"Po.");
1305 CComBSTR nom6 (
"Doublon.");
1307 CComBSTR bMa (
"Maitre.");
1309 CComBSTR bSe (
"Sens.");