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> |
b8ddfc2f |
23 | #include <Graphic3d_ArrayOfSegments.hxx> |
42cf5bc1 |
24 | #include <Graphic3d_AspectLine3d.hxx> |
25 | #include <Graphic3d_Group.hxx> |
7fd59977 |
26 | #include <Prs3d_Arrow.hxx> |
27 | #include <Prs3d_ArrowAspect.hxx> |
a6eb515f |
28 | #include <Prs3d_DimensionAspect.hxx> |
42cf5bc1 |
29 | #include <Prs3d_LineAspect.hxx> |
7fd59977 |
30 | #include <Prs3d_PointAspect.hxx> |
42cf5bc1 |
31 | #include <Prs3d_Presentation.hxx> |
7fd59977 |
32 | #include <StdPrs_Point.hxx> |
7fd59977 |
33 | |
34 | void DsgPrs_TangentPresentation::Add (const Handle(Prs3d_Presentation)& aPresentation, |
35 | const Handle(Prs3d_Drawer)& aDrawer, |
36 | const gp_Pnt& OffsetPoint, |
37 | const gp_Dir& aDirection, |
38 | const Standard_Real length) |
39 | { |
40 | gp_Vec vec(aDirection); |
41 | gp_Vec vec1 = vec.Multiplied(length); |
42 | gp_Vec vec2 = vec.Multiplied(-length); |
43 | gp_Pnt p1 = OffsetPoint.Translated(vec1); |
44 | gp_Pnt p2 = OffsetPoint.Translated(vec2); |
45 | |
46 | // Aspect |
a6eb515f |
47 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
7fd59977 |
48 | LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID); |
a6eb515f |
49 | Handle(Prs3d_ArrowAspect) ARR1 = LA->ArrowAspect(); |
50 | Handle(Prs3d_ArrowAspect) ARR2 = LA->ArrowAspect(); |
7fd59977 |
51 | ARR1->SetLength(length/5); |
52 | ARR2->SetLength(length/5); |
53 | |
54 | // Array1OfVertex |
55 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
b8ddfc2f |
56 | |
57 | Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2); |
58 | aPrims->AddVertex(p1); |
59 | aPrims->AddVertex(p2); |
60 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
7fd59977 |
61 | |
62 | // fleche 1 : |
63 | Prs3d_Root::NewGroup(aPresentation); |
64 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
4ad142d9 |
65 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), p1, aDirection, LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 |
66 | |
67 | // fleche 2 |
68 | Prs3d_Root::NewGroup(aPresentation); |
69 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
4ad142d9 |
70 | Prs3d_Arrow::Draw (Prs3d_Root::CurrentGroup (aPresentation), p2, aDirection.Reversed(), LA->ArrowAspect()->Angle(), LA->ArrowAspect()->Length()); |
7fd59977 |
71 | } |