diff --git a/InSituLib/CMakeLists.txt b/InSituLib/CMakeLists.txt index 3ad4bc2b91465fd618c6597613d3ce9279bbed16..341590e97be11134f1916506784420af8caa98b0 100644 --- a/InSituLib/CMakeLists.txt +++ b/InSituLib/CMakeLists.txt @@ -1,12 +1,12 @@ add_library(InSituLib STATIC - VtkMappedMesh.h - VtkMappedMesh.cpp - VtkMappedMeshSource.h - VtkMappedMeshSource.cpp - VtkMappedPropertyVectorTemplate.h - VtkMappedPropertyVectorTemplate-impl.h - VtkMeshNodalCoordinatesTemplate.h - VtkMeshNodalCoordinatesTemplate-impl.h + VtkMappedMesh.h + VtkMappedMesh.cpp + VtkMappedMeshSource.h + VtkMappedMeshSource.cpp + VtkMappedPropertyVectorTemplate.h + VtkMappedPropertyVectorTemplate-impl.h + VtkMeshNodalCoordinatesTemplate.h + VtkMeshNodalCoordinatesTemplate-impl.h ) target_link_libraries(InSituLib MeshLib ${VTK_LIBRARIES}) diff --git a/InSituLib/VtkMappedMesh.cpp b/InSituLib/VtkMappedMesh.cpp index 844c2a65943cebf866bb78e455bab27c8540855d..c73f3dcd0df2f7129c8e60d14f3c3f81ffd9db8f 100644 --- a/InSituLib/VtkMappedMesh.cpp +++ b/InSituLib/VtkMappedMesh.cpp @@ -37,147 +37,147 @@ vtkStandardNewMacro(VtkMappedMeshImpl) void VtkMappedMeshImpl::PrintSelf(ostream &os, vtkIndent indent) { - this->Superclass::PrintSelf(os, indent); - os << indent << "NumberOfCells: " << this->NumberOfCells << endl; + this->Superclass::PrintSelf(os, indent); + os << indent << "NumberOfCells: " << this->NumberOfCells << endl; } void VtkMappedMeshImpl::SetNodes(std::vector<MeshLib::Node*> const & nodes) { - _nodes = &nodes; + _nodes = &nodes; } void VtkMappedMeshImpl::SetElements(std::vector<MeshLib::Element*> const & elements) { - _elements = &elements; - this->NumberOfCells = _elements->size(); - this->Modified(); + _elements = &elements; + this->NumberOfCells = _elements->size(); + this->Modified(); } vtkIdType VtkMappedMeshImpl::GetNumberOfCells() { - return this->NumberOfCells; + return this->NumberOfCells; } int VtkMappedMeshImpl::GetCellType(vtkIdType cellId) { - return OGSToVtkCellType((*_elements)[cellId]->getCellType()); + return OGSToVtkCellType((*_elements)[cellId]->getCellType()); } void VtkMappedMeshImpl::GetCellPoints(vtkIdType cellId, vtkIdList *ptIds) { - const MeshLib::Element* const elem = (*_elements)[cellId]; - const unsigned numNodes(elem->getNNodes()); - const MeshLib::Node* const* nodes = (*_elements)[cellId]->getNodes(); - ptIds->SetNumberOfIds(numNodes); - - for (unsigned i(0); i < numNodes; ++i) - ptIds->SetId(i, nodes[i]->getID()); - - if(GetCellType(cellId) == VTK_WEDGE) - { - for (unsigned i=0; i<3; ++i) - { - const unsigned prism_swap_id = ptIds->GetId(i); - ptIds->SetId(i, ptIds->GetId(i+3)); - ptIds->SetId(i+3, prism_swap_id); - } - } - else if(GetCellType(cellId) == VTK_QUADRATIC_WEDGE) - { - std::array<vtkIdType, 15> ogs_nodeIds; - for (unsigned i=0; i<15; ++i) - ogs_nodeIds[i] = ptIds->GetId(i); - for (unsigned i=0; i<3; ++i) - { - ptIds->SetId(i, ogs_nodeIds[i+3]); - ptIds->SetId(i+3, ogs_nodeIds[i]); - } - for (unsigned i=0; i<3; ++i) - ptIds->SetId(6+i, ogs_nodeIds[8-i]); - for (unsigned i=0; i<3; ++i) - ptIds->SetId(9+i, ogs_nodeIds[14-i]); - ptIds->SetId(12, ogs_nodeIds[9]); - ptIds->SetId(13, ogs_nodeIds[11]); - ptIds->SetId(14, ogs_nodeIds[10]); - } + const MeshLib::Element* const elem = (*_elements)[cellId]; + const unsigned numNodes(elem->getNNodes()); + const MeshLib::Node* const* nodes = (*_elements)[cellId]->getNodes(); + ptIds->SetNumberOfIds(numNodes); + + for (unsigned i(0); i < numNodes; ++i) + ptIds->SetId(i, nodes[i]->getID()); + + if(GetCellType(cellId) == VTK_WEDGE) + { + for (unsigned i=0; i<3; ++i) + { + const unsigned prism_swap_id = ptIds->GetId(i); + ptIds->SetId(i, ptIds->GetId(i+3)); + ptIds->SetId(i+3, prism_swap_id); + } + } + else if(GetCellType(cellId) == VTK_QUADRATIC_WEDGE) + { + std::array<vtkIdType, 15> ogs_nodeIds; + for (unsigned i=0; i<15; ++i) + ogs_nodeIds[i] = ptIds->GetId(i); + for (unsigned i=0; i<3; ++i) + { + ptIds->SetId(i, ogs_nodeIds[i+3]); + ptIds->SetId(i+3, ogs_nodeIds[i]); + } + for (unsigned i=0; i<3; ++i) + ptIds->SetId(6+i, ogs_nodeIds[8-i]); + for (unsigned i=0; i<3; ++i) + ptIds->SetId(9+i, ogs_nodeIds[14-i]); + ptIds->SetId(12, ogs_nodeIds[9]); + ptIds->SetId(13, ogs_nodeIds[11]); + ptIds->SetId(14, ogs_nodeIds[10]); + } } void VtkMappedMeshImpl::GetPointCells(vtkIdType ptId, vtkIdList *cellIds) { - cellIds->Reset(); + cellIds->Reset(); - auto elements((*_nodes)[ptId]->getElements()); - for (auto elem(elements.begin()); elem != elements.end(); ++elem) - cellIds->InsertNextId((*elem)->getID()); + auto elements((*_nodes)[ptId]->getElements()); + for (auto elem(elements.begin()); elem != elements.end(); ++elem) + cellIds->InsertNextId((*elem)->getID()); } int VtkMappedMeshImpl::GetMaxCellSize() { - unsigned int size = 0; - for (auto elem(_elements->begin()); elem != _elements->end(); ++elem) - size = std::max(size, (*elem)->getNNodes()); - return size; + unsigned int size = 0; + for (auto elem(_elements->begin()); elem != _elements->end(); ++elem) + size = std::max(size, (*elem)->getNNodes()); + return size; } void VtkMappedMeshImpl::GetIdsOfCellsOfType(int type, vtkIdTypeArray *array) { - array->Reset(); + array->Reset(); - for (auto elem(_elements->begin()); elem != _elements->end(); ++elem) - { - if ((*elem)->getCellType() == VtkCellTypeToOGS(type)) - array->InsertNextValue((*elem)->getID()); - } + for (auto elem(_elements->begin()); elem != _elements->end(); ++elem) + { + if ((*elem)->getCellType() == VtkCellTypeToOGS(type)) + array->InsertNextValue((*elem)->getID()); + } } int VtkMappedMeshImpl::IsHomogeneous() { - MeshLib::CellType type = (*(_elements->begin()))->getCellType(); - for (auto elem(_elements->begin()); elem != _elements->end(); ++elem) - if((*elem)->getCellType() != type) - return 0; - return 1; + MeshLib::CellType type = (*(_elements->begin()))->getCellType(); + for (auto elem(_elements->begin()); elem != _elements->end(); ++elem) + if((*elem)->getCellType() != type) + return 0; + return 1; } void VtkMappedMeshImpl::Allocate(vtkIdType, int) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } vtkIdType VtkMappedMeshImpl::InsertNextCell(int, vtkIdList*) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } vtkIdType VtkMappedMeshImpl::InsertNextCell(int, vtkIdType, vtkIdType*) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } vtkIdType VtkMappedMeshImpl::InsertNextCell( - int, vtkIdType, vtkIdType*, vtkIdType, vtkIdType*) + int, vtkIdType, vtkIdType*, vtkIdType, vtkIdType*) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } void VtkMappedMeshImpl::ReplaceCell(vtkIdType, int, vtkIdType*) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } VtkMappedMeshImpl::VtkMappedMeshImpl() - : _nodes(NULL), _elements(NULL), NumberOfCells(0) + : _nodes(NULL), _elements(NULL), NumberOfCells(0) { } VtkMappedMeshImpl::~VtkMappedMeshImpl() { - // delete [] this->Elements; + // delete [] this->Elements; } } // end namespace diff --git a/InSituLib/VtkMappedMesh.h b/InSituLib/VtkMappedMesh.h index 7509c5b6764dfcde03cd0d0a5ca6ce3ec754364f..ee5fda3d02ca05971f277973aaf11e7e51df23e4 100644 --- a/InSituLib/VtkMappedMesh.h +++ b/InSituLib/VtkMappedMesh.h @@ -22,8 +22,8 @@ class vtkGenericCell; namespace MeshLib { - class Element; - class Node; + class Element; + class Node; } namespace InSituLib @@ -32,42 +32,42 @@ namespace InSituLib class VtkMappedMeshImpl : public vtkObject { public: - static VtkMappedMeshImpl *New(); - virtual void PrintSelf(std::ostream &os, vtkIndent indent); - vtkTypeMacro(VtkMappedMeshImpl, vtkObject) + static VtkMappedMeshImpl *New(); + virtual void PrintSelf(std::ostream &os, vtkIndent indent); + vtkTypeMacro(VtkMappedMeshImpl, vtkObject) - void SetNodes(std::vector<MeshLib::Node*> const & nodes); - void SetElements(std::vector<MeshLib::Element*> const & elements); + void SetNodes(std::vector<MeshLib::Node*> const & nodes); + void SetElements(std::vector<MeshLib::Element*> const & elements); - // API for vtkMappedUnstructuredGrid's implementation - vtkIdType GetNumberOfCells(); - int GetCellType(vtkIdType cellId); - void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds); - void GetPointCells(vtkIdType ptId, vtkIdList *cellIds); - int GetMaxCellSize(); - void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array); - int IsHomogeneous(); + // API for vtkMappedUnstructuredGrid's implementation + vtkIdType GetNumberOfCells(); + int GetCellType(vtkIdType cellId); + void GetCellPoints(vtkIdType cellId, vtkIdList *ptIds); + void GetPointCells(vtkIdType ptId, vtkIdList *cellIds); + int GetMaxCellSize(); + void GetIdsOfCellsOfType(int type, vtkIdTypeArray *array); + int IsHomogeneous(); - // This container is read only -- these methods do nothing but print a warning. - void Allocate(vtkIdType numCells, int extSize = 1000); - vtkIdType InsertNextCell(int type, vtkIdList *ptIds); - vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds); - vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds, - vtkIdType nfaces, vtkIdType *faces); - void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts); + // This container is read only -- these methods do nothing but print a warning. + void Allocate(vtkIdType numCells, int extSize = 1000); + vtkIdType InsertNextCell(int type, vtkIdList *ptIds); + vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds); + vtkIdType InsertNextCell(int type, vtkIdType npts, vtkIdType *ptIds, + vtkIdType nfaces, vtkIdType *faces); + void ReplaceCell(vtkIdType cellId, int npts, vtkIdType *pts); protected: - VtkMappedMeshImpl(); - ~VtkMappedMeshImpl(); + VtkMappedMeshImpl(); + ~VtkMappedMeshImpl(); private: - VtkMappedMeshImpl(const VtkMappedMeshImpl &); // Not implemented. - void operator=(const VtkMappedMeshImpl &); // Not implemented. + VtkMappedMeshImpl(const VtkMappedMeshImpl &); // Not implemented. + void operator=(const VtkMappedMeshImpl &); // Not implemented. - // const MeshLib::Mesh* _mesh; - const std::vector<MeshLib::Node*>* _nodes; - const std::vector<MeshLib::Element*>* _elements; - vtkIdType NumberOfCells; + // const MeshLib::Mesh* _mesh; + const std::vector<MeshLib::Node*>* _nodes; + const std::vector<MeshLib::Element*>* _elements; + vtkIdType NumberOfCells; }; vtkMakeMappedUnstructuredGrid(VtkMappedMesh, VtkMappedMeshImpl) diff --git a/InSituLib/VtkMappedMeshSource.cpp b/InSituLib/VtkMappedMeshSource.cpp index 05a07e5f644c517488026cd8dc424de95a9cf54c..47ed8c52b8e4a69e1c9f16e0654340a0e560a9ce 100644 --- a/InSituLib/VtkMappedMeshSource.cpp +++ b/InSituLib/VtkMappedMeshSource.cpp @@ -28,15 +28,15 @@ vtkStandardNewMacro(VtkMappedMeshSource) void VtkMappedMeshSource::PrintSelf(ostream &os, vtkIndent indent) { - this->Superclass::PrintSelf(os, indent); - os << indent << "Mesh: " << (_mesh ? _mesh->getName() : "(none)") << endl; + this->Superclass::PrintSelf(os, indent); + os << indent << "Mesh: " << (_mesh ? _mesh->getName() : "(none)") << endl; } VtkMappedMeshSource::VtkMappedMeshSource() : NumberOfDimensions(0), NumberOfNodes(0) { - this->SetNumberOfInputPorts(0); + this->SetNumberOfInputPorts(0); } VtkMappedMeshSource::~VtkMappedMeshSource() @@ -45,75 +45,75 @@ VtkMappedMeshSource::~VtkMappedMeshSource() } int VtkMappedMeshSource::ProcessRequest( - vtkInformation *request, vtkInformationVector **inputVector, - vtkInformationVector *outputVector) + vtkInformation *request, vtkInformationVector **inputVector, + vtkInformationVector *outputVector) { - if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) - return this->RequestData(request, inputVector, outputVector); + if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA())) + return this->RequestData(request, inputVector, outputVector); - if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) - return this->RequestInformation(request, inputVector, outputVector); + if(request->Has(vtkDemandDrivenPipeline::REQUEST_INFORMATION())) + return this->RequestInformation(request, inputVector, outputVector); - return this->Superclass::ProcessRequest(request, inputVector, outputVector); + return this->Superclass::ProcessRequest(request, inputVector, outputVector); } int VtkMappedMeshSource::RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *outputVector) { - vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); - vtkSmartPointer<vtkUnstructuredGrid> output = vtkUnstructuredGrid::SafeDownCast( - outInfo->Get(vtkDataObject::DATA_OBJECT())); - - 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()); - - // Use the mapped point container for the block points - elems->SetPoints(this->Points.GetPointer()); - - output->Allocate(elems->GetNumberOfCells()); - output->ShallowCopy(elems.GetPointer()); - - // Arrays - MeshLib::Properties const & properties = _mesh->getProperties(); - std::vector<std::string> const& propertyNames = properties.getPropertyVectorNames(); - - for(std::vector<std::string>::const_iterator name = propertyNames.cbegin(); name != propertyNames.cend(); ++name) - { - if (addProperty<double>(properties, *name)) continue; - if (addProperty<int>(properties, *name)) continue; - if (addProperty<unsigned>(properties, *name)) continue; - if (addProperty<std::size_t>(properties, *name)) continue; - if (addProperty<char>(properties, *name)) continue; - - 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; + vtkSmartPointer<vtkInformation> outInfo = outputVector->GetInformationObject(0); + vtkSmartPointer<vtkUnstructuredGrid> output = vtkUnstructuredGrid::SafeDownCast( + outInfo->Get(vtkDataObject::DATA_OBJECT())); + + 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()); + + // Use the mapped point container for the block points + elems->SetPoints(this->Points.GetPointer()); + + output->Allocate(elems->GetNumberOfCells()); + output->ShallowCopy(elems.GetPointer()); + + // Arrays + MeshLib::Properties const & properties = _mesh->getProperties(); + std::vector<std::string> const& propertyNames = properties.getPropertyVectorNames(); + + for(std::vector<std::string>::const_iterator name = propertyNames.cbegin(); name != propertyNames.cend(); ++name) + { + if (addProperty<double>(properties, *name)) continue; + if (addProperty<int>(properties, *name)) continue; + if (addProperty<unsigned>(properties, *name)) continue; + if (addProperty<std::size_t>(properties, *name)) continue; + if (addProperty<char>(properties, *name)) continue; + + 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; } int VtkMappedMeshSource::RequestInformation( - vtkInformation *, vtkInformationVector **, vtkInformationVector *) + vtkInformation *, vtkInformationVector **, vtkInformationVector *) { - this->NumberOfDimensions = 3; - this->NumberOfNodes = _mesh->getNNodes(); + this->NumberOfDimensions = 3; + this->NumberOfNodes = _mesh->getNNodes(); - return 1; + return 1; } } // Namespace InSituLib diff --git a/InSituLib/VtkMappedMeshSource.h b/InSituLib/VtkMappedMeshSource.h index f25893451e1a162ed36de6abd5e940180bdfc3c6..98116bdcd8b649473077d06b7103550884fc0f7d 100644 --- a/InSituLib/VtkMappedMeshSource.h +++ b/InSituLib/VtkMappedMeshSource.h @@ -43,8 +43,8 @@ class vtkDataArrayCollection; class vtkPointData; class vtkPoints; namespace MeshLib { - class Mesh; - class Properties; + class Mesh; + class Properties; } namespace InSituLib { @@ -54,65 +54,65 @@ namespace InSituLib { class VtkMappedMeshSource : public vtkUnstructuredGridAlgorithm { public: - static VtkMappedMeshSource *New(); - vtkTypeMacro(VtkMappedMeshSource, vtkUnstructuredGridAlgorithm) - virtual void PrintSelf(std::ostream &os, vtkIndent indent); + static VtkMappedMeshSource *New(); + 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(); } + /// 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; } + /// Returns the mesh. + const MeshLib::Mesh* GetMesh() const { return _mesh; } protected: - VtkMappedMeshSource(); - ~VtkMappedMeshSource(); + VtkMappedMeshSource(); + ~VtkMappedMeshSource(); - int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, - vtkInformationVector *outputVector); - int RequestData(vtkInformation *, vtkInformationVector **, - vtkInformationVector *); - int RequestInformation(vtkInformation *, vtkInformationVector **, - vtkInformationVector *); + int ProcessRequest(vtkInformation *request, vtkInformationVector **inputVector, + vtkInformationVector *outputVector); + int RequestData(vtkInformation *, vtkInformationVector **, + vtkInformationVector *); + int RequestInformation(vtkInformation *, vtkInformationVector **, + vtkInformationVector *); 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 MeshLib::Properties object - /// \param prop_name The name of the property vector to be mapped from - /// vtk-mesh to ogs-mesh - template <typename T> - bool addProperty(MeshLib::Properties const& properties, - std::string const& prop_name) const - { - boost::optional<MeshLib::PropertyVector<T> const &> propertyVector( - properties.getPropertyVector<T>(prop_name)); - if(!propertyVector) - return false; - - vtkNew<VtkMappedPropertyVectorTemplate<T> > dataArray; - dataArray->SetPropertyVector(const_cast<MeshLib::PropertyVector<T> &>(*propertyVector)); - dataArray->SetName(prop_name.c_str()); - - if(propertyVector->getMeshItemType() == MeshLib::MeshItemType::Node) - this->PointData->AddArray(dataArray.GetPointer()); - else if(propertyVector->getMeshItemType() == MeshLib::MeshItemType::Cell) - this->CellData->AddArray(dataArray.GetPointer()); - - return true; - } - - const MeshLib::Mesh* _mesh; - - int NumberOfDimensions; - int NumberOfNodes; - - vtkNew<vtkPoints> Points; - vtkNew<vtkPointData> PointData; - vtkNew<vtkCellData> CellData; + 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 MeshLib::Properties object + /// \param prop_name The name of the property vector to be mapped from + /// vtk-mesh to ogs-mesh + template <typename T> + bool addProperty(MeshLib::Properties const& properties, + std::string const& prop_name) const + { + boost::optional<MeshLib::PropertyVector<T> const &> propertyVector( + properties.getPropertyVector<T>(prop_name)); + if(!propertyVector) + return false; + + vtkNew<VtkMappedPropertyVectorTemplate<T> > dataArray; + dataArray->SetPropertyVector(const_cast<MeshLib::PropertyVector<T> &>(*propertyVector)); + dataArray->SetName(prop_name.c_str()); + + if(propertyVector->getMeshItemType() == MeshLib::MeshItemType::Node) + this->PointData->AddArray(dataArray.GetPointer()); + else if(propertyVector->getMeshItemType() == MeshLib::MeshItemType::Cell) + this->CellData->AddArray(dataArray.GetPointer()); + + return true; + } + + const MeshLib::Mesh* _mesh; + + int NumberOfDimensions; + int NumberOfNodes; + + vtkNew<vtkPoints> Points; + vtkNew<vtkPointData> PointData; + vtkNew<vtkCellData> CellData; }; } // Namespace InSituLib diff --git a/InSituLib/VtkMappedPropertyVectorTemplate-impl.h b/InSituLib/VtkMappedPropertyVectorTemplate-impl.h index 7a672b231b007f849b0bac2a95e212cbefb309d6..54fcf31ff7906d5c227bb702a5ec9ffc97e462da 100644 --- a/InSituLib/VtkMappedPropertyVectorTemplate-impl.h +++ b/InSituLib/VtkMappedPropertyVectorTemplate-impl.h @@ -25,297 +25,297 @@ namespace InSituLib { template <class Scalar> VtkMappedPropertyVectorTemplate<Scalar> * VtkMappedPropertyVectorTemplate<Scalar>::New() { - VTK_STANDARD_NEW_BODY(VtkMappedPropertyVectorTemplate<Scalar>) + VTK_STANDARD_NEW_BODY(VtkMappedPropertyVectorTemplate<Scalar>) } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::PrintSelf(ostream &os, vtkIndent indent) { - this->VtkMappedPropertyVectorTemplate<Scalar>::Superclass::PrintSelf( - os, indent); + this->VtkMappedPropertyVectorTemplate<Scalar>::Superclass::PrintSelf( + os, indent); } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetPropertyVector(MeshLib::PropertyVector<Scalar> & propertyVector) { - this->Initialize(); - _propertyVector = &propertyVector; - this->NumberOfComponents = _propertyVector->getNumberOfComponents(); - this->Size = this->NumberOfComponents * _propertyVector->getNumberOfTuples(); - this->MaxId = this->Size - 1; - this->Modified(); + this->Initialize(); + _propertyVector = &propertyVector; + this->NumberOfComponents = _propertyVector->getNumberOfComponents(); + this->Size = this->NumberOfComponents * _propertyVector->getNumberOfTuples(); + this->MaxId = this->Size - 1; + this->Modified(); } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetPropertyVector(MeshLib::PropertyVector<Scalar> & propertyVector, bool save) { - this->SetPropertyVector(propertyVector); - this->Save = save; + this->SetPropertyVector(propertyVector); + this->Save = save; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::Initialize() { - this->MaxId = -1; - this->Size = 0; - this->NumberOfComponents = 1; - // per default property vector deletion is managed elsewhere - this->Save = true; + this->MaxId = -1; + this->Size = 0; + this->NumberOfComponents = 1; + // per default property vector deletion is managed elsewhere + this->Save = true; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::GetTuples(vtkIdList *ptIds, vtkAbstractArray *output) { - vtkDataArray *da = vtkDataArray::FastDownCast(output); - if (!da) - { - WARN("VtkMappedElementDataArrayTemplate::GetTuples(): Input is not a vtkDataArray"); - return; - } + vtkDataArray *da = vtkDataArray::FastDownCast(output); + if (!da) + { + WARN("VtkMappedElementDataArrayTemplate::GetTuples(): Input is not a vtkDataArray"); + return; + } - if (da->GetNumberOfComponents() != this->GetNumberOfComponents()) - { - WARN("VtkMappedElementDataArrayTemplate::GetTuples(): Incorrect number of components in input array."); - return; - } + if (da->GetNumberOfComponents() != this->GetNumberOfComponents()) + { + WARN("VtkMappedElementDataArrayTemplate::GetTuples(): Incorrect number of components in input array."); + return; + } - const vtkIdType numPoints = ptIds->GetNumberOfIds(); - for (vtkIdType i = 0; i < numPoints; ++i) - { - da->SetTuple(i, this->GetTuple(ptIds->GetId(i))); - } + const vtkIdType numPoints = ptIds->GetNumberOfIds(); + for (vtkIdType i = 0; i < numPoints; ++i) + { + da->SetTuple(i, this->GetTuple(ptIds->GetId(i))); + } } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) { - vtkDataArray *da = vtkDataArray::FastDownCast(output); - if (!da) - { - vtkErrorMacro(<<"Input is not a vtkDataArray"); - return; - } + vtkDataArray *da = vtkDataArray::FastDownCast(output); + if (!da) + { + vtkErrorMacro(<<"Input is not a vtkDataArray"); + return; + } - if (da->GetNumberOfComponents() != this->GetNumberOfComponents()) - { - vtkErrorMacro(<<"Incorrect number of components in input array."); - return; - } + if (da->GetNumberOfComponents() != this->GetNumberOfComponents()) + { + vtkErrorMacro(<<"Incorrect number of components in input array."); + return; + } - for (vtkIdType daTupleId = 0; p1 <= p2; ++p1) - { - da->SetTuple(daTupleId++, this->GetTuple(p1)); - } + for (vtkIdType daTupleId = 0; p1 <= p2; ++p1) + { + da->SetTuple(daTupleId++, this->GetTuple(p1)); + } } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::Squeeze() { - // noop + // noop } //------------------------------------------------------------------------------ template <class Scalar> vtkArrayIterator* VtkMappedPropertyVectorTemplate<Scalar>::NewIterator() { - vtkErrorMacro(<<"Not implemented."); - return nullptr; + vtkErrorMacro(<<"Not implemented."); + return nullptr; } //------------------------------------------------------------------------------ template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::LookupValue(vtkVariant value) { - bool valid = true; - Scalar val = vtkVariantCast<Scalar>(value, &valid); - if (valid) - { - return this->Lookup(val, 0); - } - return -1; + bool valid = true; + Scalar val = vtkVariantCast<Scalar>(value, &valid); + if (valid) + { + return this->Lookup(val, 0); + } + return -1; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::LookupValue(vtkVariant value, vtkIdList *ids) { - bool valid = true; - Scalar val = vtkVariantCast<Scalar>(value, &valid); - ids->Reset(); - if (valid) - { - vtkIdType index = 0; - while ((index = this->Lookup(val, index)) >= 0) - { - ids->InsertNextId(index); - ++index; - } - } + bool valid = true; + Scalar val = vtkVariantCast<Scalar>(value, &valid); + ids->Reset(); + if (valid) + { + vtkIdType index = 0; + while ((index = this->Lookup(val, index)) >= 0) + { + ids->InsertNextId(index); + ++index; + } + } } //------------------------------------------------------------------------------ template <class Scalar> vtkVariant VtkMappedPropertyVectorTemplate<Scalar> ::GetVariantValue(vtkIdType idx) { - return vtkVariant(this->GetValueReference(idx)); + return vtkVariant(this->GetValueReference(idx)); } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::ClearLookup() { - // no-op, no fast lookup implemented. + // no-op, no fast lookup implemented. } //------------------------------------------------------------------------------ template <class Scalar> double* VtkMappedPropertyVectorTemplate<Scalar> ::GetTuple(vtkIdType i) { - this->TempDouble = (*this->_propertyVector)[i]; - return &this->TempDouble; + this->TempDouble = (*this->_propertyVector)[i]; + return &this->TempDouble; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::GetTuple(vtkIdType i, double *tuple) { - *tuple = (*this->_propertyVector)[i]; + *tuple = (*this->_propertyVector)[i]; } //------------------------------------------------------------------------------ template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::LookupTypedValue(Scalar value) { - return this->Lookup(value, 0); + return this->Lookup(value, 0); } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::LookupTypedValue(Scalar value, vtkIdList *ids) { - ids->Reset(); - vtkIdType index = 0; - while ((index = this->Lookup(value, index)) >= 0) - { - ids->InsertNextId(index); - ++index; - } + ids->Reset(); + vtkIdType index = 0; + while ((index = this->Lookup(value, index)) >= 0) + { + ids->InsertNextId(index); + ++index; + } } //------------------------------------------------------------------------------ template <class Scalar> Scalar VtkMappedPropertyVectorTemplate<Scalar> ::GetValue(vtkIdType idx) { - return (*this->_propertyVector)[idx]; + return (*this->_propertyVector)[idx]; } //------------------------------------------------------------------------------ template <class Scalar> Scalar& VtkMappedPropertyVectorTemplate<Scalar> ::GetValueReference(vtkIdType idx) { - // VTK has no concept of 'const', so we'll just cross our fingers - // that no one writes to the returned reference. - Scalar& value = const_cast<Scalar&>((*this->_propertyVector)[idx]); - return value; + // VTK has no concept of 'const', so we'll just cross our fingers + // that no one writes to the returned reference. + Scalar& value = const_cast<Scalar&>((*this->_propertyVector)[idx]); + return value; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::GetTupleValue(vtkIdType tupleId, Scalar *tuple) { - *tuple = (*this->_propertyVector)[tupleId]; + *tuple = (*this->_propertyVector)[tupleId]; } //------------------------------------------------------------------------------ template <class Scalar> int VtkMappedPropertyVectorTemplate<Scalar> ::Allocate(vtkIdType, vtkIdType) { - vtkErrorMacro("Read only container.") - return 0; + vtkErrorMacro("Read only container.") + return 0; } //------------------------------------------------------------------------------ template <class Scalar> int VtkMappedPropertyVectorTemplate<Scalar> ::Resize(vtkIdType) { - vtkErrorMacro("Read only container.") - return 0; + vtkErrorMacro("Read only container.") + return 0; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetNumberOfTuples(vtkIdType) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetTuple(vtkIdType, vtkIdType, vtkAbstractArray *) { - vtkErrorMacro("Read only container.")} + vtkErrorMacro("Read only container.")} //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetTuple(vtkIdType, const float *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetTuple(vtkIdType, const double *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertTuple(vtkIdType, vtkIdType, vtkAbstractArray *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertTuple(vtkIdType, const float *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertTuple(vtkIdType, const double *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertTuples(vtkIdList *, vtkIdList *, vtkAbstractArray *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertTuples(vtkIdType, vtkIdType, vtkIdType, vtkAbstractArray*) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::InsertNextTuple(vtkIdType, vtkAbstractArray *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } //------------------------------------------------------------------------------ @@ -323,124 +323,124 @@ template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::InsertNextTuple(const float *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } //------------------------------------------------------------------------------ template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::InsertNextTuple(const double *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::DeepCopy(vtkAbstractArray *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::DeepCopy(vtkDataArray *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InterpolateTuple(vtkIdType, vtkIdList *, vtkAbstractArray *, double *) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InterpolateTuple(vtkIdType, vtkIdType, vtkAbstractArray*, vtkIdType, - vtkAbstractArray*, double) + vtkAbstractArray*, double) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetVariantValue(vtkIdType, vtkVariant) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::RemoveTuple(vtkIdType) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::RemoveFirstTuple() { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::RemoveLastTuple() { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetTupleValue(vtkIdType, const Scalar*) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertTupleValue(vtkIdType, const Scalar*) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::InsertNextTupleValue(const Scalar *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::SetValue(vtkIdType, Scalar) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::InsertNextValue(Scalar) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertValue(vtkIdType, Scalar) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ template <class Scalar> void VtkMappedPropertyVectorTemplate<Scalar> ::InsertVariantValue(vtkIdType /*idx*/, vtkVariant /*value*/) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } //------------------------------------------------------------------------------ @@ -461,14 +461,14 @@ template <class Scalar> VtkMappedPropertyVectorTemplate<Scalar> template <class Scalar> vtkIdType VtkMappedPropertyVectorTemplate<Scalar> ::Lookup(const Scalar &val, vtkIdType index) { - while (index <= this->MaxId) - { - if (this->GetValueReference(index++) == val) - { - return index; - } - } - return -1; + while (index <= this->MaxId) + { + if (this->GetValueReference(index++) == val) + { + return index; + } + } + return -1; } } // end namespace InSituLib diff --git a/InSituLib/VtkMappedPropertyVectorTemplate.h b/InSituLib/VtkMappedPropertyVectorTemplate.h index 3f003fb098aa160f072d0fdccac8ba673cbf6fb5..77fbc650a81df7252262ad020d5447a3bb0384e2 100644 --- a/InSituLib/VtkMappedPropertyVectorTemplate.h +++ b/InSituLib/VtkMappedPropertyVectorTemplate.h @@ -26,90 +26,90 @@ namespace InSituLib { template <class Scalar> class VtkMappedPropertyVectorTemplate : - public vtkTypeTemplate<VtkMappedPropertyVectorTemplate<Scalar>, - vtkMappedDataArray<Scalar> > + public vtkTypeTemplate<VtkMappedPropertyVectorTemplate<Scalar>, + vtkMappedDataArray<Scalar> > { public: - vtkMappedDataArrayNewInstanceMacro(VtkMappedPropertyVectorTemplate<Scalar>) - static VtkMappedPropertyVectorTemplate *New(); - virtual void PrintSelf(std::ostream &os, vtkIndent indent); + vtkMappedDataArrayNewInstanceMacro(VtkMappedPropertyVectorTemplate<Scalar>) + static VtkMappedPropertyVectorTemplate *New(); + virtual void PrintSelf(std::ostream &os, vtkIndent indent); - // Description: - // Set the raw scalar arrays for the coordinate set. - void SetPropertyVector(MeshLib::PropertyVector<Scalar> & propertyVector); - void SetPropertyVector(MeshLib::PropertyVector<Scalar> & propertyVector, bool save); + // Description: + // Set the raw scalar arrays for the coordinate set. + void SetPropertyVector(MeshLib::PropertyVector<Scalar> & propertyVector); + void SetPropertyVector(MeshLib::PropertyVector<Scalar> & propertyVector, bool save); - // Reimplemented virtuals -- see superclasses for descriptions: - void Initialize(); - void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); - void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); - void Squeeze(); - vtkArrayIterator *NewIterator(); - vtkIdType LookupValue(vtkVariant value); - void LookupValue(vtkVariant value, vtkIdList *ids); - vtkVariant GetVariantValue(vtkIdType idx); - void ClearLookup(); - double* GetTuple(vtkIdType i); - void GetTuple(vtkIdType i, double *tuple); - vtkIdType LookupTypedValue(Scalar value); - void LookupTypedValue(Scalar value, vtkIdList *ids); - Scalar GetValue(vtkIdType idx); - Scalar& GetValueReference(vtkIdType idx); - void GetTupleValue(vtkIdType idx, Scalar *t); + // Reimplemented virtuals -- see superclasses for descriptions: + void Initialize(); + void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); + void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); + void Squeeze(); + vtkArrayIterator *NewIterator(); + vtkIdType LookupValue(vtkVariant value); + void LookupValue(vtkVariant value, vtkIdList *ids); + vtkVariant GetVariantValue(vtkIdType idx); + void ClearLookup(); + double* GetTuple(vtkIdType i); + void GetTuple(vtkIdType i, double *tuple); + vtkIdType LookupTypedValue(Scalar value); + void LookupTypedValue(Scalar value, vtkIdList *ids); + Scalar GetValue(vtkIdType idx); + Scalar& GetValueReference(vtkIdType idx); + void GetTupleValue(vtkIdType idx, Scalar *t); - // Description: - // This container is read only -- this method does nothing but print a - // warning. - int Allocate(vtkIdType sz, vtkIdType ext); - int Resize(vtkIdType numTuples); - void SetNumberOfTuples(vtkIdType number); - void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); - void SetTuple(vtkIdType i, const float *source); - void SetTuple(vtkIdType i, const double *source); - void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); - void InsertTuple(vtkIdType i, const float *source); - void InsertTuple(vtkIdType i, const double *source); - void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, - vtkAbstractArray *source); - void InsertTuples(vtkIdType, vtkIdType, vtkIdType, vtkAbstractArray*); - vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source); - vtkIdType InsertNextTuple(const float *source); - vtkIdType InsertNextTuple(const double *source); - void InsertVariantValue(vtkIdType idx, vtkVariant value); - void DeepCopy(vtkAbstractArray *aa); - void DeepCopy(vtkDataArray *da); - void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, - vtkAbstractArray* source, double* weights); - void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1, - vtkIdType id2, vtkAbstractArray *source2, double t); - void SetVariantValue(vtkIdType idx, vtkVariant value); - void RemoveTuple(vtkIdType id); - void RemoveFirstTuple(); - void RemoveLastTuple(); - void SetTupleValue(vtkIdType i, const Scalar *t); - void InsertTupleValue(vtkIdType i, const Scalar *t); - vtkIdType InsertNextTupleValue(const Scalar *t); - void SetValue(vtkIdType idx, Scalar value); - vtkIdType InsertNextValue(Scalar v); - void InsertValue(vtkIdType idx, Scalar v); + // Description: + // This container is read only -- this method does nothing but print a + // warning. + int Allocate(vtkIdType sz, vtkIdType ext); + int Resize(vtkIdType numTuples); + void SetNumberOfTuples(vtkIdType number); + void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); + void SetTuple(vtkIdType i, const float *source); + void SetTuple(vtkIdType i, const double *source); + void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); + void InsertTuple(vtkIdType i, const float *source); + void InsertTuple(vtkIdType i, const double *source); + void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, + vtkAbstractArray *source); + void InsertTuples(vtkIdType, vtkIdType, vtkIdType, vtkAbstractArray*); + vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source); + vtkIdType InsertNextTuple(const float *source); + vtkIdType InsertNextTuple(const double *source); + void InsertVariantValue(vtkIdType idx, vtkVariant value); + void DeepCopy(vtkAbstractArray *aa); + void DeepCopy(vtkDataArray *da); + void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, + vtkAbstractArray* source, double* weights); + void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1, + vtkIdType id2, vtkAbstractArray *source2, double t); + void SetVariantValue(vtkIdType idx, vtkVariant value); + void RemoveTuple(vtkIdType id); + void RemoveFirstTuple(); + void RemoveLastTuple(); + void SetTupleValue(vtkIdType i, const Scalar *t); + void InsertTupleValue(vtkIdType i, const Scalar *t); + vtkIdType InsertNextTupleValue(const Scalar *t); + void SetValue(vtkIdType idx, Scalar value); + vtkIdType InsertNextValue(Scalar v); + void InsertValue(vtkIdType idx, Scalar v); protected: - VtkMappedPropertyVectorTemplate(); - ~VtkMappedPropertyVectorTemplate(); + VtkMappedPropertyVectorTemplate(); + ~VtkMappedPropertyVectorTemplate(); - MeshLib::PropertyVector<Scalar> * _propertyVector; + MeshLib::PropertyVector<Scalar> * _propertyVector; private: - VtkMappedPropertyVectorTemplate( - const VtkMappedPropertyVectorTemplate &); // Not implemented. - void operator=( - const VtkMappedPropertyVectorTemplate &); // Not implemented. + VtkMappedPropertyVectorTemplate( + const VtkMappedPropertyVectorTemplate &); // Not implemented. + void operator=( + const VtkMappedPropertyVectorTemplate &); // Not implemented. - vtkIdType Lookup(const Scalar &val, vtkIdType startIndex); - double TempDouble; - // Description: If Save is true then this class won't delete that memory. - // By default Save is false. - bool Save; + vtkIdType Lookup(const Scalar &val, vtkIdType startIndex); + double TempDouble; + // Description: If Save is true then this class won't delete that memory. + // By default Save is false. + bool Save; }; } // end namespace InSituLib diff --git a/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h b/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h index 1718c3a73253b977843f22fe5a1daa511c7ffdd4..f308af44c82d99667eff608743e69e9882ccf073 100644 --- a/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h +++ b/InSituLib/VtkMeshNodalCoordinatesTemplate-impl.h @@ -27,81 +27,81 @@ namespace InSituLib { template <class Scalar> VtkMeshNodalCoordinatesTemplate<Scalar> * VtkMeshNodalCoordinatesTemplate<Scalar>::New() { - VTK_STANDARD_NEW_BODY(VtkMeshNodalCoordinatesTemplate<Scalar>) + VTK_STANDARD_NEW_BODY(VtkMeshNodalCoordinatesTemplate<Scalar>) } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::PrintSelf(ostream &os, vtkIndent indent) { - this->VtkMeshNodalCoordinatesTemplate<Scalar>::Superclass::PrintSelf( - os, indent); - //os << indent << "XArray: " << this->XArray << std::endl; - //os << indent << "YArray: " << this->YArray << std::endl; - //os << indent << "ZArray: " << this->ZArray << std::endl; - //os << indent << "TempDoubleArray: " << this->TempDoubleArray << std::endl; + this->VtkMeshNodalCoordinatesTemplate<Scalar>::Superclass::PrintSelf( + os, indent); + //os << indent << "XArray: " << this->XArray << std::endl; + //os << indent << "YArray: " << this->YArray << std::endl; + //os << indent << "ZArray: " << this->ZArray << std::endl; + //os << indent << "TempDoubleArray: " << this->TempDoubleArray << std::endl; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::Initialize() { - this->_nodes = NULL; - delete [] this->TempDoubleArray; - this->TempDoubleArray = NULL; - this->MaxId = -1; - this->Size = 0; - this->NumberOfComponents = 1; + this->_nodes = NULL; + delete [] this->TempDoubleArray; + this->TempDoubleArray = NULL; + this->MaxId = -1; + this->Size = 0; + this->NumberOfComponents = 1; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetNodes(std::vector<MeshLib::Node*> const & nodes) { - Initialize(); - _nodes = &nodes; - this->NumberOfComponents = 3; - this->Size = this->NumberOfComponents * _nodes->size(); - this->MaxId = this->Size - 1; - this->TempDoubleArray = new double [this->NumberOfComponents]; - this->Modified(); + Initialize(); + _nodes = &nodes; + this->NumberOfComponents = 3; + this->Size = this->NumberOfComponents * _nodes->size(); + this->MaxId = this->Size - 1; + this->TempDoubleArray = new double [this->NumberOfComponents]; + this->Modified(); } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::GetTuples(vtkIdList *ptIds, vtkAbstractArray *output) { - vtkDataArray *outArray = vtkDataArray::FastDownCast(output); - if(!outArray) - { - vtkWarningMacro(<<"Input is not a vtkDataArray"); - return; - } + vtkDataArray *outArray = vtkDataArray::FastDownCast(output); + if(!outArray) + { + vtkWarningMacro(<<"Input is not a vtkDataArray"); + return; + } - const vtkIdType numTuples = ptIds->GetNumberOfIds(); + const vtkIdType numTuples = ptIds->GetNumberOfIds(); - outArray->SetNumberOfComponents(this->NumberOfComponents); - outArray->SetNumberOfTuples(numTuples); + outArray->SetNumberOfComponents(this->NumberOfComponents); + outArray->SetNumberOfTuples(numTuples); - const vtkIdType numPoints = ptIds->GetNumberOfIds(); - for(vtkIdType i = 0; i < numPoints; i++) - outArray->SetTuple(i, this->GetTuple(ptIds->GetId(i))); + const vtkIdType numPoints = ptIds->GetNumberOfIds(); + for(vtkIdType i = 0; i < numPoints; i++) + outArray->SetTuple(i, this->GetTuple(ptIds->GetId(i))); } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output) { - vtkDataArray *da = vtkDataArray::FastDownCast(output); - if(!da) - { - vtkWarningMacro(<<"Input is not a vtkDataArray"); - return; - } + vtkDataArray *da = vtkDataArray::FastDownCast(output); + if(!da) + { + vtkWarningMacro(<<"Input is not a vtkDataArray"); + return; + } - if(da->GetNumberOfComponents() != this->GetNumberOfComponents()) - { - vtkErrorMacro(<<"Incorrect number of components in input array."); - return; - } + if(da->GetNumberOfComponents() != this->GetNumberOfComponents()) + { + vtkErrorMacro(<<"Incorrect number of components in input array."); + return; + } - for(vtkIdType daTubleId = 0; p1 <= p2; ++p1) - da->SetTuple(daTubleId++, this->GetTuple(p1)); + for(vtkIdType daTubleId = 0; p1 <= p2; ++p1) + da->SetTuple(daTubleId++, this->GetTuple(p1)); } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> @@ -113,304 +113,304 @@ template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> template <class Scalar> vtkArrayIterator* VtkMeshNodalCoordinatesTemplate<Scalar> ::NewIterator() { - vtkErrorMacro(<<"Not implemented."); - return NULL; + vtkErrorMacro(<<"Not implemented."); + return NULL; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::LookupValue(vtkVariant value) { - bool valid = true; - Scalar val = vtkVariantCast<Scalar>(value, &valid); - if(valid) - return this->Lookup(val, 0); - return -1; + bool valid = true; + Scalar val = vtkVariantCast<Scalar>(value, &valid); + if(valid) + return this->Lookup(val, 0); + return -1; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::LookupValue(vtkVariant value, vtkIdList *ids) { - bool valid = true; - Scalar val = vtkVariantCast<Scalar>(value, &valid); - ids->Reset(); - if(valid) - { - vtkIdType index = 0; - while((index = this->Lookup(val, index)) >= 0) - ids->InsertNextId(index++); - } + bool valid = true; + Scalar val = vtkVariantCast<Scalar>(value, &valid); + ids->Reset(); + if(valid) + { + vtkIdType index = 0; + while((index = this->Lookup(val, index)) >= 0) + ids->InsertNextId(index++); + } } template <class Scalar> vtkVariant VtkMeshNodalCoordinatesTemplate<Scalar> ::GetVariantValue(vtkIdType idx) { - return vtkVariant(this->GetValueReference(idx)); + return vtkVariant(this->GetValueReference(idx)); } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::ClearLookup() { - // no fast lookup implemented + // no fast lookup implemented } template <class Scalar> double* VtkMeshNodalCoordinatesTemplate<Scalar> ::GetTuple(vtkIdType i) { - this->GetTuple(i, this->TempDoubleArray); - return this->TempDoubleArray; + this->GetTuple(i, this->TempDoubleArray); + return this->TempDoubleArray; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::GetTuple(vtkIdType i, double *tuple) { - tuple[0] = (*(*this->_nodes)[i])[0]; - tuple[1] = (*(*this->_nodes)[i])[1]; - tuple[2] = (*(*this->_nodes)[i])[2]; + tuple[0] = (*(*this->_nodes)[i])[0]; + tuple[1] = (*(*this->_nodes)[i])[1]; + tuple[2] = (*(*this->_nodes)[i])[2]; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::LookupTypedValue(Scalar value) { - return this->Lookup(value, 0); + return this->Lookup(value, 0); } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::LookupTypedValue(Scalar value, vtkIdList *ids) { - ids->Reset(); - vtkIdType index = 0; - while((index = this->Lookup(value, index)) >= 0) - ids->InsertNextId(index++); + ids->Reset(); + vtkIdType index = 0; + while((index = this->Lookup(value, index)) >= 0) + ids->InsertNextId(index++); } template <class Scalar> Scalar VtkMeshNodalCoordinatesTemplate<Scalar> ::GetValue(vtkIdType idx) { - return this->GetValueReference(idx); + return this->GetValueReference(idx); } template <class Scalar> Scalar& VtkMeshNodalCoordinatesTemplate<Scalar> ::GetValueReference(vtkIdType idx) { - const vtkIdType tuple = idx / this->NumberOfComponents; - const vtkIdType comp = idx % this->NumberOfComponents; - return (*(*this->_nodes)[tuple])[comp]; + const vtkIdType tuple = idx / this->NumberOfComponents; + const vtkIdType comp = idx % this->NumberOfComponents; + return (*(*this->_nodes)[tuple])[comp]; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::GetTupleValue(vtkIdType tupleId, Scalar *tuple) { - tuple[0] = (*(*this->_nodes)[tupleId])[0]; - tuple[1] = (*(*this->_nodes)[tupleId])[1]; - tuple[2] = (*(*this->_nodes)[tupleId])[2]; + tuple[0] = (*(*this->_nodes)[tupleId])[0]; + tuple[1] = (*(*this->_nodes)[tupleId])[1]; + tuple[2] = (*(*this->_nodes)[tupleId])[2]; } template <class Scalar> int VtkMeshNodalCoordinatesTemplate<Scalar> ::Allocate(vtkIdType, vtkIdType) { - vtkErrorMacro("Read only container.") - return 0; + vtkErrorMacro("Read only container.") + return 0; } template <class Scalar> int VtkMeshNodalCoordinatesTemplate<Scalar> ::Resize(vtkIdType) { - vtkErrorMacro("Read only container.") - return 0; + vtkErrorMacro("Read only container.") + return 0; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetNumberOfTuples(vtkIdType) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetTuple(vtkIdType, vtkIdType, vtkAbstractArray *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetTuple(vtkIdType, const float *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetTuple(vtkIdType, const double *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertTuple(vtkIdType, vtkIdType, vtkAbstractArray *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertTuple(vtkIdType, const float *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertTuple(vtkIdType, const double *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertTuples(vtkIdList *, vtkIdList *, vtkAbstractArray *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertTuples(vtkIdType, vtkIdType, vtkIdType, vtkAbstractArray*) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertNextTuple(vtkIdType, vtkAbstractArray *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertNextTuple(const float *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertNextTuple(const double *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertVariantValue(vtkIdType /*idx*/, vtkVariant /*value*/) { - vtkErrorMacro("Read only container.") + vtkErrorMacro("Read only container.") } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::DeepCopy(vtkAbstractArray *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::DeepCopy(vtkDataArray *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InterpolateTuple(vtkIdType, vtkIdList *, vtkAbstractArray *, double *) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InterpolateTuple(vtkIdType, vtkIdType, vtkAbstractArray*, vtkIdType, - vtkAbstractArray*, double) + vtkAbstractArray*, double) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetVariantValue(vtkIdType, vtkVariant) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::RemoveTuple(vtkIdType) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::RemoveFirstTuple() { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::RemoveLastTuple() { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetTupleValue(vtkIdType, const Scalar*) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertTupleValue(vtkIdType, const Scalar*) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertNextTupleValue(const Scalar *) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::SetValue(vtkIdType, Scalar) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertNextValue(Scalar) { - vtkErrorMacro("Read only container.") - return -1; + vtkErrorMacro("Read only container.") + return -1; } template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> ::InsertValue(vtkIdType, Scalar) { - vtkErrorMacro("Read only container.") - return; + vtkErrorMacro("Read only container.") + return; } template <class Scalar> VtkMeshNodalCoordinatesTemplate<Scalar> ::VtkMeshNodalCoordinatesTemplate() - : _nodes(NULL), TempDoubleArray(NULL) + : _nodes(NULL), TempDoubleArray(NULL) { } @@ -418,18 +418,18 @@ template <class Scalar> VtkMeshNodalCoordinatesTemplate<Scalar> template <class Scalar> VtkMeshNodalCoordinatesTemplate<Scalar> ::~VtkMeshNodalCoordinatesTemplate() { - delete [] this->TempDoubleArray; + delete [] this->TempDoubleArray; } template <class Scalar> vtkIdType VtkMeshNodalCoordinatesTemplate<Scalar> ::Lookup(const Scalar &val, vtkIdType index) { - while(index <= this->MaxId) - { - if(this->GetValueReference(index++) == val) - return index; - } - return -1; + while(index <= this->MaxId) + { + if(this->GetValueReference(index++) == val) + return index; + } + return -1; } } // end namespace diff --git a/InSituLib/VtkMeshNodalCoordinatesTemplate.h b/InSituLib/VtkMeshNodalCoordinatesTemplate.h index bc8658d4181c9665cd6e7a51b3ab4d89b3bd88f6..eff4b21ef90330e990b604389f2d6a11cbe2af0b 100644 --- a/InSituLib/VtkMeshNodalCoordinatesTemplate.h +++ b/InSituLib/VtkMeshNodalCoordinatesTemplate.h @@ -22,7 +22,7 @@ namespace MeshLib { - class Node; + class Node; } namespace InSituLib @@ -30,85 +30,85 @@ namespace InSituLib template <class Scalar> class VtkMeshNodalCoordinatesTemplate: - public vtkTypeTemplate<VtkMeshNodalCoordinatesTemplate<Scalar>, - vtkMappedDataArray<Scalar> > + public vtkTypeTemplate<VtkMeshNodalCoordinatesTemplate<Scalar>, + vtkMappedDataArray<Scalar> > { public: - vtkMappedDataArrayNewInstanceMacro( - VtkMeshNodalCoordinatesTemplate<Scalar>) - static VtkMeshNodalCoordinatesTemplate *New(); - virtual void PrintSelf(std::ostream &os, vtkIndent indent); - - /// Pass the nodes from OGS mesh - void SetNodes(std::vector<MeshLib::Node*> const & nodes); - - // Reimplemented virtuals -- see superclasses for descriptions - void Initialize(); - void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); - void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); - void Squeeze(); - vtkArrayIterator *NewIterator(); - vtkIdType LookupValue(vtkVariant value); - void LookupValue(vtkVariant value, vtkIdList *ids); - vtkVariant GetVariantValue(vtkIdType idx); - void ClearLookup(); - double* GetTuple(vtkIdType i); - void GetTuple(vtkIdType i, double *tuple); - vtkIdType LookupTypedValue(Scalar value); - void LookupTypedValue(Scalar value, vtkIdList *ids); - Scalar GetValue(vtkIdType idx); - Scalar& GetValueReference(vtkIdType idx); - void GetTupleValue(vtkIdType idx, Scalar *t); - - // This container is read only -- this method does nothing but print a - // warning. - int Allocate(vtkIdType sz, vtkIdType ext); - int Resize(vtkIdType numTuples); - void SetNumberOfTuples(vtkIdType number); - void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); - void SetTuple(vtkIdType i, const float *source); - void SetTuple(vtkIdType i, const double *source); - void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); - void InsertTuple(vtkIdType i, const float *source); - void InsertTuple(vtkIdType i, const double *source); - void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, - vtkAbstractArray *source); - void InsertTuples(vtkIdType, vtkIdType, vtkIdType, vtkAbstractArray*); - vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source); - vtkIdType InsertNextTuple(const float *source); - vtkIdType InsertNextTuple(const double *source); - void InsertVariantValue(vtkIdType idx, vtkVariant value); - void DeepCopy(vtkAbstractArray *aa); - void DeepCopy(vtkDataArray *da); - void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, - vtkAbstractArray* source, double* weights); - void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1, - vtkIdType id2, vtkAbstractArray *source2, double t); - void SetVariantValue(vtkIdType idx, vtkVariant value); - void RemoveTuple(vtkIdType id); - void RemoveFirstTuple(); - void RemoveLastTuple(); - void SetTupleValue(vtkIdType i, const Scalar *t); - void InsertTupleValue(vtkIdType i, const Scalar *t); - vtkIdType InsertNextTupleValue(const Scalar *t); - void SetValue(vtkIdType idx, Scalar value); - vtkIdType InsertNextValue(Scalar v); - void InsertValue(vtkIdType idx, Scalar v); + vtkMappedDataArrayNewInstanceMacro( + VtkMeshNodalCoordinatesTemplate<Scalar>) + static VtkMeshNodalCoordinatesTemplate *New(); + virtual void PrintSelf(std::ostream &os, vtkIndent indent); + + /// Pass the nodes from OGS mesh + void SetNodes(std::vector<MeshLib::Node*> const & nodes); + + // Reimplemented virtuals -- see superclasses for descriptions + void Initialize(); + void GetTuples(vtkIdList *ptIds, vtkAbstractArray *output); + void GetTuples(vtkIdType p1, vtkIdType p2, vtkAbstractArray *output); + void Squeeze(); + vtkArrayIterator *NewIterator(); + vtkIdType LookupValue(vtkVariant value); + void LookupValue(vtkVariant value, vtkIdList *ids); + vtkVariant GetVariantValue(vtkIdType idx); + void ClearLookup(); + double* GetTuple(vtkIdType i); + void GetTuple(vtkIdType i, double *tuple); + vtkIdType LookupTypedValue(Scalar value); + void LookupTypedValue(Scalar value, vtkIdList *ids); + Scalar GetValue(vtkIdType idx); + Scalar& GetValueReference(vtkIdType idx); + void GetTupleValue(vtkIdType idx, Scalar *t); + + // This container is read only -- this method does nothing but print a + // warning. + int Allocate(vtkIdType sz, vtkIdType ext); + int Resize(vtkIdType numTuples); + void SetNumberOfTuples(vtkIdType number); + void SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); + void SetTuple(vtkIdType i, const float *source); + void SetTuple(vtkIdType i, const double *source); + void InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source); + void InsertTuple(vtkIdType i, const float *source); + void InsertTuple(vtkIdType i, const double *source); + void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, + vtkAbstractArray *source); + void InsertTuples(vtkIdType, vtkIdType, vtkIdType, vtkAbstractArray*); + vtkIdType InsertNextTuple(vtkIdType j, vtkAbstractArray *source); + vtkIdType InsertNextTuple(const float *source); + vtkIdType InsertNextTuple(const double *source); + void InsertVariantValue(vtkIdType idx, vtkVariant value); + void DeepCopy(vtkAbstractArray *aa); + void DeepCopy(vtkDataArray *da); + void InterpolateTuple(vtkIdType i, vtkIdList *ptIndices, + vtkAbstractArray* source, double* weights); + void InterpolateTuple(vtkIdType i, vtkIdType id1, vtkAbstractArray *source1, + vtkIdType id2, vtkAbstractArray *source2, double t); + void SetVariantValue(vtkIdType idx, vtkVariant value); + void RemoveTuple(vtkIdType id); + void RemoveFirstTuple(); + void RemoveLastTuple(); + void SetTupleValue(vtkIdType i, const Scalar *t); + void InsertTupleValue(vtkIdType i, const Scalar *t); + vtkIdType InsertNextTupleValue(const Scalar *t); + void SetValue(vtkIdType idx, Scalar value); + vtkIdType InsertNextValue(Scalar v); + void InsertValue(vtkIdType idx, Scalar v); protected: - VtkMeshNodalCoordinatesTemplate(); - ~VtkMeshNodalCoordinatesTemplate(); + VtkMeshNodalCoordinatesTemplate(); + ~VtkMeshNodalCoordinatesTemplate(); - const std::vector<MeshLib::Node*>* _nodes; + const std::vector<MeshLib::Node*>* _nodes; private: - // Not implemented - VtkMeshNodalCoordinatesTemplate(const VtkMeshNodalCoordinatesTemplate &); - void operator=(const VtkMeshNodalCoordinatesTemplate &); + // Not implemented + VtkMeshNodalCoordinatesTemplate(const VtkMeshNodalCoordinatesTemplate &); + void operator=(const VtkMeshNodalCoordinatesTemplate &); - vtkIdType Lookup(const Scalar &val, vtkIdType startIndex); - double *TempDoubleArray; + vtkIdType Lookup(const Scalar &val, vtkIdType startIndex); + double *TempDoubleArray; }; } // end namespace