diff --git a/Accelerators/Vtkm/Core/vtkmlib/vtkmDataArray.hxx b/Accelerators/Vtkm/Core/vtkmlib/vtkmDataArray.hxx index 905f579ba53ab8c777419273dc7b395ae5681723..5f398d4f7402c497141b610fcc87842180d54a96 100644 --- a/Accelerators/Vtkm/Core/vtkmlib/vtkmDataArray.hxx +++ b/Accelerators/Vtkm/Core/vtkmlib/vtkmDataArray.hxx @@ -334,7 +334,7 @@ template auto TransformForScalarRange(const ArrayHandleType& src, const vtkm::cont::ArrayHandle& ghost, vtkm::UInt8 ghostValueToSkip, bool finitesOnly) { - DecoratorForScalarRanage decorator{ ghostValueToSkip, finitesOnly }; + DecoratorForScalarRanage decorator{ DecoratorParameters{ ghostValueToSkip, finitesOnly } }; return vtkm::cont::make_ArrayHandleDecorator(src.GetNumberOfValues(), decorator, src, ghost); } @@ -342,7 +342,7 @@ template auto TransformForVectorRange(const ArrayHandleType& src, const vtkm::cont::ArrayHandle& ghost, vtkm::UInt8 ghostValueToSkip, bool finitesOnly) { - DecoratorForVectorRanage decorator{ ghostValueToSkip, finitesOnly }; + DecoratorForVectorRanage decorator{ DecoratorParameters{ ghostValueToSkip, finitesOnly } }; return vtkm::cont::make_ArrayHandleDecorator(src.GetNumberOfValues(), decorator, src, ghost); } diff --git a/Accelerators/Vtkm/DataModel/vtkmDataSet.cxx b/Accelerators/Vtkm/DataModel/vtkmDataSet.cxx index e7df6914a158a1f96c0302f4c94ef9b510c55280..324f910fd3df3a6fdaf30641d1bec1cff2adf623 100644 --- a/Accelerators/Vtkm/DataModel/vtkmDataSet.cxx +++ b/Accelerators/Vtkm/DataModel/vtkmDataSet.cxx @@ -220,14 +220,19 @@ struct WorkletGetPointCells : vtkm::worklet::WorkletVisitPointsWithCells { } - template - VTKM_EXEC void operator()(vtkm::Id, IndicesVecType, vtkm::cont::DeviceAdapterTagCuda) const + template + VTKM_EXEC void operator()(vtkm::Id, IndicesVecType, Device) const { + this->RaiseError("This worklet should only be called on serial device"); } - VTKM_SUPPRESS_EXEC_WARNINGS - template - VTKM_EXEC void operator()(vtkm::Id count, IndicesVecType idxs, Device) const + // This method is declared VTKM_CONT because we have set it to only + // run on the serial device (see the third argument). Declaring it + // as VTKM_CONT will prevent compiler warnings/errors about calling + // a host function from a device that can never happen. + template + VTKM_CONT void operator()( + vtkm::Id count, IndicesVecType idxs, vtkm::cont::DeviceAdapterTagSerial) const { this->Output->SetNumberOfIds(count); for (vtkm::Id i = 0; i < count; ++i) diff --git a/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx b/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx index 45b777f1fc269eea7c7cf9a5c5be964bdadf9e01..fdccf33c95638356e82ffaa55f7c26f0c53b88f1 100644 --- a/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx +++ b/GUISupport/Qt/QVTKOpenGLNativeWidget.cxx @@ -209,6 +209,8 @@ void QVTKOpenGLNativeWidget::initializeGL() ostate->Reset(); // By default, Qt sets the depth function to GL_LESS but VTK expects GL_LEQUAL ostate->vtkglDepthFunc(GL_LEQUAL); + // By default, Qt disables the depth test but VTK expects it to be enabled. + ostate->vtkglEnable(GL_DEPTH_TEST); // When a QOpenGLWidget is told to use a QSurfaceFormat with samples > 0, // QOpenGLWidget doesn't actually create a context with multi-samples and diff --git a/IO/Geometry/vtkFLUENTReader.cxx b/IO/Geometry/vtkFLUENTReader.cxx index d2c9eddb90bcd808259a545abd6211100deb64f5..987172a811b21a7f30b201c58b4a32a206f8dbad 100644 --- a/IO/Geometry/vtkFLUENTReader.cxx +++ b/IO/Geometry/vtkFLUENTReader.cxx @@ -225,9 +225,9 @@ vtkFLUENTReader::~vtkFLUENTReader() int vtkFLUENTReader::RequestData(vtkInformation* vtkNotUsed(request), vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) { - if (!this->FileName) + if (!this->Parsed) { - vtkErrorMacro("FileName has to be specified!"); + vtkErrorMacro("The files have not been parsed successfully, aborting."); return 0; } @@ -382,6 +382,8 @@ void vtkFLUENTReader::PrintSelf(ostream& os, vtkIndent indent) int vtkFLUENTReader::RequestInformation(vtkInformation* vtkNotUsed(request), vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* vtkNotUsed(outputVector)) { + this->Parsed = false; + if (!this->FileName) { vtkErrorMacro("FileName has to be specified!"); @@ -401,8 +403,15 @@ int vtkFLUENTReader::RequestInformation(vtkInformation* vtkNotUsed(request), } this->LoadVariableNames(); - this->ParseCaseFile(); // Reads Necessary Information from the .cas file. - this->CleanCells(); // Removes unnecessary faces from the cells. + + bool parse = this->ParseCaseFile(); // Reads Necessary Information from the .cas file. + if (!parse) + { + vtkErrorMacro("Unable to parse case file."); + return 0; + } + + this->CleanCells(); // Removes unnecessary faces from the cells. this->PopulateCellNodes(); this->GetNumberOfCellZones(); this->NumberOfScalars = 0; @@ -431,6 +440,7 @@ int vtkFLUENTReader::RequestInformation(vtkInformation* vtkNotUsed(request), } } this->NumberOfCells = static_cast(this->Cells->value.size()); + this->Parsed = true; return 1; } @@ -2348,11 +2358,13 @@ void vtkFLUENTReader::LoadVariableNames() } //------------------------------------------------------------------------------ -void vtkFLUENTReader::ParseCaseFile() +bool vtkFLUENTReader::ParseCaseFile() { this->FluentCaseFile->clear(); this->FluentCaseFile->seekg(0, ios::beg); + bool ret = true; + // XXX: Each of these parsing method should be improved for error reporting and robustness while (this->GetCaseChunk()) { @@ -2376,7 +2388,7 @@ void vtkFLUENTReader::ParseCaseFile() this->GetCellsAscii(); break; case 13: - this->GetFacesAscii(); + ret &= this->GetFacesAscii(); break; case 18: this->GetPeriodicShadowFacesAscii(); @@ -2476,6 +2488,7 @@ void vtkFLUENTReader::ParseCaseFile() break; } } + return ret; } //------------------------------------------------------------------------------ @@ -2722,7 +2735,7 @@ void vtkFLUENTReader::GetCellsBinary() } //------------------------------------------------------------------------------ -void vtkFLUENTReader::GetFacesAscii() +bool vtkFLUENTReader::GetFacesAscii() { if (this->CaseBuffer->value.at(5) == '0') @@ -2759,6 +2772,11 @@ void vtkFLUENTReader::GetFacesAscii() { numberOfNodesInFace = faceType; } + if (this->Faces->value.size() < i) + { + vtkErrorMacro("Could not parse faces"); + return false; + } this->Faces->value[i - 1].nodes.resize(numberOfNodesInFace); for (int j = 0; j < numberOfNodesInFace; j++) { @@ -2788,6 +2806,7 @@ void vtkFLUENTReader::GetFacesAscii() } } } + return true; } //------------------------------------------------------------------------------ diff --git a/IO/Geometry/vtkFLUENTReader.h b/IO/Geometry/vtkFLUENTReader.h index 740d4efa8552d8d2fad5cd0fe5c1e41ecde7ea74..6907966088aa29e5c99486ba89a3aeac42442aaf 100644 --- a/IO/Geometry/vtkFLUENTReader.h +++ b/IO/Geometry/vtkFLUENTReader.h @@ -153,7 +153,7 @@ protected: virtual int GetDataChunk(); virtual void GetSpeciesVariableNames(); - virtual void ParseCaseFile(); + virtual bool ParseCaseFile(); virtual int GetDimension(); virtual void GetLittleEndianFlag(); virtual void GetNodesAscii(); @@ -161,7 +161,7 @@ protected: virtual void GetNodesDoublePrecision(); virtual void GetCellsAscii(); virtual void GetCellsBinary(); - virtual void GetFacesAscii(); + virtual bool GetFacesAscii(); virtual void GetFacesBinary(); virtual void GetPeriodicShadowFacesAscii(); virtual void GetPeriodicShadowFacesBinary(); @@ -240,6 +240,8 @@ protected: private: vtkFLUENTReader(const vtkFLUENTReader&) = delete; void operator=(const vtkFLUENTReader&) = delete; + + bool Parsed = false; }; VTK_ABI_NAMESPACE_END #endif diff --git a/Rendering/Core/vtkImageMapper3D.cxx b/Rendering/Core/vtkImageMapper3D.cxx index 494c9e4c5503bcc8a429cc20e70df74ada0d6ff0..209b7cc04ba60e26f72d09cef8f31a2178f540cc 100644 --- a/Rendering/Core/vtkImageMapper3D.cxx +++ b/Rendering/Core/vtkImageMapper3D.cxx @@ -753,21 +753,6 @@ static VTK_THREAD_RETURN_TYPE vtkImageMapperMapColors(void* arg) return VTK_THREAD_RETURN_VALUE; } -//------------------------------------------------------------------------------ -// Given an image and an extent that describes a single slice, this method -// will return a contiguous block of unsigned char data that can be loaded -// into a texture. -// The values of xsize, ysize, bytesPerPixel, and reuseTexture must be -// pre-loaded with the current texture size and depth, with subTexture -// set to 1 if only a subTexture is to be generated. -// When the method returns, these values will be set to the dimensions -// of the data that was produced, and subTexture will remain set to 1 -// if xsize,ysize describe a subtexture size. -// If subTexture is not set to one upon return, then xsize,ysize will -// describe the full texture size, with the assumption that the full -// texture must be reloaded. -// If reuseData is false upon return, then the returned array must be -// freed after use with delete []. unsigned char* vtkImageMapper3D::MakeTextureData(vtkImageProperty* property, vtkImageData* input, int extent[6], int& xsize, int& ysize, int& bytesPerPixel, bool& reuseTexture, bool& reuseData) { diff --git a/Rendering/Core/vtkImageMapper3D.h b/Rendering/Core/vtkImageMapper3D.h index d64244a98d4d705cba02e798a9c27dc74aafa127..02f63c10d28465be1e48463ada06aec457834de2 100644 --- a/Rendering/Core/vtkImageMapper3D.h +++ b/Rendering/Core/vtkImageMapper3D.h @@ -179,8 +179,19 @@ protected: /** * Perform window/level and color mapping operations to produce - * unsigned char data that can be used as a texture. See the - * source file for more information. + * unsigned char data that can be used as a texture. + * + * Given an image and an extent that describes a single slice, this method + * will return a contiguous block of unsigned char data that can be loaded + * into a texture. + * The values of xsize, ysize, bytesPerPixel, must be pre-loaded with the + * current texture size and depth. + * When the method returns, these values will be set to the dimensions + * of the data that was produced. + * The values of reuseData and reuseTexture are typically pre-loaded with true. + * If reuseTexture is false upon return, then texture size or format has changed + * If reuseData is false upon return, then the returned array must be + * freed after use with delete []. */ unsigned char* MakeTextureData(vtkImageProperty* property, vtkImageData* input, int extent[6], int& xsize, int& ysize, int& bytesPerPixel, bool& reuseTexture, bool& reuseData); diff --git a/Rendering/OpenGL2/vtkOpenGLImageSliceMapper.cxx b/Rendering/OpenGL2/vtkOpenGLImageSliceMapper.cxx index ddf9081f4488a46dcf5ddd6b81c15cb65543a78a..eb6a0a0acbabc1a09ff4cde33b82767d938a2a1a 100644 --- a/Rendering/OpenGL2/vtkOpenGLImageSliceMapper.cxx +++ b/Rendering/OpenGL2/vtkOpenGLImageSliceMapper.cxx @@ -252,9 +252,9 @@ void vtkOpenGLImageSliceMapper::RenderTexturedPolygon( input->GetMTime() > loadTime || orientationChanged || sliceChanged || recursive) { // get the data to load as a texture - int xsize; - int ysize; - int bytesPerPixel; + int xsize = this->TextureSize[0]; + int ysize = this->TextureSize[1]; + int bytesPerPixel = this->TextureBytesPerPixel; // whether to try to use the input data directly as the texture bool reuseData = true; diff --git a/Rendering/OpenGL2/vtkSSAOPass.cxx b/Rendering/OpenGL2/vtkSSAOPass.cxx index 27250e998bbb11a20722ef3befe1f11526766caf..bffe97ea050ff989a4ef110fc72aa85f9db1e8c8 100644 --- a/Rendering/OpenGL2/vtkSSAOPass.cxx +++ b/Rendering/OpenGL2/vtkSSAOPass.cxx @@ -217,13 +217,28 @@ void vtkSSAOPass::RenderDelegate(const vtkRenderState* s, int w, int h) this->FrameBufferObject->AddDepthAttachment(this->DepthTexture); this->FrameBufferObject->StartNonOrtho(w, h); + // Clear color and depth. + // This is only required for the vtkRenderer built-in UseSSAO feature + // where the DelegatePass does not use a vtkCameraPass for clearing. vtkOpenGLRenderer* glRen = vtkOpenGLRenderer::SafeDownCast(s->GetRenderer()); + if (glRen && glRen->GetUseSSAO() && glRen->GetErase()) + { + vtkOpenGLState* ostate = glRen->GetState(); + GLbitfield clear_mask = 0; + if (!glRen->Transparent()) + { + clear_mask |= GL_COLOR_BUFFER_BIT; + } - vtkOpenGLState* ostate = glRen->GetState(); - ostate->vtkglClear(GL_COLOR_BUFFER_BIT); - ostate->vtkglDepthMask(GL_TRUE); - ostate->vtkglClearDepth(1.0); - ostate->vtkglClear(GL_DEPTH_BUFFER_BIT); + if (!glRen->GetPreserveDepthBuffer()) + { + ostate->vtkglClearDepth(static_cast(1.0)); + clear_mask |= GL_DEPTH_BUFFER_BIT; + ostate->vtkglDepthMask(GL_TRUE); + } + + ostate->vtkglClear(clear_mask); + } this->DelegatePass->Render(s); this->NumberOfRenderedProps += this->DelegatePass->GetNumberOfRenderedProps();