Coordinate 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 commit is contained in:
parent
dbc2364e35
commit
2d30e6d45a
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) {
|
auto mapper = [&](auto& outDataSet, const auto& f) {
|
||||||
DoMapField(outDataSet, f, outputToInputCellMap, cellToEdgeKeys);
|
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)
|
int main(int argc, char** argv)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
#include <vtkm/cont/ArrayHandleCompositeVector.h>
|
||||||
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
#include <vtkm/cont/ArrayHandleUniformPointCoordinates.h>
|
||||||
#include <vtkm/cont/CoordinateSystem.h>
|
#include <vtkm/cont/CoordinateSystem.h>
|
||||||
|
#include <vtkm/cont/ErrorBadValue.h>
|
||||||
|
|
||||||
namespace vtkm
|
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,
|
VTKM_CONT CoordinateSystem::CoordinateSystem(std::string name,
|
||||||
const vtkm::cont::UnknownArrayHandle& data)
|
const vtkm::cont::UnknownArrayHandle& data)
|
||||||
: Superclass(name, Association::Points, data)
|
: Superclass(name, Association::Points, data)
|
||||||
|
@ -31,6 +31,9 @@ public:
|
|||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
CoordinateSystem();
|
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);
|
VTKM_CONT CoordinateSystem(std::string name, const vtkm::cont::UnknownArrayHandle& data);
|
||||||
|
|
||||||
template <typename T, typename Storage>
|
template <typename T, typename Storage>
|
||||||
|
@ -9,8 +9,11 @@
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include <vtkm/cont/DataSet.h>
|
#include <vtkm/cont/DataSet.h>
|
||||||
|
#include <vtkm/cont/ErrorBadValue.h>
|
||||||
#include <vtkm/cont/Logging.h>
|
#include <vtkm/cont/Logging.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -84,7 +87,7 @@ VTKM_CONT void SetGlobalGhostCellFieldName(const std::string& name) noexcept
|
|||||||
|
|
||||||
void DataSet::Clear()
|
void DataSet::Clear()
|
||||||
{
|
{
|
||||||
this->CoordSystems.clear();
|
this->CoordSystemNames.clear();
|
||||||
this->Fields.Clear();
|
this->Fields.Clear();
|
||||||
this->CellSet = this->CellSet.NewInstance();
|
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->AddField(cs);
|
||||||
this->CoordSystems.push_back(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)
|
void DataSet::SetCellSetImpl(const vtkm::cont::UnknownCellSet& cellSet)
|
||||||
@ -211,67 +235,82 @@ void DataSet::SetGhostCellField(const vtkm::cont::UnknownArrayHandle& field)
|
|||||||
this->SetGhostCellField(GetGlobalGhostCellFieldName(), field);
|
this->SetGhostCellField(GetGlobalGhostCellFieldName(), field);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataSet::CopyStructure(const vtkm::cont::DataSet& source)
|
void DataSet::CopyPartsFromExcept(const vtkm::cont::DataSet& source,
|
||||||
|
vtkm::cont::DataSet::Parts partMask)
|
||||||
{
|
{
|
||||||
this->CoordSystems = source.CoordSystems;
|
if ((partMask & vtkm::cont::DataSet::Parts::CellSet) == vtkm::cont::DataSet::Parts::None)
|
||||||
this->CellSet = source.CellSet;
|
{
|
||||||
this->GhostCellName = source.GhostCellName;
|
this->CellSet = source.CellSet;
|
||||||
|
}
|
||||||
|
if ((partMask & vtkm::cont::DataSet::Parts::GhostCellName) == vtkm::cont::DataSet::Parts::None)
|
||||||
|
{
|
||||||
|
this->GhostCellName = source.GhostCellName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((partMask & vtkm::cont::DataSet::Parts::Fields) == vtkm::cont::DataSet::Parts::None)
|
||||||
|
{
|
||||||
|
vtkm::IdComponent numFields = source.GetNumberOfFields();
|
||||||
|
for (vtkm::IdComponent fIndex = 0; fIndex < numFields; ++fIndex)
|
||||||
|
{
|
||||||
|
this->AddField(source.GetField(fIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((partMask & vtkm::cont::DataSet::Parts::Coordinates) == vtkm::cont::DataSet::Parts::None)
|
||||||
|
{
|
||||||
|
vtkm::IdComponent numCoords = source.GetNumberOfCoordinateSystems();
|
||||||
|
for (vtkm::IdComponent cIndex = 0; cIndex < numCoords; ++cIndex)
|
||||||
|
{
|
||||||
|
std::string coordName = source.GetCoordinateSystemName(cIndex);
|
||||||
|
if (this->HasPointField(coordName))
|
||||||
|
{
|
||||||
|
this->AddCoordinateSystem(coordName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->AddCoordinateSystem(source.GetCoordinateSystem(cIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CheckFieldSizes(this->CellSet, this->Fields);
|
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()));
|
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
|
||||||
{
|
{
|
||||||
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems()));
|
auto nameIter = std::find(this->CoordSystemNames.begin(), this->CoordSystemNames.end(), name);
|
||||||
return this->CoordSystems[static_cast<std::size_t>(index)];
|
if (nameIter != this->CoordSystemNames.end())
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
return static_cast<vtkm::IdComponent>(std::distance(this->CoordSystemNames.begin(), nameIter));
|
||||||
{
|
}
|
||||||
index = static_cast<vtkm::Id>(std::distance(this->CoordSystems.begin(), i));
|
else
|
||||||
break;
|
{
|
||||||
}
|
return -1;
|
||||||
}
|
}
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& name) const
|
const std::string& DataSet::GetCoordinateSystemName(vtkm::Id index) const
|
||||||
|
{
|
||||||
|
VTKM_ASSERT((index >= 0) && (index < this->GetNumberOfCoordinateSystems()));
|
||||||
|
return this->CoordSystemNames[static_cast<std::size_t>(index)];
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkm::cont::CoordinateSystem DataSet::GetCoordinateSystem(const std::string& name) const
|
||||||
{
|
{
|
||||||
vtkm::Id index = this->GetCoordinateSystemIndex(name);
|
vtkm::Id index = this->GetCoordinateSystemIndex(name);
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
{
|
{
|
||||||
std::string error_message("No coordinate system with the name " + name +
|
std::string error_message("No coordinate system with the name " + name +
|
||||||
" valid names are: \n");
|
" valid names are: \n");
|
||||||
for (const auto& cs : this->CoordSystems)
|
for (const auto& csn : this->CoordSystemNames)
|
||||||
{
|
{
|
||||||
error_message += cs.GetName() + "\n";
|
error_message += csn + "\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";
|
|
||||||
}
|
}
|
||||||
throw vtkm::cont::ErrorBadValue(error_message);
|
throw vtkm::cont::ErrorBadValue(error_message);
|
||||||
}
|
}
|
||||||
@ -281,11 +320,13 @@ vtkm::cont::CoordinateSystem& DataSet::GetCoordinateSystem(const std::string& na
|
|||||||
void DataSet::PrintSummary(std::ostream& out) const
|
void DataSet::PrintSummary(std::ostream& out) const
|
||||||
{
|
{
|
||||||
out << "DataSet:\n";
|
out << "DataSet:\n";
|
||||||
out << " CoordSystems[" << this->CoordSystems.size() << "]\n";
|
out << " CoordSystems[" << this->CoordSystemNames.size() << "]\n";
|
||||||
for (std::size_t index = 0; index < this->CoordSystems.size(); index++)
|
out << " ";
|
||||||
|
for (const auto& csn : this->CoordSystemNames)
|
||||||
{
|
{
|
||||||
this->CoordSystems[index].PrintSummary(out);
|
out << " " << csn;
|
||||||
}
|
}
|
||||||
|
out << "\n";
|
||||||
|
|
||||||
out << " CellSet \n";
|
out << " CellSet \n";
|
||||||
this->GetCellSet().PrintSummary(out);
|
this->GetCellSet().PrintSummary(out);
|
||||||
|
@ -44,6 +44,19 @@ public:
|
|||||||
|
|
||||||
vtkm::cont::DataSet& operator=(const vtkm::cont::DataSet&) = default;
|
vtkm::cont::DataSet& operator=(const vtkm::cont::DataSet&) = default;
|
||||||
|
|
||||||
|
/// \brief An enumeration that can be used to refer to the parts of a `DataSet`.
|
||||||
|
///
|
||||||
|
/// The items can be or'ed together (`|`) to refer to multiple parts.
|
||||||
|
enum struct Parts : vtkm::UInt32
|
||||||
|
{
|
||||||
|
None = 0x00,
|
||||||
|
CellSet = 0x01,
|
||||||
|
Fields = 0x02,
|
||||||
|
Coordinates = 0x04,
|
||||||
|
GhostCellName = 0x08,
|
||||||
|
All = 0xFF
|
||||||
|
};
|
||||||
|
|
||||||
VTKM_CONT void Clear();
|
VTKM_CONT void Clear();
|
||||||
|
|
||||||
/// Get the number of cells contained in this DataSet
|
/// Get the number of cells contained in this DataSet
|
||||||
@ -259,8 +272,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
|
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
|
VTKM_CONT
|
||||||
bool HasCoordinateSystem(const std::string& name) const
|
bool HasCoordinateSystem(const std::string& name) const
|
||||||
@ -269,34 +295,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0) const;
|
vtkm::cont::CoordinateSystem GetCoordinateSystem(vtkm::Id index = 0) const;
|
||||||
|
|
||||||
VTKM_CONT
|
/// Returns the index for the CoordinateSystem whose
|
||||||
vtkm::cont::CoordinateSystem& GetCoordinateSystem(vtkm::Id index = 0);
|
|
||||||
|
|
||||||
/// Returns the index for the first CoordinateSystem whose
|
|
||||||
/// name matches the provided string.
|
/// name matches the provided string.
|
||||||
/// Will return -1 if no match is found
|
/// Will return -1 if no match is found
|
||||||
VTKM_CONT
|
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
|
/// Will throw an exception if no match is found
|
||||||
///@{
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
const vtkm::cont::CoordinateSystem& GetCoordinateSystem(const std::string& name) 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename CellSetType>
|
template <typename CellSetType>
|
||||||
VTKM_CONT void SetCellSet(const CellSetType& cellSet)
|
VTKM_CONT void SetCellSet(const CellSetType& cellSet)
|
||||||
@ -317,13 +329,35 @@ public:
|
|||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
vtkm::IdComponent GetNumberOfCoordinateSystems() const
|
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
|
/// Copies the structure i.e. coordinates systems and cellset from the source
|
||||||
/// dataset. The fields are left unchanged.
|
/// dataset. The fields are left unchanged.
|
||||||
|
VTKM_DEPRECATED(2.0, "Use CopyPartsFromExcept(source, vtkm::cont::DataSet::Parts::Fields)")
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
void CopyStructure(const vtkm::cont::DataSet& source);
|
void CopyStructure(const vtkm::cont::DataSet& source)
|
||||||
|
{
|
||||||
|
this->CopyPartsFromExcept(source, vtkm::cont::DataSet::Parts::Fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Copy parts from a source data set.
|
||||||
|
///
|
||||||
|
/// Data from the `source` `DataSet` are copied into this `DataSet`. Where possible,
|
||||||
|
/// parts like `Field`s and `CoordinateSystem`s from the source are added. Parts that
|
||||||
|
/// only have one instance in the `DataSet`, such as the `CellSet`, are replaced.
|
||||||
|
///
|
||||||
|
/// By default, all parts are copied. A `partMask` is provided that
|
||||||
|
/// specifies which parts _not_ to copy. For example, to copy only the structure
|
||||||
|
/// but not any of the fields, specify to not copy the fields or coordinates as so.
|
||||||
|
///
|
||||||
|
/// ```cpp
|
||||||
|
/// dest.CopyPartsFromExcept(
|
||||||
|
/// src, vtkm::cont::DataSet::Parts::Fields | vtkm::cont::DataSet::Parts::Coordinates);
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
VTKM_CONT
|
||||||
|
void CopyPartsFromExcept(const vtkm::cont::DataSet& source, vtkm::cont::DataSet::Parts partMask);
|
||||||
|
|
||||||
/// \brief Convert the structures in this data set to expected types.
|
/// \brief Convert the structures in this data set to expected types.
|
||||||
///
|
///
|
||||||
@ -344,7 +378,7 @@ public:
|
|||||||
void PrintSummary(std::ostream& out) const;
|
void PrintSummary(std::ostream& out) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<vtkm::cont::CoordinateSystem> CoordSystems;
|
std::vector<std::string> CoordSystemNames;
|
||||||
vtkm::cont::internal::FieldCollection Fields{ vtkm::cont::Field::Association::WholeDataSet,
|
vtkm::cont::internal::FieldCollection Fields{ vtkm::cont::Field::Association::WholeDataSet,
|
||||||
vtkm::cont::Field::Association::Points,
|
vtkm::cont::Field::Association::Points,
|
||||||
vtkm::cont::Field::Association::Cells };
|
vtkm::cont::Field::Association::Cells };
|
||||||
@ -355,6 +389,20 @@ private:
|
|||||||
VTKM_CONT void SetCellSetImpl(const vtkm::cont::UnknownCellSet& cellSet);
|
VTKM_CONT void SetCellSetImpl(const vtkm::cont::UnknownCellSet& cellSet);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VTKM_CONT inline vtkm::cont::DataSet::Parts operator|(vtkm::cont::DataSet::Parts lhs,
|
||||||
|
vtkm::cont::DataSet::Parts rhs)
|
||||||
|
{
|
||||||
|
using T = std::underlying_type_t<vtkm::cont::DataSet::Parts>;
|
||||||
|
return static_cast<vtkm::cont::DataSet::Parts>(static_cast<T>(lhs) | static_cast<T>(rhs));
|
||||||
|
}
|
||||||
|
|
||||||
|
VTKM_CONT inline vtkm::cont::DataSet::Parts operator&(vtkm::cont::DataSet::Parts lhs,
|
||||||
|
vtkm::cont::DataSet::Parts rhs)
|
||||||
|
{
|
||||||
|
using T = std::underlying_type_t<vtkm::cont::DataSet::Parts>;
|
||||||
|
return static_cast<vtkm::cont::DataSet::Parts>(static_cast<T>(lhs) & static_cast<T>(rhs));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cont
|
} // namespace cont
|
||||||
} // namespace vtkm
|
} // namespace vtkm
|
||||||
|
|
||||||
@ -396,13 +444,6 @@ public:
|
|||||||
{
|
{
|
||||||
const auto& dataset = serializable.DataSet;
|
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{}));
|
vtkmdiy::save(bb, dataset.GetCellSet().ResetCellSetList(CellSetTypesList{}));
|
||||||
|
|
||||||
vtkm::IdComponent numberOfFields = dataset.GetNumberOfFields();
|
vtkm::IdComponent numberOfFields = dataset.GetNumberOfFields();
|
||||||
@ -411,6 +452,13 @@ public:
|
|||||||
{
|
{
|
||||||
vtkmdiy::save(bb, dataset.GetField(i));
|
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)
|
static VTKM_CONT void load(BinaryBuffer& bb, Type& serializable)
|
||||||
@ -418,15 +466,6 @@ public:
|
|||||||
auto& dataset = serializable.DataSet;
|
auto& dataset = serializable.DataSet;
|
||||||
dataset = {}; // clear
|
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;
|
vtkm::cont::UncertainCellSet<CellSetTypesList> cells;
|
||||||
vtkmdiy::load(bb, cells);
|
vtkmdiy::load(bb, cells);
|
||||||
dataset.SetCellSet(cells);
|
dataset.SetCellSet(cells);
|
||||||
@ -439,6 +478,15 @@ public:
|
|||||||
vtkmdiy::load(bb, field);
|
vtkmdiy::load(bb, field);
|
||||||
dataset.AddField(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..
|
//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.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
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)
|
const vtkm::Bounds& bounds)
|
||||||
{
|
{
|
||||||
//Verify basics..
|
//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.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||||
|
@ -30,7 +30,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
|||||||
{
|
{
|
||||||
//Verify basics..
|
//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.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||||
|
@ -31,7 +31,7 @@ void ValidateDataSet(const vtkm::cont::DataSet& ds,
|
|||||||
{
|
{
|
||||||
//Verify basics..
|
//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.GetNumberOfCoordinateSystems() == 1, "Wrong number of coordinate systems.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
VTKM_TEST_ASSERT(ds.GetNumberOfPoints() == numPoints, "Wrong number of coordinates.");
|
||||||
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == numCells, "Wrong number of cells.");
|
||||||
|
@ -44,7 +44,7 @@ void TestDataSet_Explicit()
|
|||||||
vtkm::cont::testing::MakeTestDataSet tds;
|
vtkm::cont::testing::MakeTestDataSet tds;
|
||||||
vtkm::cont::DataSet ds = tds.Make3DExplicitDataSet0();
|
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
|
// test various field-getting methods and associations
|
||||||
const vtkm::cont::Field& f1 = ds.GetField("pointvar");
|
const vtkm::cont::Field& f1 = ds.GetField("pointvar");
|
||||||
|
@ -42,7 +42,7 @@ static void TwoDimRectilinearTest()
|
|||||||
vtkm::cont::CellSetStructured<2> cellSet;
|
vtkm::cont::CellSetStructured<2> cellSet;
|
||||||
dataSet.GetCellSet().AsCellSet(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,
|
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||||
"Incorrect number of coordinate systems");
|
"Incorrect number of coordinate systems");
|
||||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points");
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points");
|
||||||
@ -128,7 +128,7 @@ static void ThreeDimRectilinearTest()
|
|||||||
vtkm::cont::CellSetStructured<3> cellSet;
|
vtkm::cont::CellSetStructured<3> cellSet;
|
||||||
dataSet.GetCellSet().AsCellSet(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,
|
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||||
"Incorrect number of coordinate systems");
|
"Incorrect number of coordinate systems");
|
||||||
|
@ -43,7 +43,7 @@ static void TwoDimUniformTest()
|
|||||||
vtkm::cont::CellSetStructured<2> cellSet;
|
vtkm::cont::CellSetStructured<2> cellSet;
|
||||||
dataSet.GetCellSet().AsCellSet(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,
|
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||||
"Incorrect number of coordinate systems");
|
"Incorrect number of coordinate systems");
|
||||||
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points");
|
VTKM_TEST_ASSERT(cellSet.GetNumberOfPoints() == 6, "Incorrect number of points");
|
||||||
@ -132,7 +132,7 @@ static void ThreeDimUniformTest()
|
|||||||
vtkm::cont::CellSetStructured<3> cellSet;
|
vtkm::cont::CellSetStructured<3> cellSet;
|
||||||
dataSet.GetCellSet().AsCellSet(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,
|
VTKM_TEST_ASSERT(dataSet.GetNumberOfCoordinateSystems() == 1,
|
||||||
"Incorrect number of coordinate systems");
|
"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++)
|
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;
|
vtkm::cont::ArrayHandle<vtkm::Float32> lDataArray;
|
||||||
leftDataSet.GetField(j).GetData().AsArrayHandle(lDataArray);
|
leftDataSet.GetField(j).GetData().AsArrayHandle(lDataArray);
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> rDataArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> rDataArray;
|
||||||
|
@ -109,11 +109,14 @@ vtkm::cont::PartitionedDataSet NewFilter::Execute(const vtkm::cont::PartitionedD
|
|||||||
vtkm::cont::DataSet NewFilter::CreateResult(const vtkm::cont::DataSet& inDataSet) const
|
vtkm::cont::DataSet NewFilter::CreateResult(const vtkm::cont::DataSet& inDataSet) const
|
||||||
{
|
{
|
||||||
vtkm::cont::DataSet clone;
|
vtkm::cont::DataSet clone;
|
||||||
clone.CopyStructure(inDataSet);
|
clone.CopyPartsFromExcept(
|
||||||
this->MapFieldsOntoOutput(
|
inDataSet, vtkm::cont::DataSet::Parts::Fields | vtkm::cont::DataSet::Parts::Coordinates);
|
||||||
inDataSet, clone, [](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
this->MapFieldsOntoOutput(inDataSet,
|
||||||
out.AddField(fieldToPass);
|
this->GetFieldsToPass(),
|
||||||
});
|
clone,
|
||||||
|
[](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
||||||
|
out.AddField(fieldToPass);
|
||||||
|
});
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ namespace filter
|
|||||||
/// };
|
/// };
|
||||||
/// // This passes coordinate systems directly from input to output. If the points of
|
/// // 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.
|
/// // 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
|
/// \endcode
|
||||||
///
|
///
|
||||||
@ -188,15 +188,15 @@ namespace filter
|
|||||||
/// // thus making it thread-safe.
|
/// // thus making it thread-safe.
|
||||||
/// SharedStates states;
|
/// SharedStates states;
|
||||||
///
|
///
|
||||||
/// vtkm::cont::DataSet output;
|
/// vtkm::cont::CellSetExplicit<> cellSet;
|
||||||
/// output = ... // Generation of the new DataSet and store interpolation parameters in `states`
|
/// cellSet = ... // Generation of the new DataSet and store interpolation parameters in `states`
|
||||||
///
|
///
|
||||||
/// // Lambda capture of `states`, effectively passing the shared states to the Mapper.
|
/// // Lambda capture of `states`, effectively passing the shared states to the Mapper.
|
||||||
/// auto mapper = [&states](auto& outputDs, const auto& inputField) {
|
/// auto mapper = [&states](auto& outputDs, const auto& inputField) {
|
||||||
/// auto outputField = ... // Use `states` for mapping input field to output field
|
/// auto outputField = ... // Use `states` for mapping input field to output field
|
||||||
/// output.AddField(outputField);
|
/// output.AddField(outputField);
|
||||||
/// };
|
/// };
|
||||||
/// this->MapFieldsOntoOutput(input, output, mapper);
|
/// this->CreateOutput(input, cellSet, mapper);
|
||||||
///
|
///
|
||||||
/// return output;
|
/// return output;
|
||||||
/// }
|
/// }
|
||||||
@ -292,6 +292,21 @@ public:
|
|||||||
vtkm::filter::FieldSelection& GetFieldsToPass() { return this->FieldsToPass; }
|
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.
|
/// 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
|
/// 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`.
|
/// created and will eventually be returned by `CreateResult`. The `Field` comes from `input`.
|
||||||
///
|
///
|
||||||
|
|
||||||
template <typename FieldMapper>
|
template <typename FieldMapper>
|
||||||
VTKM_CONT vtkm::cont::PartitionedDataSet CreateResult(
|
VTKM_CONT vtkm::cont::PartitionedDataSet CreateResult(
|
||||||
const vtkm::cont::PartitionedDataSet& input,
|
const vtkm::cont::PartitionedDataSet& input,
|
||||||
@ -365,7 +379,7 @@ protected:
|
|||||||
FieldMapper&& fieldMapper) const
|
FieldMapper&& fieldMapper) const
|
||||||
{
|
{
|
||||||
vtkm::cont::PartitionedDataSet output(resultPartitions.GetPartitions());
|
vtkm::cont::PartitionedDataSet output(resultPartitions.GetPartitions());
|
||||||
this->MapFieldsOntoOutput(input, output, fieldMapper);
|
this->MapFieldsOntoOutput(input, this->GetFieldsToPass(), output, fieldMapper);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -376,9 +390,6 @@ protected:
|
|||||||
/// being created and a `Field` from the input and then applies any necessary transformations to
|
/// being created and a `Field` from the input and then applies any necessary transformations to
|
||||||
/// the field array and adds it to the `DataSet`.
|
/// 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
|
/// \param[in] inDataSet The input data set being modified (usually the one passed
|
||||||
/// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet`
|
/// into `DoExecute`). The returned `DataSet` is filled with fields of `inDataSet`
|
||||||
/// (as selected by the `FieldsToPass` state of the filter).
|
/// (as selected by the `FieldsToPass` state of the filter).
|
||||||
@ -396,8 +407,12 @@ protected:
|
|||||||
FieldMapper&& fieldMapper) const
|
FieldMapper&& fieldMapper) const
|
||||||
{
|
{
|
||||||
vtkm::cont::DataSet outDataSet;
|
vtkm::cont::DataSet outDataSet;
|
||||||
|
outDataSet.CopyPartsFromExcept(inDataSet,
|
||||||
|
vtkm::cont::DataSet::Parts::Fields |
|
||||||
|
vtkm::cont::DataSet::Parts::Coordinates |
|
||||||
|
vtkm::cont::DataSet::Parts::CellSet);
|
||||||
outDataSet.SetCellSet(resultCellSet);
|
outDataSet.SetCellSet(resultCellSet);
|
||||||
this->MapFieldsOntoOutput(inDataSet, outDataSet, fieldMapper);
|
this->MapFieldsOntoOutput(inDataSet, this->GetFieldsToPass(), outDataSet, fieldMapper);
|
||||||
return outDataSet;
|
return outDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,6 +451,7 @@ protected:
|
|||||||
return outDataSet;
|
return outDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///@{
|
||||||
/// \brief Create the output data set for `DoExecute`.
|
/// \brief Create the output data set for `DoExecute`.
|
||||||
///
|
///
|
||||||
/// This form of `CreateResult` will create an output data set with the given `CellSet`
|
/// This form of `CreateResult` will create an output data set with the given `CellSet`
|
||||||
@ -457,31 +473,89 @@ protected:
|
|||||||
/// the function should do nothing.
|
/// the function should do nothing.
|
||||||
///
|
///
|
||||||
template <typename FieldMapper>
|
template <typename FieldMapper>
|
||||||
VTKM_CONT vtkm::cont::DataSet CreateResult(const vtkm::cont::DataSet& inDataSet,
|
VTKM_CONT vtkm::cont::DataSet CreateResultCoordinateSystem(
|
||||||
const vtkm::cont::UnknownCellSet& resultCellSet,
|
const vtkm::cont::DataSet& inDataSet,
|
||||||
const vtkm::cont::CoordinateSystem& resultCoordSystem,
|
const vtkm::cont::UnknownCellSet& resultCellSet,
|
||||||
FieldMapper&& fieldMapper) const
|
const vtkm::cont::CoordinateSystem& resultCoordSystem,
|
||||||
|
FieldMapper&& fieldMapper) const
|
||||||
{
|
{
|
||||||
return this->CreateResult(inDataSet,
|
vtkm::cont::DataSet outDataSet;
|
||||||
resultCellSet,
|
outDataSet.CopyPartsFromExcept(inDataSet,
|
||||||
std::vector<vtkm::cont::CoordinateSystem>{ resultCoordSystem },
|
vtkm::cont::DataSet::Parts::Fields |
|
||||||
fieldMapper);
|
vtkm::cont::DataSet::Parts::Coordinates |
|
||||||
|
vtkm::cont::DataSet::Parts::CellSet);
|
||||||
|
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,
|
||||||
|
vtkm::cont::CoordinateSystem{ coordsName, coordsData },
|
||||||
|
fieldMapper);
|
||||||
|
}
|
||||||
|
///@}
|
||||||
|
|
||||||
VTKM_CONT virtual vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) = 0;
|
VTKM_CONT virtual vtkm::cont::DataSet DoExecute(const vtkm::cont::DataSet& inData) = 0;
|
||||||
VTKM_CONT virtual vtkm::cont::PartitionedDataSet DoExecutePartitions(
|
VTKM_CONT virtual vtkm::cont::PartitionedDataSet DoExecutePartitions(
|
||||||
const vtkm::cont::PartitionedDataSet& inData);
|
const vtkm::cont::PartitionedDataSet& inData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename DataSetType, typename FieldMapper>
|
template <typename FieldMapper>
|
||||||
VTKM_CONT void MapFieldsOntoOutput(const DataSetType& input,
|
VTKM_CONT void MapFieldsOntoOutput(const vtkm::cont::DataSet& input,
|
||||||
DataSetType& output,
|
const vtkm::filter::FieldSelection& fieldSelection,
|
||||||
|
vtkm::cont::DataSet& output,
|
||||||
FieldMapper&& fieldMapper) const
|
FieldMapper&& fieldMapper) const
|
||||||
{
|
{
|
||||||
for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc)
|
for (vtkm::IdComponent cc = 0; cc < input.GetNumberOfFields(); ++cc)
|
||||||
{
|
{
|
||||||
auto field = input.GetField(cc);
|
auto field = input.GetField(cc);
|
||||||
if (this->GetFieldsToPass().IsFieldSelected(field))
|
if (fieldSelection.IsFieldSelected(field))
|
||||||
|
{
|
||||||
|
fieldMapper(output, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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() || this->GetFieldsToPass().IsFieldSelected(coords)))
|
||||||
|
{
|
||||||
|
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 (fieldSelection.IsFieldSelected(field))
|
||||||
{
|
{
|
||||||
fieldMapper(output, field);
|
fieldMapper(output, field);
|
||||||
}
|
}
|
||||||
@ -493,6 +567,7 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All;
|
vtkm::filter::FieldSelection FieldsToPass = vtkm::filter::FieldSelection::Mode::All;
|
||||||
|
bool PassCoordinateSystems = true;
|
||||||
bool RunFilterWithMultipleThreads = false;
|
bool RunFilterWithMultipleThreads = false;
|
||||||
vtkm::Id NumThreadsPerCPU = 4;
|
vtkm::Id NumThreadsPerCPU = 4;
|
||||||
vtkm::Id NumThreadsPerGPU = 8;
|
vtkm::Id NumThreadsPerGPU = 8;
|
||||||
|
@ -133,7 +133,12 @@ protected:
|
|||||||
{
|
{
|
||||||
if (this->UseCoordinateSystemAsField[index])
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ void TestPointMerging()
|
|||||||
//filter for uniform data always does point merging
|
//filter for uniform data always does point merging
|
||||||
vtkm::cont::ArrayHandle<vtkm::Vec3f> newcoords;
|
vtkm::cont::ArrayHandle<vtkm::Vec3f> newcoords;
|
||||||
vtkm::cont::ArrayCopy(baseData.GetCoordinateSystem().GetData(), newcoords);
|
vtkm::cont::ArrayCopy(baseData.GetCoordinateSystem().GetData(), newcoords);
|
||||||
baseData.GetCoordinateSystem().SetData(newcoords);
|
baseData.AddPointField(baseData.GetCoordinateSystemName(), newcoords);
|
||||||
|
|
||||||
vtkm::filter::contour::Contour marchingCubes;
|
vtkm::filter::contour::Contour marchingCubes;
|
||||||
marchingCubes.SetIsoValue(0.05);
|
marchingCubes.SetIsoValue(0.05);
|
||||||
|
@ -144,8 +144,8 @@ vtkm::cont::DataSet Contour::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
|||||||
resolveFieldType);
|
resolveFieldType);
|
||||||
|
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||||
vtkm::cont::DataSet output = this->CreateResult(
|
vtkm::cont::DataSet output = this->CreateResultCoordinateSystem(
|
||||||
inDataSet, outputCells, vtkm::cont::CoordinateSystem{ "coordinates", vertices }, mapper);
|
inDataSet, outputCells, inputCoords.GetName(), vertices, mapper);
|
||||||
|
|
||||||
if (this->GenerateNormals)
|
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) {
|
auto mapper = [&](auto& outDataSet, const auto& f) {
|
||||||
this->DoMapField(outDataSet, f, filterCellInterp, MIRWeights, MIRIDs);
|
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()));
|
output.AddField(saved.GetField(this->GetOutputFieldName()));
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
@ -63,7 +63,7 @@ void TestClipExplicit()
|
|||||||
|
|
||||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
|
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
|
||||||
"Wrong number of coordinate systems in the output dataset");
|
"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");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
auto temp = outputData.GetField("scalars").GetData();
|
auto temp = outputData.GetField("scalars").GetData();
|
||||||
|
@ -62,7 +62,7 @@ void TestClipStructured(vtkm::Float64 offset)
|
|||||||
|
|
||||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
|
VTKM_TEST_ASSERT(outputData.GetNumberOfCoordinateSystems() == 1,
|
||||||
"Wrong number of coordinate systems in the output dataset");
|
"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");
|
"Wrong number of fields in the output dataset");
|
||||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 8,
|
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 8,
|
||||||
"Wrong number of cells in the output dataset");
|
"Wrong number of cells in the output dataset");
|
||||||
@ -98,7 +98,7 @@ void TestClipStructuredInverted()
|
|||||||
clip.SetFieldsToPass("scalars");
|
clip.SetFieldsToPass("scalars");
|
||||||
auto outputData = clip.Execute(ds);
|
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");
|
"Wrong number of fields in the output dataset");
|
||||||
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 4,
|
VTKM_TEST_ASSERT(outputData.GetNumberOfCells() == 4,
|
||||||
"Wrong number of cells in the output dataset");
|
"Wrong number of cells in the output dataset");
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
VTKM_TEST_ASSERT(result.GetNumberOfCoordinateSystems() == 1,
|
VTKM_TEST_ASSERT(result.GetNumberOfCoordinateSystems() == 1,
|
||||||
"Wrong number of coordinate systems in the output dataset");
|
"Wrong number of coordinate systems in the output dataset");
|
||||||
//since normals is on we have one field
|
//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");
|
"Wrong number of fields in the output dataset");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
const bool isMapped = result.HasField("tangle");
|
const bool isMapped = result.HasField("tangle");
|
||||||
VTKM_TEST_ASSERT(isMapped, "mapping should pass");
|
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");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
//verify the cellvar result
|
//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
|
// New Design: We are still using the old MapFieldOntoOutput to demonstrate the transition
|
||||||
this->MapFieldOntoOutput(result, f);
|
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
|
// create the output dataset
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
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
|
} // namespace entity_extraction
|
||||||
|
@ -59,8 +59,7 @@ vtkm::cont::DataSet ExtractPoints::DoExecute(const vtkm::cont::DataSet& input)
|
|||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
||||||
vtkm::cont::DataSet output =
|
vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper);
|
||||||
this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
|
||||||
|
|
||||||
// compact the unused points in the output dataset
|
// compact the unused points in the output dataset
|
||||||
if (this->CompactPoints)
|
if (this->CompactPoints)
|
||||||
|
@ -15,27 +15,45 @@
|
|||||||
|
|
||||||
namespace
|
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::Field& field,
|
||||||
const vtkm::cont::ArrayHandle<vtkm::Id>& CellFieldMap,
|
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())
|
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())
|
else if (field.IsCellField())
|
||||||
{
|
{
|
||||||
return vtkm::filter::MapFieldPermutation(field, CellFieldMap, result);
|
vtkm::filter::MapFieldPermutation(field, CellFieldMap, result);
|
||||||
}
|
}
|
||||||
else if (field.IsWholeDataSetField())
|
else if (field.IsWholeDataSetField())
|
||||||
{
|
{
|
||||||
result.AddField(field);
|
result.AddField(field);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@ -50,7 +68,6 @@ namespace entity_extraction
|
|||||||
vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& input)
|
vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& input)
|
||||||
{
|
{
|
||||||
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
const vtkm::cont::UnknownCellSet& cells = input.GetCellSet();
|
||||||
const vtkm::cont::CoordinateSystem& coordinates = input.GetCoordinateSystem();
|
|
||||||
|
|
||||||
vtkm::worklet::ExtractStructured worklet;
|
vtkm::worklet::ExtractStructured worklet;
|
||||||
auto cellset = worklet.Run(cells.ResetCellSetList<VTKM_DEFAULT_CELL_SET_LIST_STRUCTURED>(),
|
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->IncludeBoundary,
|
||||||
this->IncludeOffset);
|
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
|
// Create map arrays for mapping fields. Could potentially save some time to first check to see
|
||||||
// if these arrays would be used.
|
// if these arrays would be used.
|
||||||
auto CellFieldMap =
|
auto CellFieldMap =
|
||||||
@ -70,9 +84,9 @@ vtkm::cont::DataSet ExtractStructured::DoExecute(const vtkm::cont::DataSet& inpu
|
|||||||
worklet.ProcessPointField(vtkm::cont::ArrayHandleIndex(input.GetNumberOfPoints()));
|
worklet.ProcessPointField(vtkm::cont::ArrayHandleIndex(input.GetNumberOfPoints()));
|
||||||
|
|
||||||
auto mapper = [&](auto& result, const auto& f) {
|
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
|
} // 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); };
|
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
|
// create the output dataset
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
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 entity_extraction
|
||||||
} // namespace filter
|
} // namespace filter
|
||||||
|
@ -56,8 +56,7 @@ VTKM_CONT vtkm::cont::DataSet MaskPoints::DoExecute(const vtkm::cont::DataSet& i
|
|||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
||||||
vtkm::cont::DataSet output =
|
vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper);
|
||||||
this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
|
||||||
|
|
||||||
// compact the unused points in the output dataset
|
// compact the unused points in the output dataset
|
||||||
if (this->CompactPoints)
|
if (this->CompactPoints)
|
||||||
|
@ -148,7 +148,7 @@ vtkm::cont::DataSet Threshold::DoExecute(const vtkm::cont::DataSet& input)
|
|||||||
vtkm::ListForEach(callWithArrayBaseComponent, vtkm::TypeListScalarAll{});
|
vtkm::ListForEach(callWithArrayBaseComponent, vtkm::TypeListScalarAll{});
|
||||||
|
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
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 entity_extraction
|
||||||
} // namespace filter
|
} // namespace filter
|
||||||
|
@ -174,8 +174,7 @@ VTKM_CONT vtkm::cont::DataSet ThresholdPoints::DoExecute(const vtkm::cont::DataS
|
|||||||
|
|
||||||
// create the output dataset
|
// create the output dataset
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f); };
|
||||||
vtkm::cont::DataSet output =
|
vtkm::cont::DataSet output = this->CreateResult(input, outCellSet, mapper);
|
||||||
this->CreateResult(input, outCellSet, input.GetCoordinateSystems(), mapper);
|
|
||||||
|
|
||||||
// compact the unused points in the output dataset
|
// compact the unused points in the output dataset
|
||||||
if (this->CompactPoints)
|
if (this->CompactPoints)
|
||||||
|
@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
if (returnAllInRange)
|
if (returnAllInRange)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||||
"Wrong number of fields in the output dataset");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||||
"Wrong number of fields in the output dataset");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
|
|
||||||
if (returnAllInRange)
|
if (returnAllInRange)
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||||
"Wrong number of fields in the output dataset");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 1,
|
VTKM_TEST_ASSERT(output.GetNumberOfFields() == 2,
|
||||||
"Wrong number of fields in the output dataset");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||||
@ -150,7 +150,7 @@ public:
|
|||||||
threshold.SetFieldsToPass("cellvar");
|
threshold.SetFieldsToPass("cellvar");
|
||||||
auto output = threshold.Execute(dataset);
|
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");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||||
@ -180,7 +180,7 @@ public:
|
|||||||
threshold.SetFieldsToPass("cellvar");
|
threshold.SetFieldsToPass("cellvar");
|
||||||
auto output = threshold.Execute(dataset);
|
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");
|
"Wrong number of fields in the output dataset");
|
||||||
|
|
||||||
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
vtkm::cont::ArrayHandle<vtkm::Float32> cellFieldArray;
|
||||||
|
@ -97,7 +97,7 @@ public:
|
|||||||
thresholdPoints.SetActiveField("pointvar");
|
thresholdPoints.SetActiveField("pointvar");
|
||||||
thresholdPoints.SetFieldsToPass("pointvar");
|
thresholdPoints.SetFieldsToPass("pointvar");
|
||||||
auto output = thresholdPoints.Execute(dataset);
|
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");
|
"Wrong number of fields in the output dataset");
|
||||||
VTKM_TEST_ASSERT(test_equal(output.GetNumberOfCells(), 0), "Wrong result for ThresholdPoints");
|
VTKM_TEST_ASSERT(test_equal(output.GetNumberOfCells(), 0), "Wrong result for ThresholdPoints");
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,6 @@ public:
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
using UniformCoordinatesArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
using UniformCoordinatesArrayHandle = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||||
|
|
||||||
using RectilinearCoordinatesArrayHandle =
|
using RectilinearCoordinatesArrayHandle =
|
||||||
@ -424,7 +423,8 @@ private:
|
|||||||
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>;
|
vtkm::cont::ArrayHandle<vtkm::FloatDefault>>;
|
||||||
|
|
||||||
|
|
||||||
UniformCoordinatesArrayHandle MapCoordinatesUniform(const UniformCoordinatesArrayHandle& coords)
|
UniformCoordinatesArrayHandle MapCoordinatesUniform(
|
||||||
|
const UniformCoordinatesArrayHandle& coords) const
|
||||||
{
|
{
|
||||||
using CoordsArray = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
using CoordsArray = vtkm::cont::ArrayHandleUniformPointCoordinates;
|
||||||
using CoordType = CoordsArray::ValueType;
|
using CoordType = CoordsArray::ValueType;
|
||||||
@ -444,7 +444,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
RectilinearCoordinatesArrayHandle MapCoordinatesRectilinear(
|
RectilinearCoordinatesArrayHandle MapCoordinatesRectilinear(
|
||||||
const RectilinearCoordinatesArrayHandle& coords)
|
const RectilinearCoordinatesArrayHandle& coords) const
|
||||||
{
|
{
|
||||||
// For structured datasets, the cellsets are of different types based on
|
// For structured datasets, the cellsets are of different types based on
|
||||||
// its dimensionality, but the coordinates are always 3 dimensional.
|
// 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]);
|
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:
|
public:
|
||||||
template <typename T, typename Storage>
|
template <typename T, typename Storage>
|
||||||
vtkm::cont::ArrayHandle<T> ProcessPointField(
|
vtkm::cont::ArrayHandle<T> ProcessPointField(
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
// PURPOSE. See the above copyright notice for more information.
|
// 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/CylindricalCoordinateTransform.h>
|
||||||
#include <vtkm/filter/field_transform/worklet/CoordinateSystemTransform.h>
|
#include <vtkm/filter/field_transform/worklet/CoordinateSystemTransform.h>
|
||||||
|
|
||||||
@ -18,10 +19,21 @@ namespace filter
|
|||||||
namespace field_transform
|
namespace field_transform
|
||||||
{
|
{
|
||||||
|
|
||||||
|
CylindricalCoordinateTransform::CylindricalCoordinateTransform()
|
||||||
|
{
|
||||||
|
this->SetUseCoordinateSystemAsField(true);
|
||||||
|
}
|
||||||
|
|
||||||
vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
||||||
{
|
{
|
||||||
vtkm::cont::UnknownArrayHandle outArray;
|
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) {
|
auto resolveType = [&](const auto& concrete) {
|
||||||
// use std::decay to remove const ref from the decltype of concrete.
|
// use std::decay to remove const ref from the decltype of concrete.
|
||||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||||
@ -32,15 +44,21 @@ vtkm::cont::DataSet CylindricalCoordinateTransform::DoExecute(const vtkm::cont::
|
|||||||
this->Invoke(vtkm::worklet::CylToCar{}, concrete, result);
|
this->Invoke(vtkm::worklet::CylToCar{}, concrete, result);
|
||||||
outArray = result;
|
outArray = result;
|
||||||
};
|
};
|
||||||
this->CastAndCallVecField<3>(this->GetFieldFromDataSet(inDataSet), resolveType);
|
this->CastAndCallVecField<3>(inField, resolveType);
|
||||||
|
|
||||||
vtkm::cont::DataSet outDataSet =
|
std::string coordinateName = this->GetOutputFieldName();
|
||||||
this->CreateResult(inDataSet,
|
if (coordinateName.empty())
|
||||||
inDataSet.GetCellSet(),
|
{
|
||||||
vtkm::cont::CoordinateSystem("coordinates", outArray),
|
coordinateName = inField.GetName();
|
||||||
[](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
}
|
||||||
out.AddField(fieldToPass);
|
|
||||||
});
|
vtkm::cont::DataSet outDataSet = this->CreateResultCoordinateSystem(
|
||||||
|
inDataSet,
|
||||||
|
inDataSet.GetCellSet(),
|
||||||
|
vtkm::cont::CoordinateSystem(coordinateName, outArray),
|
||||||
|
[](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
||||||
|
out.AddField(fieldToPass);
|
||||||
|
});
|
||||||
return outDataSet;
|
return outDataSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ class VTKM_FILTER_FIELD_TRANSFORM_EXPORT CylindricalCoordinateTransform
|
|||||||
: public vtkm::filter::NewFilterField
|
: public vtkm::filter::NewFilterField
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
VTKM_CONT CylindricalCoordinateTransform();
|
||||||
|
|
||||||
VTKM_CONT void SetCartesianToCylindrical() { CartesianToCylindrical = true; }
|
VTKM_CONT void SetCartesianToCylindrical() { CartesianToCylindrical = true; }
|
||||||
VTKM_CONT void SetCylindricalToCartesian() { CartesianToCylindrical = false; }
|
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);
|
const auto& field = this->GetFieldFromDataSet(inDataSet);
|
||||||
this->CastAndCallVecField<3>(field, resolveType);
|
this->CastAndCallVecField<3>(field, resolveType);
|
||||||
|
|
||||||
vtkm::cont::DataSet outData = this->CreateResultField(
|
auto passMapper = [](auto& d, const auto& f) { d.AddField(f); };
|
||||||
inDataSet, this->GetOutputFieldName(), field.GetAssociation(), outArray);
|
vtkm::cont::DataSet outData = this->CreateResultCoordinateSystem(
|
||||||
|
inDataSet, inDataSet.GetCellSet(), this->GetOutputFieldName(), outArray, passMapper);
|
||||||
|
|
||||||
if (this->GetChangeCoordinateSystem())
|
if (this->GetChangeCoordinateSystem())
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
// PURPOSE. See the above copyright notice for more information.
|
// 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/SphericalCoordinateTransform.h>
|
||||||
#include <vtkm/filter/field_transform/worklet/CoordinateSystemTransform.h>
|
#include <vtkm/filter/field_transform/worklet/CoordinateSystemTransform.h>
|
||||||
|
|
||||||
@ -17,10 +18,22 @@ namespace filter
|
|||||||
{
|
{
|
||||||
namespace field_transform
|
namespace field_transform
|
||||||
{
|
{
|
||||||
|
|
||||||
|
SphericalCoordinateTransform::SphericalCoordinateTransform()
|
||||||
|
{
|
||||||
|
this->SetUseCoordinateSystemAsField(true);
|
||||||
|
}
|
||||||
|
|
||||||
vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(const vtkm::cont::DataSet& inDataSet)
|
||||||
{
|
{
|
||||||
vtkm::cont::UnknownArrayHandle outArray;
|
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) {
|
auto resolveType = [&](const auto& concrete) {
|
||||||
// use std::decay to remove const ref from the decltype of concrete.
|
// use std::decay to remove const ref from the decltype of concrete.
|
||||||
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
using T = typename std::decay_t<decltype(concrete)>::ValueType;
|
||||||
@ -31,15 +44,21 @@ vtkm::cont::DataSet SphericalCoordinateTransform::DoExecute(const vtkm::cont::Da
|
|||||||
this->Invoke(vtkm::worklet::SphereToCar{}, concrete, result);
|
this->Invoke(vtkm::worklet::SphereToCar{}, concrete, result);
|
||||||
outArray = result;
|
outArray = result;
|
||||||
};
|
};
|
||||||
this->CastAndCallVecField<3>(this->GetFieldFromDataSet(inDataSet), resolveType);
|
this->CastAndCallVecField<3>(inField, resolveType);
|
||||||
|
|
||||||
vtkm::cont::DataSet outDataSet =
|
std::string coordinateName = this->GetOutputFieldName();
|
||||||
this->CreateResult(inDataSet,
|
if (coordinateName.empty())
|
||||||
inDataSet.GetCellSet(),
|
{
|
||||||
vtkm::cont::CoordinateSystem("coordinates", outArray),
|
coordinateName = inField.GetName();
|
||||||
[](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
}
|
||||||
out.AddField(fieldToPass);
|
|
||||||
});
|
vtkm::cont::DataSet outDataSet = this->CreateResultCoordinateSystem(
|
||||||
|
inDataSet,
|
||||||
|
inDataSet.GetCellSet(),
|
||||||
|
vtkm::cont::CoordinateSystem(coordinateName, outArray),
|
||||||
|
[](vtkm::cont::DataSet& out, const vtkm::cont::Field& fieldToPass) {
|
||||||
|
out.AddField(fieldToPass);
|
||||||
|
});
|
||||||
return outDataSet;
|
return outDataSet;
|
||||||
}
|
}
|
||||||
} // namespace field_transform
|
} // namespace field_transform
|
||||||
|
@ -25,6 +25,8 @@ class VTKM_FILTER_FIELD_TRANSFORM_EXPORT SphericalCoordinateTransform
|
|||||||
: public vtkm::filter::NewFilterField
|
: public vtkm::filter::NewFilterField
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
VTKM_CONT SphericalCoordinateTransform();
|
||||||
|
|
||||||
VTKM_CONT void SetCartesianToSpherical() { CartesianToSpherical = true; }
|
VTKM_CONT void SetCartesianToSpherical() { CartesianToSpherical = true; }
|
||||||
VTKM_CONT void SetSphericalToCartesian() { CartesianToSpherical = false; }
|
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) {
|
auto fieldmapper = [&](vtkm::cont::DataSet& dataset, const vtkm::cont::Field& fieldToPass) {
|
||||||
MapField(dataset, 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("valid", this->BasisParticlesValidity);
|
||||||
outputData.AddPointField("displacement", basisParticlesDisplacement);
|
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) {
|
auto fieldmapper = [&](vtkm::cont::DataSet& dataset, const vtkm::cont::Field& field) {
|
||||||
MapField(dataset, field);
|
MapField(dataset, field);
|
||||||
};
|
};
|
||||||
vtkm::cont::DataSet output =
|
vtkm::cont::DataSet output = this->CreateResultCoordinateSystem(
|
||||||
this->CreateResult(input, lcsInput.GetCellSet(), lcsInput.GetCoordinateSystem(), fieldmapper);
|
input, lcsInput.GetCellSet(), lcsInput.GetCoordinateSystem(), fieldmapper);
|
||||||
output.AddPointField(this->GetOutputFieldName(), outputField);
|
output.AddPointField(this->GetOutputFieldName(), outputField);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ void TestLagrangianFilterMultiStepInterval()
|
|||||||
"Wrong number of coordinate systems in the output dataset.");
|
"Wrong number of coordinate systems in the output dataset.");
|
||||||
VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfPoints() == 512,
|
VTKM_TEST_ASSERT(extractedBasisFlows.GetNumberOfPoints() == 512,
|
||||||
"Wrong number of basis flows extracted.");
|
"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
|
else
|
||||||
{
|
{
|
||||||
|
@ -62,8 +62,8 @@ VTKM_CONT vtkm::cont::DataSet VertexClustering::DoExecute(const vtkm::cont::Data
|
|||||||
outCoords);
|
outCoords);
|
||||||
|
|
||||||
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
auto mapper = [&](auto& result, const auto& f) { DoMapField(result, f, worklet); };
|
||||||
return this->CreateResult(
|
return this->CreateResultCoordinateSystem(
|
||||||
input, outCellSet, vtkm::cont::CoordinateSystem("coordinates", outCoords), mapper);
|
input, outCellSet, input.GetCoordinateSystem().GetName(), outCoords, mapper);
|
||||||
}
|
}
|
||||||
} // namespace geometry_refinement
|
} // namespace geometry_refinement
|
||||||
} // namespace filter
|
} // namespace filter
|
||||||
|
@ -76,8 +76,8 @@ vtkm::cont::DataSet Probe::DoExecute(const vtkm::cont::DataSet& input)
|
|||||||
auto mapper = [&](auto& outDataSet, const auto& f) {
|
auto mapper = [&](auto& outDataSet, const auto& f) {
|
||||||
DoMapField(outDataSet, f, worklet, this->InvalidValue);
|
DoMapField(outDataSet, f, worklet, this->InvalidValue);
|
||||||
};
|
};
|
||||||
auto output = this->CreateResult(
|
auto output = this->CreateResultCoordinateSystem(
|
||||||
input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystems(), mapper);
|
input, this->Geometry.GetCellSet(), this->Geometry.GetCoordinateSystem(), mapper);
|
||||||
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField()));
|
output.AddField(vtkm::cont::make_FieldPoint("HIDDEN", worklet.GetHiddenPointsField()));
|
||||||
output.AddField(
|
output.AddField(
|
||||||
vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet())));
|
vtkm::cont::make_FieldCell("HIDDEN", worklet.GetHiddenCellsField(output.GetCellSet())));
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
void SetGeometry(const vtkm::cont::DataSet& geometry)
|
void SetGeometry(const vtkm::cont::DataSet& geometry)
|
||||||
{
|
{
|
||||||
this->Geometry = vtkm::cont::DataSet();
|
this->Geometry = vtkm::cont::DataSet();
|
||||||
this->Geometry.CopyStructure(geometry);
|
this->Geometry.CopyPartsFromExcept(geometry, vtkm::cont::DataSet::Parts::Fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
|
@ -320,6 +320,12 @@ void WritePointFields(std::ostream& out,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field.GetName() == dataSet.GetCoordinateSystemName())
|
||||||
|
{
|
||||||
|
// Do not write out the first coordinate system as a field.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
vtkm::Id npoints = field.GetNumberOfValues();
|
vtkm::Id npoints = field.GetNumberOfValues();
|
||||||
int ncomps = field.GetData().GetNumberOfComponentsFlat();
|
int ncomps = field.GetData().GetNumberOfComponentsFlat();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ void TestReadingBOVDataSet()
|
|||||||
|
|
||||||
auto const& ds = readBOVDataSet(bovFile.data());
|
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
|
// 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.GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50,
|
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");
|
VTKM_TEST_ASSERT(ds.GetNumberOfCells() == 49 * 49 * 49, "Incorrect number of cells");
|
||||||
// See the .bov file: VARIABLE: "var"
|
// See the .bov file: VARIABLE: "var"
|
||||||
VTKM_TEST_ASSERT(ds.HasField("var"), "Should have field 'var', but does not.");
|
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,
|
VTKM_TEST_ASSERT(ds.GetNumberOfCoordinateSystems() == 1,
|
||||||
"There is only one coordinate system in noise.bov");
|
"There is only one coordinate system in noise.bov");
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ void TestReadingPolyData(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 8, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 8,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 8,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -70,7 +70,7 @@ void TestReadingPolyDataEmpty()
|
|||||||
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 8);
|
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 8);
|
||||||
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
||||||
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 8);
|
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 8);
|
||||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 1);
|
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestReadingStructuredPoints(Format format)
|
void TestReadingStructuredPoints(Format format)
|
||||||
@ -81,7 +81,7 @@ void TestReadingStructuredPoints(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 72, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -99,7 +99,7 @@ void TestReadingStructuredPointsVisIt(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 64, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 64,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 64,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -116,7 +116,7 @@ void TestReadingUnstructuredGrid(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 26, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -133,7 +133,7 @@ void TestReadingV5Format(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 26, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -173,7 +173,7 @@ void TestReadingUnstructuredGridEmpty()
|
|||||||
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 26);
|
VTKM_TEST_ASSERT(data.GetNumberOfPoints() == 26);
|
||||||
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
VTKM_TEST_ASSERT(data.GetNumberOfCells() == 0);
|
||||||
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 26);
|
VTKM_TEST_ASSERT(data.GetCellSet().GetNumberOfPoints() == 26);
|
||||||
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 2);
|
VTKM_TEST_ASSERT(data.GetNumberOfFields() == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestReadingUnstructuredPixels()
|
void TestReadingUnstructuredPixels()
|
||||||
@ -291,7 +291,7 @@ void TestReadingUnstructuredGridVisIt(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 26, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 26,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -309,7 +309,7 @@ void TestReadingRectilinearGrid1(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 125, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 125,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 125,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -327,7 +327,7 @@ void TestReadingRectilinearGrid2(Format format)
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 24, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 24,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 24,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -343,7 +343,7 @@ void TestReadingStructuredGridASCII()
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 6, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 6,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 6,
|
||||||
"Incorrect number of points (from cell set)");
|
"Incorrect number of points (from cell set)");
|
||||||
@ -359,7 +359,7 @@ void TestReadingStructuredGridBin()
|
|||||||
|
|
||||||
vtkm::cont::DataSet ds = readVTKDataSet(testFileName);
|
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.GetNumberOfPoints() == 18, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 18,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 18,
|
||||||
"Incorrect number of points (from cell set)");
|
"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.GetNumberOfPoints() == 50 * 50 * 50, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 50 * 50 * 50,
|
||||||
"Incorrect number of points (from cell set)");
|
"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"), "The vtk file has a field 'vec', but the dataset does not.");
|
||||||
VTKM_TEST_ASSERT(ds.HasField("vec_magnitude"),
|
VTKM_TEST_ASSERT(ds.HasField("vec_magnitude"),
|
||||||
"The vtk file has a field 'vec_magnitude', but the dataset does not.");
|
"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::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.GetNumberOfPoints() == 72, "Incorrect number of points");
|
||||||
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72,
|
VTKM_TEST_ASSERT(ds.GetCellSet().GetNumberOfPoints() == 72,
|
||||||
"Incorrect number of points (from cell set)");
|
"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)
|
for (vtkm::IdComponent fieldId = 0; fieldId < originalData.GetNumberOfFields(); ++fieldId)
|
||||||
{
|
{
|
||||||
vtkm::cont::Field originalField = originalData.GetField(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_TEST_ASSERT(fileData.HasField(originalField.GetName(), originalField.GetAssociation()));
|
||||||
vtkm::cont::Field fileField =
|
vtkm::cont::Field fileField =
|
||||||
fileData.GetField(originalField.GetName(), originalField.GetAssociation());
|
fileData.GetField(originalField.GetName(), originalField.GetAssociation());
|
||||||
|
@ -39,20 +39,16 @@ protected:
|
|||||||
bool CompositeBackground;
|
bool CompositeBackground;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InternalsType(vtkm::cont::DataSet& dataSet)
|
InternalsType(const vtkm::cont::DataSet& dataSet, const std::string& fieldName)
|
||||||
{
|
{
|
||||||
Dataset = dataSet;
|
Dataset = dataSet;
|
||||||
Cells = dataSet.GetCellSet();
|
Cells = dataSet.GetCellSet();
|
||||||
Coords = dataSet.GetCoordinateSystem();
|
Coords = dataSet.GetCoordinateSystem();
|
||||||
Mode = RenderMode::Volume;
|
Mode = RenderMode::Volume;
|
||||||
CompositeBackground = true;
|
CompositeBackground = true;
|
||||||
//
|
if (!fieldName.empty())
|
||||||
// Just grab a default scalar field
|
|
||||||
//
|
|
||||||
|
|
||||||
if (Dataset.GetNumberOfFields() > 0)
|
|
||||||
{
|
{
|
||||||
this->SetScalarField(Dataset.GetField(0).GetName());
|
this->SetScalarField(fieldName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,8 +239,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
ConnectivityProxy::ConnectivityProxy(vtkm::cont::DataSet& dataSet)
|
ConnectivityProxy::ConnectivityProxy(const vtkm::cont::DataSet& dataSet,
|
||||||
: Internals(new InternalsType(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.AddCoordinateSystem(coords);
|
||||||
dataset.AddField(scalarField);
|
dataset.AddField(scalarField);
|
||||||
|
|
||||||
Internals = std::shared_ptr<InternalsType>(new InternalsType(dataset));
|
Internals = std::shared_ptr<InternalsType>(new InternalsType(dataset, scalarField.GetName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
VTKM_CONT
|
VTKM_CONT
|
||||||
|
@ -31,7 +31,7 @@ using PartialVector32 = std::vector<vtkm::rendering::raytracing::PartialComposit
|
|||||||
class VTKM_RENDERING_EXPORT ConnectivityProxy
|
class VTKM_RENDERING_EXPORT ConnectivityProxy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConnectivityProxy(vtkm::cont::DataSet& dataset);
|
ConnectivityProxy(const vtkm::cont::DataSet& dataset, const std::string& fieldName);
|
||||||
ConnectivityProxy(const vtkm::cont::UnknownCellSet& cellset,
|
ConnectivityProxy(const vtkm::cont::UnknownCellSet& cellset,
|
||||||
const vtkm::cont::CoordinateSystem& coords,
|
const vtkm::cont::CoordinateSystem& coords,
|
||||||
const vtkm::cont::Field& scalarField);
|
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::DataSet processedDataSet = this->FilterPoints(cellset, coords, scalarField);
|
||||||
vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet();
|
vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet();
|
||||||
vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem();
|
vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem();
|
||||||
vtkm::cont::Field processedField = processedDataSet.GetField(0);
|
vtkm::cont::Field processedField = processedDataSet.GetField(scalarField.GetName());
|
||||||
|
|
||||||
if (this->ScaleByValue)
|
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::DataSet processedDataSet = this->FilterPoints(cellset, coords, field);
|
||||||
vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet();
|
vtkm::cont::UnknownCellSet processedCellSet = processedDataSet.GetCellSet();
|
||||||
vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem();
|
vtkm::cont::CoordinateSystem processedCoords = processedDataSet.GetCoordinateSystem();
|
||||||
vtkm::cont::Field processedField = processedDataSet.GetField(0);
|
vtkm::cont::Field processedField = processedDataSet.GetField(field.GetName());
|
||||||
|
|
||||||
if (this->ScaleByValue)
|
if (this->ScaleByValue)
|
||||||
{
|
{
|
||||||
|
@ -303,7 +303,7 @@ void MapperWireframer::RenderCells(const vtkm::cont::UnknownCellSet& inCellSet,
|
|||||||
externalFaces.SetPassPolyData(true);
|
externalFaces.SetPassPolyData(true);
|
||||||
vtkm::cont::DataSet output = externalFaces.Execute(dataSet);
|
vtkm::cont::DataSet output = externalFaces.Execute(dataSet);
|
||||||
cellSet = output.GetCellSet();
|
cellSet = output.GetCellSet();
|
||||||
actualField = output.GetField(0);
|
actualField = output.GetField(inScalarField.GetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract unique edges from the cell set.
|
// Extract unique edges from the cell set.
|
||||||
|
Loading…
Reference in New Issue
Block a user