ROOT logo
// $Id: GTSIsoMaker.cxx 2088 2008-11-23 20:26:46Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

//__________________________________________________________________________
// GTSIsoMaker
//
//

#include "GTSIsoMaker.h"
#include "GTSIsoMaker.c7"

#include <GTS/GTS.h>

#include <TF3.h>

ClassImp(GTSIsoMaker);

/**************************************************************************/

void GTSIsoMaker::_init()
{
  mTarget = 0;
  mAlgo   = A_Cartesian;
  mValue  = 0;
  mXmin = mYmin = mZmin = -1;
  mXmax = mYmax = mZmax =  1;
  mXdiv = mYdiv = mZdiv = 20;
}

/**************************************************************************/

void GTSIsoMaker::SetXAxis(Float_t min, Float_t max, UShort_t div)
{
  mXmin = min; mXmax = max; mXdiv = div;
  Stamp(FID());
}

void GTSIsoMaker::SetYAxis(Float_t min, Float_t max, UShort_t div)
{
  mYmin = min; mYmax = max; mYdiv = div;
  Stamp(FID());
}

void GTSIsoMaker::SetZAxis(Float_t min, Float_t max, UShort_t div)
{
  mZmin = min; mZmax = max; mZdiv = div;
  Stamp(FID());
}

/**************************************************************************/

namespace {
  void form_to_plane(GTS::gdouble **a, GTS::GtsCartesianGrid g,
		     GTS::guint i, GTS::gpointer data)
  {
    Double_t z = g.z;
    // printf("form_to_plane called w/ i=%d => z=%lf\n", i, z);
    TF3& formula = *((TF3*)data);

    Double_t x = g.x;
    for(unsigned int nx=0; nx<g.nx; ++nx) {
      Double_t y = g.y;
      for(unsigned int ny=0; ny<g.ny; ++ny) {
	a[nx][ny] = formula.Eval(x, y, z);
	y += g.dy;
      }
      x += g.dx;
    }
  }
};

void GTSIsoMaker::MakeSurface()
{
  static const Exc_t _eh("GTSIsoMaker::MakeSurface ");

  using namespace GTS;

  GTSurf* target = *mTarget;
  if(target == 0) {
    throw(_eh + "Link Target should be set.");
  }

  TF3 formula(GForm("GTSIsoMaker_%d", GetSaturnID()), mFormula.Data(), 0, 0);
  formula.SetRange(mXmin, mXmax, mYmin, mYmax, mZmin, mZmax);

  GtsCartesianGrid grid = {
    mXdiv + 1, mYdiv + 1, mZdiv + 1,
    mXmin, (mXmax - mXmin) / mXdiv,
    mYmin, (mYmax - mYmin) / mYdiv,
    mZmin, (mZmax - mZmin) / mZdiv
  };

  GtsSurface* s = MakeDefaultSurface();

  switch(mAlgo) {
  case A_Cartesian:
    gts_isosurface_cartesian(s, grid, form_to_plane, &formula, mValue);
    break;
  case A_Tetra:
    gts_isosurface_tetra(s, grid, form_to_plane, &formula, mValue);
    break;
  case A_TetraBounded:
    gts_isosurface_tetra_bounded(s, grid, form_to_plane, &formula, mValue);
    break;
  case A_TetraBCL:
    gts_isosurface_tetra_bcl(s, grid, form_to_plane, &formula, mValue);
    break;
  }

  target->WriteLock();
  target->ReplaceSurface(s);
  target->WriteUnlock();
}

/**************************************************************************/
 GTSIsoMaker.cxx:1
 GTSIsoMaker.cxx:2
 GTSIsoMaker.cxx:3
 GTSIsoMaker.cxx:4
 GTSIsoMaker.cxx:5
 GTSIsoMaker.cxx:6
 GTSIsoMaker.cxx:7
 GTSIsoMaker.cxx:8
 GTSIsoMaker.cxx:9
 GTSIsoMaker.cxx:10
 GTSIsoMaker.cxx:11
 GTSIsoMaker.cxx:12
 GTSIsoMaker.cxx:13
 GTSIsoMaker.cxx:14
 GTSIsoMaker.cxx:15
 GTSIsoMaker.cxx:16
 GTSIsoMaker.cxx:17
 GTSIsoMaker.cxx:18
 GTSIsoMaker.cxx:19
 GTSIsoMaker.cxx:20
 GTSIsoMaker.cxx:21
 GTSIsoMaker.cxx:22
 GTSIsoMaker.cxx:23
 GTSIsoMaker.cxx:24
 GTSIsoMaker.cxx:25
 GTSIsoMaker.cxx:26
 GTSIsoMaker.cxx:27
 GTSIsoMaker.cxx:28
 GTSIsoMaker.cxx:29
 GTSIsoMaker.cxx:30
 GTSIsoMaker.cxx:31
 GTSIsoMaker.cxx:32
 GTSIsoMaker.cxx:33
 GTSIsoMaker.cxx:34
 GTSIsoMaker.cxx:35
 GTSIsoMaker.cxx:36
 GTSIsoMaker.cxx:37
 GTSIsoMaker.cxx:38
 GTSIsoMaker.cxx:39
 GTSIsoMaker.cxx:40
 GTSIsoMaker.cxx:41
 GTSIsoMaker.cxx:42
 GTSIsoMaker.cxx:43
 GTSIsoMaker.cxx:44
 GTSIsoMaker.cxx:45
 GTSIsoMaker.cxx:46
 GTSIsoMaker.cxx:47
 GTSIsoMaker.cxx:48
 GTSIsoMaker.cxx:49
 GTSIsoMaker.cxx:50
 GTSIsoMaker.cxx:51
 GTSIsoMaker.cxx:52
 GTSIsoMaker.cxx:53
 GTSIsoMaker.cxx:54
 GTSIsoMaker.cxx:55
 GTSIsoMaker.cxx:56
 GTSIsoMaker.cxx:57
 GTSIsoMaker.cxx:58
 GTSIsoMaker.cxx:59
 GTSIsoMaker.cxx:60
 GTSIsoMaker.cxx:61
 GTSIsoMaker.cxx:62
 GTSIsoMaker.cxx:63
 GTSIsoMaker.cxx:64
 GTSIsoMaker.cxx:65
 GTSIsoMaker.cxx:66
 GTSIsoMaker.cxx:67
 GTSIsoMaker.cxx:68
 GTSIsoMaker.cxx:69
 GTSIsoMaker.cxx:70
 GTSIsoMaker.cxx:71
 GTSIsoMaker.cxx:72
 GTSIsoMaker.cxx:73
 GTSIsoMaker.cxx:74
 GTSIsoMaker.cxx:75
 GTSIsoMaker.cxx:76
 GTSIsoMaker.cxx:77
 GTSIsoMaker.cxx:78
 GTSIsoMaker.cxx:79
 GTSIsoMaker.cxx:80
 GTSIsoMaker.cxx:81
 GTSIsoMaker.cxx:82
 GTSIsoMaker.cxx:83
 GTSIsoMaker.cxx:84
 GTSIsoMaker.cxx:85
 GTSIsoMaker.cxx:86
 GTSIsoMaker.cxx:87
 GTSIsoMaker.cxx:88
 GTSIsoMaker.cxx:89
 GTSIsoMaker.cxx:90
 GTSIsoMaker.cxx:91
 GTSIsoMaker.cxx:92
 GTSIsoMaker.cxx:93
 GTSIsoMaker.cxx:94
 GTSIsoMaker.cxx:95
 GTSIsoMaker.cxx:96
 GTSIsoMaker.cxx:97
 GTSIsoMaker.cxx:98
 GTSIsoMaker.cxx:99
 GTSIsoMaker.cxx:100
 GTSIsoMaker.cxx:101
 GTSIsoMaker.cxx:102
 GTSIsoMaker.cxx:103
 GTSIsoMaker.cxx:104
 GTSIsoMaker.cxx:105
 GTSIsoMaker.cxx:106
 GTSIsoMaker.cxx:107
 GTSIsoMaker.cxx:108
 GTSIsoMaker.cxx:109
 GTSIsoMaker.cxx:110
 GTSIsoMaker.cxx:111
 GTSIsoMaker.cxx:112
 GTSIsoMaker.cxx:113
 GTSIsoMaker.cxx:114
 GTSIsoMaker.cxx:115
 GTSIsoMaker.cxx:116
 GTSIsoMaker.cxx:117
 GTSIsoMaker.cxx:118