Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:40

0001 // Created on: 2016-02-04
0002 // Created by: Anastasia BORISOVA
0003 // Copyright (c) 2016 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Prs3d_ToolQuadric_HeaderFile
0017 #define _Prs3d_ToolQuadric_HeaderFile
0018 
0019 #include <Graphic3d_ArrayOfTriangles.hxx>
0020 #include <Poly_Triangulation.hxx>
0021 
0022 //! Base class to build 3D surfaces presentation of quadric surfaces.
0023 class Prs3d_ToolQuadric
0024 {
0025 public:
0026   DEFINE_STANDARD_ALLOC
0027 
0028   //! Return number of triangles for presentation with the given params.
0029   static Standard_Integer TrianglesNb (const Standard_Integer theSlicesNb,
0030                                        const Standard_Integer theStacksNb)
0031   {
0032     return theSlicesNb * theStacksNb * 2;
0033   }
0034 
0035   //! Return number of vertices for presentation with the given params.
0036   static Standard_Integer VerticesNb (const Standard_Integer theSlicesNb,
0037                                       const Standard_Integer theStacksNb,
0038                                       const Standard_Boolean theIsIndexed = Standard_True)
0039   {
0040     return theIsIndexed
0041       ? (theSlicesNb + 1) * (theStacksNb + 1)
0042       : TrianglesNb (theSlicesNb, theStacksNb) * 3;
0043   }
0044 
0045 public:
0046 
0047   //! Generate primitives for 3D quadric surface presentation.
0048   //! @param theTrsf [in] optional transformation to apply
0049   //! @return generated triangulation
0050   Standard_EXPORT Handle(Graphic3d_ArrayOfTriangles) CreateTriangulation (const gp_Trsf& theTrsf) const;
0051 
0052   //! Generate primitives for 3D quadric surface presentation.
0053   //! @param theTrsf [in] optional transformation to apply
0054   //! @return generated triangulation
0055   Standard_EXPORT Handle(Poly_Triangulation) CreatePolyTriangulation (const gp_Trsf& theTrsf) const;
0056 
0057   //! Generate primitives for 3D quadric surface and fill the given array.
0058   //! @param theArray [in][out] the array of vertices;
0059   //!                           when NULL, function will create an indexed array;
0060   //!                           when not NULL, triangles will be appended to the end of array
0061   //!                           (will raise an exception if reserved array size is not large enough)
0062   //! @param theTrsf [in] optional transformation to apply
0063   Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
0064                                   const gp_Trsf& theTrsf) const;
0065 
0066   //! Return number of triangles in generated presentation.
0067   Standard_Integer TrianglesNb() const { return mySlicesNb * myStacksNb * 2; }
0068 
0069   //! Return number of vertices in generated presentation.
0070   Standard_Integer VerticesNb (bool theIsIndexed = true) const
0071   {
0072     return theIsIndexed
0073          ? (mySlicesNb + 1) * (myStacksNb + 1)
0074          : TrianglesNb() * 3;
0075   }
0076 
0077 public:
0078 
0079   //! Generate primitives for 3D quadric surface presentation.
0080   //! @param theArray [out] generated array of triangles
0081   //! @param theTriangulation [out] generated triangulation
0082   //! @param theTrsf [in] optional transformation to apply
0083   Standard_DEPRECATED("Deprecated method, CreateTriangulation() and CreatePolyTriangulation() should be used instead")
0084   Standard_EXPORT void FillArray (Handle(Graphic3d_ArrayOfTriangles)& theArray,
0085                                   Handle(Poly_Triangulation)& theTriangulation,
0086                                   const gp_Trsf& theTrsf) const;
0087 
0088 protected:
0089 
0090   //! Redefine this method to generate vertex at given parameters.
0091   virtual gp_Pnt Vertex (const Standard_Real theU, const Standard_Real theV) const = 0;
0092 
0093   //! Redefine this method to generate normal at given parameters.
0094   virtual gp_Dir Normal (const Standard_Real theU, const Standard_Real theV) const = 0;
0095 
0096 protected:
0097 
0098   Standard_Integer mySlicesNb; //!< number of slices within U parameter
0099   Standard_Integer myStacksNb; //!< number of stacks within V parameter
0100 };
0101 
0102 #endif // _Prs3d_ToolQuadric_HeaderFile