karl- / poly2tri

Automatically exported from code.google.com/p/poly2tri
Other
0 stars 2 forks source link

javascript version outputs errors using window.alert() #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
the javascript version outputs errors using window.alert().
This causes problems when using the library in other programs : modal alert 
windows popping up on the screen.
Also, causes problems when using in Node.js.

Suggestion : allow replacing window.alert() by e.g. throwing exception

Original issue reported on code.google.com by remi.tur...@gmail.com on 14 Mar 2013 at 9:00

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Here is a proposed patch :
add a new js.poly2tri.fatal() function, used by js.poly2tri for all fatal 
messages. By default, for backward compatibility, this function still uses 
window.alert(), but it can be easily replaced by a custom handler e.g. to throw 
an exception

js.poly2tri.fatal = function(message) {
    throw new Error(message);
};

patch here:
https://code.google.com/r/remiturboult-poly2tri-js/source/detail?r=06e1da5929dea
dadf4c71803558afa8a867d49aa

(it's a clone)

Original comment by remi.tur...@gmail.com on 14 Mar 2013 at 9:06

GoogleCodeExporter commented 8 years ago
patched!

btw there is an issue with the recursive
js.poly2tri.SweepContext.prototype.MeshClean

This has been fixed in some implementations of Poly2Tri. The issue is that the 
recursive depth can cause stack overflow.

Maybe you can implement suggested solutions in the javascript version?

You can see https://code.google.com/p/poly2tri/issues/detail?id=65
or look at the current java implementation.

Original comment by thahlen@gmail.com on 14 Mar 2013 at 9:34

GoogleCodeExporter commented 8 years ago
I will look at it
(but I have no problem triangulating 10000 points in JavaScript).

Before, I will add some automated unit tests to this JavaScript version.

Original comment by remi.tur...@gmail.com on 17 Mar 2013 at 7:21

GoogleCodeExporter commented 8 years ago
here is a fix for the recursive MeshClean (also issue 57 and issue 65 in C++ 
version)

https://code.google.com/r/remiturboult-poly2tri-js-2/source/detail?r=1ca24c7253f
106aceda119cda3e5cb23f8f4116e

You can pull it directly
(or give me permission to do it).

Original comment by remi.tur...@gmail.com on 21 Mar 2013 at 10:35

GoogleCodeExporter commented 8 years ago
Have given you access to commit. Let me know if there is any problems.

Original comment by thahlen@gmail.com on 21 Mar 2013 at 10:50

GoogleCodeExporter commented 8 years ago

Original comment by thahlen@gmail.com on 21 Mar 2013 at 4:50

GoogleCodeExporter commented 8 years ago
I cleaned up the error handling in the latests commits, and used standard 
exceptions for errors.

Original comment by remi.tur...@gmail.com on 21 Mar 2013 at 6:05