c++ - CGAL + Find edge length using EdgeIterator -


i new cgal , trying find length of each each edge in mesh. don't see or length member functions or way of getting points on either side of edge.

here have gotten far. how either points on either end of edge or size of edge itself?

#include <iostream> #include <string> #include <cgal/cartesian.h> #include <cgal/filtered_kernel.h> #include <cgal/polyhedron_3.h> #include <cgal/io/polyhedron_iostream.h> typedef double real; typedef cgal::cartesian<real> kernel0; // use filtered kernel predicates exact. typedef cgal::filtered_kernel<kernel0> kernel; typedef cgal::polyhedron_3<kernel> polyhedron; typedef kernel::point_3 point;  void edge_analysis(polyhedron mesh){   float mean = 0, min, max, length;   int count = 0; bool init = true;   (polyhedron::edge_const_iterator edgeiter = mesh.edges_begin(); edgeiter != mesh.edges_end(); ++edgeiter){        point = edgeiter.prev()->vertex()->point();       point b = edgeiter.vertex()->point();       length = cgal::sqrt(cgal::squared_distance(a, b));       ++count;       if (init){           mean = min = max = length;           init = false;       }       else{           if (length < min) min = length;           if (length > max) max = length;       }       mean += length;   }   mean /= count;   std::cout << min << " " << max << " " << mean << "\n"; }  int main(int argc, char **argv){    polyhedron mesh;    // read input mesh standard input in off format.   if (!(std::cin >> mesh)) {     std::cerr << "cannot read input mesh\n";     return 1;   }   edge_analysis(mesh); return 0; } 

the mistake should fixed in order compile is:

  const point& = edgeiter->prev()->vertex()->point();   const point& b = edgeiter->vertex()->point(); 

you should use cgal::exact_predicates_inexact_constructions_kernel instead of kernel. should take const ref on mesh if want avoid unneeded copy.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -