All pastes #12373 Raw Edit

Stuff

public cpp v1 · immutable
#12373 ·published 2005-05-22 13:12 UTC
rendered paste body
// class declaration/// Cache implementation. input_t must implement "void update(bool)" and "facevertices_t& face_vertices()"template <typename input_t> class catmull_clark_cache_implementation{ public:  catmull_clark_cache_implementation(input_t& Input, int Levels);  ~catmull_clark_cache_implementation();  /// update point positions  void update(bool all = false);  /// Get the number of levels  const unsigned long levels() const  {   return m_levels;  }  /// draw the result using opengl  void draw();   private:  input_t& m_input;  int m_levels;  typedef std::map<valid_point*, border_root_t*> inner_bordermap_t;  typedef std::map<valid_point*, inner_bordermap_t*> bordermap_t;  typedef std::map<valid_point*, patch_corner*> cornermap_t;  bordermap_t m_borders;  std::vector<point_array*> m_patch_parents;  std::vector<border_parent_t*> m_border_parents;  cornermap_t m_patch_corners;  // get or create the border line with given start and end points  border_root_t* get_border(valid_point* Start, valid_point* End);  // only retrieve the border from the map  border_root_t* retrieve_border(valid_point* Start, valid_point* End, bool recurse = true);  // generate cache up to level  void generate(int level);  // get the patch_corner associated with the Point  patch_corner* get_patch_corner(valid_point* Point);};// definitiontemplate <typename T> void libk3dmesh::detail::catmull_clark_cache_implementation<T>::draw( ){ k3d::gl::store_attributes attributes; glEnable(GL_LIGHTING); glColor3d(0.8, 0.8, 1); glFrontFace(GL_CW); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glDisable(GL_CULL_FACE); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(1.0, 1.0); for (facevertices_t::iterator face = m_input.face_vertices().begin(); face != m_input.face_vertices().end(); ++face)  (*face)->draw(m_levels-1);}