00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef POINT_SET_H_
00033 # define POINT_SET_H_
00034
00035
00036 #include <stdlib.h>
00037 #include <iostream>
00038 #include <cmath>
00039 #include <string>
00040 #include <errno.h>
00041 #include <stdio.h>
00042
00043 #include <tinyXml/tinyxml.h>
00044 #include <tinyXml/tinystr.h>
00045
00046 #include <V_3D.h>
00047 #include <Matrix.h>
00048
00049 #include <vector>
00050 using namespace std;
00051
00052
00054
00058 class Point_set
00059 {
00060 public:
00061
00062
00063
00064
00065
00066
00067
00068
00070 Point_set();
00071
00073 Point_set(const Point_set &);
00074 ~Point_set();
00075
00077 int destroy();
00078
00079
00080
00081
00082
00083
00084
00085
00087
00088 int get_vertex_number() const;
00089
00091
00092 int size() const;
00093
00095
00096 int resize(int N_vertex);
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 double& get_vertex(int k_vertex,int k_dim);
00107 double get_vertex(int k_vertex,int k_dim) const;
00108 const double* get_vertex_p(int k_vertex);
00109 V_3D get_vertex(int k_vertex) const;
00110 V_3D get_vertex_v3d(int k_vertex) const;
00111
00112
00113
00114
00115
00116
00117
00118 int set_vertex(int k_vertex,double x,double y,double z);
00119 int set_vertex(int k_vertex,int k_dim,double value);
00120 int set_vertex(int k_vertex,V_3D v);
00121 int set_vertex(const std::vector <double>& to_set);
00122 int set_vertex(int k_vertex,double* v);
00123 int set_vertex(int k_vertex,int dim,double *v);
00124 int set_vertex(const Point_set& p);
00125
00126
00127
00128
00129
00130
00131 int add_vertex(double x,double y,double z);
00132 int add_vertex(const V_3D& v);
00133 int add_vertex(const std::vector <double>& to_add);
00134 int add_vertex(const std::vector <V_3D>& to_add);
00135 int add_vertex(const double* v);
00136 int add_vertex(int dim,double *v);
00137 int add_vertex(const Point_set& p);
00138
00139
00140
00141
00142
00143
00144 int add_unique(double x,double y,double z,double epsilon);
00145 int add_unique(const V_3D& v,double epsilon);
00146 int add_unique(const double* v,double epsilon);
00147
00148 int exist(const V_3D& v) const;
00149 int exist(const V_3D& v,double epsilon) const;
00150 int exist(double x,double y,double z) const;
00151 int exist(double x,double y,double z,double epsilon) const;
00152
00153 int eliminate(int k_index);
00154 int eliminate(const std::vector <int>& k_index);
00155 int eliminate(const std::vector <double>& k_index);
00156 int eliminate(double x,double y,double z);
00157 int eliminate(double x,double y,double z,double epsilon);
00158 int eliminate(const V_3D& x,double epsilon);
00159 int eliminate(const V_3D& x);
00160 int eliminate(const double* x,double epsilon);
00161 int eliminate(const double* x);
00162
00163
00164
00165
00166
00167 int matrix_transform(const Matrix& M);
00168
00169
00170 int rotate(const V_3D& n,double angle);
00171 int rotate(double n_x,double n_y,double n_z,double angle);
00172 int rotate(const double *n,double angle);
00173
00174 int rotate_centered(const V_3D& n,double angle);
00175 int rotate_centered(double n_x,double n_y,double n_z,double angle);
00176 int rotate_centered(const double *n,double angle);
00177
00178 int rotate(const V_3D& n,double angle,const V_3D& center);
00179 int rotate(double n_x,double n_y,double n_z,double angle,const V_3D& center);
00180 int rotate(const double *n,double angle,const V_3D& center);
00181
00182
00183
00184
00185 int translate(double t_x,double t_y,double t_z);
00186 int translate(const double *t);
00187 int translate(const V_3D& t);
00188
00189 int scale(double s_x,double s_y,double s_z);
00190 int scale(const double *s);
00191 int scale(const V_3D& s);
00192 int scale(double s);
00193
00194 int scale_centered(double s_x,double s_y,double s_z);
00195 int scale_centered(const double *s);
00196 int scale_centered(const V_3D& s);
00197 int scale_centered(double s);
00198
00199
00200
00201
00202
00203
00204
00205
00206 double get_closest_distance(double x,double y,double z,int *index) const;
00207 double get_closest_distance(const double* x,int *index) const;
00208 double get_closest_distance(const V_3D& x,int *index) const;
00209
00210 double get_further_distance(double x,double y,double z,int *index) const;
00211 double get_further_distance(const double* x,int *index) const;
00212 double get_further_distance(const V_3D& x,int *index) const;
00213
00214 double distance_to_index(double x,double y,double z,int index) const;
00215 double distance_to_index(const double* x,int index) const;
00216 double distance_to_index(const V_3D& x,int index) const;
00217
00218
00219 std::vector <int> N_closest(const V_3D& center,int N_closest) const;
00220 std::vector <int> N_closest(double x,double y,double z,int N_closest) const;
00221 std::vector <int> N_closest(double *x,int N_closest) const;
00222
00224 V_3D get_closest_vertex(const V_3D& center) const;
00226 V_3D get_closest_vertex(double x,double y,double z) const;
00228 V_3D get_closest_vertex(const double *x) const;
00229
00230
00231
00232
00233 std::vector <int> inside_circle(const V_3D& center,double radius) const;
00234 std::vector <int> inside_circle(double x,double y,double z,double radius) const;
00235
00236 std::vector <int> outside_circle(const V_3D& center,double radius) const;
00237 std::vector <int> outside_circle(double x,double y,double z,double radius) const;
00238
00239 std::vector <int> inside_box(const V_3D& p1,const V_3D& p2) const;
00240 std::vector <int> outside_box(const V_3D& p1,const V_3D& p2) const;
00241
00242 std::vector <int> inside_tetrahedra(const V_3D& p1,const V_3D& p2,const V_3D& p3,const V_3D& p4) const;
00243 std::vector <int> outside_tetrahedra(const V_3D& p1,const V_3D& p2,const V_3D& p3,const V_3D& p4) const;
00244
00245 std::vector <int> in_half_space(const V_3D& n,const V_3D& x0) const;
00246
00247 std::vector <int> inside_rectangle(const V_3D& p1,const V_3D& p2) const;
00248 std::vector <int> outside_rectangle(const V_3D& p1,const V_3D& p2) const;
00249
00250 std::vector <int> other_index(const std::vector <int>& index) const;
00251
00252
00253
00254
00255
00256
00257 const double *get_vertex() const;
00258 std::vector <double> get_vertex_vector() const;
00259
00260
00261
00262
00263
00264 int keep_index(int k_start,int k_end);
00265 int delete_index(int k_start,int k_end);
00266
00267
00268
00269
00270
00271
00272
00273 V_3D get_middle_point() const;
00274 V_3D get_min_point() const;
00275 V_3D get_max_point() const;
00276 V_3D get_size_set() const;
00277
00278
00279 int center_point_set();
00280
00281
00282 int unitize_size();
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00295 int load_off_file(const char* filename);
00297 int load_off_file(const std::string& filename);
00299 int load_obj_file(const char* filename);
00301 int load_obj_file(const std::string& filename);
00302
00304 int load_collada_file(const char* filename);
00306 int load_collada_file(const std::string& filename);
00308
00309 int load_collada_file(const std::string& filename,const std::string& name);
00311
00312 int load_collada_file(const char* filename,const char* name);
00313
00315 int write_off_type(const char* filename) const;
00317 int write_off_type(const std::string& filename) const;
00319 int write_obj_type(const char* filename) const;
00321 int write_obj_type(const std::string& filename) const;
00322
00323
00324
00326 int load_g_file(const char* filename);
00328 int load_g_file(const std::string& filename);
00330 int write_g_type(const char* filename) const;
00332 int write_g_type(const std::string& filename) const;
00333
00334
00335
00337
00338 int export_visible_off(const char* filename,double s_cube_size) const;
00339 int export_visible_off(const std::string& filename,double s_cube_size) const;
00340
00341
00342
00343
00344
00345
00346 double& operator[](int index);
00347 double operator[](int index) const;
00348 V_3D operator()(int index) const;
00349 double operator()(int k_index,int k_dim) const;
00350 double& operator()(int k_index,int k_dim) ;
00351
00352 const Point_set& operator=(const Point_set&);
00353
00354 friend Point_set operator+(const Point_set&, V_3D T);
00355 friend Point_set operator+(const V_3D& T,const Point_set&);
00356 friend Point_set operator-(const Point_set&, V_3D T);
00357 friend Point_set operator-(const V_3D& T,const Point_set&);
00358 friend Point_set operator*(const Matrix& M,const Point_set&);
00359 friend bool operator==(const Point_set&, const Point_set& );
00360 friend bool operator!=(const Point_set&, const Point_set& );
00361 friend ostream& operator << (ostream& flux,const Point_set& );
00362
00363
00364 private:
00365
00366
00368 int load_collada_mesh_vertices(TiXmlNode* geometry_node,const std::string& filename);
00370 std::vector <double> load_collada_float_array(TiXmlNode *mesh_source,const std::string& filename);
00371
00372
00373 std::vector <double> vertex;
00374
00375 };
00376
00377 #endif