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 : Ineq_Table6.h * 00026 * Auteur : DEXET Martine * 00027 *----------------------------------------------------------------------------* 00028 * Ce fichier contient la spécification de la classe Ineq_Table6. Cette * 00029 * classe permet de représenter un tableau d'inéquations, comportant six * 00030 * éléments. * 00031 * * 00032 *****************************************************************************/ 00033 00034 00035 #ifndef INEQ_TABLE6_H 00036 #define INEQ_TABLE6_H 00037 00038 #include "inequation.hh" 00039 00040 00041 00042 /****************************************************************************** 00043 * Classe Ineq_Table6 * 00044 *****************************************************************************/ 00045 00046 class Ineq_Table6 { 00047 00048 public: 00049 00050 // constructeurs. 00051 Ineq_Table6(); 00052 Ineq_Table6(Ineq_Table6 const & other); 00053 Ineq_Table6(CVertex const & p); 00054 Ineq_Table6(CVertex const & p1, CVertex const & p2); 00055 00056 // Méthode permettant la lecture d'une des équation du tableau. 00057 Inequation * Get_Ineq(int num); 00058 00059 // Méthode permettant l'écriture d'une équation dans le tableau. 00060 void Set_Ineq(int num, Inequation const & i); 00061 00062 00063 private: 00064 00065 // Tableau comportant six cases, et contenant des objets de la classe 00066 // Inequation. 00067 Inequation tab[6]; 00068 }; 00069 00070 /****************************************************************************** 00071 * Fichier : Ineq_Table6.inl * 00072 * Auteur : DEXET Martine * 00073 *----------------------------------------------------------------------------* 00074 * Ce fichier contient l'implémentation des méthodes de la classe * 00075 * Ineq_Table6. * 00076 * * 00077 *****************************************************************************/ 00078 00079 00080 00081 // constructeurs. 00082 inline 00083 Ineq_Table6::Ineq_Table6() 00084 {} 00085 00086 inline 00087 Ineq_Table6::Ineq_Table6(Ineq_Table6 const & other) 00088 { 00089 for (int i=0; i<6; i++) 00090 tab[i] = other.tab[i]; 00091 } 00092 00093 inline 00094 Ineq_Table6::Ineq_Table6(CVertex const & p) 00095 { 00096 tab[1].SetB(0); 00097 tab[0].SetB(0); 00098 tab[1].SetC(0); 00099 tab[0].SetC(0); 00100 00101 tab[0].SetA(1); 00102 tab[1].SetA(-1); 00103 tab[0].SetW(p.getX() + 0.5); 00104 tab[1].SetW(0.5 - p.getX()); 00105 00106 tab[3].SetA(0); 00107 tab[2].SetA(0); 00108 tab[3].SetC(0); 00109 tab[2].SetC(0); 00110 00111 tab[2].SetB(1); 00112 tab[3].SetB(-1); 00113 tab[2].SetW(p.getY() + 0.5); 00114 tab[3].SetW(0.5 - p.getY()); 00115 00116 tab[5].SetB(0); 00117 tab[4].SetB(0); 00118 tab[5].SetA(0); 00119 tab[4].SetA(0); 00120 00121 tab[4].SetC(1); 00122 tab[5].SetC(-1); 00123 tab[4].SetW(p.getZ() + 0.5); 00124 tab[5].SetW(0.5 - p.getZ()); 00125 } 00126 00127 inline 00128 Ineq_Table6::Ineq_Table6(CVertex const & p1, CVertex const & p2) 00129 { 00130 float d; 00131 00132 tab[1].SetC(0); 00133 tab[0].SetC(0); 00134 00135 tab[0].SetA(p1.getY()-p2.getY()); 00136 tab[0].SetB(p2.getX()-p1.getX()); 00137 tab[1].SetA(-tab[0].GetA()); 00138 tab[1].SetB(-tab[0].GetB()); 00139 00140 d = -(tab[0].GetA()*p1.getX() + tab[0].GetB()*p1.getY()); 00141 00142 tab[0].SetW((fabs(tab[0].GetA()) + fabs(tab[0].GetB()))/2.0); 00143 tab[1].SetW(tab[0].GetW() + d); 00144 tab[0].SetW(tab[0].GetW() - d); 00145 00146 tab[3].SetA(0); 00147 tab[2].SetA(0); 00148 00149 tab[2].SetB(p1.getZ()-p2.getZ()); 00150 tab[2].SetC(p2.getY()-p1.getY()); 00151 tab[3].SetB(-tab[2].GetB()); 00152 tab[3].SetC(-tab[2].GetC()); 00153 00154 d = -(tab[2].GetB()*p1.getY() + tab[2].GetC()*p1.getZ()); 00155 00156 tab[2].SetW((fabs(tab[2].GetB()) + fabs(tab[2].GetC()))/2.0); 00157 tab[3].SetW(tab[2].GetW() + d); 00158 tab[2].SetW(tab[2].GetW() - d); 00159 00160 tab[5].SetB(0); 00161 tab[4].SetB(0); 00162 00163 tab[4].SetC(p1.getX()-p2.getX()); 00164 tab[4].SetA(p2.getZ()-p1.getZ()); 00165 tab[5].SetC(-tab[4].GetC()); 00166 tab[5].SetA(-tab[4].GetA()); 00167 00168 d = -(tab[4].GetA()*p1.getX() + tab[4].GetC()*p1.getZ()); 00169 00170 tab[4].SetW((fabs(tab[4].GetA()) + fabs(tab[4].GetC()))/2.0); 00171 tab[5].SetW(tab[4].GetW() + d); 00172 tab[4].SetW(tab[4].GetW() - d); 00173 00174 for (int i=0; i<6; i++) 00175 { 00176 if (tab[i].GetA() == 0 && tab[i].GetB() == 0 && tab[i].GetC() == 0) 00177 tab[i].Set_Unused(); 00178 } 00179 } 00180 00181 00182 00183 // Méthode permettant la lecture d'une des équation du tableau. 00184 inline 00185 Inequation * Ineq_Table6::Get_Ineq(int num) 00186 { 00187 assert(num >= 0 && num <= 5); 00188 00189 return &tab[num]; 00190 } 00191 00192 00193 // Méthode permettant l'écriture d'une équation dans le tableau. 00194 inline 00195 void Ineq_Table6::Set_Ineq(int num, Inequation const & i) 00196 { 00197 assert(num >= 0 && num <= 5); 00198 00199 tab[num] = i; 00200 } 00201 00202 #endif