MC_curve.hpp

Go to the documentation of this file.
00001 /*
00002 **    Mesh Converter
00003 **    Copyright (C) 2009  Damien Rohmer
00004 **
00005 **    This program is free software: you can redistribute it and/or modify
00006 **    it under the terms of the GNU General Public License as published by
00007 **    the Free Software Foundation, either version 3 of the License, or
00008 **    (at your option) any later version.
00009 **
00010 **   This program is distributed in the hope that it will be useful,
00011 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **    GNU General Public Licens1e for more details.
00014 **
00015 **    You should have received a copy of the GNU General Public License
00016 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 
00020 #ifndef _MC_CURVE_HPP_
00021 #define _MC_CURVE_HPP_
00022 
00023 #include <MC_v3d_vector.hpp>
00024 #include <MC_int_vector.hpp>
00025 
00026 #include <list>
00027 #include <map>
00028 
00029 #include <stdlib.h>
00030 
00031 namespace mesh_conv
00032 {
00033     class MC_segment;
00034     class MC_int_pair_unique;
00035 
00040     class MC_curve : public MC_v3d_vector
00041     {
00042         public:
00043 
00044         //************************************************//
00045         //************************************************//
00046         //CONSTRUCTORS
00047         //************************************************//
00048         //************************************************//
00049 
00051         MC_curve();
00053         MC_curve(const MC_v3d& v0);
00055         MC_curve(const MC_v3d& v0,const MC_v3d& v1);
00057         MC_curve(const MC_v3d& v0,const MC_v3d& v1,const MC_v3d& v2);
00059         MC_curve(const MC_v3d& v0,const MC_v3d& v1,const MC_v3d& v2,const MC_v3d& v3);
00061         MC_curve(const MC_v3d& v0,const MC_v3d& v1,const MC_v3d& v2,const MC_v3d& v3,const MC_v3d& v4);
00063         MC_curve(const MC_v3d_vector& vec);
00065         MC_curve(const MC_curve& vec);
00067         MC_curve(const MC_double_vector& x_vector,const MC_double_vector& y_vector,const MC_double_vector& z_vector);
00069         MC_curve(const MC_segment& seg);
00070 
00072         MC_curve(const std::list<MC_v3d>& input);
00073 
00074         //************************************************//
00075         //************************************************//
00076         //Information
00077         //************************************************//
00078         //************************************************//
00079 
00081         double length() const;
00082 
00088         std::pair <MC_v3d,std::pair<int,double> > closest_point(const MC_v3d& x) const;
00089 
00094         MC_v3d barycenter() const;
00095 
00096         //************************************************//
00097         //************************************************//
00098         //Manipulation
00099         //************************************************//
00100         //************************************************//
00101 
00105         std::pair <MC_curve,bool> unclosed() const;
00106 
00110         std::pair <MC_curve,bool> closed() const;
00111 
00112 
00117         std::pair<MC_curve,std::pair<std::vector<std::pair<MC_int_pair_unique,MC_double_vector> >,MC_double_vector> > sample_linear(const double& d_L) const;
00118 
00120         std::vector <MC_segment> segment() const;
00122         MC_double_vector relativ_position() const;
00127         std::pair <MC_v3d,std::pair<MC_int_pair_unique,double> > value(const double& t) const;
00132         std::pair <MC_v3d_vector,std::vector<std::pair <MC_int_pair_unique,MC_double_vector> > > value(const MC_double_vector& t) const;
00133 
00138         std::pair <MC_v3d,double> value(const int& k_segment,const double& relative_position) const;
00143         std::pair <MC_v3d_vector,MC_double_vector> value(const MC_int_vector& k_segment,const MC_double_vector& _relative_position) const;
00144 
00149         std::pair <MC_v3d_vector,MC_double_vector> value_t(const MC_double_vector t) const;
00150 
00151         //************************************************//
00152         //************************************************//
00153         //INTPUT/OUTPUT
00154         //************************************************//
00155         //************************************************//
00156 
00184         static MC_curve read_lin(std::istream& stream);
00197         static MC_curve read_vect_curve(std::istream& stream);
00201         static MC_curve read_vect_curve(const std::string& filename);
00202 
00227         static void write_vect(std::ostream& stream,const std::vector<MC_curve>& v_curve,const MC_v3d_vector& v_color=MC_v3d_vector());
00231         static void write_vect(const std::string& filename,const std::vector<MC_curve>& v_curve,const MC_v3d_vector& v_color=MC_v3d_vector());
00235         void write_vect(const std::string& filename) const;
00236 
00238         static std::pair<std::vector<MC_curve>,MC_v3d_vector> read_vect(std::istream& stream);
00240         static std::pair<std::vector<MC_curve>,MC_v3d_vector> read_vect(const std::string& filename);
00241 
00242 
00243         //************************************************//
00244         //************************************************//
00245         //Diff curve
00246         //************************************************//
00247         //************************************************//
00248 
00250         MC_v3d_vector diff_forward() const;
00251 
00256         MC_v3d_vector diff_forward_close() const;
00257 
00258         //************************************************//
00259         //************************************************//
00260         //Classical Shape
00261         //************************************************//
00262         //************************************************//
00263 
00264 
00266         static MC_curve build_circle(const double& R,const int& N=20,const MC_v3d& normal=MC_v3d(0,0,1));
00267 
00269         static MC_curve build_ellipsoid(const double& R1,const double& R2,const int& N=20,const MC_v3d& e0=MC_v3d(),const MC_v3d& e1=MC_v3d(),const double& theta_1=0,const double& theta_2=2*3.14159);
00270 
00272         static MC_curve build_heart(const double& R,const int& N);
00273 
00275         static MC_curve build_line(const MC_v3d& X0,const MC_v3d& X1,const int& N=10);
00276 
00278         static MC_curve build_B_spline(const MC_curve& control_polygon,const int& N_subdiv=10);
00279 
00281         static MC_curve build_square(const int& N);
00282 
00283 
00284 
00285         //************************************************//
00286         //************************************************//
00287         //Laplacian deformation
00288         //************************************************//
00289         //************************************************//
00290 
00292         MC_curve laplacian_deformation(const MC_int_vector& index_constraint,const MC_v3d_vector& position_constraint,const MC_double_vector& weight) const;
00293 
00294         //************************************************//
00295         //************************************************//
00296         //Curve skinning
00297         //************************************************//
00298         //************************************************//
00299 
00301         MC_curve skinning(const MC_curve& old_skeleton,const MC_curve& new_skeleton) const;
00302 
00303 
00304         //************************************************//
00305         //************************************************//
00306         //Rigid deformation
00307         //************************************************//
00308         //************************************************//
00309 
00311         MC_curve isometric_deformation(const MC_int_vector& constraint_index,const MC_v3d_vector& constraint_position,const MC_curve& original_curve,const double& blending_factor) const;
00312 
00313         private:
00314 
00315     };
00316 }
00317 
00318 #endif

Generated on Sun Apr 18 20:24:47 2010 by  doxygen 1.6.1