summaryrefslogtreecommitdiff
path: root/inc/BRepMesh_VertexInspector.hxx
blob: fd045882938d26b977ca6a7e6708ef2097360d73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// File:        BRepMesh_VertexInspector.hxx
// Created:     Jun 1 18:13:23 2011
// Author:      Oleg AGASHIN
// Copyright:   Open CASCADE SAS 2011


#ifndef _BRepMesh_VertexInspector_HeaderFile
#define _BRepMesh_VertexInspector_HeaderFile

#include <BRepMesh_ListOfInteger.hxx> 
#ifndef _Precision_HeaderFile
#include <Precision.hxx>
#endif
#ifndef _gp_XY_HeaderFile
#include <gp_XY.hxx>
#endif
#ifndef _gp_XYZ_HeaderFile
#include <gp_XYZ.hxx>
#endif

#ifndef NCollection_CellFilter_HeaderFile
#include <NCollection_CellFilter.hxx>
#endif
#ifndef _BRepMesh_Vertex_HeaderFile
#include <BRepMesh_Vertex.hxx>
#endif
#ifndef _BRepMesh_VectorOfVertex_HeaderFile
#include <BRepMesh_VectorOfVertex.hxx>
#endif
#ifndef _TColStd_Array1OfReal_HeaderFile
#include <TColStd_Array1OfReal.hxx>
#endif
#include <BRepMesh_BaseAllocator.hxx>

//=======================================================================
//! The class to find in the coincidence points 
//=======================================================================

class BRepMesh_VertexInspector : public NCollection_CellFilter_InspectorXY
{
public:
  typedef Standard_Integer Target;
  //! Constructor; remembers tolerance and collector data structure.
  //! theTol can be Real or Array1OfReal with two elements which describe
  //! tolerance for each dimension.
  BRepMesh_VertexInspector (const Standard_Integer nbComp,
                            const BRepMesh_BaseAllocator& theAlloc);
                            
  BRepMesh_VertexInspector (const Standard_Integer nbComp,
                            const Standard_Real    theTol,
                            const BRepMesh_BaseAllocator& theAlloc);
                            
  BRepMesh_VertexInspector (const Standard_Integer nbComp,
                            const Standard_Real    aTolX,
                            const Standard_Real    aTolY,
                            const BRepMesh_BaseAllocator& theAlloc);

  Standard_Integer Add(const BRepMesh_Vertex& theVertex);
  
  void SetTolerance(const Standard_Real theTol)
  {
    myTol(0) = theTol*theTol;
    myTol(1) = 0.;
  }
  
  void SetTolerance(const Standard_Real theTolX, const Standard_Real theTolY)
  {
    myTol(0) = theTolX*theTolX;
    myTol(1) = theTolY*theTolY;
  }
  
  void Clear()
  {
    myVertices.Clear();
    myDelNodes.Clear();
  }

  void Delete(const Standard_Integer theIndex)
  {
    myVertices(theIndex-1).SetMovability(BRepMesh_Deleted);
    myDelNodes.Append(theIndex);
  }
  
  Standard_Integer GetNbVertices() const
  {
    return myVertices.Length(); 
  }

  BRepMesh_Vertex& GetVertex(Standard_Integer theInd)
  {
    return myVertices(theInd-1);
  }
  
  //! Set current node to be checked
  void SetCurrent (const gp_XY& theCurVertex, const Standard_Boolean theExactVal = Standard_False) 
  { 
    myResInd.Clear();
    myCurrent = theCurVertex;
  }

  //!Get result index of node
  const Standard_Integer GetCoincidentInd() const
  {
    if ( myResInd.Size() > 0 )
    {
      return myResInd.First();
    }
    return 0;
  }
  
  const BRepMesh_ListOfInteger& GetListOfDelNodes() const
  {
    return myDelNodes;
  }

  //! Implementation of inspection method
  NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget); 

  static Standard_Boolean IsEqual (Standard_Integer theIdx, const Standard_Integer theTarget)
  {
    return (theIdx == theTarget);
  }

private:
  TColStd_Array1OfReal                 myTol;
  BRepMesh_ListOfInteger               myResInd;
  BRepMesh_VectorOfVertex              myVertices;
  BRepMesh_ListOfInteger               myDelNodes;
  gp_XY                                myCurrent;
};

#endif