1 // File: LineConn2d_Box.h
2 // Created: 03.08.05 20:16:45
3 // Author: Alexander GRIGORIEV
4 // Copyright: Open Cascade 2005
7 #ifndef LineConn2d_Box_HeaderFile
8 #define LineConn2d_Box_HeaderFile
12 class LineConn2d_Segment;
13 class LineConn2d_Object;
15 /// Simple class implementing 2D Bounding Box type
21 // ---------- PUBLIC METHODS ----------
26 inline LineConn2d_Box ()
27 : myCenter (::RealLast(), ::RealLast()),
28 myHSize (-::RealLast(), -::RealLast())
34 * Center of the created box
36 * Half-diagonal of the box, both X and Y should be non-negative
38 inline LineConn2d_Box (const gp_XY& theCenter,
39 const gp_XY& theHSize)
40 : myCenter (theCenter),
48 myCenter.SetCoord (::RealLast(), ::RealLast());
49 myHSize .SetCoord (-::RealLast(), -::RealLast());
53 * Update the box by a point.
55 Standard_EXPORT void Add (const gp_XY& thePnt);
58 * Update the box by another box.
60 inline void Add (const LineConn2d_Box& theBox)
62 Add (theBox.Center() - theBox.HSize());
63 Add (theBox.Center() + theBox.HSize());
67 * Query the box center.
69 inline const gp_XY& Center () const
73 * Query the box half-diagonal.
75 inline const gp_XY& HSize () const
79 * Query the square diagonal.
81 inline Standard_Real SquareExtent () const
82 { return 4 * myHSize.SquareModulus(); }
85 * Extend the Box by the absolute value of aDiff.
87 Standard_EXPORT void Enlarge (const Standard_Real theDiff);
90 * Limit the curent Box with the internals of theBox.
92 Standard_EXPORT void Limit (const LineConn2d_Box& theBox);
95 * Check the given point for inclusion in the box.
97 * True if thePnt is outside the box.
99 Standard_EXPORT Standard_Boolean IsOut(const gp_XY& thePnt) const;
102 * Check the given box for intersection with the current box.
104 * True if there is no intersection between the boxes.
106 Standard_EXPORT Standard_Boolean IsOut(const LineConn2d_Box& theBox) const;
109 * Check the given box for intersection with an Object
111 * True if there is no intersection with the object theObj.
113 Standard_EXPORT Standard_Boolean IsOut(const LineConn2d_Object& theObj) const;
116 * Check the given box for intersection with a segment
118 * True if there is no intersection with the segment aSeg.
120 Standard_EXPORT Standard_Boolean IsOut(const LineConn2d_Segment& aSeg) const;
123 * Find intersection points between the boundary of the box and
124 * the given Segment. No intersection returned if the segment is entirely
125 * inside or outside the box. Therefore this method can not be used as
126 * replacement of the corresponding IsOut check.
128 * Array of 2 output numbers. Contains the parameters ([0..1] inclusive)
129 * of intersection point(s). If 2 intersections are found, it is ensured
130 * that outInter[0] < outInter[1].
132 * Segment for intersection.
134 * Number of intersections (0, 1 or 2).
136 Standard_EXPORT Standard_Integer Intersect
137 (Standard_Real outInter[2],
138 const LineConn2d_Segment& aSeg) const;
141 // ---------- PRIVATE FIELDS ----------