Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

object-compound.c

Go to the documentation of this file.
00001 /************************************************************************* 00002 * $Id: object-compound.c,v 1.9 2005/09/07 07:13:32 yougz Exp $ 00003 * Contains functiosn to define objects with multiple components 00004 * At moment, two components for water and fat 00005 ************************************************************************** 00006 This software is governed by the CeCILL license under French law and 00007 abiding by the rules of distribution of free software. You can use, 00008 modify and/ or redistribute the software under the terms of the CeCILL 00009 license as circulated by CEA, CNRS and INRIA at the following URL 00010 "http://www.cecill.info". 00011 00012 As a counterpart to the access to the source code and rights to copy, 00013 modify and redistribute granted by the license, users are provided only 00014 with a limited warranty and the software's author, the holder of the 00015 economic rights, and the successive licensors have only limited 00016 liability. 00017 00018 In this respect, the user's attention is drawn to the risks associated 00019 with loading, using, modifying and/or developing or reproducing the 00020 software by the user in light of its specific status of free software, 00021 that may mean that it is complicated to manipulate, and that also 00022 therefore means that it is reserved for developers and experienced 00023 professionals having in-depth computer knowledge. Users are therefore 00024 encouraged to load and test the software's suitability as regards their 00025 requirements in conditions enabling the security of their systems and/or 00026 data to be ensured and, more generally, to use and operate it in the 00027 same conditions as regards security. 00028 00029 The fact that you are presently reading this means that you have had 00030 knowledge of the CeCILL license and that you accept its terms. 00031 00032 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de 00033 l'Image). All rights reserved. See License.txt for details. 00034 00035 Version 1.0 05/09/2005 00036 *************************************************************************/ 00037 #include "object-compound.h" 00038 #include <idseq.h> 00039 #include <idacr.h> 00040 #include <string.h> 00041 #include <idvol.h> 00042 #include <display.h> 00043 00053 OBJECT3D * CreateObjectBiComponent1D(int nx) 00054 { 00055 OBJECT3D * object; 00056 int xdeb, xfin,rodeb,rofin,t1deb,t1fin,t2deb,t2fin; 00057 int ny,nz; 00058 00059 ny=1;nz=1; 00060 object = (OBJECT3D *) AllocObject(nx,ny,nz,2,3); 00061 SetObjectChemicalShift(object,DECWATER,WATER); 00062 SetObjectChemicalShift(object,DECFAT,FAT); 00063 rodeb=60;rofin=100; 00064 t1deb=50;t1fin=400; 00065 t2deb=50;t2fin=90; 00066 00067 /* 1rst part */ 00068 xdeb=0;xfin=nx/8; 00069 SetLinearObject1D(object,rodeb, rofin,t1deb,t1fin,t2deb,t2fin,xdeb, xfin, WATER); 00070 SetLinearObject1D(object,rodeb, rofin,t1deb,t1fin,t2deb,t2fin,xdeb, xfin, FAT); 00071 /* 2nd part */ 00072 xdeb=nx/8;xfin=nx/4; 00073 rodeb=100;rofin=100;t1deb=180;t1fin=180;t2deb=90;t2deb=90; 00074 SetLinearObject1D(object,rofin, rodeb,t1fin,t1deb,t2fin,t2deb,xdeb, xfin, WATER); 00075 SetLinearObject1D(object,rofin, rodeb,t1fin,t1deb,t2fin,t2deb,xdeb, xfin, FAT); 00076 /* background */ 00077 xdeb=nx/4; xfin=nx; 00078 rodeb=50;t1deb=150;t2deb=60;rofin=rodeb;t1fin=t1deb; t2fin=t2deb; 00079 SetLinearObject1D(object,rofin, rodeb,t1fin,t1deb,t2fin,t2deb,xdeb, xfin, WATER); 00080 SetLinearObject1D(object,rofin, rodeb,t1fin,t1deb,t2fin,t2deb,xdeb, xfin, FAT); 00081 00082 return(object); 00083 } 00084 00094 OBJECT3D * CreateObjectBiComponent2DCircle(int nx,int ny) 00095 { 00096 OBJECT3D * object; 00097 int nz=1; 00098 int ro,t1,t2; 00099 int ox, oy; 00100 int i,j,k; 00101 int rext,rint; 00102 00103 object = (OBJECT3D *) AllocObject(nx,ny,nz,2,3); 00104 SetObjectChemicalShift(object,DECWATER,WATER); 00105 SetObjectChemicalShift(object,DECFAT,FAT); 00106 00107 /* Background*/ 00108 ox=nx/2; oy=ny/2; 00109 t1=100; t2=50; ro=0; 00110 //t1=200; t2=2; ro=2; 00111 k=0; 00112 for (i=0;i<nx;i++) for(j=0;j<ny;j++) 00113 { 00114 SetObjectPoint(object,i,j,k,ro,t1,t2,WATER); 00115 SetObjectPoint(object,i,j,k,0,t1,t2,FAT); 00116 } 00117 00118 /* Water extern circle */ 00119 if (nx<ny) 00120 { 00121 rext=nx/4*1.5; 00122 rint=nx/8*1.5; 00123 } 00124 else 00125 { 00126 rext=ny/4*1.5; 00127 rint=ny/8*1.5; 00128 } 00129 00130 ox=nx/2; oy=ny/2; 00131 k=0; 00132 t1=3000; t2=300; ro=100; 00133 for (i=0;i<nx;i++) for(j=0;j<ny;j++) 00134 if ((((i - ox)*(i - ox)+(j - oy)*(j - oy)) < (rext * rext) ) && ( ((i - ox)*(i - ox)+(j - oy)*(j - oy)) >= (rint*rint))) 00135 { SetObjectPoint(object,i,j,k,ro,t1,t2,WATER); 00136 SetObjectPoint(object,i,j,k,0,t1,t2,FAT); 00137 } 00138 00139 /* Fat internal circle */ 00140 if (nx<ny) 00141 rint=nx/8*1.5; 00142 else 00143 rint=ny/8*1.5; 00144 00145 ox=nx/2; oy=ny/2; 00146 k=0; 00147 ro=100;t1=350; t2=70; /* T1, T2 values for B0=1T */ 00148 00149 for (i=0;i<nx;i++) for(j=0;j<ny;j++) 00150 if ((i - ox) * (i - ox) + (j - oy) * (j - oy) < rint * rint) 00151 { 00152 SetObjectPoint(object,i,j,k,80,t1,t2,FAT); 00153 SetObjectPoint(object,i,j,k,20,3000,300,WATER); 00154 } 00155 00156 return(object); 00157 } 00158 00169 OBJECT3D * CreateObjectBiComponent2DCircleEllipse(int nx,int ny) 00170 { 00171 OBJECT3D * object; 00172 int nz=1; 00173 int ro,t1,t2; 00174 int ox, oy,rx,ry; 00175 register int i,j,k; 00176 int radius; 00177 00178 object = (OBJECT3D *) AllocObject(nx,ny,nz,2,3); 00179 SetObjectChemicalShift(object,DECWATER,WATER); 00180 SetObjectChemicalShift(object,DECFAT,FAT); 00181 00182 /* Background */ 00183 t1=100; t2=50; ro=100; 00184 k=0; 00185 for (i=0;i<nx;i++) for(j=0;j<ny;j++) 00186 SetObjectPoint(object,i,j,k,ro,t1,t2,WATER); 00187 00188 /* Water circle */ 00189 if (nx<ny) radius=nx/8; 00190 else radius=ny/8; 00191 ox=nx/4; oy=ny/4; 00192 k=0; 00193 t1=0; t2=0; ro=0; 00194 for (i=0;i<nx;i++) for(j=0;j<ny;j++) 00195 if ((i - ox) * (i - ox) + (j - oy) * (j - oy) < radius * radius) 00196 SetObjectPoint(object,i,j,k,ro,t1,t2,WATER); 00197 if (nx<ny) radius=nx/8; 00198 else radius=ny/8; 00199 ox=nx/4; oy=ny/4; 00200 k=0; 00201 t1=400; t2=50; ro=100; 00202 for (i=0;i<nx;i++) for(j=0;j<ny;j++) 00203 if ((i - ox) * (i - ox) + (j - oy) * (j - oy) < radius * radius) 00204 SetObjectPoint(object,i,j,k,ro,t1,t2,WATER); 00205 00206 /* Fat ellipse */ 00207 rx=nx/4; ry=ny/8; 00208 ox=3*nx/4; oy=3*ny/4; 00209 k=0; 00210 ro=1; t1=2500; t2=200; 00211 for (i=0;i<nx;i++) for(j=0;j<ny;j++) 00212 if ((i-ox)*(i-ox)/(1.0*rx*rx)+(j-oy)*(j-oy)/(1.0*ry*ry)<1) 00213 SetObjectPoint(object,i,j,k,ro,t1,t2,FAT); 00214 00215 return(object); 00216 } 00217 00228 OBJECT3D * CreateObjectBiComponent3DSphere(int nx,int ny,int nz) 00229 { 00230 OBJECT3D * object; 00231 00232 object = (OBJECT3D *) AllocObject(nx,ny,nz,2,3); 00233 SetObjectChemicalShift(object,DECWATER,WATER); 00234 SetObjectChemicalShift(object,DECFAT,FAT); 00235 00236 /* Water extern sphere */ 00237 SetObjectSphereComponent(object, (int)(nx/3), 00238 nx, ny, nz, 00239 nx / 2, ny / 2, nz /2 , 0, 0, 0, 90, 40, 100, 0,WATER); 00240 SetObjectSphereComponent(object, (int)(nx/3), 00241 nx, ny, nz, 00242 nx / 2, ny / 2, nz /2 , 400, 50, 100, 90, 40, 100, 1,WATER); 00243 00244 /* Fat intern sphere */ 00245 SetObjectSphereComponent(object, (int)(nx/5), 00246 nx, ny, nz, 00247 nx / 2, ny / 2, nz /2 , 0, 0 , 0, 90, 40, 100, 0,WATER); 00248 SetObjectSphereComponent(object, (int)(nx/5), 00249 nx, ny, nz, 00250 nx / 2, ny / 2, nz /2 , 180, 90 , 1, 90, 40, 100, 0,FAT); 00251 SetObjectSphereComponent(object, (int)(nx/5), 00252 nx, ny, nz, 00253 nx / 2, ny / 2, nz /2 , 180, 90 , 1, 90, 40, 100, 0,WATER); 00254 00255 return (object); 00256 } 00257 00268 OBJECT3D * CreateObject3DSphereEllipse(int nx, int ny, int nz) 00269 { 00270 OBJECT3D * object; 00271 object = (OBJECT3D *) AllocObject(nx,ny,nz,1,3); 00272 00273 SetObjectSphereComponent(object, (int)(nx/5), 00274 nx, ny, nz, 00275 nx / 4, ny / 4, nz / 4, 00276 500, 90, 70, 00277 10, 50, 2,1,WATER); /* GM */ 00278 00279 SetObjectEllipseComponent(object, (int)(nx/2.5), (int)(nx/4), (int)(nx/8), 00280 nx, ny, nz, 00281 nx / 2, ny / 2, nz / 2, 00282 350, 75, 60, 00283 10, 50, 2,0,WATER); /* WM */ 00284 00285 return(object); 00286 } 00287 00309 void SetObjectSphereComponent(OBJECT3D * object, 00310 int radius, 00311 int dimx, int dimy, int dimz, 00312 int ox, int oy, int oz, 00313 int t1s, int t2s, int ros, 00314 int t1b, int t2b, int rob, int fill_all,int component) 00315 { 00316 register int i,j,k; 00317 00318 /* Few verifications */ 00319 if ((object->nbparam !=3)||(object->nbcomponent>2)) 00320 { 00321 printf("Le nombre de composantes de l'object est incoherent !\n"); 00322 exit(0); 00323 } 00324 if (!((object->x==dimx)&&(object->y==dimy)&&(object->z==dimz))) 00325 { 00326 printf("Taille d'object incompatible !\n"); 00327 exit(0); 00328 } 00329 00330 for (i=0;i<dimx;i++) for(j=0;j<dimy;j++) for(k=0;k<dimz;k++) 00331 { 00332 if ((i - ox) * (i - ox) + (j - oy) * (j - oy) + 00333 (k - oz) * (k - oz) <= radius * radius) { 00334 SetObjectPoint(object,i,j,k,ros,t1s,t2s,component); 00335 } else { 00336 if (fill_all) { 00337 SetObjectPoint(object,i,j,k,rob,t1b,t2b,component); 00338 } 00339 } 00340 } 00341 } 00342 00366 void SetObjectEllipseComponent(OBJECT3D *object, 00367 int rx, int ry, int rz, 00368 int dimx, int dimy, int dimz, 00369 int ox, int oy, int oz, 00370 int t1s, int t2s, int ros, 00371 int t1b, int t2b, int rob, int fill_all,int component) 00372 { 00373 register int i,j,k; 00374 00375 /* Few verifications */ 00376 if ((object->nbparam !=3)||(object->nbcomponent>21)) 00377 { 00378 printf("Le nombre de composantes de l'object plus grand que 2 !\n"); 00379 exit(0); 00380 } 00381 if (!((object->x==dimx)&&(object->y==dimy)&&(object->z==dimz))) 00382 { 00383 printf("Taille d'object incompatible !\n"); 00384 exit(0); 00385 } 00386 00387 for (i=0;i<dimx;i++) for(j=0;j<dimy;j++) for(k=0;k<dimz;k++) 00388 { 00389 if ((i-ox)*(i-ox) / (1.0*rx*rx) + (j-oy)*(j-oy) / (1.0*ry*ry) 00390 + (k-oz)*(k-oz) / (1.0*rz*rz) < 1) { 00391 SetObjectPoint(object,i,j,k,ros,t1s,t2s,WATER); 00392 } else { 00393 if (fill_all) { 00394 SetObjectPoint(object,i,j,k,rob,t1b,t2b,WATER); 00395 } 00396 } 00397 } 00398 } 00399

Generated on Wed Oct 19 09:28:34 2005 for SIMRI3D by doxygen 1.3.7