Update from same files in Gyroviz package

This commit is contained in:
Nader Salman 2008-06-19 11:44:56 +00:00
parent d92021ba08
commit ac2beb5ddc
6 changed files with 62 additions and 22 deletions

View File

@ -22,7 +22,7 @@
#include <CGAL/Point_with_normal_3.h>
#include <vector>
#include <set>
#include <algorithm>
@ -54,7 +54,7 @@ public:
typedef typename CGAL::Oriented_normal_3<Geom_traits> Normal; ///< Model of OrientedNormal_3 concept.
/// Iterator over cameras
typedef typename std::vector<Point_3>::const_iterator Camera_const_iterator;
typedef typename std::set<Point_3>::const_iterator Camera_const_iterator;
// Public methods
public:
@ -81,7 +81,7 @@ public:
InputIterator first_camera, InputIterator beyond_camera)
: Base(point, CGAL::NULL_VECTOR)
{
std::copy(first_camera, beyond_camera, std::back_inserter(list_of_cameras));
list_of_cameras.insert(first_camera, beyond_camera);
}
template < class InputIterator >
Gyroviz_point_3(const Point_3& point,
@ -89,7 +89,7 @@ public:
InputIterator first_camera, InputIterator beyond_camera)
: Base(point, normal)
{
std::copy(first_camera, beyond_camera, std::back_inserter(list_of_cameras));
list_of_cameras.insert(first_camera, beyond_camera);
}
// Default copy constructor and operator =() are fine
@ -104,21 +104,30 @@ public:
return ! (*this == that);
}
// Get/set cameras
// Get cameras
Camera_const_iterator cameras_begin() const { return list_of_cameras.begin(); }
Camera_const_iterator cameras_end () const { return list_of_cameras.end(); }
// Set cameras
template < class InputIterator >
void set_cameras(InputIterator first_camera, InputIterator beyond_camera)
{
list_of_cameras.clear();
std::copy(first_camera, beyond_camera, std::back_inserter(list_of_cameras));
list_of_cameras.insert(first_camera, beyond_camera);
}
// Add cameras
template < class InputIterator >
void add_cameras(InputIterator first_camera, InputIterator beyond_camera)
{
list_of_cameras.insert(first_camera, beyond_camera);
}
Camera_const_iterator cameras_begin() const { return list_of_cameras.begin(); }
Camera_const_iterator cameras_end () const { return list_of_cameras.end(); }
// Data
private:
// List of cameras
std::vector<Point_3> list_of_cameras;
std::set<Point_3> list_of_cameras;
};

View File

@ -135,11 +135,29 @@ private:
typedef CGAL::Polyhedron_3<PolyhedronTraits_3, PolyhedronItems_3> Base;
// Auxiliary class to build a triangles iterator
template <class Node> // Node is Facet
struct Project_triangle {
typedef Node argument_type;
typedef typename PolyhedronTraits_3::Triangle_3 Triangle;
typedef Triangle result_type;
typedef CGAL::Arity_tag<1> Arity;
typedef typename PolyhedronTraits_3::Point_3 Point;
Triangle operator()(const Node& f) const {
Halfedge_const_handle he = f.halfedge();
const Point& a = he->vertex()->point();
const Point& b = he->next()->vertex()->point();
const Point& c = he->next()->next()->vertex()->point();
return Triangle(a,b,c);
}
};
// Public types
public:
typedef typename PolyhedronTraits_3::FT FT;
typedef typename PolyhedronTraits_3::Point_3 Point;
typedef typename PolyhedronTraits_3::FT FT;
typedef typename PolyhedronTraits_3::Point_3 Point;
// Repeat Polyhedron_3 public types
typedef typename Base::HalfedgeDS HalfedgeDS;
@ -165,6 +183,10 @@ public:
typedef typename Base::Halfedge_around_vertex_circulator Halfedge_around_vertex_circulator;
typedef typename Base::Halfedge_around_vertex_const_circulator Halfedge_around_vertex_const_circulator;
// Iterator over triangles
typedef CGAL::Iterator_project<Facet_const_iterator, Project_triangle<Facet> >
Triangle_const_iterator;
public :
// Default constructor, copy constructor and operator =() are fine.
@ -177,6 +199,10 @@ public :
Base::vertices_begin;
Base::vertices_end;
// Get first/last iterators over triangles.
Triangle_const_iterator triangles_begin() const { return Triangle_const_iterator(facets_begin()); }
Triangle_const_iterator triangles_end() const { return Triangle_const_iterator(facets_end()); }
// Compute normals using mesh connectivity (per facet, then per vertex)
void compute_normals_per_facet()
{

View File

@ -28,7 +28,7 @@ bool surface_reconstruction_read_pwc(const char* pFilename,
FILE *pFile = fopen(pFilename,"rt");
if(pFile == NULL)
{
std::cerr << "Error: cannot open " << pFilename;
std::cerr << "Error: cannot open " << pFilename << std::endl;
return false;
}
@ -52,7 +52,7 @@ bool surface_reconstruction_read_pwc(const char* pFilename,
if ( (sscanf(pLine,"%s",signature) != 1) || (strcmp(signature, "CamOFF") != 0) )
{
// if unsupported file format
std::cerr << "Incorrect file format line " << lineNumber << " of " << pFilename;
std::cerr << "Incorrect file format line " << lineNumber << " of " << pFilename << std::endl;
return false;
}
}
@ -62,7 +62,7 @@ bool surface_reconstruction_read_pwc(const char* pFilename,
{
if (sscanf(pLine,"%ld %ld",&camCount,&pointsCount) != 2)
{
std::cerr << "Error line " << lineNumber << " of " << pFilename;
std::cerr << "Error line " << lineNumber << " of " << pFilename << std::endl;
return false;
}
}
@ -107,6 +107,10 @@ bool surface_reconstruction_read_pwc(const char* pFilename,
list_of_cameras.begin(), list_of_cameras.end());
gyroviz_point_output++;
}
else
{
//std::cerr << "Skip (" << position << ") line " << lineNumber << " of " << pFilename << std::endl;
}
}
// ...or skip comment line
}

View File

@ -79,7 +79,7 @@ public:
/// Compare positions
bool operator==(const Point_with_normal_3& that)
{
return Base::operator==(that);
return ((Base&)(*this) == (Base&)that);
}
bool operator!=(const Point_with_normal_3& that)
{

View File

@ -112,8 +112,8 @@ merge_epsilon_nearest_points_3(
InputIterator first, ///< input points
InputIterator beyond,
OutputIterator output, ///< output points
const Kernel& /*kernel*/,
double epsilon) ///< tolerance value when comparing 3D points
double epsilon, ///< tolerance value when comparing 3D points
const Kernel& /*kernel*/)
{
typedef typename Kernel::Point_3 Point;
@ -123,7 +123,7 @@ merge_epsilon_nearest_points_3(
CGAL_precondition(epsilon > 0);
// Merge points which belong to the same cell of a grid of cell size = epsilon.
Epsilon_point_set_3<Point_3> merged_points(epsilon);
Epsilon_point_set_3<Point> merged_points(epsilon);
merged_points.insert(first, beyond);
// Copy merged points to output
@ -147,8 +147,9 @@ void
merge_epsilon_nearest_points_3(
ForwardIterator first, ///< input/output points
ForwardIterator beyond,
const Kernel& /*kernel*/,
double epsilon) ///< tolerance value when comparing 3D points
double epsilon, ///< tolerance value when comparing 3D points
const Kernel& /*kernel*/)
{
CGAL_precondition(false); // nyi
}
@ -175,7 +176,7 @@ merge_epsilon_nearest_points_3(
{
typedef typename std::iterator_traits<InputIterator>::value_type Value_type;
typedef typename Kernel_traits<Value_type>::Kernel Kernel;
return merge_epsilon_nearest_points_3(first,beyond,output,Kernel(),epsilon);
return merge_epsilon_nearest_points_3(first,beyond,output,epsilon,Kernel());
}
/// Merge points which belong to the same cell of a grid of cell size = epsilon.
@ -195,7 +196,7 @@ merge_epsilon_nearest_points_3(
{
typedef typename std::iterator_traits<ForwardIterator>::value_type Value_type;
typedef typename Kernel_traits<Value_type>::Kernel Kernel;
merge_epsilon_nearest_points_3(first,beyond,Kernel(),epsilon);
merge_epsilon_nearest_points_3(first,beyond,epsilon,Kernel());
}