b311480e |
1 | // Created on: 1996-01-16 |
2 | // Created by: Jean-Pierre COMBE |
3 | // Copyright (c) 1996-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <DsgPrs_TangentPresentation.hxx> |
19 | #include <Geom_CartesianPoint.hxx> |
20 | #include <gp_Dir.hxx> |
21 | #include <gp_Pnt.hxx> |
22 | #include <gp_Vec.hxx> |
42cf5bc1 |
23 | #include <Graphic3d_Group.hxx> |
7fd59977 |
24 | #include <Prs3d_Arrow.hxx> |
a6eb515f |
25 | #include <Prs3d_DimensionAspect.hxx> |
42cf5bc1 |
26 | #include <Prs3d_LineAspect.hxx> |
42cf5bc1 |
27 | #include <Prs3d_Presentation.hxx> |
7fd59977 |
28 | #include <StdPrs_Point.hxx> |
7fd59977 |
29 | |
30 | void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, |
31 | const Handle(Prs3d_Drawer)& aDrawer, |
32 | const gp_Pnt& OffsetPoint, |
33 | const gp_Dir& aDirection, |
34 | const Standard_Real length) |
35 | { |
36 | gp_Vec vec(aDirection); |
37 | gp_Vec vec1 = vec.Multiplied(length); |
38 | gp_Vec vec2 = vec.Multiplied(-length); |
39 | gp_Pnt p1 = OffsetPoint.Translated(vec1); |
40 | gp_Pnt p2 = OffsetPoint.Translated(vec2); |
41 | |
42 | // Aspect |
a6eb515f |
43 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
7fd59977 |
44 | LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); |
a6eb515f |
45 | Handle(Prs3d_ArrowAspect) ARR1 = LA->ArrowAspect(); |
46 | Handle(Prs3d_ArrowAspect) ARR2 = LA->ArrowAspect(); |
7fd59977 |
47 | ARR1->SetLength(length/5); |
48 | ARR2->SetLength(length/5); |
49 | |
50 | // Array1OfVertex |
d6c48921 |
51 | aPresentation->CurrentGroup()->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
b8ddfc2f |
52 | |
53 | Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); |
54 | aPrims->AddVertex(p1); |
55 | aPrims->AddVertex(p2); |
d6c48921 |
56 | aPresentation->CurrentGroup()->AddPrimitiveArray(aPrims); |
7fd59977 |
57 | |
58 | // fleche 1 : |
d6c48921 |
59 | aPresentation->NewGroup(); |
60 | aPresentation->CurrentGroup()->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
61 | Prs3d_Arrow::Draw (aPresentation->CurrentGroup(), p1, aDirection, LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 |
62 | |
63 | // fleche 2 |
d6c48921 |
64 | aPresentation->NewGroup(); |
65 | aPresentation->CurrentGroup()->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
66 | Prs3d_Arrow::Draw (aPresentation->CurrentGroup(), p2, aDirection.Reversed(), LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 |
67 | } |