Commit afe7bb78 authored by Spiros Tsalikis's avatar Spiros Tsalikis Committed by Kitware Robot
Browse files

Merge topic 'fix-warnings'

84541829 vtkParticleTracerBase: Fix MeshOverTime not being set
9f150a78 vtkTemporalInterpolatedVelocityField: Use cached Locator if possible
b78324f5 vtkAbstractCellLocator: Add ComputeCellBounds
f7230f23 vtkLinearTransformCellLocator: Fix documentation
89557449 vtkParticleTracerBase:: Fix offsets ids
506435b6

 vtkPointDataToCellData/vtkCellTreeLocator: Fix warnings

Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Cory Quammen's avatarCory Quammen <cory.quammen@kitware.com>
Merge-request: !9215
parents 5f8c4785 84541829
Pipeline #282652 failed with stages
in 155 minutes
......@@ -79,6 +79,16 @@ void vtkAbstractCellLocator::FreeCellBounds()
this->CellBounds = nullptr;
}
//------------------------------------------------------------------------------
void vtkAbstractCellLocator::ComputeCellBounds()
{
if (this->CacheCellBounds)
{
this->FreeCellBounds();
this->StoreCellBounds();
}
}
//------------------------------------------------------------------------------
void vtkAbstractCellLocator::UpdateInternalWeights()
{
......
......@@ -80,6 +80,12 @@ public:
vtkBooleanMacro(CacheCellBounds, vtkTypeBool);
///@}
/**
* This function can be used either internally or externally to compute only the cached
* cell bounds if CacheCellBounds is on.
*/
void ComputeCellBounds();
///@{
/**
* Boolean controls whether to maintain list of cells in each node.
......
......@@ -791,11 +791,7 @@ void vtkCellLocator::BuildLocatorInternal()
std::make_shared<std::vector<vtkSmartPointer<vtkIdList>>>(numOctants, nullptr);
this->Tree = TreeSharedPtr->data();
if (this->CacheCellBounds)
{
this->FreeCellBounds();
this->StoreCellBounds();
}
this->ComputeCellBounds();
// Compute width of leaf octant in three directions
for (i = 0; i < 3; i++)
......
......@@ -98,8 +98,11 @@ int vtkCellLocatorStrategy::Initialize(vtkPointSet* ps)
}
else
{
this->CellLocator = psCL;
this->OwnsLocator = false;
if (psCL != this->CellLocator)
{
this->CellLocator = psCL;
this->OwnsLocator = false;
}
}
this->InitializeTime.Modified();
......
......@@ -70,7 +70,7 @@ struct vtkCellTree
virtual void FindCellsWithinBounds(double* bbox, vtkIdList* cells) = 0;
virtual int IntersectWithLine(const double a0[3], const double a1[3], double tol, double& t,
double x[3], double pcoords[3], int& subId, vtkIdType& cellId, vtkGenericCell* cell) = 0;
virtual int IntersectWithLine(const double p1[3], const double p2[3], const double tol,
virtual int IntersectWithLine(const double p1[3], const double p2[3], double tol,
vtkPoints* points, vtkIdList* cellIds, vtkGenericCell* cell) = 0;
virtual void GenerateRepresentation(int level, vtkPolyData* pd) = 0;
......@@ -1346,11 +1346,7 @@ void vtkCellTreeLocator::BuildLocatorInternal()
return;
}
this->FreeSearchStructure();
if (this->CacheCellBounds)
{
this->FreeCellBounds();
this->StoreCellBounds();
}
this->ComputeCellBounds();
// Create sorted cell fragments tuples of (cellId,binId). Depending
// on problem size, different types are used.
if (numCells >= VTK_INT_MAX)
......
......@@ -104,8 +104,11 @@ int vtkClosestPointStrategy::Initialize(vtkPointSet* ps)
}
else
{
this->PointLocator = psPL;
this->OwnsLocator = false;
if (psPL != this->PointLocator)
{
this->PointLocator = psPL;
this->OwnsLocator = false;
}
}
this->VisitedCells.resize(static_cast<size_t>(ps->GetNumberOfCells()));
this->Weights.resize(8);
......
......@@ -21,15 +21,15 @@
* vtkStaticCellLocator, vtkCellLocator, calculate the transformation matrix from the cell
* locator adaptor's dataset to the given dataset inside BuildLocator, and then use the cell locator
* and transformation to perform cell locator operations. The transformation matrix is computed
* using the https://en.wikipedia.org/wiki/Kabsch_algorithm. UseAllPoints allows to compute the
* transformation using all the points of the dataset (use that when you are not if it's a linear
* transformation) or 100 sample points (or less if the dataset is smaller) that are chosen
* using the https://en.wikipedia.org/wiki/Kabsch_algorithm. UseAllPoints allows you to compute the
* transformation using all the points of the dataset (use that when you are not sure if it's a
* linear transformation) or 100 sample points (or less if the dataset is smaller) that are chosen
* every-nth. IsLinearTransformation validates if the dataset is a linear transformation of the cell
* locator's dataset based on the used points.
*
* @warning The cell locator adaptor MUST be built before using it.
*
* vtkCellTreeLocator does NOT utilize ANY vtkLocator/vtkAbstractCellLocator parameter:
* vtkLinearTransformCellLocator does NOT utilize ANY vtkLocator/vtkAbstractCellLocator parameter:
*
* @sa
* vtkAbstractCellLocator vtkCellLocator vtkStaticCellLocator vtkCellTreeLocator vtkModifiedBSPTree
......
......@@ -199,8 +199,6 @@ void vtkPointSet::BuildCellLocator()
{
this->CellLocator = vtkStaticCellLocator::New();
}
this->CellLocator->Register(this);
this->CellLocator->Delete();
this->CellLocator->SetDataSet(this);
}
else if (this->Points->GetMTime() > this->CellLocator->GetMTime())
......
......@@ -365,8 +365,7 @@ int vtkPointDataToCellData::RequestData(
vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
vtkDataSet* input = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkIdType cellId, ptId, pointId;
vtkIdType numCells, numPts;
vtkIdType numCells;
vtkPointData* inputInPD = input->GetPointData();
vtkSmartPointer<vtkPointData> inPD;
vtkCellData* outCD = output->GetCellData();
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestParticleTracers.cxx
Module: TestStreamTracer.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
......
......@@ -157,16 +157,26 @@ void vtkAbstractInterpolatedVelocityField::Initialize(vtkCompositeDataSet* compD
for (auto& datasetInfo : this->DataSetsInfo)
{
datasetInfo.DataSet->ComputeBounds();
if (auto polyData = vtkPolyData::SafeDownCast(datasetInfo.DataSet))
{
// build cells is needed for both vtkClosestPointStrategy and vtkCellLocatorStrategy
polyData->BuildCells();
}
if (vtkClosestPointStrategy::SafeDownCast(datasetInfo.Strategy))
{
if (auto ugrid = vtkUnstructuredGrid::SafeDownCast(datasetInfo.DataSet))
{
ugrid->BuildLinks();
if (ugrid->GetLinks() == nullptr)
{
ugrid->BuildLinks();
}
}
else if (auto polyData = vtkPolyData::SafeDownCast(datasetInfo.DataSet))
{
// Build links calls BuildCells internally
polyData->BuildLinks();
if (polyData->GetLinks() == nullptr)
{
polyData->BuildLinks();
}
}
}
}
......
......@@ -156,11 +156,7 @@ void vtkModifiedBSPTree::BuildLocatorInternal()
this->mRoot->mAxis = rand() % 3;
this->mRoot->depth = 0;
if (this->CacheCellBounds)
{
this->FreeCellBounds();
this->StoreCellBounds();
}
this->ComputeCellBounds();
// sort the cells into 6 lists using structure for subdividing tests
Sorted_cell_extents_Lists* lists = new Sorted_cell_extents_Lists(numCells);
......
......@@ -370,10 +370,25 @@ int vtkParticleTracerBase::RequestUpdateExtent(vtkInformation* vtkNotUsed(reques
return 1;
}
//------------------------------------------------------------------------------
void vtkParticleTracerBase::SetMeshOverTime(int meshOverTime)
{
if (this->MeshOverTime !=
(meshOverTime < DIFFERENT ? DIFFERENT
: (meshOverTime > SAME_TOPOLOGY ? SAME_TOPOLOGY : meshOverTime)))
{
this->MeshOverTime =
(meshOverTime < DIFFERENT ? DIFFERENT
: (meshOverTime > SAME_TOPOLOGY ? SAME_TOPOLOGY : meshOverTime));
this->Modified();
// Needed since the value needs to be set at the same time.
this->Interpolator->SetMeshOverTime(this->MeshOverTime);
}
}
//------------------------------------------------------------------------------
void vtkParticleTracerBase::SetInterpolatorType(int interpolatorType)
{
this->Interpolator->SetMeshOverTime(this->MeshOverTime);
if (interpolatorType == INTERPOLATOR_WITH_CELL_LOCATOR)
{
// create an interpolator equipped with a cell locator (by default)
......@@ -431,7 +446,7 @@ int vtkParticleTracerBase::InitializeInterpolator()
return VTK_ERROR;
}
// create Interpolator if needed
// set strategy if needed
if (this->Interpolator->GetFindCellStrategy() == nullptr)
{
// cell locator is the default;
......@@ -838,7 +853,7 @@ void vtkParticleTracerBase::ResizeArrays(vtkIdType numTuples)
{
// resize first so that if you already have data, you don't lose them
this->OutputCoordinates->Resize(numTuples);
this->ParticleCellsOffsets->Resize(numTuples);
this->ParticleCellsOffsets->Resize(numTuples + 1);
this->ParticleCellsConnectivity->Resize(numTuples);
for (int i = 0; i < this->OutputPointData->GetNumberOfArrays(); ++i)
{
......@@ -846,7 +861,7 @@ void vtkParticleTracerBase::ResizeArrays(vtkIdType numTuples)
}
// set number number of tuples because resize does not do that
this->OutputCoordinates->SetNumberOfPoints(numTuples);
this->ParticleCellsOffsets->SetNumberOfValues(numTuples);
this->ParticleCellsOffsets->SetNumberOfValues(numTuples + 1);
this->ParticleCellsConnectivity->SetNumberOfValues(numTuples);
this->OutputPointData->SetNumberOfTuples(numTuples);
}
......@@ -882,6 +897,7 @@ vtkPolyData* vtkParticleTracerBase::Execute(vtkInformationVector** inputVector)
vtkDebugMacro(<< "About to allocate arrays ");
this->OutputCoordinates = vtkSmartPointer<vtkPoints>::New();
this->ParticleCellsOffsets = vtkSmartPointer<vtkIdTypeArray>::New();
this->ParticleCellsOffsets->InsertNextValue(0);
this->ParticleCellsConnectivity = vtkSmartPointer<vtkIdTypeArray>::New();
this->ParticleCells = vtkSmartPointer<vtkCellArray>::New();
......@@ -1676,7 +1692,7 @@ void vtkParticleTracerBase::SetParticle(vtkParticleTracerBaseNamespace::Particle
const double* coord = info.CurrentPosition.x;
this->OutputCoordinates->SetPoint(particleId, coord);
// create the cell
this->ParticleCellsOffsets->SetValue(particleId, particleId + 1);
this->ParticleCellsOffsets->SetValue(particleId + 1, particleId + 1);
this->ParticleCellsConnectivity->SetValue(particleId, particleId);
// set the easy scalars for this particle
this->ParticleIds->SetValue(particleId, info.UniqueParticleId);
......
......@@ -229,7 +229,9 @@ public:
* LINEAR_TRANSFORMATION = 2
* SAME_TOPOLOGY = 3
*/
vtkSetClampMacro(MeshOverTime, int, DIFFERENT, LINEAR_TRANSFORMATION);
virtual void SetMeshOverTime(int meshOverTime);
virtual int GetMeshOverTimeMinValue() { return DIFFERENT; }
virtual int GetMeshOverTimeMaxValue() { return SAME_TOPOLOGY; }
void SetMeshOverTimeToDifferent() { this->SetMeshOverTime(DIFFERENT); }
void SetMeshOverTimeToStatic() { this->SetMeshOverTime(STATIC); }
void SetMeshOverTimeToLinearTransformation() { this->SetMeshOverTime(LINEAR_TRANSFORMATION); }
......
......@@ -123,25 +123,34 @@ void vtkTemporalInterpolatedVelocityField::CreateLocators(const std::vector<vtkD
locators.reserve(datasets.size());
for (const auto& dataset : datasets)
{
if (vtkPointSet::SafeDownCast(dataset))
if (auto pointSet = vtkPointSet::SafeDownCast(dataset))
{
if (vtkCellLocatorStrategy::SafeDownCast(strategy))
{
auto cellLocator = vtkSmartPointer<vtkStaticCellLocator>::New();
cellLocator->SetDataSet(dataset);
cellLocator->CacheCellBoundsOn();
if (!pointSet->GetCellLocator())
{
pointSet->BuildCellLocator();
}
auto cellLocator = pointSet->GetCellLocator();
// if cache cell bounds were not on, enable them and compute cell bounds
if (cellLocator->GetCacheCellBounds() == 0)
{
cellLocator->CacheCellBoundsOn();
cellLocator->ComputeCellBounds();
}
cellLocator->SetUseExistingSearchStructure(
this->MeshOverTime != MeshOverTimeTypes::DIFFERENT);
cellLocator->BuildLocator();
locators.emplace_back(cellLocator);
}
else // vtkClosestPointStrategy
{
auto pointLocator = vtkSmartPointer<vtkStaticPointLocator>::New();
pointLocator->SetDataSet(dataset);
if (!pointSet->GetPointLocator())
{
pointSet->BuildPointLocator();
}
auto pointLocator = pointSet->GetPointLocator();
pointLocator->SetUseExistingSearchStructure(
this->MeshOverTime != MeshOverTimeTypes::DIFFERENT);
pointLocator->BuildLocator();
locators.emplace_back(pointLocator);
}
}
......@@ -164,12 +173,19 @@ void vtkTemporalInterpolatedVelocityField::CreateLinks(const std::vector<vtkData
{
if (auto ugrid = vtkUnstructuredGrid::SafeDownCast(dataset))
{
ugrid->BuildLinks();
if (ugrid->GetLinks() == nullptr)
{
ugrid->BuildLinks();
}
datasetLinks.emplace_back(ugrid->GetLinks());
}
else if (auto polyData = vtkPolyData::SafeDownCast(dataset))
{
polyData->BuildLinks();
if (polyData->GetLinks() == nullptr)
{
// Build links calls BuildCells internally
polyData->BuildLinks();
}
datasetLinks.emplace_back(polyData->GetLinks());
}
}
......@@ -206,7 +222,7 @@ void vtkTemporalInterpolatedVelocityField::CreateLinearTransformCellLocators(
void vtkTemporalInterpolatedVelocityField::InitializeWithLocators(
vtkCompositeInterpolatedVelocityField* ivf, const std::vector<vtkDataSet*>& datasets,
vtkFindCellStrategy* strategy, const std::vector<vtkSmartPointer<vtkLocator>>& locators,
const std::vector<vtkSmartPointer<vtkAbstractCellLinks>>& datasetLinks)
const std::vector<vtkSmartPointer<vtkAbstractCellLinks>>& links)
{
// Clear the datasets info, subclasses may want to put stuff into it.
ivf->DataSetsInfo.clear();
......@@ -269,17 +285,18 @@ void vtkTemporalInterpolatedVelocityField::InitializeWithLocators(
datasetInfo.DataSet->ComputeBounds();
if (auto polyData = vtkPolyData::SafeDownCast(datasetInfo.DataSet))
{
// build cells is needed for both vtkClosestPointStrategy and vtkCellLocatorStrategy
polyData->BuildCells();
}
if (vtkClosestPointStrategy::SafeDownCast(datasetInfo.Strategy))
{
if (auto ugrid = vtkUnstructuredGrid::SafeDownCast(datasetInfo.DataSet))
{
ugrid->SetLinks(datasetLinks[i]);
ugrid->SetLinks(links[i]);
}
else if (auto polyData = vtkPolyData::SafeDownCast(datasetInfo.DataSet))
{
polyData->SetLinks(vtkCellLinks::SafeDownCast(datasetLinks[i]));
polyData->SetLinks(vtkCellLinks::SafeDownCast(links[i]));
}
}
}
......
......@@ -50,9 +50,9 @@
#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_2_0
#include "vtkFiltersFlowPathsModule.h" // For export macro
#include "vtkFunctionSet.h"
#include "vtkSmartPointer.h" // because it is good
#include "vtkSmartPointer.h" // For vtkSmartPointer
#include <vector> // Because they are good
#include <vector> // For internal structures
class vtkAbstractCellLinks;
class vtkCompositeDataSet;
......@@ -108,7 +108,7 @@ public:
* LINEAR_TRANSFORMATION = 2
* SAME_TOPOLOGY = 3
*/
vtkSetClampMacro(MeshOverTime, int, DIFFERENT, LINEAR_TRANSFORMATION);
vtkSetClampMacro(MeshOverTime, int, DIFFERENT, SAME_TOPOLOGY);
void SetMeshOverTimeToDifferent() { this->SetMeshOverTime(DIFFERENT); }
void SetMeshOverTimeToStatic() { this->SetMeshOverTime(STATIC); }
void SetMeshOverTimeToLinearTransformation() { this->SetMeshOverTime(LINEAR_TRANSFORMATION); }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment