1 // Created on: 1997-12-08
2 // Created by: Serguei ZARITCHNY
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Aspect_AspectMarker.hxx>
19 #include <Aspect_TypeOfLine.hxx>
20 #include <Aspect_TypeOfMarker.hxx>
22 #include <DsgPrs_FilletRadiusPresentation.hxx>
24 #include <Geom_Circle.hxx>
25 #include <Geom_Line.hxx>
26 #include <Geom_TrimmedCurve.hxx>
27 #include <GeomAPI_ExtremaCurveCurve.hxx>
31 #include <Graphic3d_ArrayOfPolylines.hxx>
32 #include <Graphic3d_ArrayOfSegments.hxx>
33 #include <Graphic3d_AspectLine3d.hxx>
34 #include <Graphic3d_AspectMarker3d.hxx>
35 #include <Graphic3d_Group.hxx>
36 #include <Graphic3d_Vertex.hxx>
37 #include <Precision.hxx>
38 #include <Prs3d_Arrow.hxx>
39 #include <Prs3d_ArrowAspect.hxx>
40 #include <Prs3d_DimensionAspect.hxx>
41 #include <Prs3d_LineAspect.hxx>
42 #include <Prs3d_Presentation.hxx>
43 #include <Prs3d_Text.hxx>
44 #include <Quantity_Color.hxx>
45 #include <TCollection_AsciiString.hxx>
46 #include <TCollection_ExtendedString.hxx>
49 //=======================================================================
52 //=======================================================================
53 void DsgPrs_FilletRadiusPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
54 const Handle(Prs3d_Drawer)& aDrawer,
55 const Standard_Real theval,
56 const TCollection_ExtendedString & aText,
57 const gp_Pnt & aPosition,
58 const gp_Dir & aNormalDir,
59 const gp_Pnt & aBasePnt,
60 const gp_Pnt & aFirstPoint,
61 const gp_Pnt & aSecondPoint,
62 const gp_Pnt & aCenter,
63 const DsgPrs_ArrowSide ArrowPrs,
64 const Standard_Boolean drawRevers,
65 gp_Pnt & DrawPosition,
67 Handle(Geom_TrimmedCurve)& TrimCurve,
68 Standard_Boolean & HasCircle )
71 sprintf(valcar,"%5.2f",theval);
73 Standard_Real FirstParCirc, LastParCirc;
74 Standard_Boolean SpecCase;
77 // gp_Pnt NewPosition, EndOfArrow;
78 Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect();
79 Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
81 Standard_Real ArrowLength = LA->ArrowAspect()->Length();
82 DsgPrs::ComputeFilletRadiusPresentation( ArrowLength,
97 DrawPosition //NewPosition
99 // Creating the fillet's arc
102 const Standard_Real Alpha = Abs(LastParCirc - FirstParCirc);
103 const Standard_Integer NodeNumber = Max (4 , Standard_Integer (50. * Alpha / M_PI));
104 const Standard_Real delta = Alpha / ( NodeNumber - 1 );
106 Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(NodeNumber);
107 for (Standard_Integer i = 0 ; i < NodeNumber; i++, FirstParCirc += delta)
108 aPrims->AddVertex(ElCLib::Value( FirstParCirc, FilletCirc ));
109 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
111 HasCircle = Standard_True;
112 Handle(Geom_Circle) Circle = new Geom_Circle( FilletCirc );
113 TrimCurve = new Geom_TrimmedCurve( Circle, FirstParCirc, LastParCirc );
115 else // null or PI anle or Radius = 0
117 HasCircle = Standard_False;
120 // Line from position to intersection point on fillet's circle (EndOfArrow)
121 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
122 aPrims->AddVertex(DrawPosition);
123 aPrims->AddVertex(EndOfArrow);
124 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
127 Prs3d_Text::Draw(aPresentation, LA->TextAspect(), aText, DrawPosition);
129 // Add presentation of arrows
130 DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs );