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 : Matrix_Att.h * 00026 * Auteur : DEXET Martine * 00027 *----------------------------------------------------------------------------* 00028 * Ce fichier contient la spécification de la classe Matrix_Att. Cette * 00029 * classe permet de stocker un objet de la classe Matrix en tant * 00030 * qu'attribut. * 00031 * * 00032 *****************************************************************************/ 00033 00034 00035 #ifndef MATRIX_ATT_H 00036 #define MATRIX_ATT_H 00037 00038 #include "matrix.hh" 00039 #include "attribute.hh" 00040 00041 00042 00043 /****************************************************************************** 00044 * Classe Matrix_Att * 00045 *****************************************************************************/ 00046 00047 class Matrix_Att : public CAttribute 00048 { 00049 public: 00050 00051 // Constructeurs. 00052 Matrix_Att(); 00053 Matrix_Att(int tab[6], unsigned char color); 00054 00055 // Destructeur. 00056 virtual ~Matrix_Att(); 00057 00058 // Surcharge des méthodes de la classe CAttribute. 00059 TAttributeId getType() const; 00060 Matrix * Get_Data(); 00061 CAttribute * copy() const; 00062 void destroy(); 00063 void save(std::ostream &fd) const; 00064 void load(std::istream &fd); 00065 00066 private: 00067 00068 // Pointeur sur un objet de la classe Matrix. 00069 Matrix * mat; 00070 00071 }; 00072 00073 /****************************************************************************** 00074 * Fichier : Matrix_Att.inl * 00075 * Auteur : DEXET Martine * 00076 *----------------------------------------------------------------------------* 00077 * Ce fichier contient l'implémentation des méthodes de la classe * 00078 * Matrix_Att. * 00079 * * 00080 *****************************************************************************/ 00081 00082 #include "user.hh" 00083 00084 // Constructeurs. 00085 inline 00086 Matrix_Att::Matrix_Att() 00087 { 00088 mat = NULL; 00089 } 00090 00091 inline 00092 Matrix_Att::Matrix_Att(int tab[6], unsigned char color) 00093 { 00094 mat = new Matrix(tab,color); 00095 } 00096 00097 00098 // Destructeur. 00099 inline 00100 Matrix_Att::~Matrix_Att() 00101 { 00102 delete mat; 00103 } 00104 00105 00106 // Surcharge des méthodes de la classe CAttribute. 00107 inline 00108 TAttributeId Matrix_Att::getType() const 00109 { 00110 return MATRIX_ATTRIBUTE_ID; 00111 } 00112 00113 inline 00114 Matrix * Matrix_Att::Get_Data() 00115 { 00116 return mat; 00117 } 00118 00119 inline 00120 CAttribute * Matrix_Att::copy() const 00121 { 00122 Matrix_Att * m = new Matrix_Att(); 00123 m->mat = new Matrix(*mat); 00124 00125 return m; 00126 } 00127 00128 inline 00129 void Matrix_Att::destroy() 00130 { 00131 delete this; 00132 } 00133 00134 00135 inline 00136 void Matrix_Att::save(std::ostream &fd) const 00137 { 00138 fd << mat->Get_X_Max() << " " << mat->Get_X_Min() << " " 00139 << mat->Get_Y_Max() << " " << mat->Get_Y_Min() << " " 00140 << mat->Get_Z_Max() << " " << mat->Get_Z_Min() << std::endl; 00141 00142 for (int k=mat->Get_Z_Min(); k<=mat->Get_Z_Max(); k++) 00143 for (int j=mat->Get_Y_Min(); j<=mat->Get_Y_Max(); j++) 00144 { 00145 for (int i=mat->Get_X_Min(); i<=mat->Get_X_Max(); i++) 00146 fd << (int)mat->Get_Value(i,j,k) << " "; 00147 00148 fd << std::endl; 00149 } 00150 } 00151 00152 inline 00153 void Matrix_Att::load(std::istream &fd) 00154 { 00155 } 00156 00157 #endif