File indexing completed on 2025-01-18 10:03:13
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 : public NCollection_CellFilter_InspectorXY
0026 {
0027 public:
0028 typedef Standard_Integer Target;
0029
0030
0031
0032
0033
0034 BRepMesh_CircleInspector(
0035 const Standard_Real theTolerance,
0036 const Standard_Integer theReservedSize,
0037 const Handle(NCollection_IncAllocator)& theAllocator)
0038 : mySqTolerance(theTolerance*theTolerance),
0039 myResIndices(theAllocator),
0040 myCircles(theReservedSize, theAllocator)
0041 {
0042 }
0043
0044
0045
0046
0047 void Bind(const Standard_Integer theIndex,
0048 const BRepMesh_Circle& theCircle)
0049 {
0050 myCircles.SetValue(theIndex, theCircle);
0051 }
0052
0053
0054 const IMeshData::VectorOfCircle& Circles() const
0055 {
0056 return myCircles;
0057 }
0058
0059
0060
0061
0062 BRepMesh_Circle& Circle(const Standard_Integer theIndex)
0063 {
0064 return myCircles(theIndex);
0065 }
0066
0067
0068
0069 void SetPoint(const gp_XY& thePoint)
0070 {
0071 myResIndices.Clear();
0072 myPoint = thePoint;
0073 }
0074
0075
0076 IMeshData::ListOfInteger& GetShotCircles()
0077 {
0078 return myResIndices;
0079 }
0080
0081
0082
0083
0084 NCollection_CellFilter_Action Inspect(
0085 const Standard_Integer theTargetIndex)
0086 {
0087 BRepMesh_Circle& aCircle = myCircles(theTargetIndex);
0088 const Standard_Real& aRadius = aCircle.Radius();
0089 if (aRadius < 0.)
0090 return CellFilter_Purge;
0091
0092 gp_XY& aLoc = const_cast<gp_XY&>(aCircle.Location());
0093
0094 const Standard_Real aDX = myPoint.ChangeCoord(1) - aLoc.ChangeCoord(1);
0095 const Standard_Real aDY = myPoint.ChangeCoord(2) - aLoc.ChangeCoord(2);
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114 if ((aDX * aDX + aDY * aDY) - (aRadius * aRadius) <= mySqTolerance)
0115 myResIndices.Append(theTargetIndex);
0116
0117 return CellFilter_Keep;
0118 }
0119
0120
0121 static Standard_Boolean IsEqual(
0122 const Standard_Integer theIndex,
0123 const Standard_Integer theTargetIndex)
0124 {
0125 return (theIndex == theTargetIndex);
0126 }
0127
0128 private:
0129 Standard_Real mySqTolerance;
0130 IMeshData::ListOfInteger myResIndices;
0131 IMeshData::VectorOfCircle myCircles;
0132 gp_XY myPoint;
0133 };
0134
0135 #endif