1 // Created on: 1992-11-06
2 // Created by: Remi LEQUETTE
3 // Copyright (c) 1992-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
9 // under the terms of the GNU Lesser General Public 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.
17 #include <BRepPrim_Sphere.ixx>
20 #include <gp_Ax2d.hxx>
21 #include <Precision.hxx>
23 #include <Geom_SphericalSurface.hxx>
24 #include <Geom_Circle.hxx>
25 #include <Geom2d_Circle.hxx>
27 // parameters on the meridian
29 #define PMIN (-0.5*M_PI)
30 #define PMAX (0.5*M_PI)
32 //=======================================================================
33 //function : BRepPrim_Sphere
35 //=======================================================================
37 BRepPrim_Sphere::BRepPrim_Sphere(const Standard_Real Radius) :
38 BRepPrim_Revolution(gp::XOY(),PMIN,PMAX),
44 //=======================================================================
45 //function : BRepPrim_Sphere
47 //=======================================================================
49 BRepPrim_Sphere::BRepPrim_Sphere(const gp_Pnt& Center,
50 const Standard_Real Radius) :
51 BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
58 //=======================================================================
59 //function : BRepPrim_Sphere
61 //=======================================================================
63 BRepPrim_Sphere::BRepPrim_Sphere(const gp_Ax2& Axes,
64 const Standard_Real Radius) :
65 BRepPrim_Revolution(Axes,PMIN,PMAX),
71 //=======================================================================
72 //function : MakeEmptyLateralFace
74 //=======================================================================
76 TopoDS_Face BRepPrim_Sphere::MakeEmptyLateralFace()const
78 Handle(Geom_SphericalSurface) S =
79 new Geom_SphericalSurface(Axes(),myRadius);
81 myBuilder.Builder().MakeFace(F,S,Precision::Confusion());
85 //=======================================================================
86 //function : SetMeridian
88 //=======================================================================
90 void BRepPrim_Sphere::SetMeridian()
92 // Offset the parameters on the meridian
93 // to trim the edge in 3pi/2, 5pi/2
95 SetMeridianOffset(2*M_PI);
97 gp_Dir D = Axes().YDirection();
99 gp_Ax2 A(Axes().Location(),D,Axes().XDirection());
100 Handle(Geom_Circle) C = new Geom_Circle(A,myRadius);
101 Handle(Geom2d_Circle) C2d =
102 new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(0,0),gp_Dir2d(1,0)),