Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] How I get the right normals of facet?

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] How I get the right normals of facet?


Chronological Thread 
  • From: "Sebastien Loriot (GeometryFactory)" <>
  • To:
  • Subject: Re: [cgal-discuss] How I get the right normals of facet?
  • Date: Tue, 18 Aug 2020 09:46:53 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:8sNllhVvARqkZe1tlXIke5+zqgXV8LGtZVwlr6E/grcLSJyIuqrYZRWDuadThVPEFb/W9+hDw7KP9fy5BypZucvK6SldOLV3FDY9wf0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3OgV6PPn6FZDPhMqrye+y54fTYwJVjzahfL9+Nhq7oRjQu8UMnIduNqY8xhTUrndVeeld2H9lK0+Ukxvg/Mm74YRt8z5Xu/Iv9s5AVbv1cqElRrFGDzooLn446tTzuRbMUQWA6H0cUn4LkhVTGAjK8Av6XpbqvSTksOd2xTSXMtf3TbAwXjSi8rtrRRr1gyoJKzI17GfagdF2galGohyuugZ/zpbJbo+LOvpwfqDTc90USmVOXMleSyNPD5igb4YMFecNIfpUoof/qlYIsBCwBROsBOTqyjJQiHP4wLM13P87HgHdwAwgHswBsHLJp9vzM6cSS+G1zK7UzT7ea/9Y2Cny6I/Nch8/vfGMR7Jxf8rLxkYzCwPFiU+QqIzgMz+by+8AtHOb7+5nVeK1im4nrB1xriKqxscokYTJiYcVxUrF9SV92oo6Odq4SEtibNOiDZBfuD2UOZFsTcM+X2Fnpjw6yrsetJO1YSQHxpQpyhDCZvGHbYWF4hLuWPuPLTplhX9oeK6yigiy/EavyuPwSsa63EhWoidEjNXBuG0A2hjN5sWFVvdw+Fqq1ziI1wDW8O5EIEY0mLLHJJ4u2LEwkoAfsUPZHi/5gEn2jamWdl8l+uey8ejnbK/mqoeaN4BukQ7xKaAuldKlDeskNQgOWm6W8vm/2r375UD1XqlGg/ksnqTasJ3WP9oXqrCkDwNP3Ysu6Q6zAym839gEgHUKKUxKdA6dgIXsJV3CPO30APKxjlu2jjtn2/XLMqDiD5nQIHjOla3ucLdm5ENSzQc+z8pQ6IhIBbwELvL8QVL9uMDeAxQkKQK72fznB8941o4GWWKAHKuZMKTKvF+N/O0vIu2MaJYbuTbnNvQp/vDugHA7lFMHcqmp2pwXaH+8Hvt4OUmWfX3sgtIZHWcLuAoxUvDqhUWcXTJPY3u+RaEx6zEhBI64E4vPW5qhjbOD0SujG51ZfGFGClSCEXfycIWEXu8BaDmWIs9miDwEVL+hS5M72RGrsA/30LVnLu/O9S0ZsZLvzsR65+rWlR0q7zx7E9yd032RT2Fzhm4HWzA207p7oUBk11iD0LN4jOBFFdxI/PNESRw6NJ7Zz+xiEd/+QAPBftGTSFanWNqqGz8xTshii+IIeFt3TtW+kgjYjW3tGK4Qj7XNBZou86ua0WK2PNd403+B1a8viB4tTcJLcGGnnaVi7BOAOojSjk+lmra2IKQAwDbWpiDE1nuLpEgeUQhqUKyDU2pYfVrTtd2+50XMSPilBr0jdwdA0sWfMbAZVtq8hlpPQLLvOc/Vfnmqs2a2HxeBgL2WP6TwfGBIlh7QAkEfjwEe+z6iMhI/ATvp403TCzljCUj+TUrn7e5kuTLxBhsvywaQbkp9kb+x0hEQjP2YDfgU2+RX628atzxoEQPljJrtAN2aql85JfQOUZYG+F5CkFnhmUl4N52kIbplgwdHIQtytkLqkR5wD9cZyJV4nDYR1AN3bJmg/hZBejefh82iP7TWLizt5knqZfKJnF7Z19mS9+EE7/Fq8wy/7jHsLVIr9jBc6/cQy2GVv8yYAw8bUJa3WUEypUB3

If you have a manifold surface, you can use this function:
https://doc.cgal.org/latest/Surface_mesher/group__PkgSurfaceMesher3FunctionsIO.html#ga39a105bd1817a9200ec5df208888e8aa
with Surface_mesh for example:
https://doc.cgal.org/latest/Surface_mesh/
Then you can use the normal computation function:
https://doc.cgal.org/latest/Polygon_mesh_processing/group__PMP__normal__grp.html#ga14a7730a996879ba6e7589dfeaccff82


If not, then you can use this one and load back the file as a triangle soup:

https://doc.cgal.org/latest/Surface_mesher/group__PkgSurfaceMesher3FunctionsIO.html#ga7718d4e2047939882540d89fb5f28934


Sebastien.

On 8/17/20 6:56 PM, quaternionboy ( via cgal-discuss Mailing List) wrote:
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<CGALTriangulation::Cell_handle, int> 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/




Archive powered by MHonArc 2.6.19+.

Top of Page