File: PolyhedralSurf.cpp

package info (click to toggle)
cgal 4.0-5
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 65,068 kB
  • sloc: cpp: 500,870; ansic: 102,544; sh: 321; python: 92; makefile: 75; xml: 2
file content (35 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "PolyhedralSurf.h"

void PolyhedralSurf::compute_facets_normals()
{
  std::for_each(this->facets_begin(), this->facets_end(),
		Facet_unit_normal());
}

const Vector_3 PolyhedralSurf::computeFacetsAverageUnitNormal(const Vertex_const_handle v)
{
  Halfedge_const_handle h;
  Facet_const_handle f;
  Vector_3 sum(0., 0., 0.), n;

  Halfedge_around_vertex_const_circulator
    hedgeb = v->vertex_begin(), hedgee = hedgeb;

  do
    {
      h = hedgeb;
      if (h->is_border_edge())
	{
	  hedgeb++;
	  continue;
	}

      f =  h->facet();
      n = f->getUnitNormal();
      sum = (sum + n);
      hedgeb++;
    }
  while (hedgeb != hedgee);
  sum = sum / std::sqrt(sum * sum);
  return sum;
}