1 |
bournival |
40 |
Public Class SuperArete
|
2 |
|
|
Inherits SuperEntite
|
3 |
|
|
Public swArete As SldWorks.Edge
|
4 |
|
|
Private Shared compteur As Long
|
5 |
|
|
Private Shared no As Long
|
6 |
|
|
|
7 |
|
|
Protected swCourbe As SldWorks.Curve
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
''' <summary>
|
11 |
|
|
''' Le new pour un encapsulateur de l'arète
|
12 |
|
|
''' </summary>
|
13 |
|
|
''' <param name="swArete"></param>
|
14 |
|
|
''' <param name="encapsulateur"></param>
|
15 |
|
|
''' <remarks></remarks>
|
16 |
|
|
Public Sub New(ByRef swArete As SldWorks.Edge, ByRef encapsulateur As Boolean)
|
17 |
|
|
Me.swArete = swArete
|
18 |
|
|
Me.swCourbe = swArete.GetCurve
|
19 |
|
|
End Sub
|
20 |
|
|
|
21 |
|
|
Public Sub New(ByRef arete As SldWorks.Edge, Optional ByVal tip As integer = 0)
|
22 |
|
|
Me.swArete = arete
|
23 |
|
|
Me.swCourbe = swArete.GetCurve
|
24 |
|
|
Select Case tip
|
25 |
|
|
Case Commun.tipe_e.Volume
|
26 |
|
|
nom = "Arete" & compteur
|
27 |
|
|
Case Commun.tipe_e.coque
|
28 |
|
|
nom = "AreteCoque" & compteur
|
29 |
|
|
Case Commun.tipe_e.poutre
|
30 |
|
|
nom = "AretePoutre" & compteur
|
31 |
|
|
Case Commun.tipe_e.MiniPoutre
|
32 |
|
|
nom = "Mini-Poutre" & compteur
|
33 |
|
|
End Select
|
34 |
|
|
nomOrig = nom
|
35 |
|
|
compteur = compteur + 1
|
36 |
|
|
End Sub
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
Public Overrides Sub SaveNom()
|
40 |
|
|
' procédure qui enregistre le nom et qui , pour l'instant ne tient pas compte des conditions aux limites
|
41 |
|
|
Dim ent As SldWorks.Entity
|
42 |
|
|
ent = swArete
|
43 |
|
|
Dim retval As Boolean
|
44 |
|
|
|
45 |
|
|
Try
|
46 |
|
|
retval = swPart.SetEntityName(ent, nom)
|
47 |
|
|
Catch
|
48 |
|
|
Debug.Write("Le prog ne veut pas mettre le nom sur une entité.." & vbCr & "Le nom devrait être: " & nom) ' MsgBox("Le prog ne veut pas mettre le nom sur une entité.." & vbCr & "Le nom devrait être: " & nom)
|
49 |
|
|
End Try
|
50 |
|
|
|
51 |
|
|
Dim i As Integer
|
52 |
|
|
If retval = False Then
|
53 |
|
|
Do Until retval = True
|
54 |
|
|
i += 1
|
55 |
|
|
retval = swPart.SetEntityName(ent, nom & Chr(96 + i))
|
56 |
|
|
Loop
|
57 |
|
|
Me.nom = nom & Chr(96 + i)
|
58 |
|
|
Debug.Write("Impossibilité d'écrire le nom de l'entité... il y a déjà un nom." & Chr(13) & nom) ' MsgBox("Impossibilité d'écrire le nom de l'entité... il y a déjà un nom." & Chr(13) & nom, MsgBoxStyle.Critical, "Problème dans le setID de l'arrète")
|
59 |
|
|
End If
|
60 |
|
|
End Sub
|
61 |
|
|
|
62 |
|
|
Shared Sub reinitialiser()
|
63 |
|
|
compteur = 0
|
64 |
|
|
End Sub
|
65 |
|
|
|
66 |
|
|
Public Function GetOrientation(ByRef T As Double) As Double()
|
67 |
|
|
'retval = Edge.Evaluate ( Parameter) retval est un tableau, 4,5 et 6 sont les tangentes au point...
|
68 |
|
|
|
69 |
|
|
Dim temp(2) As Double
|
70 |
|
|
Dim retval As Object
|
71 |
|
|
|
72 |
|
|
retval = Me.swArete.Evaluate(T)
|
73 |
|
|
|
74 |
|
|
temp(0) = retval(3)
|
75 |
|
|
temp(1) = retval(4)
|
76 |
|
|
temp(2) = retval(5)
|
77 |
|
|
|
78 |
|
|
Return temp
|
79 |
|
|
|
80 |
|
|
End Function
|
81 |
|
|
|
82 |
|
|
Public Function GetOrientation(ByRef x As Double, ByRef y As Double, ByRef z As Double) As Double()
|
83 |
|
|
Dim retval As Object
|
84 |
|
|
retval = Me.swArete.GetClosestPointOn(x, y, z)
|
85 |
|
|
Return GetOrientation(retval(3))
|
86 |
|
|
End Function
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
Public Sub MettreAttributPourConditionLimite()
|
91 |
|
|
Dim swent As SldWorks.Entity
|
92 |
|
|
Dim nom As String
|
93 |
|
|
Dim cond As String
|
94 |
|
|
|
95 |
|
|
cond = Me.condition
|
96 |
|
|
If cond = "" Then Exit Sub
|
97 |
|
|
|
98 |
|
|
swent = Me.swArete
|
99 |
|
|
|
100 |
|
|
nom = "CL" & CStr(no) & "_" & cond
|
101 |
|
|
Dim Attr As SldWorks.Attribute = Nothing
|
102 |
|
|
|
103 |
|
|
Try
|
104 |
|
|
Attr = swent.FindAttribute(Intersections.DefAttrConditionLimite, 0) ' si l'attribut existe déjà on pointe dessus.
|
105 |
|
|
Catch ex As Exception
|
106 |
|
|
MsgBox("N'arrive pas à se lier à l'attribut, erreur: " & ex.Message, MsgBoxStyle.Critical)
|
107 |
|
|
End Try
|
108 |
|
|
|
109 |
|
|
' si nothing c'est que l'attribut n'existe pas
|
110 |
|
|
If Attr Is Nothing Then Attr = Intersections.DefAttrConditionLimite.CreateInstance5(swModel, Me.swArete, nom, 0, 2) ' 0 = swThisconfig, 2 = allconfig
|
111 |
|
|
|
112 |
|
|
While Attr Is Nothing
|
113 |
|
|
no += 1
|
114 |
|
|
nom = "CL" & CStr(no) & "_" & cond
|
115 |
|
|
Attr = Intersections.DefAttrConditionLimite.CreateInstance5(swModel, Me.swArete, nom, 0, 2)
|
116 |
|
|
End While
|
117 |
|
|
|
118 |
|
|
Dim ParamCL As SldWorks.Parameter
|
119 |
|
|
ParamCL = Attr.GetParameter("CL")
|
120 |
|
|
|
121 |
|
|
ParamCL.SetStringValue2(cond, 2, "") ' swAllConfiguration = 2
|
122 |
|
|
|
123 |
|
|
GererDossiers("Conditions Aux Limites", nom)
|
124 |
|
|
no = no + 1
|
125 |
|
|
|
126 |
|
|
End Sub
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
' une fonction qui transforme un attribut en condition aux limites
|
130 |
|
|
Public Sub AttributVersConditionLimite()
|
131 |
|
|
Dim p As SldWorks.Parameter
|
132 |
|
|
Dim ent As SldWorks.Entity
|
133 |
|
|
Dim attr As SldWorks.Attribute
|
134 |
|
|
|
135 |
|
|
ent = Me.swArete
|
136 |
|
|
attr = ent.FindAttribute(Intersections.DefAttrConditionLimite, 0)
|
137 |
|
|
If Not attr Is Nothing Then
|
138 |
|
|
p = attr.GetParameter("CL")
|
139 |
|
|
nom = nomOrig & "@" & p.GetStringValue
|
140 |
|
|
End If
|
141 |
|
|
|
142 |
|
|
End Sub
|
143 |
|
|
|
144 |
|
|
|
145 |
|
|
Public Function GetSwSommets() As SldWorks.Vertex()
|
146 |
|
|
Dim swsommet(1) As SldWorks.Vertex
|
147 |
|
|
swsommet(0) = Me.swArete.GetStartVertex()
|
148 |
|
|
If swsommet(0) Is Nothing Then Return Nothing
|
149 |
|
|
swsommet(1) = Me.swArete.GetEndVertex
|
150 |
|
|
Return swsommet
|
151 |
|
|
End Function
|
152 |
|
|
|
153 |
|
|
Public Overrides Sub Selectionner(Optional ByVal Mark As Integer = 0, Optional ByRef Append As Boolean = True)
|
154 |
|
|
Dim swent As SldWorks.Entity
|
155 |
|
|
swent = swArete
|
156 |
|
|
swent.Select2(Append, Mark)
|
157 |
|
|
End Sub
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
''' <summary>
|
162 |
|
|
''' Renvoie les coordonnées du point milieu
|
163 |
|
|
''' </summary>
|
164 |
|
|
''' <returns></returns>
|
165 |
|
|
''' <remarks></remarks>
|
166 |
|
|
Public Function GetPointMilieu() As Double()
|
167 |
|
|
Dim T As Double
|
168 |
|
|
Dim xyz(2) As Double
|
169 |
|
|
T = Me.GetTMilieu
|
170 |
|
|
Me.Evaluer(T, xyz)
|
171 |
|
|
Return xyz
|
172 |
|
|
End Function
|
173 |
|
|
|
174 |
|
|
''' <summary>
|
175 |
|
|
''' Renvoie les coordonnées du point milieu
|
176 |
|
|
''' </summary>
|
177 |
|
|
''' <returns>Faux si le sommet n'esiste pas</returns>
|
178 |
|
|
''' <remarks></remarks>
|
179 |
|
|
Public Function GetPointMilieu(ByRef x As Double, ByRef y As Double, ByRef z As Double) As Boolean
|
180 |
|
|
Dim T As Double
|
181 |
|
|
T = Me.GetTMilieu
|
182 |
|
|
Me.Evaluer(T, x, y, z)
|
183 |
|
|
Return True
|
184 |
|
|
End Function
|
185 |
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
''' <summary>
|
190 |
|
|
''' Détermine si une courbe est une ligne
|
191 |
|
|
''' </summary>
|
192 |
|
|
''' <returns>Vrai si la courbe est une ligne</returns>
|
193 |
|
|
''' <remarks></remarks>
|
194 |
|
|
Public Function IsLine() As Boolean
|
195 |
|
|
Try
|
196 |
|
|
Dim swCourbe As SldWorks.Curve = Me.swArete.GetCurve
|
197 |
|
|
Return swCourbe.IsLine()
|
198 |
|
|
Catch
|
199 |
|
|
Dim fault As SldWorks.FaultEntity = Me.swArete.Check
|
200 |
|
|
Debug.WriteLine("N'arrive pas à déterminer si la courbe est une ligne" & vbCr & "FaultEntity.Count = " & IIf(fault Is Nothing, "0", fault.Count) & vbCr & Me.nom)
|
201 |
|
|
Return True
|
202 |
|
|
End Try
|
203 |
|
|
|
204 |
|
|
End Function
|
205 |
|
|
|
206 |
|
|
''' <summary>
|
207 |
|
|
''' Détermine si la courbe est un cercle
|
208 |
|
|
''' </summary>
|
209 |
|
|
''' <returns>Vrai si la courbe est un cercle</returns>
|
210 |
|
|
''' <remarks></remarks>
|
211 |
|
|
Public Function IsCircle() As Boolean
|
212 |
|
|
Try
|
213 |
|
|
|
214 |
|
|
Dim swCourbe As SldWorks.Curve = Me.swArete.GetCurve
|
215 |
|
|
If swCourbe.IsLine Then Return False
|
216 |
|
|
Return Me.swCourbe.IsCircle
|
217 |
|
|
Catch ex As Exception
|
218 |
|
|
Dim fault As SldWorks.FaultEntity = Me.swArete.Check
|
219 |
|
|
Debug.WriteLine("N'arrive pas à déterminer si la courbe est un cercle" & vbCr & "FaultEntity.Count = " & IIf(fault Is Nothing, "0", fault.Count) & vbCr & Me.nom)
|
220 |
|
|
Return False
|
221 |
|
|
End Try
|
222 |
|
|
|
223 |
|
|
End Function
|
224 |
|
|
|
225 |
|
|
''' <summary>
|
226 |
|
|
''' Détermine si la courbe est une B-Spline
|
227 |
|
|
''' </summary>
|
228 |
|
|
''' <returns></returns>
|
229 |
|
|
''' <remarks>Vrai si la courbe est une b-spline</remarks>
|
230 |
|
|
Public Function IsBcurve() As Boolean
|
231 |
|
|
Try
|
232 |
|
|
Dim swCourbe As SldWorks.Curve = Me.swArete.GetCurve
|
233 |
|
|
If swCourbe.IsLine Then Return False
|
234 |
|
|
If swCourbe.IsCircle Then Return False ' le manuel dit de vérifier ça avant de demander pour une Spline...
|
235 |
|
|
Return swCourbe.IsBcurve()
|
236 |
|
|
Catch
|
237 |
|
|
Dim fault As SldWorks.FaultEntity = Me.swArete.Check
|
238 |
|
|
Debug.WriteLine("N'arrive pas à déterminer si la courbe est une spline" & vbCr & "FaultEntity.Count = " & IIf(fault Is Nothing, "0", fault.Count) & vbCr & Me.nom)
|
239 |
|
|
Return False
|
240 |
|
|
End Try
|
241 |
|
|
End Function
|
242 |
|
|
|
243 |
|
|
''' <summary>
|
244 |
|
|
''' Détermine si la courbe est une ellipse
|
245 |
|
|
''' </summary>
|
246 |
|
|
''' <returns></returns>
|
247 |
|
|
''' <remarks>Vrai si ellipse</remarks>
|
248 |
|
|
Public Function IsEllipse() As Boolean
|
249 |
|
|
Try
|
250 |
|
|
Dim swCourbe As SldWorks.Curve = Me.swArete.GetCurve
|
251 |
|
|
If swCourbe.IsLine Then Return False
|
252 |
|
|
Return swCourbe.IsEllipse
|
253 |
|
|
Catch
|
254 |
|
|
Dim fault As SldWorks.FaultEntity = Me.swArete.Check
|
255 |
|
|
Debug.WriteLine("N'arrive pas à déterminer si la courbe est une ellipse" & vbCr & "FaultEntity.Count = " & IIf(fault Is Nothing, "0", fault.Count) & vbCr & Me.nom)
|
256 |
|
|
End Try
|
257 |
|
|
|
258 |
|
|
End Function
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
''' <summary>
|
262 |
|
|
''' Sub pour sélectionner l'arète dans la fenètre de solidworks
|
263 |
|
|
''' </summary>
|
264 |
|
|
''' <param name="Append"></param>
|
265 |
|
|
''' <remarks></remarks>
|
266 |
|
|
Public Sub sélectionner(Optional ByVal Append As Boolean = False)
|
267 |
|
|
Dim swent As SldWorks.Entity
|
268 |
|
|
swent = Me.SwArete
|
269 |
|
|
swent.Select2(Append, 0)
|
270 |
|
|
End Sub
|
271 |
|
|
|
272 |
|
|
''' <summary>
|
273 |
|
|
''' Sub qui colore une arète
|
274 |
|
|
''' </summary>
|
275 |
|
|
''' <param name="Largeur">La largeur de la ligne</param>
|
276 |
|
|
''' <param name="Rouge">Le ton de rouge, entre 0 et 1</param>
|
277 |
|
|
''' <param name="Vert">Le ton de vert, entre 0 et 1</param>
|
278 |
|
|
''' <param name="Bleu">Le ton de bleu, entre 0 et 1</param>
|
279 |
|
|
''' <remarks></remarks>
|
280 |
|
|
Public Sub Colorer(Optional ByVal Largeur As Integer = 2, Optional ByRef Rouge As Double = 1, Optional ByRef Vert As Double = 0, Optional ByRef Bleu As Double = 0)
|
281 |
|
|
SwArete.Display(Largeur, Rouge, Vert, Bleu, True)
|
282 |
|
|
End Sub
|
283 |
|
|
|
284 |
|
|
|
285 |
|
|
''' <summary>
|
286 |
|
|
''' Sub qui met ou Update les paramètres des doublons des arètes
|
287 |
|
|
''' </summary>
|
288 |
|
|
''' <param name="Numero">Le numéro que l'on veut attribuer</param>
|
289 |
|
|
''' <param name="Maitre">Si ce,st un maitre on met true</param>
|
290 |
|
|
''' <param name="NomMaitre">Le nom du maitre si on le connait.</param>
|
291 |
|
|
''' <remarks>Il faut toujours effacer l'attribut du maitreé... ou s'assurer que dans MAGiC on ignore "Inconnu"... De plus, si l'attribut existe déjà, le numéro devient innutile.</remarks>
|
292 |
|
|
Public Sub MettreAttributDoublon(Optional ByRef Numero As Integer = 0, Optional ByRef Maitre As Boolean = False, Optional ByRef NomMaitre As String = Nothing)
|
293 |
|
|
Dim attr As SldWorks.Attribute
|
294 |
|
|
Dim swent As SldWorks.Entity
|
295 |
|
|
Dim nom As String
|
296 |
|
|
Dim ParamMaitre As SldWorks.Parameter
|
297 |
|
|
Dim paramSens As SldWorks.Parameter
|
298 |
|
|
Dim sens As Double = -5
|
299 |
|
|
|
300 |
|
|
'mettre un attribut et l'updater...
|
301 |
|
|
swent = Me.SwArete
|
302 |
|
|
|
303 |
|
|
nom = "DoublonA_" & Format(Numero, "000")
|
304 |
|
|
If Maitre Then nom &= "Maitre" Else nom &= "Esclave"
|
305 |
|
|
|
306 |
|
|
attr = swent.FindAttribute(Intersections.DefAttrDoublon, 0)
|
307 |
|
|
|
308 |
|
|
Do While attr Is Nothing
|
309 |
|
|
nom = "DoublonA_" & Format(Numero, "000")
|
310 |
|
|
If Maitre Then nom &= "Maitre" Else nom &= "Esclave"
|
311 |
|
|
attr = Intersections.DefAttrDoublon.CreateInstance5(swModel, SwArete, nom, 0, 2) ' 0 = swThisconfig
|
312 |
|
|
If attr Is Nothing Then Numero += 1
|
313 |
|
|
Loop
|
314 |
|
|
|
315 |
|
|
ParamMaitre = attr.GetParameter("Maitre")
|
316 |
|
|
paramsens = attr.GetParameter("Sens")
|
317 |
|
|
If NomMaitre = Nothing Then
|
318 |
|
|
NomMaitre = "Inconnu"
|
319 |
|
|
|
320 |
|
|
Else ' il faut mettre les attribut de doublons sur les sommets.
|
321 |
|
|
Dim swSommet1 As SldWorks.Vertex
|
322 |
|
|
Dim swSommet2 As SldWorks.Vertex
|
323 |
|
|
|
324 |
|
|
swSommet1 = Me.SwArete.GetStartVertex()
|
325 |
|
|
If swSommet1 IsNot Nothing Then
|
326 |
|
|
swSommet2 = Me.SwArete.GetEndVertex
|
327 |
|
|
Dim esom1 As New SuperSommet(swSommet1, True)
|
328 |
|
|
Dim esom2 As New SuperSommet(swSommet2, True)
|
329 |
|
|
Dim premier As Boolean = False
|
330 |
|
|
Dim second As Boolean = False
|
331 |
|
|
|
332 |
|
|
Dim SlySommetTest As SlySommetVolume
|
333 |
|
|
|
334 |
|
|
For Each SlySommetTest In Commun.lst_SommetVolume
|
335 |
|
|
If Not premier AndAlso Distance(esom1.GetSommet, SlySommetTest.swSommet) < Epsilon Then ' on vient de trouver le sommet du volume
|
336 |
|
|
esom1.MettreAttributDoublonSommet(SlySommetTest.nom, SlySommetTest.swSommet)
|
337 |
|
|
premier = True
|
338 |
|
|
ElseIf Distance(esom2.GetSommet, SlySommetTest.swSommet) < Epsilon Then
|
339 |
|
|
esom2.MettreAttributDoublonSommet(SlySommetTest.nom, SlySommetTest.swSommet)
|
340 |
|
|
second = True
|
341 |
|
|
End If
|
342 |
|
|
If premier AndAlso second Then Exit For
|
343 |
|
|
Next
|
344 |
|
|
|
345 |
|
|
End If
|
346 |
|
|
|
347 |
|
|
' trouver si le sens est le même, mettre 1 si oui, et -1 si non.
|
348 |
|
|
' on met 1 si les 2 startvertex sont au même endroit, -1 si ce n'est pas le cas
|
349 |
|
|
|
350 |
|
|
Dim a As SlyAreteVol = Nothing
|
351 |
|
|
Dim som1 As SldWorks.Vertex, som2 As SldWorks.Vertex
|
352 |
|
|
For Each a In Commun.lst_AreteVolume
|
353 |
|
|
If a.nom = NomMaitre Then Exit For
|
354 |
|
|
Next
|
355 |
|
|
som1 = Me.SwArete.GetStartVertex
|
356 |
|
|
If som1 IsNot Nothing Then
|
357 |
|
|
som2 = a.swArete.GetStartVertex
|
358 |
|
|
If Distance(som1, som2) < Epsilon Then sens = 1 Else sens = -1
|
359 |
|
|
Else ' wouch!, si on a une courbe fermée, comment on trouve le sens de l'arête maitre comparé à l'arète esclave.
|
360 |
|
|
' si les 2 arètes sont une par-dessus l'autre, alors je prend le point à t=0 et le T du point équivalent sur l'arète esclave
|
361 |
|
|
' si T+ deltaT = le même point sur l'arète esclave alors Bingo, même sens
|
362 |
|
|
|
363 |
|
|
' a est la Slyarete du maitre, Me est l'arète esclave
|
364 |
|
|
Dim x, y, z, T2, T3 As Double
|
365 |
|
|
Dim ret As Boolean = Me.Evaluer(0, x, y, z)
|
366 |
|
|
T2 = a.GetT(x, y, z)
|
367 |
|
|
|
368 |
|
|
Me.Evaluer(0.1, x, y, z)
|
369 |
|
|
T3 = a.GetT(x, y, z)
|
370 |
|
|
If T3 = (T2 + 0.1) Then sens = 1 Else sens = -1
|
371 |
|
|
End If
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
End If
|
376 |
|
|
|
377 |
|
|
paramSens.SetDoubleValue2(sens, 2, "")
|
378 |
|
|
ParamMaitre.SetStringValue2(NomMaitre, 2, "") ' swAllConfiguration = 2
|
379 |
|
|
GererDossiers("Doublons", nom)
|
380 |
|
|
|
381 |
|
|
'Me.Colorer(2, 1, 1, 0)
|
382 |
|
|
|
383 |
|
|
End Sub
|
384 |
|
|
|
385 |
|
|
|
386 |
|
|
''' <summary>
|
387 |
|
|
''' sub qui efface l'attribut du doublon sur l'arète maitre.
|
388 |
|
|
''' </summary>
|
389 |
|
|
''' <remarks></remarks>
|
390 |
|
|
Public Sub EffacerAttributDoublon()
|
391 |
|
|
Dim attr As SldWorks.Attribute
|
392 |
|
|
Dim swent As SldWorks.Entity
|
393 |
|
|
swent = Me.SwArete
|
394 |
|
|
attr = swent.FindAttribute(Intersections.DefAttrDoublon, 0)
|
395 |
|
|
attr.Delete(True)
|
396 |
|
|
End Sub
|
397 |
|
|
|
398 |
|
|
''' <summary>
|
399 |
|
|
''' Function qui retourne le nom qui est sur une arète
|
400 |
|
|
''' </summary>
|
401 |
|
|
''' <returns></returns>
|
402 |
|
|
''' <remarks></remarks>
|
403 |
|
|
Public Function getNom() As String
|
404 |
|
|
Dim swEnt As SldWorks.Entity
|
405 |
|
|
swEnt = swArete
|
406 |
|
|
getNom = swPart.GetEntityName(swEnt)
|
407 |
|
|
End Function
|
408 |
|
|
|
409 |
|
|
|
410 |
|
|
''' <summary>
|
411 |
|
|
''' Calcule et retourne le T au milieu de l'arète
|
412 |
|
|
''' </summary>
|
413 |
|
|
''' <returns>Le T du milieu</returns>
|
414 |
|
|
''' <remarks></remarks>
|
415 |
|
|
Public Function GetTMilieu() As Double
|
416 |
|
|
Dim swCourbe As SldWorks.Curve
|
417 |
|
|
Dim temp As Object
|
418 |
|
|
Dim T1 As Double, T2 As Double
|
419 |
|
|
Dim sommet As SldWorks.Vertex
|
420 |
|
|
Dim point As Object
|
421 |
|
|
|
422 |
|
|
swCourbe = Me.SwArete.GetCurve
|
423 |
|
|
|
424 |
|
|
sommet = Me.SwArete.GetStartVertex()
|
425 |
|
|
|
426 |
|
|
If sommet IsNot Nothing Then
|
427 |
|
|
point = sommet.GetPoint() : temp = SwArete.GetParameter(point(0), point(1), point(2)) : T1 = temp(0)
|
428 |
|
|
sommet = SwArete.GetEndVertex() : point = sommet.GetPoint() : temp = SwArete.GetParameter(point(0), point(1), point(2)) : T2 = temp(0)
|
429 |
|
|
Return (T1 + T2) / 2
|
430 |
|
|
|
431 |
|
|
Else
|
432 |
|
|
'l'arète est fermée.
|
433 |
|
|
Return 0.5 ' c'est un cercle... tous les points sont au milieu!
|
434 |
|
|
MsgBox("On demande la longueur d'une courbe fermée qui n'est pas un cercle... ce n'est pas encore programmé car ça ne devrait pas arriver.")
|
435 |
|
|
End If
|
436 |
|
|
|
437 |
|
|
End Function
|
438 |
|
|
|
439 |
|
|
|
440 |
|
|
''' <summary>
|
441 |
|
|
''' Calcule et retourne la valeur de T à un certain endroit
|
442 |
|
|
''' </summary>
|
443 |
|
|
''' <param name="x"></param>
|
444 |
|
|
''' <param name="y"></param>
|
445 |
|
|
''' <param name="z"></param>
|
446 |
|
|
''' <returns></returns>
|
447 |
|
|
''' <remarks></remarks>
|
448 |
|
|
Public Function GetT(ByRef x As Double, ByRef y As Double, ByRef z As Double) As Double
|
449 |
|
|
Dim retval As Object
|
450 |
|
|
Dim retour(1) As Double
|
451 |
|
|
retval = Me.SwArete.GetParameter(x, y, z)
|
452 |
|
|
retour = retval
|
453 |
|
|
If Not retour(1) Then MsgBox("GetT n'a pas fonctionné pour cette arête.", MsgBoxStyle.Critical)
|
454 |
|
|
Return retour(0)
|
455 |
|
|
End Function
|
456 |
|
|
|
457 |
|
|
''' <summary>
|
458 |
|
|
''' Fonction qui retourne le Tmin de l'arète
|
459 |
|
|
''' </summary>
|
460 |
|
|
''' <returns>Tmax</returns>
|
461 |
|
|
''' <remarks></remarks>
|
462 |
|
|
Public Function GetTMin() As Double
|
463 |
|
|
Dim vp As Object
|
464 |
|
|
SwArete.GetCurve()
|
465 |
|
|
vp = SwArete.GetCurveParams2()
|
466 |
|
|
Return vp(6)
|
467 |
|
|
End Function
|
468 |
|
|
|
469 |
|
|
|
470 |
|
|
''' <summary>
|
471 |
|
|
''' Fonction qui retourne le Tmax de l'arète
|
472 |
|
|
''' </summary>
|
473 |
|
|
''' <returns>Tmax</returns>
|
474 |
|
|
''' <remarks></remarks>
|
475 |
|
|
Public Function GetTMax() As Double
|
476 |
|
|
Dim vp As Object
|
477 |
|
|
SwArete.GetCurve()
|
478 |
|
|
vp = SwArete.GetCurveParams2()
|
479 |
|
|
Return vp(7)
|
480 |
|
|
End Function
|
481 |
|
|
|
482 |
|
|
|
483 |
|
|
''' <summary>
|
484 |
|
|
''' Détermine si la valeur de T est sur la courbe, si oui ça retourne les coordonnées XYZ
|
485 |
|
|
''' </summary>
|
486 |
|
|
''' <param name="T"></param>
|
487 |
|
|
''' <param name="xyz"></param>
|
488 |
|
|
''' <returns></returns>
|
489 |
|
|
''' <remarks></remarks>
|
490 |
|
|
Public Function Evaluer(ByRef T As Double, Optional ByRef xyz() As Double = Nothing) As Boolean
|
491 |
|
|
|
492 |
|
|
Dim temp(2) As Double
|
493 |
|
|
Dim retval As Object
|
494 |
|
|
Dim retour() As Double
|
495 |
|
|
Dim T1 As Double
|
496 |
|
|
Dim T2 As Double
|
497 |
|
|
|
498 |
|
|
retval = Me.SwArete.GetCurveParams2()
|
499 |
|
|
retour = retval
|
500 |
|
|
T1 = retour(6)
|
501 |
|
|
T2 = retour(7)
|
502 |
|
|
|
503 |
|
|
If Not ((T >= T1) And (T <= T2)) Then Return False
|
504 |
|
|
|
505 |
|
|
retval = Me.SwArete.Evaluate(T)
|
506 |
|
|
|
507 |
|
|
temp(0) = retval(0)
|
508 |
|
|
temp(1) = retval(1)
|
509 |
|
|
temp(2) = retval(2)
|
510 |
|
|
|
511 |
|
|
xyz = temp
|
512 |
|
|
|
513 |
|
|
Return True
|
514 |
|
|
|
515 |
|
|
End Function
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
''' <summary>
|
519 |
|
|
''' Détermine si la valeur de T est sur la courbe, si oui ça retourne les coordonnées XYZ
|
520 |
|
|
''' </summary>
|
521 |
|
|
''' <param name="T"></param>
|
522 |
|
|
''' <param name="x"></param>
|
523 |
|
|
''' <param name="y"></param>
|
524 |
|
|
''' <param name="z"></param>
|
525 |
|
|
''' <returns></returns>
|
526 |
|
|
''' <remarks></remarks>
|
527 |
|
|
Public Function Evaluer(ByRef T As Double, ByRef x As Double, ByRef y As Double, ByRef z As Double) As Boolean
|
528 |
|
|
'si XYZ est omis alors on veut juste savoir si le paramètre est sur la courbe
|
529 |
|
|
|
530 |
|
|
Dim temp(2) As Double
|
531 |
|
|
Dim retval As Object
|
532 |
|
|
Dim retour() As Double
|
533 |
|
|
Dim T1 As Double
|
534 |
|
|
Dim T2 As Double
|
535 |
|
|
|
536 |
|
|
retval = Me.SwArete.GetCurveParams2()
|
537 |
|
|
retour = retval
|
538 |
|
|
T1 = retour(6)
|
539 |
|
|
T2 = retour(7)
|
540 |
|
|
|
541 |
|
|
If Not ((T >= T1) And (T <= T2)) Then Return False
|
542 |
|
|
|
543 |
|
|
retval = Me.SwArete.Evaluate(T)
|
544 |
|
|
|
545 |
|
|
x = retval(0)
|
546 |
|
|
y = retval(1)
|
547 |
|
|
z = retval(2)
|
548 |
|
|
|
549 |
|
|
Return True
|
550 |
|
|
End Function
|
551 |
|
|
|
552 |
|
|
''' <summary>
|
553 |
|
|
''' Fonction qui compare la superarete avec une autre arète de solidworks
|
554 |
|
|
''' </summary>
|
555 |
|
|
''' <param name="swArete"></param>
|
556 |
|
|
''' <returns></returns>
|
557 |
|
|
''' <remarks></remarks>
|
558 |
|
|
Public Function comparer(ByRef swArete As SldWorks.Edge) As Boolean
|
559 |
|
|
Dim e As New SuperArete(swArete, True)
|
560 |
|
|
Return comparer(e)
|
561 |
|
|
End Function
|
562 |
|
|
|
563 |
|
|
|
564 |
|
|
|
565 |
|
|
|
566 |
|
|
''' <summary>
|
567 |
|
|
''' Fonction qui compare 2 superaretes. Retourne vrai si les 2 arêtes sont identiques
|
568 |
|
|
''' </summary>
|
569 |
|
|
''' <param name="sAreteTest">L'arète avec laquelle comparer</param>
|
570 |
|
|
''' <returns>Vrais si les 2 arêtes peuvent être fusionnées. Faux sinon</returns>
|
571 |
|
|
''' <remarks></remarks>
|
572 |
|
|
Public Function Comparer(ByRef sAreteTest As SuperArete) As Boolean
|
573 |
|
|
'on a 2 arètes, et on ne peut comparer directement les pointeurs...
|
574 |
|
|
|
575 |
|
|
If swArete Is sAreteTest Then Return True
|
576 |
|
|
|
577 |
|
|
' les conditions suivantes doivent toutes être vrai pour retourner oui..
|
578 |
|
|
' 1 - les types sont les mêmes (lignes, cercles, bsplines...)
|
579 |
|
|
If Not Me.IsLine = sAreteTest.IsLine Then Return False
|
580 |
|
|
|
581 |
|
|
|
582 |
|
|
|
583 |
|
|
' 2 - les 2 points d'extrémités sont identiques.
|
584 |
|
|
Dim debut1() As Double = Me.GetStartPoint
|
585 |
|
|
Dim debut2() As Double = sAreteTest.GetStartPoint
|
586 |
|
|
Dim fin1() As Double = Me.GetEndPoint
|
587 |
|
|
Dim fin2() As Double = sAreteTest.GetEndPoint
|
588 |
|
|
|
589 |
|
|
If debut1 Is Nothing Xor debut2 Is Nothing Then Return False
|
590 |
|
|
If debut1 Is Nothing And debut2 Is Nothing Then ' peut-être un cercle
|
591 |
|
|
If Not swModel.ClosestDistance(sAreteTest.swArete, Me.swArete, Nothing, Nothing) < Epsilon Then Return False
|
592 |
|
|
' bon, on a 2 cercles (ou courbe fermées) qui se touchent à au moins un point...
|
593 |
|
|
Dim courbe1 As SldWorks.Curve = Me.swArete.GetCurve
|
594 |
|
|
Dim courbe2 As SldWorks.Curve = sAreteTest.swArete.GetCurve
|
595 |
|
|
|
596 |
|
|
If courbe1.IsCircle AndAlso courbe2.IsCircle Then
|
597 |
|
|
Dim vparam1 As Object = courbe1.CircleParams()
|
598 |
|
|
Dim vparam2 As Object = courbe2.CircleParams()
|
599 |
|
|
If Math.Abs(vparam1(0) - vparam2(0)) < Epsilon AndAlso Math.Abs(vparam1(1) - vparam2(1)) < Epsilon AndAlso Math.Abs(vparam1(2) - vparam2(2)) < Epsilon AndAlso Math.Abs(vparam1(6) - vparam2(6)) < Epsilon Then Return True Else Return False ' centreX , y , z , Radius(6)
|
600 |
|
|
ElseIf courbe1.IsEllipse AndAlso courbe1.IsEllipse Then
|
601 |
|
|
Dim vparam1 As Object = courbe1.GetEllipseParams()
|
602 |
|
|
Dim vparam2 As Object = courbe2.GetEllipseParams()
|
603 |
|
|
For i As Integer = 0 To 10
|
604 |
|
|
If Math.Abs(vparam1(i) - vparam2(i)) > Epsilon Then Return False
|
605 |
|
|
Next
|
606 |
|
|
Return True
|
607 |
|
|
Else
|
608 |
|
|
Return False
|
609 |
|
|
End If
|
610 |
|
|
End If
|
611 |
|
|
|
612 |
|
|
If Distance(debut1, debut2) > Epsilon AndAlso Distance(debut1, fin2) > Epsilon Then Return False
|
613 |
|
|
If Distance(fin1, debut2) > Epsilon AndAlso Distance(fin1, fin2) > Epsilon Then Return False
|
614 |
|
|
|
615 |
|
|
' le pointmilieu est identique
|
616 |
|
|
Dim Milieu1() As Double = Me.GetPointMilieu()
|
617 |
|
|
Dim milieu2() As Double = sAreteTest.GetPointMilieu
|
618 |
|
|
If Distance(Milieu1, milieu2) > Epsilon Then Return False
|
619 |
|
|
|
620 |
|
|
Return True ' pourrait ne pas marcher dans certains cas fucké...
|
621 |
|
|
End Function
|
622 |
|
|
|
623 |
|
|
''' <summary>
|
624 |
|
|
''' Function qui calcule la longueur de l'arète
|
625 |
|
|
''' </summary>
|
626 |
|
|
''' <returns>La longueur de l'arrète</returns>
|
627 |
|
|
''' <remarks></remarks>
|
628 |
|
|
Public Function Longueur() As Double
|
629 |
|
|
Dim temp As Object
|
630 |
|
|
Dim T1 As Double, T2 As Double
|
631 |
|
|
Dim sommet As SldWorks.Vertex
|
632 |
|
|
Dim point As Object
|
633 |
|
|
|
634 |
|
|
sommet = SwArete.GetStartVertex()
|
635 |
|
|
|
636 |
|
|
If sommet IsNot Nothing Then
|
637 |
|
|
point = sommet.GetPoint() : temp = SwArete.GetParameter(point(0), point(1), point(2)) : T1 = temp(0)
|
638 |
|
|
sommet = SwArete.GetEndVertex() : point = sommet.GetPoint() : temp = SwArete.GetParameter(point(0), point(1), point(2)) : T2 = temp(0)
|
639 |
|
|
Return swCourbe.GetLength2(T1, T2)
|
640 |
|
|
|
641 |
|
|
Else
|
642 |
|
|
'l'arète est fermée.
|
643 |
|
|
Dim params() As Double
|
644 |
|
|
If swCourbe.IsCircle Then
|
645 |
|
|
params = swCourbe.CircleParams
|
646 |
|
|
Return params(7) * Pi * 2
|
647 |
|
|
End If
|
648 |
|
|
MsgBox("On demande la longueur d'une courbe fermée qui n'est pas un cercle... ce n'est pas encore programmé car ça ne devrait pas arriver.")
|
649 |
|
|
End If
|
650 |
|
|
End Function
|
651 |
|
|
|
652 |
|
|
''' <summary>
|
653 |
|
|
''' Renvoie les coordonnées du point de départ
|
654 |
|
|
''' </summary>
|
655 |
|
|
''' <returns></returns>
|
656 |
|
|
''' <remarks></remarks>
|
657 |
|
|
Public Function GetStartPoint() As Double()
|
658 |
|
|
Dim swSommet As SldWorks.Vertex
|
659 |
|
|
Dim retval As Object
|
660 |
|
|
Dim xyz(2) As Double
|
661 |
|
|
swSommet = Me.SwArete.GetStartVertex()
|
662 |
|
|
If swSommet Is Nothing Then Return Nothing
|
663 |
|
|
retval = swSommet.GetPoint()
|
664 |
|
|
xyz = retval
|
665 |
|
|
Return xyz
|
666 |
|
|
End Function
|
667 |
|
|
|
668 |
|
|
''' <summary>
|
669 |
|
|
''' Renvoie les coordonnées du point de départ
|
670 |
|
|
''' </summary>
|
671 |
|
|
''' <returns>Faux si le sommet n'esiste pas</returns>
|
672 |
|
|
''' <remarks></remarks>
|
673 |
|
|
Public Function GetStartPoint(ByRef x As Double, ByRef y As Double, ByRef z As Double) As Boolean
|
674 |
|
|
Dim swSommet As SldWorks.Vertex
|
675 |
|
|
Dim retval As Object
|
676 |
|
|
Dim xyz(2) As Double
|
677 |
|
|
swSommet = Me.SwArete.GetStartVertex()
|
678 |
|
|
If swSommet Is Nothing Then Return False
|
679 |
|
|
retval = swSommet.GetPoint()
|
680 |
|
|
x = retval(0)
|
681 |
|
|
y = retval(1)
|
682 |
|
|
z = retval(2)
|
683 |
|
|
Return True
|
684 |
|
|
End Function
|
685 |
|
|
|
686 |
|
|
Public Function GetEndPoint() As Double()
|
687 |
|
|
Dim swSommet As SldWorks.Vertex
|
688 |
|
|
Dim retval As Object
|
689 |
|
|
Dim xyz(2) As Double
|
690 |
|
|
swSommet = Me.SwArete.GetEndVertex()
|
691 |
|
|
If swSommet Is Nothing Then Return Nothing
|
692 |
|
|
retval = swSommet.GetPoint()
|
693 |
|
|
xyz = retval
|
694 |
|
|
Return xyz
|
695 |
|
|
End Function
|
696 |
|
|
|
697 |
|
|
''' <summary>
|
698 |
|
|
''' Renvoie les coordonnées du point de fin
|
699 |
|
|
''' </summary>
|
700 |
|
|
''' <returns>Faux si le sommet n'esiste pas</returns>
|
701 |
|
|
''' <remarks></remarks>
|
702 |
|
|
Public Function GetEndPoint(ByRef x As Double, ByRef y As Double, ByRef z As Double) As Boolean
|
703 |
|
|
Dim swSommet As SldWorks.Vertex
|
704 |
|
|
Dim retval As Object
|
705 |
|
|
Dim xyz(2) As Double
|
706 |
|
|
swSommet = Me.SwArete.GetEndVertex()
|
707 |
|
|
If swSommet Is Nothing Then Return False
|
708 |
|
|
retval = swSommet.GetPoint()
|
709 |
|
|
x = retval(0)
|
710 |
|
|
y = retval(1)
|
711 |
|
|
z = retval(2)
|
712 |
|
|
Return True
|
713 |
|
|
End Function
|
714 |
|
|
|
715 |
|
|
|
716 |
|
|
|
717 |
|
|
|
718 |
|
|
|
719 |
|
|
|
720 |
|
|
|
721 |
|
|
|
722 |
|
|
|
723 |
|
|
|
724 |
|
|
|
725 |
|
|
|
726 |
|
|
|
727 |
|
|
End Class
|