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
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.
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.
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.
23 #include <DsgPrs_ConcentricPresentation.ixx>
25 #include <Graphic3d_Group.hxx>
26 #include <Graphic3d_ArrayOfPolylines.hxx>
27 #include <Prs3d_DimensionAspect.hxx>
28 #include <Prs3d_Root.hxx>
29 #include <Prs3d_LineAspect.hxx>
31 #include <gp_Circ.hxx>
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,
46 Handle(Prs3d_DimensionAspect) LA = aDrawer->DimensionAspect();
48 //Creation et discretisation du plus gros cercle
49 gp_Circ Circ(gp_Ax2(aCenter,aNorm), aRadius);
50 const Standard_Integer nbp = 50;
51 const Standard_Real dteta = (2. * M_PI)/nbp;
53 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(LA->LineAspect()->Aspect());
55 Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(2*nbp+6,4);
57 gp_Pnt pt1 = ElCLib::Value(0., Circ);
58 aPrims->AddBound(nbp+1);
59 aPrims->AddVertex(pt1);
60 Standard_Real ucur = dteta;
62 for (i = 2; i<=nbp; i++, ucur += dteta)
63 aPrims->AddVertex(ElCLib::Value(ucur, Circ));
64 aPrims->AddVertex(pt1);
66 //Creation et discretisation du plus petit cercle
67 Circ.SetRadius(0.5*aRadius);
68 pt1 = ElCLib::Value(0., Circ);
69 aPrims->AddBound(nbp+1);
70 aPrims->AddVertex(pt1);
72 for (i = 2; i<=nbp; i++, ucur += dteta)
73 aPrims->AddVertex(ElCLib::Value(ucur, Circ));
74 aPrims->AddVertex(pt1);
76 //Creation de la croix
78 gp_Dir vecnorm(aPoint.XYZ() - aCenter.XYZ());
80 vec.Multiply(aRadius);
81 gp_Pnt p1 = aCenter.Translated(vec);
82 gp_Pnt p2 = aCenter.Translated(-vec);
85 aPrims->AddVertex(p1);
86 aPrims->AddVertex(p2);
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);
97 aPrims->AddVertex(p1);
98 aPrims->AddVertex(p2);
100 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);