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