@@ -184,10 +184,11 @@ class CornerstoneViewport extends Component {
184
184
const image = await cornerstone . loadAndCacheImage ( imageId ) ;
185
185
186
186
// Display
187
+
187
188
cornerstone . displayImage ( this . element , image ) ;
188
189
189
190
if ( isStackPrefetchEnabled ) {
190
- _enableStackPrefetching ( this . element ) ;
191
+ cornerstoneTools . stackPrefetch . enable ( this . element ) ;
191
192
}
192
193
193
194
if ( isPlaying ) {
@@ -254,10 +255,7 @@ class CornerstoneViewport extends Component {
254
255
255
256
// Need to stop/start to pickup stack changes in prefetcher
256
257
if ( shouldStopStartStackPrefetch ) {
257
- const clear = true ;
258
-
259
- _enableStackPrefetching ( this . element , clear ) ;
260
- _enableStackPrefetching ( this . element ) ;
258
+ cornerstoneTools . stackPrefetch . enable ( this . element ) ;
261
259
}
262
260
263
261
// ~~ ACTIVE TOOL
@@ -319,7 +317,7 @@ class CornerstoneViewport extends Component {
319
317
this . _setupLoadHandlers ( clear ) ;
320
318
321
319
if ( this . props . isStackPrefetchEnabled ) {
322
- _enableStackPrefetching ( this . element , clear ) ;
320
+ cornerstoneTools . stackPrefetch . disable ( this . element ) ;
323
321
}
324
322
325
323
cornerstoneTools . clearToolState ( this . element , 'stackPrefetch' ) ;
@@ -714,85 +712,6 @@ class CornerstoneViewport extends Component {
714
712
this . setViewportActive ( ) ;
715
713
716
714
scrollToIndex ( this . element , value ) ;
717
-
718
- this . resetPrefetching ( value ) ;
719
- } ;
720
-
721
- resetPrefetching = imageIdIndex => {
722
- cornerstoneTools . stackPrefetch . setConfiguration ( {
723
- maxImagesToPrefetch : Infinity ,
724
- preserveExistingPool : false ,
725
- maxSimultaneousRequests : 6 ,
726
- } ) ;
727
-
728
- const { imageIds } = this . props ;
729
-
730
- const minImageIdIndex = 0 ;
731
- const maxImageIdIndex = imageIds . length - 1 ;
732
-
733
- let lowerImageIdIndex = imageIdIndex ;
734
- let upperImageIdIndex = imageIdIndex ;
735
-
736
- // Build up an array of images to prefetch, starting with the current image.
737
- let imageIdsToPrefetch = [ imageIds [ imageIdIndex ] ] ;
738
-
739
- // 0: From current stack position down to minimum.
740
- // 1: From current stack position up to maximum.
741
-
742
- const prefetchQueuedFilled = [ false , false ] ;
743
-
744
- // Check if on edges and some criteria is already fulfilled
745
-
746
- if ( imageIdIndex === minImageIdIndex ) {
747
- prefetchQueuedFilled [ 0 ] = true ;
748
- } else if ( imageIdIndex === maxImageIdIndex ) {
749
- prefetchQueuedFilled [ 1 ] = true ;
750
- }
751
-
752
- while (
753
- prefetchQueuedFilled [ 0 ] === false ||
754
- prefetchQueuedFilled [ 1 ] === false
755
- ) {
756
- if ( prefetchQueuedFilled [ 0 ] === false ) {
757
- // Add imageId bellow
758
- lowerImageIdIndex -- ;
759
- imageIdsToPrefetch . push ( imageIds [ lowerImageIdIndex ] ) ;
760
-
761
- if ( lowerImageIdIndex === minImageIdIndex ) {
762
- prefetchQueuedFilled [ 0 ] = true ;
763
- }
764
- }
765
-
766
- if ( prefetchQueuedFilled [ 1 ] === false ) {
767
- // Add imageId above
768
- upperImageIdIndex ++ ;
769
- imageIdsToPrefetch . push ( imageIds [ upperImageIdIndex ] ) ;
770
-
771
- if ( upperImageIdIndex === maxImageIdIndex ) {
772
- prefetchQueuedFilled [ 1 ] = true ;
773
- }
774
- }
775
- }
776
-
777
- const requestPoolManager = cornerstoneTools . requestPoolManager ;
778
- const requestType = 'prefetch' ;
779
- const preventCache = false ;
780
- const noop = ( ) => { } ;
781
-
782
- requestPoolManager . clearRequestStack ( 'prefetch' ) ;
783
-
784
- imageIdsToPrefetch . forEach ( imageId => {
785
- requestPoolManager . addRequest (
786
- { } ,
787
- imageId ,
788
- requestType ,
789
- preventCache ,
790
- noop ,
791
- noop
792
- ) ;
793
- } ) ;
794
-
795
- requestPoolManager . startGrabbing ( ) ;
796
715
} ;
797
716
798
717
setViewportActive = ( ) => {
@@ -886,14 +805,6 @@ function _trySetActiveTool(element, activeToolName) {
886
805
} ) ;
887
806
}
888
807
889
- function _enableStackPrefetching ( element , clear = false ) {
890
- if ( clear ) {
891
- cornerstoneTools . stackPrefetch . disable ( element ) ;
892
- } else {
893
- cornerstoneTools . stackPrefetch . enable ( element ) ;
894
- }
895
- }
896
-
897
808
/**
898
809
* Iterate over the provided tools; Add each tool to the target element
899
810
*
0 commit comments