Brainteaser 1822: Teasing triangles

From The Sunday Times, 17th August 1997 [link]

Each of the ten line segments in the picture have been given a different whole number value from 0 to 9. A figure shown in a triangle equals the sum of the three values assigned to the sides of the triangle. The figures which have not been given from the other two triangles are the same as each other and the two add together to give a perfect square.

What are the numbers assigned to each side?

This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.

[teaser1822]