113bda70 |
1 | // Created on: 2020-09-17 |
2 | // Created by: Marina ZERNOVA |
3 | // Copyright (c) 2020 OPEN CASCADE SAS |
4 | // |
5 | // This file is part of Open CASCADE Technology software library. |
6 | // |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
12 | // |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
15 | |
16 | #ifndef _Prs3d_ToolTorus_HeaderFile |
17 | #define _Prs3d_ToolTorus_HeaderFile |
18 | |
19 | #include <Prs3d_ToolQuadric.hxx> |
20 | |
21 | //! Standard presentation algorithm that outputs graphical primitives for torus surface. |
22 | class Prs3d_ToolTorus : public Prs3d_ToolQuadric |
23 | { |
24 | public: |
25 | |
26 | //! Generate primitives for 3D quadric surface (complete torus). |
27 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
28 | //! @param theMinorRad [in] radius of the pipe |
29 | //! @param theNbSlices [in] number of slices within U parameter |
30 | //! @param theNbStacks [in] number of stacks within V parameter |
31 | //! @param theTrsf [in] optional transformation to apply |
32 | //! @return generated triangulation |
33 | static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theMajorRad, |
34 | const Standard_Real theMinorRad, |
35 | const Standard_Integer theNbSlices, |
36 | const Standard_Integer theNbStacks, |
37 | const gp_Trsf& theTrsf) |
38 | { |
39 | return Create (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, M_PI * 2.0, theNbSlices, theNbStacks, theTrsf); |
40 | } |
41 | |
42 | //! Generate primitives for 3D quadric surface (torus segment). |
43 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
44 | //! @param theMinorRad [in] radius of the pipe |
45 | //! @param theAngle [in] angle to create a torus pipe segment |
46 | //! @param theNbSlices [in] number of slices within U parameter |
47 | //! @param theNbStacks [in] number of stacks within V parameter |
48 | //! @param theTrsf [in] optional transformation to apply |
49 | //! @return generated triangulation |
50 | static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theMajorRad, |
51 | const Standard_Real theMinorRad, |
52 | const Standard_Real theAngle, |
53 | const Standard_Integer theNbSlices, |
54 | const Standard_Integer theNbStacks, |
55 | const gp_Trsf& theTrsf) |
56 | { |
57 | return Create (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, theAngle, theNbSlices, theNbStacks, theTrsf); |
58 | } |
59 | |
60 | //! Generate primitives for 3D quadric surface (torus ring segment). |
61 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
62 | //! @param theMinorRad [in] radius of the pipe |
63 | //! @param theAngle1 [in] first angle to create a torus ring segment |
64 | //! @param theAngle2 [in] second angle to create a torus ring segment |
65 | //! @param theNbSlices [in] number of slices within U parameter |
66 | //! @param theNbStacks [in] number of stacks within V parameter |
67 | //! @param theTrsf [in] optional transformation to apply |
68 | //! @return generated triangulation |
69 | static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theMajorRad, |
70 | const Standard_Real theMinorRad, |
71 | const Standard_Real theAngle1, |
72 | const Standard_Real theAngle2, |
73 | const Standard_Integer theNbSlices, |
74 | const Standard_Integer theNbStacks, |
75 | const gp_Trsf& theTrsf) |
76 | { |
77 | return Create (theMajorRad, theMinorRad, theAngle1, theAngle2, M_PI * 2.0, theNbSlices, theNbStacks, theTrsf); |
78 | } |
79 | |
80 | //! Generate primitives for 3D quadric surface (segment of the torus ring segment). |
81 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
82 | //! @param theMinorRad [in] radius of the pipe |
83 | //! @param theAngle1 [in] first angle to create a torus ring segment |
84 | //! @param theAngle2 [in] second angle to create a torus ring segment |
85 | //! @param theAngle [in] angle to create a torus pipe segment |
86 | //! @param theNbSlices [in] number of slices within U parameter |
87 | //! @param theNbStacks [in] number of stacks within V parameter |
88 | //! @param theTrsf [in] optional transformation to apply |
89 | //! @return generated triangulation |
90 | Standard_EXPORT static Handle(Graphic3d_ArrayOfTriangles) Create (const Standard_Real theMajorRad, |
91 | const Standard_Real theMinorRad, |
92 | const Standard_Real theAngle1, |
93 | const Standard_Real theAngle2, |
94 | const Standard_Real theAngle, |
95 | const Standard_Integer theNbSlices, |
96 | const Standard_Integer theNbStacks, |
97 | const gp_Trsf& theTrsf); |
98 | |
99 | public: |
100 | |
101 | //! Initializes the algorithm creating a complete torus. |
102 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
103 | //! @param theMinorRad [in] radius of the pipe |
104 | //! @param theNbSlices [in] number of slices within U parameter |
105 | //! @param theNbStacks [in] number of stacks within V parameter |
106 | Prs3d_ToolTorus (const Standard_Real theMajorRad, |
107 | const Standard_Real theMinorRad, |
108 | const Standard_Integer theNbSlices, |
109 | const Standard_Integer theNbStacks) |
110 | { |
111 | init (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, M_PI * 2.0, theNbSlices, theNbStacks); |
112 | } |
113 | |
114 | //! Initializes the algorithm creating a torus pipe segment. |
115 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
116 | //! @param theMinorRad [in] radius of the pipe |
117 | //! @param theAngle [in] angle to create a torus pipe segment |
118 | //! @param theNbSlices [in] number of slices within U parameter |
119 | //! @param theNbStacks [in] number of stacks within V parameter |
120 | Prs3d_ToolTorus (const Standard_Real theMajorRad, |
121 | const Standard_Real theMinorRad, |
122 | const Standard_Real theAngle, |
123 | const Standard_Integer theNbSlices, |
124 | const Standard_Integer theNbStacks) |
125 | { |
126 | init (theMajorRad, theMinorRad, 0.0, M_PI * 2.0, theAngle, theNbSlices, theNbStacks); |
127 | } |
128 | |
129 | //! Initializes the algorithm creating a torus ring segment. |
130 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
131 | //! @param theMinorRad [in] radius of the pipe |
132 | //! @param theAngle1 [in] first angle to create a torus ring segment |
133 | //! @param theAngle2 [in] second angle to create a torus ring segment |
134 | //! @param theNbSlices [in] number of slices within U parameter |
135 | //! @param theNbStacks [in] number of stacks within V parameter |
136 | Prs3d_ToolTorus (const Standard_Real theMajorRad, |
137 | const Standard_Real theMinorRad, |
138 | const Standard_Real theAngle1, |
139 | const Standard_Real theAngle2, |
140 | const Standard_Integer theNbSlices, |
141 | const Standard_Integer theNbStacks) |
142 | { |
143 | init (theMajorRad, theMinorRad, theAngle1, theAngle2, M_PI * 2.0, theNbSlices, theNbStacks); |
144 | } |
145 | |
146 | //! Initializes the algorithm creating a torus ring segment. |
147 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
148 | //! @param theMinorRad [in] radius of the pipe |
149 | //! @param theAngle1 [in] first angle to create a torus ring segment |
150 | //! @param theAngle2 [in] second angle to create a torus ring segment |
151 | //! @param theAngle [in] angle to create a torus pipe segment |
152 | //! @param theNbSlices [in] number of slices within U parameter |
153 | //! @param theNbStacks [in] number of stacks within V parameter |
154 | Prs3d_ToolTorus (const Standard_Real theMajorRad, |
155 | const Standard_Real theMinorRad, |
156 | const Standard_Real theAngle1, |
157 | const Standard_Real theAngle2, |
158 | const Standard_Real theAngle, |
159 | const Standard_Integer theNbSlices, |
160 | const Standard_Integer theNbStacks) |
161 | { |
162 | init (theMajorRad, theMinorRad, theAngle1, theAngle2, theAngle, theNbSlices, theNbStacks); |
163 | } |
164 | |
165 | private: |
166 | |
167 | //! Initialisation |
168 | //! @param theMajorRad [in] distance from the center of the pipe to the center of the torus |
169 | //! @param theMinorRad [in] radius of the pipe |
170 | //! @param theAngle1 [in] first angle to create a torus ring segment |
171 | //! @param theAngle2 [in] second angle to create a torus ring segment |
172 | //! @param theAngle [in] angle to create a torus pipe segment |
173 | //! @param theNbSlices [in] number of slices within U parameter |
174 | //! @param theNbStacks [in] number of stacks within V parameter |
175 | Standard_EXPORT void init (const Standard_Real theMajorRad, |
176 | const Standard_Real theMinorRad, |
177 | const Standard_Real theAngle1, |
178 | const Standard_Real theAngle2, |
179 | const Standard_Real theAngle, |
180 | const Standard_Integer theNbSlices, |
181 | const Standard_Integer theNbStacks); |
182 | |
183 | protected: |
184 | |
185 | //! Computes vertex at given parameter location of the surface. |
186 | Standard_EXPORT virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE; |
187 | |
188 | //! Computes normal at given parameter location of the surface. |
189 | Standard_EXPORT virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) const Standard_OVERRIDE; |
190 | |
191 | protected: |
192 | |
193 | Standard_Real myMajorRadius; //!< distance from the center of the pipe to the center of the torus |
194 | Standard_Real myMinorRadius; //!< radius of the pipe |
195 | Standard_Real myAngle; //!< angle to create a torus pipe segment |
196 | Standard_Real myVMin; //!< first angle to create a torus ring segment |
197 | Standard_Real myVMax; //!< second angle to create a torus ring segment |
198 | |
199 | }; |
200 | |
201 | #endif // _Prs3d_ToolTorus_HeaderFile |