Go to the documentation of this file.00001 #ifndef OPENTISSUE_DYNAMICS_PSYS_MASS_SPRING_SYSTEM_PSYS_CLOTH_H
00002 #define OPENTISSUE_DYNAMICS_PSYS_MASS_SPRING_SYSTEM_PSYS_CLOTH_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/dynamics/psys/mass_spring_system/psys_surface_mesh.h>
00013
00014 #include <boost/multi_array.hpp>
00015
00016 namespace OpenTissue
00017 {
00018 namespace psys
00019 {
00020
00021 template<
00022 typename types
00023 , typename integrator_policy
00024 >
00025 class Cloth : public SurfaceMesh<types,integrator_policy>
00026 {
00027 public:
00028
00029 typedef SurfaceMesh<types,integrator_policy> base_class;
00030 typedef typename types::coupling_type coupling_type;
00031 typedef typename types::mesh_type mesh_type;
00032 typedef typename mesh_type::vertex_handle vertex_handle;
00033 typedef typename types::math_types math_types;
00034 typedef typename math_types::real_type real_type;
00035 typedef typename math_types::vector3_type vector3_type;
00036
00037 protected:
00038
00039 mesh_type m_cloth;
00040
00041 public:
00042
00043 Cloth() {}
00044
00045 virtual ~Cloth() {}
00046
00047 public:
00048
00049
00050 void init(mesh_type & mesh, bool create_sticks, bool create_springs)
00051 {
00052 base_class::init(mesh,create_sticks,create_springs);
00053 }
00054
00055 void init(
00056 real_type const & width
00057 , real_type const & height
00058 , unsigned int subdivisions_width
00059 , unsigned int subdivisions_height
00060 , bool create_sticks
00061 , bool create_springs
00062 )
00063 {
00064 assert( subdivisions_width > 1 || !"Cloth::init(): Subdivision width must be larger than 1");
00065 assert( subdivisions_height > 1 || !"Cloth::init(): Subdivision height must be larger than 1");
00066 assert( width>0 || !"Cloth::init(): Width must be positive");
00067 assert( height>0 || !"Cloth::init(): Height must be positive");
00068
00069 this->rigidty() = 2;
00070
00071 real_type dx = width /(subdivisions_width-1);
00072 real_type dy = height /(subdivisions_height-1);
00073 mesh::make_plane(dx,dy,subdivisions_width,subdivisions_height,this->m_cloth);
00074
00075 base_class::init(m_cloth,create_sticks,create_springs);
00076 }
00077
00078 };
00079
00080 }
00081 }
00082
00083
00084 #endif