google-code-export / poly2tri

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

Problem getting c++ version working #14

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
From testing the javascript version this is exactly what im looking for, but i 
need it in c++ for speed and because thats my programs native code.

I tried using the different c++ versions and got error with all of my polygons 
(stack overflow). When I tried even a basic square I had problems(null 
pointer). I'm wondering if it is because i compiled using VC++ 2008, or am i 
missing a step. 

-------What steps will reproduce the problem?

1. Compile c++ code in VC++ 2008 Pro

--------this fails for me

std::vector<p2t::Point*> polyline;

polyline.push_back(new p2t::Point(-2.0f,-2.0f));
polyline.push_back(new p2t::Point(-2.0f,2.0f));
polyline.push_back(new p2t::Point(2.0f,2.0f));
polyline.push_back(new p2t::Point(2.0f,-2.0f));

p2t::CDT* cdt = new p2t::CDT(polyline);
cdt->Triangulate();

----------

2. Run

3. ....

-------

null pointer exception is thrown (in cdt->Triangulate();) at of one of nodes. 
Sometimes it just crashes without giving me an error.

-------

-----What is the expected output? What do you see instead?

I did it in javascript it works fine(for all my polys), but i cannot get any of 
c++ versions to work.

And For some reason if the square is (-20) to (20) it works but (-2) to (2) 
fails. There are no error using javascript.

---------this works

std::vector<p2t::Point*> polyline;

polyline.push_back(new p2t::Point(-20.0f,-20.0f));
polyline.push_back(new p2t::Point(-20.0f,20.0f));
polyline.push_back(new p2t::Point(20.0f,20.0f));
polyline.push_back(new p2t::Point(20.0f,-20.0f));

p2t::CDT* cdt = new p2t::CDT(polyline);
cdt->Triangulate();

-----What version of the product are you using? On what operating system?

C++ versions in the default clone and the mike... clone. I also tried other 
clones too. The mike... clone catchs the error ant tells me its a null pointer 
exception.

I'm using Visual C++ 2008 Pro
Windows 7 64 bit

-----Please provide any additional information below.

I had to add the definitions constants for M_PI and M_PI_2 to the util.h file 
since its not included in my <math.h>

#define M_PI 3.14159265
#define M_PI_2 6.2831853

Below is the image produced by javascript for one of my polys. It works and 
since the javascript one was derived from the c++ it baffles me that i can get 
it to work. 

Hmmmm... I'm curious if i compile a dll for this in another compiler then i can 
use it.

Thanks for any info in advance.

Original issue reported on code.google.com by ktaber...@gmail.com on 4 Dec 2010 at 9:51

Attachments:

GoogleCodeExporter commented 9 years ago
I tried this out using code blocks and MinGW and it works so it looks like 
problem is in compiling in VC++

Original comment by ktaber...@gmail.com on 5 Dec 2010 at 12:47

GoogleCodeExporter commented 9 years ago
never mind its cause i thought M_PI_2 was 2 pi, but its 1/2 pi, thats why it 
wasnt working for me... ahhh....

Original comment by ktaber...@gmail.com on 5 Dec 2010 at 1:05

GoogleCodeExporter commented 9 years ago
Oki then I'm closing this issue :)

Original comment by thahlen@gmail.com on 5 Dec 2010 at 1:47