GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/seek/methodsSeek.c Lines: 0 115 0.0 %
Date: 2017-05-26 Branches: 0 6 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 "seek.h"
25
#include "privateSeek.h"
26
27
const int
28
seekPresent = 42;
29
30
seekContext *
31
seekContextNew(void) {
32
  seekContext *sctx;
33
  unsigned int fi;
34
35
  sctx = (seekContext *)calloc(1, sizeof(seekContext));
36
  if (sctx) {
37
    sctx->verbose = 0;
38
    sctx->ninscl = NULL;
39
    sctx->gctx = NULL;
40
    sctx->pvl = NULL;
41
    sctx->type = seekTypeUnknown;
42
    sctx->sclvItem = -1;
43
    sctx->normItem = -1;
44
    sctx->gradItem = -1;
45
    sctx->evalItem = -1;
46
    sctx->evecItem = -1;
47
    sctx->stngItem = -1;
48
    sctx->hessItem = -1;
49
    sctx->lowerInside = AIR_FALSE;
50
    sctx->normalsFind = AIR_FALSE;
51
    sctx->strengthUse = AIR_FALSE;
52
    sctx->strengthSign = 1;
53
    sctx->isovalue = AIR_NAN;
54
    sctx->evalDiffThresh = 1.0; /* roughly reasonable for uchar data;
55
                                 * really should depend on dynamic range */
56
    sctx->strength = 0.0;
57
    ELL_3V_SET(sctx->samples, 0, 0, 0);
58
    /* these two magic values assume a certain level of surface smoothness,
59
       which certainly does not apply to all cases */
60
    sctx->facesPerVoxel = 2.15;
61
    sctx->vertsPerVoxel = 1.15;
62
63
    /* this should be larger so that we don't waste time from airArrayLenIncr
64
       constantly re-allocating, when the isosurface is rough; better
65
       solution is to use multiplicatively scaled dynamic array. But caller
66
       can also change this value on a per-context basis. */
67
    sctx->pldArrIncr = 2048;
68
69
    sctx->nin = NULL;
70
    sctx->flag = AIR_CAST(int *, calloc(flagLast, sizeof(int)));
71
    for (fi=flagUnknown+1; fi<flagLast; fi++) {
72
      sctx->flag[fi] = AIR_FALSE;
73
    }
74
    sctx->baseDim = 0;
75
    sctx->_shape = gageShapeNew();
76
    sctx->shape = NULL;
77
    sctx->nsclDerived = nrrdNew();
78
    sctx->sclvAns = NULL;
79
    sctx->normAns = NULL;
80
    sctx->gradAns = NULL;
81
    sctx->evalAns = NULL;
82
    sctx->evecAns = NULL;
83
    sctx->stngAns = NULL;
84
    sctx->hessAns = NULL;
85
    sctx->reverse = AIR_FALSE;
86
    ELL_3M_IDENTITY_SET(sctx->txfNormal);
87
    sctx->spanSize = 300;
88
    sctx->nspanHist = nrrdNew();
89
    sctx->range = nrrdRangeNew(AIR_NAN, AIR_NAN);
90
    sctx->sx = 0;
91
    sctx->sy = 0;
92
    sctx->sz = 0;
93
    ELL_4M_IDENTITY_SET(sctx->txfIdx);
94
    sctx->nvidx = nrrdNew();
95
    sctx->nsclv = nrrdNew();
96
    sctx->ngrad = nrrdNew();
97
    sctx->neval = nrrdNew();
98
    sctx->nevec = nrrdNew();
99
    sctx->nflip = nrrdNew();
100
    sctx->nstng = nrrdNew();
101
    sctx->nhess = nrrdNew();
102
    sctx->nt = nrrdNew();
103
    sctx->nfacevidx = nrrdNew();
104
    sctx->nedgealpha = nrrdNew();
105
    sctx->nedgenorm = nrrdNew();
106
    sctx->nedgeicoord = nrrdNew();
107
    sctx->nfacecoord = nrrdNew();
108
    sctx->nfacenorm = nrrdNew();
109
    sctx->nfaceicoord = nrrdNew();
110
    sctx->npairs = nrrdNew();
111
    sctx->ngradcontext = nrrdNew();
112
    sctx->nhesscontext = nrrdNew();
113
    sctx->ntcontext = nrrdNew();
114
    sctx->nstngcontext = nrrdNew();
115
    sctx->ntreated = nrrdNew();
116
    sctx->vidx = NULL;
117
    sctx->sclv = NULL;
118
    sctx->grad = NULL;
119
    sctx->eval = NULL;
120
    sctx->evec = NULL;
121
    sctx->flip = NULL;
122
    sctx->stng = NULL;
123
    sctx->voxNum = 0;
124
    sctx->vertNum = 0;
125
    sctx->faceNum = 0;
126
    sctx->strengthSeenMax = AIR_NAN;
127
    sctx->time = AIR_NAN;
128
  }
129
  return sctx;
130
}
131
132
seekContext *
133
seekContextNix(seekContext *sctx) {
134
135
  if (sctx) {
136
    airFree(sctx->flag);
137
    sctx->flag = NULL;
138
    sctx->_shape = gageShapeNix(sctx->_shape);
139
    sctx->nsclDerived = nrrdNuke(sctx->nsclDerived);
140
    sctx->nspanHist = nrrdNuke(sctx->nspanHist);
141
    sctx->range = nrrdRangeNix(sctx->range);
142
    sctx->nvidx = nrrdNuke(sctx->nvidx);
143
    sctx->nsclv = nrrdNuke(sctx->nsclv);
144
    sctx->ngrad = nrrdNuke(sctx->ngrad);
145
    sctx->neval = nrrdNuke(sctx->neval);
146
    sctx->nevec = nrrdNuke(sctx->nevec);
147
    sctx->nflip = nrrdNuke(sctx->nflip);
148
    sctx->nstng = nrrdNuke(sctx->nstng);
149
    sctx->nhess = nrrdNuke(sctx->nhess);
150
    sctx->nt = nrrdNuke(sctx->nt);
151
    sctx->nfacevidx = nrrdNuke(sctx->nfacevidx);
152
    sctx->nedgealpha = nrrdNuke(sctx->nedgealpha);
153
    sctx->nedgenorm = nrrdNuke(sctx->nedgenorm);
154
    sctx->nedgeicoord = nrrdNuke(sctx->nedgeicoord);
155
    sctx->nfacecoord = nrrdNuke(sctx->nfacecoord);
156
    sctx->nfacenorm = nrrdNuke(sctx->nfacenorm);
157
    sctx->nfaceicoord = nrrdNuke(sctx->nfaceicoord);
158
    sctx->npairs = nrrdNuke(sctx->npairs);
159
    sctx->ngradcontext = nrrdNuke(sctx->ngradcontext);
160
    sctx->nhesscontext = nrrdNuke(sctx->nhesscontext);
161
    sctx->ntcontext = nrrdNuke(sctx->ntcontext);
162
    sctx->nstngcontext = nrrdNuke(sctx->nstngcontext);
163
    sctx->ntreated = nrrdNuke(sctx->ntreated);
164
    airFree(sctx);
165
  }
166
  return NULL;
167
}
168