⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 doscale.c

📁 蒙特卡罗模拟光子成像C语言版,代码简洁专业
💻 C
字号:
/* ----------------------------RESCALE ------------------------------
 *  Rescale the Universe to get unit grid spacing.  Units are
 *  specified in mm in the input file.  system.dl has dimension of
 *  mm/voxel, which takes everything into voxel units.  This is the
 *  only place where the "struct Config" should be modified once
 *  it's loaded in.
 */

/*
 * This file is part of tMCimg.
 * 
 * tMCimg is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "config.h"
#include "tMCimg.h"

#if (HAVE_ASSERT_H)
#include <assert.h>
#endif

void rescale_system(struct Config *system)
{
  int i;

#if (HAVE_ASSERT)
  assert(system->dl > 0);
#endif

  system->v0 /= system->dl;
  system->k0 *= system->dl;

/*
  system->Lmax /= system->dl;
  system->Lmin /= system->dl;
  system->stepL /= system->dl;
*/

  for (i = 1; i <= system->Ntissue; i++)
    {
      system->tmus[i] *= system->dl;
      system->tmua[i] *= system->dl;
    }

  for (i = 0; i < system->nDets; i++)
    {
      system->detLoc[i][0] /= system->dl;
      system->detLoc[i][1] /= system->dl;
      system->detLoc[i][2] /= system->dl;
      system->detRad[i]    /= system->dl;
    }

  for (i = 0; i < system->nSrcs; i++)
    {
      system->srcLoc[i][0] /= system->dl;
      system->srcLoc[i][1] /= system->dl;
      system->srcLoc[i][2] /= system->dl;
      system->srcRad[i]    /= system->dl;
    }

  system->xstep /= system->dl;	  /* these are never used (cubic voxels) */
  system->ystep /= system->dl;
  system->zstep /= system->dl;

#if (HAVE_ASSERT)
  assert((system->xstep == 1.0) && 
         (system->ystep == 1.0) && (system->zstep == 1.0));
#endif

  return;
}

/* Undo a previously applied length scaling */

float unscale_length(const float x, const struct Config *system)
{
  return ((float)(x * system->dl));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -