Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/BRepMesh_Vertex.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 #ifndef _BRepMesh_Vertex_HeaderFile
0015 #define _BRepMesh_Vertex_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 #include <gp_XY.hxx>
0020 #include <BRepMesh_DegreeOfFreedom.hxx>
0021 #include <Precision.hxx>
0022 
0023 //! Light weighted structure representing vertex
0024 //! of the mesh in parametric space. Vertex could be
0025 //! associated with 3d point stored in external map.
0026 class BRepMesh_Vertex
0027 {
0028 public:
0029   DEFINE_STANDARD_ALLOC
0030 
0031   //! Default constructor
0032   BRepMesh_Vertex()
0033       : myLocation3d(0),
0034         myMovability(BRepMesh_Free)
0035   {
0036   }
0037 
0038   //! Creates vertex associated with point in 3d space.
0039   //! @param theUV position of vertex in parametric space.
0040   //! @param theLocation3d index of 3d point to be associated with vertex.
0041   //! @param theMovability movability of the vertex.
0042   BRepMesh_Vertex(const gp_XY&                   theUV,
0043                   const int                      theLocation3d,
0044                   const BRepMesh_DegreeOfFreedom theMovability)
0045   {
0046     Initialize(theUV, theLocation3d, theMovability);
0047   }
0048 
0049   //! Creates vertex without association with point in 3d space.
0050   //! @param theU U position of vertex in parametric space.
0051   //! @param theV V position of vertex in parametric space.
0052   //! @param theMovability movability of the vertex.
0053   BRepMesh_Vertex(const double                   theU,
0054                   const double                   theV,
0055                   const BRepMesh_DegreeOfFreedom theMovability)
0056       : myUV(theU, theV),
0057         myLocation3d(0),
0058         myMovability(theMovability)
0059   {
0060   }
0061 
0062   //! Initializes vertex associated with point in 3d space.
0063   //! @param theUV position of vertex in parametric space.
0064   //! @param theLocation3d index of 3d point to be associated with vertex.
0065   //! @param theMovability movability of the vertex.
0066   void Initialize(const gp_XY&                   theUV,
0067                   const int                      theLocation3d,
0068                   const BRepMesh_DegreeOfFreedom theMovability)
0069   {
0070     myUV         = theUV;
0071     myLocation3d = theLocation3d;
0072     myMovability = theMovability;
0073   }
0074 
0075   //! Returns position of the vertex in parametric space.
0076   const gp_XY& Coord() const { return myUV; }
0077 
0078   //! Returns position of the vertex in parametric space for modification.
0079   gp_XY& ChangeCoord() { return myUV; }
0080 
0081   //! Returns index of 3d point associated with the vertex.
0082   int Location3d() const { return myLocation3d; }
0083 
0084   //! Returns movability of the vertex.
0085   BRepMesh_DegreeOfFreedom Movability() const { return myMovability; }
0086 
0087   //! Sets movability of the vertex.
0088   void SetMovability(const BRepMesh_DegreeOfFreedom theMovability) { myMovability = theMovability; }
0089 
0090   //! Checks for equality with another vertex.
0091   //! @param theOther vertex to be checked against this one.
0092   //! @return TRUE if equal, FALSE if not.
0093   bool IsEqual(const BRepMesh_Vertex& theOther) const
0094   {
0095     if (myMovability == BRepMesh_Deleted || theOther.myMovability == BRepMesh_Deleted)
0096     {
0097       return false;
0098     }
0099 
0100     return (myUV.IsEqual(theOther.myUV, Precision::PConfusion()));
0101   }
0102 
0103   //! Alias for IsEqual.
0104   bool operator==(const BRepMesh_Vertex& Other) const { return IsEqual(Other); }
0105 
0106 private:
0107   gp_XY                    myUV;
0108   int                      myLocation3d;
0109   BRepMesh_DegreeOfFreedom myMovability;
0110 };
0111 
0112 namespace std
0113 {
0114 template <>
0115 struct hash<BRepMesh_Vertex>
0116 {
0117   size_t operator()(const BRepMesh_Vertex& theVertex) const noexcept
0118   {
0119     return std::hash<double>{}(
0120       (std::floor(1e5 * theVertex.Coord().X()) * std::floor(1e5 * theVertex.Coord().Y())));
0121   }
0122 };
0123 } // namespace std
0124 
0125 #endif