Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:15

0001 // Copyright (c) 2013 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 
0015 #ifndef _BRepMesh_Vertex_HeaderFile
0016 #define _BRepMesh_Vertex_HeaderFile
0017 
0018 #include <Standard.hxx>
0019 #include <Standard_DefineAlloc.hxx>
0020 #include <gp_XY.hxx>
0021 #include <BRepMesh_DegreeOfFreedom.hxx>
0022 #include <Precision.hxx>
0023 
0024 //! Light weighted structure representing vertex 
0025 //! of the mesh in parametric space. Vertex could be 
0026 //! associated with 3d point stored in external map.
0027 class BRepMesh_Vertex
0028 {
0029 public:
0030 
0031   DEFINE_STANDARD_ALLOC
0032   
0033   //! Default constructor
0034   BRepMesh_Vertex()
0035     : myLocation3d(0),
0036       myMovability(BRepMesh_Free)
0037   {
0038   }
0039   
0040   //! Creates vertex associated with point in 3d space.
0041   //! @param theUV position of vertex in parametric space.
0042   //! @param theLocation3d index of 3d point to be associated with vertex.
0043   //! @param theMovability movability of the vertex.
0044   BRepMesh_Vertex(const gp_XY&                   theUV,
0045                   const Standard_Integer         theLocation3d,
0046                   const BRepMesh_DegreeOfFreedom theMovability)
0047   {
0048     Initialize(theUV, theLocation3d, theMovability);
0049   }
0050   
0051   //! Creates vertex without association with point in 3d space.
0052   //! @param theU U position of vertex in parametric space.
0053   //! @param theV V position of vertex in parametric space.
0054   //! @param theMovability movability of the vertex.
0055   BRepMesh_Vertex(const Standard_Real            theU,
0056                   const Standard_Real            theV,
0057                   const BRepMesh_DegreeOfFreedom theMovability)
0058     : myUV(theU, theV),
0059       myLocation3d(0),
0060       myMovability(theMovability)
0061   {}
0062 
0063   //! Initializes vertex associated with point in 3d space.
0064   //! @param theUV position of vertex in parametric space.
0065   //! @param theLocation3d index of 3d point to be associated with vertex.
0066   //! @param theMovability movability of the vertex.
0067   void Initialize(const gp_XY&                   theUV,
0068                   const Standard_Integer         theLocation3d,
0069                   const BRepMesh_DegreeOfFreedom theMovability)
0070   {
0071     myUV         = theUV;
0072     myLocation3d = theLocation3d;
0073     myMovability = theMovability;
0074   }
0075   
0076   //! Returns position of the vertex in parametric space.
0077   const gp_XY& Coord() const
0078   {
0079     return myUV;
0080   }
0081 
0082   //! Returns position of the vertex in parametric space for modification.
0083   gp_XY& ChangeCoord()
0084   {
0085     return myUV;
0086   }
0087   
0088   //! Returns index of 3d point associated with the vertex.
0089   Standard_Integer Location3d() const
0090   {
0091     return myLocation3d;
0092   }
0093   
0094   //! Returns movability of the vertex.
0095   BRepMesh_DegreeOfFreedom Movability() const
0096   {
0097     return myMovability;
0098   }
0099   
0100   //! Sets movability of the vertex.
0101   void SetMovability(const BRepMesh_DegreeOfFreedom theMovability)
0102   {
0103     myMovability = theMovability;
0104   }
0105   
0106   //! Checks for equality with another vertex.
0107   //! @param theOther vertex to be checked against this one.
0108   //! @return TRUE if equal, FALSE if not.
0109   Standard_Boolean IsEqual(const BRepMesh_Vertex& theOther) const
0110   {
0111     if (myMovability          == BRepMesh_Deleted || 
0112         theOther.myMovability == BRepMesh_Deleted)
0113     {
0114       return Standard_False;
0115     }
0116 
0117     return (myUV.IsEqual(theOther.myUV, Precision::PConfusion()));
0118   }
0119 
0120   //! Alias for IsEqual.
0121   Standard_Boolean operator ==(const BRepMesh_Vertex& Other) const
0122   {
0123     return IsEqual(Other);
0124   }
0125 
0126 private:
0127 
0128   gp_XY                     myUV;
0129   Standard_Integer          myLocation3d;
0130   BRepMesh_DegreeOfFreedom  myMovability;
0131 };
0132 
0133 namespace std
0134 {
0135   template <>
0136   struct hash<BRepMesh_Vertex>
0137   {
0138     size_t operator()(const BRepMesh_Vertex& theVertex) const noexcept
0139     {
0140       return std::hash<double>{}((Floor(1e5 * theVertex.Coord().X()) * Floor(1e5 * theVertex.Coord().Y())));
0141     }
0142   };
0143 }
0144 
0145 #endif