# How I get the right normals of facet?

5 messages
Open this post in threaded view
|

## How I get the right normals of facet?

 Hi, I'm new on CGAL. When I use CGAL::make_surface_mesh() to get surface mesh, I need to get consistency normals of every facets.Here my code:         for (C2t3::Facet_iterator face= c2t3.facets_begin(); face != c2t3.facets_end(); ++face)         {                 C2t3::Cell_handle ch;                 ch = face->first;                 int index = face->second;                 Point pt0 = ch->vertex((index+1)&3)->point();                 Point pt1 = ch->vertex((index+2)&3)->point();                 Point pt2 = ch->vertex((index+3)&3)->point();                 Vector normals = CGAL::cross_product(pt1 - pt0, pt2- pt0);                 normals = normals / CGAL::sqrt(normals * normals );        } But the result is not correct. The normals is not consistent. The points(pt0, pt1, pt2) of face are not oriented ?? How I can get consistency normals of every facets. Thank you.
Open this post in threaded view
|

## Re: How I get the right normals of facet?

 Administrator Hi see http://doc.cgal.org/latest/TDS_3/index.html#title0and in particular a sentence in paragraph "Validity" ==== The set σ 4 of permutations of (0,1,2,3) has cardinality 24, and the set of positive permutations A4 has cardinality 12. Thus, for a given orientation, there are up to 12 different orderings of the four vertices of a cell. Note that cyclic permutations are negative and so do not preserve the orientation of a cell. ==== whether vertices (i,i+1,i+2,i+3) (mod 4) are positively oriented depends on the parity of i -- Monique Teillaud http://www.inria.fr/sophia/members/Monique.Teillaud/INRIA Sophia Antipolis - Méditerranée Institut National de Recherche en Informatique et Automatique Le 29/11/13 04:17, WChXiong a écrit : > Hi, I'm new on CGAL. > When I use CGAL::make_surface_mesh() to get surface mesh, I need to get > consistency normals of every facets.Here my code: >          for (C2t3::Facet_iterator face= c2t3.facets_begin(); face != > c2t3.facets_end(); ++face) > { > C2t3::Cell_handle ch; > ch = face->first; > int index = face->second; > Point pt0 = ch->vertex((index+1)&3)->point(); > Point pt1 = ch->vertex((index+2)&3)->point(); > Point pt2 = ch->vertex((index+3)&3)->point(); > > Vector normals = CGAL::cross_product(pt1 - pt0, pt2- pt0); > normals = normals / CGAL::sqrt(normals * normals ); >         } > But the result is not correct. The normals is not consistent. The > points(pt0, pt1, pt2) of face are not oriented ?? How I can get consistency > normals of every facets. Thank you. > > > > -- > View this message in context: http://cgal-discuss.949826.n4.nabble.com/How-I-get-the-right-normals-of-facet-tp4658491.html> Sent from the cgal-discuss mailing list archive at Nabble.com. > -- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss
Open this post in threaded view
|

## Re: How I get the right normals of facet?

 Tried to manage parity but still get not consistent normals... Any ideas? for (CGALTriangulation::Finite_facets_iterator it = T.finite_facets_begin();         it != T.finite_facets_end();         it++)     {         std::pair f = *it;                 const Point& p0 = f.first->vertex((f.second))->point(); //not a facet point, opposite         const Point& p1 = f.first->vertex((f.second+1)&3)->point();         const Point& p2 = f.first->vertex((f.second+2)&3)->point();         const Point& p3 = f.first->vertex((f.second+3)&3)->point();                 //normals         auto n = ( f.second % 2 == 1) ?         CGAL::normal(p1, p2, p3) :         CGAL::normal(p1, p3, p2);         n = n/std::sqrt(n.squared_length()); teillaud wrote > Hi > > see http://doc.cgal.org/latest/TDS_3/index.html#title0> and in particular a sentence in paragraph "Validity" > ==== > The set σ 4 of permutations of (0,1,2,3) has cardinality 24, and the set > of positive permutations A4 has cardinality 12. Thus, for a given > orientation, there are up to 12 different orderings of the four vertices > of a cell. > Note that cyclic permutations are negative and so do not preserve the > orientation of a cell. > ==== > > whether vertices (i,i+1,i+2,i+3) (mod 4) are positively oriented depends > on the parity of i > > -- > Monique Teillaud > http://www.inria.fr/sophia/members/Monique.Teillaud/> INRIA Sophia Antipolis - Méditerranée > Institut National de Recherche en Informatique et Automatique > > Le 29/11/13 04:17, WChXiong a écrit : >> Hi, I'm new on CGAL. >> When I use CGAL::make_surface_mesh() to get surface mesh, I need to get >> consistency normals of every facets.Here my code: >>          for (C2t3::Facet_iterator face= c2t3.facets_begin(); face != >> c2t3.facets_end(); ++face) >> { >> C2t3::Cell_handle ch; >> ch = face->first; >> int index = face->second; >> Point pt0 = ch->vertex((index+1)&3)->point(); >> Point pt1 = ch->vertex((index+2)&3)->point(); >> Point pt2 = ch->vertex((index+3)&3)->point(); >> >> Vector normals = CGAL::cross_product(pt1 - pt0, pt2- pt0); >> normals = normals / CGAL::sqrt(normals * normals ); >>         } >> But the result is not correct. The normals is not consistent. The >> points(pt0, pt1, pt2) of face are not oriented ?? How I can get >> consistency >> normals of every facets. Thank you. >> >> >> >> -- >> View this message in context: >> http://cgal-discuss.949826.n4.nabble.com/How-I-get-the-right-normals-of-facet-tp4658491.html>> Sent from the cgal-discuss mailing list archive at Nabble.com. >> > > > > > -- > You are currently subscribed to cgal-discuss. > To unsubscribe or access the archives, go to > https://sympa.inria.fr/sympa/info/cgal-discuss-- Sent from: http://cgal-discuss.949826.n4.nabble.com/-- You are currently subscribed to cgal-discuss. To unsubscribe or access the archives, go to https://sympa.inria.fr/sympa/info/cgal-discuss