File indexing completed on 2026-09-28 09:20:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef GeomBndLib_Line2d_HeaderFile
0015 #define GeomBndLib_Line2d_HeaderFile
0016
0017 #include <Bnd_Box2d.hxx>
0018 #include <GeomBndLib_InfiniteHelpers.pxx>
0019 #include <ElCLib.hxx>
0020 #include <Geom2d_Line.hxx>
0021 #include <gp_Lin2d.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 #include <Standard_Failure.hxx>
0024
0025
0026
0027
0028
0029
0030 class GeomBndLib_Line2d
0031 {
0032 public:
0033 DEFINE_STANDARD_ALLOC
0034
0035 GeomBndLib_Line2d(const occ::handle<Geom2d_Line>& theLine)
0036 : myGeom(theLine)
0037 {
0038 }
0039
0040 GeomBndLib_Line2d(const GeomBndLib_Line2d&) = delete;
0041 GeomBndLib_Line2d& operator=(const GeomBndLib_Line2d&) = delete;
0042 GeomBndLib_Line2d(GeomBndLib_Line2d&&) = delete;
0043 GeomBndLib_Line2d& operator=(GeomBndLib_Line2d&&) = delete;
0044
0045 const occ::handle<Geom2d_Line>& Geometry() const { return myGeom; }
0046
0047
0048 [[nodiscard]] Bnd_Box2d Box(double theU1, double theU2, double theTol) const
0049 {
0050 return Box(myGeom->Lin2d(), theU1, theU2, theTol);
0051 }
0052
0053
0054 [[nodiscard]] Bnd_Box2d Box(double theTol) const
0055 {
0056 return Box(myGeom->FirstParameter(), myGeom->LastParameter(), theTol);
0057 }
0058
0059
0060 [[nodiscard]] Bnd_Box2d BoxOptimal(double theU1, double theU2, double theTol) const
0061 {
0062 return Box(theU1, theU2, theTol);
0063 }
0064
0065
0066 [[nodiscard]] static Bnd_Box2d Box(const gp_Lin2d& theLin,
0067 double theU1,
0068 double theU2,
0069 double theTol)
0070 {
0071 Bnd_Box2d aBox;
0072 if (Precision::IsNegativeInfinite(theU1))
0073 {
0074 if (Precision::IsNegativeInfinite(theU2))
0075 {
0076 throw Standard_Failure("GeomBndLib_Line2d::Box - bad parameter");
0077 }
0078 else if (Precision::IsPositiveInfinite(theU2))
0079 {
0080 GeomBndLib_InfiniteHelpers::OpenMinMax(theLin.Direction(), aBox);
0081 aBox.Add(ElCLib::Value(0., theLin));
0082 }
0083 else
0084 {
0085 GeomBndLib_InfiniteHelpers::OpenMin(theLin.Direction(), aBox);
0086 aBox.Add(ElCLib::Value(theU2, theLin));
0087 }
0088 }
0089 else if (Precision::IsPositiveInfinite(theU1))
0090 {
0091 if (Precision::IsNegativeInfinite(theU2))
0092 {
0093 GeomBndLib_InfiniteHelpers::OpenMinMax(theLin.Direction(), aBox);
0094 aBox.Add(ElCLib::Value(0., theLin));
0095 }
0096 else if (Precision::IsPositiveInfinite(theU2))
0097 {
0098 throw Standard_Failure("GeomBndLib_Line2d::Box - bad parameter");
0099 }
0100 else
0101 {
0102 GeomBndLib_InfiniteHelpers::OpenMax(theLin.Direction(), aBox);
0103 aBox.Add(ElCLib::Value(theU2, theLin));
0104 }
0105 }
0106 else
0107 {
0108 aBox.Add(ElCLib::Value(theU1, theLin));
0109 if (Precision::IsNegativeInfinite(theU2))
0110 {
0111 GeomBndLib_InfiniteHelpers::OpenMin(theLin.Direction(), aBox);
0112 }
0113 else if (Precision::IsPositiveInfinite(theU2))
0114 {
0115 GeomBndLib_InfiniteHelpers::OpenMax(theLin.Direction(), aBox);
0116 }
0117 else
0118 {
0119 aBox.Add(ElCLib::Value(theU2, theLin));
0120 }
0121 }
0122 aBox.Enlarge(theTol);
0123 return aBox;
0124 }
0125
0126 private:
0127 occ::handle<Geom2d_Line> myGeom;
0128 };
0129
0130 #endif