This file is indexed.

/usr/include/Field3D/FieldWrapper.h is in libfield3d-dev 1.7.2-1build2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
//----------------------------------------------------------------------------//

#ifndef __F3DUTIL_FIELDWRAPPER_H__
#define __F3DUTIL_FIELDWRAPPER_H__

//------------------------------------------------------------------------------

// Library includes
#include <OpenEXR/ImathMatrixAlgo.h>

// Project includes
#include "DenseField.h"
#include "Field3DFile.h"
#include "FieldInterp.h"
#include "InitIO.h"
#include "MIPField.h"
#include "MIPUtil.h"
#include "SparseField.h"
#include "FieldSampler.h"
#include "FieldMapping.h"

//----------------------------------------------------------------------------//

#include "ns.h"

FIELD3D_NAMESPACE_OPEN

//------------------------------------------------------------------------------
// ValueRemapOp
//------------------------------------------------------------------------------

//! The ValueRemapOp class is used when shader-like calculations need to
//! be applied to individual fields that are part of a FieldGroup.
//! Use FieldGroup::setValueRemap() to set the current op before loading the
//! corresponding fields. Then, once lookups take place, the operator is 
//! called upon to remap the resulting values.
//! \note The class is not templated, and it needs to handle both scalar
//! and vector values.
class ValueRemapOp
{
public:
  
  // Typedefs ---

  typedef boost::shared_ptr<ValueRemapOp> Ptr;

  // To be implemented by subclasses ---

  //! Remaps a float value
  virtual float remap(const float value) const = 0;
  //! Remaps a V3f value
  virtual V3f   remap(const V3f &value)  const = 0;

};

//------------------------------------------------------------------------------
// FieldWrapper
//------------------------------------------------------------------------------

//! This class wraps up a single field to make its interpolator and its
//! mapping easily accessible. The 'Vec' typedef gives access to a std::vector.
template <typename Field_T>
struct FieldWrapper
{
  typedef Field_T                   field_type;
  typedef std::vector<FieldWrapper> Vec;

  FieldWrapper(const typename Field_T::Ptr f)
    : field(f.get()), 
      fieldPtr(f), 
      mapping(f->mapping().get()), 
      vsBounds(continuousBounds(f->dataWindow())),
      worldScale(1.0), 
      doOsToWs(false),
      doWsBoundsOptimization(false),
      valueRemapOp(NULL)
  { }

  void setOsToWs(const M44d &i_osToWs)
  {
    osToWs   = i_osToWs;
    wsToOs   = osToWs.inverse();
    // Compute world scale
    V3d ws(1.0);
    if (!Imath::extractScaling(osToWs, ws, false)) {
      Msg::print("WARNING: FieldGroup/FieldWrapper: "
                 "Couldn't extract world scale from object-to-world "
                 "transform. Defaulting to 1.0.");
    }
    worldScale = std::max(std::max(ws.x, ws.y), ws.z);
    // Set boolean
    doOsToWs = true;

    // Update wsBounds
    if (doWsBoundsOptimization) {
      setWsBoundsOptimization(doWsBoundsOptimization);
    }
  }

  void setWsBoundsOptimization(const bool doWsBoundsOptimization_)
  {
    if (!doWsBoundsOptimization_)
      return;
    // wsBounds can be set only if mapping is a matrix
    const MatrixFieldMapping *mtx_mapping = 
      dynamic_cast<const MatrixFieldMapping*>(mapping);
    if (mtx_mapping) {
      const float time = 0;
      M44d vsToWs;
      if (doOsToWs) {
        wsToVs = wsToOs * mtx_mapping->worldToVoxel(time);
        vsToWs = wsToVs.inverse();
      } else {
        wsToVs = mtx_mapping->worldToVoxel(time);
        vsToWs = wsToVs.inverse();
      }
      const Imath::Box3d wsBounds_d = Imath::transform(vsBounds,
                                                       vsToWs);
      wsBounds = Imath::Box3f(wsBounds_d.min, wsBounds_d.max);
      doWsBoundsOptimization = true;
    }
  }

  void setValueRemapOp(ValueRemapOp::Ptr op)
  {
    valueRemapOpPtr = op;
    valueRemapOp    = valueRemapOpPtr.get();
  }

  typename Field_T::LinearInterp  interp;
  const Field_T                  *field;
  typename Field_T::Ptr           fieldPtr;
  const Field3D::FieldMapping    *mapping;
  Box3d                           vsBounds;
  //! Optionally, enable doOsToWs to apply a world to object transform before
  //! lookups.
  M44d                            osToWs, wsToOs;
  double                          worldScale;
  bool                            doOsToWs;
  //! Optionally, enable wsBounds optimization to use a world axis
  //! aligned bounding box in lookups.
  M44d                            wsToVs;
  Imath::Box3f                    wsBounds;
  bool                            doWsBoundsOptimization;
  //! Optionally, set a ValueRemapOp to remap values
  ValueRemapOp::Ptr               valueRemapOpPtr;
  const ValueRemapOp             *valueRemapOp;
};

//------------------------------------------------------------------------------
// MIPFieldWrapper
//------------------------------------------------------------------------------

//! This class wraps up a single MIP field to make its interpolator and its
//! mapping easily accessible. The 'Vec' typedef gives access to a std::vector.
template <typename Field_T>
struct MIPFieldWrapper
{
  typedef Field_T                        field_type;
  typedef std::vector<MIPFieldWrapper>   Vec;
  typedef typename Field_T::LinearInterp LinearInterp;

  MIPFieldWrapper(const typename Field_T::Ptr f)
    : interpPtr(new LinearInterp(*f)), 
      field(f.get()), 
      fieldPtr(f), 
      mapping(f->mapping().get()), 
      vsBounds(continuousBounds(f->dataWindow())),
      worldScale(1.0), 
      doOsToWs(false),
      valueRemapOp(NULL)
  { 
    interp = interpPtr.get();
  }

  void setOsToWs(const M44d &i_osToWs)
  {
    osToWs   = i_osToWs;
    wsToOs   = osToWs.inverse();
    // Compute world scale
    V3d ws(1.0);
    if (!Imath::extractScaling(osToWs, ws, false)) {
      Msg::print("WARNING: FieldGroup/FieldWrapper: "
                 "Couldn't extract world scale from object-to-world "
                 "transform. Defaulting to 1.0.");
    }
    worldScale = std::max(std::max(ws.x, ws.y), ws.z);
    // Set boolean
    doOsToWs = true;

    // Update wsBounds
    if (doWsBoundsOptimization) {
      setWsBoundsOptimization(doWsBoundsOptimization);
    }
  }

  void setWsBoundsOptimization(const bool doWsBoundsOptimization_)
  {
    if (!doWsBoundsOptimization_)
      return;
    // wsBounds can be set only if mapping is a matrix
    const MatrixFieldMapping *mtx_mapping = 
      dynamic_cast<const MatrixFieldMapping*>(mapping);
    if (mtx_mapping) {
      const float time = 0;
      M44d vsToWs;
      if (doOsToWs) {
        wsToVs = wsToOs * mtx_mapping->worldToVoxel(time);
        vsToWs = wsToVs.inverse();
      } else {
        wsToVs = mtx_mapping->worldToVoxel(time);
        vsToWs = wsToVs.inverse();
      }
      const Imath::Box3d wsBounds_d = Imath::transform(vsBounds,
                                                       vsToWs);
      wsBounds = Imath::Box3f(wsBounds_d.min, wsBounds_d.max);
      doWsBoundsOptimization = true;
    }
  }

  void setValueRemapOp(ValueRemapOp::Ptr op)
  {
    valueRemapOpPtr = op;
    valueRemapOp    = valueRemapOpPtr.get();
  }

  boost::shared_ptr<LinearInterp>  interpPtr;
  LinearInterp                    *interp;
  const Field_T                   *field;
  typename Field_T::Ptr            fieldPtr;
  const Field3D::FieldMapping     *mapping;
  Box3d                            vsBounds;
  //! Optionally, enable doOsToWs to apply a world to object transform before
  //! lookups.
  M44d                             osToWs, wsToOs;
  double                           worldScale;
  bool                             doOsToWs;
  //! Optionally, enable wsBounds optimization to use a world axis
  //! aligned bounding box in lookups.
  M44d                             wsToVs;
  Imath::Box3f                     wsBounds;
  bool                             doWsBoundsOptimization;
  //! Optionally, set a ValueRemapOp to remap values
  ValueRemapOp::Ptr                valueRemapOpPtr;
  const ValueRemapOp              *valueRemapOp;
};

//----------------------------------------------------------------------------//

FIELD3D_NAMESPACE_HEADER_CLOSE

//------------------------------------------------------------------------------

#endif // include guard

//------------------------------------------------------------------------------