Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Prs3d_ToolQuadric.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 int TrianglesNb(const int theSlicesNb, const int theStacksNb)
0030   {
0031     return theSlicesNb * theStacksNb * 2;
0032   }
0033 
0034   //! Return number of vertices for presentation with the given params.
0035   static int VerticesNb(const int  theSlicesNb,
0036                         const int  theStacksNb,
0037                         const bool theIsIndexed = true)
0038   {
0039     return theIsIndexed ? (theSlicesNb + 1) * (theStacksNb + 1)
0040                         : TrianglesNb(theSlicesNb, theStacksNb) * 3;
0041   }
0042 
0043 public:
0044   //! Generate primitives for 3D quadric surface presentation.
0045   //! @param[in] theTrsf  optional transformation to apply
0046   //! @return generated triangulation
0047   Standard_EXPORT occ::handle<Graphic3d_ArrayOfTriangles> CreateTriangulation(
0048     const gp_Trsf& theTrsf) const;
0049 
0050   //! Generate primitives for 3D quadric surface presentation.
0051   //! @param[in] theTrsf  optional transformation to apply
0052   //! @return generated triangulation
0053   Standard_EXPORT occ::handle<Poly_Triangulation> CreatePolyTriangulation(
0054     const gp_Trsf& theTrsf) const;
0055 
0056   //! Generate primitives for 3D quadric surface and fill the given array.
0057   //! @param[in][out] theArray  the array of vertices;
0058   //!                           when NULL, function will create an indexed array;
0059   //!                           when not NULL, triangles will be appended to the end of array
0060   //!                           (will raise an exception if reserved array size is not large enough)
0061   //! @param[in] theTrsf  optional transformation to apply
0062   Standard_EXPORT void FillArray(occ::handle<Graphic3d_ArrayOfTriangles>& theArray,
0063                                  const gp_Trsf&                           theTrsf) const;
0064 
0065   //! Return number of triangles in generated presentation.
0066   int TrianglesNb() const { return mySlicesNb * myStacksNb * 2; }
0067 
0068   //! Return number of vertices in generated presentation.
0069   int VerticesNb(bool theIsIndexed = true) const
0070   {
0071     return theIsIndexed ? (mySlicesNb + 1) * (myStacksNb + 1) : TrianglesNb() * 3;
0072   }
0073 
0074 public:
0075   //! Generate primitives for 3D quadric surface presentation.
0076   //! @param[out] theArray  generated array of triangles
0077   //! @param[out] theTriangulation  generated triangulation
0078   //! @param[in] theTrsf  optional transformation to apply
0079   Standard_DEPRECATED(
0080     "Deprecated method, CreateTriangulation() and CreatePolyTriangulation() should be used instead")
0081   Standard_EXPORT void FillArray(occ::handle<Graphic3d_ArrayOfTriangles>& theArray,
0082                                  occ::handle<Poly_Triangulation>&         theTriangulation,
0083                                  const gp_Trsf&                           theTrsf) const;
0084 
0085 protected:
0086   //! Redefine this method to generate vertex at given parameters.
0087   virtual gp_Pnt Vertex(const double theU, const double theV) const = 0;
0088 
0089   //! Redefine this method to generate normal at given parameters.
0090   virtual gp_Dir Normal(const double theU, const double theV) const = 0;
0091 
0092 protected:
0093   int mySlicesNb; //!< number of slices within U parameter
0094   int myStacksNb; //!< number of stacks within V parameter
0095 };
0096 
0097 #endif // _Prs3d_ToolQuadric_HeaderFile