GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/mite/thread.c Lines: 0 79 0.0 %
Date: 2017-05-26 Branches: 0 28 0.0 %

Line Branch Exec Source
1
/*
2
  Teem: Tools to process and visualize scientific data and images             .
3
  Copyright (C) 2013, 2012, 2011, 2010, 2009  University of Chicago
4
  Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
5
  Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
6
7
  This library is free software; you can redistribute it and/or
8
  modify it under the terms of the GNU Lesser General Public License
9
  (LGPL) as published by the Free Software Foundation; either
10
  version 2.1 of the License, or (at your option) any later version.
11
  The terms of redistributing and/or modifying this software also
12
  include exceptions to the LGPL that facilitate static linking.
13
14
  This library is distributed in the hope that it will be useful,
15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
  Lesser General Public License for more details.
18
19
  You should have received a copy of the GNU Lesser General Public License
20
  along with this library; if not, write to Free Software Foundation, Inc.,
21
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
*/
23
24
#include "mite.h"
25
#include "privateMite.h"
26
27
miteThread *
28
miteThreadNew() {
29
  static const char me[]="miteThreadNew";
30
  miteThread *mtt;
31
  int ii;
32
33
  mtt = (miteThread *)calloc(1, sizeof(miteThread));
34
  if (!mtt) {
35
    biffAddf(MITE, "%s: couldn't calloc miteThread", me);
36
    return NULL;
37
  }
38
39
  mtt->rmop = airMopNew();
40
  if (!mtt->rmop) {
41
    biffAddf(MITE, "%s: couldn't calloc thread's mop", me);
42
    airFree(mtt); return NULL;
43
  }
44
  mtt->gctx = NULL;
45
  mtt->ansScl = mtt->ansVec = mtt->ansTen = NULL;
46
  mtt->_normal = NULL;
47
  mtt->shadeVec0 = NULL;
48
  mtt->shadeVec1 = NULL;
49
  mtt->shadeScl0 = NULL;
50
  mtt->shadeScl1 = NULL;
51
  /* were miteVal a full-fledged gageKind, the following would
52
     be done by gagePerVolumeNew */
53
  mtt->ansMiteVal = AIR_CALLOC(gageKindTotalAnswerLength(miteValGageKind),
54
                               double);
55
  mtt->directAnsMiteVal = AIR_CALLOC(miteValGageKind->itemMax+1,
56
                                     double *);
57
  if (!(mtt->ansMiteVal && mtt->directAnsMiteVal)) {
58
    biffAddf(MITE, "%s: couldn't calloc miteVal answer arrays", me);
59
    return NULL;
60
  }
61
  for (ii=0; ii<=miteValGageKind->itemMax; ii++) {
62
    mtt->directAnsMiteVal[ii] = mtt->ansMiteVal
63
      + gageKindAnswerOffset(miteValGageKind, ii);
64
  }
65
  mtt->verbose = 0;
66
  mtt->skip = 0;
67
  mtt->thrid = -1;
68
  mtt->ui = mtt->vi = -1;
69
  mtt->raySample = 0;
70
  mtt->samples = 0;
71
  mtt->stage = NULL;
72
  /* mtt->range[], rayStep, V, RR, GG, BB, TT  initialized in
73
     miteRayBegin or in miteSample */
74
75
  return mtt;
76
}
77
78
miteThread *
79
miteThreadNix(miteThread *mtt) {
80
81
  mtt->ansMiteVal = (double *)airFree(mtt->ansMiteVal);
82
  mtt->directAnsMiteVal = (double **)airFree(mtt->directAnsMiteVal);
83
  airMopOkay(mtt->rmop);
84
85
  airFree(mtt);
86
  return NULL;
87
}
88
89
/*
90
******** miteThreadBegin()
91
**
92
** this has some of the body of what would be miteThreadInit
93
*/
94
int
95
miteThreadBegin(miteThread **mttP, miteRender *mrr,
96
                miteUser *muu, int whichThread) {
97
  static const char me[]="miteThreadBegin";
98
99
  /* all the miteThreads have already been allocated */
100
  (*mttP) = mrr->tt[whichThread];
101
102
  if (!whichThread) {
103
    /* this is the first thread- it just points to the parent gageContext */
104
    (*mttP)->gctx = muu->gctx0;
105
  } else {
106
    /* we have to generate a new gageContext */
107
    (*mttP)->gctx = gageContextCopy(muu->gctx0);
108
    if (!(*mttP)->gctx) {
109
      biffMovef(MITE, GAGE,
110
                "%s: couldn't set up thread %d", me, whichThread);
111
      return 1;
112
    }
113
  }
114
115
  if (-1 != mrr->sclPvlIdx) {
116
    (*mttP)->ansScl = (*mttP)->gctx->pvl[mrr->sclPvlIdx]->answer;
117
    (*mttP)->nPerp = ((*mttP)->ansScl
118
                      + gageKindAnswerOffset(gageKindScl, gageSclNPerp));
119
    (*mttP)->geomTens = ((*mttP)->ansScl
120
                         + gageKindAnswerOffset(gageKindScl, gageSclGeomTens));
121
  } else {
122
    (*mttP)->ansScl = NULL;
123
    (*mttP)->nPerp = NULL;
124
    (*mttP)->geomTens = NULL;
125
  }
126
  (*mttP)->ansVec = (-1 != mrr->vecPvlIdx
127
                     ? (*mttP)->gctx->pvl[mrr->vecPvlIdx]->answer
128
                     : NULL);
129
  (*mttP)->ansTen = (-1 != mrr->tenPvlIdx
130
                     ? (*mttP)->gctx->pvl[mrr->tenPvlIdx]->answer
131
                     : NULL);
132
  (*mttP)->thrid = whichThread;
133
  (*mttP)->raySample = 0;
134
  (*mttP)->samples = 0;
135
  (*mttP)->verbose = 0;
136
  (*mttP)->skip = 0;
137
  (*mttP)->_normal = _miteAnswerPointer(*mttP, mrr->normalSpec);
138
139
  /* set up shading answers */
140
  switch(mrr->shadeSpec->method) {
141
  case miteShadeMethodNone:
142
    /* nothing to do */
143
    break;
144
  case miteShadeMethodPhong:
145
    (*mttP)->shadeVec0 = _miteAnswerPointer(*mttP, mrr->shadeSpec->vec0);
146
    break;
147
  case miteShadeMethodLitTen:
148
    (*mttP)->shadeVec0 = _miteAnswerPointer(*mttP, mrr->shadeSpec->vec0);
149
    (*mttP)->shadeVec1 = _miteAnswerPointer(*mttP, mrr->shadeSpec->vec1);
150
    (*mttP)->shadeScl0 = _miteAnswerPointer(*mttP, mrr->shadeSpec->scl0);
151
    (*mttP)->shadeScl1 = _miteAnswerPointer(*mttP, mrr->shadeSpec->scl1);
152
    break;
153
  default:
154
    biffAddf(MITE, "%s: shade method %d not implemented!",
155
            me, mrr->shadeSpec->method);
156
    return 1;
157
    break;
158
  }
159
160
  if (_miteStageSet(*mttP, mrr)) {
161
    biffAddf(MITE, "%s: trouble setting up stage array", me);
162
    return 1;
163
  }
164
  return 0;
165
}
166
167
int
168
miteThreadEnd(miteThread *mtt, miteRender *mrr,
169
              miteUser *muu) {
170
171
  AIR_UNUSED(mtt);
172
  AIR_UNUSED(mrr);
173
  AIR_UNUSED(muu);
174
  return 0;
175
}
176