0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Prs3d / Prs3d_ToolQuadric.hxx
1 // Created on: 2016-02-04
2 // Created by: Anastasia BORISOVA
3 // Copyright (c) 2016 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_ToolQuadric_HeaderFile
17 #define _Prs3d_ToolQuadric_HeaderFile
18
19 #include <Graphic3d_ArrayOfTriangles.hxx>
20 #include <Poly_Triangulation.hxx>
21
22 //! Base class to build 3D surfaces presentation of quadric surfaces.
23 class Prs3d_ToolQuadric
24 {
25 public:
26   DEFINE_STANDARD_ALLOC
27
28   //! Return number of triangles for presentation with the given params.
29   static Standard_Integer TrianglesNb (const Standard_Integer theSlicesNb,
30                                        const Standard_Integer theStacksNb)
31   {
32     return theSlicesNb * theStacksNb * 2;
33   }
34
35   //! Return number of vertices for presentation with the given params.
36   static Standard_Integer VerticesNb (const Standard_Integer theSlicesNb,
37                                       const Standard_Integer theStacksNb,
38                                       const Standard_Boolean theIsIndexed = Standard_True)
39   {
40     return theIsIndexed
41       ? (theSlicesNb + 1) * (theStacksNb + 1)
42       : TrianglesNb (theSlicesNb, theStacksNb) * 3;
43   }
44
45 public:
46
47   //! Generate primitives for 3D quadric surface presentation.
48   //! @param theTrsf [in] optional transformation to apply
49   //! @return generated triangulation
50   Standard_EXPORT Handle(Graphic3d_ArrayOfTriangles) CreateTriangulation (const gp_Trsf& theTrsf) const;
51
52   //! Generate primitives for 3D quadric surface presentation.
53   //! @param theTrsf [in] optional transformation to apply
54   //! @return generated triangulation
55   Standard_EXPORT Handle(Poly_Triangulation) CreatePolyTriangulation (const gp_Trsf& theTrsf) const;
56
57   //! Generate primitives for 3D quadric surface and fill the given array.
58   //! @param theArray [in][out] the array of vertices;
59   //!                           when NULL, function will create an indexed array;
60   //!                           when not NULL, triangles will be appended to the end of array
61   //!                           (will raise an exception if reserved array size is not large enough)
62   //! @param theTrsf [in] optional transformation to apply
63   Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
64                                   const gp_Trsf& theTrsf) const;
65
66   //! Return number of triangles in generated presentation.
67   Standard_Integer TrianglesNb() const { return mySlicesNb * myStacksNb * 2; }
68
69   //! Return number of vertices in generated presentation.
70   Standard_Integer VerticesNb (bool theIsIndexed = true) const
71   {
72     return theIsIndexed
73          ? (mySlicesNb + 1) * (myStacksNb + 1)
74          : TrianglesNb() * 3;
75   }
76
77 public:
78
79   //! Generate primitives for 3D quadric surface presentation.
80   //! @param theArray [out] generated array of triangles
81   //! @param theTriangulation [out] generated triangulation
82   //! @param theTrsf [in] optional transformation to apply
83   Standard_DEPRECATED("Deprecated method, CreateTriangulation() and CreatePolyTriangulation() should be used instead")
84   Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
85                                   Handle(Poly_Triangulation)& theTriangulation,
86                                   const gp_Trsf& theTrsf) const;
87
88 protected:
89
90   //! Redefine this method to generate vertex at given parameters.
91   virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const = 0;
92
93   //! Redefine this method to generate normal at given parameters.
94   virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) const = 0;
95
96 protected:
97
98   Standard_Integer mySlicesNb; //!< number of slices within U parameter
99   Standard_Integer myStacksNb; //!< number of stacks within V parameter
100 };
101
102 #endif // _Prs3d_ToolQuadric_HeaderFile