Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 2011-06-01
0002 // Created by: Oleg AGASHIN
0003 // Copyright (c) 2011-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BRepMesh_VertexInspector_HeaderFile
0017 #define _BRepMesh_VertexInspector_HeaderFile
0018 
0019 #include <Precision.hxx>
0020 #include <gp_XY.hxx>
0021 #include <IMeshData_Types.hxx>
0022 #include <NCollection_CellFilter.hxx>
0023 #include <BRepMesh_Vertex.hxx>
0024 
0025 //! Class intended for fast searching of the coincidence points.
0026 class BRepMesh_VertexInspector : public NCollection_CellFilter_InspectorXY
0027 {
0028 public:
0029   typedef Standard_Integer Target;
0030 
0031   //! Constructor.
0032   //! @param theAllocator memory allocator to be used by internal collections.
0033   BRepMesh_VertexInspector(
0034     const Handle(NCollection_IncAllocator)& theAllocator)
0035     : myIndex(0),
0036       myMinSqDist(RealLast()),
0037       myVertices(new IMeshData::VectorOfVertex),
0038       myDelNodes(theAllocator)
0039   {
0040     SetTolerance(Precision::Confusion());
0041   }
0042 
0043   //! Registers the given vertex.
0044   //! @param theVertex vertex to be registered.
0045   Standard_Integer Add(const BRepMesh_Vertex& theVertex)
0046   {
0047     if( myDelNodes.IsEmpty() )
0048     {
0049       myVertices->Append(theVertex);
0050       return myVertices->Length();
0051     }
0052     
0053     Standard_Integer aNodeIndex = myDelNodes.First();
0054     myVertices->ChangeValue(aNodeIndex - 1) = theVertex;
0055     myDelNodes.RemoveFirst();
0056     return aNodeIndex;
0057   }
0058   
0059 
0060   //! Sets the tolerance to be used for identification of 
0061   //! coincident vertices equal for both dimensions.
0062   void SetTolerance(const Standard_Real theTolerance)
0063   {
0064     myTolerance[0] = theTolerance * theTolerance;
0065     myTolerance[1] = 0.;
0066   }
0067   
0068   //! Sets the tolerance to be used for identification of 
0069   //! coincident vertices.
0070   //! @param theToleranceX tolerance for X dimension.
0071   //! @param theToleranceY tolerance for Y dimension.
0072   void SetTolerance(const Standard_Real theToleranceX,
0073                     const Standard_Real theToleranceY)
0074   {
0075     myTolerance[0] = theToleranceX * theToleranceX;
0076     myTolerance[1] = theToleranceY * theToleranceY;
0077   }
0078   
0079   //! Clear inspector's internal data structures.
0080   void Clear()
0081   {
0082     myVertices->Clear();
0083     myDelNodes.Clear();
0084   }
0085 
0086   //! Deletes vertex with the given index.
0087   //! @param theIndex index of vertex to be removed.
0088   void Delete(const Standard_Integer theIndex)
0089   {
0090     myVertices->ChangeValue(theIndex - 1).SetMovability(BRepMesh_Deleted);
0091     myDelNodes.Append(theIndex);
0092   }
0093   
0094   //! Returns number of registered vertices.
0095   Standard_Integer NbVertices() const
0096   {
0097     return myVertices->Length(); 
0098   }
0099 
0100   //! Returns vertex with the given index.
0101   BRepMesh_Vertex& GetVertex(Standard_Integer theIndex)
0102   {
0103     return myVertices->ChangeValue(theIndex - 1);
0104   }
0105   
0106   //! Set reference point to be checked.
0107   void SetPoint(const gp_XY& thePoint) 
0108   { 
0109     myIndex     = 0;
0110     myMinSqDist = RealLast();
0111     myPoint     = thePoint;
0112   }
0113 
0114   //! Returns index of point coinciding with regerence one.
0115   Standard_Integer GetCoincidentPoint() const
0116   {
0117     return myIndex;
0118   }
0119   
0120   //! Returns list with indexes of vertices that have movability attribute 
0121   //! equal to BRepMesh_Deleted and can be replaced with another node.
0122   const IMeshData::ListOfInteger& GetListOfDelPoints() const
0123   {
0124     return myDelNodes;
0125   }
0126 
0127   //! Returns set of mesh vertices.
0128   const Handle(IMeshData::VectorOfVertex)& Vertices() const
0129   {
0130     return myVertices;
0131   }
0132 
0133   //! Returns set of mesh vertices for modification.
0134   Handle(IMeshData::VectorOfVertex)& ChangeVertices()
0135   {
0136     return myVertices;
0137   }
0138 
0139   //! Performs inspection of a point with the given index.
0140   //! @param theTargetIndex index of a circle to be checked.
0141   //! @return status of the check.
0142   Standard_EXPORT NCollection_CellFilter_Action Inspect(const Standard_Integer theTargetIndex);
0143 
0144   //! Checks indices for equlity.
0145   static Standard_Boolean IsEqual(const Standard_Integer theIndex,
0146                                                   const Standard_Integer theTargetIndex)
0147   {
0148     return (theIndex == theTargetIndex);
0149   }
0150 
0151 private:
0152 
0153   Standard_Integer                  myIndex;
0154   Standard_Real                     myMinSqDist;
0155   Standard_Real                     myTolerance[2];
0156   Handle(IMeshData::VectorOfVertex) myVertices;
0157   IMeshData::ListOfInteger          myDelNodes;
0158   gp_XY                             myPoint;
0159 };
0160 
0161 #endif