2016-08-31 23:28:41 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
|
|
|
// This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
// PURPOSE. See the above copyright notice for more information.
|
|
|
|
//
|
|
|
|
// Copyright 2016 Sandia Corporation.
|
|
|
|
// Copyright 2016 UT-Battelle, LLC.
|
|
|
|
// Copyright 2016 Los Alamos National Security.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
|
|
|
// the U.S. Government retains certain rights in this software.
|
|
|
|
//
|
|
|
|
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
|
|
|
// Laboratory (LANL), the U.S. Government retains certain rights in
|
|
|
|
// this software.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <vtkm/rendering/Actor.h>
|
|
|
|
|
|
|
|
#include <vtkm/Assert.h>
|
|
|
|
#include <vtkm/cont/TryExecute.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace rendering
|
|
|
|
{
|
2016-08-31 23:28:41 +00:00
|
|
|
|
|
|
|
struct Actor::InternalsType
|
|
|
|
{
|
|
|
|
vtkm::cont::DynamicCellSet Cells;
|
|
|
|
vtkm::cont::CoordinateSystem Coordinates;
|
|
|
|
vtkm::cont::Field ScalarField;
|
|
|
|
vtkm::rendering::ColorTable ColorTable;
|
|
|
|
|
|
|
|
vtkm::Range ScalarRange;
|
|
|
|
vtkm::Bounds SpatialBounds;
|
|
|
|
|
2016-10-19 22:42:58 +00:00
|
|
|
VTKM_CONT
|
2017-05-18 14:29:41 +00:00
|
|
|
InternalsType(const vtkm::cont::DynamicCellSet& cells,
|
|
|
|
const vtkm::cont::CoordinateSystem& coordinates,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::Field& scalarField,
|
|
|
|
const vtkm::rendering::ColorTable& colorTable)
|
2017-05-18 14:29:41 +00:00
|
|
|
: Cells(cells)
|
|
|
|
, Coordinates(coordinates)
|
|
|
|
, ScalarField(scalarField)
|
|
|
|
, ColorTable(colorTable)
|
|
|
|
{
|
|
|
|
}
|
2016-08-31 23:28:41 +00:00
|
|
|
};
|
|
|
|
|
2017-07-28 17:31:19 +00:00
|
|
|
Actor::Actor(const vtkm::cont::DynamicCellSet& cells,
|
|
|
|
const vtkm::cont::CoordinateSystem& coordinates,
|
|
|
|
const vtkm::cont::Field& scalarField,
|
|
|
|
const vtkm::rendering::Color& color)
|
|
|
|
: Internals(
|
|
|
|
new InternalsType(cells, coordinates, scalarField, vtkm::rendering::ColorTable(color)))
|
|
|
|
{
|
|
|
|
this->Init(coordinates, scalarField);
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
Actor::Actor(const vtkm::cont::DynamicCellSet& cells,
|
2017-05-26 17:53:28 +00:00
|
|
|
const vtkm::cont::CoordinateSystem& coordinates,
|
|
|
|
const vtkm::cont::Field& scalarField,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::ColorTable& colorTable)
|
2016-08-31 23:28:41 +00:00
|
|
|
: Internals(new InternalsType(cells, coordinates, scalarField, colorTable))
|
2017-07-28 17:31:19 +00:00
|
|
|
{
|
|
|
|
this->Init(coordinates, scalarField);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Actor::Init(const vtkm::cont::CoordinateSystem& coordinates,
|
|
|
|
const vtkm::cont::Field& scalarField)
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
VTKM_ASSERT(scalarField.GetData().GetNumberOfComponents() == 1);
|
|
|
|
|
2017-02-24 21:39:37 +00:00
|
|
|
scalarField.GetRange(&this->Internals->ScalarRange);
|
|
|
|
this->Internals->SpatialBounds = coordinates.GetBounds();
|
2016-08-31 23:28:41 +00:00
|
|
|
}
|
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
void Actor::Render(vtkm::rendering::Mapper& mapper,
|
|
|
|
vtkm::rendering::Canvas& canvas,
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Camera& camera) const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
mapper.SetCanvas(&canvas);
|
|
|
|
mapper.SetActiveColorTable(this->Internals->ColorTable);
|
2017-05-26 17:53:28 +00:00
|
|
|
mapper.RenderCells(this->Internals->Cells,
|
|
|
|
this->Internals->Coordinates,
|
|
|
|
this->Internals->ScalarField,
|
|
|
|
this->Internals->ColorTable,
|
|
|
|
camera,
|
2016-08-31 23:28:41 +00:00
|
|
|
this->Internals->ScalarRange);
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::DynamicCellSet& Actor::GetCells() const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
return this->Internals->Cells;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::CoordinateSystem& Actor::GetCoordinates() const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
return this->Internals->Coordinates;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::cont::Field& Actor::GetScalarField() const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
return this->Internals->ScalarField;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::ColorTable& Actor::GetColorTable() const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
return this->Internals->ColorTable;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::Range& Actor::GetScalarRange() const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
return this->Internals->ScalarRange;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::Bounds& Actor::GetSpatialBounds() const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
return this->Internals->SpatialBounds;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
void Actor::SetScalarRange(const vtkm::Range& scalarRange)
|
2017-02-09 23:38:40 +00:00
|
|
|
{
|
|
|
|
this->Internals->ScalarRange = scalarRange;
|
|
|
|
}
|
2016-08-31 23:28:41 +00:00
|
|
|
}
|
|
|
|
} // namespace vtkm::rendering
|