File indexing completed on 2026-10-27 09:37:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BRepMesh_CircleInspector_HeaderFile
0017 #define BRepMesh_CircleInspector_HeaderFile
0018
0019 #include <IMeshData_Types.hxx>
0020 #include <BRepMesh_Circle.hxx>
0021 #include <gp_XY.hxx>
0022 #include <NCollection_CellFilter.hxx>
0023
0024
0025 class BRepMesh_CircleInspector
0026 {
0027 public:
0028 static constexpr int Dimension = 2;
0029
0030 typedef gp_XY Point;
0031 typedef int Target;
0032
0033 static double Coord(int i, const Point& thePnt) { return thePnt.Coord(i + 1); }
0034
0035 static Point Shift(const Point& thePnt, double theTol)
0036 {
0037 return Point(thePnt.X() + theTol, thePnt.Y() + theTol);
0038 }
0039
0040
0041
0042
0043
0044 BRepMesh_CircleInspector(const double theTolerance,
0045 const int theReservedSize,
0046 const occ::handle<NCollection_IncAllocator>& theAllocator)
0047 : mySqTolerance(theTolerance * theTolerance),
0048 myResIndices(theAllocator),
0049 myCircles(theReservedSize, theAllocator)
0050 {
0051 }
0052
0053
0054
0055
0056 void Bind(const int theIndex, const BRepMesh_Circle& theCircle)
0057 {
0058 myCircles.SetValue(theIndex, theCircle);
0059 }
0060
0061
0062 const IMeshData::VectorOfCircle& Circles() const { return myCircles; }
0063
0064
0065
0066
0067 BRepMesh_Circle& Circle(const int theIndex) { return myCircles(theIndex); }
0068
0069
0070
0071 void SetPoint(const gp_XY& thePoint)
0072 {
0073 myResIndices.Clear();
0074 myPoint = thePoint;
0075 }
0076
0077
0078 IMeshData::ListOfInteger& GetShotCircles() { return myResIndices; }
0079
0080
0081
0082
0083 NCollection_CellFilter_Action Inspect(const int theTargetIndex)
0084 {
0085 BRepMesh_Circle& aCircle = myCircles(theTargetIndex);
0086 const double& aRadius = aCircle.Radius();
0087 if (aRadius < 0.)
0088 return CellFilter_Purge;
0089
0090 gp_XY& aLoc = const_cast<gp_XY&>(aCircle.Location());
0091
0092 const double aDX = myPoint.ChangeCoord(1) - aLoc.ChangeCoord(1);
0093 const double aDY = myPoint.ChangeCoord(2) - aLoc.ChangeCoord(2);
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112 if ((aDX * aDX + aDY * aDY) - (aRadius * aRadius) <= mySqTolerance)
0113 myResIndices.Append(theTargetIndex);
0114
0115 return CellFilter_Keep;
0116 }
0117
0118
0119 static bool IsEqual(const int theIndex, const int theTargetIndex)
0120 {
0121 return (theIndex == theTargetIndex);
0122 }
0123
0124 private:
0125 double mySqTolerance;
0126 IMeshData::ListOfInteger myResIndices;
0127 IMeshData::VectorOfCircle myCircles;
0128 gp_XY myPoint;
0129 };
0130
0131 #endif