1 // Created on: 2014-10-15
2 // Created by: Denis Bogolepov
3 // Copyright (c) 2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef OpenGl_Quadric_Header
17 #define OpenGl_Quadric_Header
19 #include <OpenGl_PrimitiveArray.hxx>
21 //! Class for rendering of arbitrary primitive array.
22 //! Tool class for generating tessellation of quadric surface.
23 class OpenGl_Quadric : public OpenGl_PrimitiveArray
27 //! Creates undefined abstract quadric surface
28 Standard_EXPORT OpenGl_Quadric();
30 //! Returns true if quadric has been defined
31 Standard_Boolean IsDefined() const { return myNbSlices != 0; }
33 //! Returns number of slices
34 Standard_Integer NbSlices() const { return myNbSlices; }
36 //! Returns number of stacks
37 Standard_Integer NbStacks() const { return myNbStacks; }
39 //! Returns total number of vertices
40 Standard_Integer NbVertices() const { return (myNbSlices + 1) * (myNbStacks + 1); }
42 //! Returns total number of triangles
43 Standard_Integer NbTriangles() const { return myNbSlices * myNbStacks * 2; }
45 //! Release GL resources
46 virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
50 //! Returns surface point for the given parameters.
51 virtual OpenGl_Vec3 evalVertex (const Standard_ShortReal theU,
52 const Standard_ShortReal theV) const = 0;
54 //! Returns surface normal for the given parameters.
55 virtual OpenGl_Vec3 evalNormal (const Standard_ShortReal theU,
56 const Standard_ShortReal theV) const = 0;
58 //! Initialize primitive.
59 Standard_EXPORT Standard_Boolean init (const Standard_Integer theNbSlices,
60 const Standard_Integer theNbStacks);
64 //! Initialize arrays.
65 Standard_Boolean createArrays() const;
69 Standard_Integer myNbSlices; //!< Number of slices (u partitions)
70 Standard_Integer myNbStacks; //!< Number of stacks (v partitions)
74 #endif // OpenGl_Quadric_Header