MeVisLab Toolbox Reference
mlPagedImage.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_PAGED_IMAGE_H
14 #define ML_PAGED_IMAGE_H
15 
34 
35 //ML-includes
36 #include "mlInitSystemML.h"
38 #include "mlMemoryImage.h"
39 
41 #include "mlModuleInterfaces.h"
42 
43 #include <mlMemoryBlockHandle.h>
45 
46 #include <unordered_map>
47 #include <vector>
48 
49 ML_START_NAMESPACE
50 
52 class PagedImageCurrentlyUsedMemoryTracker;
53 class Module;
54 class SubImage;
55 class PageRequest;
56 class TileRequest;
57 
58 #if ML_DEPRECATED_SINCE(3,5,0)
59 class BaseOp;
60 #endif
62 
63 
64 //------------------------------------------------------------------------------
68 //------------------------------------------------------------------------------
69 class ML_UNIX_ONLY_EXPORT(MLEXPORT) PagedImage: public MedicalImageProperties
70 {
72  struct PageEntry
73  {
75  PageRequest* pendingRequest{};
76  };
77 
78  struct ExtendedPageEntry;
79 
80 public:
83  NO_THREAD_SUPPORT = 0,
84  MULTITHREADED = 1,
85  IO_THREAD = 4,
86  USE_MODULE_THREAD_SUPPORT = -1
87  };
88 
90  friend class Host;
91 
92  // needed for testing protected API:
93  ML_FRIEND_TEST(PagedImageDeprecationTest, NewAPI);
94  ML_FRIEND_TEST(PagedImageDeprecationTest, DeprecatedAPI);
95  ML_FRIEND_TEST(TypedHandlersTest, SetupAndVerifyProperties);
96 
97  //------------------------------------------------------
100  //------------------------------------------------------
101 
109  MLEXPORT PagedImage(Module* module=nullptr, MLint outputIndex=-1);
110 
113  MLEXPORT ~PagedImage() override;
115 
117  inline CalculateOutputImageHandler* getCalculateOutputImageHandler() const { return _calculateOutputImageHandler; }
118 
122 
124  inline bool hasExternalCalculateOutputImageHandler() const { return _isExternalCalculateOutputImageHandler; }
125 
128 
131 
133  inline MLuint32 getID() { return _id; }
134 
136  inline void updateID() { _id = getUniqueId(); }
137 
138  //-------------------------------------------------------------------
141  //-------------------------------------------------------------------
147  inline bool isValid() const { return _isValid; }
148 
151  inline void setValid(bool flag = true) { _isValid=flag; }
152 
155  inline void setInvalid() { _isValid=false; }
156 
160 
163  MLEXPORT bool updateOfImagePropertiesNeeded() const { return _updateOfImagePropertiesNeeded; }
164 
166  [[nodiscard]]
168 
170 
171  //------------------------------------------------------
174  //------------------------------------------------------
175 
177  MLEXPORT virtual void setImageExtent(const ImageVector& extent);
178 
182  inline void setImageExtent(MLint x, MLint y, MLint z = 1, MLint c = 1, MLint t = 1, MLint u = 1) {
183  setImageExtent(ImageVector(x,y,z,c,t,u));
184  }
185 
189  inline void setImageExtent(const SubImageBox &box) { setImageExtent(box.getExtent()); }
190 
195  MLEXPORT virtual void setImageProperties(const PagedImage& imageProperties);
196 
198  MLEXPORT void setPageExtent(const ImageVector& pageExtent);
199 
210  inline void setClampPagesToImageExtent(bool flag = true) { _clampPagesToImageExtent = flag; }
211 
213  inline bool getClampPagesToImageExtent() const { return _clampPagesToImageExtent; }
214 
217  inline void setPageExtent(MLint x, MLint y, MLint z = 1, MLint c = 1, MLint t = 1, MLint u = 1) {
218  setPageExtent(ImageVector(x,y,z,c,t,u));
219  }
220 
222  MLEXPORT void setDataType(MLDataType dataType) override;
223 
226 
229 
231  MLEXPORT void setPage(MLint pageID, const MLMemoryBlockHandle& page);
232 
235  MLEXPORT void removePage(MLint pageID);
236 
240  MLEXPORT void deletePageEntryFromDeletionCallback(ExtendedPageEntry* entry);
241 
246 
253 
254 
255 
256  //------------------------------------------------------
259  //------------------------------------------------------
266  MLEXPORT virtual void setStateInfo(const std::string& info, MLErrorCode errorCode);
267 
274  MLEXPORT virtual void setStateInfoErrorCode(MLErrorCode errorCode);
275 
278  MLEXPORT virtual const std::string& getStateInfoString() const;
279 
284 
285  //---------------------------------------------------------------------------
288  //---------------------------------------------------------------------------
289 
295  inline void setBypassIndex(MLint index) { _bypassIndex = index; }
296 
299  inline MLint getBypassIndex() const { return _bypassIndex; }
301 
302 
303  //------------------------------------------------------
306  //------------------------------------------------------
307 
309  inline Module* getModule() const { return _module; }
310 
312  MLEXPORT const PagedImage* getInputImage(int inputIndex) const;
313 
315  inline MLint getOutputIndex() const { return _outIndex; }
316 
318  inline ImageVector getPageSetExtent() const { return _pageSetExt; }
319 
321  inline ImageVector getPageStride() const { return _pageStride; }
322 
324  inline ImageVector getPageExtent() const { return _pageExt; }
325 
327  inline MLint getPageID(const ImageVector& voxelPosition) const { return (voxelPosition/_pageExt).dot(_pageStride); }
328 
334  inline MemoryImage& getMemoryImage() { return _memoryImg; }
335  inline const MemoryImage& getMemoryImage() const { return _memoryImg; }
337 
342  MLEXPORT void setThreadSupport(ThreadSupport support) { _threadSupport = support; }
343 
348 
352 
359 
362 
365 
369 
372  MLEXPORT void getPageIDs(std::vector <MLint>& pageIDs, const SubImageBox& subImageBox) const;
373 
377  MLEXPORT static void getPageIDs(std::vector<MLint>& pageIDs,
378  const SubImageBox& subImageBox,
379  const ImageVector& imageExtent,
380  const ImageVector& pageExtent);
381 
383  MLEXPORT std::size_t getCachedPagesSizeInBytes() const;
384 
387  MLEXPORT MLint getNumPages() const { return _pageSetSize; }
388 
390 
391 
392  //---------------------------------------------------------------------------
395  //---------------------------------------------------------------------------
396 
405  inline void setInPlaceIndex(MLint inputIndex) { _inPlaceIndex = inputIndex; }
406 
414  inline MLint getInPlaceIndex() const { return _inPlaceIndex; }
416 
417 
418  //------------------------------------------------------
426  //------------------------------------------------------
427 
433  MLEXPORT void setInputSubImageDataType(int inputIndex, MLDataType dataType);
434 
442  MLEXPORT void setInputSubImageIsReadOnly(int inputIndex, bool readOnly);
443 
446  MLEXPORT void setInputSubImagesAreReadOnly(bool readOnly = true);
447 
463  MLEXPORT void setInputSubImageUseMemoryImage(int inputIndex, bool useMemoryImage);
464 
468  MLEXPORT void setInputSubImageScaleShift(int inputIndex, const ScaleShiftData& scaleShift);
469 
473 
476 
478  MLEXPORT bool getInputSubImageIsReadOnly(int inputIndex) const;
479 
481 
482  //------------------------------------------------------
485  //------------------------------------------------------
486 
487  //---------------------------------------------------------------------------------
498  //---------------------------------------------------------------------------------
499  MLEXPORT void copyPages(const std::vector<MLint>& pageIDs,
500  SubImage* subImage,
501  const ScaleShiftData& scaleShiftData=ScaleShiftData()) const;
503 
504 
505  //-------------------------------------------------------------------
508  //-------------------------------------------------------------------
513  [[nodiscard]]
515  MLDataType dataType,
516  void** data,
517  const ScaleShiftData& scaleShiftData=ScaleShiftData(),
518  MLRequestProgressCB* progressCallback = nullptr,
519  void* progressCallbackUserData = nullptr);
520 
525  [[nodiscard]]
526  MLEXPORT MLErrorCode getTile(SubImage& subImage, const ScaleShiftData& scaleShiftData=ScaleShiftData(),
527  MLRequestProgressCB* progressCallback = nullptr,
528  void* progressCallbackUserData = nullptr);
529 
531  MLEXPORT void freeTile(void* data);
532 
538  MLEXPORT MLdouble getInterpolatedValue(const Vector3& pos, MLint c = 0, MLint t = 0, MLint u = 0, MLdouble outsideFillValue = 0);
539 
541 
544 
546  MLEXPORT static void setPageCountLimitToUsePageEntryMap(MLuint32 limit) { _pageCountLimitToUsePageEntryMap = limit; }
547 
549  MLEXPORT static MLuint32 getPageCountLimitToUsePageEntryMap() { return _pageCountLimitToUsePageEntryMap; }
550 
551 protected:
554 
557 
560 
561 private:
563  static MLuint32 getUniqueId();
564 
566  MLEXPORT bool arePropertiesLocked() const { return _propertiesLocked; }
567 
569  MLEXPORT bool setPropertiesLocked(bool locked);
570 
572  inline bool _checkPropertyWriteAccess(const char* methodName) {
573  if (_propertiesLocked) {
574  _showInvalidPropertyWriteAccessError(methodName);
575  }
576  return !_propertiesLocked;
577  }
578 
580  void _showInvalidPropertyWriteAccessError(const char* methodName);
581 
582  PagedImage(const PagedImage&) = delete;
583  PagedImage& operator=(const PagedImage&) = delete;
584 
585 
586  //------------------------------------------------------
589  //------------------------------------------------------
594  void _updateAll();
595 
596 
598  void _allocatePageList();
600 
601 
602  void static deleteMemoryBlockCallback(void* data, size_t size, void* userData);
603 
604  /*
605  * Returns true, of the registration was successfully otherwise false
606  */
607  static bool registerDeletionCallback(const ExtendedPageEntry* entry);
608 
609  /*
610  * This returns true, if the ownership of the entry stays within this class
611  */
612  static bool deregisterDeletionCallback(const ExtendedPageEntry* entry);
613 
614  static ExtendedPageEntry* deletePageEntryFromMapUnsafe(std::unordered_map<MLint, ExtendedPageEntry *> &pageEntryMap,
615  MLint pageId);
616 
617  //------------------------------------------------------
620  //------------------------------------------------------
621 
623  Module* _module;
624 
626  CalculateOutputImageHandler* _calculateOutputImageHandler;
627 
629  CalculateOutputImagePropertiesCB* _calculateOutputImageProperties;
631  void* _calculateOutputImagePropertiesUserData;
632 
634  bool _isExternalCalculateOutputImageHandler;
635 
638  MLint _outIndex;
639 
641  ImageVector _pageExt;
642 
645  ImageVector _pageStride;
646 
648  ImageVector _pageSetExt;
649 
651  MLint _pageSetSize;
652 
654  std::vector<PageEntry> _pageList;
655 
657  std::unordered_map<MLint, ExtendedPageEntry*> _pageEntryMap;
658 
660  mutable Mutex _pageAccessMutex;
661 
663  bool _pageHandlesAreStoredInList;
664 
670  MLint _inPlaceIndex;
671 
673  MLint _bypassIndex;
674 
676  bool _updateOfImagePropertiesNeeded;
677 
679  bool _isValid;
680 
684  bool _propertiesLocked;
685 
688  bool _clampPagesToImageExtent;
689 
692  MemoryImage _memoryImg;
693 
695  std::string _stateInfoString;
696 
698  MLErrorCode _stateInfoErrorCode;
699 
701  MLuint32 _id;
702 
704  std::vector<InputSubImageProperties> _inSubImageProps;
705 
707  ThreadSupport _threadSupport;
708 
711  mutable PagedImageCurrentlyUsedMemoryTracker* _currentlyUsedPageMemoryTracker;
712 
714  mutable MLMetaProfilePtr _metaProfilePtr;
716 
718  static MLuint32 _staticUniqueId;
719 
721  static MLuint32 _pageCountLimitToUsePageEntryMap;
722 
723 private:
725  static const char* const _pageAllocationMemoryProfileKey;
726  static const char* const _pageCacheHitsCountProfileKey;
727  static const char* const _pageCacheMissesCountProfileKey;
728 
729 #if ML_DEPRECATED_SINCE(3,5,0)
730 
733 
734 public:
735  // \deprecated
736  // Use getOutputIndex() instead.
737  inline ML_DEPRECATED MLint getOutIndex() const { return getOutputIndex(); }
738 
739  // \deprecated
740  // Use isValid() instead.
741  inline ML_DEPRECATED bool isUpToDate() const { return isValid(); }
742 
743  // \deprecated
744  // Use setValid() instead.
745  inline ML_DEPRECATED void setUpToDate() { setValid(); }
746 
747  // \deprecated
748  // Use setInvalid() instead.
749  inline ML_DEPRECATED void setOutOfDate() { setInvalid(); }
750 
754  MLEXPORT bool isGlobalDummyImage();
755 
758  inline ML_DEPRECATED void setImgExt(const ImageVector &ext) { setImageExtent(ext); }
761  inline ML_DEPRECATED void setImgExt(const SubImageBox &box) { setImageExtent(box); }
764  inline ML_DEPRECATED void clearPageListAndMemoryImg() { clearPageListAndMemoryImage(); }
767  MLEXPORT ML_DEPRECATED BaseOp* getBaseOp() const;
770  inline ML_DEPRECATED void setImgProps(const PagedImage &imgProps) { setImageProperties(imgProps); }
773  inline ML_DEPRECATED void setPageExt(const ImageVector &pageExt) { setPageExtent(pageExt); }
776  inline ML_DEPRECATED const PagedImage* getInImg(int index) const { return getInputImage(index); }
779  inline ML_DEPRECATED ImageVector getPageSetExt() const { return getPageSetExtent(); }
782  inline ML_DEPRECATED ImageVector getPageExt() const { return getPageExtent(); }
785  inline ML_DEPRECATED MemoryImage& getMemoryImg() { return getMemoryImage(); }
788  inline ML_DEPRECATED const MemoryImage& getMemoryImg() const { return getMemoryImage(); }
791  inline ML_DEPRECATED size_t getPageMemorySize() const { return getCachedPagesSizeInBytes(); }
794  inline ML_DEPRECATED void setInSubImageDataType(int inputIndex, MLDataType datatype) { setInputSubImageDataType(inputIndex,datatype); }
797  inline ML_DEPRECATED void setInSubImageIsReadOnly(int inputIndex, bool readOnly) { setInputSubImageIsReadOnly(inputIndex, readOnly); }
800  inline ML_DEPRECATED void setInSubImageUseMemoryImage(int inputIndex, bool useMemImg) { setInputSubImageUseMemoryImage(inputIndex, useMemImg); }
803  inline ML_DEPRECATED void setInSubImageScaleShift(int inputIndex, const ScaleShiftData& scaleShift) { setInputSubImageScaleShift(inputIndex, scaleShift); }
806  inline ML_DEPRECATED const InputSubImageProperties& getInSubImageProps(int inputIndex) const { return getInputSubImageProperties(inputIndex); }
809  inline ML_DEPRECATED MLDataType getInSubImageDataType(int inputIndex) const { return getInputSubImageDataType(inputIndex); }
812  inline ML_DEPRECATED bool getInSubImageIsReadOnly(int inputIndex) const { return getInputSubImageIsReadOnly(inputIndex); }
814 
815 #endif
816 
817 };
818 
819 #if ML_DEPRECATED_SINCE(3,5,0)
824 ML_DEPRECATED typedef PagedImage PagedImg;
826 #endif
827 
828 
829 ML_END_NAMESPACE
830 
831 // Stream output for std::ostream
832 namespace std {
833 
835  MLEXPORT std::ostream& operator<<(std::ostream& s, const ML_NAMESPACE::PagedImage &pi);
836 
837 }
838 
839 #endif //of __mlPagedImage_H
840 
841 
#define ML_DEPRECATED
Definition: CSOGroup.h:371
The strong handle of a MLMemoryBlock.
The pointer is automatically reset when the meta profile is destroyed.
The weak handle of a MLMemoryBlock.
Base class for the calculation of pages of an output image (PagedImage) of a Module.
The Host is the central image processing class in the ML.
Definition: mlHost.h:115
MLEXPORT void setImageExtent(const ImageVector &extent)
Sets the extent of the (sub)image.
Defines the class InputSubImageProperties which is a simple container for some properties which can b...
This class encapsulates basic medical image properties:
void setImageProperties(const MedicalImageProperties &medicalImageProperties)
Sets a copy of the passed image properties medicalImageProperties.
MedicalImageProperties & operator=(const MedicalImageProperties &medicalImageProperties)
Assignment operator from an existing edicalImageProperties object to get a copy.
A memory cache for the complete output image of an output connector.
Definition: mlMemoryImage.h:49
Base class for an image processing module of the ML.
Definition: mlModule.h:156
A PageRequest represents the request for the calculation of a single page of a PagedImage.
Definition: mlPageRequest.h:32
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
MLint getInPlaceIndex() const
Return optimization flag: Return index of input image whose input tile is used also as output page in...
Definition: mlPagedImage.h:414
MLEXPORT void setInputSubImageDataType(int inputIndex, MLDataType dataType)
Sets the dataType for the given inputIndex.
MLEXPORT PagedImage(Module *module=nullptr, MLint outputIndex=-1)
Constructor.
MLEXPORT void setMaxVoxelValue(MLdouble maxval)
Sets assumed maximum value to maxval. Overriden to perform access check.
MLEXPORT void clearPendingPageRequest(MLint pageID)
Clears a pending page request for the given page id.
virtual MLEXPORT void setStateInfo(const std::string &info, MLErrorCode errorCode)
Sets the state information for this PagedImage to the string info and the MLErrorCode errorCode.
MLEXPORT MLErrorCode getTile(SubImageBox location, MLDataType dataType, void **data, const ScaleShiftData &scaleShiftData=ScaleShiftData(), MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
See Host::getTile( module, outputIndex, location, dataType, data, scaleShiftData).
MLEXPORT void clearPageList()
Remove all pages of the page image and from the ML cache, and all page data chunks are freed,...
const MemoryImage & getMemoryImage() const
Definition: mlPagedImage.h:335
bool isValid() const
Returns whether image properties are valid and up-to-date.
Definition: mlPagedImage.h:147
MLEXPORT MLdouble getInterpolatedValue(const Vector3 &pos, MLint c=0, MLint t=0, MLint u=0, MLdouble outsideFillValue=0)
Get trilinear interpolated image value at given voxel position (center of a voxel is 0....
MLEXPORT SubImageBox getPageBox(MLint pageID) const
Returns the rectangular region in the entire image covered by the page with the id pageID.
ImageVector getPageExtent() const
Returns the extent of a page.
Definition: mlPagedImage.h:324
MLEXPORT MLMemoryBlockHandle getPage(MLint pageID) const
Returns the pointer to the CachedBuffer containing the data of the page with the id pageID.
void setInvalid()
Sets image properties invalid, i.e., isValid() returns false afterwards.
Definition: mlPagedImage.h:155
MLEXPORT void setPageExtent(const ImageVector &pageExtent)
Sets the extents of the pages to pageExtent.
MLEXPORT void setMinVoxelValue(MLdouble minval)
Sets assumed minimum value to minval. Overriden to perform access check.
MLEXPORT MLDataType getInputSubImageDataType(int inputIndex) const
Returns the input sub image data type for the input image at inputIndex.
MLEXPORT ThreadSupport getThreadSupport() const
Returns the current thread support of the paged image.
virtual MLEXPORT void setStateInfoErrorCode(MLErrorCode errorCode)
Sets the state information as MLErrorCode errorCode for this instance.
MLEXPORT void setCalculateOutputImagePropertiesCB(CalculateOutputImagePropertiesCB *callback, void *userData)
Sets the callback and userdata for the calculation of the properties of this PagedImage if they need ...
void setValid(bool flag=true)
Sets image properties to valid/up-to-date, i.e., isValid() returns true afterwards.
Definition: mlPagedImage.h:151
MLEXPORT void setUpdateOfImagePropertiesNeeded(bool flag)
Sets if the update of the image properties is needed, because the ML graph has changed since the last...
MLEXPORT PagedImage & getBypassSourceImage()
Returns the reference to the source image of a bypass chain.
MLEXPORT void setExternalCalculateOutputImageHandler(CalculateOutputImageHandler *handler)
Sets the pointer to the output image calculation interface handler, the ownership is NOT passed to th...
MLEXPORT MLMetaProfilePtr & getMetaProfile() const
Returns the MLMetaProfile for this paged image. Creates it if necessary.
ImageVector getPageStride() const
Returns the stride to get from one page to another.
Definition: mlPagedImage.h:321
MLEXPORT void removePage(MLint pageID)
This method removes a page with id pageID from this instance.
virtual MLEXPORT const std::string & getStateInfoString() const
Returns the current state information string which might explain something about the state of this in...
static MLEXPORT void setPageCountLimitToUsePageEntryMap(MLuint32 limit)
Sets the limit of number of pages for using the page entry map instead of the page list.
Definition: mlPagedImage.h:546
MLuint32 getID()
Returns the current image id (which changes whenever the image changes and which is unique accross al...
Definition: mlPagedImage.h:133
MLEXPORT void copyPages(const std::vector< MLint > &pageIDs, SubImage *subImage, const ScaleShiftData &scaleShiftData=ScaleShiftData()) const
Fills the subImage with contents of the Pages with the IDs pagesIDs The grey values become according ...
MLint getOutputIndex() const
Returns associated output index of Module instance if passed to constructor, -1 otherwise.
Definition: mlPagedImage.h:315
MLint getPageID(const ImageVector &voxelPosition) const
Returns the id of that page which contains the image voxel position voxelPosition.
Definition: mlPagedImage.h:327
MLEXPORT void setInputSubImageIsReadOnly(int inputIndex, bool readOnly)
Sets that the input sub image for the input image at inputIndex to readOnly.
MLEXPORT void setInputSubImageUseMemoryImage(int inputIndex, bool useMemoryImage)
Sets that the input sub image for the input image at inputIndex should use a memory image (this impli...
MLEXPORT void setInputSubImageScaleShift(int inputIndex, const ScaleShiftData &scaleShift)
Sets that the input sub image for the input image at inputIndex should be rescaled with the given sca...
MLEXPORT const InputSubImageProperties & getInputSubImageProperties(int inputIndex) const
Returns a const reference to the InputSubImageProperties of the given input image at inputIndex.
MLEXPORT void setThreadSupport(ThreadSupport support)
Sets the thread support of the paged image to the given value.
Definition: mlPagedImage.h:342
bool getClampPagesToImageExtent() const
see setClampPagesToImageExtent().
Definition: mlPagedImage.h:213
ML_FRIEND_TEST(PagedImageDeprecationTest, NewAPI)
MLEXPORT void setPage(MLint pageID, const MLMemoryBlockHandle &page)
Sets the given page handle as pagedata at pageID.
MLEXPORT bool updateOfImagePropertiesNeeded() const
Gets if the update of the image properties is needed, because the ML graph has changed since the last...
Definition: mlPagedImage.h:163
void setBypassIndex(MLint index)
Sets the index of the input image whose pages should be used instead of the pages of this image.
Definition: mlPagedImage.h:295
virtual MLEXPORT void setImageProperties(const PagedImage &imageProperties)
Function to copy all associated characteristics from imageProperties.
MLint getBypassIndex() const
Returns the index of the input image whose pages should be used instead of the pages of this image or...
Definition: mlPagedImage.h:299
MLEXPORT ~PagedImage() override
Destructor.
ImageVector getPageSetExtent() const
Returns the extents of the page set covering the entire image extents.
Definition: mlPagedImage.h:318
void setImageExtent(MLint x, MLint y, MLint z=1, MLint c=1, MLint t=1, MLint u=1)
Sets the extents of the image to the extent (x,y,z,c,t,u) and clears the list of valid pages and its ...
Definition: mlPagedImage.h:182
static MLEXPORT void getPageIDs(std::vector< MLint > &pageIDs, const SubImageBox &subImageBox, const ImageVector &imageExtent, const ImageVector &pageExtent)
Clears pageIDs and inserts the ids of all pages which need to be calculated to cover subImageBox comp...
void updateID()
Sets that the image has changed.
Definition: mlPagedImage.h:136
MLEXPORT bool getInputSubImageIsReadOnly(int inputIndex) const
Returns if input sub image at inputIndex is set to 'read-only'.
MLEXPORT void deletePageEntryFromDeletionCallback(ExtendedPageEntry *entry)
This method removes a page referenced by the page entry.
MemoryImage & getMemoryImage()
Permits the access to a memory cached output of the paged image.
Definition: mlPagedImage.h:334
bool hasExternalCalculateOutputImageHandler() const
Returns if the CalculateOutputImageHandler is an external handler and should not be overwritten.
Definition: mlPagedImage.h:124
Module * getModule() const
Returns the associated Module instance if passed to the constructor, NULL otherwise.
Definition: mlPagedImage.h:309
MLEXPORT void setCalculateOutputImageHandler(CalculateOutputImageHandler *handler)
Sets the pointer to the output image calculation interface handler, the ownership is passed to the Pa...
ThreadSupport
Defines the multi-threading support of the paged image.
Definition: mlPagedImage.h:82
MLEXPORT MLErrorCode getTile(SubImage &subImage, const ScaleShiftData &scaleShiftData=ScaleShiftData(), MLRequestProgressCB *progressCallback=nullptr, void *progressCallbackUserData=nullptr)
See Host::getTile( module, outputIndex, subImg, scaleShiftData).
static MLEXPORT MLuint32 getPageCountLimitToUsePageEntryMap()
Returns the limit of number of pages for using the page entry map instead of the page list.
Definition: mlPagedImage.h:549
ML_FRIEND_TEST(PagedImageDeprecationTest, DeprecatedAPI)
MLEXPORT void getPageIDs(std::vector< MLint > &pageIDs, const SubImageBox &subImageBox) const
Clears pageIDs and inserts the ids of all pages which need to be calculated to cover subImageBox comp...
CalculateOutputImageHandler * getCalculateOutputImageHandler() const
Returns the pointer to the output image calculation interface.
Definition: mlPagedImage.h:117
MLEXPORT MLMemoryBlockHandle getPageOrCreatePageRequestOrAddToPendingRequest(MLint &pageID, TileRequest *tileRequest, PageRequest **newPageRequest)
Returns the valid page handle if it exists.
void setClampPagesToImageExtent(bool flag=true)
If enabled, the pages are clamped to the image extent, so that pages on the border of the image will ...
Definition: mlPagedImage.h:210
MLEXPORT MLint getNumPages() const
Returns the total number of pages in this output image (regardless if they are allocated or not).
Definition: mlPagedImage.h:387
void setPageExtent(MLint x, MLint y, MLint z=1, MLint c=1, MLint t=1, MLint u=1)
Sets the extents of the pages to the extent (x,y,z,c,t,u).
Definition: mlPagedImage.h:217
MLEXPORT void calculateImageProperties()
Updates the image properties via the Module::calculateOutputImageProperties or via CalculateOutputIma...
ML_FRIEND_TEST(TypedHandlersTest, SetupAndVerifyProperties)
virtual MLEXPORT MLErrorCode getStateInfoErrorCode() const
Returns the current state information as MLError code which might explain something about the state o...
MLEXPORT MLErrorCode updateImageProperties()
Updates the image properties of the PagedImage using the Host::updateImageProperties method.
void setInPlaceIndex(MLint inputIndex)
Set optimization flag: If calculating a page in calculateOutputSubImage() the output image page shall...
Definition: mlPagedImage.h:405
MLEXPORT void initializeInputSubImageProperties(MLint numInputs)
Initializes the InSubImageProps for a given number of inputs, should only be called by the Host!
MLEXPORT void setDataType(MLDataType dataType) override
Sets type of data to dataType. Overriden to perform access check.
MLEXPORT void clearPageListAndMemoryImage()
Remove all pages of the page image and from the ML cache, and all page data chunks are freed.
MLEXPORT void freeTile(void *data)
Same as corresponding Host::freeTile(void *data).
MLEXPORT const PagedImage * getInputImage(int inputIndex) const
Returns the input image at inputIndex of the associated Module.
MLEXPORT std::size_t getCachedPagesSizeInBytes() const
Returns currently used cache size for pages in bytes.
MLEXPORT void validateInputSubImagePropertiesAfterCalculateOutputImageProperties()
Validates the properties and set datatype where it was not set, should only be called by the Host!
void setImageExtent(const SubImageBox &box)
Sets the extents of the image to box.getExtent() and updates all PagedImage settings.
Definition: mlPagedImage.h:189
virtual MLEXPORT void setImageExtent(const ImageVector &extent)
Sets the extents of the image to extent. The list of valid pages and its content are cleared.
MLEXPORT void setInputSubImagesAreReadOnly(bool readOnly=true)
Sets the read-only flag for all input images (see setInputSubImageIsReadOnly() for details)
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition: mlSubImage.h:75
VectorType getExtent() const
Returns the extents of the subimage region.
A TileRequest either represents the input sub image that is needed by a PageRequest or if it is a roo...
Definition: mlTileRequest.h:50
MLint32 MLDataType
MLDataType.
Definition: mlTypeDefs.h:684
MLint32 MLErrorCode
Type of an ML Error code.
Definition: mlTypeDefs.h:818
boost::mutex Mutex
Defines a non-recursive mutex.
Definition: mlMutex.h:39
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator "<<" for stream output of Field objects.
#define MLEXPORT
To export symbols from a dll/shared object, we need to mark them with the MLEXPORT symbol.
unsigned int MLuint32
Definition: mlTypeDefs.h:191
void MLRequestProgressCB(void *usrData, double progress)
Definition: mlTypeDefs.h:1318
double MLdouble
Definition: mlTypeDefs.h:223
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
void CalculateOutputImagePropertiesCB(void *userData, PagedImage *outImage)
Callback for the calculation of the output image properties for outputImage.
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.
TSubImageBox< MLint > SubImageBox
Define the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type.
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.