0025936: Reusable data structure for 2D tesselation (3- and 4-nodal mesh)
[occt.git] / src / Poly / Poly_Mesh.hxx
1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _Poly_Mesh_HeaderFile
15 #define _Poly_Mesh_HeaderFile
16
17 #include <Poly_Element.hxx>
18 #include <Poly_Triangulation.hxx>
19
20 //! This class is extension for Poly_Triangulation.
21 //! It allows to store mesh with quad polygons as table of Poly_Element.
22 //! Keep in mind that when you add a triangle, it is also added to the table of elements
23 //! as Poly_Element. And it will have first index set to triangle index from Poly_Triangulation
24 //! and second index will be set to 0.
25 class Poly_Mesh : public Poly_Triangulation
26 {
27
28 public:
29
30   //! Constructs an empty mesh.
31   //! theHasUVNodes flag indicates whether 2D nodes will be associated with 3D ones, (i.e. to enable a 2D representation).
32   Standard_EXPORT Poly_Mesh (const Standard_Boolean theHasUVNodes = Standard_False);
33
34   //! Adds triangle to the mesh.
35   //! @return index of the added element.
36   Standard_EXPORT Standard_Integer AddTriangle (const Poly_Triangle& theTriangle) Standard_OVERRIDE;
37
38   //! Adds element to the mesh.
39   //! @return index of the added element.
40   //! Raises exception if at least one of the element indices is less than 1 or greater than NbTriangles.
41   Standard_EXPORT Standard_Integer AddElement (const Poly_Element& theElement);
42
43   //! @return the number of elements for this mesh.
44   Standard_Integer NbElements() const { return myElements.Size(); }
45
46   //! @return the number of quads for this mesh.
47   Standard_Integer NbQuads() const { return myNbQuads; }
48
49   //! @return element at the given index.
50   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
51   Standard_EXPORT const Poly_Element& Element (const Standard_Integer theIndex);
52
53   //! Give access to the element at the given index.
54   //! Raises Standard_OutOfRange exception if theIndex is less than 1 or greater than NbElements.
55   Standard_EXPORT void SetElement (const Standard_Integer theIndex, const Poly_Element& theElement);
56
57 private:
58
59   NCollection_Vector<Poly_Element> myElements;
60   Standard_Integer                 myNbQuads;
61
62 public:
63
64   DEFINE_STANDARD_RTTI(Poly_Mesh)
65
66 };
67
68 DEFINE_STANDARD_HANDLE(Poly_Mesh, Poly_Triangulation)
69
70 #endif // _Poly_Mesh_HeaderFile