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 <BRepMesh_DegreeOfFreedom.hxx>
20 #include <Precision.hxx>
22 //! Light weighted structure representing vertex
23 //! of the mesh in parametric space. Vertex could be
24 //! associated with 3d point stored in external map.
31 //! Default constructor
34 myMovability(BRepMesh_Free)
38 //! Creates vertex associated with point in 3d space.
39 //! @param theUV position of vertex in parametric space.
40 //! @param theLocation3d index of 3d point to be associated with vertex.
41 //! @param theMovability movability of the vertex.
42 BRepMesh_Vertex(const gp_XY& theUV,
43 const Standard_Integer theLocation3d,
44 const BRepMesh_DegreeOfFreedom theMovability)
46 Initialize(theUV, theLocation3d, theMovability);
49 //! Creates vertex without association with point in 3d space.
50 //! @param theU U position of vertex in parametric space.
51 //! @param theV V position of vertex in parametric space.
52 //! @param theMovability movability of the vertex.
53 BRepMesh_Vertex(const Standard_Real theU,
54 const Standard_Real theV,
55 const BRepMesh_DegreeOfFreedom theMovability)
58 myMovability(theMovability)
61 //! Initializes vertex associated with point in 3d space.
62 //! @param theUV position of vertex in parametric space.
63 //! @param theLocation3d index of 3d point to be associated with vertex.
64 //! @param theMovability movability of the vertex.
65 inline void Initialize(const gp_XY& theUV,
66 const Standard_Integer theLocation3d,
67 const BRepMesh_DegreeOfFreedom theMovability)
70 myLocation3d = theLocation3d;
71 myMovability = theMovability;
74 //! Returns position of the vertex in parametric space.
75 inline const gp_XY& Coord() const
80 //! Returns position of the vertex in parametric space for modification.
81 inline gp_XY& ChangeCoord()
86 //! Returns index of 3d point associated with the vertex.
87 inline Standard_Integer Location3d() const
92 //! Returns movability of the vertex.
93 inline BRepMesh_DegreeOfFreedom Movability() const
98 //! Sets movability of the vertex.
99 inline void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
101 myMovability = theMovability;
104 //! Returns hash code for this vertex.
105 //! @param theUpper upper index in the container.
106 //! @return hash code.
107 Standard_Integer HashCode(const Standard_Integer Upper) const
109 return ::HashCode(Floor(1e5 * myUV.X()) * Floor(1e5 * myUV.Y()), Upper);
112 //! Checks for equality with another vertex.
113 //! @param theOther vertex to be checked against this one.
114 //! @return TRUE if equal, FALSE if not.
115 Standard_Boolean IsEqual(const BRepMesh_Vertex& theOther) const
117 if (myMovability == BRepMesh_Deleted ||
118 theOther.myMovability == BRepMesh_Deleted)
120 return Standard_False;
123 return (myUV.IsEqual(theOther.myUV, Precision::PConfusion()));
126 //! Alias for IsEqual.
127 Standard_Boolean operator ==(const BRepMesh_Vertex& Other) const
129 return IsEqual(Other);
135 Standard_Integer myLocation3d;
136 BRepMesh_DegreeOfFreedom myMovability;
139 inline Standard_Integer HashCode(const BRepMesh_Vertex& me, const Standard_Integer Upper)
141 return me.HashCode(Upper);