0030523: Visualization - Highlighting does not work anymore
[occt.git] / src / AIS / AIS_SymmetricRelation.cxx
1 // Created on: 1997-03-03
2 // Created by: Jean-Pierre COMBE
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <AIS.hxx>
19 #include <AIS_SymmetricRelation.hxx>
20 #include <BRep_Tool.hxx>
21 #include <BRepAdaptor_Curve.hxx>
22 #include <BRepAdaptor_Surface.hxx>
23 #include <DsgPrs_SymmetricPresentation.hxx>
24 #include <ElCLib.hxx>
25 #include <gce_MakeLin.hxx>
26 #include <Geom_Circle.hxx>
27 #include <Geom_Line.hxx>
28 #include <Geom_Plane.hxx>
29 #include <Geom_Transformation.hxx>
30 #include <gp_Ax1.hxx>
31 #include <gp_Ax2.hxx>
32 #include <gp_Circ.hxx>
33 #include <gp_Dir.hxx>
34 #include <gp_Lin.hxx>
35 #include <gp_Pln.hxx>
36 #include <gp_Pnt.hxx>
37 #include <Precision.hxx>
38 #include <Prs3d_ArrowAspect.hxx>
39 #include <Prs3d_DimensionAspect.hxx>
40 #include <Prs3d_Drawer.hxx>
41 #include <Prs3d_Presentation.hxx>
42 #include <Prs3d_Projector.hxx>
43 #include <Select3D_SensitiveBox.hxx>
44 #include <Select3D_SensitiveSegment.hxx>
45 #include <SelectMgr_EntityOwner.hxx>
46 #include <SelectMgr_Selection.hxx>
47 #include <Standard_NotImplemented.hxx>
48 #include <Standard_Type.hxx>
49 #include <TopoDS.hxx>
50 #include <TopoDS_Shape.hxx>
51
52 IMPLEMENT_STANDARD_RTTIEXT(AIS_SymmetricRelation,AIS_Relation)
53
54 //=======================================================================
55 //function : AIS_SymmetricRelation
56 //purpose  : 
57 //=======================================================================
58 AIS_SymmetricRelation::AIS_SymmetricRelation(const TopoDS_Shape& aSymmTool, 
59                                              const TopoDS_Shape& FirstShape, 
60                                              const TopoDS_Shape& SecondShape, 
61                                              const Handle(Geom_Plane)& aPlane)
62 :AIS_Relation(),
63  myTool(aSymmTool)
64 {
65  SetFirstShape(FirstShape);
66  SetSecondShape(SecondShape);
67  SetPlane(aPlane);
68  myPosition = aPlane->Pln().Location();
69 }
70
71 //=======================================================================
72 //function : Compute
73 //purpose  : 
74 //=======================================================================
75 void AIS_SymmetricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&, 
76                                     const Handle(Prs3d_Presentation)& aprs, 
77                                     const Standard_Integer)
78 {
79   switch (myFShape.ShapeType()) {
80   case TopAbs_FACE :
81     {
82       // cas symetrie entre deux faces
83       ComputeTwoFacesSymmetric(aprs);
84     }
85     break;
86   case TopAbs_EDGE :
87     {
88       // cas symetrie entre deux edges
89       ComputeTwoEdgesSymmetric(aprs);
90     }
91     break;
92   case TopAbs_VERTEX :
93     {
94       // cas symetrie entre deux vertexs
95       ComputeTwoVerticesSymmetric(aprs);
96     }
97     break;
98   default:
99     break;
100   }
101   if (myTool.ShapeType() == TopAbs_EDGE) {
102     Handle(Geom_Curve) aCurve,extcurve;
103     gp_Pnt p1,p2;
104     Standard_Boolean isinfinite,isonplane;
105     if (AIS::ComputeGeometry(TopoDS::Edge(myTool),
106                              aCurve,p1,p2,
107                              extcurve,
108                              isinfinite,
109                              isonplane,
110                              myPlane)) {
111       if (!extcurve.IsNull()) { 
112         gp_Pnt pf, pl;
113         if (!isinfinite) {
114           pf = p1; 
115           pl = p2;
116         }
117         if (isinfinite) aprs->SetInfiniteState(Standard_True);
118         ComputeProjEdgePresentation(aprs,TopoDS::Edge(myTool),aCurve,pf,pl);
119       }
120     }
121   }
122 }
123
124 //=======================================================================
125 //function : Compute
126 //purpose  : to avoid warning at compilation (SUN)
127 //=======================================================================
128 void AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)& /*aProjector*/,
129                                     const Handle(Prs3d_Presentation)& /*aPresentation*/)
130 {
131 // throw Standard_NotImplemented("AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)");
132 // PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
133 }
134
135 void AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)&,
136                                     const Handle(Geom_Transformation)&,
137                                     const Handle(Prs3d_Presentation)&)
138 {
139  throw Standard_NotImplemented("AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)&, const Handle(Geom_Transformation)&, const Handle(Prs3d_Presentation)&)");
140 // PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
141 }
142
143 //=======================================================================
144 //function : ComputeSelection
145 //purpose  : 
146 //=======================================================================
147 void AIS_SymmetricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel, 
148                                              const Standard_Integer)
149 {
150   Handle(Select3D_SensitiveSegment) seg;
151   Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
152   Standard_Real F,L;
153
154   Handle(Geom_Curve) geom_axis, extcurve;
155   gp_Pnt p1,p2;
156   Standard_Boolean isinfinite,isonplane;
157   if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
158                             geom_axis,p1,p2,
159                             extcurve,
160                             isinfinite,
161                             isonplane,
162                             myPlane)) return;
163
164   Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
165   gp_Lin laxis (geom_line->Lin());
166   
167   if(myFShape.ShapeType() != TopAbs_VERTEX){
168     BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
169     
170     if(cu1.GetType() == GeomAbs_Line) {
171 //      gp_Lin L1 (myFAttach,myFDirAttach);
172       gp_Pnt PjAttachPnt1  = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
173       gp_Pnt PjOffSetPnt   = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
174       Standard_Real h = fabs(PjOffSetPnt.Distance(PjAttachPnt1)/cos(myAxisDirAttach.Angle(myFDirAttach)));
175       gp_Vec VL1(myFDirAttach);
176       gp_Vec VLa(PjAttachPnt1,PjOffSetPnt);
177       Standard_Real scal = VL1.Dot(VLa);
178       if(scal < 0) VL1.Reverse();
179       VL1.Multiply(h);
180       gp_Pnt P1 = myFAttach.Translated(VL1);
181       gp_Pnt ProjAxis = ElCLib::Value(ElCLib::Parameter(laxis,P1),laxis);
182       gp_Vec v(P1,ProjAxis);
183       gp_Pnt P2 = ProjAxis.Translated(v);
184       
185       gp_Lin L3;
186       
187       if (!P1.IsEqual(P2,Precision::Confusion())) {
188         L3 = gce_MakeLin(P1,P2);
189       }
190       else {
191         L3 = gce_MakeLin(P1,myFDirAttach);
192         Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
193         Handle(Select3D_SensitiveBox) box =
194           new Select3D_SensitiveBox(own,
195                                     myPosition.X(),
196                                     myPosition.Y(),
197                                     myPosition.Z(),
198                                     myPosition.X()+size,
199                                     myPosition.Y()+size,
200                                     myPosition.Z()+size);
201         aSel->Add(box);
202       }
203       Standard_Real parmin,parmax,parcur;
204       parmin = ElCLib::Parameter(L3,P1);
205       parmax = parmin;
206       
207       parcur = ElCLib::Parameter(L3,P2);
208       parmin = Min(parmin,parcur);
209       parmax = Max(parmax,parcur);
210       
211       parcur = ElCLib::Parameter(L3,myPosition);
212       parmin = Min(parmin,parcur);
213       parmax = Max(parmax,parcur);
214       
215       gp_Pnt PointMin = ElCLib::Value(parmin,L3);
216       gp_Pnt PointMax = ElCLib::Value(parmax,L3);
217       
218       if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
219         seg = new Select3D_SensitiveSegment(own,
220                                             PointMin,
221                                             PointMax);
222         aSel->Add(seg);
223       }
224       if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
225         seg = new Select3D_SensitiveSegment(own,
226                                             myFAttach,
227                                             P1);
228         aSel->Add(seg);
229       }
230       if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
231         seg = new Select3D_SensitiveSegment(own,
232                                             mySAttach,
233                                             P2);
234         aSel->Add(seg);
235       }
236     }
237     
238     //=======================Pour les arcs======================    
239   if(cu1.GetType() == GeomAbs_Circle) { 
240     Handle(Geom_Curve) aGeomCurve = BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
241     Handle(Geom_Circle) geom_circ1 = Handle(Geom_Circle)::DownCast (aGeomCurve) ;
242 //    Handle(Geom_Circle) geom_circ1 = (const Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
243     gp_Circ circ1(geom_circ1->Circ());
244     gp_Pnt OffsetPnt(myPosition.X(),myPosition.Y(),myPosition.Z());
245     gp_Pnt Center1 = circ1.Location();
246     gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,OffsetPnt),laxis);
247     gp_Pnt ProjCenter1     = ElCLib::Value(ElCLib::Parameter(laxis,Center1),laxis);
248     gp_Vec Vp(ProjCenter1,Center1);
249     if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(laxis.Direction())^myPlane->Pln().Position().Direction();
250     Standard_Real Dt,R,h;
251     Dt = ProjCenter1.Distance(ProjOffsetPoint);
252     R  = circ1.Radius();
253     if (Dt > .999*R) {
254       Dt = .999*R;
255       gp_Vec Vout(ProjCenter1,ProjOffsetPoint);
256       ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt));
257       OffsetPnt = ProjOffsetPoint;
258     }
259     h  = Sqrt(R*R - Dt*Dt);
260     gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h)));
261     gp_Vec v(P1,ProjOffsetPoint);
262     gp_Pnt P2 = ProjOffsetPoint.Translated(v);
263     
264     gp_Lin L3;
265     if (!P1.IsEqual(P2,Precision::Confusion())) {
266       L3 = gce_MakeLin(P1,P2);
267     }
268     else {
269       L3 = gce_MakeLin(P1,laxis.Direction());
270       Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
271       Handle(Select3D_SensitiveBox) box =
272         new Select3D_SensitiveBox(own,
273                                   myPosition.X(),
274                                   myPosition.Y(),
275                                   myPosition.Z(),
276                                   myPosition.X()+size,
277                                   myPosition.Y()+size,
278                                   myPosition.Z()+size);
279       aSel->Add(box);
280     }
281     Standard_Real parmin,parmax,parcur;
282     parmin = ElCLib::Parameter(L3,P1);
283     parmax = parmin;
284     
285     parcur = ElCLib::Parameter(L3,P2);
286     parmin = Min(parmin,parcur);
287     parmax = Max(parmax,parcur);
288     
289     parcur = ElCLib::Parameter(L3,myPosition);
290     parmin = Min(parmin,parcur);
291     parmax = Max(parmax,parcur);
292     
293     gp_Pnt PointMin = ElCLib::Value(parmin,L3);
294     gp_Pnt PointMax = ElCLib::Value(parmax,L3);
295     
296     if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
297       seg = new Select3D_SensitiveSegment(own,
298                                           PointMin,
299                                           PointMax);
300       aSel->Add(seg);
301     }
302   }
303   }
304   //=======================Pour les points======================
305   else {
306     if (myFAttach.IsEqual(mySAttach,Precision::Confusion())) {
307       seg = new Select3D_SensitiveSegment(own,myPosition,myFAttach);
308       aSel->Add(seg);
309     }
310     else{
311       gp_Pnt ProjOffsetPoint      = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
312       gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
313       gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,myFAttach);
314       gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1);
315       gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed());
316       gp_Lin L3;
317       
318       if (!P1.IsEqual(P2,Precision::Confusion())) {
319         L3 = gce_MakeLin(P1,P2);
320       }
321       else {
322         L3 = gce_MakeLin(P1,myFDirAttach);
323         Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
324         Handle(Select3D_SensitiveBox) box =
325           new Select3D_SensitiveBox(own,
326                                     myPosition.X(),
327                                     myPosition.Y(),
328                                     myPosition.Z(),
329                                     myPosition.X()+size,
330                                     myPosition.Y()+size,
331                                     myPosition.Z()+size);
332         aSel->Add(box);
333       }
334       Standard_Real parmin,parmax,parcur;
335       parmin = ElCLib::Parameter(L3,P1);
336       parmax = parmin;
337       
338       parcur = ElCLib::Parameter(L3,P2);
339       parmin = Min(parmin,parcur);
340       parmax = Max(parmax,parcur);
341       
342       parcur = ElCLib::Parameter(L3,myPosition);
343       parmin = Min(parmin,parcur);
344       parmax = Max(parmax,parcur);
345       
346       gp_Pnt PointMin = ElCLib::Value(parmin,L3);
347       gp_Pnt PointMax = ElCLib::Value(parmax,L3);
348       
349       if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
350         seg = new Select3D_SensitiveSegment(own,PointMin,PointMax);
351         aSel->Add(seg);
352       }
353       if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
354         seg = new Select3D_SensitiveSegment(own,myFAttach,P1);
355         aSel->Add(seg);
356       }
357       if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
358         seg = new Select3D_SensitiveSegment(own,mySAttach,P2);
359         aSel->Add(seg);
360       }
361     }
362   }
363 }
364
365 //=======================================================================
366 //function : ComputeTwoFacesSymmetric
367 //purpose  : 
368 //=======================================================================
369 void AIS_SymmetricRelation::ComputeTwoFacesSymmetric(const Handle(Prs3d_Presentation)&)
370 {
371 }
372
373 //=======================================================================
374 //function : ComputeTwoEdgesSymmetric
375 //purpose  : 
376 //=======================================================================
377 void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presentation)& aprs)
378 {
379   BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
380   if (cu1.GetType() != GeomAbs_Line && cu1.GetType() != GeomAbs_Circle) return;
381   BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape));
382   if (cu2.GetType() != GeomAbs_Line && cu2.GetType() != GeomAbs_Circle) return;
383 //  gp_Pnt pint3d,ptat11,ptat12,ptat21,ptat22;
384   gp_Pnt ptat11,ptat12,ptat21,ptat22;
385   Handle(Geom_Curve) geom1,geom2;
386   Standard_Boolean isInfinite1,isInfinite2;
387   Handle(Geom_Curve) extCurv;
388   if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),
389                             TopoDS::Edge(mySShape),
390                             myExtShape,
391                             geom1,
392                             geom2,
393                             ptat11,
394                             ptat12,
395                             ptat21,
396                             ptat22,
397                             extCurv,
398                             isInfinite1,isInfinite2,
399                             myPlane)) {
400     return;
401   } 
402   aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0));
403   Handle(Geom_Curve) geom_axis,extcurve;
404   gp_Pnt p1,p2;
405   Standard_Boolean isinfinite,isonplane;
406   if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
407                             geom_axis,p1,p2,
408                             extcurve,
409                             isinfinite,
410                             isonplane,
411                             myPlane)) return;
412
413   Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
414   gp_Lin laxis (geom_line->Lin());
415   myAxisDirAttach = laxis.Direction();
416
417   if(cu1.GetType() == GeomAbs_Line){
418     Handle(Geom_Line) geom_lin1 (Handle(Geom_Line)::DownCast (geom1));
419     gp_Lin l1(geom_lin1->Lin());
420     myFDirAttach = l1.Direction();
421   }
422   gp_Circ circ;
423   if(cu1.GetType() == GeomAbs_Circle){
424     Handle(Geom_Circle) geom_cir1 (Handle(Geom_Circle)::DownCast (geom1));
425     gp_Circ c(geom_cir1->Circ());
426     circ = c;
427   }
428   
429   // recherche points attache
430   gp_Pnt ProjOffset = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
431   
432 /*//----------------------------------------------------
433   //Quand on fait la symetrie de 2 edges consecutifs:
434   //              
435   //              :<-- Axe
436   //              :
437   //             /:\
438   // Edge n --->/ : \
439   //           /  :  \<-- Edge n+1
440   //              :
441   //----------------------------------------------------
442 */
443   Standard_Boolean idem = Standard_False;
444   if (isInfinite1 && isInfinite2) { // geom1 et geom2 sont des lignes
445     const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin();
446     if (myAutomaticPosition) {
447       myFAttach = Handle(Geom_Line)::DownCast (geom1)->Lin().Location();      
448       mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
449     }
450     else {
451       const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin();
452       myFAttach = ElCLib::Value(ElCLib::Parameter(line1,myPosition),line1);
453       mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
454     }
455   }
456   else if (!isInfinite1 && !isInfinite2) {
457     if (ptat11.IsEqual(ptat21,Precision::Confusion())) {
458       myFAttach = ptat12;
459       mySAttach = ptat22;
460       idem = Standard_True;
461     }
462     if (ptat11.IsEqual(ptat22,Precision::Confusion())) {
463       myFAttach = ptat12;
464       mySAttach = ptat21;
465       idem = Standard_True;
466     }
467     if (ptat12.IsEqual(ptat21,Precision::Confusion())) {
468       myFAttach = ptat11;
469       mySAttach = ptat22;
470       idem = Standard_True;
471     }
472     if (ptat12.IsEqual(ptat22,Precision::Confusion())) {
473       myFAttach = ptat11;
474       mySAttach = ptat21;
475       idem = Standard_True;
476     }
477     if(!idem){
478       if( ProjOffset.SquareDistance(ptat11) > ProjOffset.SquareDistance(ptat12)) myFAttach = ptat12;
479       else myFAttach = ptat11;
480       
481       if (ProjOffset.SquareDistance(ptat21) > ProjOffset.SquareDistance(ptat22)) mySAttach = ptat22;
482       else mySAttach = ptat21;
483     }
484   }
485   else if (isInfinite1) {// geom1 et geom2 sont des lignes
486     mySAttach = ptat21;
487     const gp_Lin& line1 = Handle(Geom_Line)::DownCast (geom1)->Lin();
488     myFAttach = ElCLib::Value(ElCLib::Parameter(line1,mySAttach),line1);
489   }
490   else if (isInfinite2) {// geom1 et geom2 sont des lignes
491     myFAttach = ptat11;
492     const gp_Lin& line2 = Handle(Geom_Line)::DownCast (geom2)->Lin();
493     mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
494   }
495
496   if( !myArrowSizeIsDefined )
497     myArrowSize = myFAttach.Distance(mySAttach)/50.;
498   //----------------------------------------------------
499  
500   //----------------------------------------------------
501   // Si myFAttach <> mySAttach et PjFAttach = myFAttach
502   //----------------------------------------------------
503   gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); 
504  
505   if (PjFAttach.IsEqual(myFAttach,Precision::Confusion())){
506     Handle(Geom_Line) geom_lin2 (Handle(Geom_Line)::DownCast (geom2));
507     gp_Lin l2(geom_lin2->Lin());
508     myFDirAttach = l2.Direction();
509     gp_Pnt PntTempo;
510     PntTempo  = myFAttach;
511     myFAttach = mySAttach;
512     mySAttach = PntTempo;
513     PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
514   }
515   
516   //----------------------------------------------------
517 //  gp_Pnt curpos;
518
519   if (myAutomaticPosition) {    
520     //gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); 
521     // offset pour eviter confusion Edge et Dimension
522     gp_Vec offset(myAxisDirAttach);
523     offset = offset * myArrowSize * (-5);
524     gp_Vec Vt(myFAttach, PjFAttach);
525     gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
526     myPosition = curpos;  
527   }
528   
529   gp_Pnt Pj1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
530   gp_Pnt Pj2 = ElCLib::Value(ElCLib::Parameter(laxis,mySAttach),laxis);
531   if ((myFAttach.SquareDistance(Pj1)+mySAttach.SquareDistance(Pj2)) <= Precision::Confusion())  myArrowSize = 0.;
532   Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
533   Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
534   arr->SetLength(myArrowSize);
535   arr = la->ArrowAspect();
536   arr->SetLength(myArrowSize);
537   if(cu1.GetType() == GeomAbs_Line)
538     DsgPrs_SymmetricPresentation::Add(aprs,
539                                       myDrawer,
540                                       myFAttach,
541                                       mySAttach,
542                                       myFDirAttach,
543                                       laxis,
544                                       myPosition);
545   
546   if(cu1.GetType() == GeomAbs_Circle)
547     DsgPrs_SymmetricPresentation::Add(aprs,
548                                       myDrawer,
549                                       myFAttach,
550                                       mySAttach,
551                                       circ,
552                                       laxis,
553                                       myPosition);
554   if ( (myExtShape != 0) &&  !extCurv.IsNull()) {
555     gp_Pnt pf, pl;
556     if ( myExtShape == 1 ) {
557       if (!isInfinite1) {
558         pf = ptat11; 
559         pl = ptat12;
560       }
561       ComputeProjEdgePresentation(aprs,TopoDS::Edge(myFShape),geom1,pf,pl);
562     }
563     else {
564       if (!isInfinite2) {
565         pf = ptat21; 
566         pl = ptat22;
567       }
568       ComputeProjEdgePresentation(aprs,TopoDS::Edge(mySShape),geom2,pf,pl);
569     }
570   }
571 }
572
573 //=======================================================================
574 //function : ComputeTwoVertexsSymmetric
575 //purpose  : 
576 //=======================================================================
577 void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs)
578 {
579   if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return;
580   Handle(Geom_Curve) geom_axis,extcurve;
581   gp_Pnt p1,p2;
582   Standard_Boolean isinfinite,isonplane;
583   if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
584                             geom_axis,p1,p2,
585                             extcurve,
586                             isinfinite,
587                             isonplane,
588                             myPlane)) return;
589
590   Standard_Boolean isOnPlane1, isOnPlane2;
591
592   AIS::ComputeGeometry(TopoDS::Vertex(myFShape), myFAttach, myPlane, isOnPlane1);
593   AIS::ComputeGeometry(TopoDS::Vertex(mySShape), mySAttach, myPlane, isOnPlane2);
594
595   if( !myArrowSizeIsDefined )
596     myArrowSize = myFAttach.Distance(mySAttach)/50.;
597   
598   if (isOnPlane1 && isOnPlane2)
599     myExtShape = 0;
600   else if ( isOnPlane1 && !isOnPlane2)
601     myExtShape = 2;
602   else if (!isOnPlane1 && isOnPlane2)
603     myExtShape = 1;
604   else
605     return ;
606
607   Handle(Geom_Line) geom_line = Handle(Geom_Line)::DownCast (geom_axis);
608   gp_Lin laxis (geom_line->Lin());
609   myAxisDirAttach = laxis.Direction();
610
611   // recherche points attache
612 //  gp_Pnt curpos;
613   if (myAutomaticPosition) {    
614     gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); 
615     // offset pour eviter confusion Edge et Dimension
616     gp_Vec offset(myAxisDirAttach);
617     offset = offset * myArrowSize * (-5);
618     gp_Vec Vt(myFAttach, PjFAttach);
619     gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
620     myPosition = curpos;
621   }
622   if (2*(myFAttach.Distance(mySAttach)) <= Precision::Confusion()) myArrowSize = 0.;
623   Handle(Prs3d_DimensionAspect) la = myDrawer->DimensionAspect();
624   Handle(Prs3d_ArrowAspect) arr = la->ArrowAspect();
625   arr->SetLength(myArrowSize);
626   arr = la->ArrowAspect();
627   arr->SetLength(myArrowSize);
628   DsgPrs_SymmetricPresentation::Add(aprs,
629                                     myDrawer,
630                                     myFAttach,
631                                     mySAttach,
632                                     laxis,
633                                     myPosition);
634   if ( myExtShape == 1)
635     ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myFShape),myFAttach);
636   else if ( myExtShape == 2)
637     ComputeProjVertexPresentation(aprs,TopoDS::Vertex(mySShape),mySAttach);
638 }
639
640
641
642
643
644