2836e39b76aff985c8109efdf7333386368e6109
[occt.git] / src / BRepMesh / BRepMesh_CircleInspector.hxx
1 // Created on: 2008-05-26
2 // Created by: Ekaterina SMIRNOVA
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef BRepMesh_CircleInspector_Header
17 #define BRepMesh_CircleInspector_Header
18
19 #include <BRepMesh.hxx>
20 #include <BRepMesh_Circle.hxx>
21 #include <Precision.hxx>
22 #include <gp_XY.hxx>
23 #include <gp_XYZ.hxx>
24 #include <NCollection_CellFilter.hxx>
25
26 //! Auxilary class to find circles shot by the given point.
27 class BRepMesh_CircleInspector : public NCollection_CellFilter_InspectorXY
28 {
29 public:
30   typedef Standard_Integer Target;
31
32   //! Constructor.
33   //! @param theTolerance tolerance to be used for identification of shot circles.
34   //! @param theReservedSize size to be reserved for vector of circles.
35   //! @param theAllocator memory allocator to be used by internal collections.
36   Standard_EXPORT BRepMesh_CircleInspector(
37     const Standard_Real                     theTolerance,
38     const Standard_Integer                  theReservedSize,
39     const Handle(NCollection_IncAllocator)& theAllocator)
40   : myTolerance(theTolerance*theTolerance),
41     myResIndices(theAllocator),
42     myCircles(theReservedSize)
43   {
44   }
45
46   //! Adds the circle to vector of circles at the given position.
47   //! @param theIndex position of circle in the vector.
48   //! @param theCircle circle to be added.
49   inline void Bind(const Standard_Integer theIndex,
50                    const BRepMesh_Circle& theCircle)
51   {
52     myCircles.SetValue(theIndex, theCircle);
53   }
54
55   //! Resutns vector of registered circles.
56   inline const BRepMesh::VectorOfCircle& Circles() const
57   {
58     return myCircles; 
59   }
60
61   //! Returns circle with the given index.
62   //! @param theIndex index of circle.
63   //! @return circle with the given index.
64   inline BRepMesh_Circle& Circle(const Standard_Integer theIndex)
65   {
66     return myCircles(theIndex);
67   }
68
69   //! Set reference point to be checked.
70   //! @param thePoint bullet point.
71   inline void SetPoint(const gp_XY& thePoint)
72   {
73     myResIndices.Clear();
74     myPoint = thePoint;
75   }
76
77   //! Returns list of circles shot by the reference point.
78   inline BRepMesh::ListOfInteger& GetShotCircles()
79   {
80     return myResIndices;
81   }
82
83   //! Performs inspection of a circle with the given index.
84   //! @param theTargetIndex index of a circle to be checked.
85   //! @return status of the check.
86   Standard_EXPORT NCollection_CellFilter_Action Inspect(
87     const Standard_Integer theTargetIndex);
88
89   //! Checks indices for equlity.
90   Standard_EXPORT static Standard_Boolean IsEqual(
91     const Standard_Integer theIndex,
92     const Standard_Integer theTargetIndex)
93   {
94     return (theIndex == theTargetIndex);
95   }
96
97 private:
98   Standard_Real            myTolerance;
99   BRepMesh::ListOfInteger  myResIndices;
100   BRepMesh::VectorOfCircle myCircles;
101   gp_XY                    myPoint;
102 };
103
104 #endif