0023105: Exception during Meshing / Missing triangles
[occt.git] / src / BRepMesh / BRepMesh_VertexInspector.hxx
1 // Created on: 2011-06-01
2 // Created by: Oleg AGASHIN
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21
22 #ifndef _BRepMesh_VertexInspector_HeaderFile
23 #define _BRepMesh_VertexInspector_HeaderFile
24
25 #include <BRepMesh_ListOfInteger.hxx> 
26 #ifndef _Precision_HeaderFile
27 #include <Precision.hxx>
28 #endif
29 #ifndef _gp_XY_HeaderFile
30 #include <gp_XY.hxx>
31 #endif
32 #ifndef _gp_XYZ_HeaderFile
33 #include <gp_XYZ.hxx>
34 #endif
35
36 #ifndef NCollection_CellFilter_HeaderFile
37 #include <NCollection_CellFilter.hxx>
38 #endif
39 #ifndef _BRepMesh_Vertex_HeaderFile
40 #include <BRepMesh_Vertex.hxx>
41 #endif
42 #ifndef _BRepMesh_VectorOfVertex_HeaderFile
43 #include <BRepMesh_VectorOfVertex.hxx>
44 #endif
45 #ifndef _TColStd_Array1OfReal_HeaderFile
46 #include <TColStd_Array1OfReal.hxx>
47 #endif
48 #include <BRepMesh_BaseAllocator.hxx>
49
50 //=======================================================================
51 //! The class to find in the coincidence points 
52 //=======================================================================
53
54 class BRepMesh_VertexInspector : public NCollection_CellFilter_InspectorXY
55 {
56 public:
57   typedef Standard_Integer Target;
58   //! Constructor; remembers tolerance and collector data structure.
59   //! theTol can be Real or Array1OfReal with two elements which describe
60   //! tolerance for each dimension.
61   BRepMesh_VertexInspector (const Standard_Integer nbComp,
62                             const BRepMesh_BaseAllocator& theAlloc);
63                             
64   BRepMesh_VertexInspector (const Standard_Integer nbComp,
65                             const Standard_Real    theTol,
66                             const BRepMesh_BaseAllocator& theAlloc);
67                             
68   BRepMesh_VertexInspector (const Standard_Integer nbComp,
69                             const Standard_Real    aTolX,
70                             const Standard_Real    aTolY,
71                             const BRepMesh_BaseAllocator& theAlloc);
72
73   Standard_Integer Add(const BRepMesh_Vertex& theVertex);
74   
75   void SetTolerance(const Standard_Real theTol)
76   {
77     myTol(0) = theTol*theTol;
78     myTol(1) = 0.;
79   }
80   
81   void SetTolerance(const Standard_Real theTolX, const Standard_Real theTolY)
82   {
83     myTol(0) = theTolX*theTolX;
84     myTol(1) = theTolY*theTolY;
85   }
86   
87   void Clear()
88   {
89     myVertices.Clear();
90     myDelNodes.Clear();
91   }
92
93   void Delete(const Standard_Integer theIndex)
94   {
95     myVertices(theIndex-1).SetMovability(BRepMesh_Deleted);
96     myDelNodes.Append(theIndex);
97   }
98   
99   Standard_Integer GetNbVertices() const
100   {
101     return myVertices.Length(); 
102   }
103
104   BRepMesh_Vertex& GetVertex(Standard_Integer theInd)
105   {
106     return myVertices(theInd-1);
107   }
108   
109   //! Set current node to be checked
110   void SetCurrent (const gp_XY& theCurVertex, const Standard_Boolean) 
111   { 
112     myResInd.Clear();
113     myCurrent = theCurVertex;
114   }
115
116   //!Get result index of node
117   const Standard_Integer GetCoincidentInd() const
118   {
119     if ( myResInd.Size() > 0 )
120     {
121       return myResInd.First();
122     }
123     return 0;
124   }
125   
126   const BRepMesh_ListOfInteger& GetListOfDelNodes() const
127   {
128     return myDelNodes;
129   }
130
131   //! Implementation of inspection method
132   NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget); 
133
134   static Standard_Boolean IsEqual (Standard_Integer theIdx, const Standard_Integer theTarget)
135   {
136     return (theIdx == theTarget);
137   }
138
139 private:
140   TColStd_Array1OfReal                 myTol;
141   BRepMesh_ListOfInteger               myResInd;
142   BRepMesh_VectorOfVertex              myVertices;
143   BRepMesh_ListOfInteger               myDelNodes;
144   gp_XY                                myCurrent;
145 };
146
147 #endif