← All bug reports

FS#2598LineSimilarityAxes may throw exceptions in library.js shapeToEntity

Type
Bug
Status
Closed
Resolution
Fixed
Category
QCAD (main)
Severity
Low
Priority
Low
Reported version
3.30.1
Operating system
All
Reported
2024-09-10 by CVH
Closed
2024-09-11 by andrew

Andrew,
The failure route crosses DrawBasedOnThreeCircles.
As far as I know only used for LineSimilarityAxes.js and PointPowerCenter.js in the open source.

The culprit is that undefined shapes are send to shapeToEntity in library.js to convert in drawing entities. It then fails on isFunction(s.data) where s is the given shape.

There are several solutions.
- Not returning undefined shapes from Apollonius.getSimilarityAxes
- Filter out undefined shapes in LineSimilarityAxes.prototype.getShapes similar as PointPowerCenter.prototype.getShapes does.
- Filter out undefined shapes in DrawBasedOnThreeCircles.prototype.getOperation as seen in many other tool code.
- An additional test on an undefined shape in LinkshapeToEntity

The last solution is the safest, the second to last is the common method.

The final word is for LineSimilarityAxes.js or Apollonius.getSimilarityAxes
Under normal conditions it should return 4 lines each crossing 3 homothetic centers of 6.
In QCAD it may fail for the special cases for example:
Circle A touching B and circle B touching C
Where Ra <> Rb <> Rc

A hint:
Not all homothetic centers are found by the intersection of external or internal tangents

Regards,
CVH