mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
Merge topic 'coords-are-fields'
4ca64f0f0 Back out of DataSet::CopyPartsFromExcept method 2d30e6d45 Coordinate systems are stored as Fields Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Li-Ta Lo <ollie@lanl.gov> Merge-request: !2920
This commit is contained in:
commit
03173eced7
29
docs/changelog/coords-are-fields.md
Normal file
29
docs/changelog/coords-are-fields.md
Normal file
@ -0,0 +1,29 @@
|
||||
# Coordiante systems are stored as Fields
|
||||
|
||||
Previously, `DataSet` managed `CoordinateSystem`s separately from `Field`s.
|
||||
However, a `CoordinateSystem` is really just a `Field` with some special
|
||||
attributes. Thus, coordiante systems are now just listed along with the
|
||||
rest of the fields, and the coordinate systems are simply strings that
|
||||
point back to the appropriate field. (This was actually the original
|
||||
concept for `DataSet`, but the coordinate systems were separated from
|
||||
fields for some now obsolete reasons.)
|
||||
|
||||
This change should not be very noticible, but there are a few consequences
|
||||
that should be noted.
|
||||
|
||||
1. The `GetCoordinateSystem` methods no longer return a reference to a
|
||||
`CoordinateSystem` object. This is because the `CoordinateSystem` object
|
||||
is made on the fly from the field.
|
||||
2. When mapping fields in filters, the coordinate systems get mapped as
|
||||
part of this process. This has allowed us to remove some of the special
|
||||
cases needed to set the coordinate system in the output.
|
||||
3. If a filter is generating a coordinate system in a special way
|
||||
(different than mapping other point fields), then it can use the special
|
||||
`CreateResultCoordianteSystem` method to attach this custom coordinate
|
||||
system to the output.
|
||||
4. The `DataSet::GetCoordianteSystems()` method to get a `vector<>` of all
|
||||
coordiante systems is removed. `DataSet` no longer internally has this
|
||||
structure. Although it could be built, the only reason for its existance
|
||||
was to support passing coordinate systems in filters. Now that this is
|
||||
done autmoatically, the method is no longer needed.
|
||||
|
@ -195,7 +195,7 @@ VTKM_CONT vtkm::cont::DataSet ExtractEdges::DoExecute(const vtkm::cont::DataSet&
|
||||
auto mapper = [&](auto& outDataSet, const auto& f) {
|
||||
DoMapField(outDataSet, f, outputToInputCellMap, cellToEdgeKeys);
|
||||
};
|
||||
return this->CreateResult(inData, outCellSet, inData.GetCoordinateSystems(), mapper);
|
||||
return this->CreateResult(inData, outCellSet, mapper);
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||
#include <vtkm/cont/CoordinateSystem.h>
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
|
||||
namespace vtkm
|
||||
{
|
||||
@ -22,6 +23,15 @@ VTKM_CONT CoordinateSystem::CoordinateSystem()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(const vtkm::cont::Field& src)
|
||||
: Superclass(src)
|
||||
{
|
||||
if (src.GetAssociation() != vtkm::cont::Field::Association::Points)
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("CoordinateSystems can only be point field.");
|
||||
}
|
||||
}
|
||||
|
||||
VTKM_CONT CoordinateSystem::CoordinateSystem(std::string name,
|
||||
const vtkm::cont::UnknownArrayHandle& data)
|
||||
: Superclass(name, Association::Points, data)
|
||||
|
@ -31,6 +31,9 @@ public:
|
||||
VTKM_CONT
|
||||
CoordinateSystem();
|
||||
|
||||
// It's OK for regular _point_ fields to become a CoordinateSystem object.
|
||||
VTKM_CONT CoordinateSystem(const vtkm::cont::Field& src);
|
||||
|
||||
VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::UnknownArrayHandle& data);
|
||||
|
||||
template <typename T, typename Storage>
|
||||
|
@ -9,8 +9,11 @@
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/DataSet.h>
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
#include <vtkm/cont/Logging.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@ -84,7 +87,7 @@ VTKM_CONT void SetGlobalGhostCellFieldName(const std::string& name) noexcept
|
||||
|
||||
void DataSet::Clear()
|
||||
{
|
||||
this->CoordSystems.clear();
|
||||
this->CoordSystemNames.clear();
|
||||
this->Fields.Clear();
|
||||
this->CellSet = this->CellSet.NewInstance();
|
||||
}
|
||||
@ -158,10 +161,31 @@ const vtkm::cont::Field& DataSet::GetGhostCellField() const
|
||||
}
|
||||
}
|
||||
|
||||
void DataSet::AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs)
|
||||
vtkm::IdComponent DataSet::AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs)
|
||||
{
|
||||
CheckFieldSize(this->CellSet, cs);
|
||||
this->CoordSystems.push_back(cs);
|
||||
this->AddField(cs);
|
||||
return this->AddCoordinateSystem(cs.GetName());
|
||||
}
|
||||
|
||||
vtkm::IdComponent DataSet::AddCoordinateSystem(const std::string& pointFieldName)
|
||||
{
|
||||
// Check to see if we already have this coordinate system.
|
||||
vtkm::IdComponent index = this->GetCoordinateSystemIndex(pointFieldName);
|
||||
if (index >= 0)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
// Check to make sure this is a valid point field.
|
||||
if (!this->HasPointField(pointFieldName))
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("Cannot set point field named `" + pointFieldName +
|
||||
"` as a coordinate system because it does not exist.");
|
||||
}
|
||||
|
||||
// Add the field to the list of coordinates.
|
||||
this->CoordSystemNames.push_back(pointFieldName);
|
||||
return static_cast<vtkm::IdComponent>(this->CoordSystemNames.size() - 1);
|
||||
}
|
||||
|
||||
void DataSet::SetCellSetImpl(const vtkm::cont::UnknownCellSet& cellSet)
|
||||
@ -213,65 +237,65 @@ void DataSet::SetGhostCellField(const vtkm::cont::UnknownArrayHandle& field)
|
||||
|
||||
void DataSet::CopyStructure(const vtkm::cont::DataSet& source)
|
||||
{
|
||||
this->CoordSystems = source.CoordSystems;
|
||||
// Copy the cells.
|
||||
this->CellSet = source.CellSet;
|
||||
|
||||
// Copy the coordinate systems.
|
||||
this->CoordSystemNames.clear();
|
||||
vtkm::IdComponent numCoords = source.GetNumberOfCoordinateSystems();
|
||||
for (vtkm::IdComponent coordIndex = 0; coordIndex < numCoords; ++coordIndex)
|
||||
{
|
||||
this->AddCoordinateSystem(source.GetCoordinateSystem(coordIndex));
|
||||
}
|
||||
|
||||
// Copy the ghost cells.
|
||||
// Note that we copy the GhostCellName separately from the field it points to
|
||||
// to preserve (or remove) the case where the ghost cell name follows the
|
||||
// global ghost cell name.
|
||||
this->GhostCellName = source.GhostCellName;
|
||||
if (source.HasGhostCellField())
|
||||
{
|
||||
this->AddField(source.GetGhostCellField());
|
||||
}
|
||||
|
||||
CheckFieldSizes(this->CellSet, this->Fields);
|
||||
}
|
||||
|
||||
const vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(vtkm::Id index) const
|
||||
vtkm::cont::CoordinateSystem DataSet::GetCoordinateSystem(vtkm::Id index) const
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems()));
|
||||
return this->CoordSystems[static_cast<std::size_t>(index)];
|
||||
return this->GetPointField(this->CoordSystemNames[static_cast<std::size_t>(index)]);
|
||||
}
|
||||
|
||||
vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(vtkm::Id index)
|
||||
vtkm::IdComponent DataSet::GetCoordinateSystemIndex(const std::string& name) const
|
||||
{
|
||||
auto nameIter = std::find(this->CoordSystemNames.begin(), this->CoordSystemNames.end(), name);
|
||||
if (nameIter != this->CoordSystemNames.end())
|
||||
{
|
||||
return static_cast<vtkm::IdComponent>(std::distance(this->CoordSystemNames.begin(), nameIter));
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string& DataSet::GetCoordinateSystemName(vtkm::Id index) const
|
||||
{
|
||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems()));
|
||||
return this->CoordSystems[static_cast<std::size_t>(index)];
|
||||
return this->CoordSystemNames[static_cast<std::size_t>(index)];
|
||||
}
|
||||
|
||||
vtkm::Id DataSet::GetCoordinateSystemIndex(const std::string& name) const
|
||||
{
|
||||
vtkm::Id index = -1;
|
||||
for (auto i = this->CoordSystems.begin(); i != this->CoordSystems.end(); ++i)
|
||||
{
|
||||
if (i->GetName() == name)
|
||||
{
|
||||
index = static_cast<vtkm::Id>(std::distance(this->CoordSystems.begin(), i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
const vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& name) const
|
||||
vtkm::cont::CoordinateSystem DataSet::GetCoordinateSystem(const std::string& name) const
|
||||
{
|
||||
vtkm::Id index = this->GetCoordinateSystemIndex(name);
|
||||
if (index < 0)
|
||||
{
|
||||
std::string error_message("No coordinate system with the name " + name +
|
||||
" valid names are: \n");
|
||||
for (const auto& cs : this->CoordSystems)
|
||||
for (const auto& csn : this->CoordSystemNames)
|
||||
{
|
||||
error_message += cs.GetName() + "\n";
|
||||
}
|
||||
throw vtkm::cont::ErrorBadValue(error_message);
|
||||
}
|
||||
return this->GetCoordinateSystem(index);
|
||||
}
|
||||
|
||||
vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& name)
|
||||
{
|
||||
vtkm::Id index = this->GetCoordinateSystemIndex(name);
|
||||
if (index < 0)
|
||||
{
|
||||
std::string error_message("No coordinate system with the name " + name +
|
||||
" valid names are: \n");
|
||||
for (const auto& cs : this->CoordSystems)
|
||||
{
|
||||
error_message += cs.GetName() + "\n";
|
||||
error_message += csn + "\n";
|
||||
}
|
||||
throw vtkm::cont::ErrorBadValue(error_message);
|
||||
}
|
||||
@ -281,11 +305,13 @@ vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& na
|
||||
void DataSet::PrintSummary(std::ostream& out) const
|
||||
{
|
||||
out << "DataSet:\n";
|
||||
out << " CoordSystems[" << this->CoordSystems.size() << "]\n";
|
||||
for (std::size_t index = 0; index < this->CoordSystems.size(); index++)
|
||||
out << " CoordSystems[" << this->CoordSystemNames.size() << "]\n";
|
||||
out << " ";
|
||||
for (const auto& csn : this->CoordSystemNames)
|
||||
{
|
||||
this->CoordSystems[index].PrintSummary(out);
|
||||
out << " " << csn;
|
||||
}
|
||||
out << "\n";
|
||||
|
||||
out << " CellSet \n";
|
||||
this->GetCellSet().PrintSummary(out);
|
||||
|
@ -259,8 +259,21 @@ public:
|
||||
}
|
||||
|
||||
|
||||
/// \brief Adds the given `CoordinateSystem` to the `DataSet`.
|
||||
///
|
||||
/// The coordinate system will also be added as a point field of the same name.
|
||||
///
|
||||
/// \returns the index assigned to the added coordinate system.
|
||||
VTKM_CONT
|
||||
void AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs);
|
||||
vtkm::IdComponent AddCoordinateSystem(const vtkm::cont::CoordinateSystem& cs);
|
||||
|
||||
/// \brief Marks the point field with the given name as a coordinate system.
|
||||
///
|
||||
/// If no such point field exists or the point field is of the wrong format, an exception
|
||||
/// will be throw.
|
||||
///
|
||||
/// \returns the index assigned to the added coordinate system.
|
||||
VTKM_CONT vtkm::IdComponent AddCoordinateSystem(const std::string& pointFieldName);
|
||||
|
||||
VTKM_CONT
|
||||
bool HasCoordinateSystem(const std::string& name) const
|
||||
@ -269,34 +282,20 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0) const;
|
||||
vtkm::cont::CoordinateSystem GetCoordinateSystem(vtkm::Id index = 0) const;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0);
|
||||
|
||||
/// Returns the index for the first CoordinateSystem whose
|
||||
/// Returns the index for the CoordinateSystem whose
|
||||
/// name matches the provided string.
|
||||
/// Will return -1 if no match is found
|
||||
VTKM_CONT
|
||||
vtkm::Id GetCoordinateSystemIndex(const std::string& name) const;
|
||||
vtkm::IdComponent GetCoordinateSystemIndex(const std::string& name) const;
|
||||
|
||||
/// Returns the first CoordinateSystem that matches the provided name.
|
||||
VTKM_CONT const std::string& GetCoordinateSystemName(vtkm::Id index = 0) const;
|
||||
|
||||
/// Returns the CoordinateSystem that matches the provided name.
|
||||
/// Will throw an exception if no match is found
|
||||
///@{
|
||||
VTKM_CONT
|
||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name) const;
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name);
|
||||
///@}
|
||||
|
||||
/// Returns an `std::vector` of `CoordinateSystem`s held in this `DataSet`.
|
||||
///
|
||||
VTKM_CONT
|
||||
std::vector<vtkm::cont::CoordinateSystem> GetCoordinateSystems() const
|
||||
{
|
||||
return this->CoordSystems;
|
||||
}
|
||||
vtkm::cont::CoordinateSystem GetCoordinateSystem(const std::string& name) const;
|
||||
|
||||
template <typename CellSetType>
|
||||
VTKM_CONT void SetCellSet(const CellSetType& cellSet)
|
||||
@ -317,11 +316,12 @@ public:
|
||||
VTKM_CONT
|
||||
vtkm::IdComponent GetNumberOfCoordinateSystems() const
|
||||
{
|
||||
return static_cast<vtkm::IdComponent>(this->CoordSystems.size());
|
||||
return static_cast<vtkm::IdComponent>(this->CoordSystemNames.size());
|
||||
}
|
||||
|
||||
/// Copies the structure i.e. coordinates systems and cellset from the source
|
||||
/// dataset. The fields are left unchanged.
|
||||
/// Copies the structure from the source dataset. The structure includes the cellset,
|
||||
/// the coordinate systems, and any ghost layer information. The fields that are not
|
||||
/// part of a coordinate system or ghost layers are left unchanged.
|
||||
VTKM_CONT
|
||||
void CopyStructure(const vtkm::cont::DataSet& source);
|
||||
|
||||
@ -344,7 +344,7 @@ public:
|
||||
void PrintSummary(std::ostream& out) const;
|
||||
|
||||
private:
|
||||
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
|
||||
std::vector<std::string> CoordSystemNames;
|
||||
vtkm::cont::internal::FieldCollection Fields{ vtkm::cont::Field::Association::WholeDataSet,
|
||||
vtkm::cont::Field::Association::Points,
|
||||
vtkm::cont::Field::Association::Cells };
|
||||
@ -396,13 +396,6 @@ public:
|
||||
{
|
||||
const auto& dataset = serializable.DataSet;
|
||||
|
||||
vtkm::IdComponent numberOfCoordinateSystems = dataset.GetNumberOfCoordinateSystems();
|
||||
vtkmdiy::save(bb, numberOfCoordinateSystems);
|
||||
for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i)
|
||||
{
|
||||
vtkmdiy::save(bb, dataset.GetCoordinateSystem(i));
|
||||
}
|
||||
|
||||
vtkmdiy::save(bb, dataset.GetCellSet().ResetCellSetList(CellSetTypesList{}));
|
||||
|
||||
vtkm::IdComponent numberOfFields = dataset.GetNumberOfFields();
|
||||
@ -411,6 +404,13 @@ public:
|
||||
{
|
||||
vtkmdiy::save(bb, dataset.GetField(i));
|
||||
}
|
||||
|
||||
vtkm::IdComponent numberOfCoordinateSystems = dataset.GetNumberOfCoordinateSystems();
|
||||
vtkmdiy::save(bb, numberOfCoordinateSystems);
|
||||
for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i)
|
||||
{
|
||||
vtkmdiy::save(bb, dataset.GetCoordinateSystemName(i));
|
||||
}
|
||||
}
|
||||
|
||||
static VTKM_CONT void load(BinaryBuffer& bb, Type& serializable)
|
||||
@ -418,15 +418,6 @@ public:
|
||||
auto& dataset = serializable.DataSet;
|
||||
dataset = {}; // clear
|
||||
|
||||
vtkm::IdComponent numberOfCoordinateSystems = 0;
|
||||
vtkmdiy::load(bb, numberOfCoordinateSystems);
|
||||
for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i)
|
||||
{
|
||||
vtkm::cont::CoordinateSystem coords;
|
||||
vtkmdiy::load(bb, coords);
|
||||
dataset.AddCoordinateSystem(coords);
|
||||
}
|
||||
|
||||
vtkm::cont::UncertainCellSet<CellSetTypesList> cells;
|
||||
vtkmdiy::load(bb, cells);
|
||||
dataset.SetCellSet(cells);
|
||||
@ -439,6 +430,15 @@ public:
|
||||
vtkmdiy::load(bb, field);
|
||||
dataset.AddField(field);
|
||||
}
|
||||
|
||||
vtkm::IdComponent numberOfCoordinateSystems = 0;
|
||||
vtkmdiy::load(bb, numberOfCoordinateSystems);
|
||||
for (vtkm::IdComponent i = 0; i < numberOfCoordinateSystems; ++i)
|
||||
{
|
||||
std::string coordName;
|
||||
vtkmdiy::load(bb, coordName);
|
||||
dataset.AddCoordinateSystem(coordName);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -29,7 +29,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
{
|
||||
//Verify basics..
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
|
@ -37,7 +37,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
const vtkm::Bounds& bounds)
|
||||
{
|
||||
//Verify basics..
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
|
@ -30,7 +30,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
{
|
||||
//Verify basics..
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
|
@ -31,7 +31,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
||||
{
|
||||
//Verify basics..
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||
|
@ -44,7 +44,7 @@ void TestDataSet_Explicit()
|
||||
vtkm::cont::testing::MakeTestDataSet tds;
|
||||
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet0();
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
|
||||
// test various field-getting methods and associations
|
||||
const vtkm::cont::Field& f1 = ds.GetField("pointvar");
|
||||
|
@ -42,7 +42,7 @@ static void TwoDimRectilinearTest()
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
dataSet.GetCellSet().AsCellSet(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||
"Incorrect number of coordinate systems");
|
||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points");
|
||||
@ -128,7 +128,7 @@ static void ThreeDimRectilinearTest()
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet().AsCellSet(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||
"Incorrect number of coordinate systems");
|
||||
|
@ -43,7 +43,7 @@ static void TwoDimUniformTest()
|
||||
vtkm::cont::CellSetStructured<2> cellSet;
|
||||
dataSet.GetCellSet().AsCellSet(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||
"Incorrect number of coordinate systems");
|
||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points");
|
||||
@ -132,7 +132,7 @@ static void ThreeDimUniformTest()
|
||||
vtkm::cont::CellSetStructured<3> cellSet;
|
||||
dataSet.GetCellSet().AsCellSet(cellSet);
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
|
||||
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||
"Incorrect number of coordinate systems");
|
||||
|
@ -224,6 +224,11 @@ void DataSet_Compare(vtkm::cont::DataSet& leftDataSet, vtkm::cont::DataSet& righ
|
||||
{
|
||||
for (vtkm::Id j = 0; j < leftDataSet.GetNumberOfFields(); j++)
|
||||
{
|
||||
if (leftDataSet.HasCoordinateSystem(leftDataSet.GetField(j).GetName()))
|
||||
{
|
||||
// Skip coordinate systems, which have a different array type.
|
||||
continue;
|
||||
}
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> lDataArray;
|
||||
leftDataSet.GetField(j).GetData().AsArrayHandle(lDataArray);
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> rDataArray;
|
||||
|
@ -108,13 +108,10 @@ vtkm::cont::PartitionedDataSet NewFilter::Execute(const vtkm::cont::PartitionedD
|
||||
|
||||
vtkm::cont::DataSet NewFilter::CreateResult(const vtkm::cont::DataSet& inDataSet) const
|
||||
{
|
||||
vtkm::cont::DataSet clone;
|
||||
clone.CopyStructure(inDataSet);
|
||||
this->MapFieldsOntoOutput(
|
||||
inDataSet, clone, [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
||||
auto fieldMapper = [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
||||
out.AddField(fieldToPass);
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
return this->CreateResult(inDataSet, inDataSet.GetCellSet(), fieldMapper);
|
||||
}
|
||||
|
||||
vtkm::cont::PartitionedDataSet NewFilter::CreateResult(
|
||||
|
@ -150,7 +150,7 @@ namespace filter
|
||||
/// };
|
||||
/// // This passes coordinate systems directly from input to output. If the points of
|
||||
/// // the cell set change at all, they will have to be mapped by hand.
|
||||
/// return this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
||||
/// return this->CreateResult(input, outCellSet, mapper);
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
@ -188,15 +188,15 @@ namespace filter
|
||||
/// // thus making it thread-safe.
|
||||
/// SharedStates states;
|
||||
///
|
||||
/// vtkm::cont::DataSet output;
|
||||
/// output = ... // Generation of the new DataSet and store interpolation parameters in `states`
|
||||
/// vtkm::cont::CellSetExplicit<> cellSet;
|
||||
/// cellSet = ... // Generation of the new DataSet and store interpolation parameters in `states`
|
||||
///
|
||||
/// // Lambda capture of `states`, effectively passing the shared states to the Mapper.
|
||||
/// auto mapper = [&states](auto& outputDs, const auto& inputField) {
|
||||
/// auto outputField = ... // Use `states` for mapping input field to output field
|
||||
/// output.AddField(outputField);
|
||||
/// };
|
||||
/// this->MapFieldsOntoOutput(input, output, mapper);
|
||||
/// this->CreateOutput(input, cellSet, mapper);
|
||||
///
|
||||
/// return output;
|
||||
/// }
|
||||
@ -292,6 +292,21 @@ public:
|
||||
vtkm::filter::FieldSelection& GetFieldsToPass() { return this->FieldsToPass; }
|
||||
///@}
|
||||
|
||||
///@{
|
||||
/// \brief Specify whether to always pass coordinate systems.
|
||||
///
|
||||
/// `CoordinateSystem`s in a `DataSet` are really just point fields marked as being a
|
||||
/// coordinate system. Thus, a coordinate system is passed if and only if the associated
|
||||
/// field is passed.
|
||||
///
|
||||
/// By default, the filter will pass all fields associated with a coordinate system
|
||||
/// regardless of the `FieldsToPass` marks the field as passing. If this option is set
|
||||
/// to `false`, then coordinate systems will only be passed if it is marked so by
|
||||
/// `FieldsToPass`.
|
||||
VTKM_CONT void SetPassCoordinateSystems(bool flag) { this->PassCoordinateSystems = flag; }
|
||||
VTKM_CONT bool GetPassCoordinateSystems() const { return this->PassCoordinateSystems; }
|
||||
///@}
|
||||
|
||||
///@{
|
||||
/// Executes the filter on the input and produces a result dataset.
|
||||
///
|
||||
@ -357,7 +372,6 @@ protected:
|
||||
/// argument and a `Field` as its second argument. The `PartitionedDataSet` is the data being
|
||||
/// created and will eventually be returned by `CreateResult`. The `Field` comes from `input`.
|
||||
///
|
||||
|
||||
template <typename FieldMapper>
|
||||
VTKM_CONT vtkm::cont::PartitionedDataSet CreateResult(
|
||||
const vtkm::cont::PartitionedDataSet& input,
|
||||
@ -365,7 +379,7 @@ protected:
|
||||
FieldMapper&& fieldMapper) const
|
||||
{
|
||||
vtkm::cont::PartitionedDataSet output(resultPartitions.GetPartitions());
|
||||
this->MapFieldsOntoOutput(input, output, fieldMapper);
|
||||
this->MapFieldsOntoOutput(input, this->GetFieldsToPass(), output, fieldMapper);
|
||||
return output;
|
||||
}
|
||||
|
||||
@ -376,9 +390,6 @@ protected:
|
||||
/// being created and a `Field` from the input and then applies any necessary transformations to
|
||||
/// the field array and adds it to the `DataSet`.
|
||||
///
|
||||
/// This form of `CreateResult` returns a `DataSet` with _no_ coordinate systems. The calling
|
||||
/// program must add any necessary `CoordinateSystem`s.
|
||||
///
|
||||
/// \param[in] inDataSet The input data set being modified (usually the one passed
|
||||
/// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet`
|
||||
/// (as selected by the `FieldsToPass` state of the filter).
|
||||
@ -397,7 +408,7 @@ protected:
|
||||
{
|
||||
vtkm::cont::DataSet outDataSet;
|
||||
outDataSet.SetCellSet(resultCellSet);
|
||||
this->MapFieldsOntoOutput(inDataSet, outDataSet, fieldMapper);
|
||||
this->MapFieldsOntoOutput(inDataSet, this->GetFieldsToPass(), outDataSet, fieldMapper);
|
||||
return outDataSet;
|
||||
}
|
||||
|
||||
@ -436,6 +447,7 @@ protected:
|
||||
return outDataSet;
|
||||
}
|
||||
|
||||
///@{
|
||||
/// \brief Create the output data set for `DoExecute`.
|
||||
///
|
||||
/// This form of `CreateResult` will create an output data set with the given `CellSet`
|
||||
@ -457,31 +469,95 @@ protected:
|
||||
/// the function should do nothing.
|
||||
///
|
||||
template <typename FieldMapper>
|
||||
VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet,
|
||||
VTKM_CONT vtkm::cont::DataSet CreateResultCoordinateSystem(
|
||||
const vtkm::cont::DataSet& inDataSet,
|
||||
const vtkm::cont::UnknownCellSet& resultCellSet,
|
||||
const vtkm::cont::CoordinateSystem& resultCoordSystem,
|
||||
FieldMapper&& fieldMapper) const
|
||||
{
|
||||
return this->CreateResult(inDataSet,
|
||||
vtkm::cont::DataSet outDataSet;
|
||||
outDataSet.SetCellSet(resultCellSet);
|
||||
outDataSet.AddCoordinateSystem(resultCoordSystem);
|
||||
vtkm::filter::FieldSelection fieldSelection = this->GetFieldsToPass();
|
||||
fieldSelection.AddField(resultCoordSystem, vtkm::filter::FieldSelection::Mode::Exclude);
|
||||
this->MapFieldsOntoOutput(inDataSet, fieldSelection, outDataSet, fieldMapper);
|
||||
return outDataSet;
|
||||
}
|
||||
|
||||
template <typename FieldMapper>
|
||||
VTKM_CONT vtkm::cont::DataSet CreateResultCoordinateSystem(
|
||||
const vtkm::cont::DataSet& inDataSet,
|
||||
const vtkm::cont::UnknownCellSet& resultCellSet,
|
||||
const std::string& coordsName,
|
||||
const vtkm::cont::UnknownArrayHandle& coordsData,
|
||||
FieldMapper&& fieldMapper) const
|
||||
{
|
||||
return this->CreateResultCoordinateSystem(
|
||||
inDataSet,
|
||||
resultCellSet,
|
||||
std::vector<vtkm::cont::CoordinateSystem>{ resultCoordSystem },
|
||||
vtkm::cont::CoordinateSystem{ coordsName, coordsData },
|
||||
fieldMapper);
|
||||
}
|
||||
///@}
|
||||
|
||||
VTKM_CONT virtual vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) = 0;
|
||||
VTKM_CONT virtual vtkm::cont::PartitionedDataSet DoExecutePartitions(
|
||||
const vtkm::cont::PartitionedDataSet& inData);
|
||||
|
||||
private:
|
||||
template <typename DataSetType, typename FieldMapper>
|
||||
VTKM_CONT void MapFieldsOntoOutput(const DataSetType& input,
|
||||
DataSetType& output,
|
||||
template <typename FieldMapper>
|
||||
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
|
||||
const vtkm::filter::FieldSelection& fieldSelection,
|
||||
vtkm::cont::DataSet& output,
|
||||
FieldMapper&& fieldMapper) const
|
||||
{
|
||||
// Basic field mapping
|
||||
for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc)
|
||||
{
|
||||
auto field = input.GetField(cc);
|
||||
if (fieldSelection.IsFieldSelected(field))
|
||||
{
|
||||
fieldMapper(output, field);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the ghost levels have been copied. If so, set so on the output.
|
||||
if (input.HasGhostCellField())
|
||||
{
|
||||
const std::string& ghostFieldName = input.GetGhostCellFieldName();
|
||||
if (output.HasCellField(ghostFieldName) && (output.GetGhostCellFieldName() != ghostFieldName))
|
||||
{
|
||||
output.SetGhostCellFieldName(ghostFieldName);
|
||||
}
|
||||
}
|
||||
|
||||
for (vtkm::IdComponent csIndex = 0; csIndex < input.GetNumberOfCoordinateSystems(); ++csIndex)
|
||||
{
|
||||
auto coords = input.GetCoordinateSystem(csIndex);
|
||||
if (!output.HasCoordinateSystem(coords.GetName()))
|
||||
{
|
||||
if (!output.HasPointField(coords.GetName()) && this->GetPassCoordinateSystems())
|
||||
{
|
||||
fieldMapper(output, coords);
|
||||
}
|
||||
if (output.HasPointField(coords.GetName()))
|
||||
{
|
||||
output.AddCoordinateSystem(coords.GetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename FieldMapper>
|
||||
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::PartitionedDataSet& input,
|
||||
const vtkm::filter::FieldSelection& fieldSelection,
|
||||
vtkm::cont::PartitionedDataSet& output,
|
||||
FieldMapper&& fieldMapper) const
|
||||
{
|
||||
for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc)
|
||||
{
|
||||
auto field = input.GetField(cc);
|
||||
if (this->GetFieldsToPass().IsFieldSelected(field))
|
||||
if (fieldSelection.IsFieldSelected(field))
|
||||
{
|
||||
fieldMapper(output, field);
|
||||
}
|
||||
@ -493,6 +569,7 @@ private:
|
||||
|
||||
|
||||
vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All;
|
||||
bool PassCoordinateSystems = true;
|
||||
bool RunFilterWithMultipleThreads = false;
|
||||
vtkm::Id NumThreadsPerCPU = 4;
|
||||
vtkm::Id NumThreadsPerGPU = 8;
|
||||
|
@ -133,7 +133,12 @@ protected:
|
||||
{
|
||||
if (this->UseCoordinateSystemAsField[index])
|
||||
{
|
||||
return input.GetCoordinateSystem(this->GetActiveCoordinateSystemIndex(index));
|
||||
// Note that we cannot use input.GetCoordinateSystem because that does not return
|
||||
// a reference to a field. Instead, get the field name for the coordinate system
|
||||
// and return the field.
|
||||
const std::string& coordSystemName =
|
||||
input.GetCoordinateSystemName(this->GetActiveCoordinateSystemIndex(index));
|
||||
return input.GetPointField(coordSystemName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -76,7 +76,7 @@ void TestPointMerging()
|
||||
//filter for uniform data always does point merging
|
||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> newcoords;
|
||||
vtkm::cont::ArrayCopy(baseData.GetCoordinateSystem().GetData(), newcoords);
|
||||
baseData.GetCoordinateSystem().SetData(newcoords);
|
||||
baseData.AddPointField(baseData.GetCoordinateSystemName(), newcoords);
|
||||
|
||||
vtkm::filter::contour::Contour marchingCubes;
|
||||
marchingCubes.SetIsoValue(0.05);
|
||||
|
@ -144,8 +144,8 @@ vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
||||
resolveFieldType);
|
||||
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||
vtkm::cont::DataSet output = this->CreateResult(
|
||||
inDataSet, outputCells, vtkm::cont::CoordinateSystem{ "coordinates", vertices }, mapper);
|
||||
vtkm::cont::DataSet output = this->CreateResultCoordinateSystem(
|
||||
inDataSet, outputCells, inputCoords.GetName(), vertices, mapper);
|
||||
|
||||
if (this->GenerateNormals)
|
||||
{
|
||||
|
@ -335,7 +335,8 @@ VTKM_CONT vtkm::cont::DataSet MIRFilter::DoExecute(const vtkm::cont::DataSet& in
|
||||
auto mapper = [&](auto& outDataSet, const auto& f) {
|
||||
this->DoMapField(outDataSet, f, filterCellInterp, MIRWeights, MIRIDs);
|
||||
};
|
||||
auto output = this->CreateResult(input, saved.GetCellSet(), saved.GetCoordinateSystems(), mapper);
|
||||
auto output = this->CreateResultCoordinateSystem(
|
||||
input, saved.GetCellSet(), saved.GetCoordinateSystem(), mapper);
|
||||
output.AddField(saved.GetField(this->GetOutputFieldName()));
|
||||
|
||||
return output;
|
||||
|
@ -63,7 +63,7 @@ void TestClipExplicit()
|
||||
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
|
||||
"Wrong number of coordinate systems in the output dataset");
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
auto temp = outputData.GetField("scalars").GetData();
|
||||
|
@ -62,7 +62,7 @@ void TestClipStructured(vtkm::Float64 offset)
|
||||
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
|
||||
"Wrong number of coordinate systems in the output dataset");
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 8,
|
||||
"Wrong number of cells in the output dataset");
|
||||
@ -98,7 +98,7 @@ void TestClipStructuredInverted()
|
||||
clip.SetFieldsToPass("scalars");
|
||||
auto outputData = clip.Execute(ds);
|
||||
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 4,
|
||||
"Wrong number of cells in the output dataset");
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfCoordinateSystems() == 1,
|
||||
"Wrong number of coordinate systems in the output dataset");
|
||||
//since normals is on we have one field
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public:
|
||||
const bool isMapped = result.HasField("tangle");
|
||||
VTKM_TEST_ASSERT(isMapped, "mapping should pass");
|
||||
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 3,
|
||||
VTKM_TEST_ASSERT(result.GetNumberOfFields() == 4,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
//verify the cellvar result
|
||||
|
@ -60,7 +60,7 @@ vtkm::cont::DataSet ExternalFaces::GenerateOutput(const vtkm::cont::DataSet& inp
|
||||
// New Design: We are still using the old MapFieldOntoOutput to demonstrate the transition
|
||||
this->MapFieldOntoOutput(result, f);
|
||||
};
|
||||
return this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
||||
return this->CreateResult(input, outCellSet, mapper);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -70,7 +70,7 @@ vtkm::cont::DataSet ExtractGeometry::DoExecute(const vtkm::cont::DataSet& input)
|
||||
|
||||
// create the output dataset
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||
return this->CreateResult(input, outCells, input.GetCoordinateSystems(), mapper);
|
||||
return this->CreateResult(input, outCells, mapper);
|
||||
}
|
||||
|
||||
} // namespace entity_extraction
|
||||
|
@ -59,8 +59,7 @@ vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& input)
|
||||
|
||||
// create the output dataset
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
||||
vtkm::cont::DataSet output =
|
||||
this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
||||
vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper);
|
||||
|
||||
// compact the unused points in the output dataset
|
||||
if (this->CompactPoints)
|
||||
|
@ -15,27 +15,45 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
VTKM_CONT bool DoMapField(vtkm::cont::DataSet& result,
|
||||
VTKM_CONT void DoMapField(vtkm::cont::DataSet& result,
|
||||
const vtkm::cont::Field& field,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& CellFieldMap,
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& PointFieldMap)
|
||||
const vtkm::cont::ArrayHandle<vtkm::Id>& PointFieldMap,
|
||||
const vtkm::worklet::ExtractStructured& worklet)
|
||||
{
|
||||
if (field.IsPointField())
|
||||
{
|
||||
return vtkm::filter::MapFieldPermutation(field, PointFieldMap, result);
|
||||
vtkm::cont::UnknownArrayHandle array = field.GetData();
|
||||
using UniformCoordinatesArrayHandle =
|
||||
vtkm::worklet::ExtractStructured::UniformCoordinatesArrayHandle;
|
||||
using RectilinearCoordinatesArrayHandle =
|
||||
vtkm::worklet::ExtractStructured::RectilinearCoordinatesArrayHandle;
|
||||
if (array.CanConvert<UniformCoordinatesArrayHandle>())
|
||||
{
|
||||
// Special case that is more efficient for uniform coordinate arrays.
|
||||
UniformCoordinatesArrayHandle newCoords =
|
||||
worklet.MapCoordinatesUniform(array.AsArrayHandle<UniformCoordinatesArrayHandle>());
|
||||
result.AddField(vtkm::cont::Field(field.GetName(), field.GetAssociation(), newCoords));
|
||||
}
|
||||
else if (array.CanConvert<RectilinearCoordinatesArrayHandle>())
|
||||
{
|
||||
// Special case that is more efficient for uniform coordinate arrays.
|
||||
RectilinearCoordinatesArrayHandle newCoords =
|
||||
worklet.MapCoordinatesRectilinear(array.AsArrayHandle<RectilinearCoordinatesArrayHandle>());
|
||||
result.AddField(vtkm::cont::Field(field.GetName(), field.GetAssociation(), newCoords));
|
||||
}
|
||||
else
|
||||
{
|
||||
vtkm::filter::MapFieldPermutation(field, PointFieldMap, result);
|
||||
}
|
||||
}
|
||||
else if (field.IsCellField())
|
||||
{
|
||||
return vtkm::filter::MapFieldPermutation(field, CellFieldMap, result);
|
||||
vtkm::filter::MapFieldPermutation(field, CellFieldMap, result);
|
||||
}
|
||||
else if (field.IsWholeDataSetField())
|
||||
{
|
||||
result.AddField(field);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // anonymous namespace
|
||||
@ -50,7 +68,6 @@ namespace entity_extraction
|
||||
vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& input)
|
||||
{
|
||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||
const vtkm::cont::CoordinateSystem& coordinates = input.GetCoordinateSystem();
|
||||
|
||||
vtkm::worklet::ExtractStructured worklet;
|
||||
auto cellset = worklet.Run(cells.ResetCellSetList<VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED>(),
|
||||
@ -59,9 +76,6 @@ vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& inpu
|
||||
this->IncludeBoundary,
|
||||
this->IncludeOffset);
|
||||
|
||||
auto coords = worklet.MapCoordinates(coordinates);
|
||||
vtkm::cont::CoordinateSystem outputCoordinates(coordinates.GetName(), coords);
|
||||
|
||||
// Create map arrays for mapping fields. Could potentially save some time to first check to see
|
||||
// if these arrays would be used.
|
||||
auto CellFieldMap =
|
||||
@ -70,9 +84,9 @@ vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& inpu
|
||||
worklet.ProcessPointField(vtkm::cont::ArrayHandleIndex(input.GetNumberOfPoints()));
|
||||
|
||||
auto mapper = [&](auto& result, const auto& f) {
|
||||
DoMapField(result, f, CellFieldMap, PointFieldMap);
|
||||
DoMapField(result, f, CellFieldMap, PointFieldMap, worklet);
|
||||
};
|
||||
return this->CreateResult(input, cellset, outputCoordinates, mapper);
|
||||
return this->CreateResult(input, cellset, mapper);
|
||||
}
|
||||
|
||||
} // namespace entity_extraction
|
||||
|
@ -367,7 +367,7 @@ VTKM_CONT vtkm::cont::DataSet GhostCellRemove::DoExecute(const vtkm::cont::DataS
|
||||
}
|
||||
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||
return this->CreateResult(input, cellOut, input.GetCoordinateSystems(), mapper);
|
||||
return this->CreateResult(input, cellOut, mapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ VTKM_CONT vtkm::cont::DataSet Mask::DoExecute(const vtkm::cont::DataSet& input)
|
||||
|
||||
// create the output dataset
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||
return this->CreateResult(input, cellOut, input.GetCoordinateSystems(), mapper);
|
||||
return this->CreateResult(input, cellOut, mapper);
|
||||
}
|
||||
} // namespace entity_extraction
|
||||
} // namespace filter
|
||||
|
@ -56,8 +56,7 @@ VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(const vtkm::cont::DataSet& i
|
||||
|
||||
// create the output dataset
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
||||
vtkm::cont::DataSet output =
|
||||
this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
||||
vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper);
|
||||
|
||||
// compact the unused points in the output dataset
|
||||
if (this->CompactPoints)
|
||||
|
@ -148,7 +148,7 @@ vtkm::cont::DataSet Threshold::DoExecute(const vtkm::cont::DataSet& input)
|
||||
vtkm::ListForEach(callWithArrayBaseComponent, vtkm::TypeListScalarAll{});
|
||||
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||
return this->CreateResult(input, cellOut, input.GetCoordinateSystems(), mapper);
|
||||
return this->CreateResult(input, cellOut, mapper);
|
||||
}
|
||||
} // namespace entity_extraction
|
||||
} // namespace filter
|
||||
|
@ -174,8 +174,7 @@ VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(const vtkm::cont::DataS
|
||||
|
||||
// create the output dataset
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
||||
vtkm::cont::DataSet output =
|
||||
this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
||||
vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper);
|
||||
|
||||
// compact the unused points in the output dataset
|
||||
if (this->CompactPoints)
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||
@ -61,7 +61,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||
@ -105,7 +105,7 @@ public:
|
||||
|
||||
if (returnAllInRange)
|
||||
{
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||
@ -119,7 +119,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||
@ -150,7 +150,7 @@ public:
|
||||
threshold.SetFieldsToPass("cellvar");
|
||||
auto output = threshold.Execute(dataset);
|
||||
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||
@ -180,7 +180,7 @@ public:
|
||||
threshold.SetFieldsToPass("cellvar");
|
||||
auto output = threshold.Execute(dataset);
|
||||
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
|
||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||
|
@ -97,7 +97,7 @@ public:
|
||||
thresholdPoints.SetActiveField("pointvar");
|
||||
thresholdPoints.SetFieldsToPass("pointvar");
|
||||
auto output = thresholdPoints.Execute(dataset);
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||
"Wrong number of fields in the output dataset");
|
||||
VTKM_TEST_ASSERT(test_equal(output.GetNumberOfCells(), 0), "Wrong result for ThresholdPoints");
|
||||
}
|
||||
|
@ -415,7 +415,6 @@ public:
|
||||
return output;
|
||||
}
|
||||
|
||||
private:
|
||||
using UniformCoordinatesArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||
|
||||
using RectilinearCoordinatesArrayHandle =
|
||||
@ -424,7 +423,8 @@ private:
|
||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>;
|
||||
|
||||
|
||||
UniformCoordinatesArrayHandle MapCoordinatesUniform(const UniformCoordinatesArrayHandle& coords)
|
||||
UniformCoordinatesArrayHandle MapCoordinatesUniform(
|
||||
const UniformCoordinatesArrayHandle& coords) const
|
||||
{
|
||||
using CoordsArray = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||
using CoordType = CoordsArray::ValueType;
|
||||
@ -444,7 +444,7 @@ private:
|
||||
}
|
||||
|
||||
RectilinearCoordinatesArrayHandle MapCoordinatesRectilinear(
|
||||
const RectilinearCoordinatesArrayHandle& coords)
|
||||
const RectilinearCoordinatesArrayHandle& coords) const
|
||||
{
|
||||
// For structured datasets, the cellsets are of different types based on
|
||||
// its dimensionality, but the coordinates are always 3 dimensional.
|
||||
@ -479,41 +479,6 @@ private:
|
||||
return vtkm::cont::make_ArrayHandleCartesianProduct(xyzs[0], xyzs[1], xyzs[2]);
|
||||
}
|
||||
|
||||
struct MapCoordinatesFunctor
|
||||
{
|
||||
template <typename T, typename S>
|
||||
VTKM_CONT void operator()(const vtkm::cont::ArrayHandle<T, S>& coords,
|
||||
ExtractStructured& self,
|
||||
vtkm::cont::UnknownArrayHandle& output) const
|
||||
{
|
||||
output = self.ProcessPointField(coords);
|
||||
}
|
||||
|
||||
VTKM_CONT void operator()(const UniformCoordinatesArrayHandle::Superclass& coords,
|
||||
ExtractStructured& self,
|
||||
vtkm::cont::UnknownArrayHandle& output) const
|
||||
{
|
||||
output = self.MapCoordinatesUniform(coords);
|
||||
}
|
||||
|
||||
VTKM_CONT void operator()(const RectilinearCoordinatesArrayHandle::Superclass& coords,
|
||||
ExtractStructured& self,
|
||||
vtkm::cont::UnknownArrayHandle& output) const
|
||||
{
|
||||
output = self.MapCoordinatesRectilinear(coords);
|
||||
}
|
||||
};
|
||||
|
||||
friend MapCoordinatesFunctor;
|
||||
|
||||
public:
|
||||
vtkm::cont::UnknownArrayHandle MapCoordinates(const vtkm::cont::CoordinateSystem& coordinates)
|
||||
{
|
||||
vtkm::cont::UnknownArrayHandle output;
|
||||
vtkm::cont::CastAndCall(coordinates, MapCoordinatesFunctor{}, *this, output);
|
||||
return output;
|
||||
}
|
||||
|
||||
public:
|
||||
template <typename T, typename Storage>
|
||||
vtkm::cont::ArrayHandle<T> ProcessPointField(
|
||||
|
@ -8,6 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
#include <vtkm/filter/field_transform/CylindricalCoordinateTransform.h>
|
||||
#include <vtkm/filter/field_transform/worklet/CoordinateSystemTransform.h>
|
||||
|
||||
@ -18,10 +19,21 @@ namespace filter
|
||||
namespace field_transform
|
||||
{
|
||||
|
||||
CylindricalCoordinateTransform::CylindricalCoordinateTransform()
|
||||
{
|
||||
this->SetUseCoordinateSystemAsField(true);
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
||||
{
|
||||
vtkm::cont::UnknownArrayHandle outArray;
|
||||
|
||||
const vtkm::cont::Field& inField = this->GetFieldFromDataSet(inDataSet);
|
||||
if (!inField.IsPointField())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("CylindricalCoordinateTransform only applies to point data.");
|
||||
}
|
||||
|
||||
auto resolveType = [&](const auto& concrete) {
|
||||
// use std::decay to remove const ref from the decltype of concrete.
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
@ -32,12 +44,18 @@ vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(const vtkm::cont::
|
||||
this->Invoke(vtkm::worklet::CylToCar{}, concrete, result);
|
||||
outArray = result;
|
||||
};
|
||||
this->CastAndCallVecField<3>(this->GetFieldFromDataSet(inDataSet), resolveType);
|
||||
this->CastAndCallVecField<3>(inField, resolveType);
|
||||
|
||||
vtkm::cont::DataSet outDataSet =
|
||||
this->CreateResult(inDataSet,
|
||||
std::string coordinateName = this->GetOutputFieldName();
|
||||
if (coordinateName.empty())
|
||||
{
|
||||
coordinateName = inField.GetName();
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet outDataSet = this->CreateResultCoordinateSystem(
|
||||
inDataSet,
|
||||
inDataSet.GetCellSet(),
|
||||
vtkm::cont::CoordinateSystem("coordinates", outArray),
|
||||
vtkm::cont::CoordinateSystem(coordinateName, outArray),
|
||||
[](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
||||
out.AddField(fieldToPass);
|
||||
});
|
||||
|
@ -27,6 +27,8 @@ class VTKM_FILTER_FIELD_TRANSFORM_EXPORT CylindricalCoordinateTransform
|
||||
: public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT CylindricalCoordinateTransform();
|
||||
|
||||
VTKM_CONT void SetCartesianToCylindrical() { CartesianToCylindrical = true; }
|
||||
VTKM_CONT void SetCylindricalToCartesian() { CartesianToCylindrical = false; }
|
||||
|
||||
|
@ -51,8 +51,9 @@ VTKM_CONT vtkm::cont::DataSet PointTransform::DoExecute(const vtkm::cont::DataSe
|
||||
const auto& field = this->GetFieldFromDataSet(inDataSet);
|
||||
this->CastAndCallVecField<3>(field, resolveType);
|
||||
|
||||
vtkm::cont::DataSet outData = this->CreateResultField(
|
||||
inDataSet, this->GetOutputFieldName(), field.GetAssociation(), outArray);
|
||||
auto passMapper = [](auto& d, const auto& f) { d.AddField(f); };
|
||||
vtkm::cont::DataSet outData = this->CreateResultCoordinateSystem(
|
||||
inDataSet, inDataSet.GetCellSet(), this->GetOutputFieldName(), outArray, passMapper);
|
||||
|
||||
if (this->GetChangeCoordinateSystem())
|
||||
{
|
||||
|
@ -8,6 +8,7 @@
|
||||
// PURPOSE. See the above copyright notice for more information.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/cont/ErrorBadValue.h>
|
||||
#include <vtkm/filter/field_transform/SphericalCoordinateTransform.h>
|
||||
#include <vtkm/filter/field_transform/worklet/CoordinateSystemTransform.h>
|
||||
|
||||
@ -17,10 +18,22 @@ namespace filter
|
||||
{
|
||||
namespace field_transform
|
||||
{
|
||||
|
||||
SphericalCoordinateTransform::SphericalCoordinateTransform()
|
||||
{
|
||||
this->SetUseCoordinateSystemAsField(true);
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
||||
{
|
||||
vtkm::cont::UnknownArrayHandle outArray;
|
||||
|
||||
const vtkm::cont::Field& inField = this->GetFieldFromDataSet(inDataSet);
|
||||
if (!inField.IsPointField())
|
||||
{
|
||||
throw vtkm::cont::ErrorBadValue("SphericalCoordinateTransform only applies to point data.");
|
||||
}
|
||||
|
||||
auto resolveType = [&](const auto& concrete) {
|
||||
// use std::decay to remove const ref from the decltype of concrete.
|
||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||
@ -31,12 +44,18 @@ vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(const vtkm::cont::Da
|
||||
this->Invoke(vtkm::worklet::SphereToCar{}, concrete, result);
|
||||
outArray = result;
|
||||
};
|
||||
this->CastAndCallVecField<3>(this->GetFieldFromDataSet(inDataSet), resolveType);
|
||||
this->CastAndCallVecField<3>(inField, resolveType);
|
||||
|
||||
vtkm::cont::DataSet outDataSet =
|
||||
this->CreateResult(inDataSet,
|
||||
std::string coordinateName = this->GetOutputFieldName();
|
||||
if (coordinateName.empty())
|
||||
{
|
||||
coordinateName = inField.GetName();
|
||||
}
|
||||
|
||||
vtkm::cont::DataSet outDataSet = this->CreateResultCoordinateSystem(
|
||||
inDataSet,
|
||||
inDataSet.GetCellSet(),
|
||||
vtkm::cont::CoordinateSystem("coordinates", outArray),
|
||||
vtkm::cont::CoordinateSystem(coordinateName, outArray),
|
||||
[](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
||||
out.AddField(fieldToPass);
|
||||
});
|
||||
|
@ -25,6 +25,8 @@ class VTKM_FILTER_FIELD_TRANSFORM_EXPORT SphericalCoordinateTransform
|
||||
: public vtkm::filter::NewFilterField
|
||||
{
|
||||
public:
|
||||
VTKM_CONT SphericalCoordinateTransform();
|
||||
|
||||
VTKM_CONT void SetCartesianToSpherical() { CartesianToSpherical = true; }
|
||||
VTKM_CONT void SetSphericalToCartesian() { CartesianToSpherical = false; }
|
||||
|
||||
|
@ -262,7 +262,7 @@ VTKM_CONT vtkm::cont::DataSet Lagrangian::DoExecute(const vtkm::cont::DataSet& i
|
||||
auto fieldmapper = [&](vtkm::cont::DataSet& dataset, const vtkm::cont::Field& fieldToPass) {
|
||||
MapField(dataset, fieldToPass);
|
||||
};
|
||||
outputData = this->CreateResult(input, outCellSet, outCoords, fieldmapper);
|
||||
outputData = this->CreateResultCoordinateSystem(input, outCellSet, outCoords, fieldmapper);
|
||||
outputData.AddPointField("valid", this->BasisParticlesValidity);
|
||||
outputData.AddPointField("displacement", basisParticlesDisplacement);
|
||||
|
||||
|
@ -174,8 +174,8 @@ VTKM_CONT vtkm::cont::DataSet LagrangianStructures::DoExecute(const vtkm::cont::
|
||||
auto fieldmapper = [&](vtkm::cont::DataSet& dataset, const vtkm::cont::Field& field) {
|
||||
MapField(dataset, field);
|
||||
};
|
||||
vtkm::cont::DataSet output =
|
||||
this->CreateResult(input, lcsInput.GetCellSet(), lcsInput.GetCoordinateSystem(), fieldmapper);
|
||||
vtkm::cont::DataSet output = this->CreateResultCoordinateSystem(
|
||||
input, lcsInput.GetCellSet(), lcsInput.GetCoordinateSystem(), fieldmapper);
|
||||
output.AddPointField(this->GetOutputFieldName(), outputField);
|
||||
return output;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ void TestLagrangianFilterMultiStepInterval()
|
||||
"Wrong number of coordinate systems in the output dataset.");
|
||||
VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfPoints() == 512,
|
||||
"Wrong number of basis flows extracted.");
|
||||
VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfFields() == 2, "Wrong number of fields.");
|
||||
VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfFields() == 3, "Wrong number of fields.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,8 +62,8 @@ VTKM_CONT vtkm::cont::DataSet VertexClustering::DoExecute(const vtkm::cont::Data
|
||||
outCoords);
|
||||
|
||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||
return this->CreateResult(
|
||||
input, outCellSet, vtkm::cont::CoordinateSystem("coordinates", outCoords), mapper);
|
||||
return this->CreateResultCoordinateSystem(
|
||||
input, outCellSet, input.GetCoordinateSystem().GetName(), outCoords, mapper);
|
||||
}
|
||||
} // namespace geometry_refinement
|
||||
} // namespace filter
|
||||
|
@ -76,8 +76,8 @@ vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input)
|
||||
auto mapper = [&](auto& outDataSet, const auto& f) {
|
||||
DoMapField(outDataSet, f, worklet, this->InvalidValue);
|
||||
};
|
||||
auto output = this->CreateResult(
|
||||
input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystems(), mapper);
|
||||
auto output = this->CreateResultCoordinateSystem(
|
||||
input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystem(), mapper);
|
||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField()));
|
||||
output.AddField(
|
||||
vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet())));
|
||||
|
@ -320,6 +320,12 @@ void WritePointFields(std::ostream& out,
|
||||
continue;
|
||||
}
|
||||
|
||||
if (field.GetName() == dataSet.GetCoordinateSystemName())
|
||||
{
|
||||
// Do not write out the first coordinate system as a field.
|
||||
continue;
|
||||
}
|
||||
|
||||
vtkm::Id npoints = field.GetNumberOfValues();
|
||||
int ncomps = field.GetData().GetNumberOfComponentsFlat();
|
||||
|
||||
|
@ -45,7 +45,7 @@ void TestReadingBOVDataSet()
|
||||
|
||||
auto const& ds = readBOVDataSet(bovFile.data());
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
// See the .bov file: DATA SIZE: 50 50 50
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50,
|
||||
@ -53,7 +53,7 @@ void TestReadingBOVDataSet()
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == 49 * 49 * 49, "Incorrect number of cells");
|
||||
// See the .bov file: VARIABLE: "var"
|
||||
VTKM_TEST_ASSERT(ds.HasField("var"), "Should have field 'var', but does not.");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "There is only one field in noise.bov");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "There is only one field in noise.bov");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
|
||||
"There is only one coordinate system in noise.bov");
|
||||
|
||||
|
@ -53,7 +53,7 @@ void TestReadingPolyData(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 5, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 6, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 8, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 8,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -70,7 +70,7 @@ void TestReadingPolyDataEmpty()
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 8);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
||||
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 8);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 1);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 2);
|
||||
}
|
||||
|
||||
void TestReadingStructuredPoints(Format format)
|
||||
@ -81,7 +81,7 @@ void TestReadingStructuredPoints(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 72, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -99,7 +99,7 @@ void TestReadingStructuredPointsVisIt(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 64, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 64,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -116,7 +116,7 @@ void TestReadingUnstructuredGrid(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 26, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -133,7 +133,7 @@ void TestReadingV5Format(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 6, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 7, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 26, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -173,7 +173,7 @@ void TestReadingUnstructuredGridEmpty()
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 26);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
||||
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 26);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 2);
|
||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 3);
|
||||
}
|
||||
|
||||
void TestReadingUnstructuredPixels()
|
||||
@ -291,7 +291,7 @@ void TestReadingUnstructuredGridVisIt(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 26, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -309,7 +309,7 @@ void TestReadingRectilinearGrid1(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 125, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 125,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -327,7 +327,7 @@ void TestReadingRectilinearGrid2(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 24, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 24,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -343,7 +343,7 @@ void TestReadingStructuredGridASCII()
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 6, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 6,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -359,7 +359,7 @@ void TestReadingStructuredGridBin()
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 18, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 18,
|
||||
"Incorrect number of points (from cell set)");
|
||||
@ -379,7 +379,7 @@ void TestReadingFishTank()
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50,
|
||||
"Incorrect number of points (from cell set)");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 3, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.HasField("vec"), "The vtk file has a field 'vec', but the dataset does not.");
|
||||
VTKM_TEST_ASSERT(ds.HasField("vec_magnitude"),
|
||||
"The vtk file has a field 'vec_magnitude', but the dataset does not.");
|
||||
@ -622,7 +622,7 @@ void TestSkppingStringFields(Format format)
|
||||
|
||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
||||
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 1, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfFields() == 2, "Incorrect number of fields");
|
||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == 72, "Incorrect number of points");
|
||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72,
|
||||
"Incorrect number of points (from cell set)");
|
||||
|
@ -112,6 +112,13 @@ void CheckWrittenReadData(const vtkm::cont::DataSet& originalData,
|
||||
for (vtkm::IdComponent fieldId = 0; fieldId < originalData.GetNumberOfFields(); ++fieldId)
|
||||
{
|
||||
vtkm::cont::Field originalField = originalData.GetField(fieldId);
|
||||
if (originalField.IsPointField() &&
|
||||
(originalField.GetName() == originalData.GetCoordinateSystemName()))
|
||||
{
|
||||
// Do not check the field that is the first coordinate system. It is likely to have
|
||||
// changed name because VTK does not name coordinate systems.
|
||||
continue;
|
||||
}
|
||||
VTKM_TEST_ASSERT(fileData.HasField(originalField.GetName(), originalField.GetAssociation()));
|
||||
vtkm::cont::Field fileField =
|
||||
fileData.GetField(originalField.GetName(), originalField.GetAssociation());
|
||||
|
@ -39,20 +39,16 @@ protected:
|
||||
bool CompositeBackground;
|
||||
|
||||
public:
|
||||
InternalsType(vtkm::cont::DataSet& dataSet)
|
||||
InternalsType(const vtkm::cont::DataSet& dataSet, const std::string& fieldName)
|
||||
{
|
||||
Dataset = dataSet;
|
||||
Cells = dataSet.GetCellSet();
|
||||
Coords = dataSet.GetCoordinateSystem();
|
||||
Mode = RenderMode::Volume;
|
||||
CompositeBackground = true;
|
||||
//
|
||||
// Just grab a default scalar field
|
||||
//
|
||||
|
||||
if (Dataset.GetNumberOfFields() > 0)
|
||||
if (!fieldName.empty())
|
||||
{
|
||||
this->SetScalarField(Dataset.GetField(0).GetName());
|
||||
this->SetScalarField(fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,8 +239,9 @@ public:
|
||||
|
||||
|
||||
VTKM_CONT
|
||||
ConnectivityProxy::ConnectivityProxy(vtkm::cont::DataSet& dataSet)
|
||||
: Internals(new InternalsType(dataSet))
|
||||
ConnectivityProxy::ConnectivityProxy(const vtkm::cont::DataSet& dataSet,
|
||||
const std::string& fieldName)
|
||||
: Internals(new InternalsType(dataSet, fieldName))
|
||||
{
|
||||
}
|
||||
|
||||
@ -259,7 +256,7 @@ ConnectivityProxy::ConnectivityProxy(const vtkm::cont::UnknownCellSet& cellset,
|
||||
dataset.AddCoordinateSystem(coords);
|
||||
dataset.AddField(scalarField);
|
||||
|
||||
Internals = std::shared_ptr<InternalsType>(new InternalsType(dataset));
|
||||
Internals = std::shared_ptr<InternalsType>(new InternalsType(dataset, scalarField.GetName()));
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
|
@ -31,7 +31,7 @@ using PartialVector32 = std::vector<vtkm::rendering::raytracing::PartialComposit
|
||||
class VTKM_RENDERING_EXPORT ConnectivityProxy
|
||||
{
|
||||
public:
|
||||
ConnectivityProxy(vtkm::cont::DataSet& dataset);
|
||||
ConnectivityProxy(const vtkm::cont::DataSet& dataset, const std::string& fieldName);
|
||||
ConnectivityProxy(const vtkm::cont::UnknownCellSet& cellset,
|
||||
const vtkm::cont::CoordinateSystem& coords,
|
||||
const vtkm::cont::Field& scalarField);
|
||||
|
@ -363,7 +363,7 @@ void MapperGlyphScalar::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
|
||||
vtkm::cont::DataSet processedDataSet = this->FilterPoints(cellset, coords, scalarField);
|
||||
vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet();
|
||||
vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem();
|
||||
vtkm::cont::Field processedField = processedDataSet.GetField(0);
|
||||
vtkm::cont::Field processedField = processedDataSet.GetField(scalarField.GetName());
|
||||
|
||||
if (this->ScaleByValue)
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ void MapperGlyphVector::RenderCells(const vtkm::cont::UnknownCellSet& cellset,
|
||||
vtkm::cont::DataSet processedDataSet = this->FilterPoints(cellset, coords, field);
|
||||
vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet();
|
||||
vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem();
|
||||
vtkm::cont::Field processedField = processedDataSet.GetField(0);
|
||||
vtkm::cont::Field processedField = processedDataSet.GetField(field.GetName());
|
||||
|
||||
if (this->ScaleByValue)
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ void MapperWireframer::RenderCells(const vtkm::cont::UnknownCellSet& inCellSet,
|
||||
externalFaces.SetPassPolyData(true);
|
||||
vtkm::cont::DataSet output = externalFaces.Execute(dataSet);
|
||||
cellSet = output.GetCellSet();
|
||||
actualField = output.GetField(0);
|
||||
actualField = output.GetField(inScalarField.GetName());
|
||||
}
|
||||
|
||||
// Extract unique edges from the cell set.
|
||||
|
Loading…
Reference in New Issue
Block a user