diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml index 26cd891e0517dce4d40d39741fe7a80f970601f6..39f19dd59706f2930cc13395441c8943b7ab651d 100644 --- a/.idea/codeStyleSettings.xml +++ b/.idea/codeStyleSettings.xml @@ -45,6 +45,10 @@ <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="InstanceMethod" /> <option name="com.jetbrains.cidr.lang.util.OCDeclarationKind" value="DeallocMethod" /> </class> + <extensions> + <pair source="cpp" header="h" /> + <pair source="c" header="h" /> + </extensions> </Objective-C-extensions> <XML> <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> diff --git a/InSituLib/VtkMappedMeshSource.cpp b/InSituLib/VtkMappedMeshSource.cpp index c91dfc9bd6561ced0d2fe550d7b2c27b1fdb2fff..01cf3fbcb915303906e88fd5d80e5d80dd815afe 100644 --- a/InSituLib/VtkMappedMeshSource.cpp +++ b/InSituLib/VtkMappedMeshSource.cpp @@ -68,12 +68,15 @@ int VtkMappedMeshSource::RequestData(vtkInformation *, if (outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()) > 0) return 1; + // Points this->Points->Reset(); vtkNew<VtkMeshNodalCoordinatesTemplate<double> > nodeCoords; nodeCoords->SetNodes(_mesh->getNodes()); this->Points->SetData(nodeCoords.GetPointer()); + // output->SetPoints(this->Points.GetPointer()); // TODO: not necessary? + // Elements vtkNew<VtkMappedMesh> elems; elems->GetImplementation()->SetNodes(_mesh->getNodes()); elems->GetImplementation()->SetElements(_mesh->getElements()); @@ -84,6 +87,7 @@ int VtkMappedMeshSource::RequestData(vtkInformation *, output->Allocate(elems->GetNumberOfCells()); output->ShallowCopy(elems.GetPointer()); + // Arrays MeshLib::Properties const & properties = _mesh->getProperties(); std::vector<std::string> const& propertyNames = properties.getPropertyVectorNames(); @@ -100,6 +104,9 @@ int VtkMappedMeshSource::RequestData(vtkInformation *, DBUG ("Mesh property \"%s\" with unknown data type.", *name->c_str()); } + + output->GetPointData()->ShallowCopy(this->PointData.GetPointer()); + output->GetCellData()->ShallowCopy(this->CellData.GetPointer()); return 1; } diff --git a/InSituLib/VtkMappedMeshSource.h b/InSituLib/VtkMappedMeshSource.h index 254b797835b60b036f0083a2462002e28315a36b..5b4b6f5adfacc2794495215ab412724fc2ab08ad 100644 --- a/InSituLib/VtkMappedMeshSource.h +++ b/InSituLib/VtkMappedMeshSource.h @@ -38,6 +38,7 @@ #include "MeshLib/Properties.h" #include "MeshLib/PropertyVector.h" +class vtkCellData; class vtkDataArrayCollection; class vtkPointData; class vtkPoints; @@ -87,9 +88,9 @@ private: dataArray->SetName(prop_name.c_str()); if(propertyVector->getMeshItemType() == MeshLib::MeshItemType::Node) - output.GetPointData()->AddArray(dataArray.GetPointer()); + this->PointData->AddArray(dataArray.GetPointer()); else if(propertyVector->getMeshItemType() == MeshLib::MeshItemType::Cell) - output.GetCellData()->AddArray(dataArray.GetPointer()); + this->CellData->AddArray(dataArray.GetPointer()); return true; } @@ -103,6 +104,7 @@ private: vtkNew<vtkPoints> Points; vtkNew<vtkPointData> PointData; + vtkNew<vtkCellData> CellData; }; } // Namespace InSituLib diff --git a/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h b/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h index 860e6e2ccc978bca03e3a59c2ab33ab6d2576536..11caf47e564b056f2dc5de96cc0a5a6bcbdc555c 100644 --- a/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h +++ b/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h @@ -194,19 +194,7 @@ template <class Scalar> Scalar& VtkMeshNodalCoordinatesTemplate<Scalar> { const vtkIdType tuple = idx / this->NumberOfComponents; const vtkIdType comp = idx % this->NumberOfComponents; - switch (comp) - { - case 0: - return (*(*this->_nodes)[tuple])[0]; - case 1: - return (*(*this->_nodes)[tuple])[1]; - case 2: - return (*(*this->_nodes)[tuple])[2]; - default: - vtkErrorMacro(<<"Invalid number of components."); - static Scalar dummy(0); - return dummy; - } + return (*(*this->_nodes)[tuple])[comp]; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar>