ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magicsld/SuperFace.vb
(Generate patch)

Comparing magicsld/SuperFace.vb (file contents):
Revision 48 by bournival, Wed Aug 22 21:18:12 2007 UTC vs.
Revision 205 by bournival, Thu Jul 23 20:53:57 2009 UTC

# Line 9 | Line 9 | Public Class SuperFace
9      Private Shared compteur As Long
10      Private Shared no As Long
11  
12 +
13      Friend Flag As Integer = 0 ' = 20 si on a une coupeLong
14  
15  
# Line 42 | Line 43 | Public Class SuperFace
43      ''' <param name="Face"></param>
44      ''' <param name="encapsulateur"></param>
45      ''' <remarks></remarks>
46 <    Public Sub New(ByRef Face As SldWorks.Face2, ByRef encapsulateur As Boolean)
46 >    Public Sub New(ByRef Face As sldworks.Face2, ByRef encapsulateur As Boolean)
47          lst_Faces.Add(Face)
48      End Sub
49  
50 <    Friend Sub New(ByRef face As SldWorks.Face2, Optional ByVal tip As Integer = 0)
50 >    Friend Sub New(ByRef face As sldworks.Face2, Optional ByVal tip As Integer = 0)
51          Me.AjouterFace(face)
52          Select Case tip
53              Case Commun.tipe_e.Volume
# Line 59 | Line 60 | Public Class SuperFace
60      End Sub
61  
62  
63 <    Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreCoque, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
64 <        MsgBox("La fonction non overridée a été appelée!")
65 <        Return Nothing
66 <    End Function
63 >    'Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreCoque, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
64 >    '    MsgBox("La fonction non overridée a été appelée!")
65 >    '    Return Nothing
66 >    'End Function
67  
68 <    Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
69 <        MsgBox("La fonction non overridée a été appelée!")
70 <        Return Nothing
71 <    End Function
68 >    'Friend Overridable Function UpdateApresSplit(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre, ByRef x As Double, ByRef y As Double, ByRef z As Double, ByRef Plan As SldWorks.RefPlane, Optional ByRef FI As Boolean = False) As SldWorks.Face2
69 >    '    MsgBox("La fonction non overridée a été appelée!")
70 >    '    Return Nothing
71 >    'End Function
72  
73      ''' <summary>
74 <    ''' Sub qui ajoute des mini-poutres à la section entre le sommet de la poutre et un point de la face interne
74 >    ''' Sub qui ajoute des mini-poutres à la section entre le sommet de la poutre et un point de la face interne quand la face interne ne touche pas à la poutre
75      ''' </summary>
76      ''' <param name="poutre">La poutre principale</param>
77      ''' <param name="FaceInterne">La face où il faut ajouter UNE mini-poutre</param>
# Line 95 | Line 96 | Public Class SuperFace
96          swArete = FaceInterne.GetFirstLoop.GetFirstCoEdge.getedge
97          swSommet2 = swArete.GetStartVertex()
98  
99 <        If swSommet2 Is Nothing Then ' un celcle (ou ellipse)
99 >        If swSommet2 Is Nothing Then ' un cercle (ou ellipse)
100              Dim retval As Object
101              retval = swArete.Evaluate(0) ' il va y avor un LC point anyway...
102              x2 = retval(0)
# Line 114 | Line 115 | Public Class SuperFace
115          '  3 faire une mini-poutre entre les 2
116  
117          swModel.Insert3DSketch2(True)
117        swModel.CreateLine2(x1, y1, z1, x2, y2, z2)
118          swSketch = swModel.GetActiveSketch2()
119 +        If swSketch Is Nothing Then swModel.Insert3DSketch2(True) : swSketch = swModel.GetActiveSketch2()
120 +        If swSketch Is Nothing Then MsgBox("Ça merde vraiment...")
121 +        swModel.CreateLine2(x1, y1, z1, x2, y2, z2)
122          swModel.Insert3DSketch2(True)
123          swEnt = swSketch : swEnt.Select2(False, 1)
124          swModel.InsertCompositeCurve()
# Line 394 | Line 397 | Public Class SuperFace
397      End Sub
398  
399  
400 <    ' sub qui découpe les bords de la face.
398 <    Friend Sub CoupeCote(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre)
399 <        Dim pt3() As Double, pt3Original() As Double
400 <        Dim base(2) As Double, baseOriginal(2) As Double
401 <        Dim swEnt As SldWorks.Entity
402 <        Dim Directionnel As Boolean, Flip As Boolean
403 <        Dim planReference As SldWorks.RefPlane = Nothing
404 <        Dim sketchline As SldWorks.SketchSegment
405 <        Dim swSketch As SldWorks.Sketch
406 <        Dim DemiLargeur As Double
407 <        Dim g As Integer
408 <        Dim Face(1) As SldWorks.Face2
409 <        Dim PlanEntity As SldWorks.Entity = Nothing
410 <        Dim r(2) As Double
411 <        Dim sk(1) As Double
412 <        pt3Original = poutre.GetPoint3
413 <
414 <
415 <        swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
416 <        'swModel.SetAddToDB(True)
417 <        'swModel.SetDisplayWhenAdded(False) ' accélérer les performances
418 <
419 <        Dim vArete As Object
420 <        Dim cut As Double
421 <
422 <        If Me.estPlan Then
423 <            ' la coque est plane, on met une esquisse dessus.#
424 <            PlanEntity = Me.SwFace
425 <
426 <        ElseIf Me.estCylindre Then
427 <            ' on doit créer un plan de référence...
428 <
429 <        ElseIf Me.estFauxPlan(inter.x, inter.y, inter.z) Then
430 <            Dim vEdge As Object
431 <            Dim i As Integer
432 <            Dim swArete2() As SldWorks.Edge
433 <            Dim swSommet As SldWorks.Vertex
434 <
435 <            vEdge = Me.SwFace.GetEdges
436 <            swArete2 = vEdge
437 <            swModel.ClearSelection2(True)
438 <
439 <            While planReference Is Nothing
440 <                If UBound(swArete2) - 2 < i Then MsgBox("Dans CoupeLong, problème pour créer un plan avec 3 points.  (La face est un FauxPlan)", MsgBoxStyle.Critical, "Le plan ne sera pas créé") : Exit While
441 <                swSommet = swArete2(i).GetStartVertex()
442 <                swEnt = swSommet
443 <                swEnt.Select4(False, Nothing)
444 <                swArete2(i + 1).GetStartVertex()
445 <                swEnt = swSommet
446 <                swEnt.Select4(True, Nothing)
447 <                swArete2(i + 2).GetStartVertex()
448 <                swEnt = swSommet
449 <                swEnt.Select4(True, Nothing)
450 <                i += 1
451 <                planReference = swModel.CreatePlaneThru3Points3(False)
452 <                PlanEntity = planReference
453 <            End While
454 <
455 <
456 <        Else ' la face est une spline
457 <            MsgBox("Dans coupeCoté, la face est un type de surface qui n'est pas encore traité")
458 <        End If
459 <
460 <
461 <        baseOriginal(0) = inter.x : baseOriginal(1) = inter.y : baseOriginal(2) = inter.z
462 <
463 <
464 <        Dim Psi As Double
465 <        Dim u(2) As Double, v(2) As Double, usketch(2) As Double, vsketch(2) As Double
466 <        Dim Arete As SldWorks.Edge = Nothing
467 <        Dim retval As Object
468 <        u = poutre.GetOrientation(inter.x, inter.y, inter.z)
469 <
470 <
471 <        vArete = Me.SwFace.GetEdges
472 <
473 <        For Each Arete In vArete
474 <            If Commun.Distance(Arete, inter.x, inter.y, inter.z) < Epsilon Then Exit For
475 <        Next
476 <
477 <        retval = Arete.GetClosestPointOn(inter.x, inter.y, inter.z)
478 <        retval = Arete.Evaluate(retval(3))
479 <        v(0) = retval(3) : v(1) = retval(4) : v(2) = retval(5)
480 <
481 <
482 <
483 <
484 <        For g = 0 To 1
485 <
486 <            PlanEntity.Select(False)
487 <            swModel.InsertSketch2(True)
488 <            swSketch = swModel.GetActiveSketch2
489 <
490 <            pt3 = Commun.TransfertModelSketch(swSketch, pt3Original)
491 <            usketch = Commun.TransfertModelSketch(swSketch, u)  ' on les met dans le plan du sketch
492 <            vsketch = Commun.TransfertModelSketch(swSketch, v)
493 <            base = Commun.TransfertModelSketch(swSketch, baseOriginal)
494 <            Psi = Outils_Math.cosdir(usketch, vsketch)
495 <
496 <            Dim a As Double, b As Double
497 <            'longueur = Math.Sqrt(pt3(0) * pt3(0) + pt3(1) * pt3(1))
498 <            'If pt3(1) = 0 Then a = 999999999999 Else a = Math.Abs(poutre.GetD2() * longueur / pt3(1))
499 <            'If pt3(0) = 0 Then b = 999999999999 Else b = Math.Abs(poutre.GetD1() * longueur / pt3(0))
500 <            ' À revoir. Si le plan est un cylindre ça marche plus. sans compter l'épaisseur de la poutre.
501 <            ' pour l'instant je prend la plus prtite valeur...
502 <            a = poutre.GetD1
503 <            b = poutre.GetD2
504 <            DemiLargeur = Math.Min(a, b)
505 <            cut = DemiLargeur / Math.Sin(Pi / 2 - Psi)
506 <
507 <
508 <            Dim P1(1) As Double
509 <            Dim P2(1) As Double
510 <            Dim P3(1) As Double
511 <            Dim P4(1) As Double
512 <            Dim Ptest(2) As Double
513 <
514 <
515 <            If g = 0 Then
516 <                P1(0) = -cut
517 <                P1(1) = -cut '* mult ' 0
518 <                P2(0) = 0
519 <                P2(1) = -cut '* mult ' 0
520 <                P3(0) = 0
521 <                P3(1) = cut   'Intersections.Taille mult
522 <                P4(0) = -cut
523 <                P4(1) = cut   'Intersections.Taille mult
524 <                sk(0) = -Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
525 <
526 <            Else
527 <                P1(0) = 0
528 <                P1(1) = -cut '* mult '0
529 <                P2(0) = +cut
530 <                P2(1) = -cut '* mult '0
531 <                P3(0) = +cut
532 <                P3(1) = cut  'Intersections.Taille mult
533 <                P4(0) = 0
534 <                P4(1) = cut  'Intersections.Taille mult
535 <                sk(0) = Epsilon * 100 + base(0) : sk(1) = 0 + base(1)
536 <
537 <            End If
538 <
539 <            P1 = Outils_Math.Rotation2D(vsketch, P1)
540 <            P2 = Outils_Math.Rotation2D(vsketch, P2)
541 <            P3 = Outils_Math.Rotation2D(vsketch, P3)
542 <            P4 = Outils_Math.Rotation2D(vsketch, P4)
543 <            sk = Outils_Math.Rotation2D(vsketch, sk)
544 <
545 <            sketchline = swModel.CreateLine2(P1(0) + base(0), P1(1) + base(1), 0, P2(0) + base(0), P2(1) + base(1), 0)
546 <            sketchline = swModel.CreateLine2(P2(0) + base(0), P2(1) + base(1), 0, P3(0) + base(0), P3(1) + base(1), 0)
547 <            sketchline = swModel.CreateLine2(P3(0) + base(0), P3(1) + base(1), 0, P4(0) + base(0), P4(1) + base(1), 0)
548 <            sketchline = swModel.CreateLine2(P1(0) + base(0), P1(1) + base(1), 0, P4(0) + base(0), P4(1) + base(1), 0)
549 <
550 <            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
551 <            swModel.ClearSelection2(True)
552 <            swEnt = Me.SwFace : swEnt.Select2(False, 1)
553 <            swEnt = swSketch : swEnt.Select2(True, 4)
554 <
555 <            swModel.InsertSplitLineProject(Directionnel, Flip)
556 <            r = Commun.TransfertSketchToModel(swSketch, sk)
557 <            Face(g) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference)
558 <            'If Face(g) Is Nothing Then
559 <            'swSketch.Select(False)
560 <            'swModel.EditDelete()
561 <            'End If
562 <
563 <        Next g
564 <
565 <
566 <
567 <        ' mettre les mini-poutres
568 <        Dim vEdge2 As Object
569 <        Dim swArete As SldWorks.Edge
570 <        Dim vPoint As Object
571 <        Dim Mini1 As SldWorks.Edge = Nothing, Mini2 As SldWorks.Edge = Nothing
572 <
573 <
574 <        ' 1 - trouver les 2 arrères dont l'orientation est la même (ou l'inverse) que le v
575 <        For g = 0 To 1
576 <            If Not Face(g) Is Nothing Then
577 <                vEdge2 = Face(g).GetEdges()
578 <
579 <
580 <                ' construire u
581 <                For Each swArete In vEdge2
582 <                    If Commun.Distance(swArete, inter.x, inter.y, inter.z) < Epsilon Then
583 <                        ' l'arête touche à l'intersection,
584 <                        vPoint = swArete.GetClosestPointOn(inter.x, inter.y, inter.z)
585 <                        vPoint = swArete.Evaluate(vPoint(3))
586 <                        u(0) = vPoint(3) : u(1) = vPoint(4) : u(2) = vPoint(5)
587 <
588 <                        If Outils_Math.CompareSens(v, u) Then
589 <                            ' l'arète doit être une mini-poutre
590 <                            If Mini1 Is Nothing Then Mini1 = swArete : Exit For Else Mini2 = swArete : Exit For
591 <                        End If
592 <                    End If
593 <
594 <                Next
595 <
596 <            End If
597 <        Next
598 <
599 <        swEnt = Mini1
600 <        If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
601 <
602 <        If Not Mini2 Is Nothing Then
603 <            swEnt = Mini2
604 <            If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
605 <        End If
606 <
607 <        swModel.SetInferenceMode(True) '
608 <        'swModel.SetAddToDB(False)
609 <        'swModel.SetDisplayWhenAdded(True) '
610 <    End Sub
400 >    
401  
402  
403      ' sub qui coupe la face avec une arète qui repose dessus.
404      Friend Sub CoupeLong(ByRef inter As InterPoutreVolume, ByVal poutre As SlyAretePoutre)
615        Dim swEnt As SldWorks.Entity
616        Dim swSketchSegment As SldWorks.SketchSegment
617        Dim vSketchSegments As Object
618        Dim swSketch As SldWorks.Sketch
619        Dim faceinterne(1) As SldWorks.Face2
620        Dim swPlan As SldWorks.RefPlane = Nothing
621        Dim b As Integer
622        Dim swSommet As SldWorks.Vertex
623        Dim i As Integer
624
625        swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
626
627        ' faut découper toutes les faces de la liste si elles ne sont pas des faces internes
628        Dim MeFace As SldWorks.Face2
629        Dim ListeFace() As SldWorks.Face2
630        ReDim ListeFace(Me.lst_Faces.Count - 1)
631
632        For i = 1 To Me.lst_Faces.Count
633            ListeFace(i - 1) = Me.lst_Faces.Item(i)
634        Next
635
636        For Each MeFace In ListeFace
637
638            If Me.estPlan Then
639                swEnt = MeFace
640                swEnt.Select(False)
641                swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
642                swEnt.Select(False)
643                swModel.InsertSketch2(True)
644
645                swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
646
647            ElseIf Me.estFauxPlan(inter.x, inter.y, inter.z) Then
648                If b = 0 Then
649                    Dim vEdge As Object
650
651
652                    vEdge = MeFace.GetEdges
653                    swModel.ClearSelection2(True)
654                    While swPlan Is Nothing
655                        If UBound(vEdge) - 2 < i Then MsgBox("Dans CoupeLong, problème pour créer un plan avec 3 points.  (La face est un FauxPlan)", MsgBoxStyle.Critical, "Le plan ne sera pas créé") : Exit While
656                        swSommet = vEdge(i).GetStartVertex()
657                        swEnt = swSommet
658                        swEnt.Select4(False, Nothing)
659                        swSommet = vEdge(i + 1).GetStartVertex()
660                        swEnt = swSommet
661                        swEnt.Select4(True, Nothing)
662                        swSommet = vEdge(i + 2).GetStartVertex()
663                        swEnt = swSommet
664                        swEnt.Select4(True, Nothing)
665                        i += 1
666                        swPlan = swModel.CreatePlaneThru3Points3(False)
667
668                    End While
669                End If
670                swEnt = swPlan
671                swEnt.Select(False)
672                swModel.InsertSketch2(True)
673
674            Else
675                MsgBox("Dans coupeLong, on a un type de face qui n'est pas encore traité")
676
677            End If
678
679
680            swSketch = swModel.GetActiveSketch2
681
682            swEnt = poutre.swArete
683            swEnt.Select(False)
684
685            ' créer la ligne de  «conversion de entités»
686            swModel.SketchUseEdge2(False)
405  
688            vSketchSegments = swSketch.GetSketchSegments()
689            swSketchSegment = vSketchSegments(0)
690            swSketchSegment.Select2(False, 1)  'on sélectionne l'arète de poutre...
406  
407 <            Dim x As Double, y As Double, z As Double
408 <            Commun.GetMidPointSegment(swSketchSegment, x, y, z)
407 >        'Dim swEnt As SldWorks.Entity
408 >        'Dim swSketchSegment As SldWorks.SketchSegment
409 >        'Dim vSketchSegments As Object
410 >        'Dim swSketch As SldWorks.Sketch
411 >        'Dim faceinterne(1) As SldWorks.Face2
412 >        'Dim swPlan As SldWorks.RefPlane = Nothing
413 >        'Dim b As Integer
414 >        'Dim swSommet As SldWorks.Vertex
415 >        'Dim i As Integer
416 >
417 >        'swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
418 >
419 >        '' faut découper toutes les faces de la liste si elles ne sont pas des faces internes
420 >        'Dim MeFace As SldWorks.Face2
421 >        ''Dim ListeFace() As SldWorks.Face2
422 >        ''ReDim ListeFace(Me.lst_Faces.Count - 1)
423 >
424 >        ''For i = 1 To Me.lst_Faces.Count
425 >        ''ListeFace(i - 1) = Me.lst_Faces.Item(i)
426 >        ''Next
427 >
428 >        'For Each MeFace In Me.lst_Faces 'ListeFace
429 >
430 >        '    If Me.estPlan Then
431 >        '        swEnt = MeFace
432 >        '        swEnt.Select(False)
433 >        '        swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
434 >        '        swEnt.Select(False)
435 >        '        swModel.InsertSketch2(True)
436 >
437 >        '        swPlan = swModel.CreatePlaneAtOffset3(0, False, False)
438 >
439 >        '    ElseIf Me.estFauxPlan(inter.x, inter.y, inter.z) Then
440 >        '        If b = 0 Then
441 >        '            Dim vEdge As Object
442 >
443 >
444 >        '            vEdge = MeFace.GetEdges
445 >        '            swModel.ClearSelection2(True)
446 >        '            While swPlan Is Nothing
447 >        '                If UBound(vEdge) - 2 < i Then MsgBox("Dans CoupeLong, problème pour créer un plan avec 3 points.  (La face est un FauxPlan)", MsgBoxStyle.Critical, "Le plan ne sera pas créé") : Exit While
448 >        '                swSommet = vEdge(i).GetStartVertex()
449 >        '                swEnt = swSommet
450 >        '                swEnt.Select4(False, Nothing)
451 >        '                swSommet = vEdge(i + 1).GetStartVertex()
452 >        '                swEnt = swSommet
453 >        '                swEnt.Select4(True, Nothing)
454 >        '                swSommet = vEdge(i + 2).GetStartVertex()
455 >        '                swEnt = swSommet
456 >        '                swEnt.Select4(True, Nothing)
457 >        '                i += 1
458 >        '                swPlan = swModel.CreatePlaneThru3Points3(False)
459 >
460 >        '            End While
461 >        '        End If
462 >        '        swEnt = swPlan
463 >        '        swEnt.Select(False)
464 >        '        swModel.InsertSketch2(True)
465 >
466 >        '    Else
467 >        '        MsgBox("Dans coupeLong, on a un type de face qui n'est pas encore traité")
468 >
469 >        '    End If
470 >
471 >
472 >        '    swSketch = swModel.GetActiveSketch2
473 >
474 >        '    swEnt = poutre.swArete
475 >        '    swEnt.Select(False)
476 >
477 >        '    ' créer la ligne de  «conversion de entités»
478 >        '    swModel.SketchUseEdge2(False)
479 >
480 >        '    vSketchSegments = swSketch.GetSketchSegments()
481 >        '    swSketchSegment = vSketchSegments(0)
482 >        '    swSketchSegment.Select2(False, 1)  'on sélectionne l'arète de poutre...
483 >
484 >        '    Dim x As Double, y As Double, z As Double
485 >        '    Commun.GetMidPointSegment(swSketchSegment, x, y, z)
486 >
487 >
488 >        '    ' sketchoffset doit avoir un mark de 1 pour l'objet à offsetter.  Une valeur négative inverse la direction
489 >        '    swModel.SketchManager.SketchOffset(poutre.GetD2, False, 0, 0, 0, 0)
490 >        '    ' pour rendre le modèle plus beau, on peut enlever la contrainte de offset et laisser solidworks mettre des contraintes automatiques...
491 >
492 >        '    Dim retval As Object
493 >        '    Dim skPointA1 As sldworks.SketchPoint = Nothing, skPointA2 As sldworks.SketchPoint = Nothing, skPointB1 As sldworks.SketchPoint = Nothing, skPointB2 As sldworks.SketchPoint = Nothing
494 >
495 >        '    vSketchSegments = swSketch.GetSketchSegments()
496 >        '    swSketchSegment = vSketchSegments(1)
497 >
498 >
499 >        '    Select Case swSketchSegment.GetType()
500 >        '        Case 0 ' on a une ligne
501 >        '            Dim sketchline As sldworks.SketchLine
502 >        '            sketchline = swSketchSegment
503 >        '            skPointA1 = sketchline.GetStartPoint2
504 >        '            skPointA2 = sketchline.GetEndPoint2()
505 >        '        Case 1 ' arc
506 >        '            Dim arc As sldworks.SketchArc
507 >        '            arc = swSketchSegment
508 >        '            skPointA1 = arc.GetStartPoint
509 >        '            skPointA2 = arc.GetEndPoint2
510 >        '        Case 2 ' ellipse
511 >        '            Dim sketchEllipse As sldworks.SketchEllipse
512 >        '            sketchEllipse = swSketchSegment
513 >        '            skPointA1 = sketchEllipse.GetStartPoint2
514 >        '            skPointA2 = sketchEllipse.GetEndPoint2
515 >        '        Case 3 ' spline
516 >        '            Dim spline As sldworks.SketchSpline
517 >        '            Dim pts() As sldworks.SketchPoint
518 >        '            spline = swSketchSegment
519 >        '            retval = spline.GetPoints2()
520 >        '            pts = retval
521 >        '            skPointA1 = pts(0)
522 >        '            skPointA2 = pts(UBound(pts))
523 >        '        Case 5 ' parabole (le 4 est du texte)
524 >        '            Dim para As sldworks.SketchParabola
525 >        '            para = swSketchSegment
526 >        '            skPointA1 = para.GetStartPoint2
527 >        '            skPointA2 = para.GetEndPoint2
528 >        '    End Select
529 >
530 >        '    swSketchSegment = vSketchSegments(0)
531 >        '    Select Case swSketchSegment.GetType()
532 >        '        Case 0 ' on a une ligne
533 >        '            Dim sketchline As sldworks.SketchLine
534 >        '            sketchline = swSketchSegment
535 >        '            skPointB1 = sketchline.GetStartPoint2
536 >        '            skPointB2 = sketchline.GetEndPoint2()
537 >        '        Case 1 ' arc
538 >        '            Dim arc As sldworks.SketchArc
539 >        '            arc = swSketchSegment
540 >        '            skPointB1 = arc.GetStartPoint
541 >        '            skPointB2 = arc.GetEndPoint2
542 >        '        Case 2 ' ellipse
543 >        '            Dim sketchEllipse As sldworks.SketchEllipse
544 >        '            sketchEllipse = swSketchSegment
545 >        '            skPointB1 = sketchEllipse.GetStartPoint2
546 >        '            skPointB2 = sketchEllipse.GetEndPoint2
547 >        '        Case 3 ' spline
548 >        '            Dim spline As sldworks.SketchSpline
549 >        '            Dim pts() As sldworks.SketchPoint
550 >        '            spline = swSketchSegment
551 >        '            retval = spline.GetPoints2()
552 >        '            pts = retval
553 >        '            skPointB1 = pts(0)
554 >        '            skPointB2 = pts(UBound(pts))
555 >        '        Case 5 ' parabole (le 4 est du texte)
556 >        '            Dim para As sldworks.SketchParabola
557 >        '            para = swSketchSegment
558 >        '            skPointB1 = para.GetStartPoint2
559 >        '            skPointB2 = para.GetEndPoint2
560 >        '    End Select
561 >
562 >        '    ' création des 2 lignes pour fermer le sketch.
563 >        '    swModel.CreateLine2(skPointA1.X, skPointA1.Y, 0, skPointB1.X, skPointB1.Y, 0)
564 >        '    swModel.CreateLine2(skPointA2.X, skPointA2.Y, 0, skPointB2.X, skPointB2.Y, 0)
565 >
566 >
567 >        '    Dim x2 As Double, y2 As Double, z2 As Double ' le midpoint de la poutre
568 >        '    Dim x3 As Double, y3 As Double, z3 As Double ' le midpoint de la poutre
569 >
570 >        '    swSketchSegment = vSketchSegments(0) ' le midpoint d'une poutre
571 >        '    Commun.GetMidPointSegment(swSketchSegment, x2, y2, z2)
572 >
573 >        '    swSketchSegment = vSketchSegments(1) ' le midpoint de l'autre poutre
574 >        '    Commun.GetMidPointSegment(swSketchSegment, x3, y3, z3)
575 >
576 >        '    Dim sk(1) As Double, r(2) As Double
577 >        '    sk(0) = (x3 + x2) / 2
578 >        '    sk(1) = (y3 + y2) / 2
579 >        '    r = Commun.TransfertSketchToModel(swSketch, sk)
580 >
581 >        '    swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
582 >        '    swModel.ClearSelection2(True)
583 >        '    swEnt = MeFace : swEnt.Select2(False, 1)
584 >        '    swEnt = swSketch : swEnt.Select2(True, 4)
585 >
586 >        '    swModel.InsertSplitLineProject(False, False)
587 >
588 >        '    Me.Flag = 20 ' pour dire que l'on a un coupeLong
589 >        '    faceinterne(b) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), swPlan) ' et ça s'occupe de créer la coque... mais je suis pas certain que c'est nécessaire
590 >        '    Me.Flag = 0
591  
592  
696            ' sketchoffset doit avoir un mark de 1 pour l'objet à offsetter.  Une valeur négative inverse la direction
697            swModel.SketchManager.SketchOffset(poutre.GetD2, False, 0, 0, 0, 0)
698            ' pour rendre le modèle plus beau, on peut enlever la contrainte de offset et laisser solidworks mettre des contraintes automatiques...
699
700            Dim retval As Object
701            Dim skPointA1 As SldWorks.SketchPoint = Nothing, skPointA2 As SldWorks.SketchPoint = Nothing, skPointB1 As SldWorks.SketchPoint = Nothing, skPointB2 As SldWorks.SketchPoint = Nothing
702
703            vSketchSegments = swSketch.GetSketchSegments()
704            swSketchSegment = vSketchSegments(1)
705
706
707            Select Case swSketchSegment.GetType()
708                Case 0 ' on a une ligne
709                    Dim sketchline As SldWorks.SketchLine
710                    sketchline = swSketchSegment
711                    skPointA1 = sketchline.GetStartPoint2
712                    skPointA2 = sketchline.GetEndPoint2()
713                Case 1 ' arc
714                    Dim arc As SldWorks.SketchArc
715                    arc = swSketchSegment
716                    skPointA1 = arc.GetStartPoint
717                    skPointA2 = arc.GetEndPoint2
718                Case 2 ' ellipse
719                    Dim sketchEllipse As SldWorks.SketchEllipse
720                    sketchEllipse = swSketchSegment
721                    skPointA1 = sketchEllipse.GetStartPoint2
722                    skPointA2 = sketchEllipse.GetEndPoint2
723                Case 3 ' spline
724                    Dim spline As SldWorks.SketchSpline
725                    Dim pts() As SldWorks.SketchPoint
726                    spline = swSketchSegment
727                    retval = spline.GetPoints2()
728                    pts = retval
729                    skPointA1 = pts(0)
730                    skPointA2 = pts(UBound(pts))
731                Case 5 ' parabole (le 4 est du texte)
732                    Dim para As SldWorks.SketchParabola
733                    para = swSketchSegment
734                    skPointA1 = para.GetStartPoint2
735                    skPointA2 = para.GetEndPoint2
736            End Select
737
738            swSketchSegment = vSketchSegments(0)
739            Select Case swSketchSegment.GetType()
740                Case 0 ' on a une ligne
741                    Dim sketchline As SldWorks.SketchLine
742                    sketchline = swSketchSegment
743                    skPointB1 = sketchline.GetStartPoint2
744                    skPointB2 = sketchline.GetEndPoint2()
745                Case 1 ' arc
746                    Dim arc As SldWorks.SketchArc
747                    arc = swSketchSegment
748                    skPointB1 = arc.GetStartPoint
749                    skPointB2 = arc.GetEndPoint2
750                Case 2 ' ellipse
751                    Dim sketchEllipse As SldWorks.SketchEllipse
752                    sketchEllipse = swSketchSegment
753                    skPointB1 = sketchEllipse.GetStartPoint2
754                    skPointB2 = sketchEllipse.GetEndPoint2
755                Case 3 ' spline
756                    Dim spline As SldWorks.SketchSpline
757                    Dim pts() As SldWorks.SketchPoint
758                    spline = swSketchSegment
759                    retval = spline.GetPoints2()
760                    pts = retval
761                    skPointB1 = pts(0)
762                    skPointB2 = pts(UBound(pts))
763                Case 5 ' parabole (le 4 est du texte)
764                    Dim para As SldWorks.SketchParabola
765                    para = swSketchSegment
766                    skPointB1 = para.GetStartPoint2
767                    skPointB2 = para.GetEndPoint2
768            End Select
769
770            ' création des 2 lignes pour fermer le sketch.
771            swModel.CreateLine2(skPointA1.X, skPointA1.Y, 0, skPointB1.X, skPointB1.Y, 0)
772            swModel.CreateLine2(skPointA2.X, skPointA2.Y, 0, skPointB2.X, skPointB2.Y, 0)
773
774
775            Dim x2 As Double, y2 As Double, z2 As Double ' le midpoint de la poutre
776            Dim x3 As Double, y3 As Double, z3 As Double ' le midpoint de la poutre
777
778            swSketchSegment = vSketchSegments(0) ' le midpoint d'une poutre
779            Commun.GetMidPointSegment(swSketchSegment, x2, y2, z2)
780
781            swSketchSegment = vSketchSegments(1) ' le midpoint de l'autre poutre
782            Commun.GetMidPointSegment(swSketchSegment, x3, y3, z3)
783
784            Dim sk(1) As Double, r(2) As Double
785            sk(0) = (x3 + x2) / 2
786            sk(1) = (y3 + y2) / 2
787            r = Commun.TransfertSketchToModel(swSketch, sk)
788
789            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
790            swModel.ClearSelection2(True)
791            swEnt = MeFace : swEnt.Select2(False, 1)
792            swEnt = swSketch : swEnt.Select2(True, 4)
793
794            swModel.InsertSplitLineProject(False, False)
795
796            Me.Flag = 20 ' pour dire que l'on a un coupeLong
797            faceinterne(b) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), swPlan) ' et ça s'occupe de créer la coque... mais je suis pas certain que c'est nécessaire
798            Me.Flag = 0
799
800            'If faceinterne(b) Is Nothing Then
801            'swEnt = swSketch
802            'swEnt.Select(False)
803            'swModel.EditDelete()
804            'End If
805
806
807
808            ' reste à updater, on doit ajouter de 2 à 4 mini-poutres
809            'Dim vEdges As Object
810            'Dim Arete As SldWorks.Edge
811            'Dim vFaces As Object
812            'Dim aretePoutre As SldWorks.Edge
813
814
815            ''For b = 0 To 1
816            ''If Not faceinterne(b) Is Nothing Then
817            'b = 0
818            'While faceinterne(b) Is Nothing
819            '    b += 1
820            'End While
821
822            'vEdges = faceinterne(b).GetEdges
823            'For Each Arete In vEdges
824            '    If Distance(Arete.GetStartVertex, inter.x, inter.y, inter.z) < Epsilon Then swSommet = Arete.GetStartVertex : Exit For
825            '    If Distance(Arete.GetEndVertex, inter.x, inter.y, inter.z) < Epsilon Then swSommet = Arete.GetEndVertex : Exit For
826            'Next
827
828            'Dim T As Double
829            'Dim xyz(2) As Double
830            'Dim g As Integer
831            'Dim courbe As SldWorks.Curve
832
833            'T = poutre.GetT(inter.x, inter.y, inter.z)
834
835            'vEdges = swSommet.GetEdges
836
837            'T -= 10000 * Epsilon
838
839            'For g = 0 To UBound(vEdges) ' boucle pas optimisée en vitesse
840            '    Arete = vEdges(g)
841            '    If poutre.Evaluer(T, xyz) Then
842            '        courbe = Arete.GetCurve
843            '        If Distance(courbe, xyz(0), xyz(1), xyz(2)) < Epsilon Then aretePoutre = Arete
844            '    ElseIf poutre.Evaluer(T + 20000 * Epsilon, xyz) Then
845            '        courbe = Arete.GetCurve
846            '        If Distance(courbe, xyz(0), xyz(1), xyz(2)) < Epsilon Then aretePoutre = Arete ' la distance devrait être entre la droite (et non l'arête) et le point.
847            '    End If
848            'Next g
849
850
851            'If aretePoutre Is Nothing Then
852            '    ' putain d'enfoiré de merde!!!! on trouve pas la courbe de la poutre. alors on sort avec dignité!
853            '    Exit Sub
854            '    ' anyway on avait dit en réunion de ne pas mettre de minipoutres...
855            'End If
856
857
858            '' on a l'arète de la poutre, avec la boucle de la face on prend une arète avant et une arête après.
859            'Dim swBoucle As SldWorks.Loop2
860            'Dim AreteAvant As SldWorks.Edge, AreteSuivant As SldWorks.Edge, areteTest As SldWorks.Edge
861            'Dim varete As Object
862            'Dim Mini1 As SldWorks.Edge, Mini2 As SldWorks.Edge, Mini3 As SldWorks.Edge, Mini4 As SldWorks.Edge
863
864            'Dim j As Integer
865
866            'If Not faceinterne(0) Is Nothing Then
867            '    swBoucle = faceinterne(0).GetFirstLoop ' devrait y en avoir juste une...
868            '    varete = swBoucle.GetEdges()
869
870            '    For j = 0 To UBound(varete)
871            '        areteTest = varete(j)
872            '        If areteTest Is aretePoutre Then
873            '            If j <> 0 Then Mini1 = varete(j - 1) Else Mini1 = varete(UBound(varete))
874            '            If j <> UBound(varete) Then Mini2 = varete(j + 1) Else Mini2 = varete(0)
875            '        End If
876            '    Next j
877            'End If
878
879            'If Not faceinterne(1) Is Nothing Then
880            '    swBoucle = faceinterne(1).GetFirstLoop ' devrait y en avoir juste une...
881            '    varete = swBoucle.GetEdges()
882
883            '    For j = 0 To UBound(varete)
884            '        areteTest = varete(j)
885            '        If areteTest Is aretePoutre Then
886            '            If j <> 0 Then Mini3 = varete(j - 1) Else Mini3 = varete(UBound(varete))
887            '            If j <> UBound(varete) Then Mini4 = varete(j + 1) Else Mini4 = varete(0)
888            '        End If
889            '    Next j
890            'End If
891            'If Not Mini1 Is Nothing Then
892            '    swEnt = Mini1
893            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
894            'End If
895
896            'If Not Mini2 Is Nothing Then
897            '    swEnt = Mini2
898            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
899            'End If
900
901            'If Not Mini3 Is Nothing Then
902            '    swEnt = Mini3
903            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
904            'End If
905
906            'If Not Mini4 Is Nothing Then
907            '    swEnt = Mini4
908            '    If Not RealConstant.RCCode.CreationAttributPourPoutre(swEnt, "Mini", True) Then MsgBox("A pas marché!")
909            'End If
910        Next MeFace
911
912
913        swModel.SetInferenceMode(True) ' ne pas mettre de contraintes par défaut
914        'swModel.SetAddToDB(False)
915        'swModel.SetDisplayWhenAdded(True) ' accélérer les performances
916
593      End Sub
594  
595  
920    ' sub qui coupe la face normalement, avec un X.... [cas #1]
921    Friend Sub CoupeX(ByRef inter As InterPoutreVolume, ByRef poutre As SlyAretePoutre)
922
923        Dim swEnt As SldWorks.Entity = Nothing
924        Dim Directionnel As Boolean, Flip As Boolean
925        Dim Faces(3) As SldWorks.Face2
926        Dim r(2) As Double
927        Dim LaSurface As SldWorks.Surface
928        Dim sens As Boolean
929        Dim p(2) As Double
930        Dim retour() As Double
931
932        swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
933        'swModel.SetAddToDB(True)
934        'swModel.SetDisplayWhenAdded(False) ' accélérer les performances
935
936
937        ' l'idée est de sélectionner le point et l'arète puis d'utiliser CreatePlanePerCurveAndPassPoint3
938        Dim planReference As SldWorks.RefPlane
939        Dim swsketch As SldWorks.Sketch
940        Dim swSommet As SldWorks.Vertex, swSommet2 As SldWorks.Vertex
941        Dim pointdeb(2) As Double, pointfin(2) As Double
942
943        'swModel.Extension.SelectByID2("", "POINTREF", inter.x, inter.y, inter.z, False, 0, Nothing, 0)
944        ' faut vraiment sélectionner le bon point...
945        swSommet = poutre.swArete.GetStartVertex()
946        swSommet2 = poutre.swArete.GetEndVertex()
947        If swSommet Is Nothing Then
948            MsgBox("On a un cercle ou courbe sans sommets, dans coupeX, pas encore traité.  Ne peut pas mettre un plan si pas de sommet")
949        Else
950            If Distance(swSommet, inter.x, inter.y, inter.z) < Epsilon Then
951                swEnt = swSommet
952            ElseIf Distance(swSommet2, inter.x, inter.y, inter.z) < Epsilon Then
953                swEnt = swSommet2
954            Else
955                MsgBox("Dans coupeX, l'intersection n'est pas sur un sommet.  Pas encore traité.  Nécessite de créer un point au coordonnées d'intersection")
956            End If
957        End If
958
959        swEnt.Select4(False, Nothing)
960        swEnt = poutre.swArete
961        swEnt.Select(True)
962
963        If Me.estPlan Or Me.estFauxPlan(inter.x, inter.y, inter.z) Then
964            ' si la coque est plane alors on projette le plan de référence des deux cotés, sinon on doit le décaler vers le bas
965            planReference = swModel.CreatePlanePerCurveAndPassPoint3(True, True)
966            Directionnel = False
967            Flip = False
968        ElseIf Me.estCylindre Then
969            ' on a un cylindre, on ne projette pas des 2 cotés.  On créé un plan, puis un autre plus bas pour ensuite projeter d'un seul coté.
970            Dim PlanDessus As SldWorks.RefPlane
971            Dim Rayon As Double, L As Double, B As Double, phi As Double, dist As Double, temp1 As Double, temp2 As Double
972            Dim u(2) As Double, v(2) As Double
973            PlanDessus = swModel.CreatePlanePerCurveAndPassPoint3(True, True)
974            temp1 = poutre.GetD1
975            temp2 = poutre.GetD2
976            L = Math.Sqrt(temp1 * temp1 + temp2 * temp2)
977            Rayon = Me.GetRayonCylindre()
978            u = poutre.GetOrientation(inter.x, inter.y, inter.z)
979            v = Me.GetNormale(inter.x, inter.y, inter.z)
980            phi = -(Math.Acos(Outils_Math.cosdir(u, v)))
981            B = Math.Abs(L / 2 * Math.Sin(phi))
982            dist = Rayon - Math.Sqrt(Rayon * Rayon - ((L / 2) * (L / 2))) + B
983            If dist < 0 Then MsgBox("Gros problème pour couper le cylindre, la poutre est plus grosse!!!!!!", MsgBoxStyle.Critical) : Exit Sub
984
985            swEnt = PlanDessus
986            swEnt.Select(False)
987            Directionnel = True
988
989            Flip = Flipper(PlanDessus, inter)
990
991            planReference = swModel.CreatePlaneAtOffset3(dist * 2, Flip, True)
992        Else
993            MsgBox("La coque n'est ni un cylindre, ni un plan" & vbCr & "Le résultat n'est pas certain...", MsgBoxStyle.Information, "Avertissement")
994            planReference = swModel.CreatePlanePerCurveAndPassPoint3(True, True)
995            Directionnel = False
996            Flip = False
997        End If
998
999
1000
1001        LaSurface = Me.SwFace.GetSurface()
1002        sens = Me.SwFace.FaceInSurfaceSense()
1003
1004        ' skx est la coordonnée du point de ref en coord de sketch, Rx est le point de référence dans le repère global.
1005        Dim i As Integer, MettreFI As Boolean
1006        Dim swFeat As SldWorks.Feature
1007
1008        For i = 0 To 1
1009
1010            swEnt = planReference
1011            swEnt.Select(False)
1012            swModel.InsertSketch2(False)
1013            swModel.ClearSelection2(True)
1014            swFeat = swModel.FeatureByPositionReverse(0)
1015            swModel.SelectByID(swFeat.Name, "SKETCH", 0, 0, 0)
1016            swModel.EditSketch()
1017            swsketch = swModel.GetActiveSketch2
1018
1019            p(0) = inter.x : p(1) = inter.y : p(2) = inter.z
1020            retour = Commun.TransfertModelSketch(swsketch, p)
1021
1022
1023            r = DessineSectionPoutre(poutre, retour(0), retour(1), i + 1, swsketch, inter, MettreFI)
1024            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
1025            swModel.ClearSelection2(True)
1026
1027            Dim face As SldWorks.Face2
1028            For Each face In Me.lst_Faces
1029                swModel.ClearSelection2(True)
1030                swEnt = face : swEnt.Select2(False, 1)
1031                swEnt = swsketch : swEnt.Select2(True, 4)
1032                swModel.InsertSplitLineProject(Directionnel, Flip)
1033            Next
1034
1035
1036            Me.SwFace.DetachSurface()
1037            Me.SwFace.AttachSurface(LaSurface, sens)
1038
1039            Faces(i) = UpdateApresSplit(inter, poutre, r(0), r(1), r(2), planReference, MettreFI)
1040            Commun.MettreUnPoint(r(0), r(1), r(2))
1041
1042            If Faces(i) Is Nothing Then
1043                swEnt.Select(False)
1044                swModel.EditDelete()
1045            End If
1046            If Flag = 2 Then Flag = 0 : Exit For
1047
1048        Next i
1049
1050        swModel.SetInferenceMode(True)
1051        'swModel.SetAddToDB(False)
1052        'swModel.SetDisplayWhenAdded(True)
596  
597 +    ''' <summary>
598 +    ''' Sub qui appelle le découpage de la face
599 +    ''' </summary>
600 +    ''' <remarks>On devrait revoir cette sub en fonction des nouveaux outils de VB2005</remarks>
601 +    Public Overridable Sub decouper()
602 +        MsgBox("La fonction non Overridé a été appelée!")
603      End Sub
604  
605  
606 <    ' Sub qui appelle le découpage de la face
607 <    Public Sub decouper()
608 <
609 <        If lst_InterPoutre.Count = 0 Then Exit Sub ' sortir si on a pas d'intersection
610 <
611 <
612 <        ' les attributs ne sont pas updatés sur les faces (mais sur les arètes et les sommets c'est OK)
613 <        ' on mémorise l'attribut de la face et on la réapplique à la fin.
614 <
615 <
616 <        Dim i As Integer
617 <        Dim inter As InterPoutreVolume
618 <        Dim nb1 As Integer, nb2 As Integer, nb3 As Integer, nb5 As Integer
619 <        Dim poutre1 As SlyAretePoutre = Nothing, poutre3 As SlyAretePoutre = Nothing
620 <        Dim lst_poutre2 As New Collection
621 <        Dim aire As Double
622 <        Dim poutreTest As SlyAretePoutre
623 <
1075 <        Dim lst_coupeXinter As New Collection
1076 <        Dim lst_coupeXPoutre As New Collection
1077 <        Dim lst_coupeLinter As New Collection
1078 <        Dim lst_coupeLPoutre As New Collection
1079 <        Dim lst_coupeCinter As New Collection
1080 <        Dim lst_coupeCPoutre As New Collection
1081 <
1082 <
1083 <        For Each inter In lst_InterPoutre
1084 <
1085 <            'pour chaque intersection on peut avoir plusieurs poutres...
1086 <            For i = 1 To inter.lst_sPoutre.Count
1087 <                poutreTest = inter.lst_sPoutre.Item(i)
1088 <                Select Case CInt(inter.lst_type.Item(i))
1089 <                    Case 1
1090 <                        If poutreTest.GetAireCarree > aire Then poutre1 = poutreTest
1091 <                        nb1 += 1
1092 <                    Case 2
1093 <                        lst_poutre2.Add(poutreTest)
1094 <                        nb2 += 1
1095 <                    Case 3
1096 <                        If poutreTest.GetAireCarree > aire Then poutre3 = poutreTest
1097 <                        nb3 += 1
1098 <                    Case 5 ' un poutre à faceDeSection
1099 <                        nb5 += 1
1100 <                    Case 22
1101 <                        ' on fait rien, mais c'est pour éviter le msgbox du case else...
1102 <                    Case Else
1103 <                        MsgBox("Problème dans découper de SlyFaceCoque, le type d'intersection n'est pas reconnu", MsgBoxStyle.Critical)
1104 <                End Select
1105 <            Next i
1106 <
1107 <
1108 <
1109 <            If nb1 > 0 Then 'CoupeX(inter, poutre1) ' on coupe le x en premier
1110 <                lst_coupeXinter.Add(inter)
1111 <                lst_coupeXPoutre.Add(poutre1)
1112 <            End If
1113 <
1114 <
1115 <            For Each poutreTest In lst_poutre2 ' puis on coupe sur la longueur 'CoupeLong(inter, poutreTest)
1116 <                lst_coupeLinter.Add(inter)
1117 <                lst_coupeLPoutre.Add(poutreTest)
606 >    ''' <summary>
607 >    ''' Renvoie le nombre d'arêtes dans la face principale
608 >    ''' </summary>
609 >    ''' <value></value>
610 >    ''' <returns></returns>
611 >    ''' <remarks></remarks>
612 >    Public ReadOnly Property NbSommets() As Integer
613 >        Get
614 >            Dim lst_sommets As New Collections.Generic.List(Of sldworks.Vertex)
615 >            Dim swSommet As sldworks.Vertex = Nothing
616 >            Dim vedges As Object = Me.SwFace.GetEdges
617 >            For Each edge As sldworks.Edge In vedges
618 >                swSommet = edge.GetStartVertex
619 >                If swSommet IsNot Nothing Then
620 >                    lst_sommets.Add(swSommet)
621 >                    swSommet = edge.GetEndVertex
622 >                    lst_sommets.Add(swSommet)
623 >                End If
624              Next
625 +            Return lst_sommets.Count
626 +        End Get
627 +    End Property
628  
629 <            If nb3 > 0 Then 'CoupeCote(inter, poutre3) ' finalement on coupe sur les cotés
630 <                lst_coupeCinter.Add(inter)
631 <                lst_coupeCPoutre.Add(poutre3)
632 <            End If
633 <
634 <            If nb5 = 1 And (nb1 > 0 Or nb2 > 0 Or nb3 > 0) Then
635 <                MsgBox("Problème, on a un type d'intersection impossible dans la vraie vie!", MsgBoxStyle.Exclamation, "Design impossible à obtenir en réalité...")
1127 <            End If
1128 <
1129 <
1130 <            lst_poutre2.Clear()
1131 <            nb1 = 0 : nb2 = 0 : nb3 = 0
1132 <
1133 <
1134 <        Next inter
1135 <
1136 <
1137 <        ' maintenant on a toutes les lists d'intersections.  On les coupe.
1138 <        For i = 1 To lst_coupeXinter.Count
1139 <            CoupeX(lst_coupeXinter.Item(i), lst_coupeXPoutre.Item(i))
1140 <        Next
1141 <
1142 <        For i = 1 To lst_coupeLinter.Count
1143 <            CoupeLong(lst_coupeLinter.Item(i), lst_coupeLPoutre.Item(i))
1144 <        Next
1145 <
1146 <        For i = 1 To lst_coupeCinter.Count
1147 <            CoupeCote(lst_coupeCinter.Item(i), lst_coupeCPoutre.Item(i))
1148 <        Next
1149 <        If nb5 = 1 Then
1150 <            If lst_InterPoutre.Count <> 1 Then MsgBox("Plus d'une intersection du type FacedeSection....")
1151 <            CoupeFaceDeSection(lst_InterPoutre(1))
1152 <        End If
1153 <
1154 <    End Sub
1155 <
1156 <    Private Sub CoupeFaceDeSection(ByRef inter As InterPoutreVolume)
1157 <        Dim swEnt As SldWorks.Entity = Nothing
629 >    ''' <summary>
630 >    ''' Coupe si nécesaire la face lorsque l'on a une poutre avec face de section.  À noter que si l'on coupe c'est avec un angle de pi / 8
631 >    ''' </summary>
632 >    ''' <param name="inter"></param>
633 >    ''' <remarks></remarks>
634 >    Protected Sub CoupeFaceDeSection(ByRef inter As InterPoutreVolume)
635 >        Dim swEnt As sldworks.Entity = Nothing
636          Dim Directionnel As Boolean
637 <        Dim Faces(3) As SldWorks.Face2
637 >        Dim Faces(3) As sldworks.Face2
638          Dim r(2) As Double
639          Dim p(2) As Double
640 <        Dim planReference As SldWorks.RefPlane = Nothing
641 <        Dim swsketch As SldWorks.Sketch
640 >        Dim planReference As sldworks.RefPlane = Nothing
641 >        Dim swsketch As sldworks.Sketch
642          Dim pointdeb(2) As Double, pointfin(2) As Double
643 <        Dim sketchline As SldWorks.SketchLine
644 <        Dim swFeat As SldWorks.Feature
643 >        Dim sketchline As sldworks.SketchLine
644 >        Dim swFeat As sldworks.Feature
645  
646  
647          swModel.SetInferenceMode(False) ' ne pas mettre de contraintes par défaut
# Line 1173 | Line 651 | Public Class SuperFace
651          swModel.InsertSketch2(False)
652          swsketch = swModel.GetActiveSketch2
653  
654 <        ' dessin de la forme à faire...
654 >        ' dessin de la forme à faire SI NÉCESSAIRE
655 >        If Me.NbSommets = 0 OrElse Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
656  
657 <        Dim xyzc() As Double, xyz(2) As Double
658 <        xyz(0) = inter.x : xyz(1) = inter.y : xyz(2) = inter.z
659 <        xyzc = Commun.TransfertModelSketch(swsketch, xyz)
657 >            Dim xyzc() As Double, xyz(2) As Double
658 >            xyz(0) = inter.x : xyz(1) = inter.y : xyz(2) = inter.z
659 >            xyzc = Commun.TransfertModelSketch(swsketch, xyz)
660 >
661 >            sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0)
662 >            sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) - Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0)
663 >            swModel.CreateArc2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0, xyzc(0) - Math.Cos(Pi / 8), xyzc(1) + Math.Sin(Pi / 8), 0, 1) ' le dernier param est la direction.  1 ou -1
664  
665 <        sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0)
666 <        sketchline = swModel.CreateLine2(xyzc(0), xyzc(1), 0, xyzc(0) - Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0)
1184 <        swModel.CreateArc2(xyzc(0), xyzc(1), 0, xyzc(0) + Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0, xyzc(0) - Math.Cos(Pi / 4), xyzc(1) + Math.Sin(Pi / 4), 0, 1) ' le dernier param est la direction.  1 ou -1
1185 <
1186 <        swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
1187 <        swModel.ClearSelection2(True)
665 >            swModel.InsertSketch2(True) ' l'option true rebuild le modèle avec les modifications du sketch.
666 >            swModel.ClearSelection2(True)
667  
668 <        swEnt = Me.SwFace : swEnt.Select2(False, 1)
669 <        swEnt = swsketch : swEnt.Select2(True, 4)
670 <        swModel.InsertSplitLineProject(Directionnel, False)
668 >            swEnt = Me.SwFace : swEnt.Select2(False, 1)
669 >            swEnt = swsketch : swEnt.Select2(True, 4)
670 >            swModel.InsertSplitLineProject(Directionnel, False)
671  
672  
673 <        ' flagger les 2 faces comme faces Internes.
674 <        Dim vface As Object
675 <        Dim face As SldWorks.Face2
676 <        Dim attr As SldWorks.Attribute
677 <        swFeat = swModel.FeatureByPositionReverse(0)
678 <        Try
679 <            vface = swFeat.GetFaces
680 <            For Each face In vface
681 <                '**************
682 <                Dim nom2 As String = "FaceInterne" & no
683 <                swEnt = face
684 <                attr = swEnt.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
685 <                If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom2, 0, 2) ' 0 = swThisconfig
686 <                While attr Is Nothing
687 <                    no += 1
688 <                    nom2 = "FaceInterne" & CStr(no)
689 <                    attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom2, 0, 2)
690 <                End While
691 <                GererDossiers("FaceInternes", nom2)
692 <                no += 1
1214 <
1215 <
1216 <                '**************
1217 <                Me.AjouterFace(face)
1218 <            Next face
1219 <        Catch
1220 <            ' si on a une poutre dessinée en partie, on aura pas de feature... mais on a la face...
1221 <            ' on doit donc le déterminer anyway
1222 <        End Try
673 >            ' flagger les 2 faces comme faces Internes.
674 >            Dim vface As Object
675 >            Dim face As sldworks.Face2 = Nothing
676 >            swFeat = swModel.FeatureByPositionReverse(0)
677 >            Try
678 >                vface = swFeat.GetFaces
679 >                For Each face In vface
680 >                    no = Me.MettreAttributFaceInterne(face, 2 * Me.Aire / Me.Perimetre, True) ' plus certain que l'on a besoin du numéro
681 >                    Me.AjouterFace(face)
682 >                Next face
683 >            Catch
684 >                ' si on a une poutre dessinée en partie, on aura pas de feature... mais on a la face...
685 >                ' on doit donc le déterminer anyway
686 >            End Try
687 >
688 >            ' si ça ne touche pas à la face
689 >            If Not Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
690 >                AjouterMiniPoutresSurFaceInterne(inter.lst_sPoutre.Item(1), face, inter.x, inter.y, inter.z)
691 >                'MsgBox("On ajoute une mini-poutre entre la poutre " & inter.lst_sPoutre.Item(1).nom & vbCr & " et le point ( " & Format(inter.x * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " )")
692 >            End If
693  
694 <        ' si ça ne touche pas à la face
695 <        If Not Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
696 <            AjouterMiniPoutresSurFaceInterne(inter.lst_sPoutre.Item(1), face, inter.x, inter.y, inter.z)
697 <            'MsgBox("On ajoute une mini-poutre entre la poutre " & inter.lst_sPoutre.Item(1).nom & vbCr & " et le point ( " & Format(inter.x * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " )")
694 >        Else ' flagger la seule face comme face interne
695 >            Me.MettreAttributFaceInterne(Me.SwFace, 2 * Me.Aire / Me.Perimetre, True)
696 >            If Not Distance(Me.SwFace, inter.x, inter.y, inter.z) < Epsilon Then
697 >                AjouterMiniPoutresSurFaceInterne(inter.lst_sPoutre.Item(1), Me.SwFace, inter.x, inter.y, inter.z)
698 >                'MsgBox("On ajoute une mini-poutre entre la poutre " & inter.lst_sPoutre.Item(1).nom & vbCr & " et le point ( " & Format(inter.x * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " , " & Format(inter.y * 1000, "0000") & " )")
699 >            End If
700          End If
1229
701          swModel.SetInferenceMode(True)
702  
703      End Sub
704  
705  
706      Friend Overridable Sub chercherAttributs()
707 <        Dim swEnt As SldWorks.Entity
708 <        Dim attr As SldWorks.Attribute
707 >        Dim swEnt As sldworks.Entity
708 >        Dim attr As sldworks.Attribute
709  
710          swEnt = Me.SwFace
711  
# Line 1245 | Line 716 | Public Class SuperFace
716  
717      End Sub
718  
719 <    Private Function Flipper(ByRef PlanDessus As SldWorks.RefPlane, ByRef inter As InterPoutreVolume) As Boolean
719 >    Protected Function Flipper(ByRef PlanDessus As sldworks.RefPlane, ByRef inter As InterAreteFace) As Boolean
720          ' function qui dit si l'on doit flipper le sens du plan de référence.
721          ' calcul de la direction à prendre
722          Dim retval As Object
# Line 1253 | Line 724 | Public Class SuperFace
724          Dim ret2(6) As Double
725          Dim normalePlan(2) As Double
726          Dim OV(2) As Double
727 <        Dim swSurf As SldWorks.Surface
727 >        Dim swSurf As sldworks.Surface
728  
729          retval = PlanDessus.GetRefPlaneParams()
730          ret = retval
731          normalePlan(0) = ret(6) : normalePlan(1) = ret(7) : normalePlan(2) = ret(8)
732 <        swSurf = Me.lst_Faces.Item(1).GetSurface
732 >        swSurf = Me.lst_Faces.Item(0).GetSurface
733          retval = swSurf.CylinderParams() ' 7 doubles, les 3 premiers sont l'origine
734          ret2 = retval
735          OV(0) = ret2(0) - inter.x : OV(1) = ret2(1) - inter.y : OV(2) = ret2(2) - inter.z
# Line 1269 | Line 740 | Public Class SuperFace
740  
741      End Function
742  
743 <
744 <    Private Function DessineSectionPoutre(ByRef Poutre As SlyAretePoutre, ByVal TranslationX As Double, ByVal TranslationY As Double, ByVal numero As Integer, ByRef swSketch As SldWorks.Sketch, ByRef inter As InterPoutreVolume, ByRef MettreFI As Boolean) As Double()
743 >    ''' <summary>
744 >    ''' Sub qui dessine (insère des lignes) sur le sketch en fonction de la forme de la poutre.
745 >    ''' </summary>
746 >    ''' <param name="Poutre"></param>
747 >    ''' <param name="TranslationX"></param>
748 >    ''' <param name="TranslationY"></param>
749 >    ''' <param name="numero"></param>
750 >    ''' <param name="swSketch"></param>
751 >    ''' <param name="inter"></param>
752 >    ''' <param name="MettreFI"></param>
753 >    ''' <returns></returns>
754 >    ''' <remarks>Si Flag = 2 alors on met une faceInterne ET une mini-poutre</remarks>
755 >    Protected Function DessineSectionPoutre(ByRef Poutre As SlyAretePoutre, ByVal TranslationX As Double, ByVal TranslationY As Double, ByVal numero As Integer, ByRef swSketch As sldworks.Sketch, ByRef inter As InterAreteFace, ByRef MettreFI As Boolean, ByRef autreSection As Boolean, ByRef AjouterMiniPoutre As Boolean) As Double()
756          ' le sketch est déjà inséré, il faut juste mettre des swmodel.line ou autre
757          ' doit retourner r() qui est un point situé à l'intérieur de la coupe
758 <        Dim sketchline As SldWorks.SketchSegment
758 >        Dim sketchline As sldworks.SketchSegment
759          Dim longueur As Double
760          Dim r(2) As Double
761          Dim sk(1) As Double
# Line 1324 | Line 806 | Public Class SuperFace
806                      r(1) = inter.y + 5000 * Epsilon * IP(1)
807                      r(2) = inter.z + 5000 * Epsilon * IP(2)
808  
809 +                    autreSection = True
810 +                    AjouterMiniPoutre = False
811 +                    MettreFI = True
812 +
813                  Case 2
814                      ReDim Ligne(19)
815  
# Line 1357 | Line 843 | Public Class SuperFace
843                      r(1) = inter.y - 5000 * Epsilon * IP(1)
844                      r(2) = inter.z - 5000 * Epsilon * IP(2)
845  
846 +                    autreSection = False
847 +                    AjouterMiniPoutre = False
848 +                    MettreFI = True
849              End Select
850 <            MettreFI = True
850 >
851 >
852          ElseIf Left(Nomsection, 2) = "ST" Or Nomsection = " Tube carré générique" Then ' tube carré troué
853              Dim P(3, 1) As Double
854              Select Case numero
# Line 1372 | Line 862 | Public Class SuperFace
862                      P(3, 0) = P(2, 0)
863                      P(3, 1) = P(0, 1)
864  
865 <                    r(0) = P(0, 0) - 1000 * Epsilon
865 >                    r(0) = Poutre.GetD1 / 2 - Poutre.GetD3 / 2
866                      r(1) = 0 : r(2) = 0
867                      Outils_Math.Rotation2D(pt3, r(0), r(1))
868                      r(0) += TranslationX
# Line 1394 | Line 884 | Public Class SuperFace
884                      Ligne(8) = P(2, 0) : Ligne(9) = P(2, 1) : Ligne(10) = P(3, 0) : Ligne(11) = P(3, 1)
885                      Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
886                      MettreFI = False
887 +                    autreSection = True
888 +                    AjouterMiniPoutre = False
889  
890                  Case 2
891                      P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
# Line 1405 | Line 897 | Public Class SuperFace
897                      P(3, 0) = P(2, 0)
898                      P(3, 1) = P(0, 1)
899  
900 <                    r(0) = P(0, 0) + 1000 * Epsilon
900 >                    r(0) = Poutre.GetD1 / 2 - Poutre.GetD3 / 2
901                      r(1) = 0 : r(2) = 0
902                      Outils_Math.Rotation2D(pt3, r(0), r(1))
903                      r(0) += TranslationX
# Line 1428 | Line 920 | Public Class SuperFace
920                      Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
921  
922                      MettreFI = True  ' lorsque l'on sort on met une face interne
923 +                    autreSection = False
924 +                    AjouterMiniPoutre = True
925  
926              End Select
927  
# Line 1476 | Line 970 | Public Class SuperFace
970                      r(0) = inter.x + 5000 * Epsilon * IP(0)
971                      r(1) = inter.y + 5000 * Epsilon * IP(1)
972                      r(2) = inter.z + 5000 * Epsilon * IP(2)
973 +                    autreSection = True
974 +                    AjouterMiniPoutre = False
975 +                    MettreFI = True
976                  Case 2
977  
978                      Dim d As Double
# Line 1519 | Line 1016 | Public Class SuperFace
1016                      r(0) = inter.x - 5000 * Epsilon * IP(0)
1017                      r(1) = inter.y - 5000 * Epsilon * IP(1)
1018                      r(2) = inter.z - 5000 * Epsilon * IP(2)
1019 <
1019 >                    autreSection = False
1020 >                    AjouterMiniPoutre = False
1021 >                    MettreFI = True
1022              End Select
1023              MettreFI = True
1024  
1025 <        ElseIf Left(Nomsection, 4) = "Tube" Or Nomsection = " Tuyau (Pipe) générique" Then ' le tube rond
1025 >        ElseIf Left(Nomsection, 5) = "Tuyau" OrElse Nomsection = " Tuyau (Pipe) générique" Then ' le tube rond
1026              Dim p(4, 1) As Double
1027              p(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1028              p(0, 1) = 0
# Line 1561 | Line 1060 | Public Class SuperFace
1060                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, 1)
1061                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, 1)
1062                      MettreFI = True
1063 <                    'Flag = 2
1063 >                    autreSection = True
1064 >                    AjouterMiniPoutre = False
1065 >
1066                  Case 2
1067  
1068                      r(0) = 0
# Line 1586 | Line 1087 | Public Class SuperFace
1087                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, -1)
1088                      swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, -1)
1089                      'MettreFI = True  ' lorsque l'on sort on met une face interne
1090 <                    MettreFI = False
1091 <                    Me.Flag = 2
1092 <                    'Case 1 ' le cercle extérieur
1592 <                    '    swModel.CreateCircleByRadius2(TranslationX, TranslationY, 0, Poutre.GetD1 / 2)
1593 <                    '    MettreFI = False
1594 <                    '    r(0) = 0 : r(1) = 0 : r(2) = 0
1595 <                    '    r = Commun.TransfertSketchToModel(swSketch, r)
1596 <                    'Case 2
1597 <                    '    swModel.CreateCircleByRadius2(TranslationX, TranslationY, 0, (Poutre.GetD1 / 2) - Poutre.GetD3)
1598 <                    '    r(0) = (Poutre.GetD1 / 2 - (Poutre.GetD3 / 2))
1599 <                    '    r(1) = 0 : r(2) = 0
1600 <                    '    r = Commun.TransfertSketchToModel(swSketch, r)
1601 <                    '    MettreFI = True
1602 <            End Select
1090 >                    MettreFI = true
1091 >                    autreSection = False
1092 >                    AjouterMiniPoutre = True
1093  
1094 <        ElseIf Left(Nomsection, 1) = "C" Or Nomsection = " Poutre en C générique" Then ' le channel
1605 <            Dim P(7, 1) As Double
1094 >            End Select
1095  
1096 <            Select Case numero
1097 <                Case 1 ' le C au complet
1096 >        ElseIf Left(Poutre.GetNomSection, 2) = "Cy" Or Nomsection = " Cylindrique (Rod) générique" Then ' Pipe,
1097 >            Dim P(2, 1) As Double
1098 >            Dim d As Double, e As Double
1099 >            d = Poutre.GetD1 / 4 ' Math.Sin(30)  ( et on doit diviser le diamètre par 2)
1100 >            e = Poutre.GetD1 * Math.Sqrt(3) / 4 ' cos (30°)
1101  
1102 <                    P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1103 <                    P(0, 1) = Poutre.GetD5
1104 <                    P(1, 0) = P(0, 0)
1105 <                    P(1, 1) = Poutre.GetD5 + Poutre.GetD4 - Poutre.GetD2
1106 <                    P(2, 0) = Poutre.GetD1 / 2
1107 <                    P(2, 1) = P(1, 1)
1616 <                    P(3, 0) = P(2, 0)
1617 <                    P(3, 1) = P(1, 1) + Poutre.GetD2
1618 <                    P(4, 0) = -P(3, 0)
1619 <                    P(4, 1) = P(3, 1)
1620 <                    P(5, 0) = P(4, 0)
1621 <                    P(5, 1) = P(1, 1)
1622 <                    P(6, 0) = -P(1, 0)
1623 <                    P(6, 1) = P(5, 1)
1624 <                    P(7, 0) = -P(0, 0)
1625 <                    P(7, 1) = P(0, 1)
1102 >            P(0, 0) = 0
1103 >            P(0, 1) = 0
1104 >            P(1, 0) = d
1105 >            P(1, 1) = -e
1106 >            P(2, 0) = d
1107 >            P(2, 1) = e
1108  
1109 +            Select Case numero
1110 +                Case 1
1111                      r(0) = P(0, 0) + 1000 * Epsilon
1112                      r(1) = 0 : r(2) = 0
1113                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1114                      r(0) += TranslationX
1115                      r(1) += TranslationY
1116                      r = Commun.TransfertSketchToModel(swSketch, r)
1633
1117                      pt3(0) -= TranslationX
1118                      pt3(1) -= TranslationY
1119                      pt3(0) /= longueur : pt3(1) /= longueur
1120 <                    For i = 0 To 7
1120 >                    For i = 0 To 2
1121                          Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1122                          P(i, 0) += TranslationX
1123                          P(i, 1) += TranslationY
1124                      Next i
1125 <
1126 <                    ReDim Ligne(35)
1127 <                    For i = 0 To 6
1128 <                        Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1129 <                    Next i
1130 <                    Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1131 <
1649 <                    MettreFI = False
1650 <                    Me.Flag = 2
1125 >                    ReDim Ligne(7)
1126 >                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1127 >                    Ligne(4) = P(0, 0) : Ligne(5) = P(0, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1128 >                    swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, 1) ' le dernier param est la direction.  1 ou -1
1129 >                    autreSection = True
1130 >                    AjouterMiniPoutre = False
1131 >                    MettreFI = True
1132                  Case 2
1133 <                    MettreFI = False ' Attention, peut planter à cause de ça.
1653 <            End Select
1654 <
1655 <        ElseIf Left(Nomsection, 1) = "L" Or Nomsection = " Poutre en L générique" Then ' l'Angle en L
1656 <            Dim P(5, 1) As Double
1657 <
1658 <            Select Case numero
1659 <                Case 1 ' le C au complet
1660 <
1661 <                    P(0, 0) = -Poutre.GetD5 + Poutre.GetD1
1662 <                    P(0, 1) = -Poutre.GetD6 + Poutre.GetD4
1663 <                    P(1, 0) = -Poutre.GetD5 + Poutre.GetD3
1664 <                    P(1, 1) = P(0, 1)
1665 <                    P(2, 0) = P(1, 0)
1666 <                    P(2, 1) = -Poutre.GetD6 + Poutre.GetD2
1667 <                    P(3, 0) = -Poutre.GetD5
1668 <                    P(3, 1) = P(2, 1)
1669 <                    P(4, 0) = P(3, 0)
1670 <                    P(4, 1) = -Poutre.GetD6
1671 <                    P(5, 0) = P(0, 0)
1672 <                    P(5, 1) = P(4, 1)
1673 <
1674 <                    r(0) = P(1, 0) - 1000 * Epsilon
1133 >                    r(0) = P(0, 0) - 1000 * Epsilon
1134                      r(1) = 0 : r(2) = 0
1135                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1136                      r(0) += TranslationX
# Line 1681 | Line 1140 | Public Class SuperFace
1140                      pt3(0) -= TranslationX
1141                      pt3(1) -= TranslationY
1142                      pt3(0) /= longueur : pt3(1) /= longueur
1143 <                    For i = 0 To 5
1143 >                    For i = 0 To 2
1144                          Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1145                          P(i, 0) += TranslationX
1146                          P(i, 1) += TranslationY
1147                      Next i
1148 +                    ReDim Ligne(7)
1149 +                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1150 +                    Ligne(4) = P(0, 0) : Ligne(5) = P(0, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1151  
1152 <                    ReDim Ligne(35)
1153 <                    For i = 0 To 4
1154 <                        Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1155 <                    Next i
1694 <                    Ligne(20) = P(5, 0) : Ligne(21) = P(5, 1) : Ligne(22) = P(0, 0) : Ligne(23) = P(0, 1)
1695 <
1696 <                    MettreFI = False  ' lorsque l'on sort on met une face interne
1697 <                    Me.Flag = 2
1698 <                Case 2
1699 <                    MettreFI = False ' Attention, peut planter à cause de ça.
1152 >                    swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, -1) ' le dernier param est la direction.  1 ou -1
1153 >                    autreSection = False
1154 >                    AjouterMiniPoutre = False
1155 >                    MettreFI = True
1156              End Select
1157 +            MettreFI = True
1158 +
1159 +
1160 +        ElseIf Left(Nomsection, 1) = "C" Or Nomsection = " Poutre en C générique" Then ' le channel
1161 +            Dim P(7, 1) As Double
1162  
1163 +            P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1164 +            P(0, 1) = Poutre.GetD5
1165 +            P(1, 0) = P(0, 0)
1166 +            P(1, 1) = Poutre.GetD5 + Poutre.GetD4 - Poutre.GetD2
1167 +            P(2, 0) = Poutre.GetD1 / 2
1168 +            P(2, 1) = P(1, 1)
1169 +            P(3, 0) = P(2, 0)
1170 +            P(3, 1) = P(1, 1) + Poutre.GetD2
1171 +            P(4, 0) = -P(3, 0)
1172 +            P(4, 1) = P(3, 1)
1173 +            P(5, 0) = P(4, 0)
1174 +            P(5, 1) = P(1, 1)
1175 +            P(6, 0) = -P(1, 0)
1176 +            P(6, 1) = P(5, 1)
1177 +            P(7, 0) = -P(0, 0)
1178 +            P(7, 1) = P(0, 1)
1179 +
1180 +            r(0) = P(0, 0) + 1000 * Epsilon
1181 +            r(1) = P(0, 1) : r(2) = 0
1182 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1183 +            r(0) += TranslationX
1184 +            r(1) += TranslationY
1185 +            r = Commun.TransfertSketchToModel(swSketch, r)
1186 +
1187 +            pt3(0) -= TranslationX
1188 +            pt3(1) -= TranslationY
1189 +            pt3(0) /= longueur : pt3(1) /= longueur
1190 +            For i = 0 To 7
1191 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1192 +                P(i, 0) += TranslationX
1193 +                P(i, 1) += TranslationY
1194 +            Next i
1195 +
1196 +            ReDim Ligne(35)
1197 +            For i = 0 To 6
1198 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1199 +            Next i
1200 +            Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1201 +
1202 +            MettreFI = True
1203 +            autreSection = False
1204 +            AjouterMiniPoutre = True
1205 +
1206 +
1207 +        ElseIf Left(Nomsection, 1) = "L" Or Nomsection = " Poutre en L générique" Then ' l'Angle en L
1208 +            Dim P(5, 1) As Double
1209 +
1210 +            P(0, 0) = -Poutre.GetD5 + Poutre.GetD1
1211 +            P(0, 1) = -Poutre.GetD6 + Poutre.GetD4
1212 +            P(1, 0) = -Poutre.GetD5 + Poutre.GetD3
1213 +            P(1, 1) = P(0, 1)
1214 +            P(2, 0) = P(1, 0)
1215 +            P(2, 1) = -Poutre.GetD6 + Poutre.GetD2
1216 +            P(3, 0) = -Poutre.GetD5
1217 +            P(3, 1) = P(2, 1)
1218 +            P(4, 0) = P(3, 0)
1219 +            P(4, 1) = -Poutre.GetD6
1220 +            P(5, 0) = P(0, 0)
1221 +            P(5, 1) = P(4, 1)
1222 +
1223 +            r(0) = P(1, 0) - 1000 * Epsilon
1224 +            r(1) = 0 : r(2) = 0
1225 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1226 +            r(0) += TranslationX
1227 +            r(1) += TranslationY
1228 +            r = Commun.TransfertSketchToModel(swSketch, r)
1229 +
1230 +            pt3(0) -= TranslationX
1231 +            pt3(1) -= TranslationY
1232 +            pt3(0) /= longueur : pt3(1) /= longueur
1233 +            For i = 0 To 5
1234 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1235 +                P(i, 0) += TranslationX
1236 +                P(i, 1) += TranslationY
1237 +            Next i
1238 +
1239 +            ReDim Ligne(35)
1240 +            For i = 0 To 4
1241 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1242 +            Next i
1243 +            Ligne(20) = P(5, 0) : Ligne(21) = P(5, 1) : Ligne(22) = P(0, 0) : Ligne(23) = P(0, 1)
1244 +
1245 +            autreSection = False
1246 +            AjouterMiniPoutre = True
1247 +            MettreFI = True
1248  
1249          ElseIf Left(Nomsection, 1) = "T" Or Nomsection = " Poutre en T générique" Then ' le T
1250              Select Case numero
# Line 1710 | Line 1256 | Public Class SuperFace
1256  
1257                      P(0, 0) = 0
1258                      P(0, 1) = 0
1259 <                    P(1, 0) = -d
1259 >                    P(1, 0) = d
1260                      P(1, 1) = -Poutre.GetD4 / 2.0R
1261                      P(2, 0) = -(Poutre.GetD1 - Poutre.GetD5 - Poutre.GetD3)
1262                      P(2, 1) = -Poutre.GetD4 / 2.0R
# Line 1727 | Line 1273 | Public Class SuperFace
1273                      P(8, 0) = P(1, 0)
1274                      P(8, 1) = -P(1, 1)
1275  
1276 <                    r(0) = P(0, 0) + 1000 * Epsilon
1276 >                    r(0) = P(0, 0) - 1000 * Epsilon
1277                      r(1) = 0 : r(2) = 0
1278                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1279                      r(0) += TranslationX
# Line 1748 | Line 1294 | Public Class SuperFace
1294                          Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1295                      Next i
1296                      Ligne(32) = P(8, 0) : Ligne(33) = P(8, 1) : Ligne(34) = P(0, 0) : Ligne(35) = P(0, 1)
1297 <
1297 >                    autreSection = True
1298 >                    AjouterMiniPoutre = False
1299 >                    MettreFI = True
1300                  Case 2
1301                      Dim P(4, 1) As Double
1302                      Dim d As Double
# Line 1757 | Line 1305 | Public Class SuperFace
1305                      P(0, 0) = 0
1306                      P(0, 1) = 0
1307  
1308 <                    P(1, 0) = -d
1308 >                    P(1, 0) = d
1309                      P(1, 1) = -Poutre.GetD4 / 2.0R
1310                      P(2, 0) = Poutre.GetD5
1311                      P(2, 1) = -Poutre.GetD4 / 2.0R
# Line 1766 | Line 1314 | Public Class SuperFace
1314                      P(4, 0) = P(1, 0)
1315                      P(4, 1) = P(3, 1)
1316  
1317 <                    r(0) = P(0, 0) - 1000 * Epsilon
1317 >                    r(0) = P(0, 0) + 1000 * Epsilon
1318                      r(1) = 0 : r(2) = 0
1319                      Outils_Math.Rotation2D(pt3, r(0), r(1))
1320                      r(0) += TranslationX
# Line 1787 | Line 1335 | Public Class SuperFace
1335                          Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1336                      Next i
1337                      Ligne(16) = P(4, 0) : Ligne(17) = P(4, 1) : Ligne(18) = P(0, 0) : Ligne(19) = P(0, 1)
1338 +                    autreSection = False
1339 +                    AjouterMiniPoutre = False
1340 +                    MettreFI = True
1341 +            End Select
1342 +  
1343 +
1344 +        Else
1345 +            MsgBox("Section de poutre non reconnu!", MsgBoxStyle.Critical, "Commun.DessineSectionPoutre")
1346 +        End If
1347 +
1348 +
1349 +        If Not Ligne Is Nothing Then
1350 +            For i = 0 To UBound(Ligne) Step 4
1351 +                sketchline = swModel.CreateLine2(Ligne(i), Ligne(i + 1), 0, Ligne(i + 2), Ligne(i + 3), 0)
1352 +            Next i
1353 +        End If
1354 +
1355 +        Return r
1356 +
1357 +    End Function
1358 +
1359 +
1360 +
1361 +
1362 +    ''' <summary>
1363 +    ''' Sub qui dessine (insère des lignes) sur le sketch en fonction de la forme de la poutre.
1364 +    ''' </summary>
1365 +    ''' <param name="Poutre"></param>
1366 +    ''' <param name="TranslationX"></param>
1367 +    ''' <param name="TranslationY"></param>
1368 +    ''' <param name="numero">Si on doit découper (pipe et cercle) alors le # nous donne le numéro de l'ittération </param>
1369 +    ''' <param name="swSketch"></param>
1370 +    ''' <param name="inter"></param>
1371 +    ''' <param name="MettreFI"></param>
1372 +    ''' <returns></returns>
1373 +    ''' <remarks>C'est la version simple, donc une seule face nécessaire</remarks>
1374 +    Protected Function DessineSectionPoutreSimple(ByRef Poutre As SlyAretePoutre, ByVal TranslationX As Double, ByVal TranslationY As Double, ByVal numero As Integer, ByRef swSketch As sldworks.Sketch, ByRef inter As InterAreteFace, ByRef MettreFI As Boolean, ByRef AutreSection As Boolean, ByRef AjouterMiniPoutre As Boolean) As Double()
1375 +        ' le sketch est déjà inséré, il faut juste mettre des swmodel.line ou autre
1376 +        ' doit retourner r() qui est un point situé à l'intérieur de la coupe
1377 +        Dim sketchline As sldworks.SketchSegment
1378 +        Dim longueur As Double
1379 +        Dim r(2) As Double
1380 +        Dim sk(1) As Double
1381 +        Dim i As Integer
1382 +        Dim Ligne() As Double = Nothing ' liste des lignes (4 valeurs par ligne)
1383 +        Dim pt3() As Double
1384 +        Dim Nomsection As String
1385 +
1386 +
1387 +        ' on doit activer le sketch avant d'utiliser la fonction getactivesketch
1388 +        pt3 = Poutre.GetPoint3
1389 +        longueur = Math.Sqrt(pt3(0) * pt3(0) + pt3(1) * pt3(1))
1390 +        Dim IP(2) As Double ' IP est le vecteur directionnel
1391 +        IP(0) = pt3(0) - inter.x : IP(1) = pt3(1) - inter.y : IP(2) = pt3(2) - inter.z
1392 +
1393 +
1394 +        pt3 = Commun.TransfertModelSketch(swSketch, pt3)
1395 +        longueur = Math.Sqrt(pt3(0) * pt3(0) + pt3(1) * pt3(1))
1396 +
1397 +        Nomsection = Poutre.GetNomSection
1398 +        If Nomsection = "Rectangle" Or Nomsection = " Rectangle générique" Then ' un rectangle
1399 +            Dim P(3, 1) As Double
1400 +            P(0, 0) = Poutre.GetD1 / 2
1401 +            P(0, 1) = Poutre.GetD2 / 2
1402 +            P(1, 0) = -Poutre.GetD1 / 2
1403 +            P(1, 1) = Poutre.GetD2 / 2
1404 +            P(2, 0) = -Poutre.GetD1 / 2
1405 +            P(2, 1) = -Poutre.GetD2 / 2
1406 +            P(3, 0) = Poutre.GetD1 / 2
1407 +            P(3, 1) = -Poutre.GetD2 / 2
1408 +
1409 +            ReDim Ligne(15)
1410 +            pt3(0) -= TranslationX
1411 +            pt3(1) -= TranslationY
1412 +            For i = 0 To 3
1413 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1414 +                P(i, 0) += TranslationX
1415 +                P(i, 1) += TranslationY
1416 +            Next i
1417 +
1418 +            For i = 0 To 2
1419 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1420 +            Next i
1421 +            Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
1422 +
1423 +            r(0) = inter.x + 5000 * Epsilon * IP(0)
1424 +            r(1) = inter.y + 5000 * Epsilon * IP(1)
1425 +            r(2) = inter.z + 5000 * Epsilon * IP(2)
1426 +
1427 +            AutreSection = False
1428 +            AjouterMiniPoutre = True
1429 +            MettreFI = True
1430 +
1431 +
1432 +        ElseIf Left(Nomsection, 2) = "ST" Or Nomsection = " Tube carré générique" Then ' tube carré troué
1433 +            Dim P(3, 1) As Double
1434 +            Select Case numero
1435 +                Case 1
1436 +                    P(0, 0) = Poutre.GetD1 / 2
1437 +                    P(0, 1) = -Poutre.GetD2 / 2
1438 +                    P(1, 0) = P(0, 0)
1439 +                    P(1, 1) = -P(0, 1)
1440 +                    P(2, 0) = -P(0, 0)
1441 +                    P(2, 1) = P(1, 1)
1442 +                    P(3, 0) = P(2, 0)
1443 +                    P(3, 1) = P(0, 1)
1444 +
1445 +                    r(0) = P(0, 0) - 1000 * Epsilon
1446 +                    r(1) = 0 : r(2) = 0
1447 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1448 +                    r(0) += TranslationX
1449 +                    r(1) += TranslationY
1450 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1451 +
1452 +                    pt3(0) -= TranslationX
1453 +                    pt3(1) -= TranslationY
1454 +                    pt3(0) /= longueur : pt3(1) /= longueur
1455 +                    For i = 0 To 3
1456 +                        Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1457 +                        P(i, 0) += TranslationX
1458 +                        P(i, 1) += TranslationY
1459 +                    Next i
1460 +
1461 +                    ReDim Ligne(15)
1462 +                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1463 +                    Ligne(4) = P(1, 0) : Ligne(5) = P(1, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1464 +                    Ligne(8) = P(2, 0) : Ligne(9) = P(2, 1) : Ligne(10) = P(3, 0) : Ligne(11) = P(3, 1)
1465 +                    Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
1466 +                    MettreFI = False
1467 +                    AutreSection = True
1468 +                    AjouterMiniPoutre = False
1469 +
1470 +                Case 2
1471 +                    P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1472 +                    P(0, 1) = -Poutre.GetD2 / 2 + Poutre.GetD3
1473 +                    P(1, 0) = P(0, 0)
1474 +                    P(1, 1) = -P(0, 1)
1475 +                    P(2, 0) = -P(1, 0)
1476 +                    P(2, 1) = P(1, 1)
1477 +                    P(3, 0) = P(2, 0)
1478 +                    P(3, 1) = P(0, 1)
1479 +
1480 +                    r(0) = P(0, 0) + 1000 * Epsilon
1481 +                    r(1) = 0 : r(2) = 0
1482 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1483 +                    r(0) += TranslationX
1484 +                    r(1) += TranslationY
1485 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1486 +
1487 +                    pt3(0) -= TranslationX
1488 +                    pt3(1) -= TranslationY
1489 +                    pt3(0) /= longueur : pt3(1) /= longueur
1490 +                    For i = 0 To 3
1491 +                        Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1492 +                        P(i, 0) += TranslationX
1493 +                        P(i, 1) += TranslationY
1494 +                    Next i
1495 +
1496 +                    ReDim Ligne(15)
1497 +                    Ligne(0) = P(0, 0) : Ligne(1) = P(0, 1) : Ligne(2) = P(1, 0) : Ligne(3) = P(1, 1)
1498 +                    Ligne(4) = P(1, 0) : Ligne(5) = P(1, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1499 +                    Ligne(8) = P(2, 0) : Ligne(9) = P(2, 1) : Ligne(10) = P(3, 0) : Ligne(11) = P(3, 1)
1500 +                    Ligne(12) = P(3, 0) : Ligne(13) = P(3, 1) : Ligne(14) = P(0, 0) : Ligne(15) = P(0, 1)
1501 +
1502 +                    MettreFI = True  ' lorsque l'on sort on met une face interne
1503 +                    AutreSection = False
1504 +                    AjouterMiniPoutre = False
1505  
1506              End Select
1507 +
1508 +        ElseIf Left(Nomsection, 1) = "S" Or Nomsection = " Poutre en I générique" Then ' poutre en I de type S
1509 +            Dim P(11, 1) As Double
1510 +            Dim d As Double
1511 +
1512 +            d = Poutre.GetD4 * 0.8660254038 '  section.D4 / (2 * tan(30))
1513 +
1514 +            P(0, 0) = (Poutre.GetD1 / 2) - Poutre.GetD3
1515 +            P(0, 1) = -Poutre.GetD4 / 2
1516 +            P(1, 0) = P(0, 0)
1517 +            P(1, 1) = -Poutre.GetD2 / 2
1518 +            P(2, 0) = Poutre.GetD1 / 2
1519 +            P(2, 1) = P(1, 1)
1520 +            P(3, 0) = P(2, 0)
1521 +            P(3, 1) = -P(2, 1)
1522 +            P(4, 0) = P(1, 0)
1523 +            P(4, 1) = -P(1, 1)
1524 +            P(5, 0) = P(0, 0)
1525 +            P(5, 1) = -P(0, 1)
1526 +
1527 +            P(6, 0) = -((Poutre.GetD1 / 2) - Poutre.GetD3)
1528 +            P(6, 1) = Poutre.GetD4 / 2.0R
1529 +            P(7, 0) = P(6, 0)
1530 +            P(7, 1) = Poutre.GetD2 / 2
1531 +            P(8, 0) = -Poutre.GetD1 / 2
1532 +            P(8, 1) = P(7, 1)
1533 +            P(9, 0) = P(8, 0)
1534 +            P(9, 1) = -P(8, 1)
1535 +            P(10, 0) = P(7, 0)
1536 +            P(10, 1) = P(9, 1)
1537 +            P(11, 0) = P(6, 0)
1538 +            P(11, 1) = P(0, 1)
1539 +
1540 +
1541 +            pt3(0) -= TranslationX
1542 +            pt3(1) -= TranslationY
1543 +            pt3(0) /= longueur : pt3(1) /= longueur
1544 +            For i = 0 To 11
1545 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1546 +                P(i, 0) += TranslationX
1547 +                P(i, 1) += TranslationY
1548 +            Next i
1549 +
1550 +            ReDim Ligne(47)
1551 +
1552 +            For k As Integer = 0 To 10
1553 +                Ligne(4 * k + 0) = P(k, 0) : Ligne(4 * k + 1) = P(k, 1) : Ligne(4 * k + 2) = P(k + 1, 0) : Ligne(4 * k + 3) = P(k + 1, 1)
1554 +            Next k
1555 +            Ligne(44) = P(0, 0) : Ligne(45) = P(0, 1) : Ligne(46) = P(11, 0) : Ligne(47) = P(11, 1)
1556 +
1557 +
1558 +            r(0) = inter.x '+ 5000 * Epsilon * IP(0)
1559 +            r(1) = inter.y '+ 5000 * Epsilon * IP(1)
1560 +            r(2) = inter.z '+ 5000 * Epsilon * IP(2)
1561 +
1562 +            AutreSection = False
1563              MettreFI = True
1564 +            AjouterMiniPoutre = True
1565 +
1566 +
1567 +        ElseIf Left(Nomsection, 5) = "Tuyau" OrElse Nomsection = " Tuyau (Pipe) générique" Then ' le tube rond
1568 +            Dim p(4, 1) As Double
1569 +            p(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1570 +            p(0, 1) = 0
1571 +            p(1, 0) = Poutre.GetD1 / 2
1572 +            p(1, 1) = 0
1573 +            p(2, 0) = -p(0, 0)
1574 +            p(2, 1) = 0
1575 +            p(3, 0) = -p(1, 0)
1576 +            p(3, 1) = 0
1577 +            p(4, 0) = 0
1578 +            p(4, 1) = 0
1579 +
1580 +            Select Case numero
1581 +                Case 1
1582 +
1583 +                    r(0) = 0
1584 +                    r(1) = Poutre.GetD1 / 2 - Poutre.GetD3 / 2 : r(2) = 0
1585 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1586 +                    r(0) += TranslationX
1587 +                    r(1) += TranslationY
1588 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1589 +
1590 +                    pt3(0) -= TranslationX
1591 +                    pt3(1) -= TranslationY
1592 +                    pt3(0) /= longueur : pt3(1) /= longueur
1593 +                    For i = 0 To 4
1594 +                        Outils_Math.Rotation2D(pt3, p(i, 0), p(i, 1))
1595 +                        p(i, 0) += TranslationX
1596 +                        p(i, 1) += TranslationY
1597 +                    Next i
1598 +
1599 +                    ReDim Ligne(7)
1600 +                    Ligne(0) = p(0, 0) : Ligne(1) = p(0, 1) : Ligne(2) = p(1, 0) : Ligne(3) = p(1, 1)
1601 +                    Ligne(4) = p(2, 0) : Ligne(5) = p(2, 1) : Ligne(6) = p(3, 0) : Ligne(7) = p(3, 1)
1602 +                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, 1)
1603 +                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, 1)
1604 +                    MettreFI = True
1605 +                    AutreSection = True
1606 +                    AjouterMiniPoutre = False
1607 +
1608 +                Case 2
1609 +
1610 +                    r(0) = 0
1611 +                    r(1) = -Poutre.GetD1 / 2 + Poutre.GetD3 / 2 : r(2) = 0
1612 +                    Outils_Math.Rotation2D(pt3, r(0), r(1))
1613 +                    r(0) += TranslationX
1614 +                    r(1) += TranslationY
1615 +                    r = Commun.TransfertSketchToModel(swSketch, r)
1616  
1617 <        ElseIf Left(Poutre.GetNomSection, 1) = "P" Or Nomsection = " Circulaire pleine générique" Then ' Pipe,
1617 >                    pt3(0) -= TranslationX
1618 >                    pt3(1) -= TranslationY
1619 >                    pt3(0) /= longueur : pt3(1) /= longueur
1620 >                    For i = 0 To 4
1621 >                        Outils_Math.Rotation2D(pt3, p(i, 0), p(i, 1))
1622 >                        p(i, 0) += TranslationX
1623 >                        p(i, 1) += TranslationY
1624 >                    Next i
1625 >
1626 >                    ReDim Ligne(7)
1627 >                    Ligne(0) = p(0, 0) : Ligne(1) = p(0, 1) : Ligne(2) = p(1, 0) : Ligne(3) = p(1, 1)
1628 >                    Ligne(4) = p(2, 0) : Ligne(5) = p(2, 1) : Ligne(6) = p(3, 0) : Ligne(7) = p(3, 1)
1629 >                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(1, 0), p(1, 1), 0, p(3, 0), p(3, 1), 0, -1)
1630 >                    swModel.CreateArc2(p(4, 0), p(4, 1), 0, p(0, 0), p(0, 1), 0, p(2, 0), p(2, 1), 0, -1)
1631 >                    'MettreFI = True  ' lorsque l'on sort on met une face interne
1632 >                    MettreFI = True
1633 >                    AutreSection = False
1634 >                    AjouterMiniPoutre = True
1635 >
1636 >            End Select
1637 >
1638 >        ElseIf Left(Poutre.GetNomSection, 2) = "Cy" Or Nomsection = " Cylindrique (Rod) générique" Then ' Pipe,
1639              Dim P(2, 1) As Double
1640              Dim d As Double, e As Double
1641              d = Poutre.GetD1 / 4 ' Math.Sin(30)  ( et on doit diviser le diamètre par 2)
# Line 1825 | Line 1669 | Public Class SuperFace
1669                      Ligne(4) = P(0, 0) : Ligne(5) = P(0, 1) : Ligne(6) = P(2, 0) : Ligne(7) = P(2, 1)
1670                      swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, 1) ' le dernier param est la direction.  1 ou -1
1671  
1672 +
1673 +                    MettreFI = True
1674 +                    AjouterMiniPoutre = False
1675 +                    AutreSection = True
1676 +
1677                  Case 2
1678                      r(0) = P(0, 0) - 1000 * Epsilon
1679                      r(1) = 0 : r(2) = 0
# Line 1847 | Line 1696 | Public Class SuperFace
1696  
1697                      swModel.CreateArc2(P(0, 0), P(0, 1), 0, P(1, 0), P(1, 1), 0, P(2, 0), P(2, 1), 0, -1) ' le dernier param est la direction.  1 ou -1
1698  
1699 +                    MettreFI = True
1700 +                    AjouterMiniPoutre = False
1701 +                    AutreSection = False
1702 +
1703              End Select
1704 +
1705 +
1706 +
1707 +        ElseIf Left(Nomsection, 1) = "C" Or Nomsection = " Poutre en C générique" Then ' le channel
1708 +            Dim P(7, 1) As Double
1709 +
1710 +            P(0, 0) = Poutre.GetD1 / 2 - Poutre.GetD3
1711 +            P(0, 1) = Poutre.GetD5
1712 +            P(1, 0) = P(0, 0)
1713 +            P(1, 1) = Poutre.GetD5 + Poutre.GetD4 - Poutre.GetD2
1714 +            P(2, 0) = Poutre.GetD1 / 2
1715 +            P(2, 1) = P(1, 1)
1716 +            P(3, 0) = P(2, 0)
1717 +            P(3, 1) = P(1, 1) + Poutre.GetD2
1718 +            P(4, 0) = -P(3, 0)
1719 +            P(4, 1) = P(3, 1)
1720 +            P(5, 0) = P(4, 0)
1721 +            P(5, 1) = P(1, 1)
1722 +            P(6, 0) = -P(1, 0)
1723 +            P(6, 1) = P(5, 1)
1724 +            P(7, 0) = -P(0, 0)
1725 +            P(7, 1) = P(0, 1)
1726 +
1727 +            r(0) = P(0, 0) + 1000 * Epsilon
1728 +            r(1) = P(0, 1) : r(2) = 0
1729 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1730 +            r(0) += TranslationX
1731 +            r(1) += TranslationY
1732 +            r = Commun.TransfertSketchToModel(swSketch, r)
1733 +
1734 +            pt3(0) -= TranslationX
1735 +            pt3(1) -= TranslationY
1736 +            pt3(0) /= longueur : pt3(1) /= longueur
1737 +            For i = 0 To 7
1738 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1739 +                P(i, 0) += TranslationX
1740 +                P(i, 1) += TranslationY
1741 +            Next i
1742 +
1743 +            ReDim Ligne(35)
1744 +            For i = 0 To 6
1745 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1746 +            Next i
1747 +            Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1748 +
1749              MettreFI = True
1750 +            AjouterMiniPoutre = True
1751 +            AutreSection = False
1752 +
1753 +
1754 +        ElseIf Left(Nomsection, 1) = "L" Or Nomsection = " Poutre en L générique" Then ' l'Angle en L
1755 +            Dim P(5, 1) As Double
1756 +
1757 +            P(0, 0) = -Poutre.GetD5 + Poutre.GetD1
1758 +            P(0, 1) = -Poutre.GetD6 + Poutre.GetD4
1759 +            P(1, 0) = -Poutre.GetD5 + Poutre.GetD3
1760 +            P(1, 1) = P(0, 1)
1761 +            P(2, 0) = P(1, 0)
1762 +            P(2, 1) = -Poutre.GetD6 + Poutre.GetD2
1763 +            P(3, 0) = -Poutre.GetD5
1764 +            P(3, 1) = P(2, 1)
1765 +            P(4, 0) = P(3, 0)
1766 +            P(4, 1) = -Poutre.GetD6
1767 +            P(5, 0) = P(0, 0)
1768 +            P(5, 1) = P(4, 1)
1769 +
1770 +            r(0) = P(1, 0) - 1000 * Epsilon
1771 +            r(1) = 0 : r(2) = 0
1772 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1773 +            r(0) += TranslationX
1774 +            r(1) += TranslationY
1775 +            r = Commun.TransfertSketchToModel(swSketch, r)
1776 +
1777 +            pt3(0) -= TranslationX
1778 +            pt3(1) -= TranslationY
1779 +            pt3(0) /= longueur : pt3(1) /= longueur
1780 +            For i = 0 To 5
1781 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1782 +                P(i, 0) += TranslationX
1783 +                P(i, 1) += TranslationY
1784 +            Next i
1785 +
1786 +            ReDim Ligne(35)
1787 +            For i = 0 To 4
1788 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1789 +            Next i
1790 +            Ligne(20) = P(5, 0) : Ligne(21) = P(5, 1) : Ligne(22) = P(0, 0) : Ligne(23) = P(0, 1)
1791 +
1792 +            MettreFI = True
1793 +            AjouterMiniPoutre = True
1794 +            AutreSection = False
1795 +
1796 +
1797 +        ElseIf Left(Nomsection, 1) = "T" Or Nomsection = " Poutre en T générique" Then ' le T
1798 +
1799 +            Dim P(7, 1) As Double
1800 +            Dim d As Double
1801 +            d = Poutre.GetD4 * 0.8660254038 '  section.D4 / (2 * tan(30))
1802 +
1803 +            P(0, 0) = -Poutre.GetD5
1804 +            P(0, 1) = Poutre.GetD4 / 2
1805 +            P(1, 0) = P(0, 0)
1806 +            P(1, 1) = -P(0, 1)
1807 +            P(2, 0) = Poutre.GetD1 - Poutre.GetD5 - Poutre.GetD3
1808 +            P(2, 1) = -Poutre.GetD4 / 2.0R
1809 +            P(3, 0) = P(2, 0)
1810 +            P(3, 1) = -Poutre.GetD2 / 2
1811 +            P(4, 0) = Poutre.GetD1 - Poutre.GetD5
1812 +            P(4, 1) = P(3, 1)
1813 +            P(5, 0) = P(4, 0)
1814 +            P(5, 1) = -P(4, 1)
1815 +            P(6, 0) = P(3, 0)
1816 +            P(6, 1) = -P(3, 1)
1817 +            P(7, 0) = P(2, 0)
1818 +            P(7, 1) = -P(2, 1)
1819 +
1820 +
1821 +            r(0) = 0
1822 +            r(1) = 0 : r(2) = 0
1823 +            Outils_Math.Rotation2D(pt3, r(0), r(1))
1824 +            r(0) += TranslationX
1825 +            r(1) += TranslationY
1826 +            r = Commun.TransfertSketchToModel(swSketch, r)
1827 +
1828 +            pt3(0) -= TranslationX
1829 +            pt3(1) -= TranslationY
1830 +            pt3(0) /= longueur : pt3(1) /= longueur
1831 +            For i = 0 To 7
1832 +                Outils_Math.Rotation2D(pt3, P(i, 0), P(i, 1))
1833 +                P(i, 0) += TranslationX
1834 +                P(i, 1) += TranslationY
1835 +            Next i
1836 +
1837 +            ReDim Ligne(31)
1838 +            For i = 0 To 6
1839 +                Ligne(i * 4) = P(i, 0) : Ligne(i * 4 + 1) = P(i, 1) : Ligne(i * 4 + 2) = P(i + 1, 0) : Ligne(i * 4 + 3) = P(i + 1, 1)
1840 +            Next i
1841 +            Ligne(28) = P(7, 0) : Ligne(29) = P(7, 1) : Ligne(30) = P(0, 0) : Ligne(31) = P(0, 1)
1842 +
1843 +            MettreFI = True
1844 +            AjouterMiniPoutre = True
1845 +            AutreSection = False
1846 +
1847  
1848          Else
1849              MsgBox("Section de poutre non reconnu!", MsgBoxStyle.Critical, "Commun.DessineSectionPoutre")
# Line 1865 | Line 1860 | Public Class SuperFace
1860  
1861      End Function
1862  
1863 <    Public Function SwFace() As SldWorks.Face2 ' retourne la première face de la liste (dans la partie traitement, ce sera la seule...)
1863 >
1864 >    Public Function SwFace() As sldworks.Face2 ' retourne la première face de la liste (dans la partie traitement, ce sera la seule...)
1865          Return Me.lst_Faces.Item(0)
1866      End Function
1867  
1868 <    Public Function IsFaceInterne(ByRef swface As SldWorks.Face2) As Boolean
1869 <        Dim attr As SldWorks.Attribute
1870 <        Dim SwEnt As SldWorks.Entity
1868 >    Public Function IsFaceInterne(ByRef swface As sldworks.Face2) As Boolean
1869 >        Dim attr As sldworks.Attribute
1870 >        Dim SwEnt As sldworks.Entity
1871          SwEnt = swface
1872          attr = SwEnt.FindAttribute(DefAttrFaceInterne, 0)
1873          If attr Is Nothing Then Return False Else Return True
# Line 1882 | Line 1878 | Public Class SuperFace
1878      ''' </summary>
1879      ''' <returns>Un tableau de Edges</returns>
1880      ''' <remarks></remarks>
1881 <    Public Function GetAretes() As SldWorks.Edge()
1882 <        Dim face As SldWorks.Face2
1883 <        Dim arete As SldWorks.Edge = Nothing
1884 <        Dim temp2 As Collections.Generic.List(Of SldWorks.Edge)
1885 <        Dim lst As New Collections.Generic.List(Of SldWorks.Edge)
1881 >    Public Function GetAretes() As sldworks.Edge()
1882 >        Dim face As sldworks.Face2
1883 >        Dim arete As sldworks.Edge = Nothing
1884 >        Dim temp2 As Collections.Generic.List(Of sldworks.Edge)
1885 >        Dim lst As New Collections.Generic.List(Of sldworks.Edge)
1886  
1887          For Each face In Me.lst_Faces
1888              temp2 = GetArete1Face(face)
# Line 1898 | Line 1894 | Public Class SuperFace
1894          Return lst.ToArray
1895      End Function
1896  
1897 <    Private Function GetArete1Face(ByRef Face As SldWorks.Face2) As Collections.Generic.List(Of SldWorks.Edge)
1897 >    Private Function GetArete1Face(ByRef Face As sldworks.Face2) As Collections.Generic.List(Of sldworks.Edge)
1898          Dim vArete As Object
1899 <        Dim a As SldWorks.Edge
1900 <        Dim arete() As SldWorks.Edge
1901 <        Dim lst As New Collections.Generic.List(Of SldWorks.Edge)
1899 >        Dim a As sldworks.Edge
1900 >        Dim arete() As sldworks.Edge
1901 >        Dim lst As New Collections.Generic.List(Of sldworks.Edge)
1902  
1903          ReDim arete(Face.GetEdgeCount - 1)
1904          vArete = Face.GetEdges()
# Line 1915 | Line 1911 | Public Class SuperFace
1911      End Function
1912  
1913      Public Overrides Sub Selectionner(Optional ByVal Mark As Integer = 0, Optional ByRef append As Boolean = True)
1914 <        Dim swent As SldWorks.Entity
1915 <        Dim swface As SldWorks.Face2
1914 >        Dim swent As sldworks.Entity
1915 >        Dim swface As sldworks.Face2
1916  
1917          For Each swface In lst_Faces
1918              swent = swface
# Line 1932 | Line 1928 | Public Class SuperFace
1928      ''' <param name="Append"></param>
1929      ''' <remarks></remarks>
1930      Public Sub SelectionnerToutes(Optional ByRef Mark As Integer = 0, Optional ByRef Append As Boolean = True)
1931 <        Dim swFace As SldWorks.Face2
1931 >        Dim swFace As sldworks.Face2
1932  
1933 <        Dim swent As SldWorks.Entity
1933 >        Dim swent As sldworks.Entity
1934          If Append = False Then swModel.ClearSelection2(True)
1935          For Each swFace In Me.lst_Faces
1936              swent = swFace : swent.Select2(True, Mark)
# Line 1945 | Line 1941 | Public Class SuperFace
1941  
1942  
1943      Public Function Couleur(ByRef rouge As Double, ByRef Vert As Double, ByRef Bleu As Double, Optional ByVal Ambient As Double = 1, Optional ByVal Diffuse As Double = 1, Optional ByVal Specular As Double = 1, Optional ByVal Shininess As Double = 0.5, Optional ByVal Transparency As Double = 0, Optional ByVal Emission As Double = 0.2) As Integer
1948
1944          swModel.SelectedFaceProperties(RGB(rouge, Vert, Bleu), Ambient, Diffuse, Specular, Shininess, Transparency, Emission, False, "")
1950
1945          Return 1
1946      End Function
1947  
1954    Public Sub AjouterFace(ByRef face As SldWorks.Face2)
1955        Dim testface As SldWorks.Face2
1956        Dim faultentity As SldWorks.FaultEntity
1957        Dim swent As SldWorks.Entity
1958
1959        If Not Me.lst_Faces.Contains(face) Then Me.lst_Faces.Add(face)
1960
1961        ' vérifier que les anciennes faces sont toujours ok...
1962        For Each testface In Me.lst_Faces
1963            faultentity = testface.Check
1964            If Not faultentity.Count = 0 Then ' on a un problème avec la face....
1965                lst_Faces.Remove(testface)
1966                Dim i As Integer
1967                For i = 0 To faultentity.Count
1968                    swent = faultentity.Entity(i)
1969                    If Not swent Is Nothing Then
1970                        swent.Select4(True, Nothing)
1971                    End If
1972                    Debug.Print("   Fault[" & i & "] = " & swent.errorCode(i))
1973                Next i
1974            End If
1975        Next testface
1976
1948  
1949 +    Public Sub AjouterFace(ByRef face As sldworks.Face2)
1950 +        Me.lst_Faces.Add(face)
1951      End Sub
1952  
1953  
# Line 1998 | Line 1971 | Public Class SuperFace
1971      ''' </summary>
1972      ''' <returns></returns>
1973      ''' <remarks></remarks>
1974 <    Public Function GetFace() As SldWorks.Face2
1974 >    Public Function GetFace() As sldworks.Face2
1975          Return Me.SwFace
1976      End Function
1977  
# Line 2007 | Line 1980 | Public Class SuperFace
1980      ''' </summary>
1981      ''' <returns></returns>
1982      ''' <remarks></remarks>
1983 <    Public Function GetFaces() As SldWorks.Face2()
1983 >    Public Function GetFaces() As sldworks.Face2()
1984          Return Me.lst_Faces.ToArray
1985      End Function
1986  
# Line 2038 | Line 2011 | Public Class SuperFace
2011      ''' <param name="X"></param>
2012      ''' <param name="Y"></param>
2013      ''' <param name="Z"></param>
2014 <    ''' <returns>Vrai si l epoint est sur la face, faux sinon</returns>
2014 >    ''' <returns>Vrai si le point est sur la face, faux sinon</returns>
2015      ''' <remarks>Retourne X, Y et Z même si le point n'est pas sur la face (mais sur la surface) </remarks>
2016      Public Function Evaluer(ByRef U As Double, ByVal V As Double, ByRef X As Double, ByRef Y As Double, ByRef Z As Double) As Boolean
2017 <        Dim surf As SldWorks.Surface
2017 >        Dim surf As sldworks.Surface
2018          Dim vEv As Object, vpoint As Object
2019          Dim P(2) As Double
2020  
# Line 2066 | Line 2039 | Public Class SuperFace
2039      ''' <returns>Un tableau de 3 doubles correspondant à la normale</returns>
2040      ''' <remarks></remarks>
2041      Public Function Normale(ByRef X As Double, ByRef Y As Double, ByRef Z As Double) As Double()
2042 <        Dim surf As SldWorks.Surface
2042 >        Dim surf As sldworks.Surface
2043          Dim vtemp As Object
2044          Dim temp() As Double
2045          Dim sens As Boolean
# Line 2074 | Line 2047 | Public Class SuperFace
2047          surf = SwFace.GetSurface
2048          If surf.IsPlane Then vtemp = SwFace.Normal : temp = vtemp : Return temp ' si la face est plane alors c'est ok, sinon il faut travailler...
2049  
2077
2050          vtemp = surf.EvaluateAtPoint(X, Y, Z)
2051          ReDim temp(2)
2080
2052          ' la normale de la face pointe AWAY from the body
2082
2053          sens = SwFace.FaceInSurfaceSense()  'TRUE if face normal and surface normal are in the opposite direction and FALSE if they are in the same direction
2054  
2085
2055          If sens Then ' on doit inverser
2056              temp(0) = -vtemp(0) : temp(1) = -vtemp(1) : temp(2) = -vtemp(2)
2057          Else
# Line 2092 | Line 2061 | Public Class SuperFace
2061  
2062      End Function
2063  
2064 <
2065 <    Public Sub MettreAttributFaceInterne(Optional ByRef Valeur As Double = 0)
2064 >    ''' <summary>
2065 >    ''' Met un attribut de face interne
2066 >    ''' </summary>
2067 >    ''' <param name="face">La face sur laquelle mettre l'attribut</param>
2068 >    ''' <param name="Valeur">La taille de maille suggérée</param>
2069 >    ''' <param name="poutre">Si vrai alors on a une poutre, sinon une coque</param>
2070 >    ''' <returns>Le numéro de l'attribut (si jamais c'est important)</returns>
2071 >    ''' <remarks>Attention au signe de la valeur</remarks>
2072 >    Public Function MettreAttributFaceInterne(ByRef face As sldworks.Face2, Optional ByRef Valeur As Double = 0, Optional ByVal poutre As Boolean = True) As Integer
2073          Dim no As Integer = 0
2074          Dim nom As String = "FaceInterne" & no
2075 <        Dim swent As SldWorks.Entity
2076 <        Dim attr As SldWorks.Attribute
2075 >        Dim swent As sldworks.Entity
2076 >        Dim attr As sldworks.Attribute
2077 >        Dim p As sldworks.Parameter
2078 >
2079 >        swent = face 'Me.SwFace
2080  
2102        swent = Me.SwFace
2081          attr = swent.FindAttribute(Intersections.DefAttrFaceInterne, 0) ' si l'attribut existe déjà on pointe dessus.
2082 <        If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, SwFace, nom, 0, 2) ' 0 = swThisconfig
2082 >        If attr Is Nothing Then attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom, 0, 2) ' 0 = swThisconfig
2083          While attr Is Nothing
2084              no += 1
2085              nom = "FaceInterne" & CStr(no)
2086 <            attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, SwFace, nom, 0, 2)
2086 >            attr = Intersections.DefAttrFaceInterne.CreateInstance5(swModel, face, nom, 0, 2)
2087          End While
2088 +        p = attr.GetParameter("FI")
2089 +        p.SetDoubleValue(Valeur)
2090 +
2091 +        p = attr.GetParameter("Po")
2092 +        If poutre Then
2093 +            p.SetDoubleValue(0) ' poutre
2094 +        Else
2095 +            p.SetDoubleValue(1) ' coque
2096 +        End If
2097 +
2098 +
2099          GererDossiers("FaceInternes", nom)
2100 +        Return no
2101 +    End Function
2102 +
2103 +    ''' <summary>
2104 +    ''' Si la face est une face interne,alors on écrit les points POG dans le fichier
2105 +    ''' </summary>
2106 +    ''' <remarks></remarks>
2107 +    Public Sub MettrePointSurPOG(ByVal fichier As System.IO.StreamWriter)
2108 +        ' 2 - Si la face a un attribut de faceInterne on:
2109 +        Dim ENG As Double = Commun.ÉcartNodal
2110 +        Dim EcartSouhaite As Double
2111 +        Dim ratio As Double
2112 +
2113 +
2114 +        If Me.PossedeAttributFaceInterne Then
2115 +            ' 2.1 Détermine l'écart nodal à cette face ( en fait, le ratio... )
2116 +
2117 +            ' là on a 2 options,
2118 +            ' a) on utilise le rayon hydraulique: 4* Surface / Périmètre
2119 +            EcartSouhaite = Me.GrosseurMailleFaceInterne ' 4 * Me.Aire / Me.Perimetre
2120 +            If EcartSouhaite <= 0 Then Exit Sub
2121 +            ratio = EcartSouhaite / ENG
2122 +
2123 +
2124 +            If ratio > 0.75 Then ratio = 0.75 ' ?!? on s'assure d'avoir un minimum de rafinement...
2125 +            ' b) On analyse la tessellation et on prend la plus petite longueur de triangle...
2126 +
2127 +            ' 2.2 Créé une série de points [ sur chaque point de la tessellation   :-) ]  mais là on va avoir un tas de doubles... Update.  La tessellation n emarche pas, sur des faces «carrées» il y a des zones trop vides
2128 +            ' On va mettre des points sur le contour des faces.  un point va automatiquement se retrouver au milieu
2129 +
2130 +            Dim objArete As Object = Me.SwFace.GetEdges
2131 +            Dim points As New Collections.Generic.List(Of Point)
2132 +            Dim p As Point
2133 +            Dim x, y, z As Double
2134 +
2135 +
2136 +            For Each swArete As sldworks.Edge In objArete
2137 +                Dim e As New SuperArete(swArete, True)
2138 +                Dim LongueurArete As Double = e.Longueur
2139 +                Dim nbSeg As Integer = Int(LongueurArete / EcartSouhaite / 2) : If nbSeg < 2 Then nbSeg = 2
2140 +                Dim dt As Double = (e.GetTMax - e.GetTMin) / nbSeg
2141 +                Dim T As Double = e.GetTMin
2142 +
2143 +
2144 +                ' les points sur les arètes
2145  
2146 +                For s As Integer = 1 To nbSeg - 1
2147 +                    T += dt
2148 +                    e.Evaluer(T, x, y, z)
2149 +                    p = New Point(x, y, z) : points.Add(p)
2150 +                Next s
2151 +
2152 +
2153 +
2154 +                ' les points sur les sommets
2155 +                Dim swSommets() As sldworks.Vertex = Me.GetSommets
2156 +                Dim es As SuperSommet
2157 +                For Each sommet As sldworks.Vertex In swSommets
2158 +                    es = New SuperSommet(sommet, True)
2159 +                    p = New Point(es.X, es.Y, es.Z) : points.Add(p)
2160 +                Next
2161 +                e = Nothing
2162 +                es = Nothing
2163 +
2164 +            Next
2165 +
2166 +            For Each p In points
2167 +                ' 2.3 enregistre ces points dans le fichier.
2168 +                fichier.WriteLine(CStr(p) & " " & ratio & " " & "4" & " " & "0")
2169 +            Next p
2170 +            ENG = 1 ' pour y mettre un point d'arrêt
2171 +        End If
2172      End Sub
2173  
2174  
2175 +    ''' <summary>
2176 +    ''' Retourne un tableau de swSommets
2177 +    ''' </summary>
2178 +    ''' <returns></returns>
2179 +    ''' <remarks></remarks>
2180 +    Public Function GetSommets() As sldworks.Vertex()
2181 +        Dim lst_sommets As New Collections.Generic.List(Of sldworks.Vertex)
2182 +        Dim swSommet As sldworks.Vertex
2183 +        Dim objArete As Object = Me.SwFace.GetEdges()
2184 +
2185 +        For Each arete As sldworks.Edge In objArete
2186 +            swSommet = arete.GetStartVertex() : If swSommet Is Nothing Then Continue For
2187 +            If Not lst_sommets.Contains(swSommet) Then lst_sommets.Add(swSommet)
2188 +            swSommet = arete.GetEndVertex()
2189 +            If Not lst_sommets.Contains(swSommet) Then lst_sommets.Add(swSommet)
2190 +        Next arete
2191 +        Return lst_sommets.ToArray
2192 +    End Function
2193 +
2194 +
2195 +    ''' <summary>
2196 +    ''' Function qui donne la grosseur des maille que l'on aimerait avoir pour
2197 +    ''' </summary>
2198 +    ''' <returns></returns>
2199 +    ''' <remarks></remarks>
2200 +    Public Function GrosseurMailleFaceInterne() As Double
2201 +        Dim swEnt As sldworks.Entity
2202 +        Dim attr As sldworks.Attribute
2203 +        swEnt = Me.SwFace
2204 +        attr = swEnt.FindAttribute(Intersections.DefAttrFaceInterne, 0)
2205 +        If attr Is Nothing Then Return Nothing
2206 +        Dim p As sldworks.Parameter = attr.GetParameter("FI")
2207 +        Return p.GetDoubleValue
2208 +    End Function
2209 +
2210 +    ''' <summary>
2211 +    ''' Retourne vrai si la face a un attribut de face interne.
2212 +    ''' </summary>
2213 +    ''' <returns></returns>
2214 +    ''' <remarks></remarks>
2215 +    Public Function PossedeAttributFaceInterne() As Boolean
2216 +        Dim swEnt As sldworks.Entity
2217 +        Dim attr As sldworks.Attribute
2218 +        swEnt = Me.SwFace
2219 +        attr = swEnt.FindAttribute(Intersections.DefAttrFaceInterne, 0)
2220 +        If attr Is Nothing Then Return False Else Return True
2221 +    End Function
2222 +
2223 +
2224 +    ''' <summary>
2225 +    ''' Retourne le périmètre de la face
2226 +    ''' </summary>
2227 +    ''' <returns></returns>
2228 +    ''' <remarks>Attention, c'est une approximation!!!</remarks>
2229 +    Public Function Perimetre() As Double
2230 +        Dim objArete As Object = Me.SwFace.GetEdges
2231 +        'Dim swAretes() As sldworks.Edge = objArete
2232 +        Dim longueur As Double
2233 +
2234 +        For Each swArete As sldworks.Edge In objArete
2235 +            Dim e As New SuperArete(swArete, True)
2236 +            longueur += e.Longueur()
2237 +        Next
2238 +        Return longueur
2239 +    End Function
2240 +
2241 +
2242 +    ''' <summary>
2243 +    ''' Retourne la surface (l'aire) de la face
2244 +    ''' </summary>
2245 +    ''' <returns></returns>
2246 +    ''' <remarks></remarks>
2247 +    Public Function Aire() As Double
2248 +        Return Me.SwFace.GetArea
2249 +    End Function
2250 +
2251 +    ''' <summary>
2252 +    ''' Retourne le nombre d'arètes contenues dans la superface
2253 +    ''' </summary>
2254 +    ''' <value></value>
2255 +    ''' <returns></returns>
2256 +    ''' <remarks></remarks>
2257 +    Public ReadOnly Property GetNbAretes() As Integer
2258 +        Get
2259 +            Dim nb As Integer
2260 +            Dim lstFaces() As sldworks.Face2 = Me.SwFace
2261 +            For Each swFace As sldworks.Face2 In lstFaces
2262 +                nb += swFace.GetEdgeCount
2263 +            Next
2264 +            Return nb
2265 +        End Get
2266 +    End Property
2267 +
2268 +    Public Function GetSurface() As sldworks.Surface
2269 +        Return Me.GetFace.GetSurface
2270 +    End Function
2271 +
2272 +
2273 +
2274   End Class

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines