00001 /* 00002 * lib-spamod : Visualisation des objets en discret. 00003 * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC 00004 * http://www.sic.sp2mi.univ-poitiers.fr/ 00005 * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS, 00006 * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/ 00007 * 00008 * This file is part of lib-spamod 00009 * 00010 * This program is free software: you can redistribute it and/or modify 00011 * it under the terms of the GNU Lesser General Public License as published by 00012 * the Free Software Foundation, either version 3 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public License 00021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00022 */ 00023 00024 /****************************************************************************** 00025 * Fichier : Voxel_List.h * 00026 * Auteur : DEXET Martine * 00027 *----------------------------------------------------------------------------* 00028 * Ce fichier contient la spécification de la classe Voxel_List. Cette * 00029 * classe permet de stocker une liste d'objets de la classe Voxel en tant * 00030 * qu'attribut. * 00031 * * 00032 *****************************************************************************/ 00033 00034 00035 #ifndef VOXEL_LIST_H 00036 #define VOXEL_LIST_H 00037 00038 #include "voxel.hh" 00039 #include "attribute.hh" 00040 00041 #include <list> 00042 #include <iostream> 00043 00044 00045 /****************************************************************************** 00046 * Classe Voxel_List * 00047 *****************************************************************************/ 00048 00049 class Voxel_List : public CAttribute { 00050 00051 public: 00052 00053 // Constructeur. 00054 Voxel_List(); 00055 00056 // Destructeur. 00057 virtual ~Voxel_List(); 00058 00059 // Surcharge des méthodes de la classe CAttribute. 00060 TAttributeId getType() const; 00061 void * Get_Data(); 00062 CAttribute * copy() const; 00063 void destroy(); 00064 void save(std::ostream &fd) const; 00065 void load(std::istream &fd); 00066 00067 private: 00068 00069 // Pointeur sur une liste d'objets de la classe Voxel. 00070 std::list<Voxel*> * lst; 00071 }; 00072 00073 00074 /****************************************************************************** 00075 * Fichier : Voxel_List.inl * 00076 * Auteur : DEXET Martine * 00077 *----------------------------------------------------------------------------* 00078 * Ce fichier contient l'implémentation des méthodes de la classe * 00079 * Voxel_List. * 00080 * * 00081 *****************************************************************************/ 00082 00083 #include "user.hh" 00084 00085 00086 // Constructeur. 00087 inline 00088 Voxel_List::Voxel_List() 00089 { 00090 lst = new std::list<Voxel*>; 00091 } 00092 00093 00094 // Destructeur. 00095 inline 00096 Voxel_List::~Voxel_List() 00097 { 00098 std::list<Voxel*>::iterator iter; 00099 00100 for (iter=lst->begin(); 00101 iter!=lst->end(); 00102 iter++) 00103 if (*iter != NULL) 00104 delete *iter; 00105 00106 delete lst; 00107 } 00108 00109 00110 // Surcharge des méthodes de la classe CAttribute. 00111 inline 00112 TAttributeId Voxel_List::getType() const 00113 { 00114 return VOXEL_LIST_ATTRIBUTE_ID; 00115 } 00116 00117 inline 00118 void * Voxel_List::Get_Data() 00119 { 00120 return lst; 00121 } 00122 00123 inline 00124 CAttribute * Voxel_List::copy() const 00125 { 00126 Voxel_List * l = new Voxel_List(); 00127 std::list<Voxel*>::iterator li; 00128 00129 for (li=lst->begin(); li!=lst->end(); li++) 00130 l->lst->push_front(*li); 00131 00132 return l; 00133 } 00134 00135 inline 00136 void Voxel_List::destroy() 00137 { 00138 delete this; 00139 } 00140 00141 inline 00142 void Voxel_List::save(std::ostream &fd) const 00143 { 00144 std::list<Voxel*>::iterator li; 00145 00146 for (li=lst->begin(); li!=lst->end(); li++) 00147 fd << *li; 00148 } 00149 00150 inline 00151 void Voxel_List::load(std::istream &fd) 00152 { 00153 } 00154 00155 #endif