enable copying for Actor and ConnectivityProxy

This commit is contained in:
Li-Ta Lo 2023-06-02 10:32:44 -06:00
parent 09c78eec43
commit 04b6d96aab
6 changed files with 63 additions and 8 deletions

@ -55,7 +55,7 @@ int main(int argc, char* argv[])
tangleData.GetField(fieldName),
colorTable);
vtkm::rendering::Scene scene;
scene.AddActor(std::move(actor));
scene.AddActor(actor);
// 2048x2048 pixels in the canvas:
CanvasRayTracer canvas(2048, 2048);
// Create a view and use it to render the input data using OS Mesa

@ -104,7 +104,7 @@ int main(int argc, char** argv)
dataSet.GetCoordinateSystem(),
dataSet.GetCellField("spins"),
vtkm::cont::ColorTable("Cool To Warm"));
scene.AddActor(std::move(actor));
scene.AddActor(actor);
vtkm::rendering::CanvasRayTracer canvas(1024, 1024);
vtkm::rendering::MapperRayTracer mapper;
mapper.SetShadingOn(false);

@ -81,9 +81,36 @@ Actor::Actor(const vtkm::cont::UnknownCellSet& cells,
this->Init(coordinates, scalarField);
}
Actor::~Actor() = default;
Actor::Actor(const Actor& rhs)
: Internals(nullptr)
{
// rhs might have been moved, its Internal would be nullptr
if (rhs.Internals)
Internals = std::make_unique<InternalsType>(*rhs.Internals);
}
Actor& Actor::operator=(const Actor& rhs)
{
// both *this and rhs might have been moved.
if (!rhs.Internals)
{
Internals.reset();
}
else if (!Internals)
{
Internals = std::make_unique<InternalsType>(*rhs.Internals);
}
else
{
*Internals = *rhs.Internals;
}
return *this;
}
Actor::Actor(vtkm::rendering::Actor&&) noexcept = default;
Actor& Actor::operator=(Actor&&) noexcept = default;
Actor::~Actor() = default;
void Actor::Init(const vtkm::cont::CoordinateSystem& coordinates,
const vtkm::cont::Field& scalarField)

@ -40,9 +40,8 @@ public:
const vtkm::cont::Field& scalarField,
const vtkm::rendering::Color& color);
// Disable copying due to unique_ptr;
Actor(const Actor&) = delete;
Actor& operator=(const Actor&) = delete;
Actor(const Actor&);
Actor& operator=(const Actor&);
Actor(Actor&&) noexcept;
Actor& operator=(Actor&&) noexcept;

@ -259,6 +259,35 @@ ConnectivityProxy::ConnectivityProxy(const vtkm::cont::UnknownCellSet& cellset,
Internals = std::make_unique<InternalsType>(dataset, scalarField.GetName());
}
ConnectivityProxy::ConnectivityProxy(const ConnectivityProxy& rhs)
: Internals(nullptr)
{
// rhs might have been moved, its Internal would be nullptr
if (rhs.Internals)
{
Internals = std::make_unique<InternalsType>(*rhs.Internals);
}
}
ConnectivityProxy& ConnectivityProxy::operator=(const ConnectivityProxy& rhs)
{
// both *this and rhs might have been moved.
if (!rhs.Internals)
{
Internals.reset();
}
else if (!Internals)
{
Internals = std::make_unique<InternalsType>(*rhs.Internals);
}
else
{
*Internals = *rhs.Internals;
}
return *this;
}
VTKM_CONT
ConnectivityProxy::ConnectivityProxy(ConnectivityProxy&&) noexcept = default;
VTKM_CONT

@ -35,8 +35,8 @@ public:
const vtkm::cont::CoordinateSystem& coords,
const vtkm::cont::Field& scalarField);
ConnectivityProxy(const ConnectivityProxy&) = delete;
ConnectivityProxy& operator=(const ConnectivityProxy&) = delete;
ConnectivityProxy(const ConnectivityProxy&);
ConnectivityProxy& operator=(const ConnectivityProxy&);
ConnectivityProxy(ConnectivityProxy&&) noexcept;
ConnectivityProxy& operator=(ConnectivityProxy&&) noexcept;