b311480e |
1 | // Created on: 1996-03-18 |
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 | |
22 | |
23 | #include <DsgPrs_ConcentricPresentation.ixx> |
24 | |
25 | #include <Graphic3d_Group.hxx> |
b8ddfc2f |
26 | #include <Graphic3d_ArrayOfPolylines.hxx> |
a6eb515f |
27 | #include <Prs3d_DimensionAspect.hxx> |
7fd59977 |
28 | #include <Prs3d_Root.hxx> |
29 | #include <Prs3d_LineAspect.hxx> |
30 | |
31 | #include <gp_Circ.hxx> |
32 | #include <gp_Pnt.hxx> |
33 | #include <gp_Dir.hxx> |
34 | #include <gp_Vec.hxx> |
35 | |
36 | #include <ElCLib.hxx> |
37 | |
38 | void DsgPrs_ConcentricPresentation::Add( |
39 | const Handle(Prs3d_Presentation)& aPresentation, |
40 | const Handle(Prs3d_Drawer)& aDrawer, |
41 | const gp_Pnt& aCenter, |
42 | const Standard_Real aRadius, |
43 | const gp_Dir& aNorm, |
44 | const gp_Pnt& aPoint) |
45 | { |
a6eb515f |
46 | Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect(); |
7fd59977 |
47 | |
48 | //Creation et discretisation du plus gros cercle |
49 | gp_Circ Circ(gp_Ax2(aCenter,aNorm), aRadius); |
b8ddfc2f |
50 | const Standard_Integer nbp = 50; |
51 | const Standard_Real dteta = (2. * M_PI)/nbp; |
52 | |
53 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect()); |
54 | |
55 | Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(2*nbp+6,4); |
56 | |
57 | gp_Pnt pt1 = ElCLib::Value(0., Circ); |
58 | aPrims->AddBound(nbp+1); |
59 | aPrims->AddVertex(pt1); |
60 | Standard_Real ucur = dteta; |
7fd59977 |
61 | Standard_Integer i ; |
b8ddfc2f |
62 | for (i = 2; i<=nbp; i++, ucur += dteta) |
63 | aPrims->AddVertex(ElCLib::Value(ucur, Circ)); |
64 | aPrims->AddVertex(pt1); |
7fd59977 |
65 | |
66 | //Creation et discretisation du plus petit cercle |
b8ddfc2f |
67 | Circ.SetRadius(0.5*aRadius); |
68 | pt1 = ElCLib::Value(0., Circ); |
69 | aPrims->AddBound(nbp+1); |
70 | aPrims->AddVertex(pt1); |
71 | ucur = dteta; |
72 | for (i = 2; i<=nbp; i++, ucur += dteta) |
73 | aPrims->AddVertex(ElCLib::Value(ucur, Circ)); |
74 | aPrims->AddVertex(pt1); |
7fd59977 |
75 | |
76 | //Creation de la croix |
77 | //1er segment |
b8ddfc2f |
78 | gp_Dir vecnorm(aPoint.XYZ() - aCenter.XYZ()); |
7fd59977 |
79 | gp_Vec vec(vecnorm); |
80 | vec.Multiply(aRadius); |
81 | gp_Pnt p1 = aCenter.Translated(vec); |
82 | gp_Pnt p2 = aCenter.Translated(-vec); |
b8ddfc2f |
83 | |
84 | aPrims->AddBound(2); |
85 | aPrims->AddVertex(p1); |
86 | aPrims->AddVertex(p2); |
7fd59977 |
87 | |
88 | //2ieme segment |
89 | vec.Cross(aNorm); |
90 | vecnorm.SetCoord(vec.X(), vec.Y(), vec.Z() ); |
91 | vec.SetXYZ(vecnorm.XYZ()); |
92 | vec.Multiply(aRadius); |
93 | p1 = aCenter.Translated(vec); |
94 | p2 = aCenter.Translated(-vec); |
7fd59977 |
95 | |
b8ddfc2f |
96 | aPrims->AddBound(2); |
97 | aPrims->AddVertex(p1); |
98 | aPrims->AddVertex(p2); |
7fd59977 |
99 | |
b8ddfc2f |
100 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
7fd59977 |
101 | } |