Replacing french comments by english one
[occt.git] / src / DsgPrs / DsgPrs_SymmetricPresentation.cxx
CommitLineData
7fd59977 1// File: DsgPrs_SymmetricPresentation.cxx
2// Created: Wed Jan 22 18:47:51 1997
3// Author: Prestataire Michael ALEONARD
4// <mal>
5
6
7#include <DsgPrs_SymmetricPresentation.ixx>
8
9#include <Precision.hxx>
10
11#include <gp_Lin.hxx>
12#include <gp_Circ.hxx>
13#include <gp_Vec.hxx>
14#include <gp_Dir.hxx>
15#include <gp_Ax1.hxx>
16#include <gp_Ax2.hxx>
17#include <gp_Pnt.hxx>
18#include <gp_Pnt2d.hxx>
19
20#include <Geom_Plane.hxx>
21#include <Geom_Line.hxx>
22
23#include <ElCLib.hxx>
24
25#include <gce_MakeLin.hxx>
26#include <gce_MakeDir.hxx>
27
28#include <Graphic3d_Group.hxx>
29#include <Graphic3d_Array1OfVertex.hxx>
30#include <Graphic3d_AspectLine3d.hxx>
31#include <Graphic3d_AspectMarker3d.hxx>
32#include <Graphic3d_Vertex.hxx>
33
34#include <Prs3d_Arrow.hxx>
35#include <Prs3d_ArrowAspect.hxx>
36#include <Prs3d_LineAspect.hxx>
37#include <Prs3d_LengthAspect.hxx>
38
39#include <TCollection_AsciiString.hxx>
40
41#include <Geom2d_Line.hxx>
42
43#include <GeomAPI.hxx>
44
45#include <IntAna2d_AnaIntersection.hxx>
46
47
48//===================================================================
49//Function:Add
50//Purpose: draws the representation of an axial symmetry between two segments.
51//===================================================================
52void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
53 const Handle(Prs3d_Drawer)& aDrawer,
54 const gp_Pnt& AttachmentPoint1,
55 const gp_Pnt& AttachmentPoint2,
56 const gp_Dir& aDirection1,
57 const gp_Lin& aAxis,
58 const gp_Pnt& OffsetPoint)
59{
60 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
61 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
62 gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPoint),aAxis);
63 gp_Pnt PjAttachPnt1 = ElCLib::Value(ElCLib::Parameter(aAxis,AttachmentPoint1),aAxis);
64 gp_Dir aDirectionAxis = aAxis.Direction();
65// gp_Lin L1 (AttachmentPoint1,aDirection1);
66 Standard_Real h = fabs(ProjOffsetPoint.Distance(PjAttachPnt1)/cos(aDirectionAxis.Angle(aDirection1)));
67
68 gp_Vec VL1(aDirection1);
69 gp_Vec VLa(PjAttachPnt1,ProjOffsetPoint);
70 Standard_Real scal;
71 scal = VL1.Dot(VLa);
72 if (scal < 0) VL1.Reverse();
73 VL1.Multiply(h);
74
75 gp_Pnt P1,P2;
76
77 //===================================
81bba717 78 // SYMETRY OF EDGE PERPEND. TO THE AXIS
7fd59977 79 // ____ : ____
80 // edge2 | : -=- | edge 1
81 // |<------:------>|
82 // :
83 //===================================
84
85 if (VLa.Dot(VL1) == 0) {
86 P1 = AttachmentPoint1.Translated(VLa);
87 gp_Vec VPntat2Axe(PjAttachPnt1,AttachmentPoint2);
88 P2 = ProjOffsetPoint.Translated(VPntat2Axe);
89 }
90 else {
91 P1 = AttachmentPoint1.Translated(VL1);
92 gp_Vec VPntat1Axe(P1,ProjOffsetPoint);
93 P2 = ProjOffsetPoint.Translated(VPntat1Axe);
94 }
95
96 gp_Lin L3 = gce_MakeLin(P1,P2);
97 Standard_Real parmin,parmax,parcur;
98 parmin = ElCLib::Parameter(L3,P1);
99 parmax = parmin;
100 parcur = ElCLib::Parameter(L3,P2);
101 Standard_Real dist = Abs(parmin-parcur);
102 if (parcur < parmin) parmin = parcur;
103 if (parcur > parmax) parmax = parcur;
104 parcur = ElCLib::Parameter(L3,OffsetPoint);
105 gp_Pnt offp = ElCLib::Value(parcur,L3);
106
107 Standard_Boolean outside = Standard_False;
108 if (parcur < parmin) {
109 parmin = parcur;
110 outside = Standard_True;
111 }
112 if (parcur > parmax) {
113 parmax = parcur;
114 outside = Standard_True;
115 }
116
117 gp_Pnt PointMin = ElCLib::Value(parmin,L3);
118 gp_Pnt PointMax = ElCLib::Value(parmax,L3);
119 Graphic3d_Array1OfVertex V(1,2);
120 Graphic3d_Array1OfVertex Vc(1,3);
121 Quantity_Length X,Y,Z;
122 Standard_Real D1,coeff;
123 coeff = .5;
124 D1 = aAxis.Distance(AttachmentPoint1);
125 gp_Pnt pint,Pj_P1,P1Previous;
126 P1Previous.SetX(P1.X());
127 P1Previous.SetY(P1.Y());
128 P1Previous.SetZ(P1.Z());
129
130
131/*//=======================================================
81bba717 132 // TO AVOID CROSSING
133 // P1 -=- P2 P2 -=- P1
134 // \<-->/ |<-->|
135 // \ / | |
136 // \/ | |
137 // /\ | |
138 // / \ | |
139 // Pattach2 /____\ Pattach1 Pattach2 /______\ Pattach1
140 // / NO \ / YES \
7fd59977 141 //=======================================================
142*/
143
144 Standard_Boolean Cross = Standard_False;
145 gp_Vec Attch1_PjAttch1(AttachmentPoint1,PjAttachPnt1);
146 gp_Vec v(P1,ProjOffsetPoint);
147 if (v.IsOpposite((Attch1_PjAttch1),Precision::Confusion())){
148 Cross = Standard_True;
149 gp_Pnt PntTempo;
150 PntTempo = P1;
151 P1 = P2;
152 P2 = PntTempo;
153 }
154/* //===================================
81bba717 155 // FRACTURES OF TRAITS OF CALL
7fd59977 156 // / \
157 // / \
158 // | -=- |
159 // |<------------->|
160 //===================================
161*/
162 gp_Vec Vfix;
163// Standard_Real alpha,b,s,d;
164 Standard_Real alpha,b;
165
166 if(aAxis.Distance(P1) > D1*(1 + coeff) && !Cross){
167
81bba717 168 //==== PROCESSING OF FACE ===========
7fd59977 169 Prs3d_Root::NewGroup(aPresentation);
170 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
171 Pj_P1 = ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis);
172 gp_Vec Vp(Pj_P1,P1);
173 Vfix = Vp.Divided(Vp.Magnitude()).Multiplied(D1*(1 + coeff));
174 Pj_P1.Translated(Vfix).Coord(X,Y,Z);
175 P1.SetCoord(X,Y,Z);
176 Pj_P1.Translated(Vfix.Reversed()).Coord(X,Y,Z);
177 P2.SetCoord(X,Y,Z);
178
179 //=================================
81bba717 180 // LISTING AT THE EXTERIOR
7fd59977 181 // -=-
182 // ->|----------|<------
183 // | |
184 //=================================
185
186 L3 = gce_MakeLin(P1,P2);
187 parmin = ElCLib::Parameter(L3,P1);
188 parmax = parmin;
189 parcur = ElCLib::Parameter(L3,P2);
190 dist = Abs(parmin-parcur);
191 if (parcur < parmin) parmin = parcur;
192 if (parcur > parmax) parmax = parcur;
193 parcur = ElCLib::Parameter(L3,OffsetPoint);
194 offp = ElCLib::Value(parcur,L3);
195 outside = Standard_False;
196 if (parcur < parmin) {
197 parmin = parcur;
198 outside = Standard_True;
199 }
200 if (parcur > parmax) {
201 parmax = parcur;
202 outside = Standard_True;
203 }
204 PointMin = ElCLib::Value(parmin,L3);
205 PointMax = ElCLib::Value(parmax,L3);
206
207 PointMin.Coord(X,Y,Z);
208 V(1).SetCoord(X,Y,Z);
209 PointMax.Coord(X,Y,Z);
210 V(2).SetCoord(X,Y,Z);
211 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
212
81bba717 213 //==== PROCESSING OF CALL 1 =====
7fd59977 214 Prs3d_Root::NewGroup(aPresentation);
215 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
216 AttachmentPoint1.Coord(X,Y,Z);
217 Vc(1).SetCoord(X,Y,Z);
218
219 alpha = aDirectionAxis.Angle(aDirection1);
220 b = (coeff*D1)/sin(alpha);
221 gp_Vec Vpint(AttachmentPoint1,P1Previous);
222 AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)).Coord(X,Y,Z);
223 pint.SetCoord(X,Y,Z);
224
225 pint.Coord(X,Y,Z);
226 Vc(2).SetCoord(X,Y,Z);
227 P1.Coord(X,Y,Z);
228 Vc(3).SetCoord(X,Y,Z);
229 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc);
230
81bba717 231 //==== PROCESSING OF CALL 2 =====
7fd59977 232 Prs3d_Root::NewGroup(aPresentation);
233 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
234 AttachmentPoint2.Coord(X,Y,Z);
235 Vc(1).SetCoord(X,Y,Z);
236 gp_Pnt Pj_pint = ElCLib::Value(ElCLib::Parameter(aAxis,pint),aAxis);
237 gp_Vec V_int(pint, Pj_pint);
238 gp_Pnt Sym_pint;
239 Pj_pint.Translated(V_int).Coord(X,Y,Z);
240 Sym_pint.SetCoord(X,Y,Z);
241
242 Sym_pint.Coord(X,Y,Z);
243 Vc(2).SetCoord(X,Y,Z);
244 P2.Coord(X,Y,Z);
245 Vc(3).SetCoord(X,Y,Z);
246 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc);
247 }
248
249/*//===================================
81bba717 250 // FRACTURES OF PROCESSING OF CALL
7fd59977 251 // -=-
252 // |<--------->|
253 // | |
254 // / \
255 // / \
256 //===================================
257*/
258 else if (aAxis.Distance(P1) < D1*(1 - coeff) || Cross) {
259
81bba717 260 //------ PROCESSING OF FACE ------------
7fd59977 261 Prs3d_Root::NewGroup(aPresentation);
262 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
263 Pj_P1 = ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis);
264 gp_Vec VpInf(Pj_P1,P1);
265 Vfix = VpInf.Divided(VpInf.Magnitude()).Multiplied(D1*(1 - coeff));
266 Pj_P1.Translated(Vfix).Coord(X,Y,Z);
267 P1.SetCoord(X,Y,Z);
268 Pj_P1.Translated(Vfix.Reversed()).Coord(X,Y,Z);
269 P2.SetCoord(X,Y,Z);
270
271 //=================================
81bba717 272 // LISTING AT THE EXTERIOR
7fd59977 273 // -=-
274 // ->|----------|<------
275 // | |
276 //=================================
277 L3 = gce_MakeLin(P1,P2);
278 parmin = ElCLib::Parameter(L3,P1);
279 parmax = parmin;
280 parcur = ElCLib::Parameter(L3,P2);
281 dist = Abs(parmin-parcur);
282 if (parcur < parmin) parmin = parcur;
283 if (parcur > parmax) parmax = parcur;
284 parcur = ElCLib::Parameter(L3,OffsetPoint);
285 offp = ElCLib::Value(parcur,L3);
286 outside = Standard_False;
287 if (parcur < parmin) {
288 parmin = parcur;
289 outside = Standard_True;
290 }
291 if (parcur > parmax) {
292 parmax = parcur;
293 outside = Standard_True;
294 }
295 PointMin = ElCLib::Value(parmin,L3);
296 PointMax = ElCLib::Value(parmax,L3);
297
298 PointMin.Coord(X,Y,Z);
299 V(1).SetCoord(X,Y,Z);
300 PointMax.Coord(X,Y,Z);
301 V(2).SetCoord(X,Y,Z);
302 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
303
81bba717 304 //==== PROCESSING OF CALL 1 =====
7fd59977 305 Prs3d_Root::NewGroup(aPresentation);
306 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
307 AttachmentPoint1.Coord(X,Y,Z);
308 Vc(1).SetCoord(X,Y,Z);
309
310 alpha = aDirectionAxis.Angle(aDirection1);
311 b = (coeff*D1)/sin(alpha);
312 gp_Vec Vpint(AttachmentPoint1,P1Previous);
313 AttachmentPoint1.Translated(Vpint.Divided(Vpint.Magnitude()).Multiplied(b)).Coord(X,Y,Z);
314 pint.SetCoord(X,Y,Z);
315
316 pint.Coord(X,Y,Z);
317 Vc(2).SetCoord(X,Y,Z);
318 P1.Coord(X,Y,Z);
319 Vc(3).SetCoord(X,Y,Z);
320 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc);
321
81bba717 322 //==== PROCESSING OF CALL 2 =====
7fd59977 323 Prs3d_Root::NewGroup(aPresentation);
324 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
325 AttachmentPoint2.Coord(X,Y,Z);
326 Vc(1).SetCoord(X,Y,Z);
327 gp_Pnt Pj_pint = ElCLib::Value(ElCLib::Parameter(aAxis,pint),aAxis);
328 gp_Vec V_int(pint, Pj_pint);
329 gp_Pnt Sym_pint;
330 Pj_pint.Translated(V_int).Coord(X,Y,Z);
331 Sym_pint.SetCoord(X,Y,Z);
332
333 Sym_pint.Coord(X,Y,Z);
334 Vc(2).SetCoord(X,Y,Z);
335 P2.Coord(X,Y,Z);
336 Vc(3).SetCoord(X,Y,Z);
337 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc);
338 }
339 else {
340
81bba717 341 //==== PROCESSING OF FACE ===========
7fd59977 342 Prs3d_Root::NewGroup(aPresentation);
343 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
344 PointMin.Coord(X,Y,Z);
345 V(1).SetCoord(X,Y,Z);
346 PointMax.Coord(X,Y,Z);
347 V(2).SetCoord(X,Y,Z);
348 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
349
81bba717 350 //==== PROCESSING OF CALL 1 =====
7fd59977 351 Prs3d_Root::NewGroup(aPresentation);
352 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
353 AttachmentPoint1.Coord(X,Y,Z);
354 V(1).SetCoord(X,Y,Z);
355 P1.Coord(X,Y,Z);
356 V(2).SetCoord(X,Y,Z);
357 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
358
81bba717 359 //==== PROCESSING OF CALL 2 =====
7fd59977 360 Prs3d_Root::NewGroup(aPresentation);
361 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
362 AttachmentPoint2.Coord(X,Y,Z);
363 V(1).SetCoord(X,Y,Z);
364 P2.Coord(X,Y,Z);
365 V(2).SetCoord(X,Y,Z);
366 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
367 }
368
81bba717 369 //==== ARROWS ================
7fd59977 370 Prs3d_Root::NewGroup(aPresentation);
371 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
372
373 if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True;
374 gp_Dir arrdir = L3.Direction().Reversed();
375 if (outside) arrdir.Reverse();
81bba717 376 // arrow 1 ----
7fd59977 377 Prs3d_Arrow::Draw(aPresentation,P1,arrdir,
378 LA->Arrow1Aspect()->Angle(),
379 LA->Arrow1Aspect()->Length());
380
81bba717 381 // arrow 2 ----
7fd59977 382 Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),
383 LA->Arrow2Aspect()->Angle(),
384 LA->Arrow2Aspect()->Length());
385
81bba717 386 //-------------------------------------------------------------------------------------
387 //| SYMBOL OF SYMMETRY |
388 //-------------------------------------------------------------------------------------
7fd59977 389
81bba717 390 // ------- : Superior Segment
391 // ----------- : Axis
392 // ------- : Inferior Segment
7fd59977 393
394 gp_Vec Vvar(P1,P2);
395 gp_Vec vec;
396 gp_Vec Vtmp = Vvar.Divided(Vvar.Magnitude()).Multiplied((aAxis.Distance(AttachmentPoint1)+
397 aAxis.Distance(AttachmentPoint2)));
398 vec.SetCoord(Vtmp.X(),Vtmp.Y(),Vtmp.Z());
399 gp_Vec vecA = vec.Multiplied(.1);
400
401 gp_Dir DirAxis = aAxis.Direction();
402 gp_Vec Vaxe(DirAxis);
403 gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude());
404 vecB.Multiply(.5);
405
406 gp_Pnt pm,pOff;
407 if (VLa.Dot(VL1) == 0) {
408 gp_Vec Vper(P1,ElCLib::Value(ElCLib::Parameter(aAxis,P1),aAxis));
409 pm = P1.Translated(Vper);
410 }
411 else {
412 pm = P1.Translated(Vvar.Multiplied(.5));
413 }
414 //pm = P1.Translated(Vvar.Multiplied(.5));
415 pOff = OffsetPoint.Translated(vecB);
416
81bba717 417 //Calculate the extremities of the symbol axis
7fd59977 418 gp_Vec vecAxe = vecA.Multiplied(.7);
419 pOff.Translated(vecAxe).Coord(X,Y,Z);
420 V(1).SetCoord(X,Y,Z);
421 pOff.Translated(vecAxe.Reversed()).Coord(X,Y,Z);
422 V(2).SetCoord(X,Y,Z);
423 Prs3d_Root::NewGroup(aPresentation);
424 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
425 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
426
81bba717 427 //Calculate the extremities of the superior segment of the symbol
7fd59977 428 gp_Vec vec1 = vecAxe.Multiplied(.6);
429 vecAxe = Vaxe.Multiplied(vecAxe.Magnitude());
430 gp_Vec vec2 = vecAxe.Multiplied(.4);
431
432 pOff.Translated(vec1.Added(vec2)).Coord(X,Y,Z);
433 V(1).SetCoord(X,Y,Z);
434 pOff.Translated(vec1.Reversed().Added(vec2)).Coord(X,Y,Z);
435 V(2).SetCoord(X,Y,Z);
436 Prs3d_Root::NewGroup(aPresentation);
437 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
438 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
439
81bba717 440 //Calculate the extremities of the inferior segment of the symbol
7fd59977 441 pOff.Translated(vec1.Added(vec2.Reversed())).Coord(X,Y,Z);
442 V(1).SetCoord(X,Y,Z);
443 pOff.Translated(vec1.Reversed().Added(vec2.Reversed())).Coord(X,Y,Z);
444 V(2).SetCoord(X,Y,Z);
445 Prs3d_Root::NewGroup(aPresentation);
446 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
447 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
448
449/*//--------------------------------------------------------------------------------------
81bba717 450 //| MARKING OF THE SYMMETRY AXIS |
7fd59977 451 //--------------------------------------------------------------------------------------
452 // ____
81bba717 453 // \ / :Cursor
7fd59977 454 // \/
455 // /\
456 // /__\
457*/
458
459 Graphic3d_Array1OfVertex cursor(1,5);
460 Standard_Real Dist = (aAxis.Distance(AttachmentPoint1)+
461 aAxis.Distance(AttachmentPoint2))/75;
462 gp_Vec vs(aDirectionAxis);
463 gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ());
464
465 gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z());
466
467 gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper));
468 cursor(1).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
469 pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2)));
470 cursor(2).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
471 pm1 = pm1.Translated(vsymper.Multiplied(2));
472 cursor(3).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
473 pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2)));
474 cursor(4).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
475 pm1 = pm1.Translated(vsymper.Multiplied(2));
476 cursor(5).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
477
478 Prs3d_Root::NewGroup(aPresentation);
479 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
480 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(cursor);
481
482 vsym.Multiply(4);
483 V(1).SetCoord(pm.Translated(vsym).X(),
484 pm.Translated(vsym).Y(),
485 pm.Translated(vsym).Z());
486 V(2).SetCoord(pm.Translated(vsym.Reversed()).X(),
487 pm.Translated(vsym.Reversed()).Y(),
488 pm.Translated(vsym.Reversed()).Z());
489
490 Prs3d_Root::NewGroup(aPresentation);
491 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
492 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
493}
494
495//===================================================================
496//Function:Add
497//Purpose: draws the representation of an axial symmetry between two arcs.
498//===================================================================
499void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
500 const Handle(Prs3d_Drawer)& aDrawer,
501 const gp_Pnt& AttachmentPoint1,
502 const gp_Pnt& AttachmentPoint2,
503 const gp_Circ& aCircle1,
504 const gp_Lin& aAxis,
505 const gp_Pnt& OffsetPoint)
506{
507 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
508 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
509 gp_Pnt OffsetPnt(OffsetPoint.X(),OffsetPoint.Y(),OffsetPoint.Z());
510 gp_Pnt Center1 = aCircle1.Location();
511 gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPnt),aAxis);
512 gp_Pnt ProjCenter1 = ElCLib::Value(ElCLib::Parameter(aAxis,Center1),aAxis);
513 gp_Vec Vp(ProjCenter1,Center1);
514 if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(aAxis.Direction())^aCircle1.Position().Direction();
515
516
517 Standard_Real Dt,R,h;
518 Dt = ProjCenter1.Distance(ProjOffsetPoint);
519 R = aCircle1.Radius();
520 if (Dt > .999*R) {
521 Dt = .999*R;
522 gp_Vec Vout(ProjCenter1,ProjOffsetPoint);
523 ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt));
524 OffsetPnt = ProjOffsetPoint;
525 }
526 h = Sqrt(R*R - Dt*Dt);
527 gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h)));
528 gp_Vec v(P1,ProjOffsetPoint);
529 gp_Pnt P2 = ProjOffsetPoint.Translated(v);
530
531 gp_Lin L3 = gce_MakeLin(P1,P2);
532 Standard_Real parmin,parmax,parcur;
533 parmin = ElCLib::Parameter(L3,P1);
534 parmax = parmin;
535 parcur = ElCLib::Parameter(L3,P2);
536 Standard_Real dist = Abs(parmin-parcur);
537 if (parcur < parmin) parmin = parcur;
538 if (parcur > parmax) parmax = parcur;
539 parcur = ElCLib::Parameter(L3,OffsetPnt);
540#ifdef DEB
541 gp_Pnt offp =
542#endif
543 ElCLib::Value(parcur,L3);
544
545 Standard_Boolean outside = Standard_False;
546 if (parcur < parmin) {
547 parmin = parcur;
548 outside = Standard_True;
549 }
550 if (parcur > parmax) {
551 parmax = parcur;
552 outside = Standard_True;
553 }
554 gp_Pnt PointMin = ElCLib::Value(parmin,L3);
555 gp_Pnt PointMax = ElCLib::Value(parmax,L3);
556 Graphic3d_Array1OfVertex V(1,2);
557 Quantity_Length X,Y,Z;
558
81bba717 559 //==== PROCESSING OF FACE ===========
7fd59977 560 Prs3d_Root::NewGroup(aPresentation);
561 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
562 PointMin.Coord(X,Y,Z);
563 V(1).SetCoord(X,Y,Z);
564 PointMax.Coord(X,Y,Z);
565 V(2).SetCoord(X,Y,Z);
566 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
567
81bba717 568 //==== PROCESSING OF CALL 1 =====
7fd59977 569 Standard_Integer nbp = 10;
570 Prs3d_Root::NewGroup(aPresentation);
571 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
572 Standard_Real ParamP1 = ElCLib::Parameter(aCircle1,P1);
573 Standard_Real ParamPAttach1 = ElCLib::Parameter(aCircle1,AttachmentPoint1);
574// gp_Vec Center1_PAttach1(Center1,AttachmentPoint1);
575// gp_Vec Center1_P1(Center1,P1);
576 Standard_Real alpha,Dalpha,alphaIter;
577
578 alpha = fabs(ParamP1 - ParamPAttach1);
579 if(ParamP1 < ParamPAttach1){
580 if(alpha > PI){
581 alpha = (2*PI) - alpha;
582 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
583 Dalpha = alpha/(nbp - 1);
584 }
585 else{
586 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
587 Dalpha = -alpha/(nbp - 1);
588 }
589 }
590 else{
591 if(alpha > PI){
592 alpha = (2*PI) - alpha;
593 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
594 Dalpha = -alpha/(nbp - 1);
595 }
596 else{
597 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
598 Dalpha = alpha/(nbp - 1);
599 }
600 }
601
602 Graphic3d_Array1OfVertex Vc1(1,nbp);
603 AttachmentPoint1.Coord(X,Y,Z);
604 Vc1(1).SetCoord(X,Y,Z);
605 alphaIter = Dalpha;
606 gp_Pnt PntIter;
607 Standard_Integer i ;
608 for( i = 2; i <= nbp; i++){
609 PntIter = ElCLib::Value(ParamPAttach1 + alphaIter,aCircle1);
610 alphaIter = alphaIter + Dalpha;
611 PntIter.Coord(X,Y,Z);
612 Vc1(i).SetCoord(X,Y,Z);
613
614 }
615 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc1);
616
81bba717 617 //==== PROCESSING OF CALL 2 =====
7fd59977 618 Prs3d_Root::NewGroup(aPresentation);
619 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
620 gp_Pnt Center2 = ProjCenter1.Translated(Vp.Reversed());
621// gp_Vec Center2_PAttach2(Center2,AttachmentPoint2);
622// gp_Vec Center2_P2(Center2,P2);
623
624 gp_Dir DirC2 = aCircle1.Axis().Direction();
625 gp_Ax2 AxeC2(Center2,DirC2);
626 gp_Circ aCircle2(AxeC2,aCircle1.Radius());
627 Standard_Real ParamP2 = ElCLib::Parameter(aCircle2,P2);
628 Standard_Real ParamPAttach2 = ElCLib::Parameter(aCircle2,AttachmentPoint2);
629
630 alpha = fabs(ParamP2 - ParamPAttach2);
631 if (alpha <= Precision::Confusion()) alpha = 1.e-5;
632 if(ParamP2 < ParamPAttach2){
633 if(alpha > PI){
634 alpha = (2*PI) - alpha;
635 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
636 Dalpha = alpha/(nbp - 1);
637 }
638 else{
639 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
640 Dalpha = -alpha/(nbp - 1);
641 }
642 }
643 else{
644 if(alpha > PI){
645 alpha = (2*PI) - alpha;
646 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
647 Dalpha = -alpha/(nbp - 1);
648 }
649 else{
650 nbp = (Standard_Integer ) IntegerPart(alpha/(alpha*.02));
651 Dalpha = alpha/(nbp - 1);
652 }
653 }
654
655 Graphic3d_Array1OfVertex Vc2(1,nbp);
656 AttachmentPoint2.Coord(X,Y,Z);
657 Vc2(1).SetCoord(X,Y,Z);
658 alphaIter = Dalpha;
659 for(i = 2; i <= nbp; i++){
660 PntIter = ElCLib::Value(ParamPAttach2 + alphaIter,aCircle2);
661 alphaIter = alphaIter + Dalpha;
662 PntIter.Coord(X,Y,Z);
663 Vc2(i).SetCoord(X,Y,Z);
664 }
665 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vc2);
666
81bba717 667 //==== ARROWS ================
7fd59977 668 Prs3d_Root::NewGroup(aPresentation);
669 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
670
671 if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True;
672 gp_Dir arrdir = L3.Direction().Reversed();
673 if (outside) arrdir.Reverse();
81bba717 674 // arrow 1 ----
7fd59977 675 Prs3d_Arrow::Draw(aPresentation,P1,arrdir,
676 LA->Arrow1Aspect()->Angle(),
677 LA->Arrow1Aspect()->Length());
678
81bba717 679 // arrow 2 ----
7fd59977 680 Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),
681 LA->Arrow2Aspect()->Angle(),
682 LA->Arrow2Aspect()->Length());
683
81bba717 684 //-------------------------------------------------------------------------------------
685 //| SYMBOL OF SYMMETRY |
686 //-------------------------------------------------------------------------------------
7fd59977 687
81bba717 688 // ------- : Superior Segment
689 // ----------- : Axis
690 // ------- : Inferior Segment
7fd59977 691
692 gp_Vec Vvar(P1,P2);
693 gp_Vec vec;
694 gp_Vec Vtmp = Vvar.Divided(Vvar.Magnitude()).Multiplied(2*(aAxis.Distance(Center1)));
695 vec.SetCoord(Vtmp.X(),Vtmp.Y(),Vtmp.Z());
696 gp_Vec vecA = vec.Multiplied(.1);
697
698 gp_Dir DirAxis = aAxis.Direction();
699 gp_Vec Vaxe(DirAxis);
700 gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude());
701 vecB.Multiply(.5);
702
703 //gp_Vec vecB(-vec.Y(),vec.X(),vec.Z());
704 //vecB.Multiply(.05);
705 gp_Pnt pm,pOff;
706 pm = P1.Translated(Vvar.Multiplied(.5));
707 pOff = OffsetPnt.Translated(vecB);
708
81bba717 709 //Calculation of extremas of the axis of the symbol
7fd59977 710 gp_Vec vecAxe = vecA.Multiplied(.7);
711 pOff.Translated(vecAxe).Coord(X,Y,Z);
712 V(1).SetCoord(X,Y,Z);
713 pOff.Translated(vecAxe.Reversed()).Coord(X,Y,Z);
714 V(2).SetCoord(X,Y,Z);
715 Prs3d_Root::NewGroup(aPresentation);
716 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
717 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
718
81bba717 719 //Calculation of extremas of the superior segment of the symbol
7fd59977 720 gp_Vec vec1 = vecAxe.Multiplied(.6);
721
722 vecAxe = Vaxe.Multiplied(vecAxe.Magnitude());
723 //vecAxe.SetCoord(-vecAxe.Y(),vecAxe.X(),vecAxe.Z());
724
725 gp_Vec vec2 = vecAxe.Multiplied(.4);
726
727 pOff.Translated(vec1.Added(vec2)).Coord(X,Y,Z);
728 V(1).SetCoord(X,Y,Z);
729 pOff.Translated(vec1.Reversed().Added(vec2)).Coord(X,Y,Z);
730 V(2).SetCoord(X,Y,Z);
731 Prs3d_Root::NewGroup(aPresentation);
732 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
733 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
734
81bba717 735 //Calculation of extremas of the inferior segment of the symbol
7fd59977 736 pOff.Translated(vec1.Added(vec2.Reversed())).Coord(X,Y,Z);
737 V(1).SetCoord(X,Y,Z);
738 pOff.Translated(vec1.Reversed().Added(vec2.Reversed())).Coord(X,Y,Z);
739 V(2).SetCoord(X,Y,Z);
740 Prs3d_Root::NewGroup(aPresentation);
741 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
742 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
743
744/*//--------------------------------------------------------------------------------------
81bba717 745 //| MARKING OF THE AXIS OF SYMMETRY |
7fd59977 746 //--------------------------------------------------------------------------------------
747 // ____
81bba717 748 // \ / :Cursor
7fd59977 749 // \/
750 // /\
751 // /__\
752*/
753
754 Graphic3d_Array1OfVertex cursor(1,5);
755 //Standard_Real Dist = aCircle1.Radius()/37;
756 Standard_Real Dist = aAxis.Distance(Center1)/37;
757 gp_Dir aDirectionAxis = aAxis.Direction();
758 gp_Vec vs(aDirectionAxis);
759 gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ());
760
761 gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z());
762 gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper));
763 cursor(1).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
764 pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2)));
765 cursor(2).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
766 pm1 = pm1.Translated(vsymper.Multiplied(2));
767 cursor(3).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
768 pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2)));
769 cursor(4).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
770 pm1 = pm1.Translated(vsymper.Multiplied(2));
771 cursor(5).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
772
773 Prs3d_Root::NewGroup(aPresentation);
774 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
775 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(cursor);
776
777 vsym.Multiply(4);
778 V(1).SetCoord(pm.Translated(vsym).X(),
779 pm.Translated(vsym).Y(),
780 pm.Translated(vsym).Z());
781 V(2).SetCoord(pm.Translated(vsym.Reversed()).X(),
782 pm.Translated(vsym.Reversed()).Y(),
783 pm.Translated(vsym.Reversed()).Z());
784
785 Prs3d_Root::NewGroup(aPresentation);
786 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
787 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
788}
789
790//===================================================================
791//Function:Add
792//Purpose: draws the representation of an axial symmetry between two vertex.
793//===================================================================
794void DsgPrs_SymmetricPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
795 const Handle(Prs3d_Drawer)& aDrawer,
796 const gp_Pnt& AttachmentPoint1,
797 const gp_Pnt& AttachmentPoint2,
798 const gp_Lin& aAxis,
799 const gp_Pnt& OffsetPoint)
800{
801 Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
802 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
803
804 if (AttachmentPoint1.IsEqual(AttachmentPoint2,Precision::Confusion())){
805 //==============================================================
81bba717 806 // SYMMETRY WHEN THE REFERENCE POINT IS ON THE AXIS OF SYM.:
7fd59977 807 //==============================================================
81bba717 808 //Marker of localisation of the face
7fd59977 809 Handle(Graphic3d_AspectMarker3d) MarkerAsp = new Graphic3d_AspectMarker3d();
810 MarkerAsp->SetType(Aspect_TOM_BALL);
811 MarkerAsp->SetScale(0.8);
812 Quantity_Color acolor;
813 Aspect_TypeOfLine atype;
814 Standard_Real awidth;
815 LA->LineAspect()->Aspect()->Values(acolor, atype, awidth);
816 MarkerAsp->SetColor(acolor);
817 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAsp);
818 Graphic3d_Vertex V3d(AttachmentPoint1.X(),
819 AttachmentPoint1.Y(),
820 AttachmentPoint1.Z());
821 Prs3d_Root::CurrentGroup(aPresentation)->Marker(V3d);
822
81bba717 823 //Trace of the linking segment
7fd59977 824 Prs3d_Root::NewGroup(aPresentation);
825 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
826 Graphic3d_Array1OfVertex Vrac(1,2);
827 Vrac(1).SetCoord(AttachmentPoint1.X(),
828 AttachmentPoint1.Y(),
829 AttachmentPoint1.Z());
830 Vrac(2).SetCoord(OffsetPoint.X(),
831 OffsetPoint.Y(),
832 OffsetPoint.Z());
833 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac);
834
835 //--------------------------------------------------------------------------------------
81bba717 836 //| SYMBOL OF SYMMETRY |
7fd59977 837 //--------------------------------------------------------------------------------------
81bba717 838 // ------- : Superior Segment
839 // ----------- : Axis
840 // ------- : Inferior Segment
7fd59977 841
81bba717 842 //Calculate extremas of the axis of the symbol
7fd59977 843 gp_Vec VAO (AttachmentPoint1,OffsetPoint);
844 gp_Vec uVAO = VAO.Divided(VAO.Magnitude());
845 gp_Pnt pDaxe = OffsetPoint.Translated(uVAO.Multiplied(3.));
846 gp_Pnt pFaxe = pDaxe.Translated(uVAO.Multiplied(12.));
847 Vrac(1).SetCoord(pDaxe.X(),pDaxe.Y(),pDaxe.Z());
848 Vrac(2).SetCoord(pFaxe.X(),pFaxe.Y(),pFaxe.Z());
849 Prs3d_Root::NewGroup(aPresentation);
850 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
851 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac);
852
81bba717 853 //Calculate extremas of the superior segment of the symbol
7fd59977 854 gp_Vec nVAO (-uVAO.Y(),uVAO.X(),uVAO.Z());
855 gp_Pnt sgP11 = pDaxe.Translated(uVAO.Multiplied(2.).Added(nVAO.Multiplied(2.)));
856 gp_Pnt sgP12 = sgP11.Translated(uVAO.Multiplied(8.));
857 Vrac(1).SetCoord(sgP11.X(),sgP11.Y(),sgP11.Z());
858 Vrac(2).SetCoord(sgP12.X(),sgP12.Y(),sgP12.Z());
859 Prs3d_Root::NewGroup(aPresentation);
860 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
861 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac);
862
81bba717 863 //Calculate extremas of the inferior segment of the symbol
7fd59977 864 gp_Vec nVAOr = nVAO.Reversed();
865 gp_Pnt sgP21 = pDaxe.Translated(uVAO.Multiplied(2.).Added(nVAOr.Multiplied(2.)));
866 gp_Pnt sgP22 = sgP21.Translated(uVAO.Multiplied(8.));
867 Vrac(1).SetCoord(sgP21.X(),sgP21.Y(),sgP21.Z());
868 Vrac(2).SetCoord(sgP22.X(),sgP22.Y(),sgP22.Z());
869 Prs3d_Root::NewGroup(aPresentation);
870 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
871 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(Vrac);
872 }
873 //==============================================================
81bba717 874 // OTHER CASES :
7fd59977 875 //==============================================================
876
877 else{
878 gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(aAxis,OffsetPoint),aAxis);
879 gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(aAxis,AttachmentPoint1),aAxis);
880 gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,AttachmentPoint1);
881 gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1);
882 gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed());
883
884 gp_Lin L3 = gce_MakeLin(P1,P2);
885 Standard_Real parmin,parmax,parcur;
886 parmin = ElCLib::Parameter(L3,P1);
887 parmax = parmin;
888 parcur = ElCLib::Parameter(L3,P2);
889 Standard_Real dist = Abs(parmin-parcur);
890 if (parcur < parmin) parmin = parcur;
891 if (parcur > parmax) parmax = parcur;
892 parcur = ElCLib::Parameter(L3,OffsetPoint);
893#ifdef DEB
894 gp_Pnt offp =
895#endif
896 ElCLib::Value(parcur,L3);
897
898 Standard_Boolean outside = Standard_False;
899 if (parcur < parmin) {
900 parmin = parcur;
901 outside = Standard_True;
902 }
903 if (parcur > parmax) {
904 parmax = parcur;
905 outside = Standard_True;
906 }
907 gp_Pnt PointMin = ElCLib::Value(parmin,L3);
908 gp_Pnt PointMax = ElCLib::Value(parmax,L3);
909 Graphic3d_Array1OfVertex V(1,2);
910 Quantity_Length X,Y,Z;
911
81bba717 912 //==== PROCESSING OF FACE ===========
7fd59977 913 Prs3d_Root::NewGroup(aPresentation);
914 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
915 PointMin.Coord(X,Y,Z);
916 V(1).SetCoord(X,Y,Z);
917 PointMax.Coord(X,Y,Z);
918 V(2).SetCoord(X,Y,Z);
919 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
920
81bba717 921 //==== PROCESSING OF CALL 1 =====
7fd59977 922 Prs3d_Root::NewGroup(aPresentation);
923 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
924 AttachmentPoint1.Coord(X,Y,Z);
925 V(1).SetCoord(X,Y,Z);
926 P1.Coord(X,Y,Z);
927 V(2).SetCoord(X,Y,Z);
928 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
929
81bba717 930 //==== PROCESSING OF CALL 2 =====
7fd59977 931 Prs3d_Root::NewGroup(aPresentation);
932 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
933 AttachmentPoint2.Coord(X,Y,Z);
934 V(1).SetCoord(X,Y,Z);
935 P2.Coord(X,Y,Z);
936 V(2).SetCoord(X,Y,Z);
937 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
938
81bba717 939 //==== ARROWS ================
7fd59977 940 Prs3d_Root::NewGroup(aPresentation);
941 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
942
943 if (dist < (LA->Arrow1Aspect()->Length()+LA->Arrow2Aspect()->Length())) outside = Standard_True;
944 gp_Dir arrdir = L3.Direction().Reversed();
945 if (outside) arrdir.Reverse();
81bba717 946 // arrow 1 ----
7fd59977 947 Prs3d_Arrow::Draw(aPresentation,P1,arrdir,
948 LA->Arrow1Aspect()->Angle(),
949 LA->Arrow1Aspect()->Length());
950
81bba717 951 // arrow 2 ----
7fd59977 952 Prs3d_Arrow::Draw(aPresentation,P2,arrdir.Reversed(),
953 LA->Arrow2Aspect()->Angle(),
954 LA->Arrow2Aspect()->Length());
955
956 //==== POINTS ================
81bba717 957 //Marker of localization of attachment points:
7fd59977 958 Prs3d_Root::NewGroup(aPresentation);
959 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
960 Handle(Graphic3d_AspectMarker3d) MarkerAspAtt = new Graphic3d_AspectMarker3d();
961 MarkerAspAtt->SetType(Aspect_TOM_BALL);
962 MarkerAspAtt->SetScale(0.8);
963 Quantity_Color color;
964 Aspect_TypeOfLine type;
965 Standard_Real width;
966 LA->LineAspect()->Aspect()->Values(color, type, width);
967 MarkerAspAtt->SetColor(color);
968 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAspAtt);
969 Graphic3d_Vertex Vatt1(AttachmentPoint1.X(),
970 AttachmentPoint1.Y(),
971 AttachmentPoint1.Z());
972 Prs3d_Root::CurrentGroup(aPresentation)->Marker(Vatt1);
973
974 Prs3d_Root::NewGroup(aPresentation);
975 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
976 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(MarkerAspAtt);
977 Graphic3d_Vertex Vatt2(AttachmentPoint2.X(),
978 AttachmentPoint2.Y(),
979 AttachmentPoint2.Z());
980 Prs3d_Root::CurrentGroup(aPresentation)->Marker(Vatt2);
981
81bba717 982 //-------------------------------------------------------------------------------------
983 //| SYMBOL OF SYMMETRY |
984 //-------------------------------------------------------------------------------------
7fd59977 985
81bba717 986 // ------- : Superior Segment
987 // ----------- : Axis
988 // ------- : Inferior Segment
7fd59977 989
990 gp_Vec vec(P1,P2);
991 gp_Vec vecA = vec.Multiplied(.1);
992
993 gp_Dir DirAxis = aAxis.Direction();
994 gp_Vec Vaxe(DirAxis);
995 gp_Vec vecB = Vaxe.Multiplied(vecA.Magnitude());
996 vecB.Multiply(.5);
997
998 //gp_Vec vecB(-vec.Y(),vec.X(),vec.Z());
999 //vecB.Multiply(.05);
1000
1001 gp_Pnt pm,pOff;
1002 pm = P1.Translated(vec.Multiplied(.5));
1003 pOff = OffsetPoint.Translated(vecB);
1004
81bba717 1005 //Calculate the extremas of the axis of the symbol
7fd59977 1006 gp_Vec vecAxe = vecA.Multiplied(.7);
1007 pOff.Translated(vecAxe).Coord(X,Y,Z);
1008 V(1).SetCoord(X,Y,Z);
1009 pOff.Translated(vecAxe.Reversed()).Coord(X,Y,Z);
1010 V(2).SetCoord(X,Y,Z);
1011 Prs3d_Root::NewGroup(aPresentation);
1012 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
1013 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
1014
81bba717 1015 //Calculate the extremas of the superior segment of the symbol
7fd59977 1016 gp_Vec vec1 = vecAxe.Multiplied(.6);
1017
1018 vecAxe = Vaxe.Multiplied(vecAxe.Magnitude());
1019
1020 //vecAxe.SetCoord(-vecAxe.Y(),vecAxe.X(),vecAxe.Z());
1021 gp_Vec vec2 = vecAxe.Multiplied(.4);
1022
1023 pOff.Translated(vec1.Added(vec2)).Coord(X,Y,Z);
1024 V(1).SetCoord(X,Y,Z);
1025 pOff.Translated(vec1.Reversed().Added(vec2)).Coord(X,Y,Z);
1026 V(2).SetCoord(X,Y,Z);
1027 Prs3d_Root::NewGroup(aPresentation);
1028 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
1029 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
1030
81bba717 1031 //Calculate the extremas of the inferior segment of the symbol
7fd59977 1032 pOff.Translated(vec1.Added(vec2.Reversed())).Coord(X,Y,Z);
1033 V(1).SetCoord(X,Y,Z);
1034 pOff.Translated(vec1.Reversed().Added(vec2.Reversed())).Coord(X,Y,Z);
1035 V(2).SetCoord(X,Y,Z);
1036 Prs3d_Root::NewGroup(aPresentation);
1037 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
1038 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
1039
1040/* //--------------------------------------------------------------------------------------
81bba717 1041 //| MARKING OF THE AXIS OF SYMMETRY |
7fd59977 1042 //--------------------------------------------------------------------------------------
1043 // ____
81bba717 1044 // \ / :Cursor
7fd59977 1045 // \/
1046 // /\
1047 // /__\
1048*/
1049
1050 Graphic3d_Array1OfVertex cursor(1,5);
1051 Standard_Real Dist = P1.Distance(P2)/75;
1052 gp_Dir aDirectionAxis = aAxis.Direction();
1053 gp_Vec vs(aDirectionAxis);
1054 gp_Vec vsym(vs.Divided(vs.Magnitude()).Multiplied(Dist).XYZ());
1055
1056 gp_Vec vsymper(vsym.Y(),-vsym.X(),vsym.Z());
1057 gp_Pnt pm1 = pm.Translated(vsym.Added(vsymper));
1058 cursor(1).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
1059 pm1 = pm1.Translated(vsym.Reversed().Multiplied(2).Added(vsymper.Reversed().Multiplied(2)));
1060 cursor(2).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
1061 pm1 = pm1.Translated(vsymper.Multiplied(2));
1062 cursor(3).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
1063 pm1 = pm1.Translated(vsym.Multiplied(2).Added(vsymper.Reversed().Multiplied(2)));
1064 cursor(4).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
1065 pm1 = pm1.Translated(vsymper.Multiplied(2));
1066 cursor(5).SetCoord(pm1.X(),pm1.Y(),pm1.Z());
1067
1068 Prs3d_Root::NewGroup(aPresentation);
1069 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
1070 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(cursor);
1071
1072 vsym.Multiply(4);
1073 V(1).SetCoord(pm.Translated(vsym).X(),
1074 pm.Translated(vsym).Y(),
1075 pm.Translated(vsym).Z());
1076 V(2).SetCoord(pm.Translated(vsym.Reversed()).X(),
1077 pm.Translated(vsym.Reversed()).Y(),
1078 pm.Translated(vsym.Reversed()).Z());
1079
1080 Prs3d_Root::NewGroup(aPresentation);
1081 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
1082 Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
1083 }
1084}
1085
1086
1087
1088
1089
1090
1091
1092
1093