Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-01-22 |
2 | // Created by: Prestataire Michael ALEONARD | |
3 | // Copyright (c) 1997-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
b311480e | 16 | |
7fd59977 | 17 | |
42cf5bc1 | 18 | #include <DsgPrs_SymmetricPresentation.hxx> |
19 | #include <ElCLib.hxx> | |
20 | #include <gce_MakeDir.hxx> | |
21 | #include <gce_MakeLin.hxx> | |
22 | #include <Geom2d_Line.hxx> | |
23 | #include <Geom_Line.hxx> | |
24 | #include <Geom_Plane.hxx> | |
25 | #include <GeomAPI.hxx> | |
7fd59977 | 26 | #include <gp_Ax1.hxx> |
27 | #include <gp_Ax2.hxx> | |
42cf5bc1 | 28 | #include <gp_Circ.hxx> |
29 | #include <gp_Dir.hxx> | |
30 | #include <gp_Lin.hxx> | |
7fd59977 | 31 | #include <gp_Pnt.hxx> |
32 | #include <gp_Pnt2d.hxx> | |
42cf5bc1 | 33 | #include <gp_Vec.hxx> |
34 | #include <Graphic3d_ArrayOfPoints.hxx> | |
b8ddfc2f | 35 | #include <Graphic3d_ArrayOfPolylines.hxx> |
42cf5bc1 | 36 | #include <Graphic3d_ArrayOfSegments.hxx> |
7fd59977 | 37 | #include <Graphic3d_AspectLine3d.hxx> |
38 | #include <Graphic3d_AspectMarker3d.hxx> | |
42cf5bc1 | 39 | #include <Graphic3d_Group.hxx> |
42cf5bc1 | 40 | #include <IntAna2d_AnaIntersection.hxx> |
41 | #include <Precision.hxx> | |
7fd59977 | 42 | #include <Prs3d_Arrow.hxx> |
43 | #include <Prs3d_ArrowAspect.hxx> | |
a6eb515f | 44 | #include <Prs3d_DimensionAspect.hxx> |
42cf5bc1 | 45 | #include <Prs3d_LineAspect.hxx> |
46 | #include <Prs3d_Presentation.hxx> | |
7fd59977 | 47 | #include <TCollection_AsciiString.hxx> |
48 | ||
7fd59977 | 49 | //=================================================================== |
50 | //Function:Add | |
51 | //Purpose: draws the representation of an axial symmetry between two segments. | |
52 | //=================================================================== | |
53 | void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, | |
54 | const Handle(Prs3d_Drawer)& aDrawer, | |
55 | const gp_Pnt& AttachmentPoint1, | |
56 | const gp_Pnt& AttachmentPoint2, | |
57 | const gp_Dir& aDirection1, | |
58 | const gp_Lin& aAxis, | |
59 | const gp_Pnt& OffsetPoint) | |
60 | { | |
a6eb515f | 61 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
b8ddfc2f | 62 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
63 | ||
7fd59977 | 64 | gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPoint),aAxis); |
65 | gp_Pnt PjAttachPnt1 = ElCLib::Value(ElCLib::Parameter(aAxis,AttachmentPoint1),aAxis); | |
66 | gp_Dir aDirectionAxis = aAxis.Direction(); | |
7fd59977 | 67 | Standard_Real h = fabs(ProjOffsetPoint.Distance(PjAttachPnt1)/cos(aDirectionAxis.Angle(aDirection1))); |
68 | ||
69 | gp_Vec VL1(aDirection1); | |
70 | gp_Vec VLa(PjAttachPnt1,ProjOffsetPoint); | |
71 | Standard_Real scal; | |
72 | scal = VL1.Dot(VLa); | |
73 | if (scal < 0) VL1.Reverse(); | |
74 | VL1.Multiply(h); | |
75 | ||
76 | gp_Pnt P1,P2; | |
77 | ||
78 | //=================================== | |
81bba717 | 79 | // SYMETRY OF EDGE PERPEND. TO THE AXIS |
7fd59977 | 80 | // ____ : ____ |
81 | // edge2 | : -=- | edge 1 | |
82 | // |<------:------>| | |
83 | // : | |
84 | //=================================== | |
85 | ||
86 | if (VLa.Dot(VL1) == 0) { | |
87 | P1 = AttachmentPoint1.Translated(VLa); | |
88 | gp_Vec VPntat2Axe(PjAttachPnt1,AttachmentPoint2); | |
89 | P2 = ProjOffsetPoint.Translated(VPntat2Axe); | |
90 | } | |
91 | else { | |
92 | P1 = AttachmentPoint1.Translated(VL1); | |
93 | gp_Vec VPntat1Axe(P1,ProjOffsetPoint); | |
94 | P2 = ProjOffsetPoint.Translated(VPntat1Axe); | |
95 | } | |
96 | ||
97 | gp_Lin L3 = gce_MakeLin(P1,P2); | |
98 | Standard_Real parmin,parmax,parcur; | |
99 | parmin = ElCLib::Parameter(L3,P1); | |
100 | parmax = parmin; | |
101 | parcur = ElCLib::Parameter(L3,P2); | |
102 | Standard_Real dist = Abs(parmin-parcur); | |
103 | if (parcur < parmin) parmin = parcur; | |
104 | if (parcur > parmax) parmax = parcur; | |
105 | parcur = ElCLib::Parameter(L3,OffsetPoint); | |
106 | gp_Pnt offp = ElCLib::Value(parcur,L3); | |
107 | ||
108 | Standard_Boolean outside = Standard_False; | |
109 | if (parcur < parmin) { | |
110 | parmin = parcur; | |
111 | outside = Standard_True; | |
112 | } | |
113 | if (parcur > parmax) { | |
114 | parmax = parcur; | |
115 | outside = Standard_True; | |
116 | } | |
117 | ||
118 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); | |
119 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); | |
7fd59977 | 120 | |
ee2be2a8 | 121 | Standard_Real X,Y,Z; |
b8ddfc2f | 122 | Standard_Real D1(aAxis.Distance(AttachmentPoint1)),coeff(.5); |
123 | gp_Pnt pint,Pj_P1,P1Previous = P1; | |
7fd59977 | 124 | |
012d92b6 | 125 | /*======================================================= |
126 | TO AVOID CROSSING | |
127 | P1 -=- P2 P2 -=- P1 | |
128 | \<-->/ |<-->| | |
129 | \ / | | | |
130 | \/ | | | |
131 | /\ | | | |
132 | / \ | | | |
133 | Pattach2 /____\ Pattach1 Pattach2 /______\ Pattach1 | |
134 | / NO \ / YES \ | |
135 | =======================================================*/ | |
7fd59977 | 136 | |
137 | Standard_Boolean Cross = Standard_False; | |
138 | gp_Vec Attch1_PjAttch1(AttachmentPoint1,PjAttachPnt1); | |
139 | gp_Vec v(P1,ProjOffsetPoint); | |
140 | if (v.IsOpposite((Attch1_PjAttch1),Precision::Confusion())){ | |
141 | Cross = Standard_True; | |
142 | gp_Pnt PntTempo; | |
143 | PntTempo = P1; | |
144 | P1 = P2; | |
145 | P2 = PntTempo; | |
146 | } | |
012d92b6 | 147 | /*=================================== |
148 | FRACTURES OF TRAITS OF CALL | |
149 | / \ | |
150 | / \ | |
151 | | -=- | | |
152 | |<------------->| | |
153 | ===================================*/ | |
b8ddfc2f | 154 | |
7fd59977 | 155 | gp_Vec Vfix; |
7fd59977 | 156 | Standard_Real alpha,b; |
157 | ||
158 | if(aAxis.Distance(P1) > D1*(1 + coeff) && !Cross){ | |
159 | ||
81bba717 | 160 | //==== PROCESSING OF FACE =========== |
7fd59977 | 161 | Prs3d_Root::NewGroup(aPresentation); |
162 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 163 | |
7fd59977 | 164 | Pj_P1 = ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis); |
165 | gp_Vec Vp(Pj_P1,P1); | |
166 | Vfix = Vp.Divided(Vp.Magnitude()).Multiplied(D1*(1 + coeff)); | |
b8ddfc2f | 167 | P1 = Pj_P1.Translated(Vfix); |
168 | P2 = Pj_P1.Translated(Vfix.Reversed()); | |
7fd59977 | 169 | |
170 | //================================= | |
81bba717 | 171 | // LISTING AT THE EXTERIOR |
7fd59977 | 172 | // -=- |
173 | // ->|----------|<------ | |
174 | // | | | |
175 | //================================= | |
176 | ||
177 | L3 = gce_MakeLin(P1,P2); | |
178 | parmin = ElCLib::Parameter(L3,P1); | |
179 | parmax = parmin; | |
180 | parcur = ElCLib::Parameter(L3,P2); | |
181 | dist = Abs(parmin-parcur); | |
182 | if (parcur < parmin) parmin = parcur; | |
183 | if (parcur > parmax) parmax = parcur; | |
184 | parcur = ElCLib::Parameter(L3,OffsetPoint); | |
185 | offp = ElCLib::Value(parcur,L3); | |
186 | outside = Standard_False; | |
187 | if (parcur < parmin) { | |
188 | parmin = parcur; | |
189 | outside = Standard_True; | |
190 | } | |
191 | if (parcur > parmax) { | |
192 | parmax = parcur; | |
193 | outside = Standard_True; | |
194 | } | |
195 | PointMin = ElCLib::Value(parmin,L3); | |
196 | PointMax = ElCLib::Value(parmax,L3); | |
197 | ||
b8ddfc2f | 198 | Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(8,3); |
199 | ||
200 | aPrims->AddBound(2); | |
201 | aPrims->AddVertex(PointMin); | |
202 | aPrims->AddVertex(PointMax); | |
7fd59977 | 203 | |
81bba717 | 204 | //==== PROCESSING OF CALL 1 ===== |
7fd59977 | 205 | alpha = aDirectionAxis.Angle(aDirection1); |
206 | b = (coeff*D1)/sin(alpha); | |
207 | gp_Vec Vpint(AttachmentPoint1,P1Previous); | |
b8ddfc2f | 208 | pint = AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)); |
209 | ||
210 | aPrims->AddBound(3); | |
211 | aPrims->AddVertex(AttachmentPoint1); | |
212 | aPrims->AddVertex(pint); | |
213 | aPrims->AddVertex(P1); | |
214 | ||
81bba717 | 215 | //==== PROCESSING OF CALL 2 ===== |
7fd59977 | 216 | gp_Pnt Pj_pint = ElCLib::Value(ElCLib::Parameter(aAxis,pint),aAxis); |
217 | gp_Vec V_int(pint, Pj_pint); | |
b8ddfc2f | 218 | gp_Pnt Sym_pint = Pj_pint.Translated(V_int); |
219 | ||
220 | aPrims->AddBound(3); | |
221 | aPrims->AddVertex(AttachmentPoint2); | |
222 | aPrims->AddVertex(Sym_pint); | |
223 | aPrims->AddVertex(P2); | |
224 | ||
225 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 226 | } |
227 | ||
012d92b6 | 228 | /*=================================== |
229 | FRACTURES OF PROCESSING OF CALL | |
230 | -=- | |
231 | |<--------->| | |
232 | | | | |
233 | / \ | |
234 | / \ | |
235 | ===================================*/ | |
7fd59977 | 236 | else if (aAxis.Distance(P1) < D1*(1 - coeff) || Cross) { |
237 | ||
81bba717 | 238 | //------ PROCESSING OF FACE ------------ |
7fd59977 | 239 | Prs3d_Root::NewGroup(aPresentation); |
240 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 241 | |
7fd59977 | 242 | Pj_P1 = ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis); |
243 | gp_Vec VpInf(Pj_P1,P1); | |
244 | Vfix = VpInf.Divided(VpInf.Magnitude()).Multiplied(D1*(1 - coeff)); | |
245 | Pj_P1.Translated(Vfix).Coord(X,Y,Z); | |
246 | P1.SetCoord(X,Y,Z); | |
247 | Pj_P1.Translated(Vfix.Reversed()).Coord(X,Y,Z); | |
248 | P2.SetCoord(X,Y,Z); | |
249 | ||
250 | //================================= | |
81bba717 | 251 | // LISTING AT THE EXTERIOR |
7fd59977 | 252 | // -=- |
253 | // ->|----------|<------ | |
254 | // | | | |
255 | //================================= | |
256 | L3 = gce_MakeLin(P1,P2); | |
257 | parmin = ElCLib::Parameter(L3,P1); | |
258 | parmax = parmin; | |
259 | parcur = ElCLib::Parameter(L3,P2); | |
260 | dist = Abs(parmin-parcur); | |
261 | if (parcur < parmin) parmin = parcur; | |
262 | if (parcur > parmax) parmax = parcur; | |
263 | parcur = ElCLib::Parameter(L3,OffsetPoint); | |
264 | offp = ElCLib::Value(parcur,L3); | |
265 | outside = Standard_False; | |
266 | if (parcur < parmin) { | |
267 | parmin = parcur; | |
268 | outside = Standard_True; | |
269 | } | |
270 | if (parcur > parmax) { | |
271 | parmax = parcur; | |
272 | outside = Standard_True; | |
273 | } | |
274 | PointMin = ElCLib::Value(parmin,L3); | |
275 | PointMax = ElCLib::Value(parmax,L3); | |
276 | ||
b8ddfc2f | 277 | Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(8,3); |
278 | ||
279 | aPrims->AddBound(2); | |
280 | aPrims->AddVertex(PointMin); | |
281 | aPrims->AddVertex(PointMax); | |
7fd59977 | 282 | |
81bba717 | 283 | //==== PROCESSING OF CALL 1 ===== |
7fd59977 | 284 | alpha = aDirectionAxis.Angle(aDirection1); |
285 | b = (coeff*D1)/sin(alpha); | |
286 | gp_Vec Vpint(AttachmentPoint1,P1Previous); | |
b8ddfc2f | 287 | pint = AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)); |
288 | ||
289 | aPrims->AddBound(3); | |
290 | aPrims->AddVertex(AttachmentPoint1); | |
291 | aPrims->AddVertex(pint); | |
292 | aPrims->AddVertex(P1); | |
7fd59977 | 293 | |
81bba717 | 294 | //==== PROCESSING OF CALL 2 ===== |
7fd59977 | 295 | gp_Pnt Pj_pint = ElCLib::Value(ElCLib::Parameter(aAxis,pint),aAxis); |
296 | gp_Vec V_int(pint, Pj_pint); | |
b8ddfc2f | 297 | gp_Pnt Sym_pint = Pj_pint.Translated(V_int); |
298 | ||
299 | aPrims->AddBound(3); | |
300 | aPrims->AddVertex(AttachmentPoint2); | |
301 | aPrims->AddVertex(Sym_pint); | |
302 | aPrims->AddVertex(P2); | |
303 | ||
304 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 305 | } |
306 | else { | |
307 | ||
81bba717 | 308 | //==== PROCESSING OF FACE =========== |
7fd59977 | 309 | Prs3d_Root::NewGroup(aPresentation); |
310 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
7fd59977 | 311 | |
b8ddfc2f | 312 | Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(6); |
313 | ||
314 | aPrims->AddVertex(PointMin); | |
315 | aPrims->AddVertex(PointMax); | |
316 | ||
81bba717 | 317 | //==== PROCESSING OF CALL 1 ===== |
b8ddfc2f | 318 | aPrims->AddVertex(AttachmentPoint1); |
319 | aPrims->AddVertex(P1); | |
7fd59977 | 320 | |
81bba717 | 321 | //==== PROCESSING OF CALL 2 ===== |
b8ddfc2f | 322 | aPrims->AddVertex(AttachmentPoint2); |
323 | aPrims->AddVertex(P2); | |
324 | ||
325 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 326 | } |
327 | ||
81bba717 | 328 | //==== ARROWS ================ |
7fd59977 | 329 | Prs3d_Root::NewGroup(aPresentation); |
330 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
331 | ||
a6eb515f | 332 | if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; |
7fd59977 | 333 | gp_Dir arrdir = L3.Direction().Reversed(); |
334 | if (outside) arrdir.Reverse(); | |
81bba717 | 335 | // arrow 1 ---- |
4ad142d9 | 336 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), P1, arrdir, LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 | 337 | |
81bba717 | 338 | // arrow 2 ---- |
4ad142d9 | 339 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), P2, arrdir.Reversed(), LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 | 340 | |
81bba717 | 341 | //------------------------------------------------------------------------------------- |
342 | //| SYMBOL OF SYMMETRY | | |
343 | //------------------------------------------------------------------------------------- | |
7fd59977 | 344 | |
81bba717 | 345 | // ------- : Superior Segment |
346 | // ----------- : Axis | |
347 | // ------- : Inferior Segment | |
7fd59977 | 348 | |
349 | gp_Vec Vvar(P1,P2); | |
350 | gp_Vec vec; | |
351 | gp_Vec Vtmp = Vvar.Divided(Vvar.Magnitude()).Multiplied((aAxis.Distance(AttachmentPoint1)+ | |
352 | aAxis.Distance(AttachmentPoint2))); | |
353 | vec.SetCoord(Vtmp.X(),Vtmp.Y(),Vtmp.Z()); | |
354 | gp_Vec vecA = vec.Multiplied(.1); | |
355 | ||
356 | gp_Dir DirAxis = aAxis.Direction(); | |
357 | gp_Vec Vaxe(DirAxis); | |
358 | gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude()); | |
359 | vecB.Multiply(.5); | |
360 | ||
361 | gp_Pnt pm,pOff; | |
362 | if (VLa.Dot(VL1) == 0) { | |
363 | gp_Vec Vper(P1,ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis)); | |
364 | pm = P1.Translated(Vper); | |
365 | } | |
366 | else { | |
367 | pm = P1.Translated(Vvar.Multiplied(.5)); | |
368 | } | |
7fd59977 | 369 | pOff = OffsetPoint.Translated(vecB); |
370 | ||
81bba717 | 371 | //Calculate the extremities of the symbol axis |
7fd59977 | 372 | gp_Vec vecAxe = vecA.Multiplied(.7); |
b8ddfc2f | 373 | |
7fd59977 | 374 | Prs3d_Root::NewGroup(aPresentation); |
375 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 376 | |
377 | Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(13,5); | |
378 | ||
379 | aPrims->AddBound(2); | |
380 | aPrims->AddVertex(pOff.Translated(vecAxe)); | |
381 | aPrims->AddVertex(pOff.Translated(vecAxe.Reversed())); | |
7fd59977 | 382 | |
81bba717 | 383 | //Calculate the extremities of the superior segment of the symbol |
7fd59977 | 384 | gp_Vec vec1 = vecAxe.Multiplied(.6); |
385 | vecAxe = Vaxe.Multiplied(vecAxe.Magnitude()); | |
386 | gp_Vec vec2 = vecAxe.Multiplied(.4); | |
387 | ||
b8ddfc2f | 388 | aPrims->AddBound(2); |
389 | aPrims->AddVertex(pOff.Translated(vec1.Added(vec2))); | |
390 | aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2))); | |
7fd59977 | 391 | |
81bba717 | 392 | //Calculate the extremities of the inferior segment of the symbol |
b8ddfc2f | 393 | aPrims->AddBound(2); |
394 | aPrims->AddVertex(pOff.Translated(vec1.Added(vec2.Reversed()))); | |
395 | aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2.Reversed()))); | |
396 | ||
258ff83b | 397 | /*-------------------------------------------------------------------------------------- |
398 | | MARKING OF THE SYMMETRY AXIS | | |
399 | -------------------------------------------------------------------------------------- | |
400 | ____ | |
401 | \ / :Cursor | |
402 | \/ | |
403 | /\ | |
404 | /__\ | |
405 | */ | |
b8ddfc2f | 406 | Standard_Real Dist = (aAxis.Distance(AttachmentPoint1)+aAxis.Distance(AttachmentPoint2))/75; |
7fd59977 | 407 | gp_Vec vs(aDirectionAxis); |
408 | gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ()); | |
7fd59977 | 409 | gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z()); |
410 | ||
b8ddfc2f | 411 | aPrims->AddBound(5); |
7fd59977 | 412 | gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper)); |
b8ddfc2f | 413 | aPrims->AddVertex(pm1); |
7fd59977 | 414 | pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); |
b8ddfc2f | 415 | aPrims->AddVertex(pm1); |
7fd59977 | 416 | pm1 = pm1.Translated(vsymper.Multiplied(2)); |
b8ddfc2f | 417 | aPrims->AddVertex(pm1); |
7fd59977 | 418 | pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); |
b8ddfc2f | 419 | aPrims->AddVertex(pm1); |
7fd59977 | 420 | pm1 = pm1.Translated(vsymper.Multiplied(2)); |
b8ddfc2f | 421 | aPrims->AddVertex(pm1); |
7fd59977 | 422 | |
423 | vsym.Multiply(4); | |
7fd59977 | 424 | |
b8ddfc2f | 425 | aPrims->AddBound(2); |
426 | aPrims->AddVertex(pm.Translated(vsym)); | |
427 | aPrims->AddVertex(pm.Translated(vsym.Reversed())); | |
428 | ||
429 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 430 | } |
431 | ||
432 | //=================================================================== | |
433 | //Function:Add | |
434 | //Purpose: draws the representation of an axial symmetry between two arcs. | |
435 | //=================================================================== | |
436 | void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, | |
437 | const Handle(Prs3d_Drawer)& aDrawer, | |
438 | const gp_Pnt& AttachmentPoint1, | |
439 | const gp_Pnt& AttachmentPoint2, | |
440 | const gp_Circ& aCircle1, | |
441 | const gp_Lin& aAxis, | |
442 | const gp_Pnt& OffsetPoint) | |
443 | { | |
a6eb515f | 444 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
7fd59977 | 445 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
b8ddfc2f | 446 | |
7fd59977 | 447 | gp_Pnt OffsetPnt(OffsetPoint.X(),OffsetPoint.Y(),OffsetPoint.Z()); |
448 | gp_Pnt Center1 = aCircle1.Location(); | |
449 | gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPnt),aAxis); | |
450 | gp_Pnt ProjCenter1 = ElCLib::Value(ElCLib::Parameter(aAxis,Center1),aAxis); | |
451 | gp_Vec Vp(ProjCenter1,Center1); | |
452 | if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(aAxis.Direction())^aCircle1.Position().Direction(); | |
453 | ||
7fd59977 | 454 | Standard_Real Dt,R,h; |
455 | Dt = ProjCenter1.Distance(ProjOffsetPoint); | |
456 | R = aCircle1.Radius(); | |
457 | if (Dt > .999*R) { | |
458 | Dt = .999*R; | |
459 | gp_Vec Vout(ProjCenter1,ProjOffsetPoint); | |
460 | ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt)); | |
461 | OffsetPnt = ProjOffsetPoint; | |
462 | } | |
463 | h = Sqrt(R*R - Dt*Dt); | |
464 | gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h))); | |
465 | gp_Vec v(P1,ProjOffsetPoint); | |
466 | gp_Pnt P2 = ProjOffsetPoint.Translated(v); | |
467 | ||
468 | gp_Lin L3 = gce_MakeLin(P1,P2); | |
469 | Standard_Real parmin,parmax,parcur; | |
470 | parmin = ElCLib::Parameter(L3,P1); | |
471 | parmax = parmin; | |
472 | parcur = ElCLib::Parameter(L3,P2); | |
473 | Standard_Real dist = Abs(parmin-parcur); | |
474 | if (parcur < parmin) parmin = parcur; | |
475 | if (parcur > parmax) parmax = parcur; | |
476 | parcur = ElCLib::Parameter(L3,OffsetPnt); | |
7fd59977 | 477 | |
478 | Standard_Boolean outside = Standard_False; | |
479 | if (parcur < parmin) { | |
480 | parmin = parcur; | |
481 | outside = Standard_True; | |
482 | } | |
483 | if (parcur > parmax) { | |
484 | parmax = parcur; | |
485 | outside = Standard_True; | |
486 | } | |
487 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); | |
488 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); | |
b8ddfc2f | 489 | |
81bba717 | 490 | //==== PROCESSING OF FACE =========== |
b8ddfc2f | 491 | Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(2); |
492 | aPrims->AddVertex(PointMin); | |
493 | aPrims->AddVertex(PointMax); | |
494 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 495 | |
81bba717 | 496 | //==== PROCESSING OF CALL 1 ===== |
7fd59977 | 497 | Standard_Integer nbp = 10; |
7fd59977 | 498 | Standard_Real ParamP1 = ElCLib::Parameter(aCircle1,P1); |
499 | Standard_Real ParamPAttach1 = ElCLib::Parameter(aCircle1,AttachmentPoint1); | |
7fd59977 | 500 | Standard_Real alpha,Dalpha,alphaIter; |
501 | ||
502 | alpha = fabs(ParamP1 - ParamPAttach1); | |
503 | if(ParamP1 < ParamPAttach1){ | |
c6541a0c | 504 | if(alpha > M_PI){ |
b8ddfc2f | 505 | alpha = (2.*M_PI) - alpha; |
7fd59977 | 506 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); |
507 | Dalpha = alpha/(nbp - 1); | |
508 | } | |
509 | else{ | |
510 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); | |
511 | Dalpha = -alpha/(nbp - 1); | |
512 | } | |
513 | } | |
514 | else{ | |
c6541a0c | 515 | if(alpha > M_PI){ |
b8ddfc2f | 516 | alpha = (2.*M_PI) - alpha; |
7fd59977 | 517 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); |
518 | Dalpha = -alpha/(nbp - 1); | |
519 | } | |
520 | else{ | |
521 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); | |
522 | Dalpha = alpha/(nbp - 1); | |
523 | } | |
524 | } | |
525 | ||
b8ddfc2f | 526 | aPrims = new Graphic3d_ArrayOfPolylines(nbp); |
527 | aPrims->AddVertex(AttachmentPoint1); | |
7fd59977 | 528 | alphaIter = Dalpha; |
529 | gp_Pnt PntIter; | |
b8ddfc2f | 530 | Standard_Integer i; |
531 | for(i = 2; i <= nbp; i++, alphaIter += Dalpha) | |
532 | aPrims->AddVertex(ElCLib::Value(ParamPAttach1 + alphaIter,aCircle1)); | |
533 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 534 | |
81bba717 | 535 | //==== PROCESSING OF CALL 2 ===== |
7fd59977 | 536 | gp_Pnt Center2 = ProjCenter1.Translated(Vp.Reversed()); |
7fd59977 | 537 | gp_Dir DirC2 = aCircle1.Axis().Direction(); |
538 | gp_Ax2 AxeC2(Center2,DirC2); | |
539 | gp_Circ aCircle2(AxeC2,aCircle1.Radius()); | |
540 | Standard_Real ParamP2 = ElCLib::Parameter(aCircle2,P2); | |
541 | Standard_Real ParamPAttach2 = ElCLib::Parameter(aCircle2,AttachmentPoint2); | |
542 | ||
543 | alpha = fabs(ParamP2 - ParamPAttach2); | |
544 | if (alpha <= Precision::Confusion()) alpha = 1.e-5; | |
545 | if(ParamP2 < ParamPAttach2){ | |
c6541a0c D |
546 | if(alpha > M_PI){ |
547 | alpha = (2*M_PI) - alpha; | |
7fd59977 | 548 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); |
549 | Dalpha = alpha/(nbp - 1); | |
550 | } | |
551 | else{ | |
552 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); | |
553 | Dalpha = -alpha/(nbp - 1); | |
554 | } | |
555 | } | |
556 | else{ | |
c6541a0c D |
557 | if(alpha > M_PI){ |
558 | alpha = (2*M_PI) - alpha; | |
7fd59977 | 559 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); |
560 | Dalpha = -alpha/(nbp - 1); | |
561 | } | |
562 | else{ | |
563 | nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02)); | |
564 | Dalpha = alpha/(nbp - 1); | |
565 | } | |
566 | } | |
567 | ||
b8ddfc2f | 568 | aPrims = new Graphic3d_ArrayOfPolylines(nbp); |
569 | aPrims->AddVertex(AttachmentPoint2); | |
7fd59977 | 570 | alphaIter = Dalpha; |
b8ddfc2f | 571 | for(i = 2; i <= nbp; i++, alphaIter += Dalpha) |
572 | aPrims->AddVertex(ElCLib::Value(ParamPAttach2 + alphaIter,aCircle2)); | |
573 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
574 | ||
81bba717 | 575 | //==== ARROWS ================ |
7fd59977 | 576 | Prs3d_Root::NewGroup(aPresentation); |
577 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
578 | ||
a6eb515f | 579 | if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; |
7fd59977 | 580 | gp_Dir arrdir = L3.Direction().Reversed(); |
581 | if (outside) arrdir.Reverse(); | |
81bba717 | 582 | // arrow 1 ---- |
4ad142d9 | 583 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), P1, arrdir, LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 | 584 | |
81bba717 | 585 | // arrow 2 ---- |
4ad142d9 | 586 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), P2, arrdir.Reversed(), LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 | 587 | |
81bba717 | 588 | //------------------------------------------------------------------------------------- |
589 | //| SYMBOL OF SYMMETRY | | |
590 | //------------------------------------------------------------------------------------- | |
7fd59977 | 591 | |
81bba717 | 592 | // ------- : Superior Segment |
593 | // ----------- : Axis | |
594 | // ------- : Inferior Segment | |
7fd59977 | 595 | |
596 | gp_Vec Vvar(P1,P2); | |
7fd59977 | 597 | gp_Vec Vtmp = Vvar.Divided(Vvar.Magnitude()).Multiplied(2*(aAxis.Distance(Center1))); |
b8ddfc2f | 598 | gp_Vec vec = Vtmp; |
7fd59977 | 599 | gp_Vec vecA = vec.Multiplied(.1); |
600 | ||
601 | gp_Dir DirAxis = aAxis.Direction(); | |
602 | gp_Vec Vaxe(DirAxis); | |
603 | gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude()); | |
604 | vecB.Multiply(.5); | |
605 | ||
b8ddfc2f | 606 | gp_Pnt pm = P1.Translated(Vvar.Multiplied(.5)); |
607 | gp_Pnt pOff = OffsetPnt.Translated(vecB); | |
7fd59977 | 608 | |
81bba717 | 609 | //Calculation of extremas of the axis of the symbol |
7fd59977 | 610 | gp_Vec vecAxe = vecA.Multiplied(.7); |
b8ddfc2f | 611 | |
7fd59977 | 612 | Prs3d_Root::NewGroup(aPresentation); |
613 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 614 | |
615 | aPrims = new Graphic3d_ArrayOfPolylines(13,5); | |
616 | ||
617 | aPrims->AddBound(2); | |
618 | aPrims->AddVertex(pOff.Translated(vecAxe)); | |
619 | aPrims->AddVertex(pOff.Translated(vecAxe.Reversed())); | |
7fd59977 | 620 | |
81bba717 | 621 | //Calculation of extremas of the superior segment of the symbol |
7fd59977 | 622 | gp_Vec vec1 = vecAxe.Multiplied(.6); |
7fd59977 | 623 | vecAxe = Vaxe.Multiplied(vecAxe.Magnitude()); |
7fd59977 | 624 | gp_Vec vec2 = vecAxe.Multiplied(.4); |
625 | ||
b8ddfc2f | 626 | aPrims->AddBound(2); |
627 | aPrims->AddVertex(pOff.Translated(vec1.Added(vec2))); | |
628 | aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2))); | |
7fd59977 | 629 | |
81bba717 | 630 | //Calculation of extremas of the inferior segment of the symbol |
b8ddfc2f | 631 | aPrims->AddBound(2); |
632 | aPrims->AddVertex(pOff.Translated(vec1.Added(vec2.Reversed()))); | |
633 | aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2.Reversed()))); | |
7fd59977 | 634 | |
258ff83b | 635 | /*-------------------------------------------------------------------------------------- |
636 | | MARKING OF THE AXIS OF SYMMETRY | | |
637 | -------------------------------------------------------------------------------------- | |
638 | ____ | |
639 | \ / :Cursor | |
640 | \/ | |
641 | /\ | |
642 | /__\ | |
643 | */ | |
7fd59977 | 644 | Standard_Real Dist = aAxis.Distance(Center1)/37; |
645 | gp_Dir aDirectionAxis = aAxis.Direction(); | |
646 | gp_Vec vs(aDirectionAxis); | |
647 | gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ()); | |
7fd59977 | 648 | gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z()); |
b8ddfc2f | 649 | |
650 | aPrims->AddBound(5); | |
7fd59977 | 651 | gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper)); |
b8ddfc2f | 652 | aPrims->AddVertex(pm1); |
7fd59977 | 653 | pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); |
b8ddfc2f | 654 | aPrims->AddVertex(pm1); |
7fd59977 | 655 | pm1 = pm1.Translated(vsymper.Multiplied(2)); |
b8ddfc2f | 656 | aPrims->AddVertex(pm1); |
7fd59977 | 657 | pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); |
b8ddfc2f | 658 | aPrims->AddVertex(pm1); |
7fd59977 | 659 | pm1 = pm1.Translated(vsymper.Multiplied(2)); |
b8ddfc2f | 660 | aPrims->AddVertex(pm1); |
7fd59977 | 661 | |
662 | vsym.Multiply(4); | |
7fd59977 | 663 | |
b8ddfc2f | 664 | aPrims->AddBound(2); |
665 | aPrims->AddVertex(pm.Translated(vsym)); | |
666 | aPrims->AddVertex(pm.Translated(vsym.Reversed())); | |
667 | ||
668 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 669 | } |
b8ddfc2f | 670 | |
7fd59977 | 671 | //=================================================================== |
672 | //Function:Add | |
673 | //Purpose: draws the representation of an axial symmetry between two vertex. | |
674 | //=================================================================== | |
675 | void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, | |
676 | const Handle(Prs3d_Drawer)& aDrawer, | |
677 | const gp_Pnt& AttachmentPoint1, | |
678 | const gp_Pnt& AttachmentPoint2, | |
679 | const gp_Lin& aAxis, | |
680 | const gp_Pnt& OffsetPoint) | |
681 | { | |
a6eb515f | 682 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
7fd59977 | 683 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
684 | ||
b8ddfc2f | 685 | if (AttachmentPoint1.IsEqual(AttachmentPoint2,Precision::Confusion())) |
686 | { | |
7fd59977 | 687 | //============================================================== |
81bba717 | 688 | // SYMMETRY WHEN THE REFERENCE POINT IS ON THE AXIS OF SYM.: |
7fd59977 | 689 | //============================================================== |
81bba717 | 690 | //Marker of localisation of the face |
b6472664 | 691 | Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); |
a577aaab | 692 | Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); |
693 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); | |
694 | Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); | |
695 | anArrayOfPoints->AddVertex (AttachmentPoint1.X(), AttachmentPoint1.Y(), AttachmentPoint1.Z()); | |
696 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints); | |
697 | ||
7fd59977 | 698 | |
81bba717 | 699 | //Trace of the linking segment |
7fd59977 | 700 | Prs3d_Root::NewGroup(aPresentation); |
701 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 702 | |
703 | Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(8); | |
704 | ||
705 | aPrims->AddVertex(AttachmentPoint1); | |
706 | aPrims->AddVertex(OffsetPoint); | |
7fd59977 | 707 | |
708 | //-------------------------------------------------------------------------------------- | |
81bba717 | 709 | //| SYMBOL OF SYMMETRY | |
7fd59977 | 710 | //-------------------------------------------------------------------------------------- |
81bba717 | 711 | // ------- : Superior Segment |
712 | // ----------- : Axis | |
713 | // ------- : Inferior Segment | |
7fd59977 | 714 | |
81bba717 | 715 | //Calculate extremas of the axis of the symbol |
7fd59977 | 716 | gp_Vec VAO (AttachmentPoint1,OffsetPoint); |
717 | gp_Vec uVAO = VAO.Divided(VAO.Magnitude()); | |
718 | gp_Pnt pDaxe = OffsetPoint.Translated(uVAO.Multiplied(3.)); | |
719 | gp_Pnt pFaxe = pDaxe.Translated(uVAO.Multiplied(12.)); | |
b8ddfc2f | 720 | |
721 | aPrims->AddVertex(pDaxe); | |
722 | aPrims->AddVertex(pFaxe); | |
7fd59977 | 723 | |
81bba717 | 724 | //Calculate extremas of the superior segment of the symbol |
7fd59977 | 725 | gp_Vec nVAO (-uVAO.Y(),uVAO.X(),uVAO.Z()); |
726 | gp_Pnt sgP11 = pDaxe.Translated(uVAO.Multiplied(2.).Added(nVAO.Multiplied(2.))); | |
727 | gp_Pnt sgP12 = sgP11.Translated(uVAO.Multiplied(8.)); | |
b8ddfc2f | 728 | |
729 | aPrims->AddVertex(sgP11); | |
730 | aPrims->AddVertex(sgP12); | |
7fd59977 | 731 | |
81bba717 | 732 | //Calculate extremas of the inferior segment of the symbol |
7fd59977 | 733 | gp_Vec nVAOr = nVAO.Reversed(); |
734 | gp_Pnt sgP21 = pDaxe.Translated(uVAO.Multiplied(2.).Added(nVAOr.Multiplied(2.))); | |
735 | gp_Pnt sgP22 = sgP21.Translated(uVAO.Multiplied(8.)); | |
b8ddfc2f | 736 | |
737 | aPrims->AddVertex(sgP21); | |
738 | aPrims->AddVertex(sgP22); | |
739 | ||
740 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 741 | } |
742 | //============================================================== | |
81bba717 | 743 | // OTHER CASES : |
7fd59977 | 744 | //============================================================== |
745 | ||
b8ddfc2f | 746 | else { |
7fd59977 | 747 | gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPoint),aAxis); |
748 | gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(aAxis,AttachmentPoint1),aAxis); | |
749 | gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,AttachmentPoint1); | |
750 | gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1); | |
751 | gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed()); | |
b8ddfc2f | 752 | |
7fd59977 | 753 | gp_Lin L3 = gce_MakeLin(P1,P2); |
754 | Standard_Real parmin,parmax,parcur; | |
755 | parmin = ElCLib::Parameter(L3,P1); | |
756 | parmax = parmin; | |
757 | parcur = ElCLib::Parameter(L3,P2); | |
758 | Standard_Real dist = Abs(parmin-parcur); | |
759 | if (parcur < parmin) parmin = parcur; | |
760 | if (parcur > parmax) parmax = parcur; | |
761 | parcur = ElCLib::Parameter(L3,OffsetPoint); | |
7fd59977 | 762 | |
763 | Standard_Boolean outside = Standard_False; | |
764 | if (parcur < parmin) { | |
765 | parmin = parcur; | |
766 | outside = Standard_True; | |
767 | } | |
768 | if (parcur > parmax) { | |
769 | parmax = parcur; | |
770 | outside = Standard_True; | |
771 | } | |
772 | gp_Pnt PointMin = ElCLib::Value(parmin,L3); | |
773 | gp_Pnt PointMax = ElCLib::Value(parmax,L3); | |
b8ddfc2f | 774 | |
81bba717 | 775 | //==== PROCESSING OF FACE =========== |
7fd59977 | 776 | Prs3d_Root::NewGroup(aPresentation); |
777 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 778 | |
779 | Handle(Graphic3d_ArrayOfPrimitives) aPrims = new Graphic3d_ArrayOfSegments(6); | |
780 | ||
781 | aPrims->AddVertex(PointMin); | |
782 | aPrims->AddVertex(PointMax); | |
7fd59977 | 783 | |
81bba717 | 784 | //==== PROCESSING OF CALL 1 ===== |
b8ddfc2f | 785 | aPrims->AddVertex(AttachmentPoint1); |
786 | aPrims->AddVertex(P1); | |
7fd59977 | 787 | |
81bba717 | 788 | //==== PROCESSING OF CALL 2 ===== |
b8ddfc2f | 789 | aPrims->AddVertex(AttachmentPoint2); |
790 | aPrims->AddVertex(P2); | |
791 | ||
792 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); | |
7fd59977 | 793 | |
81bba717 | 794 | //==== ARROWS ================ |
a6eb515f | 795 | if (dist < (LA->ArrowAspect()->Length()+LA->ArrowAspect()->Length())) outside = Standard_True; |
7fd59977 | 796 | gp_Dir arrdir = L3.Direction().Reversed(); |
797 | if (outside) arrdir.Reverse(); | |
81bba717 | 798 | // arrow 1 ---- |
4ad142d9 | 799 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), P1, arrdir, LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 | 800 | |
81bba717 | 801 | // arrow 2 ---- |
4ad142d9 | 802 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), P2, arrdir.Reversed(), LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 | 803 | |
804 | //==== POINTS ================ | |
81bba717 | 805 | //Marker of localization of attachment points: |
7fd59977 | 806 | Prs3d_Root::NewGroup(aPresentation); |
807 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 808 | |
b6472664 | 809 | Quantity_Color aColor = LA->LineAspect()->Aspect()->Color(); |
a577aaab | 810 | Handle(Graphic3d_AspectMarker3d) aMarkerAspAtt = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); |
811 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAspAtt); | |
812 | Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (1); | |
813 | anArrayOfPoints1->AddVertex (AttachmentPoint1.X(), AttachmentPoint1.Y(), AttachmentPoint1.Z()); | |
814 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints1); | |
7fd59977 | 815 | |
816 | Prs3d_Root::NewGroup(aPresentation); | |
817 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
a577aaab | 818 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAspAtt); |
819 | Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints2 = new Graphic3d_ArrayOfPoints (1); | |
820 | anArrayOfPoints2->AddVertex (AttachmentPoint2.X(), AttachmentPoint2.Y(), AttachmentPoint2.Z()); | |
821 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints2); | |
7fd59977 | 822 | |
81bba717 | 823 | //------------------------------------------------------------------------------------- |
824 | //| SYMBOL OF SYMMETRY | | |
825 | //------------------------------------------------------------------------------------- | |
7fd59977 | 826 | |
81bba717 | 827 | // ------- : Superior Segment |
828 | // ----------- : Axis | |
829 | // ------- : Inferior Segment | |
7fd59977 | 830 | |
831 | gp_Vec vec(P1,P2); | |
832 | gp_Vec vecA = vec.Multiplied(.1); | |
833 | ||
834 | gp_Dir DirAxis = aAxis.Direction(); | |
835 | gp_Vec Vaxe(DirAxis); | |
836 | gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude()); | |
837 | vecB.Multiply(.5); | |
838 | ||
b8ddfc2f | 839 | gp_Pnt pm = P1.Translated(vec.Multiplied(.5)); |
840 | gp_Pnt pOff = OffsetPoint.Translated(vecB); | |
7fd59977 | 841 | |
81bba717 | 842 | //Calculate the extremas of the axis of the symbol |
7fd59977 | 843 | gp_Vec vecAxe = vecA.Multiplied(.7); |
b8ddfc2f | 844 | |
7fd59977 | 845 | Prs3d_Root::NewGroup(aPresentation); |
846 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); | |
b8ddfc2f | 847 | |
848 | aPrims = new Graphic3d_ArrayOfPolylines(13,5); | |
849 | ||
850 | aPrims->AddBound(2); | |
851 | aPrims->AddVertex(pOff.Translated(vecAxe)); | |
852 | aPrims->AddVertex(pOff.Translated(vecAxe.Reversed())); | |
853 | ||
81bba717 | 854 | //Calculate the extremas of the superior segment of the symbol |
7fd59977 | 855 | gp_Vec vec1 = vecAxe.Multiplied(.6); |
7fd59977 | 856 | vecAxe = Vaxe.Multiplied(vecAxe.Magnitude()); |
7fd59977 | 857 | gp_Vec vec2 = vecAxe.Multiplied(.4); |
b8ddfc2f | 858 | |
859 | aPrims->AddBound(2); | |
860 | aPrims->AddVertex(pOff.Translated(vec1.Added(vec2))); | |
861 | aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2))); | |
7fd59977 | 862 | |
81bba717 | 863 | //Calculate the extremas of the inferior segment of the symbol |
b8ddfc2f | 864 | aPrims->AddBound(2); |
865 | aPrims->AddVertex(pOff.Translated(vec1.Added(vec2.Reversed()))); | |
866 | aPrims->AddVertex(pOff.Translated(vec1.Reversed().Added(vec2.Reversed()))); | |
867 | ||
258ff83b | 868 | /*-------------------------------------------------------------------------------------- |
869 | | MARKING OF THE AXIS OF SYMMETRY | | |
870 | -------------------------------------------------------------------------------------- | |
871 | ____ | |
872 | \ / :Cursor | |
873 | \/ | |
874 | /\ | |
875 | /__\ | |
876 | */ | |
7fd59977 | 877 | Standard_Real Dist = P1.Distance(P2)/75; |
878 | gp_Dir aDirectionAxis = aAxis.Direction(); | |
879 | gp_Vec vs(aDirectionAxis); | |
880 | gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ()); | |
7fd59977 | 881 | gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z()); |
b8ddfc2f | 882 | |
883 | aPrims->AddBound(5); | |
7fd59977 | 884 | gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper)); |
b8ddfc2f | 885 | aPrims->AddVertex(pm1); |
7fd59977 | 886 | pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); |
b8ddfc2f | 887 | aPrims->AddVertex(pm1); |
7fd59977 | 888 | pm1 = pm1.Translated(vsymper.Multiplied(2)); |
b8ddfc2f | 889 | aPrims->AddVertex(pm1); |
7fd59977 | 890 | pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2))); |
b8ddfc2f | 891 | aPrims->AddVertex(pm1); |
7fd59977 | 892 | pm1 = pm1.Translated(vsymper.Multiplied(2)); |
b8ddfc2f | 893 | aPrims->AddVertex(pm1); |
7fd59977 | 894 | |
b8ddfc2f | 895 | vsym.Multiply(4); |
7fd59977 | 896 | |
b8ddfc2f | 897 | aPrims->AddBound(2); |
898 | aPrims->AddVertex(pm.Translated(vsym)); | |
899 | aPrims->AddVertex(pm.Translated(vsym.Reversed())); | |
7fd59977 | 900 | |
b8ddfc2f | 901 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
902 | } | |
903 | } |