0027232: Configuration - fix mblen missing building issue on Android
[occt.git] / src / BRepMesh / BRepMesh_Vertex.hxx
1 // Copyright (c) 2013 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
15 #ifndef _BRepMesh_Vertex_HeaderFile
16 #define _BRepMesh_Vertex_HeaderFile
17
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Macro.hxx>
21 #include <gp_XY.hxx>
22 #include <BRepMesh_DegreeOfFreedom.hxx>
23
24 //! Light weighted structure representing vertex 
25 //! of the mesh in parametric space. Vertex could be 
26 //! associated with 3d point stored in external map.
27 class BRepMesh_Vertex
28 {
29 public:
30
31   DEFINE_STANDARD_ALLOC
32   
33   //! Default constructor
34   Standard_EXPORT BRepMesh_Vertex()
35     : myLocation3d(0),
36       myMovability(BRepMesh_Free)
37   {
38   }
39   
40   //! Creates vertex associated with point in 3d space.
41   //! @param theUV position of vertex in parametric space.
42   //! @param theLocation3d index of 3d point to be associated with vertex.
43   //! @param theMovability movability of the vertex.
44   Standard_EXPORT BRepMesh_Vertex(const gp_XY&                   theUV,
45                                   const Standard_Integer         theLocation3d,
46                                   const BRepMesh_DegreeOfFreedom theMovability)
47   {
48     Initialize(theUV, theLocation3d, theMovability);
49   }
50   
51   //! Creates vertex without association with point in 3d space.
52   //! @param theU U position of vertex in parametric space.
53   //! @param theV V position of vertex in parametric space.
54   //! @param theMovability movability of the vertex.
55   Standard_EXPORT BRepMesh_Vertex(const Standard_Real            theU,
56                                   const Standard_Real            theV,
57                                   const BRepMesh_DegreeOfFreedom theMovability)
58     : myUV(theU, theV),
59       myLocation3d(0),
60       myMovability(theMovability)
61   {}
62
63   //! Initializes vertex associated with point in 3d space.
64   //! @param theUV position of vertex in parametric space.
65   //! @param theLocation3d index of 3d point to be associated with vertex.
66   //! @param theMovability movability of the vertex.
67   inline void Initialize(const gp_XY&                   theUV,
68                          const Standard_Integer         theLocation3d,
69                          const BRepMesh_DegreeOfFreedom theMovability)
70   {
71     myUV         = theUV;
72     myLocation3d = theLocation3d;
73     myMovability = theMovability;
74   }
75   
76   //! Returns position of the vertex in parametric space.
77   inline const gp_XY& Coord() const
78   {
79     return myUV;
80   }
81
82   //! Returns position of the vertex in parametric space for modification.
83   inline gp_XY& ChangeCoord()
84   {
85     return myUV;
86   }
87   
88   //! Returns index of 3d point associated with the vertex.
89   inline Standard_Integer Location3d() const
90   {
91     return myLocation3d;
92   }
93   
94   //! Returns movability of the vertex.
95   inline BRepMesh_DegreeOfFreedom Movability() const
96   {
97     return myMovability;
98   }
99   
100   //! Sets movability of the vertex.
101   inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
102   {
103     myMovability = theMovability;
104   }
105   
106   //! Returns hash code for this vertex.
107   //! @param theUpper upper index in the container.
108   //! @return hash code.
109   Standard_EXPORT Standard_Integer HashCode(const Standard_Integer Upper) const
110   {
111     return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), Upper);
112   }
113   
114   //! Checks for equality with another vertex.
115   //! @param theOther vertex to be checked against this one.
116   //! @return TRUE if equal, FALSE if not.
117   Standard_EXPORT Standard_Boolean IsEqual(const BRepMesh_Vertex& theOther) const
118   {
119     if (myMovability          == BRepMesh_Deleted || 
120         theOther.myMovability == BRepMesh_Deleted)
121     {
122       return Standard_False;
123     }
124
125     return (myUV.IsEqual(theOther.myUV, Precision::PConfusion()));
126   }
127
128   //! Alias for IsEqual.
129   Standard_EXPORT Standard_Boolean operator ==(const BRepMesh_Vertex& Other) const
130   {
131     return IsEqual(Other);
132   }
133
134 private:
135
136   gp_XY                     myUV;
137   Standard_Integer          myLocation3d;
138   BRepMesh_DegreeOfFreedom  myMovability;
139 };
140
141 inline Standard_Integer HashCode(const BRepMesh_Vertex& me, const Standard_Integer Upper)
142 {
143  return me.HashCode(Upper);
144 }
145
146 #endif