0022972: Eliminate macro definitions that has compiler-provided analogs (WNT and...
[occt.git] / src / DsgPrs / DsgPrs.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15
42cf5bc1 16#include <Aspect_AspectMarker.hxx>
7fd59977 17#include <Aspect_TypeOfLine.hxx>
18#include <Aspect_TypeOfMarker.hxx>
42cf5bc1 19#include <DsgPrs.hxx>
7fd59977 20#include <ElCLib.hxx>
42cf5bc1 21#include <gce_MakeLin.hxx>
7fd59977 22#include <Geom_Circle.hxx>
42cf5bc1 23#include <Geom_Curve.hxx>
24#include <Geom_Line.hxx>
25#include <Geom_Surface.hxx>
7fd59977 26#include <GeomAPI_ExtremaCurveCurve.hxx>
7fd59977 27#include <GeomAPI_ProjectPointOnCurve.hxx>
42cf5bc1 28#include <GeomAPI_ProjectPointOnSurf.hxx>
29#include <gp_Ax1.hxx>
30#include <gp_Circ.hxx>
31#include <gp_Dir.hxx>
32#include <gp_Elips.hxx>
33#include <gp_Pln.hxx>
34#include <gp_Pnt.hxx>
35#include <gp_Vec.hxx>
36#include <Graphic3d_ArrayOfPoints.hxx>
37#include <Graphic3d_AspectLine3d.hxx>
38#include <Graphic3d_AspectMarker3d.hxx>
39#include <Graphic3d_Group.hxx>
40#include <Graphic3d_Vertex.hxx>
41#include <Precision.hxx>
42#include <Prs3d_Arrow.hxx>
43#include <Prs3d_ArrowAspect.hxx>
44#include <Prs3d_DimensionAspect.hxx>
45#include <Prs3d_LineAspect.hxx>
46#include <Prs3d_Presentation.hxx>
47#include <Prs3d_Root.hxx>
48#include <Quantity_Color.hxx>
49#include <TCollection_AsciiString.hxx>
50#include <TCollection_ExtendedString.hxx>
7fd59977 51
7fd59977 52void DsgPrs::ComputeSymbol (const Handle(Prs3d_Presentation)& aPresentation,
a6eb515f 53 const Handle(Prs3d_DimensionAspect)& LA,
7fd59977 54 const gp_Pnt& pt1,
55 const gp_Pnt& pt2,
56 const gp_Dir& dir1,
57 const gp_Dir& dir2,
a6eb515f 58 const DsgPrs_ArrowSide ArrowSide,
59 const Standard_Boolean drawFromCenter)
7fd59977 60{
61 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
a577aaab 62
63 Quantity_Color aColor;
64 Aspect_TypeOfLine aType;
65 Standard_Real aWidth;
66 LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth);
67 Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0);
68 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp);
a6eb515f 69 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
7fd59977 70
71 switch(ArrowSide) {
72 case DsgPrs_AS_NONE:
73 {
74 break;
75 }
76 case DsgPrs_AS_FIRSTAR:
77 {
78
79 Prs3d_Arrow::Draw(aPresentation,
80 pt1,
81 dir1,
82 LA->ArrowAspect()->Angle(),
83 LA->ArrowAspect()->Length());
84 break;
85 }
86 case DsgPrs_AS_LASTAR:
87 {
88
89 Prs3d_Arrow::Draw(aPresentation,
90 pt2,
91 dir2,
92 LA->ArrowAspect()->Angle(),
93 LA->ArrowAspect()->Length());
94 break;
95 }
96
97 case DsgPrs_AS_BOTHAR:
98 {
99 Prs3d_Arrow::Draw(aPresentation,
100 pt1,
101 dir1,
102 LA->ArrowAspect()->Angle(),
103 LA->ArrowAspect()->Length());
104 Prs3d_Arrow::Draw(aPresentation,
105 pt2,
106 dir2,
107 LA->ArrowAspect()->Angle(),
108 LA->ArrowAspect()->Length());
109
110 break;
111 }
112
113 case DsgPrs_AS_FIRSTPT:
114 {
a6eb515f 115 if(drawFromCenter)
a577aaab 116 {
117 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
118 anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
119 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
120 }
7fd59977 121 break;
122 }
123
124 case DsgPrs_AS_LASTPT:
125 {
126 // On dessine un rond
a577aaab 127 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
128 anArrayOfPoints->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
129 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
7fd59977 130 break;
131 }
132
133 case DsgPrs_AS_BOTHPT:
134 {
a6eb515f 135 if(drawFromCenter)
a577aaab 136 {
137 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints1 = new Graphic3d_ArrayOfPoints (1);
138 anArrayOfPoints1->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
139 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints1);
140 }
a6eb515f 141 if(drawFromCenter)
142 {
143 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints2 = new Graphic3d_ArrayOfPoints (1);
144 anArrayOfPoints2->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
145 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints2);
146 }
7fd59977 147 break;
148 }
149
150 case DsgPrs_AS_FIRSTAR_LASTPT:
151 {
152 // an Arrow
a6eb515f 153 Prs3d_Arrow::Draw(aPresentation,
154 pt1,
155 dir1,
156 LA->ArrowAspect()->Angle(),
157 LA->ArrowAspect()->Length());
7fd59977 158 // a Round
a577aaab 159 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
160 anArrayOfPoints->AddVertex (pt2.X(), pt2.Y(), pt2.Z());
161 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
7fd59977 162 break;
163 }
164
165 case DsgPrs_AS_FIRSTPT_LASTAR:
166 {
167 // a Round
a6eb515f 168 if(drawFromCenter)
a577aaab 169 {
170 Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1);
171 anArrayOfPoints->AddVertex (pt1.X(), pt1.Y(), pt1.Z());
172 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints);
173 }
7fd59977 174 // an Arrow
a6eb515f 175 Prs3d_Arrow::Draw(aPresentation,
176 pt2,
177 dir2,
178 LA->ArrowAspect()->Angle(),
179 LA->ArrowAspect()->Length());
7fd59977 180 break;
181 }
182 }
183}
184
185
186//=======================================================================
187//function : ComputePlanarFacesLengthPresentation
188//purpose :
189//=======================================================================
190
191void DsgPrs::ComputePlanarFacesLengthPresentation( const Standard_Real FirstArrowLength,
192 const Standard_Real SecondArrowLength,
193 const gp_Pnt& AttachmentPoint1,
194 const gp_Pnt& AttachmentPoint2,
195 const gp_Dir& DirAttach,
196 const gp_Pnt& OffsetPoint,
197 const gp_Pln& PlaneOfFaces,
198 gp_Pnt & EndOfArrow1,
199 gp_Pnt & EndOfArrow2,
200 gp_Dir & DirOfArrow1 )
201{
202 gp_Lin FirstLin( AttachmentPoint1, DirAttach );
203 gp_Lin SecondLin( AttachmentPoint2, DirAttach );
204
205 EndOfArrow1 = ElCLib::Value( ElCLib::Parameter( FirstLin, OffsetPoint ), FirstLin );
206 EndOfArrow2 = ElCLib::Value( ElCLib::Parameter( SecondLin, OffsetPoint ), SecondLin );
207
08cd2f6b 208 if (EndOfArrow1.SquareDistance( EndOfArrow2 ) > Precision::SquareConfusion()) // not null length
7fd59977 209 {
210 gp_Dir LengthDir( gp_Vec( EndOfArrow1, EndOfArrow2 ) );
211 if ((FirstArrowLength + SecondArrowLength)*(FirstArrowLength + SecondArrowLength) <
212 EndOfArrow1.SquareDistance( EndOfArrow2 ))
213 DirOfArrow1 = -LengthDir;
214 else
215 DirOfArrow1 = LengthDir;
216 }
217 else // null length
218 DirOfArrow1 = PlaneOfFaces.Axis().Direction();
219}
220
221//=======================================================================
222//function : ComputeCurvilinearFacesLengthPresentation
223//purpose :
224//=======================================================================
225
226void DsgPrs::ComputeCurvilinearFacesLengthPresentation( const Standard_Real FirstArrowLength,
227 const Standard_Real SecondArrowLength,
228 const Handle( Geom_Surface )& SecondSurf,
229 const gp_Pnt& AttachmentPoint1,
230 const gp_Pnt& AttachmentPoint2,
231 const gp_Dir& DirAttach,
232 gp_Pnt & EndOfArrow2,
233 gp_Dir & DirOfArrow1,
234 Handle( Geom_Curve )& VCurve,
235 Handle( Geom_Curve )& UCurve,
236 Standard_Real & FirstU,
237 Standard_Real & deltaU,
238 Standard_Real & FirstV,
239 Standard_Real & deltaV )
240{
241 GeomAPI_ProjectPointOnSurf ProjectorOnSurface;
242 GeomAPI_ProjectPointOnCurve ProjectorOnCurve;
243 Quantity_Parameter U1, V1, U2, V2;
244 Standard_Real LastU, LastV;
08cd2f6b 245 Standard_Real SquareTolerance = Precision::SquareConfusion();
7fd59977 246
247 ProjectorOnSurface.Init( AttachmentPoint1, SecondSurf );
248 Standard_Integer Index(1);
249 Quantity_Length MinDist = RealLast();
250 Quantity_Parameter LocalU, LocalV;
251 gp_Vec D1U, D1V;
252 gp_Dir LocalDir;
253 for (Standard_Integer i = 1; i <= ProjectorOnSurface.NbPoints(); i++)
254 {
255 ProjectorOnSurface.Parameters( i, LocalU, LocalV );
256
257 SecondSurf->D1( LocalU, LocalV, EndOfArrow2, D1U, D1V );
258 if (D1U.SquareMagnitude() <= SquareTolerance || D1V.SquareMagnitude() <= SquareTolerance)
259 LocalDir = gp_Dir( gp_Vec( AttachmentPoint1, ProjectorOnSurface.Point( i ) ) );
260 else
261 LocalDir = gp_Dir( D1U ^ D1V );
262 if (DirAttach.IsParallel( LocalDir, Precision::Angular() ) && ProjectorOnSurface.Distance( i ) < MinDist)
263 {
264 Index = i;
265 MinDist = ProjectorOnSurface.Distance( i );
266 }
267 }
268 EndOfArrow2 = ProjectorOnSurface.Point( Index );
269 ProjectorOnSurface.Parameters( Index, U1, V1 );
270
271 if ((FirstArrowLength + SecondArrowLength)*(FirstArrowLength + SecondArrowLength) <
272 AttachmentPoint1.SquareDistance( EndOfArrow2 ))
273 DirOfArrow1 = -DirAttach;
274 else
275 DirOfArrow1 = DirAttach;
276
08cd2f6b 277 if (EndOfArrow2.SquareDistance( AttachmentPoint2 ) > Precision::SquareConfusion())
7fd59977 278 {
279 VCurve = SecondSurf->VIso( V1 );
280 ProjectorOnCurve.Init( EndOfArrow2, VCurve );
281 FirstU = ProjectorOnCurve.LowerDistanceParameter();
282
283 ProjectorOnSurface.Init( AttachmentPoint2, SecondSurf );
284 ProjectorOnSurface.LowerDistanceParameters( U2, V2 );
285 UCurve = SecondSurf->UIso( U2 );
286
287 ProjectorOnCurve.Init( AttachmentPoint2, UCurve );
288 LastV = ProjectorOnCurve.LowerDistanceParameter();
289
290 gp_Pnt Intersection = SecondSurf->Value( U2, V1 );
291 ProjectorOnCurve.Init( Intersection, VCurve );
292 LastU = ProjectorOnCurve.LowerDistanceParameter();
293 ProjectorOnCurve.Init( Intersection, UCurve );
294 FirstV = ProjectorOnCurve.LowerDistanceParameter();
295
296 deltaU = LastU - FirstU;
297 deltaV = LastV - FirstV;
298
299 if (VCurve->IsPeriodic() && Abs( deltaU ) > VCurve->Period()/2)
300 {
301 Standard_Real Sign = (deltaU > 0.0)? -1.0 : 1.0;
302 deltaU = VCurve->Period() - Abs( deltaU );
303 deltaU *= Sign;
304 }
305 if (UCurve->IsPeriodic() && Abs( deltaV ) > UCurve->Period()/2)
306 {
307 Standard_Real Sign = (deltaV > 0.0)? -1.0 : 1.0;
308 deltaV = UCurve->Period() - Abs( deltaV );
309 deltaV *= Sign;
310 }
311 }
312}
313
314
315//=======================================================================
316//function : ComputeFacesAnglePresentation
317//purpose :
318//=======================================================================
319
320void DsgPrs::ComputeFacesAnglePresentation( const Standard_Real ArrowLength,
321 const Standard_Real Value,
322 const gp_Pnt& CenterPoint,
323 const gp_Pnt& AttachmentPoint1,
324 const gp_Pnt& AttachmentPoint2,
325 const gp_Dir& dir1,
326 const gp_Dir& dir2,
327 const gp_Dir& axisdir,
328 const Standard_Boolean isPlane,
329 const gp_Ax1& AxisOfSurf,
330 const gp_Pnt& OffsetPoint,
331 gp_Circ & AngleCirc,
332 Standard_Real & FirstParAngleCirc,
333 Standard_Real & LastParAngleCirc,
334 gp_Pnt & EndOfArrow1,
335 gp_Pnt & EndOfArrow2,
336 gp_Dir & DirOfArrow1,
337 gp_Dir & DirOfArrow2,
338 gp_Pnt & ProjAttachPoint2,
339 gp_Circ & AttachCirc,
340 Standard_Real & FirstParAttachCirc,
341 Standard_Real & LastParAttachCirc )
342{
c6541a0c 343 if (Value > Precision::Angular() && Abs( M_PI-Value ) > Precision::Angular())
7fd59977 344 {
345 // Computing presentation of angle's arc
346 gp_Ax2 ax( CenterPoint, axisdir, dir1 );
347 AngleCirc.SetPosition( ax );
348 AngleCirc.SetRadius( CenterPoint.Distance( OffsetPoint ) );
349 gp_Vec vec1( dir1 );
350 vec1 *= AngleCirc.Radius();
351 gp_Pnt p1 = CenterPoint.Translated( vec1 );
352 gp_Vec vec2( dir2 );
353 vec2 *= AngleCirc.Radius();
354 gp_Pnt p2 = CenterPoint.Translated( vec2 );
355
356 Standard_Real Par1 = 0.;
357 Standard_Real Par2 = ElCLib::Parameter( AngleCirc, p2 );
358 Standard_Real Par0 = ElCLib::Parameter( AngleCirc, OffsetPoint );
359
360 gp_Vec PosVec( CenterPoint, OffsetPoint );
361 gp_Vec NormalOfPlane = vec1 ^ vec2;
362
363 gp_Vec Normal1 = NormalOfPlane ^ vec1;
364 gp_Vec Normal2 = NormalOfPlane ^ vec2;
365 Standard_Integer Sign1 = (PosVec * Normal1 >= 0)? 1 : -1;
366 Standard_Integer Sign2 = (PosVec * Normal2 >= 0)? 1 : -1;
367 if (Sign1 == 1 && Sign2 == -1)
368 {
369 FirstParAngleCirc = Par1;
370 LastParAngleCirc = Par2;
371 }
372 else if (Sign1 == 1 && Sign2 == 1)
373 {
374 FirstParAngleCirc = Par1;
375 LastParAngleCirc = Par0;
376 }
377 else if (Sign1 == -1 && Sign2 == 1)
378 {
c6541a0c
D
379 Par1 += M_PI;
380 Par2 += M_PI;
7fd59977 381 FirstParAngleCirc = Par1;
382 LastParAngleCirc = Par2;
383 }
384 else //Sign1 == -1 && Sign2 == -1
385 {
386 AngleCirc.SetPosition( gp_Ax2( CenterPoint, axisdir, gp_Dir( PosVec ) ) );
387 Par0 = 0.;
388 Par1 = ElCLib::Parameter( AngleCirc, p1 );
389 Par2 = ElCLib::Parameter( AngleCirc, p2 );
390 FirstParAngleCirc = Par0;
391 LastParAngleCirc = Par2;
392 }
393
394 // Computing presentation of arrows
395 EndOfArrow1 = ElCLib::Value( Par1, AngleCirc );
396 EndOfArrow2 = ElCLib::Value( Par2, AngleCirc );
397 Standard_Real beta = 0.;
398 if (AngleCirc.Radius() > Precision::Confusion())
399 beta = ArrowLength / AngleCirc.Radius();
400 gp_Pnt OriginOfArrow1 = ElCLib::Value( Par1 + beta, AngleCirc );
401 gp_Pnt OriginOfArrow2 = ElCLib::Value( Par2 - beta, AngleCirc );
402 DirOfArrow1 = gp_Dir( gp_Vec( OriginOfArrow1, EndOfArrow1 ) );
403 DirOfArrow2 = gp_Dir( gp_Vec( OriginOfArrow2, EndOfArrow2 ) );
404 if (EndOfArrow1.SquareDistance( EndOfArrow2 ) <= (ArrowLength + ArrowLength)*(ArrowLength + ArrowLength))
405 {
406 DirOfArrow1.Reverse();
407 DirOfArrow2.Reverse();
408 }
409 }
410 else // dir1 and dir2 are parallel
411 {
412 gp_Dir ArrowDir = axisdir ^ dir1;
413 DirOfArrow1 = ArrowDir;
414 DirOfArrow2 = -ArrowDir;
415 gp_Lin DirLine( AttachmentPoint1, dir1 );
416 EndOfArrow1 = ElCLib::Value( ElCLib::Parameter( DirLine, OffsetPoint ), DirLine );
417 EndOfArrow2 = EndOfArrow1;
418 }
419
420 // Line or arc from AttachmentPoint2 to its "projection"
421 gp_Lin SecondLin( CenterPoint, dir2 );
422 if (SecondLin.Contains( AttachmentPoint2, Precision::Confusion() ))
423 ProjAttachPoint2 = AttachmentPoint2;
424 else
425 {
426 if (isPlane)
427 ProjAttachPoint2 = ElCLib::Value( ElCLib::Parameter( SecondLin, AttachmentPoint2 ), SecondLin );
428 else
429 {
430 gp_Lin LineOfAxis( AxisOfSurf );
431 gp_Pnt CenterOfArc = ElCLib::Value( ElCLib::Parameter( LineOfAxis, AttachmentPoint2 ),
432 LineOfAxis );
433
434 gp_Ax2 Ax2( CenterOfArc,
435 AxisOfSurf.Direction(),
436 gp_Dir( gp_Vec( CenterOfArc, AttachmentPoint2 ) ) );
437 AttachCirc.SetPosition( Ax2 );
438 AttachCirc.SetRadius( CenterOfArc.Distance( AttachmentPoint2 ) );
439
440 GeomAPI_ExtremaCurveCurve Intersection( new Geom_Circle( AttachCirc ),
441 new Geom_Line( SecondLin ) );
442 Intersection.NearestPoints( ProjAttachPoint2, ProjAttachPoint2 );
443
444 Standard_Real U2 = ElCLib::Parameter( AttachCirc, ProjAttachPoint2 );
c6541a0c 445 if (U2 <= M_PI)
7fd59977 446 {
447 FirstParAttachCirc = 0;
448 LastParAttachCirc = U2;
449 }
450 else
451 {
452 FirstParAttachCirc = U2;
c6541a0c 453 LastParAttachCirc = 2*M_PI;
7fd59977 454 }
455 }
456 }
457}
458
459
460
35e08fe8 461void DsgPrs::ComputeFilletRadiusPresentation( const Standard_Real /*ArrowLength*/,
7fd59977 462 const Standard_Real Value,
463 const gp_Pnt & Position,
464 const gp_Dir & NormalDir,
465 const gp_Pnt & FirstPoint,
466 const gp_Pnt & SecondPoint,
467 const gp_Pnt & Center,
468 const gp_Pnt & BasePnt,
469 const Standard_Boolean drawRevers,
470 Standard_Boolean & SpecCase,
471 gp_Circ & FilletCirc,
472 Standard_Real & FirstParCirc,
473 Standard_Real & LastParCirc,
474 gp_Pnt & EndOfArrow,
475 gp_Dir & DirOfArrow,
476 gp_Pnt & DrawPosition)
477{
478 gp_Dir dir1(gp_Vec(Center, FirstPoint));
479 gp_Dir dir2(gp_Vec(Center, SecondPoint));
480 Standard_Real Angle = dir1.Angle(dir2);
c6541a0c 481 if(Angle <= Precision::Angular() || ( M_PI - Angle ) <= Precision::Angular() ||
7fd59977 482 Value <= Precision::Confusion()) SpecCase = Standard_True;
483 else SpecCase = Standard_False;
484 if ( !SpecCase )
485 {
486 // Computing presentation of fillet's arc
487 gp_Ax2 ax( Center, NormalDir, dir1 );
488 FilletCirc.SetPosition( ax );
489 FilletCirc.SetRadius( Center.Distance( FirstPoint ) ); //***
490 gp_Vec vec1( dir1 );
491 vec1 *= FilletCirc.Radius();
0797d9d3 492#ifdef OCCT_DEBUG
7fd59977 493 gp_Pnt p1 =
494#endif
495 Center.Translated( vec1 );
496 gp_Vec vec2( dir2 );
497 vec2 *= FilletCirc.Radius();
0797d9d3 498#ifdef OCCT_DEBUG
7fd59977 499 gp_Pnt p2 =
500#endif
501 Center.Translated( vec2 );
502 gp_Vec PosVec;
503 if(! Center.IsEqual( Position, Precision::Confusion() ))
504 PosVec.SetXYZ( gp_Vec(Center, Position).XYZ() );
505 else
506 PosVec.SetXYZ( (vec1.Added(vec2)).XYZ() );
507 gp_Vec NormalOfPlane = vec1 ^ vec2;
508 gp_Vec Normal1 = NormalOfPlane ^ vec1;
509 gp_Vec Normal2 = NormalOfPlane ^ vec2;
510 Standard_Integer Sign1 = (PosVec * Normal1 >= 0)? 1 : -1;
511 Standard_Integer Sign2 = (PosVec * Normal2 >= 0)? 1 : -1;
512 gp_Lin L1( Center, dir1 );
513 gp_Lin L2( Center, dir2 );
514 if ( Sign1 != Sign2 )
515 {
516 DrawPosition = Position; //***
517 gp_Dir direction(PosVec) ;
518 Standard_Real angle = dir1.Angle(direction) ;
519 if (( dir1 ^ direction) * NormalDir < 0.0e0) angle = -angle ;
c6541a0c 520 if(Sign1 == -1) angle += M_PI;
7fd59977 521 EndOfArrow = ElCLib::Value(angle, FilletCirc); //***
522
523 }
524 else
525 {
526 if(L1.Distance(Position) < L2.Distance(Position))
527 {
528 EndOfArrow = FirstPoint; //***
529 DrawPosition = ElCLib::Value(ElCLib::Parameter(L1, Position), L1);
530 }
531 else
532 {
533 EndOfArrow = SecondPoint; //***
534 DrawPosition = ElCLib::Value(ElCLib::Parameter(L2, Position), L2);
535 }
536 }
537 if((dir1^dir2).IsOpposite(NormalDir, Precision::Angular()))
538 {
539 gp_Dir newdir = NormalDir.Reversed() ;
540 gp_Ax2 axnew( Center, newdir, dir1 );
541 FilletCirc.SetPosition( axnew );
542 }
543 FirstParCirc = ElCLib::Parameter( FilletCirc, FirstPoint );
544 LastParCirc = ElCLib::Parameter( FilletCirc, SecondPoint );
545
0797d9d3 546#ifdef OCCT_DEBUG
7fd59977 547#endif
548 }
549 else //Angle equal 0 or PI or R = 0
550 {
551 DrawPosition = Position;
552 EndOfArrow = BasePnt;
553 }
554
555
556 if(drawRevers)
557 {
558 gp_Vec Vd(DrawPosition, EndOfArrow);
559 DrawPosition.Translate(Vd *2);
560 }
561 DirOfArrow.SetXYZ(gp_Dir(gp_Vec(DrawPosition, EndOfArrow)).XYZ());
562}
563
564//=======================================================================
565//function : ComputeRadiusLine
566//purpose :
567//=======================================================================
568
569void DsgPrs::ComputeRadiusLine(const gp_Pnt & aCenter,
570 const gp_Pnt & anEndOfArrow,
571 const gp_Pnt & aPosition,
572 const Standard_Boolean drawFromCenter,
573 gp_Pnt & aRadLineOrign,
574 gp_Pnt & aRadLineEnd)
575{
576 if(drawFromCenter)
577 {
578 gp_Lin RadiusLine = gce_MakeLin( aCenter, anEndOfArrow );
579 Standard_Real PosParOnLine = ElCLib::Parameter( RadiusLine, aPosition );
580 Standard_Real EndOfArrowPar = ElCLib::Parameter( RadiusLine, anEndOfArrow );
581 if (PosParOnLine < 0.0)
582 {
583 aRadLineOrign = aPosition;
584 aRadLineEnd = anEndOfArrow;
585 }
586 else if (PosParOnLine > EndOfArrowPar)
587 {
588 aRadLineOrign = aPosition;
589 aRadLineEnd = aCenter;
590 }
591 else
592 {
593 aRadLineOrign = aCenter;
594 aRadLineEnd = anEndOfArrow;
595 }
596 }
597 else
598 {
599 aRadLineOrign = aPosition;
600 aRadLineEnd = anEndOfArrow;
601 }
602}
603
604
605//=======================================================================
606//function : DistanceFromApex
607//purpose :
608//=======================================================================
609
610Standard_Real DsgPrs::DistanceFromApex(const gp_Elips & elips,
611 const gp_Pnt & Apex,
612 const Standard_Real par)
613{
614 Standard_Real dist;
615 Standard_Real parApex = ElCLib::Parameter ( elips, Apex );
c6541a0c 616 if(parApex == 0.0 || parApex == M_PI)
7fd59977 617 {//Major case
618 if(parApex == 0.0) //pos Apex
c6541a0c 619 dist = (par < M_PI) ? par : (2*M_PI - par);
7fd59977 620 else //neg Apex
c6541a0c 621 dist = (par < M_PI) ? ( M_PI - par) : ( par - M_PI );
7fd59977 622 }
623 else
624 {// Minor case
c6541a0c 625 if(parApex == M_PI / 2) //pos Apex
7fd59977 626 {
c6541a0c 627 if(par <= parApex + M_PI && par > parApex )
7fd59977 628 dist = par - parApex;
629 else
630 {
c6541a0c
D
631 if(par > parApex + M_PI)
632 dist = 2*M_PI - par + parApex;
7fd59977 633 else
c6541a0c 634 dist = parApex - par; // 0 < par < M_PI/2
7fd59977 635 }
636 }
637 else //neg Apex == 3/2 PI
638 {
c6541a0c 639 if(par <= parApex && par >= M_PI/2)
7fd59977 640 dist = parApex - par;
641 else
642 {
643 if(par > parApex)
644 dist = par - parApex;
645 else
c6541a0c 646 dist = par + M_PI/2; // 0 < par < PI/2
7fd59977 647 }
648 }
649 }
650 return dist;
651}