0024428: Implementation of LGPL license
[occt.git] / src / BRepPrim / BRepPrim_Torus.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//
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <BRepPrim_Torus.ixx>
18
19#include <gp.hxx>
20#include <gp_Vec.hxx>
21#include <gp_Ax2d.hxx>
22#include <Precision.hxx>
23
24#include <Geom_ToroidalSurface.hxx>
25#include <Geom_Circle.hxx>
26#include <Geom2d_Circle.hxx>
27
28//=======================================================================
29//function : BRepPrim_Torus
30//purpose :
31//=======================================================================
32
33BRepPrim_Torus::BRepPrim_Torus(const gp_Ax2& Position,
34 const Standard_Real Major,
35 const Standard_Real Minor) :
c6541a0c 36 BRepPrim_Revolution(Position,0,2*M_PI),
7fd59977 37 myMajor(Major),
38 myMinor(Minor)
39{
40 SetMeridian();
41}
42
43//=======================================================================
44//function : BRepPrim_Torus
45//purpose :
46//=======================================================================
47
48BRepPrim_Torus::BRepPrim_Torus(const Standard_Real Major,
49 const Standard_Real Minor) :
c6541a0c 50 BRepPrim_Revolution(gp::XOY(),0,2*M_PI),
7fd59977 51 myMajor(Major),
52 myMinor(Minor)
53{
54 SetMeridian();
55}
56
57//=======================================================================
58//function : BRepPrim_Torus
59//purpose :
60//=======================================================================
61
62BRepPrim_Torus::BRepPrim_Torus(const gp_Pnt& Center,
63 const Standard_Real Major,
64 const Standard_Real Minor) :
65 BRepPrim_Revolution(gp_Ax2(Center,gp_Dir(0,0,1),gp_Dir(1,0,0)),
c6541a0c 66 0,2*M_PI),
7fd59977 67 myMajor(Major),
68 myMinor(Minor)
69{
70 SetMeridian();
71}
72
73//=======================================================================
74//function : MakeEmptyLateralFace
75//purpose :
76//=======================================================================
77
78TopoDS_Face BRepPrim_Torus::MakeEmptyLateralFace()const
79{
80 Handle(Geom_ToroidalSurface) T =
81 new Geom_ToroidalSurface(Axes(),myMajor,myMinor);
82 TopoDS_Face F;
83 myBuilder.Builder().MakeFace(F,T,Precision::Confusion());
84 return F;
85}
86
87
88//=======================================================================
89//function : SetMeridian
90//purpose :
91//=======================================================================
92
93void BRepPrim_Torus::SetMeridian()
94{
95 gp_Dir D = Axes().YDirection();
96 D.Reverse();
97 gp_Ax2 A(Axes().Location(),D,Axes().XDirection());
98 gp_Vec V = Axes().XDirection();
99 V.Multiply(myMajor);
100 A.Translate(V);
101 Handle(Geom_Circle) C = new Geom_Circle(A,myMinor);
102 Handle(Geom2d_Circle) C2d = new Geom2d_Circle(gp_Ax2d(gp_Pnt2d(myMajor,0),
103 gp_Dir2d(1,0)),
104 myMinor);
105 Meridian(C,C2d);
106}