Commit | Line | Data |
---|---|---|

7fd59977 | 1 | -- File: Box2d.cdl |

2 | -- Created: Mon Jan 28 11:51:08 1991 | |

3 | -- Author: Remi Lequette | |

4 | -- <rle@topsn3> | |

5 | ---Copyright: Matra Datavision 1991, 1992 | |

6 | ||

7 | ||

8 | class Box2d from Bnd | |

9 | ||

10 | ---Purpose: Describes a bounding box in 2D space. | |

11 | -- A bounding box is parallel to the axes of the coordinates | |

12 | -- system. If it is finite, it is defined by the two intervals: | |

13 | -- - [ Xmin,Xmax ], and | |

14 | -- - [ Ymin,Ymax ]. | |

15 | -- A bounding box may be infinite (i.e. open) in one or more | |

16 | -- directions. It is said to be: | |

17 | -- - OpenXmin if it is infinite on the negative side of the "X Direction"; | |

18 | -- - OpenXmax if it is infinite on the positive side of the "X Direction"; | |

19 | -- - OpenYmin if it is infinite on the negative side of the "Y Direction"; | |

20 | -- - OpenYmax if it is infinite on the positive side of the "Y Direction"; | |

21 | -- - WholeSpace if it is infinite in all four directions. In | |

22 | -- this case, any point of the space is inside the box; | |

23 | -- - Void if it is empty. In this case, there is no point included in the box. | |

24 | -- A bounding box is defined by four bounds (Xmin, Xmax, Ymin and Ymax) which | |

25 | -- limit the bounding box if it is finite, six flags (OpenXmin, OpenXmax, OpenYmin, | |

26 | -- OpenYmax, WholeSpace and Void) which describe the bounding box if it is infinite or empty, and | |

27 | -- - a gap, which is included on both sides in any direction when consulting the finite bounds of the box. | |

28 | ||

29 | ||

30 | uses Pnt2d from gp, | |

31 | Dir2d from gp, | |

32 | Lin2d from gp, | |

33 | Trsf2d from gp | |

34 | ||

35 | raises | |

36 | ConstructionError from Standard | |

37 | ||

38 | is | |

39 | ||

40 | Create returns Box2d from Bnd; | |

41 | ---Purpose: Creates an empty 2D bounding box. | |

42 | -- The constructed box is qualified Void. Its gap is null. | |

43 | ---C++: inline | |

44 | ||

45 | SetWhole(me : in out) is static; | |

46 | ---Purpose: Sets this bounding box so that it covers the whole 2D | |

47 | -- space, i.e. it is infinite in all directions. | |

48 | ---C++: inline | |

49 | ||

50 | SetVoid(me : in out) is static; | |

51 | ---Purpose: Sets this 2D bounding box so that it is empty. All points are outside a void box. | |

52 | ---C++: inline | |

53 | ||

54 | Set(me : in out; P : Pnt2d) is static; | |

55 | ---Purpose: Sets this 2D bounding box so that it bounds | |

56 | -- the point P. This involves first setting this bounding box | |

57 | -- to be void and then adding the point PThe rectangle bounds the point <P>. | |

58 | ---C++: inline | |

59 | ||

60 | Set(me : in out; P : Pnt2d; D : Dir2d) is static; | |

61 | ---Purpose: Sets this 2D bounding box so that it bounds | |

62 | -- the half-line defined by point P and direction D, i.e. all | |

63 | -- points M defined by M=P+u*D, where u is greater than | |

64 | -- or equal to 0, are inside the bounding area. This involves | |

65 | -- first setting this 2D box to be void and then adding the half-line. | |

66 | ---C++: inline | |

67 | ||

68 | Update(me : in out; aXmin, aYmin, aXmax, aYmax : Real) | |

69 | ---Purpose: Enlarges this 2D bounding box, if required, so that it | |

70 | -- contains at least: | |

71 | -- - interval [ aXmin,aXmax ] in the "X Direction", | |

72 | -- - interval [ aYmin,aYmax ] in the "Y Direction" | |

73 | is static; | |

74 | ||

75 | Update(me : in out; X,Y : Real) | |

76 | ---Purpose: Adds a point of coordinates (X,Y) to this bounding box. | |

77 | is static; | |

78 | ||

79 | GetGap(me) returns Real | |

80 | ---Purpose: Returns the gap of this 2D bounding box. | |

81 | ---C++: inline | |

82 | is static; | |

83 | ||

84 | SetGap(me : in out; Tol : Real) | |

85 | ---Purpose: Set the gap of this 2D bounding box to abs(Tol). | |

86 | ---C++: inline | |

87 | is static; | |

88 | ||

89 | Enlarge(me : in out; Tol : Real) | |

90 | ---Purpose: Enlarges the box with a tolerance value. | |

91 | -- This means that the minimum values of its X and Y | |

92 | -- intervals of definition, when they are finite, are reduced by | |

93 | -- the absolute value of Tol, while the maximum values are | |

94 | -- increased by the same amount. | |

95 | ---C++: inline | |

96 | is static; | |

97 | ||

98 | Get(me; aXmin, aYmin, aXmax, aYmax : out Real) | |

99 | ---Purpose: Returns the bounds of this 2D bounding box. | |

100 | -- The gap is included. If this bounding box is infinite (i.e. "open"), returned values | |

101 | -- may be equal to +/- Precision::Infinite(). | |

102 | raises ConstructionError -- if IsVoid() | |

103 | is static; | |

104 | ||

105 | OpenXmin(me : in out) | |

106 | ---Purpose: The Box will be infinitely long in the Xmin direction. | |

107 | ---Level: Public | |

108 | ---C++: inline | |

109 | is static; | |

110 | ||

111 | OpenXmax(me : in out) | |

112 | ---Purpose: The Box will be infinitely long in the Xmax direction. | |

113 | ---Level: Public | |

114 | ---C++: inline | |

115 | is static; | |

116 | ||

117 | OpenYmin(me : in out) | |

118 | ---Purpose: The Box will be infinitely long in the Ymin direction. | |

119 | ---Level: Public | |

120 | ---C++: inline | |

121 | is static; | |

122 | ||

123 | OpenYmax(me : in out) | |

124 | ---Purpose: The Box will be infinitely long in the Ymax direction. | |

125 | ---Level: Public | |

126 | ---C++: inline | |

127 | is static; | |

128 | ||

129 | IsOpenXmin(me) returns Boolean | |

130 | ---Purpose: Returns true if this bounding box is open in the Xmin direction. | |

131 | ---C++: inline | |

132 | is static; | |

133 | ||

134 | IsOpenXmax(me) returns Boolean | |

135 | ---Purpose: Returns true if this bounding box is open in the Xmax direction. | |

136 | ---C++: inline | |

137 | is static; | |

138 | ||

139 | IsOpenYmin(me) returns Boolean | |

140 | ---Purpose: Returns true if this bounding box is open in the Ymin direction. | |

141 | ---C++: inline | |

142 | is static; | |

143 | ||

144 | IsOpenYmax(me) returns Boolean | |

145 | ---Purpose: Returns true if this bounding box is open in the Ymax direction. | |

146 | ---C++: inline | |

147 | is static; | |

148 | ||

149 | IsWhole(me) returns Boolean is static; | |

150 | ---Purpose: | |

151 | -- Returns true if this bounding box is infinite in all 4 | |

152 | -- directions (Whole Space flag). | |

153 | ---C++: inline | |

154 | ||

155 | IsVoid(me) returns Boolean is static; | |

156 | ---Purpose: | |

157 | -- Returns true if this 2D bounding box is empty (Void flag). | |

158 | ---C++: inline | |

159 | ||

160 | Transformed(me; T : Trsf2d from gp) | |

161 | ---Purpose: Returns a bounding box which is the result of applying the | |

162 | -- transformation T to this bounding box. | |

163 | -- Warning | |

164 | -- Applying a geometric transformation (for example, a | |

165 | -- rotation) to a bounding box generally increases its | |

166 | -- dimensions. This is not optimal for algorithms which use it. | |

167 | ||

168 | returns Box2d from Bnd is static; | |

169 | ||

170 | Add(me : in out; Other : Box2d) is static; | |

171 | ---Purpose: Adds the 2d box <Other> to <me>. | |

172 | ---Level: Public | |

173 | ||

174 | Add(me : in out; P : Pnt2d) is static; | |

175 | ---Purpose: Adds the 2d pnt <P> to <me>. | |

176 | ---Level: Public | |

177 | ---C++: inline | |

178 | ||

179 | Add(me : in out; P : Pnt2d; D : Dir2d) is static; | |

180 | ---Purpose: Extends <me> from the Pnt <P> in the direction <D>. | |

181 | ---Level: Public | |

182 | ---C++: inline | |

183 | ||

184 | Add(me : in out; D : Dir2d) is static; | |

185 | ---Purpose: Extends the Box in the given Direction, i.e. adds | |

186 | -- a half-line. The box may become infinite in 1 or 2 | |

187 | -- directions. | |

188 | ---Level: Public | |

189 | ||

190 | IsOut(me; P : Pnt2d) returns Boolean is static; | |

191 | ---Purpose: Returns True if the 2d pnt <P> is out <me>. | |

192 | ---Level: Public | |

193 | ||

194 | IsOut(me; Other : Box2d) returns Boolean is static; | |

195 | ---Purpose: Returns True if <Box2d> is out <me>. | |

196 | ---Level: Public | |

197 | ||

198 | IsOut(me; Other : Box2d; T : Trsf2d from gp) returns Boolean is static; | |

199 | ---Purpose: Returns True if transformed <Box2d> is out <me>. | |

200 | ---Level: Public | |

201 | ---C++: inline | |

202 | ||

203 | IsOut(me; T1 : Trsf2d from gp; Other : Box2d; T2 : Trsf2d from gp) | |

204 | returns Boolean is static; | |

205 | ---Purpose: Compares a transformed bounding with a transformed | |

206 | -- bounding. The default implementation is to make a copy | |

207 | -- of <me> and <Other>, to transform them and to test. | |

208 | ---Level: Public | |

209 | ---C++: inline | |

210 | ||

211 | Dump(me) is static; | |

212 | ||

213 | ||

214 | fields Xmin : Real; | |

215 | Xmax : Real; | |

216 | Ymin : Real; | |

217 | Ymax : Real; | |

218 | Gap : Real; | |

219 | Flags : Integer; -- 6 flags | |

220 | ||

221 | end Box2d; |