Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef PLYELEMENT_HPP_
00009 #define PLYELEMENT_HPP_
00010
00011 #include <vector>
00012 #include <iostream>
00013 using std::vector;
00014 using std::ostream;
00015 using std::endl;
00016
00017 #include "PLYProperty.hpp"
00018
00019 namespace lssr
00020 {
00021
00025 class PLYElement
00026 {
00027 public:
00028
00032 PLYElement() : m_name(""), m_count(0) {};
00033
00040 PLYElement(string name, size_t count) : m_name(name), m_count(count){};
00041
00049 void addProperty(string name, string elementType, string listType = "", size_t count = 0)
00050 {
00051
00052 Property* p;
00053
00054
00055 if(elementType == "char")
00056 {
00057 p = new ScalarProperty<char>(name);
00058 }
00059 else if(elementType == "uchar")
00060 {
00061 p = new ScalarProperty<uchar>(name);
00062 }
00063 else if(elementType == "short")
00064 {
00065 p = new ScalarProperty<short>(name);
00066 }
00067 else if(elementType == "uint")
00068 {
00069 p = new ScalarProperty<uint>(name);
00070 }
00071 else if(elementType == "int")
00072 {
00073 p = new ScalarProperty<int>(name);
00074 }
00075 else if(elementType == "float")
00076 {
00077 p = new ScalarProperty<float>(name);
00078 }
00079 else if(elementType == "double")
00080 {
00081 p = new ScalarProperty<double>(name);
00082 }
00083
00084
00085 if(listType == "")
00086 {
00087 m_properties.push_back(p);
00088 return;
00089 }
00090 else
00091 {
00092 Property* l;
00093 if(listType == "char")
00094 {
00095 l = new ListProperty<char>(count, p);
00096 }
00097 else if(listType == "uchar")
00098 {
00099 l = new ListProperty<uchar>(count, p);
00100 }
00101 else if(listType == "short")
00102 {
00103 l = new ListProperty<short>(count, p);
00104 }
00105 else if(listType == "uint")
00106 {
00107 l = new ListProperty<uint>(count, p);
00108 }
00109 else if(listType == "int")
00110 {
00111 l = new ListProperty<int>(count, p);
00112 }
00113 else if(listType == "float")
00114 {
00115 l = new ListProperty<float>(count, p);
00116 }
00117 else if(listType == "double")
00118 {
00119 l = new ListProperty<double>(count, p);
00120 }
00121 m_properties.push_back(l);
00122 }
00123
00124 }
00125
00126
00127
00128
00129 vector<Property*>::iterator getFirstProperty() { return m_properties.begin(); }
00130
00134 vector<Property*>::iterator getLastProperty() { return m_properties.end(); }
00135
00139 string getName() {return m_name;}
00140
00144 size_t getCount() {return m_count;}
00145
00150 void printProperties(ostream &out)
00151 {
00152 for(vector<Property*>::iterator it = m_properties.begin();
00153 it != m_properties.end();
00154 it ++)
00155 {
00156 Property* p = *it;
00157 out << "property ";
00158 if(p->isList())
00159 {
00160 out << "list ";
00161 out << p->getCountTypeStr() << " ";
00162 }
00163 out << p->getElementTypeStr() << " ";
00164 out << p->getName() << endl;
00165 }
00166 }
00167
00168 private:
00169
00171 vector<Property*> m_properties;
00172
00174 string m_name;
00175
00177 size_t m_count;
00178
00179
00180 };
00181
00182 }
00183
00184 #endif