9 |
|
Public sFaceCoque2 As SlyFaceCoque |
10 |
|
|
11 |
|
Public AreteCoque1 As SldWorks.Edge |
12 |
< |
Public AreteCoque2 As SldWorks.Edge |
12 |
> |
Public AreteCoque2 As sldworks.Edge |
13 |
> |
|
14 |
> |
Private ADecouper1 As Boolean |
15 |
> |
Private ADecouper2 As Boolean |
16 |
> |
Private FaceAPlat1 As Boolean |
17 |
> |
Private FaceAPlat2 As Boolean |
18 |
> |
|
19 |
> |
|
20 |
> |
''' <summary> |
21 |
> |
''' Nouvelle instance de la classe Intersection Coque Coque. |
22 |
> |
''' </summary> |
23 |
> |
''' <param name="coque1">Une des 2 coques</param> |
24 |
> |
''' <param name="coque2">L'autre</param> |
25 |
> |
''' <remarks></remarks> |
26 |
> |
Public Sub New(ByRef coque1 As SlyFaceCoque, ByRef coque2 As SlyFaceCoque) |
27 |
> |
sFaceCoque1 = coque1 |
28 |
> |
sFaceCoque2 = coque2 |
29 |
> |
End Sub |
30 |
> |
|
31 |
> |
|
32 |
> |
|
33 |
> |
|
34 |
> |
''' <summary> |
35 |
> |
''' Analyse les 2 coques qui se touchent et détermine de quel type il s'agit. |
36 |
> |
''' </summary> |
37 |
> |
''' <remarks></remarks> |
38 |
> |
Public Sub DetermineType() |
39 |
> |
|
40 |
> |
ADecouper1 = True |
41 |
> |
ADecouper2 = True |
42 |
> |
FaceAPlat1 = False |
43 |
> |
FaceAPlat2 = False |
44 |
> |
|
45 |
> |
' si les faces reposent une sur l'autre, on doit leur faire un traitement particulier |
46 |
> |
If Intersections.ComparerSurfaces(sFaceCoque1.SwFace.GetSurface, sFaceCoque2.SwFace.GetSurface) Then |
47 |
> |
ADecouper1 = False |
48 |
> |
ADecouper2 = False |
49 |
> |
FaceAPlat1 = True |
50 |
> |
FaceAPlat2 = True |
51 |
> |
End If |
52 |
> |
|
53 |
> |
End Sub |
54 |
> |
|
55 |
> |
''' <summary> |
56 |
> |
''' Si vrai, alors on a une intersection de face à plat |
57 |
> |
''' </summary> |
58 |
> |
''' <value></value> |
59 |
> |
''' <returns></returns> |
60 |
> |
''' <remarks></remarks> |
61 |
> |
Public ReadOnly Property FaceAPlat() As Boolean |
62 |
> |
Get |
63 |
> |
Return FaceAPlat1 |
64 |
> |
End Get |
65 |
> |
End Property |
66 |
> |
|
67 |
> |
''' <summary> |
68 |
> |
''' Vrai si on doit couper la coque #1 |
69 |
> |
''' </summary> |
70 |
> |
''' <value></value> |
71 |
> |
''' <returns></returns> |
72 |
> |
''' <remarks></remarks> |
73 |
> |
Public ReadOnly Property DoitCouperCoque1() As Boolean |
74 |
> |
Get |
75 |
> |
Return ADecouper1 |
76 |
> |
End Get |
77 |
> |
End Property |
78 |
> |
|
79 |
> |
''' <summary> |
80 |
> |
''' Vrai si on doit couper la coque #2 |
81 |
> |
''' </summary> |
82 |
> |
''' <value></value> |
83 |
> |
''' <returns></returns> |
84 |
> |
''' <remarks></remarks> |
85 |
> |
Public ReadOnly Property DoitCouperCoque2() As Boolean |
86 |
> |
Get |
87 |
> |
Return ADecouper2 |
88 |
> |
End Get |
89 |
> |
End Property |
90 |
> |
|
91 |
> |
|
92 |
> |
|
93 |
> |
''' <summary> |
94 |
> |
''' Sub qui coupe 2 coques à plat |
95 |
> |
''' </summary> |
96 |
> |
''' <remarks></remarks> |
97 |
> |
Public Sub CoupeAPlat() |
98 |
> |
Dim feat As sldworks.Feature = Nothing |
99 |
> |
Dim swEnt As sldworks.Entity |
100 |
> |
Dim sketch(2) As sldworks.Sketch |
101 |
> |
Dim SelMgr As sldworks.SelectionMgr = swModel.SelectionManager |
102 |
> |
Dim nom As String |
103 |
> |
Dim xyz(2) As Double |
104 |
> |
|
105 |
> |
|
106 |
> |
' a) faire 1 esquisses 3D |
107 |
> |
|
108 |
> |
swModel.ClearSelection2(True) |
109 |
> |
swModel.Insert3DSketch2(True) |
110 |
> |
swEnt = Me.sFaceCoque1.SwFace() : swEnt.Select(False) |
111 |
> |
swEnt = Me.sFaceCoque2.SwFace() : swEnt.Select(True) |
112 |
> |
swModel.Sketch3DIntersections() |
113 |
> |
swModel.SketchManager.InsertSketch(True) |
114 |
> |
feat = swModel.FeatureByPositionReverse(0) |
115 |
> |
nom = feat.Name |
116 |
> |
|
117 |
> |
|
118 |
> |
' b) Remplir la surface |
119 |
> |
Dim vPatchBoundaries As Object |
120 |
> |
swModel.Extension.SelectByID2(nom, "SKETCH", 0, 0, 0, False, 1, Nothing, 0) |
121 |
> |
vPatchBoundaries = SelMgr.GetSelectedObject2(1) |
122 |
> |
swModel.FeatureManager.InsertFillSurface2(3, swconst.swFeatureFillSurfaceOptions_e.swOptimizeSurface, vPatchBoundaries, swconst.swContactType_e.swContact, Nothing, Nothing) |
123 |
> |
|
124 |
> |
|
125 |
> |
' On coupe une surface |
126 |
> |
swModel.ClearSelection2(True) |
127 |
> |
swModel.Insert3DSketch2(True) |
128 |
> |
swEnt = Me.sFaceCoque1.SwFace() : swEnt.Select2(False, 0) |
129 |
> |
swEnt = Me.sFaceCoque2.SwFace() : swEnt.Select2(True, 0) |
130 |
> |
swModel.Sketch3DIntersections() |
131 |
> |
swModel.SketchManager.InsertSketch(True) |
132 |
> |
feat = swModel.FeatureByPositionReverse(0) |
133 |
> |
sketch(0) = feat.GetSpecificFeature2() |
134 |
> |
If PointAGarder(Me.sFaceCoque1, Me.sFaceCoque2, xyz) Then |
135 |
> |
Commun.MettreUnPoint(xyz(0), xyz(1), xyz(2)) |
136 |
> |
swModel.Extension.SelectByID2("", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0) |
137 |
> |
swModel.FeatureManager.PreTrimSurface(0, 1, 0, 0) |
138 |
> |
swModel.Extension.SelectByID2("", "SURFACEBODY", xyz(0), xyz(1), xyz(2), True, 0, Nothing, 0) '-0.04387817789132, -0.03087621363591, -0.02079408480836, True, 0, Nothing, 0) |
139 |
> |
swModel.FeatureManager.PostTrimSurface(1) |
140 |
> |
End If |
141 |
> |
|
142 |
> |
|
143 |
> |
'' on coupe l'autre surface |
144 |
> |
swModel.ClearSelection2(True) |
145 |
> |
If PointAGarder(Me.sFaceCoque2, Me.sFaceCoque1, xyz) Then |
146 |
> |
Commun.MettreUnPoint(xyz(0), xyz(1), xyz(2)) |
147 |
> |
swModel.Extension.SelectByID2("", "BODYFEATURE", 0, 0, 0, True, 0, Nothing, 0) |
148 |
> |
swModel.FeatureManager.PreTrimSurface(0, 1, 0, 0) |
149 |
> |
swModel.Extension.SelectByID2("", "SURFACEBODY", xyz(0), xyz(1), xyz(2), True, 0, Nothing, 0) '-0.04387817789132, -0.03087621363591, -0.02079408480836, True, 0, Nothing, 0) |
150 |
> |
swModel.FeatureManager.PostTrimSurface(1) |
151 |
> |
End If |
152 |
> |
|
153 |
> |
|
154 |
> |
End Sub |
155 |
> |
|
156 |
> |
|
157 |
> |
''' <summary> |
158 |
> |
''' Function qui retourne un point qui appartient à la face1 et pas à la face2 |
159 |
> |
''' </summary> |
160 |
> |
''' <returns></returns> |
161 |
> |
''' <remarks></remarks> |
162 |
> |
Private Function PointAGarder(ByRef Face1 As SuperFace, ByRef Face2 As SuperFace, ByRef XYZ() As Double) As Boolean |
163 |
> |
Dim u As Double |
164 |
> |
Dim v As Double |
165 |
> |
Dim umin As Double |
166 |
> |
Dim vmin As Double |
167 |
> |
Dim umax As Double |
168 |
> |
Dim vmax As Double |
169 |
> |
|
170 |
> |
|
171 |
> |
Face1.UVMinMax(umin, umax, vmin, vmax) |
172 |
> |
u = umin |
173 |
> |
v = vmin |
174 |
> |
Dim incV As Double = (vmax - vmin) / 100 |
175 |
> |
Dim incU As Double = (umax - umin) / 100 |
176 |
> |
|
177 |
> |
Do While u <= umax |
178 |
> |
u += incU |
179 |
> |
Do While v < vmax |
180 |
> |
v += incV |
181 |
> |
If Not Face1.Evaluer(u, v, XYZ(0), XYZ(1), XYZ(2)) Then Continue Do |
182 |
> |
If Commun.Distance(Face2, XYZ(0), XYZ(1), XYZ(2)) > 100 * Epsilon Then Return True |
183 |
> |
Loop |
184 |
> |
|
185 |
> |
Loop |
186 |
> |
|
187 |
> |
Return False |
188 |
> |
|
189 |
> |
|
190 |
> |
End Function |
191 |
> |
|
192 |
> |
|
193 |
|
|
194 |
|
''' <summary> |
195 |
|
''' Sub qui dessine le sweep à l'endroit d'intersection |
385 |
|
Dim e As New SuperArete(swAreteVol, True) : e.Colorer(2, 0, 1, 0) |
386 |
|
For Each swAreteCoque As SldWorks.Edge In swAreteCoques |
387 |
|
If e.comparer(swAreteCoque) Then |
388 |
< |
sFace.MettreAttributFaceInterne() |
388 |
> |
sFace.MettreAttributFaceInterne(sFace.SwFace, , False) |
389 |
|
trouve = True : Exit For |
390 |
|
End If |
391 |
|
Next |
397 |
|
End Sub |
398 |
|
|
399 |
|
|
400 |
+ |
|
401 |
|
End Class |