nel-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nel] How to use NLMISC::CPolygon::toConvexPolygons function


From: lionel berenguier
Subject: Re: [Nel] How to use NLMISC::CPolygon::toConvexPolygons function
Date: Tue, 16 Dec 2003 14:23:33 +0100

I don't know where is your problem, since It seems to work with your data.
 
This is my code::
 
 {
  CMatrix m1;
  
  CPolygon poly1;
  
  poly1.Vertices.push_back(CVector(0,8,0));
  poly1.Vertices.push_back(CVector(0,0,0));
  poly1.Vertices.push_back(CVector(12,0,0));
  poly1.Vertices.push_back(CVector(12,8,0));
  poly1.Vertices.push_back(CVector(8,8,0));
  poly1.Vertices.push_back(CVector(8,4,0));
  poly1.Vertices.push_back(CVector(4,4,0));
  poly1.Vertices.push_back(CVector(4,8,0));
  
  list<CPolygon> convexPolygons;
  
  nlinfo("%d", (uint)poly1.toConvexPolygons(convexPolygons,m1));
 
  nlinfo("");
  
  for(list<CPolygon>::iterator i = convexPolygons.begin() ; i != convexPolygons.end(); ++i)
  {
   vector<CVector> t1 = i->Vertices;
   
   for(int j = 0;j<t1.size();++j)
    nlinfo("%f,%f,%f", t1[j].x, t1[j].y, t1[j].z);
   nlinfo("");
  }
  
 }
 
And this is my result:
 
 
R:\code\test\test_3dyoyo\main.cpp(1551) : INF 1860: 1
R:\code\test\test_3dyoyo\main.cpp(1553) : INF 1860:
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 4.000000,4.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 4.000000,8.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 0.000000,8.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 0.000000,0.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1561) : INF 1860:
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 8.000000,4.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 4.000000,4.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 0.000000,0.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 12.000000,0.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1561) : INF 1860:
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 12.000000,0.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 12.000000,8.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 8.000000,8.000000,0.000000
R:\code\test\test_3dyoyo\main.cpp(1560) : INF 1860: 8.000000,4.000000,0.000000
which sounds good to me.
 
Lionel.
----- Original Message -----
Sent: Saturday, December 13, 2003 6:06 AM
Subject: Re: [Nel] How to use NLMISC::CPolygon::toConvexPolygons function

Hi
 I have tried making last point != first point also but its not giving results.Input is --
0,8,0
0,0,0
12,0,0
12,8,0
8,8,0
8,4,0
4,4,0
4,8,0
Polygon is like --
_____          ________
|        |         |             |  (for input last point != first point)
|        |         |             |
|        |_____|             |
|                               |
|__________________|
 
 
Output is a list of 3 plygons--
4,4,0
4,8,0
0,8,0
0,0,0
 
12,8,0
8,8,0
8,4,0
 
12,0,0
12,8,0
8,4,0

The function -- Poly1.toConvexPolygons(convexPolygons,m1) is also returning  0(false).Please help.
 
Raman Gupta


reply via email to

[Prev in Thread] Current Thread [Next in Thread]