0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepPrim / BRepPrim_Sphere.cxx
CommitLineData
b311480e 1// Created on: 1992-11-06
2// Created by: Remi LEQUETTE
3// Copyright (c) 1992-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.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <BRepPrim_Sphere.hxx>
19#include <Geom2d_Circle.hxx>
20#include <Geom_Circle.hxx>
21#include <Geom_SphericalSurface.hxx>
7fd59977 22#include <gp.hxx>
42cf5bc1 23#include <gp_Ax2.hxx>
7fd59977 24#include <gp_Ax2d.hxx>
42cf5bc1 25#include <gp_Pnt.hxx>
7fd59977 26#include <Precision.hxx>
42cf5bc1 27#include <Standard_DomainError.hxx>
28#include <TopoDS_Face.hxx>
7fd59977 29
0d969553 30// parameters on the meridian
c6541a0c
D
31#define PMIN (-0.5*M_PI)
32#define PMAX (0.5*M_PI)
7fd59977 33
34//=======================================================================
35//function : BRepPrim_Sphere
36//purpose :
37//=======================================================================
38
39BRepPrim_Sphere::BRepPrim_Sphere(const Standard_Real Radius) :
40 BRepPrim_Revolution(gp::XOY(),PMIN,PMAX),
41 myRadius(Radius)
42{
43 SetMeridian();
44}
45
46//=======================================================================
47//function : BRepPrim_Sphere
48//purpose :
49//=======================================================================
50
51BRepPrim_Sphere::BRepPrim_Sphere(const gp_Pnt& Center,
52 const Standard_Real Radius) :
53 BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
54 PMIN,PMAX),
55 myRadius(Radius)
56{
57 SetMeridian();
58}
59
60//=======================================================================
61//function : BRepPrim_Sphere
62//purpose :
63//=======================================================================
64
65BRepPrim_Sphere::BRepPrim_Sphere(const gp_Ax2& Axes,
66 const Standard_Real Radius) :
67 BRepPrim_Revolution(Axes,PMIN,PMAX),
68 myRadius(Radius)
69{
70 SetMeridian();
71}
72
73//=======================================================================
74//function : MakeEmptyLateralFace
75//purpose :
76//=======================================================================
77
78TopoDS_Face BRepPrim_Sphere::MakeEmptyLateralFace()const
79{
80 Handle(Geom_SphericalSurface) S =
81 new Geom_SphericalSurface(Axes(),myRadius);
82 TopoDS_Face F;
83 myBuilder.Builder().MakeFace(F,S,Precision::Confusion());
84 return F;
85}
86
87//=======================================================================
88//function : SetMeridian
89//purpose :
90//=======================================================================
91
92void BRepPrim_Sphere::SetMeridian()
93{
94 // Offset the parameters on the meridian
95 // to trim the edge in 3pi/2, 5pi/2
96
c6541a0c 97 SetMeridianOffset(2*M_PI);
7fd59977 98
99 gp_Dir D = Axes().YDirection();
100 D.Reverse();
101 gp_Ax2 A(Axes().Location(),D,Axes().XDirection());
102 Handle(Geom_Circle) C = new Geom_Circle(A,myRadius);
103 Handle(Geom2d_Circle) C2d =
104 new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(0,0),gp_Dir2d(1,0)),
105 myRadius);
106 Meridian(C,C2d);
107}
108
109