MC_segment.hpp

Go to the documentation of this file.
00001 
00002 /*
00003 **    Mesh Converter
00004 **    Copyright (C) 2009  Damien Rohmer
00005 **
00006 **    This program is free software: you can redistribute it and/or modify
00007 **    it under the terms of the GNU General Public License as published by
00008 **    the Free Software Foundation, either version 3 of the License, or
00009 **    (at your option) any later version.
00010 **
00011 **   This program is distributed in the hope that it will be useful,
00012 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 **    GNU General Public License for more details.
00015 **
00016 **    You should have received a copy of the GNU General Public License
00017 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 
00021 #ifndef _MC_SEGMENT_HPP_
00022 #define _MC_SEGMENT_HPP_
00023 
00024 
00025 #include <stdlib.h>
00026 #include <iostream>
00027 
00028 #include <MC_v3d.hpp>
00029 #include <vector>
00030 
00031 namespace mesh_conv
00032 {
00033 
00034     class MC_double_vector;
00035     class MC_int_pair;
00036 
00037 
00039     class MC_segment
00040     {
00041         public:
00042 
00043 
00044         //*********************************************//
00045         //*********************************************//
00046         // CONSTRUCTORS
00047         //*********************************************//
00048         //*********************************************//
00049 
00051         MC_segment();
00053         MC_segment(const MC_v3d& start_point,const MC_v3d& end_point);
00055         MC_segment(const MC_segment& s);
00056 
00058         ~MC_segment();
00059 
00060 
00061         //*********************************************//
00062         //*********************************************//
00063         // Manipulation
00064         //*********************************************//
00065         //*********************************************//
00066 
00068         MC_v3d unit_vector() const;
00070         MC_v3d vector() const;
00071 
00073         MC_segment fliped() const;
00074 
00075         // ***************************************************** //
00076         // ***************************************************** //
00077         // Build
00078         // ***************************************************** //
00079         // ***************************************************** //
00080 
00082         static std::vector<MC_segment> build_segment_vector(const MC_v3d_vector& vertices,const std::vector<MC_int_pair>& constraints);
00083 
00084 
00085 
00086         //*********************************************//
00087         //*********************************************//
00088         // Information
00089         //*********************************************//
00090         //*********************************************//
00091 
00093         double length() const;
00094 
00096         MC_v3d closest_point(const MC_v3d& x) const;
00097 
00099         double distance_to_point(const MC_v3d& x) const;
00100 
00111         MC_segment closest_to_segment(const MC_segment& s) const;
00112 
00113 
00117         double distance_to_segment(const MC_segment& s) const;
00118 
00136         MC_v3d plane_intersection(const MC_v3d& n,const MC_v3d& x0,int *type=0) const;
00137 
00142         bool is_belonging(const MC_v3d& x,int *type=0) const;
00143 
00147         bool is_aligned(const MC_v3d& x) const;
00148 
00149 
00153         double relative_position(const MC_v3d& x,bool *is_aligned=0) const;
00154 
00155 
00159         void assert_bounds(const int& u) const;
00160 
00161 
00162         //************************************************//
00163         //************************************************//
00164         //Get value
00165         //************************************************//
00166         //************************************************//
00167 
00169         MC_v3d  operator()(const int& index) const;
00171         MC_v3d& operator()(const int& index);
00173         MC_v3d  operator[](const int& index) const;
00175         MC_v3d& operator[](const int& index);
00176 
00181         MC_v3d value(const double& t) const;
00182 
00187         MC_v3d_vector value(const MC_double_vector& t) const;
00188 
00196         std::pair<MC_v3d_vector,MC_double_vector> linear_sampling_intervals(const double& d_L) const;
00197 
00202         std::pair<MC_v3d_vector,MC_double_vector> linear_sampling(const int& N) const;
00203 
00204 
00205 
00206         //************************************************//
00207         //************************************************//
00208         //Math operator
00209         //************************************************//
00210         //************************************************//
00211 
00212 
00214         friend MC_segment operator+(const MC_segment& s,const MC_v3d& x);
00216         friend MC_segment operator+(const MC_v3d& x,const MC_segment& s);
00218         friend MC_segment operator*(const MC_segment& s,const double& a);
00220         friend MC_segment operator*(const double& a,const MC_segment& s);
00221 
00222 
00223         //************************************************//
00224         //************************************************//
00225         //OUTPUT
00226         //************************************************//
00227         //************************************************//
00228 
00230         friend std::ostream& operator << (std::ostream& stream, const MC_segment& s);
00231 
00232     private:
00233 
00235         MC_v3d x0,x1;
00236 
00237     };
00238 }
00239 
00240 #endif

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