2020-09-22 15:32:01 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
//
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//============================================================================
|
|
|
|
#ifndef vtk_m_cont_internal_CellLocatorBase_h
|
|
|
|
#define vtk_m_cont_internal_CellLocatorBase_h
|
|
|
|
|
|
|
|
#include <vtkm/cont/vtkm_cont_export.h>
|
|
|
|
|
|
|
|
#include <vtkm/Types.h>
|
|
|
|
#include <vtkm/cont/CoordinateSystem.h>
|
|
|
|
#include <vtkm/cont/ExecutionObjectBase.h>
|
2022-01-04 22:38:18 +00:00
|
|
|
#include <vtkm/cont/UnknownCellSet.h>
|
2020-09-22 15:32:01 +00:00
|
|
|
|
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace cont
|
|
|
|
{
|
|
|
|
namespace internal
|
|
|
|
{
|
|
|
|
|
|
|
|
/// \brief Base class for all `CellLocator` classes.
|
|
|
|
///
|
|
|
|
/// `CellLocatorBase` uses the curiously recurring template pattern (CRTP). Subclasses
|
|
|
|
/// must provide their own type for the template parameter. Subclasses must implement
|
|
|
|
/// `Update` and `PrepareForExecution` methods.
|
|
|
|
///
|
|
|
|
template <typename Derived>
|
2020-09-30 16:29:47 +00:00
|
|
|
class VTKM_ALWAYS_EXPORT CellLocatorBase : public vtkm::cont::ExecutionObjectBase
|
2020-09-22 15:32:01 +00:00
|
|
|
{
|
2022-01-04 22:38:18 +00:00
|
|
|
vtkm::cont::UnknownCellSet CellSet;
|
2020-09-22 15:32:01 +00:00
|
|
|
vtkm::cont::CoordinateSystem Coords;
|
2020-11-11 22:29:48 +00:00
|
|
|
mutable bool Modified = true;
|
2020-09-22 15:32:01 +00:00
|
|
|
|
|
|
|
public:
|
2022-01-04 22:38:18 +00:00
|
|
|
const vtkm::cont::UnknownCellSet& GetCellSet() const { return this->CellSet; }
|
2020-09-22 15:32:01 +00:00
|
|
|
|
2022-01-04 22:38:18 +00:00
|
|
|
void SetCellSet(const vtkm::cont::UnknownCellSet& cellSet)
|
2020-09-22 15:32:01 +00:00
|
|
|
{
|
|
|
|
this->CellSet = cellSet;
|
|
|
|
this->SetModified();
|
|
|
|
}
|
|
|
|
|
|
|
|
const vtkm::cont::CoordinateSystem& GetCoordinates() const { return this->Coords; }
|
|
|
|
|
|
|
|
void SetCoordinates(const vtkm::cont::CoordinateSystem& coords)
|
|
|
|
{
|
|
|
|
this->Coords = coords;
|
|
|
|
this->SetModified();
|
|
|
|
}
|
|
|
|
|
2020-11-11 22:29:48 +00:00
|
|
|
void Update() const
|
2020-09-22 15:32:01 +00:00
|
|
|
{
|
|
|
|
if (this->Modified)
|
|
|
|
{
|
2020-11-11 22:29:48 +00:00
|
|
|
static_cast<Derived*>(const_cast<CellLocatorBase*>(this))->Build();
|
2020-09-22 15:32:01 +00:00
|
|
|
this->Modified = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void SetModified() { this->Modified = true; }
|
|
|
|
bool GetModified() const { return this->Modified; }
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // vtkm::cont::internal
|
|
|
|
|
|
|
|
#endif //vtk_m_cont_internal_CellLocatorBase_h
|