You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am after drawing concave/vex polygons in openGL, and came across your code,
which I believe
might be what I am looking for to break polygons into multiple triangles.
I have the following in my code:
==================
//Run the polytri to calculate tesslated triangles
/// Constrained triangles
vector<Triangle*> triangles;
vector<p2t::Point*> polyline;
//For tesselattion cannot have duplicated point = > skip the last
for (int i = 0; i < (pPolygonPoints->size() -1); ++i)
{
polyline.push_back(new Point(*(pPolygonPoints->at(i)->getX()),*(pPolygonPoints->at(i)-
>getY())));
cout << "gdsPolygonDEBUG: ADDED POINT " << *(pPolygonPoints->at(i)->getX()) << " " <<
*(pPolygonPoints->at(i)->getY())<< flush << endl;
}
CDT* cdt = new CDT(polyline);
cdt->Triangulate();
triangles = cdt->GetTriangles();
delete cdt;
for (int i = 0; i < triangles.size(); i++) {
Triangle& t = *triangles[i];
Point& a = *t.GetPoint(0);
Point& b = *t.GetPoint(1);
Point& c = *t.GetPoint(2);
float newX1 = a.x;
float newY1 = a.y;
float newX2 = b.x;
float newY2 = b.y;
float newX3 = c.x;
float newY3 = c.y;
//////////////////////////
#ifdef gdsPolygonDEBUG
cout << "gdsPolygonDEBUG: Triangle A : "<< newX1 << " " << newY1 << flush << endl;
cout << "gdsPolygonDEBUG: Triangle B : "<< newX2 << " " << newY2 << flush << endl;
cout << "gdsPolygonDEBUG: Triangle C : "<< newX3 << " " << newY3 << flush << endl;
#endif
//////////////////////////
}
==================
When I run, I get the following (note you can see the points I am adding in
from my classes into
polyline).
Either the triangle point for "a" come out as inf or -0. Point "a" never seems
to be getting non-
zero numbers.
Am I using your class incorrectly, or is there as buglet somewhere ?
I hope you can help.
Many thanks in advance
Colin Thomas
===================
gdsPolygonDEBUG: ADDED POINT -1.92 0
gdsPolygonDEBUG: ADDED POINT -1.92 1.92
gdsPolygonDEBUG: ADDED POINT -0.96 1.92
gdsPolygonDEBUG: ADDED POINT -0.96 2.88
gdsPolygonDEBUG: ADDED POINT 5.12 2.88
gdsPolygonDEBUG: ADDED POINT 5.12 -4.16
gdsPolygonDEBUG: ADDED POINT -1.92 -4.16
gdsPolygonDEBUG: ADDED POINT -1.92 -0.96
gdsPolygonDEBUG: ADDED POINT -0.96 -0.96
gdsPolygonDEBUG: ADDED POINT -0.96 0
gdsPolygonDEBUG: Triangle A : 0 0
gdsPolygonDEBUG: Triangle B : -1.92 1.92
gdsPolygonDEBUG: Triangle C : -1.92 0
gdsPolygonDEBUG: Triangle A : 0 0
gdsPolygonDEBUG: Triangle B : -1.92 0
gdsPolygonDEBUG: Triangle C : -0.96 0
gdsPolygonDEBUG: Triangle A : 0 -0
gdsPolygonDEBUG: Triangle B : -0.96 1.92
gdsPolygonDEBUG: Triangle C : -0.96 0
gdsPolygonDEBUG: Triangle A : 0 -0
gdsPolygonDEBUG: Triangle B : -0.96 0
gdsPolygonDEBUG: Triangle C : -0.96 -0.96
gdsPolygonDEBUG: Triangle A : 0 0
gdsPolygonDEBUG: Triangle B : 5.12 -4.16
gdsPolygonDEBUG: Triangle C : 5.12 2.88
gdsPolygonDEBUG: Triangle A : 0 0
gdsPolygonDEBUG: Triangle B : -0.96 -0.96
gdsPolygonDEBUG: Triangle C : -1.92 -4.16
gdsPolygonDEBUG: Triangle A : 0 0
gdsPolygonDEBUG: Triangle B : -1.92 -0.96
gdsPolygonDEBUG: Triangle C : -1.92 -4.16
gdsPolygonDEBUG: Triangle A : 0 -0
gdsPolygonDEBUG: Triangle B : -0.96 2.88
gdsPolygonDEBUG: Triangle C : -0.96 1.92
===================
Original issue reported on code.google.com by ColinPet...@gmail.com on 27 Apr 2010 at 6:15
The text was updated successfully, but these errors were encountered:
I ran your point set with the testbed demo; see the screenshot for results. I
would
suggest that you check your code again. Maybe you have a pointer error?
Original comment by mason.gr...@gmail.com on 29 Apr 2010 at 11:48
Original issue reported on code.google.com by
ColinPet...@gmail.com
on 27 Apr 2010 at 6:15The text was updated successfully, but these errors were encountered: