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