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