0024947: Redesign OCCT legacy type system -- automatic
[occt.git] / src / OpenGl / OpenGl_Quadric.hxx
CommitLineData
c827ea3a 1// Created on: 2014-10-15
2// Created by: Denis Bogolepov
3// Copyright (c) 2014 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 OpenGl_Quadric_Header
17#define OpenGl_Quadric_Header
18
19#include <OpenGl_PrimitiveArray.hxx>
20
21//! Class for rendering of arbitrary primitive array.
22//! Tool class for generating tessellation of quadric surface.
23class OpenGl_Quadric : public OpenGl_PrimitiveArray
24{
25public:
26
27 //! Creates undefined abstract quadric surface
28 Standard_EXPORT OpenGl_Quadric();
29
30 //! Returns true if quadric has been defined
31 Standard_Boolean IsDefined() const { return myNbSlices != 0; }
32
33 //! Returns number of slices
34 Standard_Integer NbSlices() const { return myNbSlices; }
35
36 //! Returns number of stacks
37 Standard_Integer NbStacks() const { return myNbStacks; }
38
39 //! Returns total number of vertices
40 Standard_Integer NbVertices() const { return (myNbSlices + 1) * (myNbStacks + 1); }
41
42 //! Returns total number of triangles
43 Standard_Integer NbTriangles() const { return myNbSlices * myNbStacks * 2; }
44
45 //! Release GL resources
46 virtual void Release (OpenGl_Context* theContext) Standard_OVERRIDE;
47
48protected:
49
50 //! Returns surface point for the given parameters.
51 virtual OpenGl_Vec3 evalVertex (const Standard_ShortReal theU,
52 const Standard_ShortReal theV) const = 0;
53
54 //! Returns surface normal for the given parameters.
55 virtual OpenGl_Vec3 evalNormal (const Standard_ShortReal theU,
56 const Standard_ShortReal theV) const = 0;
57
58 //! Initialize primitive.
59 Standard_EXPORT Standard_Boolean init (const Standard_Integer theNbSlices,
60 const Standard_Integer theNbStacks);
61
62private:
63
64 //! Initialize arrays.
65 Standard_Boolean createArrays() const;
66
67private:
68
69 Standard_Integer myNbSlices; //!< Number of slices (u partitions)
70 Standard_Integer myNbStacks; //!< Number of stacks (v partitions)
71
72};
73
74#endif // OpenGl_Quadric_Header