summaryrefslogtreecommitdiff
path: root/src/AIS/AIS_SymmetricRelation.cxx
blob: 1103f8c12178960b6924e8ba83b48442c246516c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
// File:	AIS_SymmetricRelation.cxx
// Created:	Mon Mar  3 16:17:40 1997
// Author:	Jean-Pierre COMBE
//		<jpr>

#define BUC60915        //GG 05/06/01 Enable to compute the requested arrow size
//                      if any in all dimensions.

#include <Standard_NotImplemented.hxx>

#include <AIS_SymmetricRelation.ixx>
#include <AIS.hxx>
#include <AIS_Drawer.hxx>

#include <gce_MakeLin.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveBox.hxx>
#include <Precision.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <gp_Lin.hxx>
#include <gp_Circ.hxx>
#include <gp_Pnt.hxx>
#include <ElCLib.hxx>
#include <gp_Pln.hxx>
#include <gp_Dir.hxx>
#include <gp_Ax1.hxx>
#include <gp_Ax2.hxx>

#include <Geom_Plane.hxx>
#include <Geom_Line.hxx>
#include <Geom_Circle.hxx>
#include <TopExp_Explorer.hxx>

#include <Precision.hxx>
#include <Prs3d_Drawer.hxx>
#include <Prs3d_ArrowAspect.hxx>
#include <Prs3d_LengthAspect.hxx>

#include <DsgPrs_SymmetricPresentation.hxx>

//=======================================================================
//function : AIS_SymmetricRelation
//purpose  : 
//=======================================================================
AIS_SymmetricRelation::AIS_SymmetricRelation(const TopoDS_Shape& aSymmTool, 
					     const TopoDS_Shape& FirstShape, 
					     const TopoDS_Shape& SecondShape, 
					     const Handle(Geom_Plane)& aPlane)
:AIS_Relation(),
 myTool(aSymmTool)
{
 SetFirstShape(FirstShape);
 SetSecondShape(SecondShape);
 SetPlane(aPlane);
 myPosition = aPlane->Pln().Location();
}

//=======================================================================
//function : Compute
//purpose  : 
//=======================================================================
void AIS_SymmetricRelation::Compute(const Handle(PrsMgr_PresentationManager3d)&, 
				    const Handle(Prs3d_Presentation)& aprs, 
				    const Standard_Integer)
{
  aprs->Clear();

  switch (myFShape.ShapeType()) {
  case TopAbs_FACE :
    {
      // cas symetrie entre deux faces
      ComputeTwoFacesSymmetric(aprs);
    }
    break;
  case TopAbs_EDGE :
    {
      // cas symetrie entre deux edges
      ComputeTwoEdgesSymmetric(aprs);
    }
    break;
  case TopAbs_VERTEX :
    {
      // cas symetrie entre deux vertexs
      ComputeTwoVerticesSymmetric(aprs);
    }
    break;
  default:
    break;
  }
  if (myTool.ShapeType() == TopAbs_EDGE) {
    Handle(Geom_Curve) aCurve,extcurve;
    gp_Pnt p1,p2;
    Standard_Boolean isinfinite,isonplane;
    if (AIS::ComputeGeometry(TopoDS::Edge(myTool),
			     aCurve,p1,p2,
			     extcurve,
			     isinfinite,
			     isonplane,
			     myPlane)) {
      if (!extcurve.IsNull()) { 
	gp_Pnt pf, pl;
	if (!isinfinite) {
	  pf = p1; 
	  pl = p2;
	}
	if (isinfinite) aprs->SetInfiniteState(Standard_True);
	ComputeProjEdgePresentation(aprs,TopoDS::Edge(myTool),aCurve,pf,pl);
      }
    }
  }
}

//=======================================================================
//function : Compute
//purpose  : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)& /*aProjector*/,
				    const Handle(Prs3d_Presentation)& /*aPresentation*/)
{
// Standard_NotImplemented::Raise("AIS_SymmetricRelation::Compute(const Handle(Prs3d_Projector)&,const Handle(Prs3d_Presentation)&)");
// PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
}

//=======================================================================
//function : Compute
//purpose  : to avoid warning at compilation (SUN)
//=======================================================================
void AIS_SymmetricRelation::Compute
  (const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager2d*/,
   const Handle(Graphic2d_GraphicObject)& /*aGraphicObject*/,
   const Standard_Integer /*anInteger*/)
{
// Standard_NotImplemented::Raise("AIS_SymmetricRelation::Compute(const Handle(PrsMgr_PresentationManager2d)&,const Handle(Graphic2d_GraphicObject)&,const Standard_Integer)");
// PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
}

void AIS_SymmetricRelation::Compute(const Handle_Prs3d_Projector& aProjector,
                                    const Handle_Geom_Transformation& aTransformation,
                                    const Handle_Prs3d_Presentation& aPresentation)
{
 Standard_NotImplemented::Raise("AIS_SymmetricRelation::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
}

//=======================================================================
//function : ComputeSelection
//purpose  : 
//=======================================================================
void AIS_SymmetricRelation::ComputeSelection(const Handle(SelectMgr_Selection)& aSel, 
					     const Standard_Integer)
{
  Handle(Select3D_SensitiveSegment) seg;
  Handle(SelectMgr_EntityOwner) own = new SelectMgr_EntityOwner(this,7);
  Standard_Real F,L;

  Handle(Geom_Line) geom_axis,extcurve;
  gp_Pnt p1,p2;
  Standard_Boolean isinfinite,isonplane;
  if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
			    geom_axis,p1,p2,
			    extcurve,
			    isinfinite,
			    isonplane,
			    myPlane)) return;

  gp_Lin laxis (geom_axis->Lin());
  
  if(myFShape.ShapeType() != TopAbs_VERTEX){
    BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
    
    if(cu1.GetType() == GeomAbs_Line) {
//      gp_Lin L1 (myFAttach,myFDirAttach);
      gp_Pnt PjAttachPnt1  = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
      gp_Pnt PjOffSetPnt   = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
      Standard_Real h = fabs(PjOffSetPnt.Distance(PjAttachPnt1)/cos(myAxisDirAttach.Angle(myFDirAttach)));
      gp_Vec VL1(myFDirAttach);
      gp_Vec VLa(PjAttachPnt1,PjOffSetPnt);
      Standard_Real scal = VL1.Dot(VLa);
      if(scal < 0) VL1.Reverse();
      VL1.Multiply(h);
      gp_Pnt P1 = myFAttach.Translated(VL1);
      gp_Pnt ProjAxis = ElCLib::Value(ElCLib::Parameter(laxis,P1),laxis);
      gp_Vec v(P1,ProjAxis);
      gp_Pnt P2 = ProjAxis.Translated(v);
      
      gp_Lin L3;
      
      if (!P1.IsEqual(P2,Precision::Confusion())) {
	L3 = gce_MakeLin(P1,P2);
      }
      else {
	L3 = gce_MakeLin(P1,myFDirAttach);
	Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
	Handle(Select3D_SensitiveBox) box =
	  new Select3D_SensitiveBox(own,
				    myPosition.X(),
				    myPosition.Y(),
				    myPosition.Z(),
				    myPosition.X()+size,
				    myPosition.Y()+size,
				    myPosition.Z()+size);
	aSel->Add(box);
      }
      Standard_Real parmin,parmax,parcur;
      parmin = ElCLib::Parameter(L3,P1);
      parmax = parmin;
      
      parcur = ElCLib::Parameter(L3,P2);
      parmin = Min(parmin,parcur);
      parmax = Max(parmax,parcur);
      
      parcur = ElCLib::Parameter(L3,myPosition);
      parmin = Min(parmin,parcur);
      parmax = Max(parmax,parcur);
      
      gp_Pnt PointMin = ElCLib::Value(parmin,L3);
      gp_Pnt PointMax = ElCLib::Value(parmax,L3);
      
      if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
	seg = new Select3D_SensitiveSegment(own,
					    PointMin,
					    PointMax);
	aSel->Add(seg);
      }
      if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
	seg = new Select3D_SensitiveSegment(own,
					    myFAttach,
					    P1);
	aSel->Add(seg);
      }
      if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
	seg = new Select3D_SensitiveSegment(own,
					    mySAttach,
					    P2);
	aSel->Add(seg);
      }
    }
    
    //=======================Pour les arcs======================    
  if(cu1.GetType() == GeomAbs_Circle) { 
    BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
//    Handle(Geom_Circle) geom_circ1 = (Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
//JR/Hp
    Handle(Geom_Curve) aGeomCurve = BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
    Handle(Geom_Circle) geom_circ1 = (Handle(Geom_Circle)&) aGeomCurve ;
//    Handle(Geom_Circle) geom_circ1 = (const Handle(Geom_Circle)&) BRep_Tool::Curve(TopoDS::Edge(myFShape),F,L);
    gp_Circ circ1(geom_circ1->Circ());
    gp_Pnt OffsetPnt(myPosition.X(),myPosition.Y(),myPosition.Z());
    gp_Pnt Center1 = circ1.Location();
    gp_Pnt ProjOffsetPoint = ElCLib::Value(ElCLib::Parameter(laxis,OffsetPnt),laxis);
    gp_Pnt ProjCenter1     = ElCLib::Value(ElCLib::Parameter(laxis,Center1),laxis);
    gp_Vec Vp(ProjCenter1,Center1);
    if (Vp.Magnitude() <= Precision::Confusion()) Vp = gp_Vec(laxis.Direction())^myPlane->Pln().Position().Direction();
    Standard_Real Dt,R,h;
    Dt = ProjCenter1.Distance(ProjOffsetPoint);
    R  = circ1.Radius();
    if (Dt > .999*R) {
      Dt = .999*R;
      gp_Vec Vout(ProjCenter1,ProjOffsetPoint);
      ProjOffsetPoint = ProjCenter1.Translated(Vout.Divided(Vout.Magnitude()).Multiplied(Dt));
      OffsetPnt = ProjOffsetPoint;
    }
    h  = Sqrt(R*R - Dt*Dt);
    gp_Pnt P1 = ProjOffsetPoint.Translated(Vp.Added(Vp.Divided(Vp.Magnitude()).Multiplied(h)));
    gp_Vec v(P1,ProjOffsetPoint);
    gp_Pnt P2 = ProjOffsetPoint.Translated(v);
    
    gp_Lin L3;
    if (!P1.IsEqual(P2,Precision::Confusion())) {
      L3 = gce_MakeLin(P1,P2);
    }
    else {
      L3 = gce_MakeLin(P1,laxis.Direction());
      Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
      Handle(Select3D_SensitiveBox) box =
	new Select3D_SensitiveBox(own,
				  myPosition.X(),
				  myPosition.Y(),
				  myPosition.Z(),
				  myPosition.X()+size,
				  myPosition.Y()+size,
				  myPosition.Z()+size);
      aSel->Add(box);
    }
    Standard_Real parmin,parmax,parcur;
    parmin = ElCLib::Parameter(L3,P1);
    parmax = parmin;
    
    parcur = ElCLib::Parameter(L3,P2);
    parmin = Min(parmin,parcur);
    parmax = Max(parmax,parcur);
    
    parcur = ElCLib::Parameter(L3,myPosition);
    parmin = Min(parmin,parcur);
    parmax = Max(parmax,parcur);
    
    gp_Pnt PointMin = ElCLib::Value(parmin,L3);
    gp_Pnt PointMax = ElCLib::Value(parmax,L3);
    
    if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
      seg = new Select3D_SensitiveSegment(own,
					  PointMin,
					  PointMax);
      aSel->Add(seg);
    }
  }
  }
  //=======================Pour les points======================
  else {
    if (myFAttach.IsEqual(mySAttach,Precision::Confusion())) {
      seg = new Select3D_SensitiveSegment(own,myPosition,myFAttach);
      aSel->Add(seg);
    }
    else{
      gp_Pnt ProjOffsetPoint      = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
      gp_Pnt ProjAttachmentPoint1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
      gp_Vec PjAtt1_Att1(ProjAttachmentPoint1,myFAttach);
      gp_Pnt P1 = ProjOffsetPoint.Translated(PjAtt1_Att1);
      gp_Pnt P2 = ProjOffsetPoint.Translated(PjAtt1_Att1.Reversed());
      gp_Lin L3;
      
      if (!P1.IsEqual(P2,Precision::Confusion())) {
	L3 = gce_MakeLin(P1,P2);
      }
      else {
	L3 = gce_MakeLin(P1,myFDirAttach);
	Standard_Real size(Min(myVal/100.+1.e-6,myArrowSize+1.e-6));
	Handle(Select3D_SensitiveBox) box =
	  new Select3D_SensitiveBox(own,
				    myPosition.X(),
				    myPosition.Y(),
				    myPosition.Z(),
				    myPosition.X()+size,
				    myPosition.Y()+size,
				    myPosition.Z()+size);
	aSel->Add(box);
      }
      Standard_Real parmin,parmax,parcur;
      parmin = ElCLib::Parameter(L3,P1);
      parmax = parmin;
      
      parcur = ElCLib::Parameter(L3,P2);
      parmin = Min(parmin,parcur);
      parmax = Max(parmax,parcur);
      
      parcur = ElCLib::Parameter(L3,myPosition);
      parmin = Min(parmin,parcur);
      parmax = Max(parmax,parcur);
      
      gp_Pnt PointMin = ElCLib::Value(parmin,L3);
      gp_Pnt PointMax = ElCLib::Value(parmax,L3);
      
      if (!PointMin.IsEqual(PointMax,Precision::Confusion())) {
	seg = new Select3D_SensitiveSegment(own,PointMin,PointMax);
	aSel->Add(seg);
      }
      if (!myFAttach.IsEqual(P1,Precision::Confusion())) {
	seg = new Select3D_SensitiveSegment(own,myFAttach,P1);
	aSel->Add(seg);
      }
      if (!mySAttach.IsEqual(P2,Precision::Confusion())) {
	seg = new Select3D_SensitiveSegment(own,mySAttach,P2);
	aSel->Add(seg);
      }
    }
  }
}

//=======================================================================
//function : ComputeTwoFacesSymmetric
//purpose  : 
//=======================================================================
void AIS_SymmetricRelation::ComputeTwoFacesSymmetric(const Handle(Prs3d_Presentation)&)
{
}

//=======================================================================
//function : ComputeTwoEdgesSymmetric
//purpose  : 
//=======================================================================
void AIS_SymmetricRelation::ComputeTwoEdgesSymmetric(const Handle(Prs3d_Presentation)& aprs)
{
  BRepAdaptor_Curve cu1(TopoDS::Edge(myFShape));
  if (cu1.GetType() != GeomAbs_Line && cu1.GetType() != GeomAbs_Circle) return;
  BRepAdaptor_Curve cu2(TopoDS::Edge(mySShape));
  if (cu2.GetType() != GeomAbs_Line && cu2.GetType() != GeomAbs_Circle) return;
//  gp_Pnt pint3d,ptat11,ptat12,ptat21,ptat22;
  gp_Pnt ptat11,ptat12,ptat21,ptat22;
  Handle(Geom_Curve) geom1,geom2;
  Standard_Boolean isInfinite1,isInfinite2;
  Handle(Geom_Curve) extCurv;
  if (!AIS::ComputeGeometry(TopoDS::Edge(myFShape),
			    TopoDS::Edge(mySShape),
			    myExtShape,
			    geom1,
			    geom2,
			    ptat11,
			    ptat12,
			    ptat21,
			    ptat22,
			    extCurv,
			    isInfinite1,isInfinite2,
			    myPlane)) {
    return;
  } 
  aprs->SetInfiniteState((isInfinite1 || isInfinite2) && (myExtShape !=0));
  Handle(Geom_Line) geom_axis,extcurve;
  gp_Pnt p1,p2;
  Standard_Boolean isinfinite,isonplane;
  if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
			    geom_axis,p1,p2,
			    extcurve,
			    isinfinite,
			    isonplane,
			    myPlane)) return;

  gp_Lin laxis (geom_axis->Lin());
  myAxisDirAttach = laxis.Direction();

  if(cu1.GetType() == GeomAbs_Line){
    const Handle(Geom_Line)& geom_lin1 = (Handle(Geom_Line)&) geom1;
    gp_Lin l1(geom_lin1->Lin());
    myFDirAttach = l1.Direction();
  }
  gp_Circ circ;
  if(cu1.GetType() == GeomAbs_Circle){
    const Handle(Geom_Circle)& geom_cir1 = (Handle(Geom_Circle)&) geom1;
    gp_Circ c(geom_cir1->Circ());
    circ = c;
  }
  
  // recherche points attache
  gp_Pnt ProjOffset = ElCLib::Value(ElCLib::Parameter(laxis,myPosition),laxis);
  
/*//----------------------------------------------------
  //Quand on fait la symetrie de 2 edges consecutifs:
  //              
  //              :<-- Axe
  //              :
  //             /:\
  // Edge n --->/ : \
  //           /  :  \<-- Edge n+1
  //              :
  //----------------------------------------------------
*/
  Standard_Boolean idem = Standard_False;
  if (isInfinite1 && isInfinite2) { // geom1 et geom2 sont des lignes
    const gp_Lin& line2 = ((Handle(Geom_Line)&) geom2)->Lin();
    if (myAutomaticPosition) {
      myFAttach = ((Handle(Geom_Line)&) geom1)->Lin().Location();      
      mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
    }
    else {
      const gp_Lin& line1 = ((Handle(Geom_Line)&) geom1)->Lin();
      myFAttach = ElCLib::Value(ElCLib::Parameter(line1,myPosition),line1);
      mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
    }
  }
  else if (!isInfinite1 && !isInfinite2) {
    if (ptat11.IsEqual(ptat21,Precision::Confusion())) {
      myFAttach = ptat12;
      mySAttach = ptat22;
      idem = Standard_True;
    }
    if (ptat11.IsEqual(ptat22,Precision::Confusion())) {
      myFAttach = ptat12;
      mySAttach = ptat21;
      idem = Standard_True;
    }
    if (ptat12.IsEqual(ptat21,Precision::Confusion())) {
      myFAttach = ptat11;
      mySAttach = ptat22;
      idem = Standard_True;
    }
    if (ptat12.IsEqual(ptat22,Precision::Confusion())) {
      myFAttach = ptat11;
      mySAttach = ptat21;
      idem = Standard_True;
    }
    if(!idem){
      if( ProjOffset.SquareDistance(ptat11) > ProjOffset.SquareDistance(ptat12)) myFAttach = ptat12;
      else myFAttach = ptat11;
      
      if (ProjOffset.SquareDistance(ptat21) > ProjOffset.SquareDistance(ptat22)) mySAttach = ptat22;
      else mySAttach = ptat21;
    }
  }
  else if (isInfinite1) {// geom1 et geom2 sont des lignes
    mySAttach = ptat21;
    const gp_Lin& line1 = ((Handle(Geom_Line)&) geom1)->Lin();
    myFAttach = ElCLib::Value(ElCLib::Parameter(line1,mySAttach),line1);
  }
  else if (isInfinite2) {// geom1 et geom2 sont des lignes
    myFAttach = ptat11;
    const gp_Lin& line2 = ((Handle(Geom_Line)&) geom2)->Lin();
    mySAttach = ElCLib::Value(ElCLib::Parameter(line2,myFAttach),line2);
  }

#ifdef BUC60915
  if( !myArrowSizeIsDefined )
#endif
    myArrowSize = myFAttach.Distance(mySAttach)/50.;
  //----------------------------------------------------
 
  //----------------------------------------------------
  // Si myFAttach <> mySAttach et PjFAttach = myFAttach
  //----------------------------------------------------
  gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); 
 
  if (PjFAttach.IsEqual(myFAttach,Precision::Confusion())){
    const Handle(Geom_Line)& geom_lin2 = (Handle(Geom_Line)&) geom2;
    gp_Lin l2(geom_lin2->Lin());
    myFDirAttach = l2.Direction();
    gp_Pnt PntTempo;
    PntTempo  = myFAttach;
    myFAttach = mySAttach;
    mySAttach = PntTempo;
    PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
  }
  
  //----------------------------------------------------
//  gp_Pnt curpos;

  if (myAutomaticPosition) {    
    //gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); 
    // offset pour eviter confusion Edge et Dimension
    gp_Vec offset(myAxisDirAttach);
    offset = offset * myArrowSize * (-5);
    gp_Vec Vt(myFAttach, PjFAttach);
    gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
    myPosition = curpos;  
  }
  
  gp_Pnt Pj1 = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis);
  gp_Pnt Pj2 = ElCLib::Value(ElCLib::Parameter(laxis,mySAttach),laxis);
  if ((myFAttach.SquareDistance(Pj1)+mySAttach.SquareDistance(Pj2)) <= Precision::Confusion())  myArrowSize = 0.;
  Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
  Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
  arr->SetLength(myArrowSize);
  arr = la->Arrow2Aspect();
  arr->SetLength(myArrowSize);
  if(cu1.GetType() == GeomAbs_Line)
    DsgPrs_SymmetricPresentation::Add(aprs,
				      myDrawer,
				      myFAttach,
				      mySAttach,
				      myFDirAttach,
				      laxis,
				      myPosition);
  
  if(cu1.GetType() == GeomAbs_Circle)
    DsgPrs_SymmetricPresentation::Add(aprs,
				      myDrawer,
				      myFAttach,
				      mySAttach,
				      circ,
				      laxis,
				      myPosition);
  if ( (myExtShape != 0) &&  !extCurv.IsNull()) {
    gp_Pnt pf, pl;
    if ( myExtShape == 1 ) {
      if (!isInfinite1) {
	pf = ptat11; 
	pl = ptat12;
      }
      ComputeProjEdgePresentation(aprs,TopoDS::Edge(myFShape),geom1,pf,pl);
    }
    else {
      if (!isInfinite2) {
	pf = ptat21; 
	pl = ptat22;
      }
      ComputeProjEdgePresentation(aprs,TopoDS::Edge(mySShape),geom2,pf,pl);
    }
  }
}

//=======================================================================
//function : ComputeTwoVertexsSymmetric
//purpose  : 
//=======================================================================
void AIS_SymmetricRelation::ComputeTwoVerticesSymmetric(const Handle(Prs3d_Presentation)& aprs)
{
  if(myFShape.ShapeType() != TopAbs_VERTEX || mySShape.ShapeType() != TopAbs_VERTEX) return;
  Handle(Geom_Line) geom_axis,extcurve;
  gp_Pnt p1,p2;
  Standard_Boolean isinfinite,isonplane;
  if (!AIS::ComputeGeometry(TopoDS::Edge(myTool),
			    geom_axis,p1,p2,
			    extcurve,
			    isinfinite,
			    isonplane,
			    myPlane)) return;

  Standard_Boolean isOnPlane1, isOnPlane2;

  AIS::ComputeGeometry(TopoDS::Vertex(myFShape), myFAttach, myPlane, isOnPlane1);
  AIS::ComputeGeometry(TopoDS::Vertex(mySShape), mySAttach, myPlane, isOnPlane2);

#ifdef BUC60915
  if( !myArrowSizeIsDefined )
#endif
    myArrowSize = myFAttach.Distance(mySAttach)/50.;
  
  if (isOnPlane1 && isOnPlane2)
    myExtShape = 0;
  else if ( isOnPlane1 && !isOnPlane2)
    myExtShape = 2;
  else if (!isOnPlane1 && isOnPlane2)
    myExtShape = 1;
  else
    return ;
  gp_Lin laxis (geom_axis->Lin());
  myAxisDirAttach = laxis.Direction();

  // recherche points attache
//  gp_Pnt curpos;
  if (myAutomaticPosition) {    
    gp_Pnt PjFAttach = ElCLib::Value(ElCLib::Parameter(laxis,myFAttach),laxis); 
    // offset pour eviter confusion Edge et Dimension
    gp_Vec offset(myAxisDirAttach);
    offset = offset * myArrowSize * (-5);
    gp_Vec Vt(myFAttach, PjFAttach);
    gp_Pnt curpos = PjFAttach.Translated(offset.Added(Vt.Multiplied(.15)));
    myPosition = curpos;
  }
  if (2*(myFAttach.Distance(mySAttach)) <= Precision::Confusion()) myArrowSize = 0.;
  Handle(Prs3d_LengthAspect) la = myDrawer->LengthAspect();
  Handle(Prs3d_ArrowAspect) arr = la->Arrow1Aspect();
  arr->SetLength(myArrowSize);
  arr = la->Arrow2Aspect();
  arr->SetLength(myArrowSize);
  DsgPrs_SymmetricPresentation::Add(aprs,
				    myDrawer,
				    myFAttach,
				    mySAttach,
				    laxis,
				    myPosition);
  if ( myExtShape == 1)
    ComputeProjVertexPresentation(aprs,TopoDS::Vertex(myFShape),myFAttach);
  else if ( myExtShape == 2)
    ComputeProjVertexPresentation(aprs,TopoDS::Vertex(mySShape),mySAttach);
}