ctu-fgis / 2015-f-citygml

Python library converting CityGML to printable STL
http://geo.fsv.cvut.cz/gwiki/155YFSG
MIT License
9 stars 2 forks source link

Infinite loop when triangulating geoRES_testdata_v1.0.0 #4

Open hroncok opened 9 years ago

hroncok commented 9 years ago

When triangulating a polygon form _geoRES_testdatav1.0.0 from the tests, there is an infinite loop in the poly2tri call.

Test script:

from citygml2stl import polygons, citygml, exceptions
filename = 'geoRES_testdata_v1.0.0'
path = 'test/datasets/' + filename
c = citygml.CityGML(path)

for obj in c.get_objects_of_types():
    for polygon in polygons.Polygons.extract_polygons(obj):
        try:
            polygons.Polygons.triangulate(polygon)
        except exceptions.PlaneConstructionError:
            pass

Triangulated data (exterior and two holes):

((3499993.0, 5.67479085922),
(3499993.0, 4.00208950043),
(3499994.0, 4.00208950043),
(3499994.0, 5.67479085922),
(3499994.0, 5.78301525116),
(3499994.0, 5.87855863571),
(3499993.75, 5.95739650726),
(3499993.75, 6.01620817184),
(3499993.5, 6.05251598358),
(3499993.5, 6.06479120255),
(3499993.25, 6.05251598358),
(3499993.25, 6.01620817184),
(3499993.25, 5.95739650726),
(3499993.0, 5.87855863571),
(3499993.0, 5.78301525116))

((3499994.0, 5.63112974167),
(3499994.0, 4.04575109482),
(3499993.0, 4.04575109482),
(3499993.0, 5.63112974167))

((3499994.0, 5.85266685486),
(3499994.0, 5.76336097717),
(3499994.0, 5.71264028549),
(3499993.0, 5.71264028549),
(3499993.0, 5.76336097717),
(3499993.0, 5.85266685486),
(3499993.25, 5.92635726929),
(3499993.25, 5.98132944107),
(3499993.25, 6.01526689529),
(3499993.5, 6.02674055099),
(3499993.5, 6.01526689529),
(3499993.75, 5.98132944107),
(3499993.75, 5.92635726929))
hroncok commented 9 years ago

green

The problem is that the holes almost entirely cover the object (green), as seen on the gif above (scale has been adjusted and the image was rotated), even if there are no actually identical points.