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 
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 
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);
282  void updateAuxMembers() const;
284  void syncLevelInfo(const size_t level) const;
286  void loadLevelFromDisk(size_t level) const;
288  template <typename T>
289  void sanityChecks(const T &fields);
290 
291 };
292 
293 //----------------------------------------------------------------------------//
294 // Helper classes
295 //----------------------------------------------------------------------------//
296 
297 template <typename Data_T>
298 class MIPSparseField : public MIPField<SparseField<Data_T> >
299 {
300 public:
301  virtual FieldBase::Ptr clone() const
302  {
303  return FieldBase::Ptr(new MIPSparseField(*this));
304  }
305 };
306 
307 //----------------------------------------------------------------------------//
308 
309 template <typename Data_T>
310 class MIPDenseField : public MIPField<DenseField<Data_T> >
311 {
312  public:
313  virtual FieldBase::Ptr clone() const
314  {
315  return FieldBase::Ptr(new MIPDenseField(*this));
316  }
317 };
318 
319 //----------------------------------------------------------------------------//
320 // MIPField implementations
321 //----------------------------------------------------------------------------//
322 
323 template <class Field_T>
325  : base(),
326  m_ioMutex(new boost::mutex)
327 {
328  m_fields.resize(base::m_numLevels);
329 }
330 
331 //----------------------------------------------------------------------------//
332 
333 template <class Field_T>
335  : base(other)
336 {
337  init(other);
338 }
339 
340 //----------------------------------------------------------------------------//
341 
342 template <class Field_T>
343 const MIPField<Field_T>&
345 {
346  base::operator=(rhs);
347  return init(rhs);
348 }
349 
350 //----------------------------------------------------------------------------//
351 
352 template <class Field_T>
353 const MIPField<Field_T>&
355 {
356  // If any of the fields aren't yet loaded, we can rely on the same load
357  // actions as the other one
358  m_loadActions = rhs.m_loadActions;
359  // Copy all the regular data members
360  m_mipRes = rhs.m_mipRes;
361  m_relativeResolution = rhs.m_relativeResolution;
362  // The contained fields must be individually cloned if they have already
363  // been loaded
364  m_fields.resize(rhs.m_fields.size());
365  m_rawFields.resize(rhs.m_rawFields.size());
366  for (size_t i = 0, end = m_fields.size(); i < end; ++i) {
367  // Update the field pointer
368  if (rhs.m_fields[i]) {
369  FieldBase::Ptr baseClone = rhs.m_fields[i]->clone();
370  FieldPtr clone = field_dynamic_cast<Field_T>(baseClone);
371  if (clone) {
372  m_fields[i] = clone;
373  } else {
374  std::cerr << "MIPField::op=(): Failed to clone." << std::endl;
375  }
376  }
377  // Update the raw pointer
378  m_rawFields[i] = m_fields[i].get();
379  }
380  // New mutex
381  m_ioMutex.reset(new boost::mutex);
382  // Done
383  return *this;
384 }
385 
386 //----------------------------------------------------------------------------//
387 
388 template <class Field_T>
390 {
391  m_fields.clear();
392  m_rawFields.clear();
393  base::m_numLevels = 0;
394  base::m_lowestLevel = 0;
395 }
396 
397 //----------------------------------------------------------------------------//
398 
399 template <class Field_T>
401 {
402  // Clear existing data
403  clear();
404  // Run sanity checks. This will throw an exception if the fields are invalid.
405  sanityChecks(fields);
406  // Update state of object
407  m_fields = fields;
408  base::m_numLevels = fields.size();
409  base::m_lowestLevel = 0;
410  updateMapping(fields[0]);
411  updateAuxMembers();
412  // Resize vectors
413  m_mipRes.resize(base::m_numLevels);
414  m_relativeResolution.resize(base::m_numLevels);
415  // For each MIP level
416  for (size_t i = 0; i < fields.size(); i++) {
417  // Update MIP res from real fields
418  m_mipRes[i] = m_fields[i]->extents().size() + V3i(1);
419  // Update relative resolutions
420  m_relativeResolution[i] = V3f(m_mipRes[i]) / m_mipRes[0];
421  }
422 }
423 
424 //----------------------------------------------------------------------------//
425 
426 template <class Field_T>
428 (const ProxyVec &proxies,
429  const typename LazyLoadAction<Field_T>::Vec &actions)
430 {
431  using namespace Exc;
432 
433  // Clear existing data
434  clear();
435  // Check same number of proxies and actions
436  if (proxies.size() != actions.size()) {
437  throw MIPFieldException("Incorrect number of lazy load actions");
438  }
439  // Run sanity checks. This will throw an exception if the fields are invalid.
440  sanityChecks(proxies);
441  // Store the lazy load actions
442  m_loadActions = actions;
443  // Update state of object
444  base::m_numLevels = proxies.size();
445  base::m_lowestLevel = 0;
446  m_fields.resize(base::m_numLevels);
447  updateMapping(proxies[0]);
448  updateAuxMembers();
449  // Resize vectors
450  m_mipRes.resize(base::m_numLevels);
451  m_relativeResolution.resize(base::m_numLevels);
452  for (size_t i = 0; i < proxies.size(); i++) {
453  // Update mip res from proxy fields
454  m_mipRes[i] = proxies[i]->extents().size() + V3i(1);
455  // Update relative resolutions
456  m_relativeResolution[i] = V3f(m_mipRes[i]) / m_mipRes[0];
457  }
458 }
459 
460 //----------------------------------------------------------------------------//
461 
462 #if 0
463 
464 template <class Field_T>
466 MIPField<Field_T>::mipLevel(size_t level) const
467 {
468  assert(level < base::m_numLevels);
469  // Ensure level is loaded.
470  if (!m_rawFields[level]) {
471  loadLevelFromDisk(level);
472  }
473  return m_fields[level];
474 }
475 #endif
476 
477 //----------------------------------------------------------------------------//
478 
479 template <class Field_T>
480 const Field_T*
482 {
483  assert(level < base::m_numLevels);
484  // Ensure level is loaded.
485  if (!m_rawFields[level]) {
486  loadLevelFromDisk(level);
487  }
488  // Return
489  return m_rawFields[level];
490 }
491 
492 //----------------------------------------------------------------------------//
493 
494 template <class Field_T>
495 typename Field_T::Ptr
497 {
498  assert(level < base::m_numLevels);
499  // Ensure level is loaded.
500  if (!m_rawFields[level]) {
501  loadLevelFromDisk(level);
502  }
503  // Return
504  return m_fields[level];
505 }
506 
507 //----------------------------------------------------------------------------//
508 
509 template <class Field_T>
511 MIPField<Field_T>::value(int i, int j, int k) const
512 {
513  return fastMipValue(0, i, j, k);
514 }
515 
516 //----------------------------------------------------------------------------//
517 
518 template <class Field_T>
519 size_t
521 {
522  size_t count = 0;
523  for (size_t i = 0; i < m_fields.size(); i++) {
524  if (m_fields[i]) {
525  count += m_fields[i]->voxelCount();
526  }
527  }
528  return count;
529 }
530 
531 //----------------------------------------------------------------------------//
532 
533 template <class Field_T>
534 long long int MIPField<Field_T>::memSize() const
535 {
536  long long int mem = 0;
537  for (size_t i = 0; i < m_fields.size(); i++) {
538  if (m_fields[i]) {
539  mem += m_fields[i]->memSize();
540  }
541  }
542  return mem + sizeof(*this);
543 }
544 
545 //----------------------------------------------------------------------------//
546 
547 template <class Field_T>
549 {
550  // Update MIP offset
551  const V3i offset =
552  base::metadata().vecIntMetadata(detail::k_mipOffsetStr, V3i(0));
553  base::setMIPOffset(offset);
554 
555  V3i baseRes = base::dataWindow().size() + V3i(1);
556  if (m_fields[0]) {
557  m_fields[0]->setMapping(base::mapping());
558  }
559  for (size_t i = 1; i < m_fields.size(); i++) {
560  if (m_fields[i]) {
561  FieldMapping::Ptr mapping =
562  detail::adjustedMIPFieldMapping(this, baseRes,
563  m_fields[i]->extents(), i);
564  m_fields[i]->setMapping(mapping);
565  }
566  }
567 }
568 
569 //----------------------------------------------------------------------------//
570 
571 template <class Field_T>
573 MIPField<Field_T>::mipValue(size_t level, int i, int j, int k) const
574 {
575  return fastMipValue(level, i, j, k);
576 }
577 
578 //----------------------------------------------------------------------------//
579 
580 template <class Field_T>
582 {
583  assert(level < base::m_numLevels);
584  return m_mipRes[level];
585 }
586 
587 //----------------------------------------------------------------------------//
588 
589 template <class Field_T>
590 bool MIPField<Field_T>::levelLoaded(const size_t level) const
591 {
592  assert(level < base::m_numLevels);
593  return m_rawFields[level] != NULL;
594 }
595 
596 //----------------------------------------------------------------------------//
597 
598 template <typename Field_T>
599 void MIPField<Field_T>::getVsMIPCoord(const V3f &vsP, const size_t level,
600  V3f &outVsP) const
601 {
602  const V3i &mipOff = base::mipOffset();
603 
604  // Compute offset of current level
605  const V3i offset((mipOff.x >> level) << level,
606  (mipOff.y >> level) << level,
607  (mipOff.z >> level) << level);
608 
609  // Difference between current offset and base offset is num voxels
610  // to offset current level by
611  const V3f diff = offset - mipOff;
612 
613  // Incorporate shift due to mip offset
614  outVsP = (vsP - diff) * pow(2.0, -static_cast<float>(level));
615 }
616 
617 //----------------------------------------------------------------------------//
618 
619 template <typename Field_T>
621 MIPField<Field_T>::mipLevel(const size_t level) const
622 {
623  assert(level < base::m_numLevels);
624  // Ensure level is loaded.
625  if (!m_rawFields[level]) {
626  loadLevelFromDisk(level);
627  }
628  // Return
629  return m_fields[level];
630 }
631 
632 //----------------------------------------------------------------------------//
633 
634 template <class Field_T>
636 MIPField<Field_T>::fastMipValue(size_t level, int i, int j, int k) const
637 {
638  assert(level < base::m_numLevels);
639  // Ensure level is loaded.
640  if (!m_rawFields[level]) {
641  loadLevelFromDisk(level);
642  }
643  // Read from given level
644  return m_rawFields[level]->fastValue(i, j, k);
645 }
646 
647 //----------------------------------------------------------------------------//
648 
649 template <class Field_T>
651 {
652  m_rawFields.resize(m_fields.size());
653  for (size_t i = 0; i < m_fields.size(); i++) {
654  m_rawFields[i] = m_fields[i].get();
655  }
656 }
657 
658 //----------------------------------------------------------------------------//
659 
660 template <class Field_T>
661 void MIPField<Field_T>::syncLevelInfo(const size_t level) const
662 {
663  // At this point, m_fields[level] is guaranteed in memory
664 
665  // First sync name, attribute
666  m_fields[level]->name = base::name;
667  m_fields[level]->attribute = base::attribute;
668  // Copy metadata
669  m_fields[level]->copyMetadata(*this);
670 }
671 
672 //----------------------------------------------------------------------------//
673 
674 template <class Field_T>
676 {
677  base::m_extents = field->extents();
678  base::m_dataWindow = field->dataWindow();
679  base::setMapping(field->mapping());
680 }
681 
682 //----------------------------------------------------------------------------//
683 
684 template <class Field_T>
685 void MIPField<Field_T>::loadLevelFromDisk(size_t level) const
686 {
687  // Double-check locking
688  if (!m_rawFields[level]) {
689  boost::mutex::scoped_lock lock(*m_ioMutex);
690  if (!m_rawFields[level]) {
691  // Execute the lazy load action
692  m_fields[level] = m_loadActions[level]->load();
693  // Check that field was loaded
694  if (!m_fields[level]) {
695  throw Exc::MIPFieldException("Couldn't load MIP level: " +
696  boost::lexical_cast<std::string>(level));
697  }
698  // Remove lazy load action
699  m_loadActions[level].reset();
700  // Update aux data
701  updateAuxMembers();
702  // Ensure metadata is up to date
703  syncLevelInfo(level);
704  // Update the mapping of the loaded field
705  V3i baseRes = base::dataWindow().size() + V3i(1);
706  FieldMapping::Ptr mapping =
707  detail::adjustedMIPFieldMapping(this, baseRes,
708  m_fields[level]->extents(), level);
709  m_fields[level]->setMapping(mapping);
710  }
711  }
712 }
713 
714 //----------------------------------------------------------------------------//
715 
716 template <class Field_T>
717 template <class T>
718 void
720 {
721  using boost::lexical_cast;
722  using std::string;
723  using Exc::MIPFieldException;
724 
725  // Check zero length
726  if (fields.size() == 0) {
727  throw MIPFieldException("Zero fields in input");
728  }
729  // Check all non-null
730  for (size_t i = 0; i < fields.size(); i++) {
731  if (!fields[i]) {
732  throw MIPFieldException("Found null pointer in input");
733  }
734  }
735  // Check decreasing resolution at higher levels
736  V3i prevSize = fields[0]->extents().size();
737  for (size_t i = 1; i < fields.size(); i++) {
738  V3i size = fields[i]->extents().size();
739  if (size.x > prevSize.x ||
740  size.y > prevSize.y ||
741  size.z > prevSize.z) {
742  throw MIPFieldException("Field " + lexical_cast<string>(i) +
743  " had greater resolution than previous"
744  " level");
745  }
746  if (size.x >= prevSize.x &&
747  size.y >= prevSize.y &&
748  size.z >= prevSize.z) {
749  throw MIPFieldException("Field " + lexical_cast<string>(i) +
750  " did not decrease in resolution from "
751  " previous level: " +
752  lexical_cast<string>(size) + " > " +
753  lexical_cast<string>(prevSize));
754  }
755  prevSize = size;
756  }
757  // All good.
758 }
759 
760 //----------------------------------------------------------------------------//
761 // Static data member instantiation
762 //----------------------------------------------------------------------------//
763 
764 template <typename Field_T>
767 
768 //----------------------------------------------------------------------------//
769 
771 
772 //----------------------------------------------------------------------------//
773 
774 #endif // Include guard
FIELD3D_NAMESPACE_HEADER_CLOSE
#define FIELD3D_NAMESPACE_HEADER_CLOSE
Definition: ns.h:58
FieldBase
Definition: Field.h:92
V3i
Imath::V3i V3i
Definition: SpiMathLib.h:71
DEFINE_FIELD_RTTI_CONCRETE_CLASS
#define DEFINE_FIELD_RTTI_CONCRETE_CLASS
Definition: RefCount.h:84
MIPField::NestedType
Field_T NestedType
Definition: MIPField.h:116
MIPField::Ptr
boost::intrusive_ptr< MIPField > Ptr
Definition: MIPField.h:118
MIPField::MIPField
MIPField(const MIPField &other)
Copy constructor. We need this because a) we own a mutex and b) we own shared pointers and shallow co...
Definition: MIPField.h:334
MIPField::Vec
std::vector< Ptr > Vec
Definition: MIPField.h:119
Field::Ptr
boost::intrusive_ptr< Field > Ptr
Definition: Field.h:395
MIPField::operator=
const MIPField & operator=(const MIPField &rhs)
Assignment operator.
Definition: MIPField.h:344
MIPField::ProxyPtr
ProxyField::Ptr ProxyPtr
Definition: MIPField.h:127
LazyLoadAction::Vec
std::vector< Ptr > Vec
Definition: MIPBase.h:78
MIPField::CubicInterp
CubicMIPFieldInterp< Data_T > CubicInterp
Definition: MIPField.h:122
MIPField::setupLazyLoad
void setupLazyLoad(const ProxyVec &proxies, const typename LazyLoadAction< Field_T >::Vec &actions)
Sets up the MIP field in lazy-load mode.
Definition: MIPField.h:428
MIPField::mappingChanged
virtual void mappingChanged()
We need to know if the mapping changed so that we may update the MIP levels' mappings.
Definition: MIPField.h:548
MIPField::ProxyField
EmptyField< Data_T > ProxyField
Definition: MIPField.h:126
MIPField::staticClassName
static DEFINE_FIELD_RTTI_CONCRETE_CLASS const char * staticClassName()
Definition: MIPField.h:176
MIPField::m_loadActions
LazyLoadAction< Field_T >::Vec m_loadActions
Lazy load actions. Only used if setupLazyLoad() has been called.
Definition: MIPField.h:258
MIPDenseField::clone
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:313
MIPField::m_rawFields
std::vector< Field_T * > m_rawFields
Raw pointers to MIP levels.
Definition: MIPField.h:262
FieldMapping::Ptr
boost::intrusive_ptr< FieldMapping > Ptr
Definition: FieldMapping.h:92
EmptyField::Ptr
boost::intrusive_ptr< EmptyField > Ptr
Definition: EmptyField.h:93
MIPField::fastMipValue
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:636
V3f
Imath::V3f V3f
Definition: SpiMathLib.h:73
MIPSparseField::clone
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:301
FieldBase::name
std::string name
Optional name of the field.
Definition: Field.h:171
MIPField::value_type
Data_T value_type
Definition: MIPField.h:124
MIPField::clear
void clear()
Clears all the levels of the MIP field.
Definition: MIPField.h:389
MIPField::mipValue
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:573
FieldBase::Ptr
boost::intrusive_ptr< FieldBase > Ptr
Definition: Field.h:97
MIPField::Data_T
Field_T::value_type Data_T
Definition: MIPField.h:115
MIPLinearInterp
Definition: MIPInterp.h:62
MIPField::rawMipLevel
const Field_T * rawMipLevel(const size_t level) const
Returns a raw pointer to a MIP level.
Definition: MIPField.h:481
ns.h
MIPBase.h
Contains MIPBase class.
MIPField::voxelCount
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:520
FieldRes::Ptr
boost::intrusive_ptr< FieldRes > Ptr
Definition: Field.h:213
MIPField::clone
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
MIPField::MIPField
MIPField()
Constructs an empty MIP field.
Definition: MIPField.h:324
detail::k_mipOffsetStr
FIELD3D_API const std::string k_mipOffsetStr
Definition: MIPUtil.cpp:66
MIPField::setup
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:400
MIPField::m_ioMutex
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
MIPField::FieldPtr
Field_T::Ptr FieldPtr
Definition: MIPField.h:130
MIPField::m_mipRes
std::vector< V3i > m_mipRes
Resolution of each MIP level.
Definition: MIPField.h:264
MIPField::memSize
virtual long long int memSize() const
Returns the memory usage (in bytes)
Definition: MIPField.h:534
MIPField::init
const MIPField & init(const MIPField &rhs)
Copies from a second MIPField.
Definition: MIPField.h:354
MIPField::value
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:511
MIPBase::m_numLevels
size_t m_numLevels
Number of MIP levels. The default is 1.
Definition: MIPBase.h:196
MIPField::updateMapping
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:675
MIPField::FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION
FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION
Definition: MIPField.h:205
MIPField::mipLevel
virtual Field< Data_T >::Ptr mipLevel(const size_t level) const
Returns a MIP level field.
Definition: MIPField.h:621
EmptyField
This subclass of Field does not store any data.
Definition: EmptyField.h:88
MIPField::sanityChecks
void sanityChecks(const T &fields)
Sanity checks to ensure that the provided Fields are a MIP representation.
Definition: MIPField.h:719
CubicMIPFieldInterp
Definition: MIPField.h:80
DenseField.h
Contains the DenseField class.
Exc
Namespace for Exception objects.
Definition: Exception.h:57
MIPField::updateAuxMembers
void updateAuxMembers() const
Updates the dependent data members based on m_field.
Definition: MIPField.h:650
MIPInterp.h
Contains MIPInterp class.
MIPField::loadLevelFromDisk
void loadLevelFromDisk(size_t level) const
Loads the given level from disk.
Definition: MIPField.h:685
MIPField::getVsMIPCoord
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:599
MIPField::base
MIPBase< Data_T > base
Definition: MIPField.h:242
MIPBase
Definition: MIPBase.h:117
MIPField
This subclass stores a MIP representation of a Field_T field.
Definition: MIPField.h:110
MIPSparseField
Definition: MIPField.h:299
NestedFieldType
Used to return a string for the name of a nested templated field.
Definition: Traits.h:307
EmptyField.h
Contains the EmptyField class.
MIPField::staticClassType
static const char * staticClassType()
Definition: MIPField.h:181
FIELD3D_NAMESPACE_OPEN
Definition: FieldMapping.cpp:74
MIPField::m_relativeResolution
std::vector< V3f > m_relativeResolution
Relative resolution of each MIP level. Pre-computed to avoid int-to-float conversions.
Definition: MIPField.h:267
detail::adjustedMIPFieldMapping
FIELD3D_API FieldMapping::Ptr adjustedMIPFieldMapping(const FieldRes *base, const V3i &baseRes, const Box3i &extents, const size_t level)
Definition: MIPUtil.cpp:82
MIPField::concreteMipLevel
Field_T::Ptr concreteMipLevel(const size_t level) const
Returns a concretely typed pointer to a MIP level.
Definition: MIPField.h:496
MIPField::FieldVec
std::vector< FieldPtr > FieldVec
Definition: MIPField.h:131
MIPField::syncLevelInfo
void syncLevelInfo(const size_t level) const
Updates the name, attribute and metadata for a given level.
Definition: MIPField.h:661
SparseField.h
Contains the SparseField class.
Field
Definition: Field.h:390
MIPField::ProxyVec
std::vector< ProxyPtr > ProxyVec
Definition: MIPField.h:128
MIPDenseField
Definition: MIPField.h:311
MIPUtil.h
Contains MIP-related utility functions.
MIPField::mipResolution
virtual V3i mipResolution(size_t level) const
Returns the resolution of a given MIP level.
Definition: MIPField.h:581
MIPField::levelLoaded
virtual bool levelLoaded(const size_t level) const
Whether a given MIP level is loaded.
Definition: MIPField.h:590
MIPField::m_fields
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
DECLARE_FIELD3D_GENERIC_EXCEPTION
#define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class)
Used to declare a generic but named exception.
Definition: Exception.h:107
MIPField::class_type
MIPField< Field_T > class_type
Definition: MIPField.h:173
MIPField::LinearInterp
MIPLinearInterp< MIPField< Field_T > > LinearInterp
Definition: MIPField.h:121
MIPField::ms_classType
static NestedFieldType< MIPField< Field_T > > ms_classType
Definition: MIPField.h:246