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