DrGCirlceItem>>intersectionWith:flag: needs clarification

Bug #1798606 reported by Hannes Hirzel on 2018-10-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Dr. Geo II
Undecided
Unassigned

Bug Description

The following method implements the distinction of different cases.

Thus parameter aCurveItem actually may be any item, not only a curveItem.
The code should show this. In addition the call to this code is protected by

on: Error do: [nil]

It was difficult to spot an error here.

OLD
----

DrGCircleItem>>

intersectionWith: aCurveItem flag: aFlag
|aPoint|
 aCurveItem isLineItem
  ifTrue: [^self intersectionWithDirection: aCurveItem flag: aFlag].
 (aCurveItem isSegmentItem or: [aCurveItem isRayItem])
  ifTrue:
   [aPoint := self intersectionWithDirection: aCurveItem flag: aFlag.
   aPoint ifNil: [^nil].
   (aCurveItem contains: aPoint)
    ifTrue: [^aPoint]
    ifFalse: [^nil]].
 aCurveItem isCircleItem
  ifTrue: [^self intersectionWithCircle: aCurveItem flag: aFlag].
 aCurveItem isArcItem
  ifTrue: [^aCurveItem intersectionWith: self flag: aFlag]

New
---

intersectionWith: anItem flag: aFlag
|aPoint|
 anItem isLineItem
  ifTrue: [^self intersectionWithDirection: anItem flag: aFlag].
 (anItem isSegmentItem or: [anItem isRayItem])
  ifTrue:
   [aPoint := self intersectionWithDirection: anItem flag: aFlag.
   aPoint ifNil: [^nil].
   (anItem contains: aPoint)
    ifTrue: [^aPoint]
    ifFalse: [^nil]].
 anItem isCircleItem
  ifTrue: [^self intersectionWithCircle: anItem flag: aFlag].
 anItem isArcItem
  ifTrue: [^anItem intersectionWith: self flag: aFlag]

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers