diff --git a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp index 773268c1b1b1783eaa635581c17df57c69f1557f..a007939330cdd2cd6e18375728f648d4949c2526 100644 --- a/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp +++ b/Applications/DataExplorer/VtkVis/VtkConsoleOutputWindow.cpp @@ -10,6 +10,7 @@ #include "VtkConsoleOutputWindow.h" #include <string> +#include <ostream> #include "vtkObjectFactory.h" #ifdef WIN32 @@ -44,40 +45,10 @@ void VtkConsoleOutputWindow::DisplayText(const char* someText) (someTextString.find("Invalid framebuffer operation") != std::string::npos)) return; - // Create a buffer big enough to hold the entire text - char* buffer = new char[strlen(someText)+1]; - // Start at the beginning - const char* NewLinePos = someText; - while(NewLinePos) - { - int len = 0; - // Find the next new line in text - NewLinePos = strchr(someText, '\n'); - // if no new line is found then just add the text - if(NewLinePos == 0) - { #ifdef WIN32 - OutputDebugString(someText); + OutputDebugString(someTextString.c_str()); #endif - cerr << someText; - } - // if a new line is found copy it to the buffer - // and add the buffer with a control new line - else - { - len = NewLinePos - someText; - strncpy(buffer, someText, len); - buffer[len] = 0; - someText = NewLinePos+1; -#ifdef WIN32 - OutputDebugString(buffer); - OutputDebugString("\r\n"); -#endif - cerr << buffer; - cerr << "\r\n"; - } - } - delete [] buffer; + std::cerr << someText; } //---------------------------------------------------------------------------- diff --git a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp index a636f783a55c04e0c0daf9a5d09bc0d92763a463..bfa509048ea8cdad1f0e7e31308bfc072c188467 100644 --- a/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp +++ b/Applications/DataExplorer/VtkVis/VtkVisPointSetItem.cpp @@ -268,7 +268,6 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) // Remove type identifier _activeArrayName = QString(name).remove(0, 2).toStdString(); - const char* arrayName = _activeArrayName.c_str(); vtkDataSet* dataSet = vtkDataSet::SafeDownCast(this->_algorithm->GetOutputDataObject(0)); if (!dataSet) @@ -282,7 +281,7 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) if(pointData) { _algorithm->SetInputArrayToProcess(0, 0, 0, - vtkDataObject::FIELD_ASSOCIATION_POINTS, arrayName); + vtkDataObject::FIELD_ASSOCIATION_POINTS, _activeArrayName.c_str()); _mapper->SetScalarModeToUsePointFieldData(); } } @@ -292,7 +291,7 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) if(cellData) { _algorithm->SetInputArrayToProcess(0, 0, 0, - vtkDataObject::FIELD_ASSOCIATION_CELLS, arrayName); + vtkDataObject::FIELD_ASSOCIATION_CELLS, _activeArrayName.c_str()); _mapper->SetScalarModeToUseCellFieldData(); } } @@ -316,7 +315,7 @@ void VtkVisPointSetItem::SetActiveAttribute( const QString& name ) } _mapper->SetLookupTable(lut); } - _mapper->SelectColorArray(arrayName); + _mapper->SelectColorArray( _activeArrayName.c_str()); } bool VtkVisPointSetItem::activeAttributeExists(vtkDataSetAttributes* data, std::string& name) diff --git a/InSituLib/VtkMappedMeshSource.h b/InSituLib/VtkMappedMeshSource.h index 5b4b6f5adfacc2794495215ab412724fc2ab08ad..3f2ac2fa758b40acb2f7261a399475b581614ac6 100644 --- a/InSituLib/VtkMappedMeshSource.h +++ b/InSituLib/VtkMappedMeshSource.h @@ -49,6 +49,8 @@ namespace MeshLib { namespace InSituLib { +/// Adapter which maps a MeshLib::Mesh to a vtkUnstructuredGridAlgorithm. +/// Allows for zero-copy access of the mesh from the visualization side. class VtkMappedMeshSource : public vtkUnstructuredGridAlgorithm { public: @@ -56,7 +58,10 @@ public: vtkTypeMacro(VtkMappedMeshSource, vtkUnstructuredGridAlgorithm) virtual void PrintSelf(std::ostream &os, vtkIndent indent); + /// Sets the mesh. Calling is mandatory void SetMesh(const MeshLib::Mesh* mesh) { this->_mesh = mesh; this->Modified(); } + + /// Returns the mesh. const MeshLib::Mesh* GetMesh() const { return _mesh; } protected: @@ -74,6 +79,10 @@ private: VtkMappedMeshSource(const VtkMappedMeshSource &); // Not implemented. void operator=(const VtkMappedMeshSource &); // Not implemented. + /// Adds a zero-copy array (InSituLib::VtkMappedPropertyVectorTemplate) as + /// either point or cell data to the mesh. + /// \param properties Usually MeshLib::Mesh::getProperties() + /// \param prop_name The name of the property vector. template<typename T> bool addProperty(vtkUnstructuredGrid &output, MeshLib::Properties const& properties, std::string const& prop_name) const @@ -99,8 +108,6 @@ private: int NumberOfDimensions; int NumberOfNodes; - std::vector<std::string> NodalVariableNames; - std::vector<std::string> ElementVariableNames; vtkNew<vtkPoints> Points; vtkNew<vtkPointData> PointData;