Field3D
MIPField.h
Go to the documentation of this file.
1 //----------------------------------------------------------------------------//
2 
3 /*
4  * Copyright (c) 2009 Sony Pictures Imageworks Inc
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution. Neither the name of Sony Pictures Imageworks nor the
18  * names of its contributors may be used to endorse or promote
19  * products derived from this software without specific prior written
20  * permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
33  * OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 //----------------------------------------------------------------------------//
37 
42 //----------------------------------------------------------------------------//
43 
44 #ifndef _INCLUDED_MIPField_H_
45 #define _INCLUDED_MIPField_H_
46 
47 #include <vector>
48 
49 #include <boost/lexical_cast.hpp>
50 #include <boost/thread/mutex.hpp>
51 
52 #include "EmptyField.h"
53 #include "MIPBase.h"
54 #include "MIPInterp.h"
55 #include "MIPUtil.h"
56 #include "DenseField.h"
57 #include "SparseField.h"
58 
59 //----------------------------------------------------------------------------//
60 
61 #include "ns.h"
62 
64 
65 //----------------------------------------------------------------------------//
66 // Exceptions
67 //----------------------------------------------------------------------------//
68 
69 namespace Exc {
70 
71 DECLARE_FIELD3D_GENERIC_EXCEPTION(MIPFieldException, Exception)
72 
73 } // namespace Exc
74 
75 //----------------------------------------------------------------------------//
76 // Forward declarations
77 //----------------------------------------------------------------------------//
78 
79 template <class T>
81 
82 //----------------------------------------------------------------------------//
83 // MIPField
84 //----------------------------------------------------------------------------//
85 
106 //----------------------------------------------------------------------------//
107 
108 template <class Field_T>
109 class MIPField : public MIPBase<typename Field_T::value_type>
110 {
111 public:
112 
113  // Typedefs ------------------------------------------------------------------
114 
115  typedef typename Field_T::value_type Data_T;
116  typedef Field_T NestedType;
117 
118  typedef boost::intrusive_ptr<MIPField> Ptr;
119  typedef std::vector<Ptr> Vec;
120 
123 
124  typedef Data_T value_type;
125 
127  typedef typename ProxyField::Ptr ProxyPtr;
128  typedef std::vector<ProxyPtr> ProxyVec;
129 
130  typedef typename Field_T::Ptr FieldPtr;
131  typedef std::vector<FieldPtr> FieldVec;
132 
133  // Constructors --------------------------------------------------------------
134 
137 
139  MIPField();
140 
143  MIPField(const MIPField &other);
144 
146  const MIPField& operator = (const MIPField &rhs);
147 
148  // \}
149 
150  // From FieldRes base class --------------------------------------------------
151 
156  virtual long long int memSize() const;
159  virtual void mappingChanged();
161 
162  // From Field base class -----------------------------------------------------
163 
167  virtual Data_T value(int i, int j, int k) const;
168  virtual size_t voxelCount() const;
170 
171  // RTTI replacement ----------------------------------------------------------
172 
175 
176  static const char *staticClassName()
177  {
178  return "MIPField";
179  }
180 
181  static const char *staticClassType()
182  {
184  }
185 
186  // From MIPField -------------------------------------------------------------
187 
188  virtual Data_T mipValue(size_t level, int i, int j, int k) const;
189  virtual V3i mipResolution(size_t level) const;
190  virtual bool levelLoaded(const size_t level) const;
191  virtual void getVsMIPCoord(const V3f &vsP, const size_t level,
192  V3f &outVsP) const;
193  virtual typename Field<Data_T>::Ptr mipLevel(const size_t level) const;
194 
195  // Concrete voxel access -----------------------------------------------------
196 
198  Data_T fastMipValue(size_t level, int i, int j, int k) const;
199 
200  // From FieldBase ------------------------------------------------------------
201 
204 
206 
207  virtual FieldBase::Ptr clone() const
208  {
209  return Ptr(new MIPField(*this));
210  }
211 
213 
214  // Main methods --------------------------------------------------------------
215 
217  void clear();
223  void setup(const FieldVec &fields);
226  void setupLazyLoad(const ProxyVec &proxies,
227  const typename LazyLoadAction<Field_T>::Vec &actions);
228 
229 #if 0
230  FieldPtr mipLevel(const size_t level) const;
232 #endif
233  const Field_T* rawMipLevel(const size_t level) const;
236  typename Field_T::Ptr concreteMipLevel(const size_t level) const;
237 
238 protected:
239 
240  // Typedefs ------------------------------------------------------------------
241 
243 
244  // Static data members -------------------------------------------------------
245 
247 
248  // Preventing instantiation of this helper class -----------------------------
249 
250 
251 
252  // Data members --------------------------------------------------------------
253 
256  mutable std::vector<FieldPtr> m_fields;
262  mutable std::vector<Field_T*> m_rawFields;
264  mutable std::vector<V3i> m_mipRes;
267  mutable std::vector<V3f> m_relativeResolution;
271  boost::shared_ptr<boost::mutex> m_ioMutex;
272 
273  // Utility methods -----------------------------------------------------------
274 
276  const MIPField& init(const MIPField &rhs);
280  void updateMapping(FieldRes::Ptr field);
282  void updateAuxMembers() const;
284  void loadLevelFromDisk(size_t level) const;
286  template <typename T>
287  void sanityChecks(const T &fields);
288 
289 };
290 
291 //----------------------------------------------------------------------------//
292 // Helper classes
293 //----------------------------------------------------------------------------//
294 
295 template <typename Data_T>
296 class MIPSparseField : public MIPField<SparseField<Data_T> >
297 {
298 
299 };
300 
301 //----------------------------------------------------------------------------//
302 
303 template <typename Data_T>
304 class MIPDenseField : public MIPField<DenseField<Data_T> >
305 {
306 
307 };
308 
309 //----------------------------------------------------------------------------//
310 // MIPField implementations
311 //----------------------------------------------------------------------------//
312 
313 template <class Field_T>
315  : base(),
316  m_ioMutex(new boost::mutex)
317 {
318  m_fields.resize(base::m_numLevels);
319 }
320 
321 //----------------------------------------------------------------------------//
322 
323 template <class Field_T>
325  : base(other)
326 {
327  init(other);
328 }
329 
330 //----------------------------------------------------------------------------//
331 
332 template <class Field_T>
333 const MIPField<Field_T>&
335 {
336  base::operator=(rhs);
337  return init(rhs);
338 }
339 
340 //----------------------------------------------------------------------------//
341 
342 template <class Field_T>
343 const MIPField<Field_T>&
345 {
346  // If any of the fields aren't yet loaded, we can rely on the same load
347  // actions as the other one
349  // Copy all the regular data members
350  m_mipRes = rhs.m_mipRes;
352  // The contained fields must be individually cloned if they have already
353  // been loaded
354  m_fields.resize(rhs.m_fields.size());
355  m_rawFields.resize(rhs.m_rawFields.size());
356  for (size_t i = 0, end = m_fields.size(); i < end; ++i) {
357  // Update the field pointer
358  if (rhs.m_fields[i]) {
359  FieldBase::Ptr baseClone = rhs.m_fields[i]->clone();
360  FieldPtr clone = field_dynamic_cast<Field_T>(baseClone);
361  if (clone) {
362  m_fields[i] = clone;
363  } else {
364  std::cerr << "MIPField::op=(): Failed to clone." << std::endl;
365  }
366  }
367  // Update the raw pointer
368  m_rawFields[i] = m_fields[i].get();
369  }
370  // New mutex
371  m_ioMutex.reset(new boost::mutex);
372  // Done
373  return *this;
374 }
375 
376 //----------------------------------------------------------------------------//
377 
378 template <class Field_T>
380 {
381  m_fields.clear();
382  m_rawFields.clear();
383  base::m_numLevels = 0;
385 }
386 
387 //----------------------------------------------------------------------------//
388 
389 template <class Field_T>
391 {
392  // Clear existing data
393  clear();
394  // Run sanity checks. This will throw an exception if the fields are invalid.
395  sanityChecks(fields);
396  // Update state of object
397  m_fields = fields;
398  base::m_numLevels = fields.size();
400  updateMapping(fields[0]);
402  // Resize vectors
403  m_mipRes.resize(base::m_numLevels);
405  // For each MIP level
406  for (size_t i = 0; i < fields.size(); i++) {
407  // Update MIP res from real fields
408  m_mipRes[i] = m_fields[i]->extents().size() + V3i(1);
409  // Update relative resolutions
411  }
412 }
413 
414 //----------------------------------------------------------------------------//
415 
416 template <class Field_T>
418 (const ProxyVec &proxies,
419  const typename LazyLoadAction<Field_T>::Vec &actions)
420 {
421  using namespace Exc;
422 
423  // Clear existing data
424  clear();
425  // Check same number of proxies and actions
426  if (proxies.size() != actions.size()) {
427  throw MIPFieldException("Incorrect number of lazy load actions");
428  }
429  // Run sanity checks. This will throw an exception if the fields are invalid.
430  sanityChecks(proxies);
431  // Store the lazy load actions
432  m_loadActions = actions;
433  // Update state of object
434  base::m_numLevels = proxies.size();
436  m_fields.resize(base::m_numLevels);
437  updateMapping(proxies[0]);
439  // Resize vectors
440  m_mipRes.resize(base::m_numLevels);
442  for (size_t i = 0; i < proxies.size(); i++) {
443  // Update mip res from proxy fields
444  m_mipRes[i] = proxies[i]->extents().size() + V3i(1);
445  // Update relative resolutions
447  }
448 }
449 
450 //----------------------------------------------------------------------------//
451 
452 #if 0
453 
454 template <class Field_T>
456 MIPField<Field_T>::mipLevel(size_t level) const
457 {
458  assert(level < base::m_numLevels);
459  // Ensure level is loaded.
460  if (!m_rawFields[level]) {
461  loadLevelFromDisk(level);
462  }
463  return m_fields[level];
464 }
465 #endif
466 
467 //----------------------------------------------------------------------------//
468 
469 template <class Field_T>
470 const Field_T*
472 {
473  assert(level < base::m_numLevels);
474  // Ensure level is loaded.
475  if (!m_rawFields[level]) {
476  loadLevelFromDisk(level);
477  }
478  return m_rawFields[level];
479 }
480 
481 //----------------------------------------------------------------------------//
482 
483 template <class Field_T>
484 typename Field_T::Ptr
486 {
487  assert(level < base::m_numLevels);
488  // Ensure level is loaded.
489  if (!m_rawFields[level]) {
490  loadLevelFromDisk(level);
491  }
492  return m_fields[level];
493 }
494 
495 //----------------------------------------------------------------------------//
496 
497 template <class Field_T>
499 MIPField<Field_T>::value(int i, int j, int k) const
500 {
501  return fastMipValue(0, i, j, k);
502 }
503 
504 //----------------------------------------------------------------------------//
505 
506 template <class Field_T>
507 size_t
509 {
510  size_t count = 0;
511  for (size_t i = 0; i < m_fields.size(); i++) {
512  if (m_fields[i]) {
513  count += m_fields[i]->voxelCount();
514  }
515  }
516  return count;
517 }
518 
519 //----------------------------------------------------------------------------//
520 
521 template <class Field_T>
522 long long int MIPField<Field_T>::memSize() const
523 {
524  long long int mem = 0;
525  for (size_t i = 0; i < m_fields.size(); i++) {
526  if (m_fields[i]) {
527  mem += m_fields[i]->memSize();
528  }
529  }
530  return mem + sizeof(*this);
531 }
532 
533 //----------------------------------------------------------------------------//
534 
535 template <class Field_T>
537 {
538  V3i baseRes = base::dataWindow().size() + V3i(1);
539  if (m_fields[0]) {
540  m_fields[0]->setMapping(base::mapping());
541  }
542  for (size_t i = 1; i < m_fields.size(); i++) {
543  if (m_fields[i]) {
546  m_fields[i]->extents(), i);
547  m_fields[i]->setMapping(mapping);
548  }
549  }
550 }
551 
552 //----------------------------------------------------------------------------//
553 
554 template <class Field_T>
556 MIPField<Field_T>::mipValue(size_t level, int i, int j, int k) const
557 {
558  return fastMipValue(level, i, j, k);
559 }
560 
561 //----------------------------------------------------------------------------//
562 
563 template <class Field_T>
565 {
566  assert(level < base::m_numLevels);
567  return m_mipRes[level];
568 }
569 
570 //----------------------------------------------------------------------------//
571 
572 template <class Field_T>
573 bool MIPField<Field_T>::levelLoaded(const size_t level) const
574 {
575  assert(level < base::m_numLevels);
576  return m_rawFields[level] != NULL;
577 }
578 
579 //----------------------------------------------------------------------------//
580 
581 template <typename Field_T>
582 void MIPField<Field_T>::getVsMIPCoord(const V3f &vsP, const size_t level,
583  V3f &outVsP) const
584 {
585  outVsP = vsP * m_relativeResolution[level];
586 }
587 
588 //----------------------------------------------------------------------------//
589 
590 template <typename Field_T>
592 MIPField<Field_T>::mipLevel(const size_t level) const
593 {
594  assert(level < base::m_numLevels);
595  // Ensure level is loaded.
596  if (!m_rawFields[level]) {
597  loadLevelFromDisk(level);
598  }
599  return m_fields[level];
600 }
601 
602 //----------------------------------------------------------------------------//
603 
604 template <class Field_T>
606 MIPField<Field_T>::fastMipValue(size_t level, int i, int j, int k) const
607 {
608  assert(level < base::m_numLevels);
609  // Ensure level is loaded.
610  if (!m_rawFields[level]) {
611  loadLevelFromDisk(level);
612  }
613  // Read from given level
614  return m_rawFields[level]->fastValue(i, j, k);
615 }
616 
617 //----------------------------------------------------------------------------//
618 
619 template <class Field_T>
621 {
622  m_rawFields.resize(m_fields.size());
623  for (size_t i = 0; i < m_fields.size(); i++) {
624  m_rawFields[i] = m_fields[i].get();
625  }
626 }
627 
628 //----------------------------------------------------------------------------//
629 
630 template <class Field_T>
632 {
633  base::m_extents = field->extents();
634  base::m_dataWindow = field->dataWindow();
635  base::setMapping(field->mapping());
636 }
637 
638 //----------------------------------------------------------------------------//
639 
640 template <class Field_T>
641 void MIPField<Field_T>::loadLevelFromDisk(size_t level) const
642 {
643  // Double-check locking
644  if (!m_rawFields[level]) {
645  boost::mutex::scoped_lock lock(*m_ioMutex);
646  if (!m_rawFields[level]) {
647  // Execute the lazy load action
648  m_fields[level] = m_loadActions[level]->load();
649  // Remove lazy load action
650  m_loadActions[level].reset();
651  // Update aux data
653  // Update the mapping of the loaded field
654  V3i baseRes = base::dataWindow().size() + V3i(1);
657  m_fields[level]->extents(), level);
658  m_fields[level]->setMapping(mapping);
659  }
660  }
661 }
662 
663 //----------------------------------------------------------------------------//
664 
665 template <class Field_T>
666 template <class T>
667 void
669 {
670  using boost::lexical_cast;
671  using std::string;
672  using Exc::MIPFieldException;
673 
674  // Check zero length
675  if (fields.size() == 0) {
676  throw MIPFieldException("Zero fields in input");
677  }
678  // Check all non-null
679  for (size_t i = 0; i < fields.size(); i++) {
680  if (!fields[i]) {
681  throw MIPFieldException("Found null pointer in input");
682  }
683  }
684  // Check decreasing resolution at higher levels
685  V3i prevSize = fields[0]->extents().size();
686  for (size_t i = 1; i < fields.size(); i++) {
687  V3i size = fields[i]->extents().size();
688  if (size.x > prevSize.x ||
689  size.y > prevSize.y ||
690  size.z > prevSize.z) {
691  throw MIPFieldException("Field " +
692  lexical_cast<string>(i) +
693  " had greater resolution than previous"
694  " level");
695  }
696  if (size.x >= prevSize.x &&
697  size.y >= prevSize.y &&
698  size.z >= prevSize.z) {
699  throw MIPFieldException("Field " +
700  lexical_cast<string>(i) +
701  " did not decrease in resolution from "
702  " previous level");
703  }
704  prevSize = size;
705  }
706  // All good.
707 }
708 
709 //----------------------------------------------------------------------------//
710 // Static data member instantiation
711 //----------------------------------------------------------------------------//
712 
713 template <typename Field_T>
716 
717 //----------------------------------------------------------------------------//
718 
720 
721 //----------------------------------------------------------------------------//
722 
723 #endif // Include guard
Field_T NestedType
Definition: MIPField.h:116
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
const Field_T * rawMipLevel(const size_t level) const
Returns a raw pointer to a MIP level.
Definition: MIPField.h:471
Field_T::Ptr field_dynamic_cast(RefBase::Ptr field)
Dynamic cast that uses string-comparison in order to be safe even after an object crosses a shared li...
Definition: RefCount.h:256
std::vector< Ptr > Vec
Definition: MIPField.h:119
virtual void getVsMIPCoord(const V3f &vsP, const size_t level, V3f &outVsP) const
Given a voxel space coordinate in the 0-level field, computes the coordinate in another level...
Definition: MIPField.h:582
const Box3i & extents() const
Returns the extents of the data. This signifies the relevant area that the data exists over...
Definition: Field.h:254
virtual Data_T mipValue(size_t level, int i, int j, int k) const
Read access to a voxel in a given MIP level.
Definition: MIPField.h:556
static NestedFieldType< MIPField< Field_T > > ms_classType
Definition: MIPField.h:246
Contains the DenseField class.
Namespace for Exception objects.
Definition: Exception.h:57
EmptyField< Data_T > ProxyField
Definition: MIPField.h:126
virtual void mappingChanged()
We need to know if the mapping changed so that we may update the MIP levels&#39; mappings.
Definition: MIPField.h:536
RefBase & operator=(const RefBase &)
Assignment operator.
Definition: RefCount.h:134
Definition: Field.h:394
boost::intrusive_ptr< FieldBase > Ptr
Definition: Field.h:97
virtual size_t voxelCount() const
Counts the number of voxels. For most fields, this is just the volume of the data window...
Definition: MIPField.h:508
LazyLoadAction< Field_T >::Vec m_loadActions
Lazy load actions. Only used if setupLazyLoad() has been called.
Definition: MIPField.h:258
void setupLazyLoad(const ProxyVec &proxies, const typename LazyLoadAction< Field_T >::Vec &actions)
Sets up the MIP field in lazy-load mode.
Definition: MIPField.h:418
Data_T value_type
Definition: MIPField.h:124
Contains the EmptyField class.
FIELD3D_API FieldMapping::Ptr adjustedMIPFieldMapping(const FieldMapping::Ptr baseMapping, const V3i &baseRes, const Box3i &extents, const size_t level)
Definition: MIPUtil.cpp:77
boost::intrusive_ptr< FieldRes > Ptr
Definition: Field.h:218
CubicMIPFieldInterp< Data_T > CubicInterp
Definition: MIPField.h:122
void setup(const FieldVec &fields)
Sets up the MIP field given a set of non-MIP fields This call performs sanity checking to ensure that...
Definition: MIPField.h:390
This subclass stores a MIP representation of a Field_T field.
Definition: MIPField.h:109
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:315
boost::intrusive_ptr< MIPField > Ptr
Definition: MIPField.h:118
std::vector< Field_T * > m_rawFields
Raw pointers to MIP levels.
Definition: MIPField.h:262
void clear()
Clears all the levels of the MIP field.
Definition: MIPField.h:379
const MIPField & operator=(const MIPField &rhs)
Assignment operator.
Definition: MIPField.h:334
Contains MIPInterp class.
MIPField()
Constructs an empty MIP field.
Definition: MIPField.h:314
Field_T::value_type Data_T
Definition: MIPField.h:115
Imath::V3i V3i
Definition: SpiMathLib.h:71
boost::intrusive_ptr< FieldMapping > Ptr
Definition: FieldMapping.h:92
static DEFINE_FIELD_RTTI_CONCRETE_CLASS const char * staticClassName()
Definition: MIPField.h:176
void setMapping(FieldMapping::Ptr mapping)
Sets the field&#39;s mapping.
Definition: Field.h:352
This subclass of Field does not store any data.
Definition: EmptyField.h:86
size_t m_lowestLevel
The lowest MIP level to use. Defaults to 0, but can be set higher to prevent high resolution levels f...
Definition: MIPBase.h:192
Field_T::Ptr FieldPtr
Definition: MIPField.h:130
void updateAuxMembers() const
Updates the dependent data members based on m_field.
Definition: MIPField.h:620
const MIPField & init(const MIPField &rhs)
Copies from a second MIPField.
Definition: MIPField.h:344
virtual Data_T value(int i, int j, int k) const
Read access to a voxel. The coordinates are in integer voxel space .
Definition: MIPField.h:499
std::vector< V3i > m_mipRes
Resolution of each MIP level.
Definition: MIPField.h:264
boost::intrusive_ptr< EmptyField > Ptr
Definition: EmptyField.h:93
Imath::V3f V3f
Definition: SpiMathLib.h:73
FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION
Definition: MIPField.h:205
boost::shared_ptr< boost::mutex > m_ioMutex
Mutex lock around IO. Used to make sure only one thread reads MIP level data at a time...
Definition: MIPField.h:271
void sanityChecks(const T &fields)
Sanity checks to ensure that the provided Fields are a MIP representation.
Definition: MIPField.h:668
Box3i m_extents
Defines the extents of the the storage. This may be larger or smaller than the data window...
Definition: Field.h:312
void updateMapping(FieldRes::Ptr field)
Updates the mapping, extents and data window to match the given field. Used so that the MIPField will...
Definition: MIPField.h:631
size_t m_numLevels
Number of MIP levels. The default is 1.
Definition: MIPBase.h:189
#define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class)
Used to declare a generic but named exception.
Definition: Exception.h:107
static const char * staticClassType()
Definition: MIPField.h:181
std::vector< V3f > m_relativeResolution
Relative resolution of each MIP level. Pre-computed to avoid int-to-float conversions.
Definition: MIPField.h:267
void loadLevelFromDisk(size_t level) const
Loads the given level from disk.
Definition: MIPField.h:641
Contains MIPBase class.
MIPBase< Data_T > base
Definition: MIPField.h:242
std::vector< FieldPtr > FieldVec
Definition: MIPField.h:131
virtual V3i mipResolution(size_t level) const
Returns the resolution of a given MIP level.
Definition: MIPField.h:564
Contains MIP-related utility functions.
virtual long long int memSize() const
Returns the memory usage (in bytes)
Definition: MIPField.h:522
std::vector< Ptr > Vec
Definition: MIPBase.h:77
FIELD3D_API V3i mipResolution(const V3i &baseRes, const size_t level)
Definition: MIPUtil.cpp:66
Contains the SparseField class.
std::vector< FieldPtr > m_fields
Storage of all MIP levels. Some or all of the pointers may be NULL. This is mutable because it needs ...
Definition: MIPField.h:256
#define DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition: RefCount.h:84
Data_T fastMipValue(size_t level, int i, int j, int k) const
Read access to voxel at a given MIP level.
Definition: MIPField.h:606
MIPField< Field_T > class_type
Definition: MIPField.h:173
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:258
ProxyField::Ptr ProxyPtr
Definition: MIPField.h:127
Used to return a string for the name of a nested templated field.
Definition: Traits.h:140
Field_T::Ptr concreteMipLevel(const size_t level) const
Returns a concretely typed pointer to a MIP level.
Definition: MIPField.h:485
virtual Field< Data_T >::Ptr mipLevel(const size_t level) const
Returns a MIP level field.
Definition: MIPField.h:592
std::vector< ProxyPtr > ProxyVec
Definition: MIPField.h:128
MIPLinearInterp< MIPField< Field_T > > LinearInterp
Definition: MIPField.h:121
boost::intrusive_ptr< Field > Ptr
Definition: Field.h:400
FieldMapping::Ptr mapping()
Returns a pointer to the mapping.
Definition: Field.h:268
virtual bool levelLoaded(const size_t level) const
Whether a given MIP level is loaded.
Definition: MIPField.h:573
std::string name
Optional name of the field.
Definition: Field.h:176
virtual FieldBase::Ptr clone() const
Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement i...
Definition: MIPField.h:207