vtf-logo

shells/subdiv/Vertex.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 //                                   Fehmi Cirak   
00006 //                       California Institute of Technology
00007 //                          (C) 2003 All Rights Reserved
00008 //
00009 // <LicenseText>
00010 //
00011 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00012 //      
00013 #ifndef __Vertex_h__
00014 #define __Vertex_h__
00015 
00016 #include <map>
00017 #include <algorithm>
00018 #include <iostream>
00019 
00020 #include "definitions.h"
00021 
00022 
00023 
00024 namespace subdiv {
00025     
00026     class Vertex {
00027     public:     
00028         Vertex(int level=0){
00029             if (!_m_p[level]) {
00030                 VecD3* newpoint = new VecD3();
00031                 _m_p[level] = newpoint;
00032             }
00033             _corner = false;
00034             _crease = false; 
00035         }
00036         
00037         ~Vertex(){};    
00038         
00039         // iterators
00040         typedef std::map<int, VecD3*, std::greater<int> >::iterator LevelIterator;
00041         LevelIterator levBegin() {return _m_p.begin();}
00042         LevelIterator levEnd() {return _m_p.end();}
00043         
00044         // io
00045         friend void operator>>(std::istream& is, subdiv::Vertex* v) {
00046             VecD3* coor = v->_m_p[0];
00047             is >> (*coor)[0] >> (*coor)[1]  >> (*coor)[2];
00048         }
00049         friend std::ostream& operator<<(std::ostream& os, subdiv::Vertex* v) {
00050             VecD3* coor = v->_m_p.begin()->second;
00051             os << (*coor)[0] << " "<< (*coor)[1] << " "<< (*coor)[2];
00052             return os;
00053         }
00054         
00055         // interface
00056         int& number() {return _number;} 
00057         bool& corner() {return _corner;}
00058         bool& crease() {return _crease;}
00059         
00060         void addNewLevel(const VecD3& vec, int level){
00061             PointMap::iterator it = _m_p.find(level);       
00062             if (it != _m_p.end()) {
00063                 *((*it).second) = vec;
00064             } else { 
00065                 VecD3* newpoint = new VecD3(vec);
00066                 _m_p.insert(PointMap::value_type(level, newpoint));  
00067             }
00068         }       
00069         
00070         int maxActiveLevel(){return _m_p.begin()->first;}
00071 
00072         VecD3& position(int level){return *(_m_p[level]);} 
00073         VecD3& position(){ return *(_m_p.begin()->second); } 
00074         
00075     private:
00076         int     _number;      // vertex number       
00077         bool    _corner;      // tag for corner   
00078         bool    _crease;      // tag for crease     
00079         
00080         typedef std::map<int, VecD3*, std::greater<int> >  PointMap;
00081         
00082         PointMap    _m_p;     // coordinates 
00083     };
00084     
00085 }
00086 #endif /* __Vertex_h__ */

Generated on Fri Aug 24 13:00:24 2007 for SFC Thin-Shell Finite Element Solver by  doxygen 1.4.7