Model Specifications - externalRadius - internalRadius - height - center Build Cylinder's Profile -> Create characteristic points with their coordinates (en utilisant soit la classe gp_Pnt, soit la classe Geom_CartesianPoint) exemple -rayon,0,0 +rayon,0,0 0,-rayon,0 0,+rayon,0 NB gp_Pnt is manipulated by value. Like all objects of its kind, it will have a limited lifetime. Geom_CartesianPoint is manipulated by handle and may have multiple references and a long lifetime. Since all the points you will define are only used to create the profile's curves, an object with a limited lifetime will do. gp_Pnt aPnt1(-myWidth / 2., 0, 0); -> Defining the Geometry (tracer des traits qui rejoignent les points) NB Geom_Circle Handle(Geom_TrimmedCurve) aArcOfCircle = GC_MakeArcOfCircle(aPnt2,aPnt3,aPnt4); y a prob moyen de ne pas avoir à définir 4 points, faudra regarder dans Geom_Circle sinon la ligne d'avant devrait suffire All GC classes provide a casting method to obtain a result automatically with a function-like call. Note that this method will raise an exception if construction has failed. To handle possible errors more explicitly, you may use the IsDone and Value methods. exemple GC_MakeSegment mkSeg (aPnt1, aPnt2); Handle(Geom_TrimmedCurve) aSegment1; if(mkSegment.IsDone()){ aSegment1 = mkSeg.Value(); } else { // handle error } -> Defining the Topology NB on a créé des lignes sans lien entre elles, on devrait pouvoir les manipuler comme une unique entité TopoDS définit des relations entre entités geometriques qui peuvent être reliées SEE https://www.opencascade.com/doc/occt-6.9.1/overview/html/occt__tutorial.html#sec1 le tableau on a besoin des TopoDS_Edges et des TopoDS_Wire (câble) pour relier les Edges NB BRepBuilderAPI_MakeEdge exemple TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1); TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aPnt1, aPnt3); NB BRepBuilderAPI_MakeWire example TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(aEdge1, aEdge2, aEdge3); -> completing the profile (ils font une reflection qui permet d'obtenir l'autre côté, on en aura pas besoin nous pour notre cylindre creux) NB compute a new wire by reflecting the existing one. add the reflected wire to the initial one. Build the Cylinder's Body NB Prism Your current profile is a wire. Referring to the Shape/Generates table, you need to compute a face out of its wire to generate a solid. ça veut dire que tu dois avoir une surface et pas juste un câble si tu veux pouvoir creer un volume BRepBuilderAPI_MakeFace exemple TopoDS_Face myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile); SEE The BRepPrimAPI package provides all the classes to create topological primitive constructions: boxes, cones, cylinders, spheres, etc. NB BRepPrimAPI_MakePrism le prisme est définit par une surface et un vecteur indiquant une direction de propagation (avec la hauteur donc) exemple gp_Vec aPrismVec(0, 0, myHeight); TopoDS_Shape myBody = BRepPrimAPI_MakePrism(myFaceProfile, aPrismVec); Applying Fillets (ça nous interesse pas, c'est un espece de bord plus doux) Build the Threading on the Cylinder's Neck (ça servira pour les vis) NB en gros ce qu'ils font c'est qu'ils créent des courbes et ces courbes une fois rejointes forment un solide les deux premieres lignes forment le bord exterieur et les deux suivantes sont le debut de l'extrusion par rapport à l'ouverture de la bouteille (c'est plus facile visuellement) puis ce solide est ajouté à l'ouverture de la bouteille Creating a Hollowed Solid (pour que le bouchon soit creux) SEE Thick Solid NB BRepOffsetAPI_MakeThickSolid ça a besoin d'une forme, d'une tolerance (pas compris), l'epaisseur(thickness) et la face à retirer du solide original faut remettre dans le contexte de la bouteille, ils avaient deux parties(wall) et ils veulent retirer à un côté pour impacter l'autre par reflection, si j'ai bien compris on peut itérer sur les surfaces pour trouver celle qui nous convient exemple for(TopExp_Explorer aFaceExplorer(myBody, TopAbs_FACE) ; aFaceExplorer.More() ; aFaceExplorer.Next()){ TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current()); } NB BRep_Tool pour obtenir des informations sur les proprietes geometriques des faces exemple Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace); NB BRep_Tool::Surface method returns an instance of the Geom_Surface class manipulated by handle. However, the Geom_Surface class does not provide information about the real type of the object aSurface, which could be an instance of Geom_Plane, Geom_CylindricalSurface, etc DynamicType to know the real type of the object IsKind to know if the object inherits from one particular type DynamicType returns the real type of the object, but you need to compare it with the existing known types to determine whether aSurface is a plane, a cylindrical surface or some other type. exemple if(aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane)){ // } NB If this comparison is true, you know that the aSurface real type is Geom_Plane. You can then convert it from Geom_Surface to Geom_Plane by using the DownCast() method provided by each class inheriting Standard_Transient exemple Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface); NB Remember that the goal of all these conversions is to find the highest face of the bottle lying on a plane You can easily find the plane whose origin is the biggest in Z knowing that the location of the plane is given with the Geom_Plane::Location method exemple gp_Pnt aPnt = aPlane->Location(); Standard_Real aZ = aPnt.Z(); if(aZ > zMax){ //zMax est un Standard_Real valant -1 à l'initialisation zMax = aZ; faceToRemove = aFace; //faceToRemove est un TopoDS_Face } NB the BRepOffsetAPI_MakeThickSolid constructor takes a list of faces as arguments parce qu'on peut retirer plusieurs faces à la fois, donc on doit foutre la face dans une liste exemple TopTools_ListOfShape facesToRemove; facesToRemove.Append(faceToRemove); MyBody = BRepOffsetAPI_MakeThickSolid(myBody, facesToRemove, -myThickness / 50, 1.e-3); Build the Result Compound Mon algo...DE CYLINDRE CREUX TopoDS_Shape MakeHollowCylinder(const Standard_Real myRadius, const Standard_Real myHeight, const Standard_Real myThickness) { // Profile : Define Support Points gp_Pnt aPnt1(-myRadius / 2., 0, 0); gp_Pnt aPnt2( myRadius / 2., 0, 0); gp_Pnt aPnt3( 0, -myRadius / 2., 0); // Profile : Define the Geometry Handle(Geom_TrimmedCurve) anArcOfCircle = GC_MakeArcOfCircle(aPnt1,aPnt2,aPnt3); // Profile : Define the Topology TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(anArcOfCircle); TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge2); // Complete Profile gp_Ax1 xAxis = gp::OX(); // origine 0,0,0 avec dir 1,0,0 gp_Trsf aTrsf; aTrsf.SetMirror(xAxis); // ok j'ai pas compris, il definit pas de plan pour sa reflection du coup ...? et du coup c'est pour obtenir une matrice de transformation ?? donc on se limite au plan du câble et on fait une reflection par rapport à l'axe.. okok BRepBuilderAPI_Transform aBRepTrsf(aWire, aTrsf); // application de la matrice supposée TopoDS_Shape aMirroredShape = aBRepTrsf.Shape(); TopoDS_Wire aMirroredWire = TopoDS::Wire(aMirroredShape); BRepBuilderAPI_MakeWire mkWire; mkWire.Add(aWire); mkWire.Add(aMirroredWire); TopoDS_Wire myWireProfile = mkWire.Wire(); // Body : Prism the Profile // bordel y a pas de constructeur entre plusieurs wires, en gros je peux faire entre une surface et un wire puis rajouter d'autres wire mais ce faisant j'obtiens plutôt une grande surface plutôt qu'une bande circulaire (je crois?) TopoDS_Face myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile); gp_Vec aPrismVec(0, 0, myHeight); TopoDS_Shape myBody = BRepPrimAPI_MakePrism(myFaceProfile, aPrismVec); // Body : Create a Hollowed Solid TopoDS_Face faceTopToRemove; TopoDS_Face faceBotToRemove; Standard_Real zMax = -1; Standard_Real zMin = 1; for(TopExp_Explorer aFaceExplorer(myBody, TopAbs_FACE); aFaceExplorer.More(); aFaceExplorer.Next()){ //TopAbs_FACE doit etre un param TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current()); // Check if is the top face of the bottle's neck Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace); if(aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane)){ Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface); gp_Pnt aPnt = aPlane->Location(); Standard_Real aZ = aPnt.Z(); if(aZ > zMax){ zMax = aZ; faceTopToRemove = aFace; } if(aZ < zMin){ zMin = aZ; faceBotToRemove = aFace; } } } TopTools_ListOfShape facesToRemove; facesToRemove.Append(faceTopToRemove); facesToRemove.Append(faceBotToRemove); myBody = BRepOffsetAPI_MakeThickSolid(myBody, facesToRemove, -myThickness , 1.e-3); // à quoi correspond le 1.e-3 ? // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, myBody); return aRes; } Mon algo...DE CÔNE CREUX SANS TÊTE TopoDS_Shape MakeHollowCylinder(const Standard_Real myRadius, const Standard_Real myHeight, const Standard_Real myHeadRadius, const Standard_Real myThickness) { //EXTERIOR PART gp_Pnt aPnt11(-myRadius / 2., 0, 0); gp_Pnt aPnt12(-myHeadRadius/ 2., 0, myHeight); // INTERIOR PART gp_Pnt aPnt21(-myRadius / 2. - myThickness, 0, 0); gp_Pnt aPnt22(-myHeadRadius/ 2. - myThickness, 0, myHeight); // Profile : Define the Geometry Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(aPnt11, aPnt22); Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(aPnt12, aPnt21); Handle(Geom_TrimmedCurve) aSegment3 = GC_MakeSegment(aPnt21, aPnt22); Handle(Geom_TrimmedCurve) aSegment4 = GC_MakeSegment(aPnt22, aPnt11); // Profile : Define the Topology TopoDS_Edge anEdge1 = BRepBuilderAPI_MakeEdge(aSegment1); TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(aSegment2); TopoDS_Edge anEdge3 = BRepBuilderAPI_MakeEdge(aSegment3); TopoDS_Edge anEdge4 = BRepBuilderAPI_MakeEdge(aSegment4); TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge1, anEdge2, anEdge3, anEdge4); // Complete Profile gp_Ax1 xAxis = gp::OX(); // origine 0,0,0 avec dir 1,0,0 TopoDS_Face F = BRepBuilderAPI_MakeFace(aWire); TopoDS_Solid aRotatedShape = BRepPrimAPI_MakeRevol(F,xAxis,2*PI); // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, aRotatedShape); return aRes; } Mon algo...DE PYRAMIDE TRONQUEE DECALEE TopoDS_Shape MakeHollowCylinder(const Standard_Real W, const Standard_Real w, const Standard_Real H, const Standard_Real alpha=0) { // initialisation e=(W-w)/2; x=sqrt(e*e+H*H); d=x*cos(alpha); // LEFT PART gp_Pnt aPnt11(0, 0, 0); gp_Pnt aPnt12(W, 0, 0); gp_Pnt aPnt13(W/2-d-w/2, e, H); gp_Pnt aPnt14(W/2-d+w/2, e, H); // RIGHT PART gp_Pnt aPnt21(0, W, 0); gp_Pnt aPnt22(W, W, 0); gp_Pnt aPnt23(W/2-d-w/2, e+w, H); gp_Pnt aPnt24(W/2-d+w/2, e+w, H); // Profile : Define the Geometry of the left Handle(Geom_TrimmedCurve) aSegment11 = GC_MakeSegment(aPnt11, aPnt12); Handle(Geom_TrimmedCurve) aSegment12 = GC_MakeSegment(aPnt12, aPnt13); Handle(Geom_TrimmedCurve) aSegment13 = GC_MakeSegment(aPnt13, aPnt14); Handle(Geom_TrimmedCurve) aSegment14 = GC_MakeSegment(aPnt14, aPnt11); // Profile : Define the Geometry of the right Handle(Geom_TrimmedCurve) aSegment21 = GC_MakeSegment(aPnt21, aPnt22); Handle(Geom_TrimmedCurve) aSegment22 = GC_MakeSegment(aPnt22, aPnt23); Handle(Geom_TrimmedCurve) aSegment23 = GC_MakeSegment(aPnt23, aPnt24); Handle(Geom_TrimmedCurve) aSegment24 = GC_MakeSegment(aPnt24, aPnt21); // Profile : Define the Topology of the left TopoDS_Edge anEdge11 = BRepBuilderAPI_MakeEdge(aSegment11); TopoDS_Edge anEdge12 = BRepBuilderAPI_MakeEdge(aSegment12); TopoDS_Edge anEdge13 = BRepBuilderAPI_MakeEdge(aSegment13); TopoDS_Edge anEdge14 = BRepBuilderAPI_MakeEdge(aSegment14); // Profile : Define the Topology of the right TopoDS_Edge anEdge21 = BRepBuilderAPI_MakeEdge(aSegment21); TopoDS_Edge anEdge22 = BRepBuilderAPI_MakeEdge(aSegment22); TopoDS_Edge anEdge23 = BRepBuilderAPI_MakeEdge(aSegment23); TopoDS_Edge anEdge24 = BRepBuilderAPI_MakeEdge(aSegment24); TopoDS_Wire aWire1 = BRepBuilderAPI_MakeWire(anEdge11, anEdge12, anEdge13, anEdge14); TopoDS_Wire aWire2 = BRepBuilderAPI_MakeWire(anEdge21, anEdge22, anEdge23, anEdge24); TopoDS_Face F1 = BRepBuilderAPI_MakeFace(aWire1); TopoDS_Face F2 = BRepBuilderAPI_MakeFace(aWire2); BRepBuilderAPI_Sewing Sew; Sew.Add(F1); Sew.Add(F2); Sew.Perform(); TopoDS_Shape result= Sew.SewedShape(); return result; } Mon algo...DE VIS TopoDS_Shape MakeHollowCylinder(const Standard_Real widthBase, const Standard_Real diameter, const Standard_Real lengthVis, const Standard_Real pas, const Standard_Real heightBase, const Standard_Real profondeurSillon, const Standard_Real longueurSillon) { // BASE PART gp_Pnt aPnt11(0, 0, 0); gp_Pnt aPnt12(widthBase, 0, 0); gp_Pnt aPnt13(widthBase, 0, heightBase); gp_Pnt aPnt14(0, 0, heightBase); // Profile : Define the Geometry of the base Handle(Geom_TrimmedCurve) aSegment11 = GC_MakeSegment(aPnt11, aPnt12); Handle(Geom_TrimmedCurve) aSegment12 = GC_MakeSegment(aPnt12, aPnt13); Handle(Geom_TrimmedCurve) aSegment13 = GC_MakeSegment(aPnt13, aPnt14); Handle(Geom_TrimmedCurve) aSegment14 = GC_MakeSegment(aPnt14, aPnt11); // Profile : Define the Topology of the base TopoDS_Edge anEdge11 = BRepBuilderAPI_MakeEdge(aSegment11); TopoDS_Edge anEdge12 = BRepBuilderAPI_MakeEdge(aSegment12); TopoDS_Edge anEdge13 = BRepBuilderAPI_MakeEdge(aSegment13); TopoDS_Edge anEdge14 = BRepBuilderAPI_MakeEdge(aSegment14); TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge11, anEdge12, anEdge13, anEdge14); TopoDS_Face F = BRepBuilderAPI_MakeFace(aWire); gp_Ax1 xAxis = gp::OX(); // origine 0,0,0 avec dir 1,0,0 TopoDS_Solid aSolid = BRepPrimAPI_MakeRevol(F,xAxis,2*PI); // on ajoute la vis gp_Pnt visLocation(0, 0, heightBase); gp_Dir visAxis = gp::DZ(); gp_Ax2 visAx(neckLocation, visAxis); BRepPrimAPI_MakeCylinder MKCylinder(visAx, diameter/2, lengthVis); TopoDS_Shape myVis = MKCylinder.Shape(); aSolid = BRepAlgoAPI_Fuse(aSolid, myVis); // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, aSolid); // Threading : Define 2D Curves gp_Pnt2d aPnt(2. * M_PI * diameter/2, heightVis-longueurSillon); // on veut que (distance)longueurSillon de vis, et donc on doit definir à quelle hauteur on commence gp_Dir2d aDir(2. * M_PI * diameter/2, longueurSillon ); // probablement une erreur avec diameter/2 mais je comprends pas prk ce serait pas ça gp_Ax2d anAx2d(aPnt, aDir); // on définit un axe de rotation Standard_Real aMajor = 2. * M_PI * diameter/2; Standard_Real aMinor = longueurSillon / 10; Handle(Geom2d_Ellipse) anEllipse1 = new Geom2d_Ellipse(anAx2d, aMajor, aMinor); Handle(Geom2d_Ellipse) anEllipse2 = new Geom2d_Ellipse(anAx2d, aMajor, aMinor / 4); Handle(Geom2d_TrimmedCurve) anArc1 = new Geom2d_TrimmedCurve(anEllipse1, 0, M_PI); Handle(Geom2d_TrimmedCurve) anArc2 = new Geom2d_TrimmedCurve(anEllipse2, 0, M_PI); gp_Pnt2d anEllipsePnt1 = anEllipse1->Value(0); gp_Pnt2d anEllipsePnt2 = anEllipse1->Value(M_PI); Handle(Geom2d_TrimmedCurve) aSegment = GCE2d_MakeSegment(anEllipsePnt1, anEllipsePnt2); // Threading : Build Edges and Wires TopoDS_Edge anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(anArc1, aCyl1); TopoDS_Edge anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment, aCyl1); TopoDS_Edge anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(anArc2, aCyl2); TopoDS_Edge anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment, aCyl2); TopoDS_Wire threadingWire1 = BRepBuilderAPI_MakeWire(anEdge1OnSurf1, anEdge2OnSurf1); TopoDS_Wire threadingWire2 = BRepBuilderAPI_MakeWire(anEdge1OnSurf2, anEdge2OnSurf2); BRepLib::BuildCurves3d(threadingWire1); BRepLib::BuildCurves3d(threadingWire2); // Create Threading BRepOffsetAPI_ThruSections aTool(Standard_True); aTool.AddWire(threadingWire1); aTool.AddWire(threadingWire2); aTool.CheckCompatibility(Standard_False); TopoDS_Shape myThreading = aTool.Shape(); // Building the Resulting Compound aBuilder.Add (aRes, myThreading); return aRes; } Mon algo...DE PIERCED HOLLOWED CYLINDER TopoDS_Shape MakeHollowCylinder(const Standard_Real myRadius, const Standard_Real myHeight, const Standard_Real myThickness, const Standard_Real myRadius2, const Standard_Real myHeight2, const Standard_Real myThickness2, const Standard_Real pierceHeight) { // on crée le premier cylindre TopoDS_Shape hollowCylinder1 = MakeHollowCylinder(myRadius, myHeight, myThickness); // on crée le second cylindre qui va percer le premier BRepPrimAPI_MakeCylinder myCylinder( gp_Ax2( gp_Pnt(0,0,0), gp::DZ()), myRadius2, (myThickness+(myRadius-myThickness)/2)*2 ); // on met plus que la thickness pour avoir un trou suffisamment profond (mais faut pas trop rajouter sinon ça peut foutre la merde) TopoDS_Shape cylinder = myCylinder.Shape(); // le cylindre creux qu'on va fuse TopoDS_Shape hollowCylinder2 = MakeHollowCylinder(myRadius2, myHeight2,myThickness2); // rotation gp_Pnt aOrigin(0, 0, myHeight2/2); gp_Dir yDir(0, 1, 0); gp_Ax1 yAxis(aOrigin, yDir); gp_Trsf aTrsf; aTrsf.SetRotation(yAxis,PI/2); // j'avais pas mit d'angle, jsuppose que c'est ça BRepBuilderAPI_Transformation theTrsf(aTrsf); theTrsf.Perform(hollowCylinder2); theTrsf.Perform(cylinder); // deplacement gp_Vec V( gp_Pnt(0,0,myHeight2/2), gp_Pnt(myRadius,0,pierceHeight) ); gp_Trsf aTrsf; aTrsf.SetTranslation(V); BRepBuilderAPI_Transformation theTrsf(aTrsf); theTrsf.Perform(hollowCylinder2); theTrsf.Perform(cylinder); // piercing and fusing TopoDS_Shape S = BRepAlgoAPI_Cut(hollowCylinder1,cylinder); TopoDS_Shape S = BRepAlgoAPI_Fuse(S,hollowCylinder2); // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, S); return aRes; } Mon algo...DE TUBE CUBIQUE TopoDS_Shape MakeCubicTube(const Standard_Real myWidth, const Standard_Real myHeight, const Standard_Real myThickness, const Standard_Real myLength, const gp_Vec offset=gp_Vec(0,0,0)) { // initialisation Standard_Real anAngTol = 1.e-8; Standard_Boolean bShared = Standard_False; // inferior part // BASE PART EXT gp_Pnt aPnt11(0, 0, 0); gp_Pnt aPnt12(myWidth, 0, 0); gp_Pnt aPnt13(myWidth, myHeight, 0); gp_Pnt aPnt14(0, myHeight, 0); // BASE PART INT gp_Pnt aPnt15( 0+myThickness, 0+myThickness, 0); gp_Pnt aPnt16( myWidth-myThickness, 0+myThickness, 0); gp_Pnt aPnt17( myWidth-myThickness, myHeight-myThickness, 0); gp_Pnt aPnt18( 0+myThickness, myHeight-myThickness, 0); // Profile : Define the Geometry of the bottom Handle(Geom_TrimmedCurve) aSegment11 = GC_MakeSegment(aPnt11, aPnt12); Handle(Geom_TrimmedCurve) aSegment12 = GC_MakeSegment(aPnt12, aPnt13); Handle(Geom_TrimmedCurve) aSegment13 = GC_MakeSegment(aPnt13, aPnt14); Handle(Geom_TrimmedCurve) aSegment14 = GC_MakeSegment(aPnt14, aPnt11); // Profile : Define the Geometry of the bottom Handle(Geom_TrimmedCurve) aSegment15 = GC_MakeSegment(aPnt15, aPnt16); Handle(Geom_TrimmedCurve) aSegment16 = GC_MakeSegment(aPnt16, aPnt17); Handle(Geom_TrimmedCurve) aSegment17 = GC_MakeSegment(aPnt17, aPnt18); Handle(Geom_TrimmedCurve) aSegment18 = GC_MakeSegment(aPnt18, aPnt11); // Profile : Define the Topology of the bottom TopoDS_Edge anEdge11 = BRepBuilderAPI_MakeEdge(aSegment11); TopoDS_Edge anEdge12 = BRepBuilderAPI_MakeEdge(aSegment12); TopoDS_Edge anEdge13 = BRepBuilderAPI_MakeEdge(aSegment13); TopoDS_Edge anEdge14 = BRepBuilderAPI_MakeEdge(aSegment14); // Profile : Define the Topology of the left TopoDS_Edge anEdge15 = BRepBuilderAPI_MakeEdge(aSegment15); TopoDS_Edge anEdge16 = BRepBuilderAPI_MakeEdge(aSegment16); TopoDS_Edge anEdge17 = BRepBuilderAPI_MakeEdge(aSegment17); TopoDS_Edge anEdge18 = BRepBuilderAPI_MakeEdge(aSegment18); // on ne peut pas créer les wires comme ça parce qu'on a besoin de les mettre dans le meme élément aWires // edit: je viens de voir que aWires est un TopoDS_Shape... oui pas un tableau ni rien, juste ça // jsp comment ajouter des trucs à ce machin... faudrait essayer un append dessus // sinon tu peux essayer TopTools_ListOfShape //TopoDS_Wire aWire11 = BRepBuilderAPI_MakeWire(anEdge11, anEdge12, anEdge13, anEdge14); //TopoDS_Wire aWire12 = BRepBuilderAPI_MakeWire(anEdge15, anEdge16, anEdge17, anEdge18); TopoDS_Shape aWires; /* resulting wires */ Standard_Integer iErr = BOPAlgo_Tools::EdgesToWires(anEdges, aWires, bShared, anAngTol); if (iErr) { cout << "Error: Unable to build wires from given edges"; return; } TopoDS_Shape aFaces; Standard_Boolean bDone = BOPAlgo_Tools::WiresToFaces(aWires, aFaces, anAngTol); if (!bDone) { cout << "Error: Unable to build faces from wiresnn"; return; } // superior part // TOP PART EXT gp_Pnt aPnt21( 0+offset.X(), 0+offset.Y(), myLength); gp_Pnt aPnt22( myWidth+offset.X(), 0+offset.Y(), myLength); gp_Pnt aPnt23( myWidth+offset.X(), myHeight+offset.Y(), myLength); gp_Pnt aPnt24( 0+offset.X(), myHeight+offset.Y(), myLength); // TOP PART INT gp_Pnt aPnt11( 0+myThickness+offset.X(), 0+myThickness+offset.Y(), myLength); gp_Pnt aPnt12( myWidth-myThickness+offset.X(), 0+myThickness+offset.Y(), myLength); gp_Pnt aPnt13( myWidth-myThickness+offset.X(), myHeight-myThickness+offset.Y(), myLength); gp_Pnt aPnt14( 0+myThickness+offset.X(), myHeight-myThickness+offset.Y(), myLength); // j'ai pas mit l'offset en z puisque on est pas censé en avoir // Profile : Define the Geometry of the right Handle(Geom_TrimmedCurve) aSegment21 = GC_MakeSegment(aPnt21, aPnt22); Handle(Geom_TrimmedCurve) aSegment22 = GC_MakeSegment(aPnt22, aPnt23); Handle(Geom_TrimmedCurve) aSegment23 = GC_MakeSegment(aPnt23, aPnt24); Handle(Geom_TrimmedCurve) aSegment24 = GC_MakeSegment(aPnt24, aPnt21); // Profile : Define the Topology of the left TopoDS_Edge anEdge11 = BRepBuilderAPI_MakeEdge(aSegment11); TopoDS_Edge anEdge12 = BRepBuilderAPI_MakeEdge(aSegment12); TopoDS_Edge anEdge13 = BRepBuilderAPI_MakeEdge(aSegment13); TopoDS_Edge anEdge14 = BRepBuilderAPI_MakeEdge(aSegment14); // Profile : Define the Topology of the right TopoDS_Edge anEdge21 = BRepBuilderAPI_MakeEdge(aSegment21); TopoDS_Edge anEdge22 = BRepBuilderAPI_MakeEdge(aSegment22); TopoDS_Edge anEdge23 = BRepBuilderAPI_MakeEdge(aSegment23); TopoDS_Edge anEdge24 = BRepBuilderAPI_MakeEdge(aSegment24); TopoDS_Wire aWire1 = BRepBuilderAPI_MakeWire(anEdge11, anEdge12, anEdge13, anEdge14); TopoDS_Wire aWire2 = BRepBuilderAPI_MakeWire(anEdge21, anEdge22, anEdge23, anEdge24); TopoDS_Face F1 = BRepBuilderAPI_MakeFace(aWire1); TopoDS_Face F2 = BRepBuilderAPI_MakeFace(aWire2); // building the body // Sewing BRepBuilderAPI_Sewing Sew; Sew.Add(F1); Sew.Add(F2); Sew.Perform(); TopoDS_Shape result= Sew.SewedShape(); return result; } Mon algo...DE CYLINDRE CREUX AVEC UNE EXTENSION DE TUBE CUBIQUE TopoDS_Shape MakeHollowedCylinderWithCubicTube(const Standard_Real myWidth, const Standard_Real myHeight, const Standard_Real myThickness, const Standard_Real myLength, const Standard_Real myWidth2, const Standard_Real myHeight2, const Standard_Real myThickness2, const Standard_Real myLength2, const gp_Vec offset2=gp_Vec(0,0,0)) { // la position de depart va ptet foutre la merde (faudra modifier la position de mes cubicTube pour que ça corresponde aux makeBox) // on crée le premier cylindre TopoDS_Shape hollowCylinder = MakeHollowCylinder(myRadius, myHeight, myThickness); // on crée le tube cubique qui va percer le cylindre TopoDS_Shape myCubicShape = BRepPrimAPI_MakeBox(myWidth, myHeight, myLength); TopoDS_Shape cubicShape = myCylinder.Shape(); // le tube cubique qu'on va fuse TopoDS_Shape cubicTube = MakeCubicTube(myWidth2, myHeight2, myThickness2, myLength2, offset2); // rotation gp_Pnt aOrigin(0, 0, myHeight2/2); gp_Dir yDir(0, 1, 0); gp_Ax1 yAxis(aOrigin, yDir); gp_Trsf aTrsf; aTrsf.SetRotation(yAxis,PI/2); BRepBuilderAPI_Transformation theTrsf(aTrsf); theTrsf.Perform(cubicShape); theTrsf.Perform(cubicTube); // deplacement gp_Vec V( gp_Pnt(0,0,myHeight2/2), gp_Pnt(myRadius,0,pierceHeight) ); gp_Trsf aTrsf; aTrsf.SetTranslation(V); BRepBuilderAPI_Transformation theTrsf(aTrsf); theTrsf.Perform(cubicShape); theTrsf.Perform(cubicTube); // piercing and fusing TopoDS_Shape S = BRepAlgoAPI_Cut(hollowCylinder1,cubicShape); TopoDS_Shape S = BRepAlgoAPI_Fuse(S,cubicTube); // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, S); return aRes; } Mon algo...DE JOINT 3 PARTIES TopoDS_Shape MakeHollowedCylinderWithCubicTube(const Standard_Real myRadius, const Standard_Real myLength, const Standard_Real myThickness) { TopoDS_Shape cyl1 = MakeHollowCylinder(myRadius, myHeight, myThickness); TopoDS_Shape cyl2 = MakeHollowCylinder(myRadius, myHeight, myThickness); TopoDS_Shape cyl2 = MakeHollowCylinder(myRadius, myHeight, myThickness); TopoDS_Shape intersect = MakeJointIntersection(myRadius, myThickness); // rotation // les cylindres ne sont pas centrés en 0,0,0 gp_Pnt aOrigin(myHeight2/2,0, 0,); gp_Dir dir(0, 1, 0); // oh le con j'ai mit en X pour l'extrusion donc rotation sur Y gp_Ax1 axis(aOrigin, dir); gp_Trsf aTrsf1; gp_Trsf aTrsf2; aTrsf1.SetRotation(axis,PI/3.); aTrsf2.SetRotation(axis,-PI/3.); BRepBuilderAPI_Transformation theTrsf1(aTrsf1); BRepBuilderAPI_Transformation theTrsf2(aTrsf2); theTrsf1.Perform(cyl1); theTrsf2.Perform(cyl2); // deplacement // vu qu'on est con on doit d'abord les replacer à l'origine puis enfin les deplacer là où on veut Standard_Real d=1; gp_Vec V1( gp_Pnt(myHeight2/2,0,0), gp_Pnt(-(d+myHeight2/2)*sin(PI/3.),0,(d+myHeight2/2)*cos(PI/3.)) ); // on deplace le centre du cylindre btw #plusSimpleMaisPlusMoche gp_Vec V2( gp_Pnt(myHeight2/2,0,0), gp_Pnt(-(d+myHeight2/2)*sin(PI/3.),0,-(d+myHeight2/2)*cos(PI/3.)) ); gp_Vec V3( gp_Pnt(0,0,0), gp_Pnt(d,0,0) ); // là on deplace le cul du cylindre #plusSimpleMaisPasMoche aTrsf1.SetTranslation(V1); aTrsf2.SetTranslation(V2); aTrsf3.SetTranslation(V3); BRepBuilderAPI_Transformation theTrsf1(aTrsf1); BRepBuilderAPI_Transformation theTrsf2(aTrsf2); BRepBuilderAPI_Transformation theTrsf3(aTrsf3); theTrsf1.Perform(cyl1); theTrsf2.Perform(cyl2); theTrsf2.Perform(cyl3); // fusing TopoDS_Shape res = BRepAlgoAPI_Fuse(intersect,cyl1); TopoDS_Shape res = BRepAlgoAPI_Fuse(res,cyl2); TopoDS_Shape res = BRepAlgoAPI_Fuse(res,cyl3); // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, res); return aRes; } Mon algo...DE L'INTERSECTION DE JOINT 3 PARTIES TopoDS_Shape MakeHollowedCylinderWithCubicTube(const Standard_Real myRadius, const Standard_Real myLength, const Standard_Real myThickness) { // un peu le meme principe que le joint en lui-même // mais au lieu de call le MakeHollowCylinder, faudra build from scratch des cylindres avec un bout bizarre à partir de wires // finalement jvais créer une fonction pour avoir ces cylindres au bout bizarre TopoDS_Shape cyl1 = MakeSharpHollowCylinder(myRadius, myRadius+myThickness, myThickness); TopoDS_Shape cyl2 = MakeSharpHollowCylinder(myRadius, myRadius+myThickness, myThickness); TopoDS_Shape cyl2 = MakeSharpHollowCylinder(myRadius, myRadius+myThickness, myThickness); // rotation // les cylindres ne sont pas centrés en 0,0,0 gp_Pnt aOrigin(0,0, 0,); gp_Dir dir(0, 1, 0); // oh le con j'ai mit en X pour l'extrusion donc rotation sur Y gp_Ax1 axis(aOrigin, dir); gp_Trsf aTrsf1; gp_Trsf aTrsf2; aTrsf1.SetRotation(axis,2*PI/3.); aTrsf2.SetRotation(axis,-2*PI/3.); BRepBuilderAPI_Transformation theTrsf1(aTrsf1); BRepBuilderAPI_Transformation theTrsf2(aTrsf2); theTrsf1.Perform(cyl1); theTrsf2.Perform(cyl2); // fusing TopoDS_Shape res = BRepAlgoAPI_Fuse(cyl1,cyl2); res = BRepAlgoAPI_Fuse(res,cyl3); // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, res); return aRes; } Mon algo...DE SHARP HOLLOWED CYLINDER TopoDS_Shape MakeSharpHollowCylinder(const Standard_Real myRadius, const Standard_Real myLength, const Standard_Real myThickness) { // création des wires du bas gp_Pnt aPnt111(myThickness, 0, 0); gp_Pnt aPnt112(2*myRadius-myThickness, 0, 0); gp_Pnt aPnt113(myRadius, (myRadius-myThickness)*sin(PI/6), (myRadius-myThickness)*cos(PI/6)); gp_Pnt aPnt114(myRadius, (myRadius-myThickness)*sin(PI/6), -(myRadius-myThickness)*cos(PI/6)); gp_Pnt aPnt121(0, 0, 0); gp_Pnt aPnt122(2*myRadius, 0, 0); gp_Pnt aPnt123(myRadius, (myRadius)*sin(PI/6), (myRadius)*cos(PI/6)); gp_Pnt aPnt124(myRadius, (myRadius)*sin(PI/6), -(myRadius)*cos(PI/6)); Handle(Geom_TrimmedCurve) anArcOfCircle111 = GC_MakeArcOfCircle(aPnt111,aPnt112,aPnt113); Handle(Geom_TrimmedCurve) anArcOfCircle112 = GC_MakeArcOfCircle(aPnt111,aPnt112,aPnt114); Handle(Geom_TrimmedCurve) anArcOfCircle121 = GC_MakeArcOfCircle(aPnt121,aPnt122,aPnt123); Handle(Geom_TrimmedCurve) anArcOfCircle122 = GC_MakeArcOfCircle(aPnt121,aPnt122,aPnt124); TopoDS_Edge anEdge111 = BRepBuilderAPI_MakeEdge(anArcOfCircle111); TopoDS_Edge anEdge112 = BRepBuilderAPI_MakeEdge(anArcOfCircle112); TopoDS_Edge anEdge121 = BRepBuilderAPI_MakeEdge(anArcOfCircle121); TopoDS_Edge anEdge122 = BRepBuilderAPI_MakeEdge(anArcOfCircle122); TopoDS_Wire aWire11 = BRepBuilderAPI_MakeWire(anEdge111, anEdge112); TopoDS_Wire aWire12 = BRepBuilderAPI_MakeWire(anEdge121, anEdge122); // création de la surface du bas TopoDS_Shape aFaces1; /* resulting faces */ Standard_Real anAngTol = 1.e-8; Standard_Boolean bDone = BOPAlgo_Tools::WiresToFaces(aWire11.append(aWire12), aFaces1, anAngTol); if (!bDone) { cout << "Error: Unable to build faces from wiresnn"; return; } // creation des wires du haut gp_Pnt aPnt211(myThickness, myLength, 0); gp_Pnt aPnt212(2*myRadius-myThickness, myLength, 0); gp_Pnt aPnt213(myRadius, myLength, (myRadius-myThickness)); gp_Pnt aPnt214(myRadius, myLength, -(myRadius-myThickness)); gp_Pnt aPnt221(0, myLength, 0); gp_Pnt aPnt222(2*myRadius, myLength, 0); gp_Pnt aPnt223(myRadius, myLength, myRadius); gp_Pnt aPnt224(myRadius, myLength, -myRadius); Handle(Geom_TrimmedCurve) anArcOfCircle211 = GC_MakeArcOfCircle(aPnt211,aPnt212,aPnt213); Handle(Geom_TrimmedCurve) anArcOfCircle212 = GC_MakeArcOfCircle(aPnt211,aPnt212,aPnt214); Handle(Geom_TrimmedCurve) anArcOfCircle221 = GC_MakeArcOfCircle(aPnt221,aPnt222,aPnt223); Handle(Geom_TrimmedCurve) anArcOfCircle222 = GC_MakeArcOfCircle(aPnt221,aPnt222,aPnt224); TopoDS_Edge anEdge211 = BRepBuilderAPI_MakeEdge(anArcOfCircle211); TopoDS_Edge anEdge212 = BRepBuilderAPI_MakeEdge(anArcOfCircle212); TopoDS_Edge anEdge221 = BRepBuilderAPI_MakeEdge(anArcOfCircle221); TopoDS_Edge anEdge222 = BRepBuilderAPI_MakeEdge(anArcOfCircle222); TopoDS_Wire aWire21 = BRepBuilderAPI_MakeWire(anEdge211, anEdge212); TopoDS_Wire aWire22 = BRepBuilderAPI_MakeWire(anEdge221, anEdge222); // creation de la surface du haut TopoDS_Shape aFaces2; /* resulting faces */ Standard_Boolean bDone = BOPAlgo_Tools::WiresToFaces(aWire21.append(aWire22), aFaces2, anAngTol); if (!bDone) { cout << "Error: Unable to build faces from wiresnn"; return; } // on coud avec les surfaces BRepBuilderAPI_Sewing Sew; Sew.Add(aFaces1); Sew.Add(aFaces2); Sew.Perform(); TopoDS_Shape result= Sew.SewedShape(); // faut le deplacer vu qu'il est pas centré gp_Vec V( gp_Pnt(0,0,0), gp_Pnt(-myRadius,0,0) ); // là on deplace le cul du cylindre #plusSimpleMaisPasMoche gp_Trsf aTrsf; aTrsf.SetTranslation(V); BRepBuilderAPI_Transformation theTrsf1(aTrsf); theTrsf1.Perform(result); return result; } Mon algo...DE COUVERCLE CHELOU TopoDS_Shape MakeLid(const Standard_Real myRadius1, const Standard_Real myRadius2, const Standard_Real myHeight, const Standard_Real myThickness) { // creation du wire (base + arc + capot ) // on va définir un certain nombre de points // certains avec des intersections de cercles, donc va y avoir un peu de calculs... gp_Pnt A(myThickness, 0, 0); // point à droite de la base gp_Pnt B(0, 0, 0); // point à gauche de la base gp_Pnt C(0, myHeight-myThickness-myRadius2, 0); // debut de l'arc exterieur gp_Pnt H(myThickness, myHeight-myThickness-myRadius2, 0); // debut de l'arc intérieur gp_Pnt P(myThickness+myRadius1, myHeight-myThickness-myRadius2, 0); // centre du petit cercle formant l'arc gp_Pnt O(myThickness+myRadius2, myHeight-myThickness-myRadius2, 0); // centre du grand cercle formant le capot gp_Pnt a1(-myRadius1*cos(PI/4)+myThickness+myRadius1, myRadius1*sin(PI/4)+myHeight-myThickness-myRadius2, 0); // point de l'arc de cercle intérieur gp_Pnt a2(-(myRadius1+myThickness)*cos(PI/4)+myThickness+myRadius1, (myRadius1+myThickness)*sin(PI/4)+myHeight-myThickness-myRadius2, 0); // point de l'arc de cercle extérieur // pour a3 et a4 c'est compliqué, je crois que je dois choisir un angle au hasard et que potentiellement ça peut tout niquer (si R2 trop petit comparé à R1) gp_Pnt a3(-myRadius2*cos(3*PI/4)+myThickness+myRadius2, myRadius2*sin(3*PI/4)+myHeight-myThickness-myRadius2, 0); // point de l'arc du capot intérieur gp_Pnt a4(-(myRadius2+myThickness)*cos(3*PI/4)+myThickness+myRadius2, (myRadius2+myThickness)*sin(3*PI/4)+myHeight-myThickness-myRadius2, 0); // point de l'arc du capot extérieur gp_Pnt E(myThickness+myRadius2, myHeight, 0); // haut du capot gp_Pnt F(myThickness+myRadius2, myHeight-myThickness, 0); // haut du capot mais côté intérieur // maintenant il faut définir les intersections des arcs de cercle et du capot // soit l'intersection du cercle de rayon myRadius1(R1) et de centre P (que l'on va abréger P(R1) ) avec O(R2) // et également (myThickness=T) P(R1+T) avec O(R2+T) Standard_Real psi1= ( -P.X*P.X - P.Y*P.Y + O.X*O.X + O.Y*O.Y + myRadius2*myRadius2 - myRadius1*myRadius1 ) / (2*(O.Y-P.Y)); Standard_Real psi2= ( O.X - P.X ) / (O.Y - P.Y); Standard_Real a=psi2*psi2 +1; Standard_Real b=-2*P.X + 2 * P.Y * psi2 - 2* psi1*psi2; Standard_Real c= P.X * P.X + P.Y * P.Y - 2* P.Y * psi1 + psi1 * psi1 - myRadius2 * myRadius2; Standard_Real delta= b*b - 4*a*c; Standard_Real Xg1= ( -b + sqrt(delta) )/ 2*a; Standard_Real Xg2= ( -b - sqrt(delta) )/ 2*a; Standard_Real Yg1= psi1 - Xg1*psi2 ; Standard_Real Yg2= psi1 - Xg2*psi2 ; gp_Pnt G( Yg1 > Yg2 ? Xg1 : Xg2, Yg1 > Yg2 ? Yg1 : Yg2, 0); psi1= ( -P.X*P.X - P.Y*P.Y + O.X*O.X + O.Y*O.Y + (myRadius2+myThickness)*(myRadius2+myThickness) - (myRadius1+myThickness)*(myRadius1+myThickness) ) / (2*(O.Y-P.Y)); psi2= ( O.X - P.X ) / (O.Y - P.Y); a=psi2*psi2 +1; b=-2*P.X + 2 * P.Y * psi2 - 2* psi1*psi2; c= P.X * P.X + P.Y * P.Y - 2* P.Y * psi1 + psi1 * psi1 - (myRadius2+myThickness) * (myRadius2+myThickness); delta= b*b - 4*a*c; Standard_Real Xd1= ( -b + sqrt(delta) )/ 2*a; Standard_Real Xd2= ( -b - sqrt(delta) )/ 2*a; Standard_Real Yd1= psi1 - Xd1*psi2 ; Standard_Real Yd2= psi1 - Xd2*psi2 ; gp_Pnt D( Yd1 > Yd2 ? Xd1 : Xd2, Yd1 > Yd2 ? Yd1 : Yd2, 0); // maintenant qu'on a tous nos points faut les relier ;) Handle(Geom_TrimmedCurve) SAB= GC_MakeSegment(A, B); TopoDS_Edge AB = BRepBuilderAPI_MakeEdge(SAB); Handle(Geom_TrimmedCurve) SBC= GC_MakeSegment(B, C); TopoDS_Edge BC = BRepBuilderAPI_MakeEdge(SBC); Handle(Geom_TrimmedCurve) SCD = GC_MakeArcOfCircle(C,D,a2); TopoDS_Edge CD = BRepBuilderAPI_MakeEdge(SCD); Handle(Geom_TrimmedCurve) SDE = GC_MakeArcOfCircle(D,E,a4); TopoDS_Edge DE = BRepBuilderAPI_MakeEdge(SDE); Handle(Geom_TrimmedCurve) SEF= GC_MakeSegment(E, F); TopoDS_Edge EF = BRepBuilderAPI_MakeEdge(SEF); Handle(Geom_TrimmedCurve) SFG = GC_MakeArcOfCircle(F,G,a3); TopoDS_Edge FG = BRepBuilderAPI_MakeEdge(SFG); Handle(Geom_TrimmedCurve) SGH = GC_MakeArcOfCircle(G,H,a1); TopoDS_Edge GH = BRepBuilderAPI_MakeEdge(SGH); Handle(Geom_TrimmedCurve) SHA= GC_MakeSegment(H, A); TopoDS_Edge HA = BRepBuilderAPI_MakeEdge(SHA); TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(AB, BC, CD, DE, EF, FG, GH, HA); // faut le deplacer vu qu'il est pas centré (pour pouvoir faire la rotation) gp_Vec V( gp_Pnt(0,0,0), gp_Pnt(-myRadius2,0,0) ); // là on deplace le cul du cylindre #plusSimpleMaisPasMoche gp_Trsf aTrsf; aTrsf.SetTranslation(V); BRepBuilderAPI_Transformation theTrsf(aTrsf); theTrsf.Perform(aWire); // jsp si ça marche sur les wires, sinon faudra simplement choisir un axe de rotation décalé, faire la rotation puis redéplacer la forme pour qu'elle soit centrée // rotation du wire gp_Ax1 Axis = gp::OY(); // origine 0,0,0 avec dir 0,1,0 TopoDS_Face F = BRepBuilderAPI_MakeFace(aWire); TopoDS_Solid aRotatedShape = BRepPrimAPI_MakeRevol(F,Axis,2*PI); // Building the Resulting Compound TopoDS_Compound result; BRep_Builder aBuilder; aBuilder.MakeCompound (result); aBuilder.Add (result, aRotatedShape); return result; } Mon algo...DE COUDE TopoDS_Shape MakeCoude(const Standard_Real L1, const Standard_Real L2, const Standard_Real R, const Standard_Real L3, const Standard_Real L4, const Standard_Real myThickness, const Standard_Real alpha, const Standard_Real n) { // les cylindres du bout TopoDS_Shape cyl1 = MakeHollowCylinder(R, L3, myThickness); TopoDS_Shape cyl2 = MakeHollowCylinder(R, L4, myThickness); // petite partie circulaire du coude TopoDS_Shape SPC = MakeCircularPartCoude(alpha, n, L1-L3, L2, R, myThickness); // avant de les assembler il faut les deplacer // cyl1 reste en place // le tuyau se deplace en haut pour se coller gp_Vec V( gp_Pnt(0,0,0), gp_Pnt(0,L3,0) ); gp_Trsf aTrsf; aTrsf.SetTranslation(V); BRepBuilderAPI_Transformation theTrsf(aTrsf); theTrsf.Perform(SPC); // le cyl2 doit etre recentré sur 0,0,0, tourné de 90 dégré selon l'axe Z puis le remonter de L1-R1 ( sans oublier le decalage) V( gp_Pnt(0,0,0), gp_Pnt(0,-L3/2,0) ); gp_Trsf aTrsf; aTrsf.SetTranslation(V); BRepBuilderAPI_Transformation theTrsf(aTrsf); theTrsf.Perform(cyl2); // mntn la rotation gp_Ax1 Axis = gp::OZ(); aTrsf.SetRotation(Axis,PI/2); theTrsf(aTrsf); theTrsf.Perform(cyl2); // et maintenant le deplacement finalement V( gp_Pnt(0,0,0), gp_Pnt(L2-L4/2,L1-R,0) ); aTrsf.SetTranslation(V); theTrsf(aTrsf); theTrsf.Perform(cyl2); // assemblage TopoDS_Shape res = BRepAlgoAPI_Fuse(cyl1,cyl2); res = BRepAlgoAPI_Fuse(res,SPC); // Building the Resulting Compound TopoDS_Compound aRes; BRep_Builder aBuilder; aBuilder.MakeCompound (aRes); aBuilder.Add (aRes, res); return aRes; } Mon algo...DE CIRCULAR PART OF COUDE TopoDS_Shape MakeCircularPartCoude(const Standard_Real alpha, const Standard_Real n, const Standard_Real L1L3, const Standard_Real L2,const Standard_Real R, const Standard_Real T) { TopoDS_Shape F; BRepBuilderAPI_Sewing Sew; for (Standard_Real i=0; i