Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002126 [Squeak] Graphics minor always 10-25-05 20:46 02-16-06 10:01
Reporter BGaertner View Status public  
Assigned To andreas
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 3.9 Product Version 3.9
  Product Build
Summary 0002126: Rectangle>>areasOutside: has a bug
Description The instance method areasOutside: of Rectangle has a subtle bug that can cause a result with lots of rectangles of height zero. To see the problem, you can evaluate this piece of code:

| frame rects visibleBackground cnt |

cnt := 0.
visibleBackground := [:f :rc | | visibleAreas |
  visibleAreas := Array with: f.
  rc do: [:rect | | remnants |
      remnants := OrderedCollection new.
      visibleAreas do: [:a | remnants addAll: (a areasOutside: rect)].
      visibleAreas := remnants.
       cnt := cnt + 1.
      Transcript show: cnt printString; show: ' '; show: visibleAreas size
printString; cr.
  ].
  visibleAreas
 ].

frame := 0@0 extent: 300@300. /> rects := OrderedCollection new: 80.
0 to: 9 do: [:i |
  0 to: 7 do: [:j |
        rects add: (i@j * 20 extent: 10@10)
]].

( visibleBackground value: frame value: rects) size

-----------------
Here we have a large rectangle (frame) and 80 small rectangles
that are placed on the large rectangle. The block is a piece
of code that computes the part of the large rectangle that is
not covered by small rects.

replace the last statement of the code above with

(( visibleBackground value: frame value: rects)
   reject: [:r | r area = 0]
) size

to see that most of the rectangles have no area.

The many useless rectangles of height zero are created becaue areasOutside: uses a wrong test for intersection. The test ignores the fact that the bottom line and the right border line of a rectangle are not part of the rectangle.

Attached you find
1. a proposed fix (Rect-areasOutside-bg.1.cs)
2. some additional tests for class Rectangle. (RectangleAdditionalTests.2.cs)
Steps To Reproduce
Additional Information The bug is also present in earlier versions of Squeak.
Attached Files  Rect-areasOutside-bg.1.cs [^] (1,326 bytes) 10-25-05 20:47
 RectangleAdditionalTests.2.cs [^] (3,013 bytes) 10-25-05 20:48

- Relationships

- Notes
(0002978 - 118 - 118 - 118 - 118 - 118 - 118)
BGaertner
10-25-05 20:50

For some reason, the description text is displayed in a very ugly form. I am sorry about that, but I cannot change it.
 
(0002980 - 37 - 37 - 37 - 37 - 37 - 37)
andreas
10-26-05 02:30

Now integrated. Thanks for reporting.
 
(0003880 - 10 - 10 - 10 - 10 - 10 - 10)
MarcusDenker
02-16-06 10:01

integrated
 

- Issue History
Date Modified Username Field Change
10-25-05 20:46 BGaertner New Issue
10-25-05 20:47 BGaertner File Added: Rect-areasOutside-bg.1.cs
10-25-05 20:48 BGaertner File Added: RectangleAdditionalTests.2.cs
10-25-05 20:50 BGaertner Note Added: 0002978
10-25-05 20:52 BGaertner Issue Monitored: BGaertner
10-25-05 21:49 andreas Assigned To  => andreas
10-25-05 21:49 andreas Status new => assigned
10-25-05 21:49 andreas Category System => Graphics
10-26-05 02:30 andreas Status assigned => resolved
10-26-05 02:30 andreas Fixed in Version  => 3.9
10-26-05 02:30 andreas Resolution open => fixed
10-26-05 02:30 andreas Note Added: 0002980
02-16-06 10:00 MarcusDenker Issue Monitored: MarcusDenker
02-16-06 10:01 MarcusDenker Status resolved => closed
02-16-06 10:01 MarcusDenker Note Added: 0003880


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
56 total queries executed.
37 unique queries executed.
Powered by Mantis Bugtracker