074567b999ae6881299959d7a1023b48ea7e9c3b
[occt.git] / src / DsgPrs / DsgPrs_TangentPresentation.cxx
1 // Created on: 1996-01-16
2 // Created by: Jean-Pierre COMBE
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <DsgPrs_TangentPresentation.ixx>
24
25 #include <Graphic3d_Group.hxx>
26 #include <Graphic3d_Array1OfVertex.hxx>
27 #include <Prs3d_Arrow.hxx>
28 #include <Prs3d_ArrowAspect.hxx>
29 #include <Prs3d_LineAspect.hxx>
30 #include <Prs3d_LengthAspect.hxx>
31 #include <Graphic3d_AspectLine3d.hxx>
32 #include <Prs3d_PointAspect.hxx>
33 #include <Geom_CartesianPoint.hxx>
34 #include <StdPrs_Point.hxx>
35 #include <gp_Vec.hxx>
36 #include <Prs3d_Arrow.hxx>
37
38 void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation,
39                                       const Handle(Prs3d_Drawer)& aDrawer,
40                                       const gp_Pnt& OffsetPoint,
41                                       const gp_Dir& aDirection,
42                                       const Standard_Real length)
43 {
44   gp_Vec vec(aDirection);
45   gp_Vec vec1 = vec.Multiplied(length);
46   gp_Vec vec2 = vec.Multiplied(-length);
47   gp_Pnt p1 = OffsetPoint.Translated(vec1);
48   gp_Pnt p2 = OffsetPoint.Translated(vec2);
49   
50   // Aspect
51   Handle(Prs3d_LengthAspect) LA = aDrawer->LengthAspect();
52   LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID);
53   Handle(Prs3d_ArrowAspect) ARR1 = LA->Arrow1Aspect();
54   Handle(Prs3d_ArrowAspect) ARR2 = LA->Arrow2Aspect();
55   ARR1->SetLength(length/5);
56   ARR2->SetLength(length/5);
57
58   // Array1OfVertex
59   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
60   Graphic3d_Array1OfVertex V(1,2);
61   Quantity_Length X,Y,Z;
62   p1.Coord(X,Y,Z);
63   V(1).SetCoord(X,Y,Z);
64   p2.Coord(X,Y,Z);
65   V(2).SetCoord(X,Y,Z);
66   Prs3d_Root::CurrentGroup(aPresentation)->Polyline(V);
67
68   // fleche 1 : 
69   Prs3d_Root::NewGroup(aPresentation);
70   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
71   Prs3d_Arrow::Draw(aPresentation,p1,aDirection,
72                     LA->Arrow1Aspect()->Angle(),
73                     LA->Arrow1Aspect()->Length());
74
75   // fleche 2
76   Prs3d_Root::NewGroup(aPresentation);
77   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
78   Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(),
79                     LA->Arrow2Aspect()->Angle(),
80                     LA->Arrow2Aspect()->Length());
81 }
82
83