1 // Created on: 1996-01-16
2 // Created by: Jean-Pierre COMBE
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <DsgPrs_TangentPresentation.hxx>
19 #include <Geom_CartesianPoint.hxx>
23 #include <Graphic3d_ArrayOfSegments.hxx>
24 #include <Graphic3d_AspectLine3d.hxx>
25 #include <Graphic3d_Group.hxx>
26 #include <Prs3d_Arrow.hxx>
27 #include <Prs3d_ArrowAspect.hxx>
28 #include <Prs3d_DimensionAspect.hxx>
29 #include <Prs3d_LineAspect.hxx>
30 #include <Prs3d_PointAspect.hxx>
31 #include <Prs3d_Presentation.hxx>
32 #include <StdPrs_Point.hxx>
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)
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);
47 Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect();
48 LA->LineAspect()->SetTypeOfLine(Aspect_TOL_SOLID);
49 Handle(Prs3d_ArrowAspect) ARR1 = LA->ArrowAspect();
50 Handle(Prs3d_ArrowAspect) ARR2 = LA->ArrowAspect();
51 ARR1->SetLength(length/5);
52 ARR2->SetLength(length/5);
55 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
57 Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(2);
58 aPrims->AddVertex(p1);
59 aPrims->AddVertex(p2);
60 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
63 Prs3d_Root::NewGroup(aPresentation);
64 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
65 Prs3d_Arrow::Draw(aPresentation,p1,aDirection,LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length());
68 Prs3d_Root::NewGroup(aPresentation);
69 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
70 Prs3d_Arrow::Draw(aPresentation,p2,aDirection.Reversed(),LA->ArrowAspect()->Angle(),LA->ArrowAspect()->Length());