0027525: Coding - eliminate warnings on Windows for OCCT with static type of libraries
[occt.git] / src / DsgPrs / DsgPrs_FilletRadiusPresentation.cxx
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
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 <Aspect_AspectMarker.hxx>
19 #include <Aspect_TypeOfLine.hxx>
20 #include <Aspect_TypeOfMarker.hxx>
21 #include <DsgPrs.hxx>
22 #include <DsgPrs_FilletRadiusPresentation.hxx>
23 #include <ElCLib.hxx>
24 #include <Geom_Circle.hxx>
25 #include <Geom_Line.hxx>
26 #include <Geom_TrimmedCurve.hxx>
27 #include <GeomAPI_ExtremaCurveCurve.hxx>
28 #include <gp_Dir.hxx>
29 #include <gp_Lin.hxx>
30 #include <gp_Pnt.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>
47
48 #include <stdio.h>
49 //=======================================================================
50 //function : Add
51 //purpose  : 
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,
66                                                  gp_Pnt & EndOfArrow,
67                                                  Handle(Geom_TrimmedCurve)& TrimCurve,
68                                                  Standard_Boolean & HasCircle )
69 {
70   char valcar[80];
71   sprintf(valcar,"%5.2f",theval);
72
73   Standard_Real FirstParCirc, LastParCirc;
74   Standard_Boolean SpecCase;
75   gp_Dir DirOfArrow;
76   gp_Circ FilletCirc;
77   //  gp_Pnt NewPosition, EndOfArrow;
78   Handle( Prs3d_DimensionAspect ) LA = aDrawer->DimensionAspect();
79   Prs3d_Root::CurrentGroup( aPresentation )->SetPrimitivesAspect( LA->LineAspect()->Aspect() );
80
81   Standard_Real ArrowLength = LA->ArrowAspect()->Length();
82   DsgPrs::ComputeFilletRadiusPresentation( ArrowLength,
83                                            theval,
84                                            aPosition,
85                                            aNormalDir,
86                                            aFirstPoint,
87                                            aSecondPoint,
88                                            aCenter,
89                                            aBasePnt,
90                                            drawRevers,
91                                            SpecCase,
92                                            FilletCirc,
93                                            FirstParCirc,
94                                            LastParCirc,
95                                            EndOfArrow,
96                                            DirOfArrow,
97                                            DrawPosition //NewPosition
98                                            );
99   // Creating the fillet's arc                                
100   if( !SpecCase )
101   {
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 );
105
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);
110
111     HasCircle = Standard_True;
112     Handle(Geom_Circle) Circle = new Geom_Circle( FilletCirc );
113     TrimCurve = new Geom_TrimmedCurve( Circle,  FirstParCirc, LastParCirc );
114   }
115   else // null or PI anle or Radius = 0
116   {
117     HasCircle = Standard_False;
118   }
119   
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);
125
126   // Drawing the text
127   Prs3d_Text::Draw(aPresentation, LA->TextAspect(), aText, DrawPosition);
128    
129   // Add presentation of arrows
130   DsgPrs::ComputeSymbol( aPresentation, LA, EndOfArrow, EndOfArrow, DirOfArrow, DirOfArrow, ArrowPrs );
131 }