Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] CGAL+OpenGL, incorrectly render mesh triangles

Subject: CGAL users discussion list

List archive

[cgal-discuss] CGAL+OpenGL, incorrectly render mesh triangles


Chronological Thread 
  • From: mikef <>
  • To:
  • Subject: [cgal-discuss] CGAL+OpenGL, incorrectly render mesh triangles
  • Date: Thu, 13 Apr 2017 20:05:36 -0700 (PDT)
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=None
  • Ironport-phdr: 9a23:riylQBNsosi2j0NwtTol6mtUPXoX/o7sNwtQ0KIMzox0Lfn7rarrMEGX3/hxlliBBdydsKMYzbKO+4nbGkU4qa6bt34DdJEeHzQksu4x2zIaPcieFEfgJ+TrZSFpVO5LVVti4m3peRMNQJW2aFLduGC94iAPERvjKwV1Ov71GonPhMiryuy+4ZPebgFHiTanfb9+MAi9oBnMuMURnYZsMLs6xAHTontPdeRWxGdoKkyWkh3h+Mq+/4Nt/jpJtf45+MFOTav1f6IjTbxFFzsmKHw65NfqtRbYUwSC4GYXX3gMnRpJBwjF6wz6Xov0vyDnuOdxxDWWMMvrRr8zRTmv4aZmRRvxhCsaKzIy7WXbh8JsgK5HpR6soQF0zYzJb4GPLPdwcKPTc80ZS2RcUcleSyNPD5igb4YNFecNIfpUo5Xjq1YIsBCwBROsBOTqyjJQg3/23K463PovEQrb2wEgEd0OsXTJoNnpN6ofSu+1zKzSwjXCa/Nawyvy6I/Nch04p/yHQLx+cc3UyUY1FgPFiE2dqYr/MDyOzesNt3aU4/B8WuKojm4qrRx6rDu3xso0l4XEh5wZxkra+Sh5zos5P8C0RUB1bNK+H5ZduTmWO5Z3T888WW1kpiY3x7MctZKmciUHxo4ryh7dZvGBboOG+AjsVPyLLjd9nH9leKywhxK18UW4z+39WM600ExJriZflNnDrGsC2AfX6seZUPdy4kCh2TOX2wDS7OFLP1w0mLLGJ5Mg3LI8jIQfvETNEyPshUn7gqGbel8r9+Wm8+jnZ6/ppp6YN496kAH+NaEul9SxAeQ3MgkCQnSX9Oen2b3s+E32WrRKjvksnqbFt5DaINwXprSlDA9NzoYj9xG/Ai+639QXh3YHKEtJdw+Gj4jyJ17OPev4DeykjlS3kDZrwujGMaf7DpXMKHjDirbhcqxn505S0gpghexYsplbA7VELPPoUVLqr/TZCAU4Okq62bXJEtJ4g4YfWm+BSvuXP7KL6Q+g6ecmIu3Kb4gQ7mWuY8M57uLj2CZq0WQWerOkiMBPMH0=

I am using CGAL "make_surface_mesh" to create a mesh out of an ellipsoid
function, then using OpenGL to draw it by plotting triangle by triangle. I
have no clue what is going on...

*Problem:* the plotted surface is weird, some triangle has color, some not,
some are like holes.

*My codes for mesh generation:*
Surface_3 surface(earth_function, // pointer to function
Sphere_3(CGAL::ORIGIN, 7000*7000));
// bounding sphere
// Note that "2." above is the *squared* radius of the bounding
sphere!
// defining meshing criteria
CGAL::Surface_mesh_default_criteria_3 criteria(30., // angular
bound
500, // radius bound
50); // distance bound
// meshing surface
CGAL::make_surface_mesh(c2t3, surface, criteria ,
CGAL::Manifold_tag());

*My codes for mesh plotting: *
glNewList(EARTH_S, GL_COMPILE);

Point_3 pt0, pt1, pt2, pt3;
for (auto it = c2t3.facets_begin(); it != c2t3.facets_end(); it++) {

pt0 = it->first->vertex((it->second) & 3)->point();
pt1 = it->first->vertex((it->second + 1) & 3)->point();
pt2 = it->first->vertex((it->second + 2) & 3)->point();
pt3 = it->first->vertex((it->second + 3) & 3)->point();

auto vv = pt1 - pt0;
auto n = CGAL::normal(pt1, pt2, pt3);
if (CGAL::angle(n, vv) == CGAL::ACUTE) { n = -n; }
//auto n = ((it->second % 2 ) == 1)?CGAL::normal(pt1, pt2,
pt3): CGAL::normal(pt1, pt3, pt2);

glBegin(GL_TRIANGLES);
glColor3f(0.4, 0.5, 0.3);
glNormal3f(n.x(), n.y(), n.z());
glVertex3f(pt1.x(), pt1.y(), pt1.z());
glVertex3f(pt2.x(), pt2.y(), pt2.z());
glVertex3f(pt3.x(), pt3.y(), pt3.z());
glEnd();
}

glEndList();

*Resulting plot: *
<http://cgal-discuss.949826.n4.nabble.com/file/n4662670/Capture.jpg>



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/CGAL-OpenGL-incorrectly-render-mesh-triangles-tp4662670.html
Sent from the cgal-discuss mailing list archive at Nabble.com.



Archive powered by MHonArc 2.6.18.

Top of Page