olivierdalang / VectorBender

VectorBender is a QGis plugin
GNU General Public License v3.0
37 stars 15 forks source link

Multithreading support #10

Open ThePromenader opened 7 years ago

ThePromenader commented 7 years ago

Hello,

(As we discussed, ; ) I'd like to add multithreading support to your script using .map: it would make transforming large numbers of polygons a much faster process (it presently only uses one core).

I will find it eventually, but if you could indicate where the actual polygon shifting begins (or whether each point is calculated then shifted in the same loop), that would be kind.

Also, this would affect your progress bar output; it would have to be transformed from a "# in the queue being processed" one to an end-thread-process-updated (x# out of total#) one.

Thanks, best,

Josef.

olivierdalang commented 7 years ago

Hi !

Everything is happening in the Transformer.map method.

If you're doing affine transforms, I think the algorithm will be much (much) faster than the triangle mesh (but I'm not sure the affine transformation alogirthm made it to a release in QGIS yet, will be sorting this out in the pull request about affine transforms in a minute)

If it's non uniform transforms, I think the step that makes everything very slow is that for each point, the algorithm has to find in which triangle of the original mesh it lies (using matplotlib's TriFinder).

This could probably be enhanced drastically (especially for few big triangles and lots of points) by checking whether the triangle is the same as for the previous point).

Let me know if this makes sense,

Bests

ThePromenader commented 7 years ago

Yes, it makes perfect sense, thank you.

There is nothing about the affine transformation in your documentation or in the interface (it doesn't let us know when vectorbender is using it)... and I would love to know how it works. For the time being, I gave it a try (using exactly three pairs)... it's zippy for sure, but not very accurate... for what I'm doing, anyway. But perhaps there is a 'best place' to put the pairs so that it can detect an overall distortion.

Okay, I'll have a look in the transformer map method... I may have to remaniate the progress part of the code too (so that it will show accurate progress with multithreading), so I'll post the code when it's done/working.

Thanks for your patience, I'm new to this.