MCPcopy Create free account
hub / github.com/Kitware/VTK / StreamingFindMinMax

Function StreamingFindMinMax

Rendering/LICOpenGL2/vtkLineIntegralConvolution2D.cxx:782–828  ·  view source on GitHub ↗

Description find min/max of unmasked fragments across all regions download each search each region individually

Source from the content-addressed store, hash-verified

780// find min/max of unmasked fragments across all regions
781// download each search each region individually
782void StreamingFindMinMax(vtkOpenGLFramebufferObject* fbo, vtkTextureObject* tex,
783 const deque<vtkPixelExtent>& extents, float& min, float& max)
784{
785 size_t nExtents = extents.size();
786 // initiate download of each region
787 fbo->AddColorAttachment(0U, tex);
788 fbo->ActivateDrawBuffer(0U);
789 fbo->ActivateReadBuffer(0U);
790 fbo->CheckFrameBufferStatus(GL_FRAMEBUFFER);
791 vector<vtkPixelBufferObject*> pbos(nExtents, nullptr);
792 for (size_t q = 0; q < nExtents; ++q)
793 {
794 pbos[q] =
795 fbo->Download(const_cast<int*>(extents[q].GetData()), VTK_FLOAT, 4, GL_FLOAT, GL_RGBA);
796 }
797 fbo->DeactivateDrawBuffers();
798 fbo->DeactivateReadBuffer();
799 fbo->RemoveColorAttachment(0U);
800 fbo->RemoveColorAttachment(0U);
801 // search each region
802 for (size_t q = 0; q < nExtents; ++q)
803 {
804 vtkPixelBufferObject*& pbo = pbos[q];
805 float* pColors = (float*)pbo->MapPackedBuffer();
806
807 size_t n = extents[q].Size();
808 for (size_t i = 0; i < n; ++i)
809 {
810 bool masked = pColors[4 * i + 1] != 0.0f;
811 bool ceskip = pColors[4 * i + 2] != 0.0f;
812 if (!masked && !ceskip)
813 {
814 float color = pColors[4 * i];
815 min = min > color ? color : min;
816 max = max < color ? color : max;
817 }
818 }
819
820 pbo->UnmapPackedBuffer();
821 pbo->Delete();
822 pbo = nullptr;
823 }
824 pbos.clear();
825#if vtkLineIntegralConvolution2DDEBUG >= 1
826 std::cerr << "min=" << min << " max=" << max << endl;
827#endif
828}
829#else
830// Description
831// find min/max of unmasked fragments across all regions

Callers 2

CombineColorsAndLICMethod · 0.85
ExecuteMethod · 0.85

Calls 13

AddColorAttachmentMethod · 0.80
ActivateDrawBufferMethod · 0.80
ActivateReadBufferMethod · 0.80
DeactivateDrawBuffersMethod · 0.80
DeactivateReadBufferMethod · 0.80
RemoveColorAttachmentMethod · 0.80
DeleteMethod · 0.65
sizeMethod · 0.45
DownloadMethod · 0.45
GetDataMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected