0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / DsgPrs / DsgPrs_TangentPresentation.cxx
1 // File:        DsgPrs_TangentPresentation.cxx
2 // Created:     Tue Jan 16 14:29:33 1996
3 // Author:      Jean-Pierre COMBE
4 //              <jpi>
5
6
7 #include <DsgPrs_TangentPresentation.ixx>
8
9 #include <Graphic3d_Group.hxx>
10 #include <Graphic3d_Array1OfVertex.hxx>
11 #include <Prs3d_Arrow.hxx>
12 #include <Prs3d_ArrowAspect.hxx>
13 #include <Prs3d_LineAspect.hxx>
14 #include <Prs3d_LengthAspect.hxx>
15 #include <Graphic3d_AspectLine3d.hxx>
16 #include <Prs3d_PointAspect.hxx>
17 #include <Geom_CartesianPoint.hxx>
18 #include <StdPrs_Point.hxx>
19 #include <gp_Vec.hxx>
20 #include <Prs3d_Arrow.hxx>
21
22 void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
23                                       const Handle(Prs3d_Drawer)& aDrawer,
24                                       const gp_Pnt& OffsetPoint,
25                                       const gp_Dir& aDirection,
26                                       const Standard_Real length)
27 {
28   gp_Vec vec(aDirection);
29   gp_Vec vec1 = vec.Multiplied(length);
30   gp_Vec vec2 = vec.Multiplied(-length);
31   gp_Pnt p1 = OffsetPoint.Translated(vec1);
32   gp_Pnt p2 = OffsetPoint.Translated(vec2);
33   
34   // Aspect
35   Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
36   LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID);
37   Handle(Prs3d_ArrowAspect) ARR1 = LA->Arrow1Aspect();
38   Handle(Prs3d_ArrowAspect) ARR2 = LA->Arrow2Aspect();
39   ARR1->SetLength(length/5);
40   ARR2->SetLength(length/5);
41
42   // Array1OfVertex
43   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
44   Graphic3d_Array1OfVertex V(1,2);
45   Quantity_Length X,Y,Z;
46   p1.Coord(X,Y,Z);
47   V(1).SetCoord(X,Y,Z);
48   p2.Coord(X,Y,Z);
49   V(2).SetCoord(X,Y,Z);
50   Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
51
52   // fleche 1 : 
53   Prs3d_Root::NewGroup(aPresentation);
54   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
55   Prs3d_Arrow::Draw(aPresentation,p1,aDirection,
56                     LA->Arrow1Aspect()->Angle(),
57                     LA->Arrow1Aspect()->Length());
58
59   // fleche 2
60   Prs3d_Root::NewGroup(aPresentation);
61   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
62   Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(),
63                     LA->Arrow2Aspect()->Angle(),
64                     LA->Arrow2Aspect()->Length());
65 }
66
67