Closed mlavik1 closed 1 year ago
Update: Made a PR: #77
And by the way, this is the dataset I tested with: https://carto.ville.namur.be/data/Bati3d_CityGML/maille-2907.zip (from here: https://opendata.bordeaux-metropole.fr/explore/dataset/bati3d/information/)
First of all, thanks a lot for making this great library!
When importing some larger datasets I ran into some crashes.
This appears to be the cause:
gluTessVertex
we pass a pointer to elements stored inside the_vertices
and_indices
vectors.gluTessVertex
does not appear to do any work until we callgluTessEndPolygon
._vertices
and_indices
may have been re-allocated (after successive calls toTesselatorBase::addContour
which pushes new elements to them, causing them to re-allocate to fit a new capacity)vertexDataCallback
andcombineCallback
) will trigger undefined behaviour.We can fix this by making sure the vectors containing the elements we send to GLU do not grow while GLU is processing them. That would be really simple if we knew before starting how many vertices we will need to add. Unfortunately I don't think we know that?
So here's my suggested solution:
addContour
will not happen while GLU is processing them.void* data
parameter, so that we can safely add new elements to_indices
(fromTesselator::combineCallback
) while GLU is working with them._vertices
to a new temporary std::vector, and pass vertex pointers from this list instead, so we can safely add new elements to_vertices
(fromTesselator::combineCallback
) later.It's confusing to explain, so I'll send you a PR :grin: