1 // Copyright (c) 2013 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #ifndef _BRepMesh_Vertex_HeaderFile
16 #define _BRepMesh_Vertex_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Macro.hxx>
22 #include <BRepMesh_DegreeOfFreedom.hxx>
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.
33 //! Default constructor
34 Standard_EXPORT BRepMesh_Vertex()
36 myMovability(BRepMesh_Free)
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)
48 Initialize(theUV, theLocation3d, theMovability);
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)
60 myMovability(theMovability)
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)
72 myLocation3d = theLocation3d;
73 myMovability = theMovability;
76 //! Returns position of the vertex in parametric space.
77 inline const gp_XY& Coord() const
82 //! Returns position of the vertex in parametric space for modification.
83 inline gp_XY& ChangeCoord()
88 //! Returns index of 3d point associated with the vertex.
89 inline Standard_Integer Location3d() const
94 //! Returns movability of the vertex.
95 inline BRepMesh_DegreeOfFreedom Movability() const
100 //! Sets movability of the vertex.
101 inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
103 myMovability = theMovability;
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
111 return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), Upper);
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
119 if (myMovability == BRepMesh_Deleted ||
120 theOther.myMovability == BRepMesh_Deleted)
122 return Standard_False;
125 return (myUV.IsEqual(theOther.myUV, Precision::PConfusion()));
128 //! Alias for IsEqual.
129 Standard_EXPORT Standard_Boolean operator ==(const BRepMesh_Vertex& Other) const
131 return IsEqual(Other);
137 Standard_Integer myLocation3d;
138 BRepMesh_DegreeOfFreedom myMovability;
141 inline Standard_Integer HashCode(const BRepMesh_Vertex& me, const Standard_Integer Upper)
143 return me.HashCode(Upper);