b311480e |
1 | // Created on: 1996-04-01 |
2 | // Created by: Flore Lantheaume |
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 <Aspect_AspectMarker.hxx> |
19 | #include <Aspect_TypeOfLine.hxx> |
20 | #include <Aspect_TypeOfMarker.hxx> |
21 | #include <DsgPrs_FixPresentation.hxx> |
22 | #include <gp_Ax1.hxx> |
23 | #include <gp_Dir.hxx> |
24 | #include <gp_Pnt.hxx> |
25 | #include <gp_Vec.hxx> |
26 | #include <Graphic3d_ArrayOfPoints.hxx> |
b8ddfc2f |
27 | #include <Graphic3d_ArrayOfSegments.hxx> |
7fd59977 |
28 | #include <Graphic3d_AspectLine3d.hxx> |
42cf5bc1 |
29 | #include <Graphic3d_AspectMarker3d.hxx> |
30 | #include <Graphic3d_Group.hxx> |
7fd59977 |
31 | #include <Graphic3d_Vertex.hxx> |
a6eb515f |
32 | #include <Prs3d_DimensionAspect.hxx> |
7fd59977 |
33 | #include <Prs3d_LineAspect.hxx> |
42cf5bc1 |
34 | #include <Prs3d_Presentation.hxx> |
7fd59977 |
35 | #include <Prs3d_Root.hxx> |
7fd59977 |
36 | #include <Quantity_Color.hxx> |
37 | |
7fd59977 |
38 | //======================================================================= |
39 | //function : Add |
40 | //purpose : |
41 | //======================================================================= |
7fd59977 |
42 | void DsgPrs_FixPresentation::Add( |
43 | const Handle(Prs3d_Presentation)& aPresentation, |
44 | const Handle(Prs3d_Drawer)& aDrawer, |
45 | const gp_Pnt& aPntAttach, |
46 | const gp_Pnt& aPntEnd, |
47 | const gp_Dir& aNormPln, |
48 | const Standard_Real symbsize) |
49 | { |
a6eb515f |
50 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
7fd59977 |
51 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
52 | |
b8ddfc2f |
53 | Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(10); |
54 | |
7fd59977 |
55 | //Trace du segment de raccordement |
b8ddfc2f |
56 | aPrims->AddVertex(aPntAttach); |
57 | aPrims->AddVertex(aPntEnd); |
7fd59977 |
58 | |
59 | // trace du symbole 'Fix' |
b8ddfc2f |
60 | gp_Vec dirac(aPntAttach, aPntEnd); // vecteur directeur du seg. de raccord |
7fd59977 |
61 | dirac.Normalize(); |
62 | gp_Vec norac = dirac.Crossed(gp_Vec(aNormPln)); |
63 | gp_Ax1 ax(aPntEnd, aNormPln); |
b8ddfc2f |
64 | norac.Rotate(ax, M_PI/8); // vecteur normal au seg. de raccord |
7fd59977 |
65 | norac*=(symbsize/2); |
66 | gp_Pnt P1 = aPntEnd.Translated(norac); |
67 | gp_Pnt P2 = aPntEnd.Translated(-norac); |
68 | |
b8ddfc2f |
69 | aPrims->AddVertex(P1); |
70 | aPrims->AddVertex(P2); |
7fd59977 |
71 | |
72 | // trace des 'dents' |
73 | norac*=0.8; |
74 | P1 = aPntEnd.Translated(norac); |
75 | P2 = aPntEnd.Translated(-norac); |
76 | dirac*=(symbsize/2); |
b8ddfc2f |
77 | gp_Pnt PF = P1; |
7fd59977 |
78 | gp_Pnt PL = PF.Translated(dirac); |
79 | PL.Translate(norac); |
7fd59977 |
80 | |
b8ddfc2f |
81 | aPrims->AddVertex(PF); |
82 | aPrims->AddVertex(PL); |
83 | |
84 | PF = P2; |
7fd59977 |
85 | PL = PF.Translated(dirac); |
86 | PL.Translate(norac); |
7fd59977 |
87 | |
b8ddfc2f |
88 | aPrims->AddVertex(PF); |
89 | aPrims->AddVertex(PL); |
90 | |
91 | PF.SetXYZ(0.5*(P1.XYZ() + P2.XYZ())); |
7fd59977 |
92 | PL = PF.Translated(dirac); |
93 | PL.Translate(norac); |
b8ddfc2f |
94 | |
95 | aPrims->AddVertex(PF); |
96 | aPrims->AddVertex(PL); |
97 | |
98 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
7fd59977 |
99 | |
100 | // On ajoute un rond au point d'attache |
101 | Prs3d_Root::NewGroup(aPresentation); |
102 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
a577aaab |
103 | Quantity_Color aColor; |
104 | Aspect_TypeOfLine aType; |
105 | Standard_Real aWidth; |
106 | LA->LineAspect()->Aspect()->Values (aColor, aType, aWidth); |
107 | Handle(Graphic3d_AspectMarker3d) aMarkerAsp = new Graphic3d_AspectMarker3d (Aspect_TOM_O, aColor, 1.0); |
108 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect (aMarkerAsp); |
109 | Handle(Graphic3d_ArrayOfPoints) anArrayOfPoints = new Graphic3d_ArrayOfPoints (1); |
110 | anArrayOfPoints->AddVertex (aPntAttach.X(), aPntAttach.Y(), aPntAttach.Z()); |
111 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray (anArrayOfPoints); |
7fd59977 |
112 | } |