Point_set Class Reference

Set of 3D Points = Vertices. More...

#include <Point_set.h>

Collaboration diagram for Point_set:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Point_set ()
 Build an empty point set.
 Point_set (const Point_set &)
 Copy constructor.
 ~Point_set ()
int destroy ()
 Empty the Point_set.
int get_vertex_number () const
 Number of vertices.
int size () const
 Number of vertices (same as get_vertex_number()).
int resize (int N_vertex)
 Resize the vertex.
double & get_vertex (int k_vertex, int k_dim)
double get_vertex (int k_vertex, int k_dim) const
const double * get_vertex_p (int k_vertex)
V_3D get_vertex (int k_vertex) const
V_3D get_vertex_v3d (int k_vertex) const
int set_vertex (int k_vertex, double x, double y, double z)
int set_vertex (int k_vertex, int k_dim, double value)
int set_vertex (int k_vertex, V_3D v)
int set_vertex (const std::vector< double > &to_set)
int set_vertex (int k_vertex, double *v)
int set_vertex (int k_vertex, int dim, double *v)
int set_vertex (const Point_set &p)
int add_vertex (double x, double y, double z)
int add_vertex (const V_3D &v)
int add_vertex (const std::vector< double > &to_add)
int add_vertex (const std::vector< V_3D > &to_add)
int add_vertex (const double *v)
int add_vertex (int dim, double *v)
int add_vertex (const Point_set &p)
int add_unique (double x, double y, double z, double epsilon)
int add_unique (const V_3D &v, double epsilon)
int add_unique (const double *v, double epsilon)
int exist (const V_3D &v) const
int exist (const V_3D &v, double epsilon) const
int exist (double x, double y, double z) const
int exist (double x, double y, double z, double epsilon) const
int eliminate (int k_index)
int eliminate (const std::vector< int > &k_index)
int eliminate (const std::vector< double > &k_index)
int eliminate (double x, double y, double z)
int eliminate (double x, double y, double z, double epsilon)
int eliminate (const V_3D &x, double epsilon)
int eliminate (const V_3D &x)
int eliminate (const double *x, double epsilon)
int eliminate (const double *x)
int matrix_transform (const Matrix &M)
int rotate (const V_3D &n, double angle)
int rotate (double n_x, double n_y, double n_z, double angle)
int rotate (const double *n, double angle)
int rotate_centered (const V_3D &n, double angle)
int rotate_centered (double n_x, double n_y, double n_z, double angle)
int rotate_centered (const double *n, double angle)
int rotate (const V_3D &n, double angle, const V_3D &center)
int rotate (double n_x, double n_y, double n_z, double angle, const V_3D &center)
int rotate (const double *n, double angle, const V_3D &center)
int translate (double t_x, double t_y, double t_z)
int translate (const double *t)
int translate (const V_3D &t)
int scale (double s_x, double s_y, double s_z)
int scale (const double *s)
int scale (const V_3D &s)
int scale (double s)
int scale_centered (double s_x, double s_y, double s_z)
int scale_centered (const double *s)
int scale_centered (const V_3D &s)
int scale_centered (double s)
double get_closest_distance (double x, double y, double z, int *index) const
double get_closest_distance (const double *x, int *index) const
double get_closest_distance (const V_3D &x, int *index) const
double get_further_distance (double x, double y, double z, int *index) const
double get_further_distance (const double *x, int *index) const
double get_further_distance (const V_3D &x, int *index) const
double distance_to_index (double x, double y, double z, int index) const
double distance_to_index (const double *x, int index) const
double distance_to_index (const V_3D &x, int index) const
std::vector< int > N_closest (const V_3D &center, int N_closest) const
std::vector< int > N_closest (double x, double y, double z, int N_closest) const
std::vector< int > N_closest (double *x, int N_closest) const
V_3D get_closest_vertex (const V_3D &center) const
 get the closest vertex
V_3D get_closest_vertex (double x, double y, double z) const
 get the closest vertex
V_3D get_closest_vertex (const double *x) const
 get the closest vertex
std::vector< int > inside_circle (const V_3D &center, double radius) const
std::vector< int > inside_circle (double x, double y, double z, double radius) const
std::vector< int > outside_circle (const V_3D &center, double radius) const
std::vector< int > outside_circle (double x, double y, double z, double radius) const
std::vector< int > inside_box (const V_3D &p1, const V_3D &p2) const
std::vector< int > outside_box (const V_3D &p1, const V_3D &p2) const
std::vector< int > inside_tetrahedra (const V_3D &p1, const V_3D &p2, const V_3D &p3, const V_3D &p4) const
std::vector< int > outside_tetrahedra (const V_3D &p1, const V_3D &p2, const V_3D &p3, const V_3D &p4) const
std::vector< int > in_half_space (const V_3D &n, const V_3D &x0) const
std::vector< int > inside_rectangle (const V_3D &p1, const V_3D &p2) const
std::vector< int > outside_rectangle (const V_3D &p1, const V_3D &p2) const
std::vector< int > other_index (const std::vector< int > &index) const
const double * get_vertex () const
std::vector< double > get_vertex_vector () const
int keep_index (int k_start, int k_end)
int delete_index (int k_start, int k_end)
V_3D get_middle_point () const
V_3D get_min_point () const
V_3D get_max_point () const
V_3D get_size_set () const
int center_point_set ()
int unitize_size ()
int load_off_file (const char *filename)
 load off vertices
int load_off_file (const std::string &filename)
 load off vertices
int load_obj_file (const char *filename)
 load obj vertices
int load_obj_file (const std::string &filename)
 load obj vertices
int load_collada_file (const char *filename)
 load Collada vertices
int load_collada_file (const std::string &filename)
 load Collada vertices
int load_collada_file (const std::string &filename, const std::string &name)
 load Collada vertices with name
int load_collada_file (const char *filename, const char *name)
 load Collada vertices with name
int write_off_type (const char *filename) const
 Add vertices description in a .off type.
int write_off_type (const std::string &filename) const
 Add vertices description in a .off type.
int write_obj_type (const char *filename) const
 Add vertices description in a .obj type.
int write_obj_type (const std::string &filename) const
 Add vertices description in a .obj type.
int load_g_file (const char *filename)
 load g file vertices
int load_g_file (const std::string &filename)
 load g file vertices
int write_g_type (const char *filename) const
 write g type file vertices
int write_g_type (const std::string &filename) const
 write g type file vertices
int export_visible_off (const char *filename, double s_cube_size) const
 export into mesh in off file
int export_visible_off (const std::string &filename, double s_cube_size) const
double & operator[] (int index)
double operator[] (int index) const
V_3D operator() (int index) const
double operator() (int k_index, int k_dim) const
double & operator() (int k_index, int k_dim)
const Point_setoperator= (const Point_set &)

Private Member Functions

int load_collada_mesh_vertices (TiXmlNode *geometry_node, const std::string &filename)
 Load vertices starting with node positionned at geometry entry.
std::vector< double > load_collada_float_array (TiXmlNode *mesh_source, const std::string &filename)
 load a float_array in a collada file

Private Attributes

std::vector< double > vertex

Friends

Point_set operator+ (const Point_set &, V_3D T)
Point_set operator+ (const V_3D &T, const Point_set &)
Point_set operator- (const Point_set &, V_3D T)
Point_set operator- (const V_3D &T, const Point_set &)
Point_set operator* (const Matrix &M, const Point_set &)
bool operator== (const Point_set &, const Point_set &)
bool operator!= (const Point_set &, const Point_set &)
ostream & operator<< (ostream &flux, const Point_set &)


Detailed Description

Set of 3D Points = Vertices.

Point_set is a container class for a set of 3D points

Points are not ordered

Definition at line 58 of file Point_set.h.


Constructor & Destructor Documentation

Point_set::Point_set (  ) 

Build an empty point set.

Definition at line 22 of file Point_set.cpp.

References vertex.

00022 :vertex(){vertex.resize(0);}

Point_set::Point_set ( const Point_set p  ) 

Copy constructor.

Definition at line 23 of file Point_set.cpp.

00023 :vertex(p.vertex){}

Point_set::~Point_set (  ) 

Definition at line 24 of file Point_set.cpp.

References vertex.

00024 {vertex.resize(0);}


Member Function Documentation

int Point_set::destroy (  ) 

Empty the Point_set.

Definition at line 26 of file Point_set.cpp.

References vertex.

Referenced by Mesh_object::destroy(), load_g_file(), load_obj_file(), and load_off_file().

00026 {vertex.resize(0);return 0;}

Here is the caller graph for this function:

int Point_set::get_vertex_number (  )  const

Number of vertices.

Number of stored vertex ((x0,y0,z0),...,(xN,yN,zN))

Definition at line 30 of file Point_set.cpp.

References size().

Referenced by eliminate(), get_max_point(), get_min_point(), matrix_transform(), scale(), and translate().

00030 {return size();}

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::size (  )  const

Number of vertices (same as get_vertex_number()).

Number of stored vertex ((x0,y0,z0),...,(xN,yN,zN))

Definition at line 31 of file Point_set.cpp.

References vertex.

Referenced by delete_index(), exist(), export_visible_off(), get_closest_distance(), get_further_distance(), get_vertex_number(), Mesh_object::get_vertex_number(), in_half_space(), inside_box(), inside_circle(), inside_tetrahedra(), keep_index(), N_closest(), operator!=(), operator*(), operator+(), operator-(), operator<<(), operator==(), other_index(), outside_box(), outside_circle(), outside_tetrahedra(), Mesh_object::save_g_file(), Mesh_object::save_obj_file(), Mesh_object::save_off_file(), write_obj_type(), and write_off_type().

00031                          {
00032   if( vertex.size()%3 != 0)
00033     {printf("Error vertex size is not correct in Point_set (not divisible by 3) [%d]\n",int(vertex.size()));exit(-1);}
00034   return vertex.size()/3;
00035 }

int Point_set::resize ( int  N_vertex  ) 

Resize the vertex.

Resize the array

Definition at line 37 of file Point_set.cpp.

References vertex.

00037 {vertex.resize(3*_N_vertex);return 0;}

double & Point_set::get_vertex ( int  k_vertex,
int  k_dim 
)

Definition at line 57 of file Point_set.cpp.

Referenced by operator<<().

00057 {return (*this)[3*k_vertex+k_dim];}

Here is the caller graph for this function:

double Point_set::get_vertex ( int  k_vertex,
int  k_dim 
) const

Definition at line 58 of file Point_set.cpp.

00058 {return (*this)[3*k_vertex+k_dim];}

const double * Point_set::get_vertex_p ( int  k_vertex  ) 

Definition at line 59 of file Point_set.cpp.

References vertex.

Referenced by Mesh_object::get_vertex_p().

00060 {
00061   if(k_vertex<0)
00062     {printf("Error index<0 (%d) in get_vertex_p in Point_set\n",k_vertex);exit(-1);}
00063   else if(3*k_vertex+2>=int(vertex.size()))
00064     {printf("Error in get_vertex_p, index too large compared to size in Point_set (%d/%d)\n",k_vertex,vertex.size());exit(-1);}
00065   return &vertex[3*k_vertex];
00066 }

Here is the caller graph for this function:

V_3D Point_set::get_vertex ( int  k_vertex  )  const

Definition at line 68 of file Point_set.cpp.

References get_vertex().

00069 {
00070   V_3D v(get_vertex(k_vertex,0),get_vertex(k_vertex,1),get_vertex(k_vertex,2));
00071   return v;
00072 }

Here is the call graph for this function:

V_3D Point_set::get_vertex_v3d ( int  k_vertex  )  const

int Point_set::set_vertex ( int  k_vertex,
double  x,
double  y,
double  z 
)

Definition at line 77 of file Point_set.cpp.

Referenced by matrix_transform(), operator*(), operator+(), operator-(), scale(), set_vertex(), Mesh_object::set_vertex(), and translate().

00078 {
00079   (*this)[3*k_vertex+0]=x;
00080   (*this)[3*k_vertex+1]=y;
00081   (*this)[3*k_vertex+2]=z;
00082   return 0;
00083 }

Here is the caller graph for this function:

int Point_set::set_vertex ( int  k_vertex,
int  k_dim,
double  value 
)

Definition at line 84 of file Point_set.cpp.

References V_3D::set(), and set_vertex().

00085 {V_3D v;v.set(k_dim,value);return set_vertex(k_vertex,v);}

Here is the call graph for this function:

int Point_set::set_vertex ( int  k_vertex,
V_3D  v 
)

Definition at line 86 of file Point_set.cpp.

References set_vertex().

00087 {return set_vertex(k_vertex,v[0],v[1],v[2]);}

Here is the call graph for this function:

int Point_set::set_vertex ( const std::vector< double > &  to_set  ) 

int Point_set::set_vertex ( int  k_vertex,
double *  v 
)

Definition at line 88 of file Point_set.cpp.

References set_vertex().

00089 {return set_vertex(k_vertex,v[0],v[1],v[2]);}

Here is the call graph for this function:

int Point_set::set_vertex ( int  k_vertex,
int  dim,
double *  v 
)

Definition at line 90 of file Point_set.cpp.

References set_vertex().

00091 {for(int k=0;k<dim;k++){set_vertex(k_vertex+k,&v[3*k]);}return 0;}

Here is the call graph for this function:

int Point_set::set_vertex ( const Point_set p  ) 

Definition at line 92 of file Point_set.cpp.

00093 {(*this)=p;return 0;}

int Point_set::add_vertex ( double  x,
double  y,
double  z 
)

Definition at line 96 of file Point_set.cpp.

References vertex.

Referenced by add_unique(), add_vertex(), Mesh_object::add_vertex(), load_collada_mesh_vertices(), load_g_file(), load_obj_file(), and load_off_file().

00097 {vertex.push_back(x);vertex.push_back(y);vertex.push_back(z);return 0;}

Here is the caller graph for this function:

int Point_set::add_vertex ( const V_3D v  ) 

Definition at line 98 of file Point_set.cpp.

References add_vertex().

00099 {return add_vertex(v[0],v[1],v[2]);}

Here is the call graph for this function:

int Point_set::add_vertex ( const std::vector< double > &  to_add  ) 

Definition at line 100 of file Point_set.cpp.

References add_vertex().

00101 {
00102   if((to_add.size()%3)!=0)
00103     {printf("Error in add_vertex in Point_set, size of to_add is not multiple of 3 (%d)\n",to_add.size());exit(-1);}
00104   int k_vertex=0;
00105   for(k_vertex=0;k_vertex<int(to_add.size())/3;k_vertex++)
00106     add_vertex(to_add[3*k_vertex+0],to_add[3*k_vertex+1],to_add[3*k_vertex+2]);
00107   return 0;
00108 }

Here is the call graph for this function:

int Point_set::add_vertex ( const std::vector< V_3D > &  to_add  ) 

Definition at line 109 of file Point_set.cpp.

References add_vertex().

00110 {
00111   int k_vertex=0;
00112   for(k_vertex=0;k_vertex<int(to_add.size());k_vertex++)
00113     add_vertex(to_add[k_vertex]);
00114   return 0;
00115 }

Here is the call graph for this function:

int Point_set::add_vertex ( const double *  v  ) 

Definition at line 116 of file Point_set.cpp.

References add_vertex().

00116 {return add_vertex(v[0],v[1],v[2]);}

Here is the call graph for this function:

int Point_set::add_vertex ( int  dim,
double *  v 
)

Definition at line 117 of file Point_set.cpp.

References add_vertex().

00118 {for(int k=0;k<dim;k++){add_vertex(v[3*k+0],v[3*k+1],v[3*k+2]);}return 0;}

Here is the call graph for this function:

int Point_set::add_vertex ( const Point_set p  ) 

Definition at line 119 of file Point_set.cpp.

References add_vertex(), and get_vertex_vector().

00120 {return add_vertex(p.get_vertex_vector());}

Here is the call graph for this function:

int Point_set::add_unique ( double  x,
double  y,
double  z,
double  epsilon 
)

Definition at line 146 of file Point_set.cpp.

References add_vertex(), and exist().

Referenced by Mesh_object::add_unique().

00147 {
00148   if(exist(x,y,z,epsilon)==-1)
00149     return add_vertex(x,y,z);
00150   return -1;
00151 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::add_unique ( const V_3D v,
double  epsilon 
)

Definition at line 152 of file Point_set.cpp.

References add_vertex(), and exist().

00153 {
00154   if(exist(v,epsilon)==-1)
00155     return add_vertex(v);
00156   return -1;
00157 }

Here is the call graph for this function:

int Point_set::add_unique ( const double *  v,
double  epsilon 
)

Definition at line 158 of file Point_set.cpp.

References add_vertex(), and exist().

00159 {
00160   if(exist(v[0],v[1],v[2],epsilon)==-1)
00161     return add_vertex(v);
00162   return -1;
00163 }

Here is the call graph for this function:

int Point_set::exist ( const V_3D v  )  const

Definition at line 141 of file Point_set.cpp.

Referenced by add_unique(), eliminate(), exist(), and Mesh_object::exist().

00141 {return exist(v,0.00001);}

Here is the caller graph for this function:

int Point_set::exist ( const V_3D v,
double  epsilon 
) const

Definition at line 128 of file Point_set.cpp.

References V_3D::equal(), get_vertex(), and size().

00129 {
00130   int k_vertex=0;
00131   int N_vertex=size();
00132   V_3D x;
00133   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00134     {
00135       x=get_vertex(k_vertex);
00136       if(v.equal(x,epsilon)==1)
00137         return k_vertex;
00138     }
00139   return -1;
00140 }

Here is the call graph for this function:

int Point_set::exist ( double  x,
double  y,
double  z 
) const

Definition at line 142 of file Point_set.cpp.

References exist().

00142 {return exist(x,y,z,0.00001);}

Here is the call graph for this function:

int Point_set::exist ( double  x,
double  y,
double  z,
double  epsilon 
) const

Definition at line 143 of file Point_set.cpp.

References exist().

00143 {V_3D X(x,y,z);return exist(X,epsilon);}

Here is the call graph for this function:

int Point_set::eliminate ( int  k_index  ) 

Definition at line 166 of file Point_set.cpp.

References get_vertex_number(), and vertex.

Referenced by eliminate(), and Mesh_object::eliminate().

00167 {
00168   if(k_index<0 || k_index>=get_vertex_number())
00169     {printf("Error k_index too large in eliminate (%d/%d)\n",k_index,get_vertex_number());exit(-1);}
00170   int k_vertex=0,N_vertex=get_vertex_number();
00171   int k_dim=0;
00172   for(k_vertex=k_index;k_vertex<N_vertex-1;k_vertex++)
00173     for(k_dim=0;k_dim<3;k_dim++)
00174       vertex[3*k_vertex+k_dim]=vertex[3*(k_vertex+1)+k_dim];
00175   vertex.resize(N_vertex-1);
00176   return 0;
00177 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::eliminate ( const std::vector< int > &  k_index  ) 

Definition at line 178 of file Point_set.cpp.

References eliminate().

00179 {
00180   int k_vertex=0;
00181   int N_vertex=k_index.size();
00182   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00183     eliminate(k_index[k_vertex]);
00184   return 0;
00185 }

Here is the call graph for this function:

int Point_set::eliminate ( const std::vector< double > &  k_index  ) 

Definition at line 200 of file Point_set.cpp.

References eliminate().

00201 {
00202   int k_vertex=0;
00203   int N_index=0;
00204   if((k_index.size()%3)!=0)
00205     {printf("Error size of k_index in eliminate is not divisible by 3 (%d)\n",k_index.size());exit(-1);}
00206   for(k_vertex=0;k_vertex<N_index/3;k_vertex++)
00207     eliminate(k_index[3*k_vertex+0],k_index[3*k_vertex+1],k_index[3*k_vertex+2]);
00208   return 0;
00209 }

Here is the call graph for this function:

int Point_set::eliminate ( double  x,
double  y,
double  z 
)

Definition at line 186 of file Point_set.cpp.

References eliminate().

00186 {return eliminate(x,y,z,0.00001);}

Here is the call graph for this function:

int Point_set::eliminate ( double  x,
double  y,
double  z,
double  epsilon 
)

Definition at line 187 of file Point_set.cpp.

References eliminate(), and exist().

00188 {
00189   int k_index=0;
00190   k_index=exist(x,y,z,epsilon);
00191   if(k_index!=-1)
00192     return eliminate(k_index);
00193   
00194   return -1;
00195 }

Here is the call graph for this function:

int Point_set::eliminate ( const V_3D x,
double  epsilon 
)

Definition at line 196 of file Point_set.cpp.

References eliminate().

00196 {return eliminate(x[0],x[1],x[2],epsilon);}

Here is the call graph for this function:

int Point_set::eliminate ( const V_3D x  ) 

Definition at line 197 of file Point_set.cpp.

References eliminate().

00197 {return eliminate(x[0],x[1],x[2],0.00001);}

Here is the call graph for this function:

int Point_set::eliminate ( const double *  x,
double  epsilon 
)

Definition at line 198 of file Point_set.cpp.

References eliminate().

00198 {return eliminate(x[0],x[1],x[2],epsilon);}

Here is the call graph for this function:

int Point_set::eliminate ( const double *  x  ) 

Definition at line 199 of file Point_set.cpp.

References eliminate().

00199 {return eliminate(x[0],x[1],x[2],0.00001);}

Here is the call graph for this function:

int Point_set::matrix_transform ( const Matrix M  ) 

Definition at line 218 of file Point_set.cpp.

References get_vertex_number(), get_vertex_v3d(), and set_vertex().

Referenced by Mesh_object::matrix_transform(), and rotate().

00219 {
00220   int k_vertex=0,N_vertex=get_vertex_number();
00221   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00222     set_vertex(k_vertex,M*get_vertex_v3d(k_vertex));
00223   return 0;  
00224 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::rotate ( const V_3D n,
double  angle 
)

Definition at line 228 of file Point_set.cpp.

Referenced by rotate(), Mesh_object::rotate(), and rotate_centered().

00228 {return rotate(n[0],n[1],n[2],angle);}

Here is the caller graph for this function:

int Point_set::rotate ( double  n_x,
double  n_y,
double  n_z,
double  angle 
)

Definition at line 229 of file Point_set.cpp.

References matrix_transform(), and Matrix::set_rotation_matrix().

00230 {
00231   Matrix R;
00232   R.set_rotation_matrix(n_x,n_y,n_z,angle);
00233   return matrix_transform(R);
00234 }

Here is the call graph for this function:

int Point_set::rotate ( const double *  n,
double  angle 
)

Definition at line 235 of file Point_set.cpp.

References rotate().

00235 {return rotate(n[0],n[1],n[2],angle);}

Here is the call graph for this function:

int Point_set::rotate_centered ( const V_3D n,
double  angle 
)

Definition at line 294 of file Point_set.cpp.

References get_middle_point(), rotate(), and translate().

Referenced by rotate_centered(), and Mesh_object::rotate_centered().

00295 {
00296   V_3D center=get_middle_point();
00297   translate(-1.0*center);
00298   rotate(n,angle);
00299   translate( center);
00300   return 0;
00301 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::rotate_centered ( double  n_x,
double  n_y,
double  n_z,
double  angle 
)

Definition at line 302 of file Point_set.cpp.

References rotate_centered().

00303 {V_3D n(n_x,n_y,n_z);return rotate_centered(n,angle);}

Here is the call graph for this function:

int Point_set::rotate_centered ( const double *  n,
double  angle 
)

Definition at line 304 of file Point_set.cpp.

References rotate_centered().

00305 {V_3D n_v3d(n[0],n[1],n[2]);return rotate_centered(n_v3d,angle);}

Here is the call graph for this function:

int Point_set::rotate ( const V_3D n,
double  angle,
const V_3D center 
)

Definition at line 239 of file Point_set.cpp.

References rotate().

00240 {return rotate(n[0],n[1],n[2],angle,center);}

Here is the call graph for this function:

int Point_set::rotate ( double  n_x,
double  n_y,
double  n_z,
double  angle,
const V_3D center 
)

Definition at line 241 of file Point_set.cpp.

References matrix_transform(), Matrix::set_rotation_matrix(), and Matrix::set_translation().

00242 {
00243   Matrix R;R.set_rotation_matrix(n_x,n_y,n_z,angle);
00244   Matrix T;T.set_translation(center[0],center[1],center[2]);
00245   Matrix iT;iT.set_translation(-center[0],-center[1],-center[2]);
00246   Matrix M = T*R*iT;
00247 
00248   return matrix_transform(M);
00249 }

Here is the call graph for this function:

int Point_set::rotate ( const double *  n,
double  angle,
const V_3D center 
)

Definition at line 250 of file Point_set.cpp.

References rotate().

00251 {return rotate(n[0],n[1],n[2],angle,center);}

Here is the call graph for this function:

int Point_set::translate ( double  t_x,
double  t_y,
double  t_z 
)

Definition at line 255 of file Point_set.cpp.

References get_vertex_number(), set_vertex(), and vertex.

Referenced by center_point_set(), rotate_centered(), scale_centered(), translate(), and Mesh_object::translate().

00256 {
00257   int k_vertex=0,N_vertex=get_vertex_number();
00258   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00259     set_vertex(k_vertex,vertex[3*k_vertex+0]+t_x,vertex[3*k_vertex+1]+t_y,vertex[3*k_vertex+2]+t_z);
00260   return 0;
00261 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::translate ( const double *  t  ) 

Definition at line 262 of file Point_set.cpp.

References translate().

00262 {return translate(t[0],t[1],t[2]);}

Here is the call graph for this function:

int Point_set::translate ( const V_3D t  ) 

Definition at line 263 of file Point_set.cpp.

References translate().

00263 {return translate(t[0],t[1],t[2]);}

Here is the call graph for this function:

int Point_set::scale ( double  s_x,
double  s_y,
double  s_z 
)

Definition at line 270 of file Point_set.cpp.

References get_vertex_number(), set_vertex(), and vertex.

Referenced by scale(), Mesh_object::scale(), scale_centered(), and unitize_size().

00271 {
00272   double epsilon=0.000001;
00273   if(fabs(s_x)<epsilon)
00274     {printf("Warning scaling x=0.0 \n");}
00275   if(fabs(s_y)<epsilon)
00276     {printf("Warning scaling y=0.0 \n");}
00277   if(fabs(s_z)<epsilon)
00278     {printf("Warning scaling z=0.0 \n");}
00279 
00280   int k_vertex=0,N_vertex=get_vertex_number();
00281   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00282     set_vertex(k_vertex,vertex[3*k_vertex+0]*s_x,vertex[3*k_vertex+1]*s_y,vertex[3*k_vertex+2]*s_z);
00283   return 0;  
00284 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::scale ( const double *  s  ) 

Definition at line 285 of file Point_set.cpp.

References scale().

00285 {return scale(s[0],s[1],s[2]);}

Here is the call graph for this function:

int Point_set::scale ( const V_3D s  ) 

Definition at line 286 of file Point_set.cpp.

References scale().

00286 {return scale(s[0],s[1],s[2]);}

Here is the call graph for this function:

int Point_set::scale ( double  s  ) 

Definition at line 287 of file Point_set.cpp.

References scale().

00287 {return scale(s,s,s);}

Here is the call graph for this function:

int Point_set::scale_centered ( double  s_x,
double  s_y,
double  s_z 
)

Definition at line 309 of file Point_set.cpp.

References get_middle_point(), scale(), and translate().

Referenced by scale_centered(), and Mesh_object::scale_centered().

00310 {
00311   V_3D center=get_middle_point();
00312   translate(-1.0*center);
00313   scale(s_x,s_y,s_z);
00314   translate( center);
00315   return 0;
00316 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::scale_centered ( const double *  s  ) 

Definition at line 317 of file Point_set.cpp.

References scale_centered().

00317 {return scale_centered(s[0],s[1],s[2]);}

Here is the call graph for this function:

int Point_set::scale_centered ( const V_3D s  ) 

Definition at line 318 of file Point_set.cpp.

References scale_centered().

00318 {return scale_centered(s[0],s[1],s[2]);}

Here is the call graph for this function:

int Point_set::scale_centered ( double  s  ) 

Definition at line 319 of file Point_set.cpp.

References scale_centered().

00319 {return scale_centered(s,s,s);}

Here is the call graph for this function:

double Point_set::get_closest_distance ( double  x,
double  y,
double  z,
int *  index 
) const

Definition at line 387 of file Point_set.cpp.

Referenced by get_closest_distance(), and Mesh_object::get_closest_distance().

00388 {V_3D X(x,y,z);return get_closest_distance(X,index);}

Here is the caller graph for this function:

double Point_set::get_closest_distance ( const double *  x,
int *  index 
) const

Definition at line 389 of file Point_set.cpp.

References get_closest_distance().

00390 {return get_closest_distance(x[0],x[1],x[2],index);}

Here is the call graph for this function:

double Point_set::get_closest_distance ( const V_3D x,
int *  index 
) const

Definition at line 391 of file Point_set.cpp.

References get_vertex_v3d(), and size().

00392 {
00393   int k_vertex=0;
00394   double min_dist=9999999.0;
00395   V_3D current;
00396   double current_dist=0.0;
00397   for(k_vertex=0;k_vertex<size();k_vertex++)
00398     {
00399       current = get_vertex_v3d(k_vertex);
00400       current_dist=(x-current).norm();
00401       if(min_dist>current_dist)
00402         {
00403           *index=k_vertex;
00404           min_dist=current_dist;
00405         }
00406     }
00407   return min_dist;
00408 }

Here is the call graph for this function:

double Point_set::get_further_distance ( double  x,
double  y,
double  z,
int *  index 
) const

Definition at line 415 of file Point_set.cpp.

Referenced by get_further_distance(), and Mesh_object::get_further_distance().

00416 {V_3D X(x,y,z);return get_further_distance(X,index);}

Here is the caller graph for this function:

double Point_set::get_further_distance ( const double *  x,
int *  index 
) const

Definition at line 417 of file Point_set.cpp.

References get_further_distance().

00418 {return get_further_distance(x[0],x[1],x[2],index);}

Here is the call graph for this function:

double Point_set::get_further_distance ( const V_3D x,
int *  index 
) const

Definition at line 419 of file Point_set.cpp.

References get_vertex_v3d(), and size().

00420 {
00421   int k_vertex=0;
00422   double max_dist=0.0;
00423   V_3D current;
00424   double current_dist=0.0;
00425   for(k_vertex=0;k_vertex<size();k_vertex++)
00426     {
00427       current = get_vertex_v3d(k_vertex);
00428       current_dist=(x-current).norm();
00429       if(max_dist<current_dist)
00430         {
00431           *index=k_vertex;
00432           max_dist=current_dist;
00433         }
00434     }
00435   return max_dist;
00436 }

Here is the call graph for this function:

double Point_set::distance_to_index ( double  x,
double  y,
double  z,
int  index 
) const

Definition at line 439 of file Point_set.cpp.

Referenced by distance_to_index(), and Mesh_object::distance_to_index().

00440 {V_3D X(x,y,z);return distance_to_index(X,index);}

Here is the caller graph for this function:

double Point_set::distance_to_index ( const double *  x,
int  index 
) const

Definition at line 441 of file Point_set.cpp.

References distance_to_index().

00442 {V_3D X(x[0],x[1],x[2]);return distance_to_index(X,index);}

Here is the call graph for this function:

double Point_set::distance_to_index ( const V_3D x,
int  index 
) const

Definition at line 443 of file Point_set.cpp.

References get_vertex_v3d().

00444 {return (x-get_vertex_v3d(index)).norm();}

Here is the call graph for this function:

std::vector< int > Point_set::N_closest ( const V_3D center,
int  N_closest 
) const

Definition at line 449 of file Point_set.cpp.

References get_vertex_v3d(), and size().

Referenced by get_closest_vertex(), N_closest(), and Mesh_object::N_closest().

00450 {
00451   std::vector <int> closest;
00452   std::vector <double> dist;
00453   std::vector <double> full_dist(size());
00454 
00455   closest.resize(_N_closest);
00456   dist.resize(_N_closest);
00457 
00458   int k_vertex=0,N_vertex=size();
00459   V_3D current;
00460 
00461   //calculate every distance to every vertex
00462   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00463     {
00464       current=get_vertex_v3d(k_vertex);
00465       full_dist[k_vertex] = (current-center).norm();
00466     }
00467   
00468   int k_closest=0;
00469   //first case
00470   for(k_vertex=0,dist[0]=9999.9;k_vertex<N_vertex;k_vertex++)
00471     if(full_dist[k_vertex]<dist[0]){closest[0]=k_vertex;dist[0]=full_dist[k_vertex];}
00472   //other case
00473   for(k_closest=1;k_closest<_N_closest;k_closest++)
00474     for(k_vertex=0,dist[k_closest]=9999.9;k_vertex<N_vertex;k_vertex++)
00475       if(full_dist[k_vertex]<dist[k_closest] && dist[k_closest]>dist[k_closest-1])
00476         {closest[k_closest]=k_vertex;dist[k_closest]=full_dist[k_vertex];}
00477   
00478   return closest;
00479 }

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< int > Point_set::N_closest ( double  x,
double  y,
double  z,
int  N_closest 
) const

Definition at line 480 of file Point_set.cpp.

References N_closest().

00481 {V_3D X(x,y,z);return N_closest(X,_N_closest);}

Here is the call graph for this function:

std::vector< int > Point_set::N_closest ( double *  x,
int  N_closest 
) const

Definition at line 482 of file Point_set.cpp.

References N_closest().

00483 {return N_closest(x[0],x[1],x[2],_N_closest);}

Here is the call graph for this function:

V_3D Point_set::get_closest_vertex ( const V_3D center  )  const

get the closest vertex

Definition at line 1226 of file Point_set.cpp.

References get_vertex_v3d(), and N_closest().

Referenced by get_closest_vertex(), and Mesh_object::get_closest_vertex().

01227 {return get_vertex_v3d(N_closest(center,1)[0]);}

Here is the call graph for this function:

Here is the caller graph for this function:

V_3D Point_set::get_closest_vertex ( double  x,
double  y,
double  z 
) const

get the closest vertex

Definition at line 1228 of file Point_set.cpp.

References get_closest_vertex().

01229 {return get_closest_vertex(V_3D(x,y,z));}

Here is the call graph for this function:

V_3D Point_set::get_closest_vertex ( const double *  x  )  const

get the closest vertex

Definition at line 1230 of file Point_set.cpp.

References get_closest_vertex().

01231 {return get_closest_vertex(V_3D(x[0],x[1],x[2]));}

Here is the call graph for this function:

std::vector< int > Point_set::inside_circle ( const V_3D center,
double  radius 
) const

Definition at line 490 of file Point_set.cpp.

References size().

Referenced by inside_circle().

00491 {
00492   std::vector <int> points;
00493   int k_vertex=0,N_vertex=size();
00494   V_3D current;
00495   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00496     if( (current-center).norm()<=radius )
00497       points.push_back(k_vertex);
00498 
00499   return points;
00500 }

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< int > Point_set::inside_circle ( double  x,
double  y,
double  z,
double  radius 
) const

Definition at line 501 of file Point_set.cpp.

References inside_circle().

00502 {V_3D X(x,y,z);return inside_circle(X,radius);}

Here is the call graph for this function:

std::vector< int > Point_set::outside_circle ( const V_3D center,
double  radius 
) const

Definition at line 512 of file Point_set.cpp.

References size().

Referenced by outside_circle().

00513 {
00514   std::vector <int> points;
00515   int k_vertex=0,N_vertex=size();
00516   V_3D current;
00517   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00518     if( (current-center).norm()>radius )
00519       points.push_back(k_vertex);
00520 
00521   return points;
00522 }

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< int > Point_set::outside_circle ( double  x,
double  y,
double  z,
double  radius 
) const

Definition at line 523 of file Point_set.cpp.

References outside_circle().

00524 {V_3D X(x,y,z);return outside_circle(X,radius);}

Here is the call graph for this function:

std::vector< int > Point_set::inside_box ( const V_3D p1,
const V_3D p2 
) const

Definition at line 532 of file Point_set.cpp.

References V_3D::get_max_scalar(), V_3D::get_min_scalar(), get_vertex_v3d(), and size().

00533 {
00534   std::vector <int> point;
00535   int k_vertex=0,N_vertex=size();
00536   V_3D current;
00537 
00538   V_3D A=p1.get_min_scalar(p2);
00539   V_3D B=p1.get_max_scalar(p2);
00540   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00541     {
00542       current=get_vertex_v3d(k_vertex);
00543       if(current>=A && current<=B)
00544         point.push_back(k_vertex);
00545     }
00546   return point;
00547 }

Here is the call graph for this function:

std::vector< int > Point_set::outside_box ( const V_3D p1,
const V_3D p2 
) const

Definition at line 548 of file Point_set.cpp.

References V_3D::get_max_scalar(), V_3D::get_min_scalar(), get_vertex_v3d(), and size().

00549 {
00550   std::vector <int> point;
00551   int k_vertex=0,N_vertex=size();
00552   V_3D current;
00553 
00554   V_3D A=p1.get_min_scalar(p2);
00555   V_3D B=p1.get_max_scalar(p2);
00556   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00557     {
00558       current=get_vertex_v3d(k_vertex);
00559       if(!(current>=A && current<=B))
00560         point.push_back(k_vertex);
00561     }
00562   return point;
00563 }

Here is the call graph for this function:

std::vector< int > Point_set::inside_tetrahedra ( const V_3D p1,
const V_3D p2,
const V_3D p3,
const V_3D p4 
) const

Definition at line 565 of file Point_set.cpp.

References get_vertex_v3d(), V_3D::is_inside_volume(), and size().

00566 {
00567   std::vector <int> point;
00568   int k_vertex=0,N_vertex=size();
00569   V_3D current;
00570 
00571   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00572     {
00573       current=get_vertex_v3d(k_vertex);
00574       if(current.is_inside_volume(p1,p2,p3,p4)==1)
00575         point.push_back(k_vertex);
00576     }
00577   return point;
00578 }

Here is the call graph for this function:

std::vector< int > Point_set::outside_tetrahedra ( const V_3D p1,
const V_3D p2,
const V_3D p3,
const V_3D p4 
) const

Definition at line 580 of file Point_set.cpp.

References get_vertex_v3d(), V_3D::is_inside_volume(), and size().

00581 {
00582   std::vector <int> point;
00583   int k_vertex=0,N_vertex=size();
00584   V_3D current;
00585 
00586   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00587     {
00588       current=get_vertex_v3d(k_vertex);
00589       if(current.is_inside_volume(p1,p2,p3,p4)==0)
00590         point.push_back(k_vertex);
00591     }
00592   return point;
00593 }

Here is the call graph for this function:

std::vector< int > Point_set::in_half_space ( const V_3D n,
const V_3D x0 
) const

Definition at line 595 of file Point_set.cpp.

References V_3D::distance_to_oriented_plane(), get_vertex_v3d(), and size().

00596 {
00597   std::vector <int> point;
00598   int k_vertex=0,N_vertex=size();
00599   V_3D current;
00600 
00601   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00602     {
00603       current=get_vertex_v3d(k_vertex);
00604       if(current.distance_to_oriented_plane(n,x0)>0)
00605         point.push_back(k_vertex);
00606     }
00607   return point;
00608 }

Here is the call graph for this function:

std::vector<int> Point_set::inside_rectangle ( const V_3D p1,
const V_3D p2 
) const

std::vector<int> Point_set::outside_rectangle ( const V_3D p1,
const V_3D p2 
) const

std::vector< int > Point_set::other_index ( const std::vector< int > &  index  )  const

Definition at line 610 of file Point_set.cpp.

References size().

00611 {
00612   std::vector <int> point;
00613   int k_vertex=0,N_vertex=size();
00614   int k_vertex_2=0,N_vertex_2=index.size();
00615   int is_found=0;
00616   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00617     {
00618       is_found=0;
00619       for(k_vertex_2=0;is_found==0 && k_vertex_2<N_vertex_2;k_vertex_2++)
00620         if(k_vertex==k_vertex_2)
00621           is_found=1;
00622       if(is_found==0)
00623         point.push_back(k_vertex);
00624     }
00625   return point;
00626 }

Here is the call graph for this function:

const double * Point_set::get_vertex (  )  const

Definition at line 629 of file Point_set.cpp.

References vertex.

Referenced by delete_index(), exist(), export_visible_off(), get_vertex(), get_vertex_v3d(), and keep_index().

00629 {return &vertex[0];}

Here is the caller graph for this function:

std::vector< double > Point_set::get_vertex_vector (  )  const

Definition at line 630 of file Point_set.cpp.

References vertex.

Referenced by add_vertex(), and operator=().

00630 {return vertex;}

Here is the caller graph for this function:

int Point_set::keep_index ( int  k_start,
int  k_end 
)

Definition at line 655 of file Point_set.cpp.

References get_vertex(), size(), and vertex.

00656 {
00657   if(k_start>k_end || k_start<0 || k_end>=size())
00658     {printf("Error in keep_index in Point_set, (k_start,k_end)=(%d,%d) and size=%d\n",k_start,k_end,size());exit(-1);}
00659 
00660   vector <double> new_vertex;
00661   int k_vertex=0;
00662   int k_dim=0;
00663   for(k_vertex=k_start;k_vertex<=k_end;k_vertex++)
00664     for(k_dim=0;k_dim<3;k_dim++)
00665       new_vertex.push_back(get_vertex(k_vertex,k_dim));
00666   vertex=new_vertex;
00667   return 0;
00668 }

Here is the call graph for this function:

int Point_set::delete_index ( int  k_start,
int  k_end 
)

Definition at line 669 of file Point_set.cpp.

References get_vertex(), size(), and vertex.

00670 {
00671   if(k_start>k_end || k_start<0 || k_end>=size())
00672     {printf("Error in delete_index in Point_set, (k_start,k_end)=(%d,%d) and size=%d\n",k_start,k_end,size());exit(-1);}
00673 
00674   vector <double> new_vertex;
00675   int k_vertex=0;
00676   int N_vertex=size();
00677   int k_dim=0;
00678   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00679     if(k_vertex<k_start || k_vertex>k_end)
00680       for(k_dim=0;k_dim<3;k_dim++)
00681         new_vertex.push_back(get_vertex(k_vertex,k_dim));
00682   vertex=new_vertex;
00683   return 0;  
00684 }

Here is the call graph for this function:

V_3D Point_set::get_middle_point (  )  const

Definition at line 329 of file Point_set.cpp.

References get_max_point(), and get_min_point().

Referenced by center_point_set(), Mesh_object::get_middle_point(), rotate_centered(), and scale_centered().

00330 {
00331   V_3D min_point = get_min_point();
00332   V_3D max_point = get_max_point();
00333 
00334   return 0.5*(min_point+max_point); 
00335 }

Here is the call graph for this function:

Here is the caller graph for this function:

V_3D Point_set::get_min_point (  )  const

Definition at line 336 of file Point_set.cpp.

References get_vertex_number(), and get_vertex_v3d().

Referenced by get_middle_point(), Mesh_object::get_min_point(), and get_size_set().

00337 {
00338   V_3D min_point(9999,9999,9999);
00339   V_3D current;
00340   int k_vertex=0,N_vertex=get_vertex_number();
00341   int k_dim=0;
00342   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00343     {
00344       current = get_vertex_v3d(k_vertex);
00345       for(k_dim=0;k_dim<3;k_dim++)
00346         if(current[k_dim]<min_point[k_dim])
00347           min_point[k_dim] = current[k_dim];
00348     }
00349 
00350   return min_point;
00351 }

Here is the call graph for this function:

Here is the caller graph for this function:

V_3D Point_set::get_max_point (  )  const

Definition at line 352 of file Point_set.cpp.

References get_vertex_number(), and get_vertex_v3d().

Referenced by Mesh_object::get_max_point(), get_middle_point(), and get_size_set().

00353 {
00354   V_3D max_point(-9999,-9999,-9999);
00355   V_3D current;
00356   int k_vertex=0,N_vertex=get_vertex_number();
00357   int k_dim=0;
00358   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00359     {
00360       current = get_vertex_v3d(k_vertex);
00361       for(k_dim=0;k_dim<3;k_dim++)
00362         if(current[k_dim]>max_point[k_dim])
00363           max_point[k_dim] = current[k_dim];
00364     }
00365   return max_point;
00366 }

Here is the call graph for this function:

Here is the caller graph for this function:

V_3D Point_set::get_size_set (  )  const

Definition at line 367 of file Point_set.cpp.

References get_max_point(), and get_min_point().

Referenced by export_visible_off(), Mesh_object::get_size_mesh(), and unitize_size().

00368 {
00369   V_3D min_point = get_min_point();
00370   V_3D max_point = get_max_point();
00371 
00372   return (max_point-min_point);
00373 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::center_point_set (  ) 

Definition at line 376 of file Point_set.cpp.

References get_middle_point(), and translate().

Referenced by Mesh_object::center_mesh().

00376 {return translate(-1.0*get_middle_point());}

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::unitize_size (  ) 

Definition at line 1218 of file Point_set.cpp.

References V_3D::get_max_of_coeff(), get_size_set(), and scale().

Referenced by Mesh_object::unitize_size().

01219 {
01220   double max_size = get_size_set().get_max_of_coeff();
01221   if(fabs(max_size)<0.00001)
01222     {printf("Error in unitize size in Point_set\n");exit(-1);}
01223   return scale(1.0/max_size);
01224 }

Here is the call graph for this function:

Here is the caller graph for this function:

int Point_set::load_off_file ( const char *  filename  ) 

load off vertices

Definition at line 788 of file Point_set.cpp.

Referenced by Mesh_object::load_off_file().

00789 {std::string file=filename;return load_off_file(file);}

Here is the caller graph for this function:

int Point_set::load_off_file ( const std::string &  filename  ) 

load off vertices

Definition at line 790 of file Point_set.cpp.

References add_vertex(), destroy(), and SIZE_BUFFER.

00791 {
00792  
00793   destroy();
00794 
00795 #define SIZE_BUFFER 2048
00796   char buffer[SIZE_BUFFER]={'\0'};
00797   
00798   FILE *fid=NULL;
00799   fid=fopen(filename.data(),"r");
00800   if(fid==NULL)
00801     {printf("ERROR loading %s in load_off_file in Point_set\n",filename.data());exit(-1);}
00802 
00803 
00804 
00805   //detect if OFF or NOFF
00806   int is_NOFF=0;
00807   while(strcmp(buffer,"OFF")!=0 && strcmp(buffer,"NOFF")!=0)
00808     {
00809       if(fscanf(fid,"%s",buffer)==EOF)
00810         {printf("ERROR file %s is not off file\n",filename.data());exit(-1);}
00811       if(buffer[0]=='#')//comments
00812         fgets(buffer,sizeof(buffer),fid);
00813     }
00814   if(strcmp(buffer,"NOFF")==0)
00815     is_NOFF=1;
00816 
00817   //pass comments
00818   fscanf(fid,"%s",buffer);
00819   while(buffer[0]=='#')//comments
00820     {
00821       fgets(buffer,sizeof(buffer),fid);
00822       fscanf(fid,"%s",buffer);
00823     }
00824 
00825 
00826   //read Number of vertices
00827   int N_vertex=0;
00828   int k_vertex=0;
00829   N_vertex=atoi(buffer);//N_vertex
00830   fgets(buffer,sizeof(buffer),fid);//read line
00831 
00832   float X[3]={0.0,0.0,0.0};
00833   if(is_NOFF==0)
00834     while(k_vertex<N_vertex)
00835       {
00836         if(fscanf(fid,"%f %f %f",X,X+1,X+2)!=3)
00837           {
00838             fscanf(fid,"%s",buffer);
00839             if(buffer[0]!='#')
00840               {printf("ERROR loading %s in Point_set\n",filename.data());exit(-1);}
00841             else//read line
00842               fgets(buffer,sizeof(buffer),fid);
00843           }
00844         else
00845           {
00846             add_vertex(X[0],X[1],X[2]);
00847             k_vertex++;
00848           }
00849       }
00850   else
00851     while(k_vertex<N_vertex)
00852       {
00853         if(fscanf(fid,"%f %f %f %*f %*f %*f",X,X+1,X+2)!=3)
00854           {
00855             fscanf(fid,"%s",buffer);
00856             if(buffer[0]!='#')
00857               {printf("ERROR loading %s in Point_set\n",filename.data());exit(-1);}
00858             else//read line
00859               fgets(buffer,sizeof(buffer),fid);
00860           }
00861         else
00862           {
00863             add_vertex(X[0],X[1],X[2]);
00864             k_vertex++;
00865           }
00866       }
00867 
00868 
00869   if(fclose(fid)!=0)
00870     {printf("ERROR closing %s in load_off_file in Point_set\n",filename.data());exit(-1);}
00871 
00872   return 0;
00873 }

Here is the call graph for this function:

int Point_set::load_obj_file ( const char *  filename  ) 

load obj vertices

Definition at line 895 of file Point_set.cpp.

Referenced by Mesh_object::load_obj_file().

00896 {std::string file=filename;return load_obj_file(file);}

Here is the caller graph for this function:

int Point_set::load_obj_file ( const std::string &  filename  ) 

load obj vertices

Definition at line 897 of file Point_set.cpp.

References add_vertex(), destroy(), and SIZE_BUFFER.

00898 {
00899   destroy();
00900 
00901 #define SIZE_BUFFER 2048
00902   char buffer[SIZE_BUFFER]={'\0'};
00903   
00904   FILE *fid=NULL;
00905   fid=fopen(filename.data(),"r");
00906   if(fid==NULL)
00907     {printf("ERROR loading %s in load_obj_file in Point_set\n",filename.data());exit(-1);}
00908 
00909   float X[3];
00910   while(fscanf(fid,"%s",buffer)!=EOF)
00911     {
00912       if(strcmp(buffer,"v")==0)
00913         {
00914           if(fscanf(fid,"%f %f %f\n",X,X+1,X+2)!=3)
00915             {printf("Error reading vertices in load_obj_file in Point_set\n");exit(-1);}
00916           add_vertex(X[0],X[1],X[2]);
00917         }
00918       else //read the whole line
00919         fgets(buffer,sizeof(buffer),fid);
00920     }
00921 
00922 
00923   if(fclose(fid)!=0)
00924     {printf("ERROR closing %s in load_obj_file in Point_set\n",filename.data());exit(-1);}
00925   return 0;
00926 }

Here is the call graph for this function:

int Point_set::load_collada_file ( const char *  filename  ) 

load Collada vertices

Definition at line 1068 of file Point_set.cpp.

Referenced by load_collada_file(), and Mesh_object::load_collada_file().

01069 {std::string file=filename;return load_collada_file(file);}

Here is the caller graph for this function:

int Point_set::load_collada_file ( const std::string &  filename  ) 

load Collada vertices

Definition at line 1070 of file Point_set.cpp.

References load_collada_file().

01071 {return load_collada_file(filename,"_ALL_");}

Here is the call graph for this function:

int Point_set::load_collada_file ( const std::string &  filename,
const std::string &  name 
)

load Collada vertices with name

the name _ALL_ can be given to load everything

Definition at line 1131 of file Point_set.cpp.

References load_collada_mesh_vertices().

01132 {
01133   TiXmlDocument doc(filename);
01134   if(!doc.LoadFile())
01135     {
01136       printf("ERROR opening %s\n",filename.data());
01137       cerr << "error #" << doc.ErrorId() << " : " << doc.ErrorDesc() << endl;
01138       exit(-1);
01139     }
01140 
01141 
01142   //find library_geometries
01143   TiXmlHandle root(doc.RootElement());
01144   TiXmlNode *lib_geometry=NULL;lib_geometry=root.ToNode();
01145   if(lib_geometry==NULL)
01146     {printf("Error reading file %s in load_collada_file in Point_set\n",filename.data());exit(-1);}
01147 
01148 
01149   //go to library_geometries entry
01150   lib_geometry = lib_geometry->FirstChild("library_geometries");
01151 
01152   if(lib_geometry==NULL)
01153     {printf("Error in file %s, cannot find library_geometries in load_collada_file in Point_set\n",filename.data());exit(-1);}
01154   
01155   
01156   //load all geometries
01157   TiXmlNode *geometry=NULL;
01158   geometry=lib_geometry->FirstChild("geometry");
01159   if(geometry==NULL)
01160     {printf("Error cannot find geometry in file %s in load_collada_file in Point_set\n",filename.data());exit(-1);}
01161   
01162 
01163   std::string geometry_id;
01164   int is_find=0;
01165   do
01166     {
01167       if(geometry->ToElement()->Attribute("id")==NULL)
01168         {printf("Error in file %s, geometry does not have id \n",filename.data());exit(-1);}
01169       geometry_id = geometry->ToElement()->Attribute("id");
01170       if(geometry_id==name || name=="_ALL_")
01171         {
01172           load_collada_mesh_vertices(geometry,filename);
01173           if(name!="_ALL_")
01174             is_find=1;
01175         }
01176       geometry=geometry->NextSiblingElement("geometry");
01177     }while(geometry!=NULL && is_find==0);
01178   
01179 
01180 
01181   if(is_find==0 && name!="_ALL_")
01182     {printf("Error in file %s, no geometry found to load Point_set with id=\"%s\"\n",filename.data(),name.data());exit(-1);}
01183 
01184   return 0; 
01185 }

Here is the call graph for this function:

int Point_set::load_collada_file ( const char *  filename,
const char *  name 
)

load Collada vertices with name

the name _ALL_ can be given to load everything

Definition at line 1129 of file Point_set.cpp.

References load_collada_file().

01130 {std::string file=filename;std::string mesh_name=name;return load_collada_file(file,mesh_name);}

Here is the call graph for this function:

int Point_set::write_off_type ( const char *  filename  )  const

Add vertices description in a .off type.

Definition at line 876 of file Point_set.cpp.

Referenced by Mesh_object::save_off_file(), and write_g_type().

00877 {std::string file=filename;return write_off_type(file);}

Here is the caller graph for this function:

int Point_set::write_off_type ( const std::string &  filename  )  const

Add vertices description in a .off type.

Definition at line 878 of file Point_set.cpp.

References size().

00879 {
00880   FILE *fid=NULL;
00881   fid=fopen(filename.data(),"a");
00882   if(fid==NULL)
00883     {printf("ERROR loading %s in write_off_type in Point_set\n",filename.data());exit(-1);}
00884 
00885   int k_vertex=0,N_vertex=size();
00886   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00887     fprintf(fid,"%9.9f %9.9f %9.9f\n",(*this)(k_vertex,0),(*this)(k_vertex,1),(*this)(k_vertex,2));
00888 
00889   if(fclose(fid)!=0)
00890     {printf("ERROR closing %s in write_off_type in Point_set\n",filename.data());exit(-1);}
00891 
00892   return 0;
00893 }

Here is the call graph for this function:

int Point_set::write_obj_type ( const char *  filename  )  const

Add vertices description in a .obj type.

Definition at line 929 of file Point_set.cpp.

Referenced by Mesh_object::save_obj_file().

00930 {std::string file=filename;return write_obj_type(file);}

Here is the caller graph for this function:

int Point_set::write_obj_type ( const std::string &  filename  )  const

Add vertices description in a .obj type.

Definition at line 931 of file Point_set.cpp.

References size().

00932 {
00933   FILE *fid=NULL;
00934   fid=fopen(filename.data(),"a");
00935   if(fid==NULL)
00936     {printf("ERROR loading %s in write_obj_type in Point_set\n",filename.data());exit(-1);}
00937 
00938   int k_vertex=0,N_vertex=size();
00939   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00940     fprintf(fid,"v %9.9f %9.9f %9.9f\n",(*this)(k_vertex,0),(*this)(k_vertex,1),(*this)(k_vertex,2));
00941 
00942   if(fclose(fid)!=0)
00943     {printf("ERROR closing %s in write_obj_type in Point_set\n",filename.data());exit(-1);}
00944 
00945   return 0;
00946 }

Here is the call graph for this function:

int Point_set::load_g_file ( const char *  filename  ) 

load g file vertices

Definition at line 1009 of file Point_set.cpp.

Referenced by Mesh_object::load_g_file().

01010 {std::string file=filename;return load_g_file(file);}

Here is the caller graph for this function:

int Point_set::load_g_file ( const std::string &  filename  ) 

load g file vertices

Definition at line 1011 of file Point_set.cpp.

References add_vertex(), destroy(), and SIZE_BUFFER.

01012 {
01013    destroy();
01014 
01015 #define SIZE_BUFFER 2048
01016   char buffer[SIZE_BUFFER]={'\0'};
01017   
01018   FILE *fid=NULL;
01019   fid=fopen(filename.data(),"r");
01020   if(fid==NULL)
01021     {printf("ERROR loading %s in load_g_file in Point_set\n",filename.data());exit(-1);}
01022 
01023 
01024 
01025 
01026 
01027   //pass comments
01028   fscanf(fid,"%s",buffer);
01029   while(buffer[0]=='#')//comments
01030     {
01031       fgets(buffer,sizeof(buffer),fid);
01032       fscanf(fid,"%s",buffer);
01033     }
01034 
01035 
01036   //read Number of vertices
01037   int N_vertex=0;
01038   int k_vertex=0;
01039   N_vertex=atoi(buffer);//N_vertex
01040   fgets(buffer,sizeof(buffer),fid);//read line
01041 
01042   float X[3]={0.0,0.0,0.0};
01043   while(k_vertex<N_vertex)
01044     {
01045       if(fscanf(fid,"%f %f %f",X,X+1,X+2)!=3)
01046         {
01047           fscanf(fid,"%s",buffer);
01048           if(buffer[0]!='#')
01049             {printf("ERROR loading %s in Point_set\n",filename.data());exit(-1);}
01050           else//read line
01051             fgets(buffer,sizeof(buffer),fid);
01052         }
01053       else
01054         {
01055           add_vertex(X[0],X[1],X[2]);
01056           k_vertex++;
01057         }
01058     }
01059 
01060 
01061   if(fclose(fid)!=0)
01062     {printf("ERROR closing %s in load_obj_file in Point_set\n",filename.data());exit(-1);}
01063  
01064   return 0;
01065 }

Here is the call graph for this function:

int Point_set::write_g_type ( const char *  filename  )  const

write g type file vertices

Definition at line 1235 of file Point_set.cpp.

Referenced by Mesh_object::save_g_file().

01236 {return write_g_type(std::string(filename));}

Here is the caller graph for this function:

int Point_set::write_g_type ( const std::string &  filename  )  const

write g type file vertices

the same as off, only points

Definition at line 1237 of file Point_set.cpp.

References write_off_type().

01238 {
01240   return write_off_type(filename);
01241 }

Here is the call graph for this function:

int Point_set::export_visible_off ( const char *  filename,
double  s_cube_size 
) const

export into mesh in off file

the size of the cube is defined as TOTAL_MESH_SIZE/s_cube_size

Definition at line 952 of file Point_set.cpp.

00953 {std::string file=filename;return export_visible_off(file,s_cube_size);}

int Point_set::export_visible_off ( const std::string &  filename,
double  s_cube_size 
) const

Definition at line 954 of file Point_set.cpp.

References V_3D::get_max_of_coeff(), get_size_set(), get_vertex(), and size().

00955 {
00956   V_3D D=get_size_set();
00957   double d_max=D.get_max_of_coeff();
00958 
00959   double s_size=d_max/s_cube_size;
00960   
00961 
00962 
00963   FILE *fid=NULL;
00964   fid=fopen(filename.data(),"w");
00965   if(fid==NULL)
00966     {printf("ERROR loading %s in export_visible_off in Point_set\n",filename.data());exit(-1);}
00967 
00968 
00969   fprintf(fid,"#VISIBLE OFF SCENE %s\n",filename.data());
00970   fprintf(fid,"#N_vertex=%d\n",size());
00971   fprintf(fid,"OFF\n");
00972   fprintf(fid,"%d %d 0\n",8*size(),6*size());
00973 
00974   int k_vertex=0,N_vertex=size();
00975   V_3D current;
00976   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00977     {
00978       current=get_vertex(k_vertex);
00979       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]-s_size,current[1]-s_size,current[2]-s_size);
00980       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]+s_size,current[1]-s_size,current[2]-s_size);
00981       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]+s_size,current[1]+s_size,current[2]-s_size);
00982       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]-s_size,current[1]+s_size,current[2]-s_size);
00983 
00984       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]-s_size,current[1]-s_size,current[2]+s_size);
00985       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]+s_size,current[1]-s_size,current[2]+s_size);
00986       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]+s_size,current[1]+s_size,current[2]+s_size);
00987       fprintf(fid,"%9.9f %9.9f %9.9f\n",current[0]-s_size,current[1]+s_size,current[2]+s_size);
00988     }
00989   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00990     {
00991       fprintf(fid,"4 %d %d %d %d\n",8*k_vertex+0,8*k_vertex+1,8*k_vertex+2,8*k_vertex+3);
00992       fprintf(fid,"4 %d %d %d %d\n",8*k_vertex+1,8*k_vertex+5,8*k_vertex+6,8*k_vertex+2);
00993       fprintf(fid,"4 %d %d %d %d\n",8*k_vertex+5,8*k_vertex+4,8*k_vertex+7,8*k_vertex+6);
00994       fprintf(fid,"4 %d %d %d %d\n",8*k_vertex+4,8*k_vertex+0,8*k_vertex+3,8*k_vertex+7);
00995       fprintf(fid,"4 %d %d %d %d\n",8*k_vertex+2,8*k_vertex+6,8*k_vertex+7,8*k_vertex+3);
00996       fprintf(fid,"4 %d %d %d %d\n",8*k_vertex+0,8*k_vertex+4,8*k_vertex+5,8*k_vertex+1);
00997     }
00998   
00999   fprintf(fid,"#EOF [OK] %s\n",filename.data());
01000   if(fclose(fid)!=0)
01001     {printf("ERROR closing %s in export_visible_off in Point_set\n",filename.data());exit(-1);}
01002 
01003 
01004   return 0;
01005 }

Here is the call graph for this function:

double & Point_set::operator[] ( int  index  ) 

Definition at line 39 of file Point_set.cpp.

References vertex.

00040 {
00041   if(index<0)
00042     {printf("Error index<0 (%d) in operator[] in Point_set\n",index);exit(-1);}
00043   else if(index>=int(vertex.size()))
00044     {printf("Error in operator[], index too large compared to size in Point_set (%d/%d)\n",index,vertex.size());exit(-1);}
00045   return vertex[index];
00046 }

double Point_set::operator[] ( int  index  )  const

Definition at line 47 of file Point_set.cpp.

References vertex.

00048 {
00049   if(index<0)
00050     {printf("Error index<0 (%d) in operator[] {const} in Point_set\n",index);exit(-1);}
00051   else if(index>=int(vertex.size()))
00052     {printf("Error in operator[] {const}, index too large compared to size in Point_set (%d/%d)\n",index,vertex.size());exit(-1);}
00053   return vertex[index];
00054 }

V_3D Point_set::operator() ( int  index  )  const

Definition at line 632 of file Point_set.cpp.

References vertex.

00633 {
00634   if(3*index+2>=int(vertex.size()) || index<0)
00635     {printf("Error in operator() in Point_set index(%d) is not correct in size(%d)\n",index,vertex.size());exit(-1);}
00636 
00637   V_3D v(vertex[3*index],vertex[3*index+1],vertex[3*index+2]);
00638   return v;
00639 }

double Point_set::operator() ( int  k_index,
int  k_dim 
) const

Definition at line 640 of file Point_set.cpp.

References vertex.

00641 {
00642   if(3*index+k_dim<0 || 3*index+k_dim>=int(vertex.size()))
00643     {printf("Error int const operator(index,k_dim) is not correct in operator() in Point_set -> (%d,%d) with size=%d\n",index,k_dim,vertex.size());exit(-1);}
00644   return vertex[3*index+k_dim];
00645 }

double & Point_set::operator() ( int  k_index,
int  k_dim 
)

Definition at line 646 of file Point_set.cpp.

References vertex.

00647 {
00648   if(3*index+k_dim<0 || 3*index+k_dim>=int(vertex.size()))
00649     {printf("Error in operator(index,k_dim) is not correct in operator() in Point_set -> (%d,%d) with size=%d\n",index,k_dim,vertex.size());exit(-1);}
00650   return vertex[3*index+k_dim];
00651 }

const Point_set & Point_set::operator= ( const Point_set p  ) 

Definition at line 778 of file Point_set.cpp.

References get_vertex_vector(), and vertex.

00779 {
00780   vertex=p.get_vertex_vector();
00781   return (*this);
00782 }

Here is the call graph for this function:

int Point_set::load_collada_mesh_vertices ( TiXmlNode *  geometry_node,
const std::string &  filename 
) [private]

Load vertices starting with node positionned at geometry entry.

Definition at line 1074 of file Point_set.cpp.

References add_vertex(), and load_collada_float_array().

Referenced by load_collada_file().

01075 {
01076 
01077   TiXmlNode *mesh_node=NULL;
01078   mesh_node=geometry_node->FirstChild("mesh");
01079   
01080   //need to find mesh
01081   if(mesh_node==NULL)
01082     {printf("Error in Point_set in load_collada_mesh_connectivity for file %s\n",filename.data());exit(-1);}
01083 
01084   
01085   //then try to find position array
01086   TiXmlElement *mesh_source_root=NULL;
01087   TiXmlElement *mesh_source=NULL;
01088   mesh_source=mesh_node->FirstChild("source")->ToElement();
01089   mesh_source_root=mesh_source;
01090   if(mesh_source==NULL)
01091     {printf("Error, no <source> entry in <mesh> in load_collada_mesh_vertices in Point_set in file %s\n",filename.data());exit(-1);}
01092 
01093   std::string name_attribute;
01094   do
01095     {
01096       if(mesh_source->Attribute("name")!=NULL)
01097         name_attribute = mesh_source->Attribute("name");
01098       if(name_attribute!="position")
01099         mesh_source = mesh_source->NextSiblingElement("source");
01100     }while(mesh_source!=NULL && name_attribute!="position");
01101 
01102   if(name_attribute!="position")
01103     {
01104       //might try to find [name]-positions in id
01105       std::string extension_to_find="positions";
01106       mesh_source=mesh_source_root;
01107       do
01108         {
01109           if(mesh_source->Attribute("id")!=NULL)
01110             name_attribute = mesh_source->Attribute("id");
01111           if(name_attribute.find(extension_to_find)!=std::string::npos)
01112             mesh_source->NextSiblingElement("source");    
01113         }while(mesh_source!=NULL && name_attribute.find(extension_to_find)==std::string::npos);
01114 
01115 
01116       if(name_attribute.find(extension_to_find)==std::string::npos)
01117         {printf("Error cannot find positions in <mesh><source> in load_collada_mesh_vertices in Point_set in file %s\n",filename.data());exit(-1);}
01118       //else find [something]positions
01119     }
01120 
01121   //load_float_array
01122   std::vector <double> position;
01123   position = load_collada_float_array(mesh_source,filename);
01124 
01125   //add the vertex
01126   return add_vertex(position);
01127 }

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< double > Point_set::load_collada_float_array ( TiXmlNode *  mesh_source,
const std::string &  filename 
) [private]

load a float_array in a collada file

Definition at line 1190 of file Point_set.cpp.

Referenced by load_collada_mesh_vertices().

01191 {
01192   TiXmlElement *float_array_node=NULL;
01193   float_array_node = mesh_source->FirstChild("float_array")->ToElement();
01194   if(float_array_node==NULL)
01195     {printf("Error cannot find float_array in load_collada_float_array in Point_set in file %s\n",filename.data());exit(-1);}
01196   
01197   int count=0;
01198   float_array_node->QueryIntAttribute("count",&count);
01199   if(float_array_node->FirstChild()==NULL)
01200     {printf("Error in load_collada_float_array in Point_set in file %s\n",filename.data());exit(-1);}
01201   std::string full_array = float_array_node->FirstChild()->ToText()->ValueStr();
01202 
01203   //fill vector array
01204   std::vector <double> array;
01205   int c=0,k1=0,k0=0;
01206   string X;
01207   for(c=0;c<count;c++)
01208     {
01209       k1= full_array.find(" ",k1+1);
01210       X = full_array.substr(k0,k1-k0);
01211       array.push_back(atof(X.data())); //add vertex
01212       k0=k1+1;
01213     }
01214 
01215   return array;
01216 }

Here is the caller graph for this function:


Friends And Related Function Documentation

Point_set operator+ ( const Point_set p,
V_3D  T 
) [friend]

Definition at line 694 of file Point_set.cpp.

00695 {
00696   Point_set set;
00697   int N_vertex=p.size();
00698   int k_vertex=0;
00699   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00700     set.set_vertex(k_vertex,p(k_vertex)+T);
00701   return set;
00702 }

Point_set operator+ ( const V_3D T,
const Point_set  
) [friend]

Point_set operator- ( const Point_set p,
V_3D  T 
) [friend]

Definition at line 713 of file Point_set.cpp.

00714 {
00715   Point_set set;
00716   int N_vertex=p.size();
00717   int k_vertex=0;
00718   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00719     set.set_vertex(k_vertex,p(k_vertex)-T);
00720   return set;
00721 }

Point_set operator- ( const V_3D T,
const Point_set  
) [friend]

Point_set operator* ( const Matrix M,
const Point_set p 
) [friend]

Definition at line 733 of file Point_set.cpp.

00734 {
00735   Point_set set;
00736   int N_vertex=p.size();
00737   int k_vertex=0;
00738   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00739     set.set_vertex(k_vertex,M*p(k_vertex));
00740   return set;
00741 }

bool operator== ( const Point_set pa,
const Point_set pb 
) [friend]

Definition at line 743 of file Point_set.cpp.

00744 {
00745   if(pa.size()==pb.size())
00746     {
00747       int k_vertex=0,N_vertex=pa.size();
00748       for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00749         if(pa(k_vertex)!=pb(k_vertex))
00750           return false;
00751       return true;
00752     }
00753   return false;
00754 }

bool operator!= ( const Point_set pa,
const Point_set pb 
) [friend]

Definition at line 756 of file Point_set.cpp.

00757 {
00758   if(pa.size()==pb.size())
00759     {
00760       int k_vertex=0,N_vertex=pa.size();
00761       for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00762         if(pa(k_vertex)!=pb(k_vertex))
00763           return true;
00764       return false;
00765     }
00766   return true;
00767 }

ostream& operator<< ( ostream &  flux,
const Point_set p 
) [friend]

Definition at line 769 of file Point_set.cpp.

00770 {
00771   int k_vertex=0;
00772   int N_vertex=p.size();
00773   for(k_vertex=0;k_vertex<N_vertex;k_vertex++)
00774     flux<<"("<<p.get_vertex(k_vertex,0)<<","<<p.get_vertex(k_vertex,1)<<","<<p.get_vertex(k_vertex,2)<<")\n";
00775   return flux;
00776 }


Member Data Documentation

std::vector<double> Point_set::vertex [private]


The documentation for this class was generated from the following files:

Generated on Mon Mar 30 16:58:10 2009 by  doxygen 1.5.6