Skip to content
Snippets Groups Projects
Commit 54ab3ff1 authored by Jaswant Panchumarti (Kitware)'s avatar Jaswant Panchumarti (Kitware)
Browse files

vtkCellGrid: Move definitions of non-templated functions to CXX file

- This commit refactors the code to resolve `-Wunique-object-duplication`.
- While in here, also moves the implementation of the other non templated `std::vector<std::string> vtkCellGrid::GetCellTypes()` function to `vtkCellGrid.cxx` for consistency.
parent 4e30457b
No related branches found
No related tags found
No related merge requests found
......@@ -422,6 +422,34 @@ int vtkCellGrid::RemoveUnusedCellMetadata()
return numRemoved;
}
std::vector<vtkStringToken> vtkCellGrid::CellTypeArray() const
{
#if defined(_MSC_VER) && _MSC_VER >= 1930 && _MSC_VER < 1940 /*17.4+*/
// MSVC 2022 shows LNK1161 when an exported method uses thread_local in its implementation.
// See https://github.com/pytorch/pytorch/issues/87957 for more. We omit the
// thread_local here, which makes this method non-threadsafe on Windows, which
// should be OK in most cases.
static std::vector<vtkStringToken> cellTypes;
#else
static thread_local std::vector<vtkStringToken> cellTypes;
#endif
cellTypes.clear();
this->CellTypes(cellTypes);
return cellTypes;
}
std::vector<std::string> vtkCellGrid::GetCellTypes() const
{
auto cta = this->CellTypeArray();
std::vector<std::string> result;
result.reserve(cta.size());
for (const auto& cellTypeToken : cta)
{
result.push_back(cellTypeToken.Data());
}
return result;
}
const vtkCellMetadata* vtkCellGrid::GetCellType(vtkStringToken cellTypeName) const
{
auto it = this->Cells.find(cellTypeName);
......
......@@ -282,32 +282,8 @@ public:
this->CellTypes(cellTypes);
return cellTypes;
}
std::vector<vtkStringToken> CellTypeArray() const
{
#if defined(_MSC_VER) && _MSC_VER >= 1930 && _MSC_VER < 1940 /*17.4+*/
// MSVC 2022 bombs when an exported method uses thread_local in its implementation.
// See https://github.com/pytorch/pytorch/issues/87957 for more. We omit the
// thread_local here, which makes this method non-threadsafe on Windows, which
// should be OK in most cases.
static std::vector<vtkStringToken> cellTypes;
#else
static thread_local std::vector<vtkStringToken> cellTypes;
#endif
cellTypes.clear();
this->CellTypes(cellTypes);
return cellTypes;
}
std::vector<std::string> GetCellTypes() const
{
auto cta = this->CellTypeArray();
std::vector<std::string> result;
result.reserve(cta.size());
for (const auto& cellTypeToken : cta)
{
result.push_back(cellTypeToken.Data());
}
return result;
}
std::vector<vtkStringToken> CellTypeArray() const;
std::vector<std::string> GetCellTypes() const;
///@}
///@{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment