MC_mesh_index_vector.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 License 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 #ifndef MC_MESH_INDEX_VECTOR_H_
00020 #define MC_MESH_INDEX_VECTOR_H_
00021 
00022 
00023 #include <MC_connectivity_index.hpp>
00024 #include <MC_v3d_vector.hpp>
00025 
00026 #include <stdlib.h>
00027 #include <set>
00028 
00029 
00030 namespace mesh_conv
00031 {
00032     class MC_polygon;
00033     class MC_segment;
00034     class MC_matrix;
00035     class MC_double_vector_vector;
00036     class MC_int_pair;
00037     class MC_int_pair_less;
00038 
00039     namespace mesh
00040     {
00041         namespace cgal
00042         {
00043             class MC_mesh_cgal;
00044         }
00045     }
00046 
00048     class MC_mesh_index_vector
00049     {
00050     public:
00051 
00052 
00053         //*********************************************//
00054         //*********************************************//
00055         // CONSTRUCTORS
00056         //*********************************************//
00057         //*********************************************//
00058 
00060         MC_mesh_index_vector();
00062         MC_mesh_index_vector(const MC_v3d_vector& _point_set,const MC_connectivity_index& _connectivity);
00064         MC_mesh_index_vector(const std::pair<MC_v3d_vector,MC_connectivity_index>& _mesh);
00066         MC_mesh_index_vector(const std::vector<MC_polygon> poly_soup);
00068         MC_mesh_index_vector(const mesh::cgal::MC_mesh_cgal& mesh);
00069 
00070         //*********************************************//
00071         //*********************************************//
00072         // Informations
00073         //*********************************************//
00074         //*********************************************//
00075 
00077         int polygon_number() const;
00079         int vertex_number() const;
00080 
00082         int polygon_size(const int& k_polygon) const;
00083 
00084         //*********************************************//
00085         //*********************************************//
00086         // Add index and vertices
00087         //*********************************************//
00088         //*********************************************//
00089 
00093         MC_mesh_index_vector& add_vertex(const MC_v3d& v);
00097         MC_mesh_index_vector& add_connectivity_index(const MC_int_vector& c);
00098 
00099 
00105         friend MC_mesh_index_vector operator<<(const MC_mesh_index_vector& vec0,const MC_mesh_index_vector& vec1);
00106 
00112         MC_mesh_index_vector& concatenation(const MC_mesh_index_vector& vec1);
00113 
00114 
00115         //*********************************************//
00116         //*********************************************//
00117         // Get internal structures
00118         //*********************************************//
00119         //*********************************************//
00120 
00122         MC_connectivity_index& connectivity();
00124         const MC_connectivity_index& connectivity() const;
00126         MC_v3d_vector& point_set();
00128         const MC_v3d_vector& point_set() const;
00129 
00130 
00131 
00132         //*********************************************//
00133         //*********************************************//
00134         // get
00135         //*********************************************//
00136         //*********************************************//
00137 
00139         MC_polygon get_polygon(const int& k_index) const;
00140 
00142         std::vector<MC_polygon> get_polygon() const;
00143 
00145         MC_mesh_index_vector get_polygon_mesh() const;
00146 
00147         //*********************************************//
00148         //*********************************************//
00149         // Subdivision
00150         //*********************************************//
00151         //*********************************************//
00152 
00154         MC_mesh_index_vector subdivide_mid_edge() const;
00155 
00157         MC_mesh_index_vector subdivide_barycenter_mid_edge() const;
00158 
00160         MC_mesh_index_vector subdivide_mid_edge_unchanged_boundary() const;
00162         MC_mesh_index_vector subdivide_barycenter_mid_edge_unchanged_boundary() const;
00164         MC_mesh_index_vector subdivide_mixed_mid_edge_unchanged_boundary() const;
00165 
00167         MC_mesh_index_vector subdivide_mid_edge_unchanged_boundary(const std::set<MC_int_pair,MC_int_pair_less>& allowed_edge) const;
00169         MC_mesh_index_vector subdivide_barycenter_mid_edge_unchanged_boundary(const std::set<MC_int_pair,MC_int_pair_less>& allowed_edge) const;//=std::set<MC_int_pair,MC_int_pair_less>) const;
00171         MC_mesh_index_vector subdivide_mixed_mid_edge_unchanged_boundary(const std::set<MC_int_pair,MC_int_pair_less>& allowed_edge) const;//=std::set<MC_int_pair,MC_int_pair_less>) const;
00172 
00176         MC_mesh_index_vector subdivide_mixed_mid_edge(const std::set<int>& polygon_to_subdivide,const std::set <MC_int_pair,MC_int_pair_less>& allowed_edge) const;
00180         MC_mesh_index_vector subdivide_mixed_mid_edge(const std::set<int>& polygon_to_subdivide) const;
00181 
00182 
00183         //*********************************************//
00184         //*********************************************//
00185         // Special Shapes
00186         //*********************************************//
00187         //*********************************************//
00188 
00190         static MC_mesh_index_vector build_cube();
00191 
00193         static std::vector <MC_mesh_index_vector> build_local_basis();
00194 
00195 
00197         static MC_mesh_index_vector build_segment(const std::vector<MC_segment>& v_seg,const double& radius,const double& N_circular);
00198 
00200         static MC_mesh_index_vector build_icosahedron();
00202         static MC_mesh_index_vector build_sphere(const int& N_subdiv=2);
00204         static MC_mesh_index_vector build_quad_sphere(const int& N_subdiv=2);
00208         static MC_mesh_index_vector build_parametric_sphere(const int& N_1=10,const int& N_2=10);
00213         static MC_mesh_index_vector build_torus(const double& R0,const double& R1,const int& N_1,const int& N_2);
00217         static MC_mesh_index_vector build_closed_cylinder(const int& N1,const int& N2,const bool& is_closed=true);
00219         static MC_mesh_index_vector build_cone(const int& N_radius,const int& N_face);
00227         static MC_mesh_index_vector build_disc(const MC_v3d& center=MC_v3d(0,0,0),const MC_v3d& normal=MC_v3d(0,0,1),const double& radius=1,const int& N_radius=10,const int& N_interior=2);
00230         static MC_mesh_index_vector build_arrow(const MC_segment& dir,const double& radius_cylinder=0.1,const int& N_cylinder=30,const int& N_shape_cylinder=5,const double& radius_cone=0.25,const double& length_cone=0.35,const int& N_cone=30,const int& N_shape_cone=5);
00231 
00232 
00234         static std::pair <MC_mesh_index_vector,std::pair<MC_v3d_vector,std::vector<MC_int_pair> > > build_strip_planar(const MC_curve& c,const MC_v3d& normal,const int& number_of_lines=5,const double& binormal_length=0.06,const double& sample_decrease_factor=1.5);
00235 
00244         static MC_mesh_index_vector sweep_surface(const MC_curve& c,const MC_curve& pattern=MC_curve(),const int& N_subdiv=2,const bool& is_closed=true,const MC_v3d_vector& e1=MC_v3d_vector());
00245 
00262         static MC_mesh_index_vector build_square(const int& N_1=0,const int& N_2=0);
00264         static MC_mesh_index_vector build_square(const int& N_1,const int& N_2,const MC_v3d& tangent_1,const MC_v3d& tangent_2,const MC_v3d& center,const double& L1,const double& L2);
00265 
00271         static MC_mesh_index_vector build_ball_point_set(const MC_v3d_vector& v,const double& radius=0.1,const int& N_subdiv=2);
00272 
00274         static MC_mesh_index_vector build_wireframe(const MC_mesh_index_vector& mesh,const double& radius_cylinder,const int& N_circular,const int& N_subdiv_edges=2);
00275 
00277         static MC_mesh_index_vector build_sphere_point_set(const MC_v3d_vector& position,const double& radius,const unsigned int& N_subdiv);
00278 
00279 
00280         //*********************************************//
00281         //*********************************************//
00282         // Math Operator
00283         //*********************************************//
00284         //*********************************************//
00285 
00289         friend MC_mesh_index_vector operator+(const MC_mesh_index_vector& vec,const MC_v3d& to_add);
00293         friend MC_mesh_index_vector operator-(const MC_mesh_index_vector& vec,const MC_v3d& to_sub);
00294 
00298         friend MC_mesh_index_vector operator+(const MC_mesh_index_vector& vec,const MC_v3d_vector& to_add);
00302         friend MC_mesh_index_vector operator-(const MC_mesh_index_vector& vec,const MC_v3d_vector& to_sub);
00303 
00307         friend MC_mesh_index_vector operator*(const MC_mesh_index_vector& vec,const double& to_mult);
00311         friend MC_mesh_index_vector operator*(const double& to_mult,const MC_mesh_index_vector& vec);
00315         friend MC_mesh_index_vector operator/(const MC_mesh_index_vector& vec,const double& to_subdiv);
00316 
00317 
00318 
00320         MC_mesh_index_vector& operator+=(const MC_v3d& to_add);
00322         MC_mesh_index_vector& operator-=(const MC_v3d& to_sub);
00324         MC_mesh_index_vector& operator+=(const MC_v3d_vector& to_add);
00326         MC_mesh_index_vector& operator-=(const MC_v3d_vector& to_sub);
00328         MC_mesh_index_vector& operator*=(const double& to_mult);
00330         MC_mesh_index_vector& operator/=(const double& to_subdiv);
00331 
00332 
00334         friend MC_mesh_index_vector operator*(const MC_matrix& M,const MC_mesh_index_vector& mesh);
00336         MC_mesh_index_vector& operator*=(const MC_matrix& M);
00337 
00338 
00340         MC_v3d_vector normal_vertex() const;
00342         static MC_v3d_vector normal_vertex(const MC_v3d_vector& point_set,const MC_connectivity_index& connectivity);
00344         static MC_double_vector normal_vertex(const MC_double_vector& point_set,const MC_connectivity_index& connectivity);
00345 
00347         MC_v3d_vector normal_polygon() const;
00348 
00349         //*********************************************//
00350         //*********************************************//
00351         // Boundary with geometry
00352         //*********************************************//
00353         //*********************************************//
00354 
00359         std::pair <std::vector <MC_curve>,MC_int_vector_vector> boundary_curve() const;
00360 
00361 
00362 
00363         //*********************************************//
00364         //*********************************************//
00365         // Add / delete operation with geometry
00366         //*********************************************//
00367         //*********************************************//
00368 
00377         std::pair <MC_int_vector,MC_int_vector> add_unique_polygon(const MC_polygon& polygon,std::map <MC_v3d,int,MC_v3d_less>* map_vertices);
00378 
00379 
00386         std::pair<MC_mesh_index_vector,std::pair<MC_int_vector_vector,MC_int_vector_vector> > added_polygon_soup(const std::vector<MC_polygon> poly_soup) const;
00387 
00410         static std::pair<MC_mesh_index_vector,std::pair<MC_int_vector_vector,MC_int_vector_vector> > build_from_polygon_soup(const std::vector<MC_polygon> poly_soup);
00411 
00412 
00417         std::pair <MC_int_vector,MC_int_vector> polygons_inside_sphere(const MC_v3d& center,const double& radius) const;
00418 
00419         //*********************************************//
00420         //*********************************************//
00421         // Operation with geometry (intersection, ...)
00422         //*********************************************//
00423         //*********************************************//
00424 
00430         std::vector <MC_curve> plane_intersection(const MC_v3d& n,const MC_v3d& x0) const;
00431 
00442         MC_mesh_index_vector half_space_intersection(const MC_v3d& n,const MC_v3d& x0,int *type=0) const;
00443 
00444 
00445 
00453         std::pair <MC_v3d_vector,std::pair <MC_int_vector,MC_double_vector> > segment_intersection(const MC_segment& s) const;
00454 
00465         static std::pair <MC_int_vector,std::pair <MC_v3d_vector,std::pair <MC_int_vector,MC_double_vector> > >
00466                segment_intersection(const std::vector <MC_mesh_index_vector>& v_mesh,const MC_segment& s);
00467 
00469         static MC_curve intersection_curve(const MC_mesh_index_vector& mesh,const MC_segment& c);
00470 
00471 
00473         static MC_v3d_vector map(const MC_mesh_index_vector& mesh_to_map,const MC_double_vector_vector& barycentric_coordinates,const MC_int_vector& polygon_index);
00474 
00480         static std::pair<MC_v3d_vector,std::pair<MC_int_vector,MC_double_vector_vector> > map(const MC_mesh_index_vector& mesh_to_map,const MC_mesh_index_vector& original_map,const MC_v3d_vector& points_to_map);
00481 
00487         static MC_v3d_vector project_to_surface(const MC_mesh_index_vector& mesh_to_project,const MC_v3d_vector& vertex_to_project,const MC_int_vector& triangle_close_to_vertex);
00493         static MC_v3d_vector project_to_surface(const MC_mesh_index_vector& mesh_to_project,const MC_v3d& vertex_to_project,const int& polygon_close_to_vertex);
00494 
00500         static MC_double_vector_vector barycentric_coordinates(const MC_mesh_index_vector& mesh,const MC_v3d_vector& vertices,const MC_int_vector& belonging_polygon);
00501 
00502 
00503 
00510         std::pair <std::pair<MC_mesh_index_vector,MC_mesh_index_vector>,std::pair<MC_int_vector,MC_int_vector> > delete_polygon(const std::set<int> index_to_delete) const;
00511 
00520         std::pair<std::pair<MC_mesh_index_vector,MC_mesh_index_vector>,std::pair<MC_int_vector,MC_int_vector> > delete_vertex(const std::set<int> index_to_delete) const;
00521 
00530         std::pair<std::pair<MC_mesh_index_vector,MC_mesh_index_vector>,std::pair<MC_int_vector,MC_int_vector> > delete_boundary_polygon() const;
00531 
00536         static std::pair<MC_mesh_index_vector,std::vector<MC_mesh_index_vector> > paste_parameterization(const MC_mesh_index_vector& original_mesh,const MC_mesh_index_vector& patch_to_paste);
00538         static std::pair<MC_mesh_index_vector,std::vector<MC_mesh_index_vector> > paste_parameterization_2(const MC_mesh_index_vector& original_mesh,const MC_mesh_index_vector& patch_to_paste);
00539 
00540         //*********************************************//
00541         //*********************************************//
00542         // Volume/Area/...
00543         //*********************************************//
00544         //*********************************************//
00545 
00547         double average_edge_length() const;
00548 
00550         double volume() const;
00552         MC_v3d_vector volume_gradient() const;
00553 
00555         double area() const;
00557         MC_v3d_vector area_gradient() const;
00558 
00559 
00563         MC_v3d centroid_polygon(const MC_int_vector& selected_polygon=MC_int_vector()) const;
00564 
00566         MC_matrix inertia() const;
00567 
00568         //*********************************************//
00569         //*********************************************//
00570         // Deformation
00571         //*********************************************//
00572         //*********************************************//
00573 
00578         static MC_mesh_index_vector laplacian_deformation(const MC_mesh_index_vector& input_mesh,const std::pair<MC_int_vector,MC_v3d_vector>& constraints);
00579 
00583         static std::vector<MC_matrix> polygon_transformation(const MC_mesh_index_vector& m0,const MC_mesh_index_vector& m1);
00584 
00589         static MC_mesh_index_vector as_rigid_as_possible(const MC_mesh_index_vector& m0,const MC_mesh_index_vector& m1,const std::pair<MC_int_vector,MC_v3d_vector>& constraints);
00590 
00592         static std::pair<std::vector<MC_matrix>,std::pair<MC_v3d_vector,MC_v3d_vector> > stretch(const MC_mesh_index_vector& m0,const MC_mesh_index_vector& m1);
00593 
00594         static std::pair<std::vector<MC_matrix>,std::pair<MC_v3d_vector,MC_v3d_vector> > UGLY_stretch_filter(const MC_mesh_index_vector& m0,const MC_mesh_index_vector& m1,const int& N_step=3);
00595 
00596 
00603         MC_mesh_index_vector laplacian_smoothing(const double& lambda=0.5,const int& steps=1,const bool& is_boundary_preserving=true) const;
00604 
00605         //*********************************************//
00606         //*********************************************//
00607         // Angle
00608         //*********************************************//
00609         //*********************************************//
00610 
00612         static std::pair<double,MC_double_vector> angular_error(const MC_mesh_index_vector& mesh_0,const MC_mesh_index_vector& mesh_1);
00613 
00614         //*********************************************//
00615         //*********************************************//
00616         // Loader
00617         //*********************************************//
00618         //*********************************************//
00619 
00621         static MC_mesh_index_vector load_mesh_file(const std::string& filename);
00622 
00623 
00624 
00625         //*********************************************//
00626         //*********************************************//
00627         // Convert geometry to texture coordinate
00628         //*********************************************//
00629         //*********************************************//
00630 
00632         static MC_mesh_index_vector texture_convert_planar_xy(const MC_mesh_index_vector& mesh);
00633 
00635         static MC_mesh_index_vector texture_convert_planar_xy_same_connectivity(const MC_mesh_index_vector& mesh,const MC_mesh_index_vector& mesh_ref);
00636 
00637 
00638     protected:
00639 
00641         MC_connectivity_index connectivity_mesh;
00643         MC_v3d_vector point_set_mesh;
00644 
00645     };
00646 }
00647 
00648 #endif

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