Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

model::Model Class Reference
[The PCG model layer]

A abstract class of a Model in PCG. More...

#include <Model.h>

Inheritance diagram for model::Model:

Inheritance graph
[legend]
Collaboration diagram for model::Model:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Model ()
virtual ~Model ()=0
void setVertexs (vector< Vertex * > vertexs)
VertexgetVertex (int i)
vector< Vertex * > getVertexs ()
Matrix getModelVertexs ()
void addVertex (Vertex *vertex)
void removeVertex (Vertex *vertex)
void updateVertices (Matrix vertexs)
void setFaces (vector< Face * > faces)
FacegetFace (int i)
vector< Face * > getFaces ()
void addFace (Face *face)
void removeFace (Face *face)
void setLandmarks (vector< Landmark * > landmarks)
vector< Landmark * > getLandmarks ()
void addLandmark (Landmark *landmark)
void removeLandmark (Landmark *landmark)
void setContours (vector< Contour * > contours)
vector< Contour * > getContours ()
void addContour (Contour *contour)
void removeContour (Contour *contour)
void setAnnotations (vector< Annotation * > annotations)
vector< Annotation * > getAnnotations ()
void addAnnotation (Annotation *annotation)
void removeAnnotation (Annotation *annotation)
bool save (char *filename)
bool save (ofstream *saveFile)
bool load (char *filename)
bool load (ifstream *loadFile)

Protected Attributes

Vertexm_vertexs
Facem_faces
Landmarkm_landmarks
Contourm_contours
Annotationm_annotations

Detailed Description

A abstract class of a Model in PCG.

It contains Vertex's, Face's, Landmark's, Contour's, and Annotation's.

See also:
Vertex | Face | Landmark | Contour | Annotation

Definition at line 35 of file Model.h.


Constructor & Destructor Documentation

model::Model::Model  )  [inline]
 

Write brief comment for Model here.

Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for Model here.

Remarks:
Write remarks for Model here.
See also:
Separate items with the '|' character.

Definition at line 66 of file Model.h.

00066 {};

Model::~Model  )  [pure virtual]
 

Write brief comment for ~Model here.

Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for ~Model here.

Remarks:
Write remarks for ~Model here.
See also:
Separate items with the '|' character.

Definition at line 20 of file Model.cpp.

00020               {
00021 
00022 }


Member Function Documentation

void Model::addAnnotation Annotation annotation  ) 
 

Write brief comment for addAnnotation here.

Parameters:
annotation Description of parameter annotation.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for addAnnotation here.

Remarks:
Write remarks for addAnnotation here.
See also:
Separate items with the '|' character.

Definition at line 548 of file Model.cpp.

References m_annotations.

00548                                                 {
00549         m_annotations.push_back(annotation);
00550 }

void Model::addContour Contour contour  ) 
 

Write brief comment for addContour here.

Parameters:
contour Description of parameter contour.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for addContour here.

Remarks:
Write remarks for addContour here.
See also:
Separate items with the '|' character.

Definition at line 460 of file Model.cpp.

References m_contours.

00460                                        {
00461         m_contours.push_back(contour);
00462 }

void Model::addFace Face face  ) 
 

Write brief comment for addFace here.

Parameters:
face Description of parameter face.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for addFace here.

Remarks:
Write remarks for addFace here.
See also:
Separate items with the '|' character.

Definition at line 284 of file Model.cpp.

References m_faces.

Referenced by pcggui::CovertScene(), load(), and functions::Importer::readAttributes().

00284                               {
00285         m_faces.push_back(face);
00286 }

void Model::addLandmark Landmark landmark  ) 
 

Write brief comment for addLandmark here.

Parameters:
landmark Description of parameter landmark.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for addLandmark here.

Remarks:
Write remarks for addLandmark here.
See also:
Separate items with the '|' character.

Definition at line 372 of file Model.cpp.

References m_landmarks.

00372                                           {
00373         m_landmarks.push_back(landmark);
00374 }

void Model::addVertex Vertex vertex  ) 
 

Write brief comment for addVertex here.

Parameters:
vertex Description of parameter vertex.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for addVertex here.

Remarks:
Write remarks for addVertex here.
See also:
Separate items with the '|' character.

Definition at line 141 of file Model.cpp.

References m_vertexs, and model::Vertex::setIndex().

Referenced by pcggui::CovertScene(), load(), and functions::Importer::readAttributes().

00141                                     {   
00142         vertex->setIndex(m_vertexs.size());
00143         m_vertexs.push_back(vertex);
00144 }

Here is the call graph for this function:

vector< Annotation * > Model::getAnnotations  ) 
 

Write brief comment for getAnnotations here.

Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getAnnotations here.

Remarks:
Write remarks for getAnnotations here.
See also:
Separate items with the '|' character.

Definition at line 526 of file Model.cpp.

00526                                           {
00527         return m_annotations;
00528 }

vector< Contour * > Model::getContours  ) 
 

Write brief comment for getContours here.

Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getContours here.

Remarks:
Write remarks for getContours here.
See also:
Separate items with the '|' character.

Definition at line 438 of file Model.cpp.

00438                                     {
00439         return m_contours;
00440 }

Face * Model::getFace int  i  ) 
 

Write brief comment for getFace here.

Parameters:
i Description of parameter i.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getFace here.

Remarks:
Write remarks for getFace here.
See also:
Separate items with the '|' character.

Definition at line 240 of file Model.cpp.

References m_faces.

Referenced by functions::Importer::readAttributes(), and pcggui::Render().

00240                           {
00241         return m_faces[i];
00242 }

vector< Face * > Model::getFaces  ) 
 

Write brief comment for getFaces here.

Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getFaces here.

Remarks:
Write remarks for getFaces here.
See also:
Separate items with the '|' character.

Definition at line 262 of file Model.cpp.

Referenced by functions::Exporter::exportModel(), pcggui::Render(), and log::write().

00262                               {
00263         return m_faces;
00264 }

vector< Landmark * > Model::getLandmarks  ) 
 

Write brief comment for getLandmarks here.

Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getLandmarks here.

Remarks:
Write remarks for getLandmarks here.
See also:
Separate items with the '|' character.

Definition at line 350 of file Model.cpp.

00350                                       {
00351         return m_landmarks;
00352 }

Matrix Model::getModelVertexs  ) 
 

Write brief comment for getModelVertexs here.

Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getModelVertexs here.

Remarks:
Write remarks for getModelVertexs here.
See also:
Separate items with the '|' character.

Definition at line 111 of file Model.cpp.

References model::Vertex::getCoordinates(), and m_vertexs.

Referenced by model::Analyzer::mergeData().

00111                               {
00112         int size = m_vertexs.size();
00113         Matrix v(size*3,1);
00114         for(int i=0; i<(int)m_vertexs.size(); i++) {
00115                 IvVector3* tmp = m_vertexs[i]->getCoordinates();
00116                 v((i*3)+1,1) = tmp->x;
00117                 v((i*3)+2,1) = tmp->y;
00118                 v((i*3)+3,1) = tmp->z;
00119         }
00120         return v;
00121 }

Here is the call graph for this function:

Vertex * Model::getVertex int  i  ) 
 

Write brief comment for getVertex here.

Parameters:
i Description of parameter i.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getVertex here.

Remarks:
Write remarks for getVertex here.
See also:
Separate items with the '|' character.

Definition at line 67 of file Model.cpp.

References m_vertexs.

Referenced by pcggui::CovertScene(), load(), functions::Importer::readAttributes(), and pcggui::Render().

00067                               {
00068         return m_vertexs[i];
00069 }

vector< Vertex * > Model::getVertexs  ) 
 

Write brief comment for getVertexs here.

Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for getVertexs here.

Remarks:
Write remarks for getVertexs here.
See also:
Separate items with the '|' character.

Definition at line 89 of file Model.cpp.

Referenced by functions::Exporter::exportModel(), pcggui::Render(), and log::write().

00089                                   {
00090         return m_vertexs;
00091 }

bool Model::load ifstream *  loadFile  ) 
 

Write brief comment for load here.

Parameters:
loadFile Description of parameter loadFile.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for load here.

Remarks:
Write remarks for load here.
See also:
Separate items with the '|' character.

Reimplemented in model::ReferenceModel.

Definition at line 711 of file Model.cpp.

References addFace(), addVertex(), getVertex(), m_annotations, m_contours, m_faces, m_landmarks, m_vertexs, model::Vertex::setCoordinates(), model::Vertex::setNormal(), model::Face::setVertices(), and Tokenize().

00711                                    {
00712         m_vertexs.clear();
00713         m_faces.clear();
00714         m_landmarks.clear();
00715         m_contours.clear();
00716         m_annotations.clear();
00717 
00718 
00719         string line;
00720         vector<string> tokens;
00721         vector<string> coords;
00722         if(loadFile->is_open()) {
00723                 getline(*loadFile,line);//Vertex
00724                 getline(*loadFile,line);//Coords
00725                 tokens.clear();
00726                 Tokenize(line,tokens,",");
00727                 for(int i=0;i<(int)tokens.size();i++) {
00728                         coords.clear();
00729                         Tokenize(tokens[i],coords," ");
00730                         Vertex* vertex = new Vertex();
00731                         vertex->setCoordinates(convertTo<float>(coords[0]),convertTo<float>(coords[1]),convertTo<float>(coords[2]));
00732                         addVertex(vertex);
00733                 }
00734                 getline(*loadFile,line);//Normals
00735                 tokens.clear();
00736                 Tokenize(line,tokens,",");
00737                 for(int i=0;i<(int)tokens.size();i++) {
00738                         coords.clear();
00739                         Tokenize(tokens[i],coords," ");
00740                         Vertex* vertex = getVertex(i);
00741                         vertex->setNormal(convertTo<float>(coords[0]),convertTo<float>(coords[1]),convertTo<float>(coords[2]));
00742                 }
00743                 getline(*loadFile,line);//Face
00744                 getline(*loadFile,line);//Indexs
00745                 tokens.clear();
00746                 Tokenize(line,tokens,",");
00747                 for(int i=0;i<(int)tokens.size();i++) {
00748                         coords.clear();
00749                         Tokenize(tokens[i],coords," ");
00750                         Face* face = new Face();
00751                         face->setVertices(m_vertexs[convertTo<int>(coords[0])],m_vertexs[convertTo<int>(coords[1])],m_vertexs[convertTo<int>(coords[2])]);
00752                         addFace(face);
00753                 }
00754                 getline(*loadFile,line);//Landmark
00755                 getline(*loadFile,line);//Data
00756                 tokens.clear();
00757                 Tokenize(line,tokens,",");
00758                 for(int i=0;i<(int)tokens.size();i++) {
00759                         coords.clear();
00760                         Tokenize(tokens[i],coords," ");
00761                         //addLandmark
00762                 }
00763                 getline(*loadFile,line);//Contour
00764                 getline(*loadFile,line);//Data
00765                 tokens.clear();
00766                 Tokenize(line,tokens,",");
00767                 for(int i=0;i<(int)tokens.size();i++) {
00768                         coords.clear();
00769                         Tokenize(tokens[i],coords," ");
00770                 }
00771                 getline(*loadFile,line);//Annotation
00772                 getline(*loadFile,line);//Data
00773                 tokens.clear();
00774                 Tokenize(line,tokens,",");
00775                 for(int i=0;i<(int)tokens.size();i++) {
00776                         coords.clear();
00777                         Tokenize(tokens[i],coords," ");
00778                 }
00779                 return true;
00780         } else {
00781                 return false;
00782         }
00783 }

Here is the call graph for this function:

bool Model::load char *  filename  ) 
 

Write brief comment for load here.

Parameters:
filename Description of parameter filename.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for load here.

Remarks:
Write remarks for load here.
See also:
Separate items with the '|' character.

Reimplemented in model::ReferenceModel.

Definition at line 683 of file Model.cpp.

Referenced by model::ReferenceModel::load(), and pcggui::LoadAll().

00683                                {
00684         ifstream loadFile(filename);
00685         bool res = load(&loadFile);
00686         loadFile.close();
00687         return res;
00688 }

void Model::removeAnnotation Annotation annotation  ) 
 

Write brief comment for removeAnnotation here.

Parameters:
annotation Description of parameter annotation.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for removeAnnotation here.

Remarks:
Write remarks for removeAnnotation here.
See also:
Separate items with the '|' character.

Definition at line 570 of file Model.cpp.

00570                                                    {
00571         //m_annotations.remove(annotation);
00572 }

void Model::removeContour Contour contour  ) 
 

Write brief comment for removeContour here.

Parameters:
contour Description of parameter contour.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for removeContour here.

Remarks:
Write remarks for removeContour here.
See also:
Separate items with the '|' character.

Definition at line 482 of file Model.cpp.

00482                                           {
00483         //m_contours.remove(contour);
00484 }

void Model::removeFace Face face  ) 
 

Write brief comment for removeFace here.

Parameters:
face Description of parameter face.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for removeFace here.

Remarks:
Write remarks for removeFace here.
See also:
Separate items with the '|' character.

Definition at line 306 of file Model.cpp.

00306                                  {
00307         //m_faces.remove(face);
00308 }

void Model::removeLandmark Landmark landmark  ) 
 

Write brief comment for removeLandmark here.

Parameters:
landmark Description of parameter landmark.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for removeLandmark here.

Remarks:
Write remarks for removeLandmark here.
See also:
Separate items with the '|' character.

Definition at line 394 of file Model.cpp.

00394                                              {
00395         //m_landmarks.remove(landmark);
00396 }

void Model::removeVertex Vertex vertex  ) 
 

Write brief comment for removeVertex here.

Parameters:
vertex Description of parameter vertex.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for removeVertex here.

Remarks:
Write remarks for removeVertex here.
See also:
Separate items with the '|' character.

Definition at line 164 of file Model.cpp.

00164                                        {
00165         //m_vertexs.erase(vertex);
00166 }

bool Model::save ofstream *  saveFile  ) 
 

Write brief comment for save here.

Parameters:
saveFile Description of parameter saveFile.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for save here.

Remarks:
Write remarks for save here.
See also:
Separate items with the '|' character.

Reimplemented in model::ReferenceModel.

Definition at line 623 of file Model.cpp.

References model::Vertex::getCoordinates(), model::Vertex::getIndex(), model::Vertex::getNormal(), model::Face::getVertex(), m_annotations, m_contours, m_faces, m_landmarks, and m_vertexs.

00623                                    {
00624         if(saveFile->is_open()) {
00625                 *saveFile << "Vertex\n";
00626                 for(int i=0;i<(int)m_vertexs.size();i++) {
00627                         *saveFile << m_vertexs[i]->getCoordinates()->x << " ";
00628                         *saveFile << m_vertexs[i]->getCoordinates()->y << " ";
00629                         *saveFile << m_vertexs[i]->getCoordinates()->z << ",";
00630                 }
00631                 *saveFile << "\n";
00632                 for(int i=0;i<(int)m_vertexs.size();i++) {
00633                         *saveFile << m_vertexs[i]->getNormal()->x << " ";
00634                         *saveFile << m_vertexs[i]->getNormal()->y << " ";
00635                         *saveFile << m_vertexs[i]->getNormal()->z << ",";
00636                 }
00637                 *saveFile << "\nFace\n";
00638                 for(int i=0;i<(int)m_faces.size();i++) {
00639                         *saveFile << m_faces[i]->getVertex(0)->getIndex() << " ";
00640                         *saveFile << m_faces[i]->getVertex(1)->getIndex() << " ";
00641                         *saveFile << m_faces[i]->getVertex(2)->getIndex() << ",";
00642                 }
00643                 *saveFile << "\nLandmark\n";
00644                 for(int i=0;i<(int)m_landmarks.size();i++) {
00645                         //saveFile << m_landmarks[i] << " ";
00646                 }
00647                 *saveFile << "\nContour\n";
00648                 for(int i=0;i<(int)m_contours.size();i++) {
00649                         //saveFile << m_contours[i] << " ";
00650                 }
00651                 *saveFile << "\nAnnotation\n";
00652                 for(int i=0;i<(int)m_annotations.size();i++) {
00653                         //saveFile << m_annotations[i] << " ";
00654                 }
00655                 *saveFile << "\n";
00656                 return true;
00657         } else {
00658                 return false;
00659         }
00660 }

Here is the call graph for this function:

bool Model::save char *  filename  ) 
 

Write brief comment for save here.

Parameters:
filename Description of parameter filename.
Returns:
Write description of return value here.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for save here.

Remarks:
Write remarks for save here.
See also:
Separate items with the '|' character.

Reimplemented in model::ReferenceModel.

Definition at line 595 of file Model.cpp.

Referenced by model::ReferenceModel::save().

00595                                {
00596         ofstream saveFile(filename);
00597         bool res = save(&saveFile);
00598         saveFile.close();
00599         return res;
00600 }

void Model::setAnnotations vector< Annotation * >  annotations  ) 
 

Write brief comment for setAnnotations here.

Parameters:
annotations Description of parameter annotations.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for setAnnotations here.

Remarks:
Write remarks for setAnnotations here.
See also:
Separate items with the '|' character.

Definition at line 504 of file Model.cpp.

References m_annotations.

00504                                                           {
00505         m_annotations = annotations;
00506 }

void Model::setContours vector< Contour * >  contours  ) 
 

Write brief comment for setContours here.

Parameters:
contours Description of parameter contours.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for setContours here.

Remarks:
Write remarks for setContours here.
See also:
Separate items with the '|' character.

Definition at line 416 of file Model.cpp.

References m_contours.

00416                                                  {
00417         m_contours = contours;
00418 }

void Model::setFaces vector< Face * >  faces  ) 
 

Write brief comment for setFaces here.

Parameters:
faces Description of parameter faces.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for setFaces here.

Remarks:
Write remarks for setFaces here.
See also:
Separate items with the '|' character.

Definition at line 215 of file Model.cpp.

References m_faces.

Referenced by Batch::analyzeModel(), and Batch::TestAnalyzer().

00215                                         {
00216         m_faces = faces;
00217 }

void Model::setLandmarks vector< Landmark * >  landmarks  ) 
 

Write brief comment for setLandmarks here.

Parameters:
landmarks Description of parameter landmarks.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for setLandmarks here.

Remarks:
Write remarks for setLandmarks here.
See also:
Separate items with the '|' character.

Definition at line 328 of file Model.cpp.

References m_landmarks.

00328                                                     {
00329         m_landmarks = landmarks;
00330 }

void Model::setVertexs vector< Vertex * >  vertexs  ) 
 

Write brief comment for setVertexs here.

Parameters:
vertexs Description of parameter vertexs.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for setVertexs here.

Remarks:
Write remarks for setVertexs here.
See also:
Separate items with the '|' character.

Definition at line 42 of file Model.cpp.

References m_vertexs.

Referenced by Batch::analyzeModel(), and Batch::TestAnalyzer().

00042                                               {
00043         m_vertexs = vertexs;
00044 }

void Model::updateVertices Matrix  vertexs  ) 
 

Write brief comment for updateVertices here.

Parameters:
vertexs Description of parameter vertexs.
Exceptions:
<exception class> Description of criteria for throwing this exception.
Write detailed description for updateVertices here.

Remarks:
Write remarks for updateVertices here.
See also:
Separate items with the '|' character.

Definition at line 186 of file Model.cpp.

References m_vertexs, and model::Vertex::updateCoordinates().

Referenced by model::Analyzer::getModel().

00186                                          {
00187         printf("Model::updateVertices\n");
00188         for(int i=0; i<(int)m_vertexs.size();i++) {
00189                 float x = (float)vertexs(i*3+1,1);
00190                 float y = (float)vertexs(i*3+2,1);
00191                 float z = (float)vertexs(i*3+3,1);
00192                 m_vertexs[i]->updateCoordinates(x,y,z);
00193         }
00194 }

Here is the call graph for this function:


Member Data Documentation

Annotation* model::Model::m_annotations [protected]
 

A Collection of Annotation's

Definition at line 42 of file Model.h.

Referenced by addAnnotation(), load(), model::ReferenceModel::operator=(), model::ReferenceModel::ReferenceModel(), save(), and setAnnotations().

Contour* model::Model::m_contours [protected]
 

A Collection of Contour's

Definition at line 41 of file Model.h.

Referenced by addContour(), load(), model::ReferenceModel::operator=(), model::ReferenceModel::ReferenceModel(), save(), and setContours().

Face* model::Model::m_faces [protected]
 

A Collection of Face's

Definition at line 39 of file Model.h.

Referenced by addFace(), getFace(), load(), model::ReferenceModel::operator=(), model::ReferenceModel::ReferenceModel(), save(), and setFaces().

Landmark* model::Model::m_landmarks [protected]
 

A Collection of Landmark's

Definition at line 40 of file Model.h.

Referenced by addLandmark(), load(), model::ReferenceModel::operator=(), model::ReferenceModel::ReferenceModel(), save(), and setLandmarks().

Vertex* model::Model::m_vertexs [protected]
 

A Collection of Vertex's

Definition at line 38 of file Model.h.

Referenced by addVertex(), getModelVertexs(), getVertex(), load(), model::ReferenceModel::operator=(), model::ReferenceModel::ReferenceModel(), save(), setVertexs(), and updateVertices().


The documentation for this class was generated from the following files:
Generated on Tue Apr 17 09:40:05 2007 for PCG Library by  doxygen 1.3.9.1