2016-08-31 23:28:41 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2016-08-31 23:28:41 +00:00
|
|
|
// 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.
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <vtkm/rendering/Scene.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace vtkm
|
|
|
|
{
|
|
|
|
namespace rendering
|
|
|
|
{
|
2016-08-31 23:28:41 +00:00
|
|
|
|
|
|
|
struct Scene::InternalsType
|
|
|
|
{
|
|
|
|
std::vector<vtkm::rendering::Actor> Actors;
|
|
|
|
};
|
|
|
|
|
|
|
|
Scene::Scene()
|
|
|
|
: Internals(new InternalsType)
|
2017-05-18 14:29:41 +00:00
|
|
|
{
|
|
|
|
}
|
2016-08-31 23:28:41 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
void Scene::AddActor(const vtkm::rendering::Actor& actor)
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
this->Internals->Actors.push_back(actor);
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Actor& Scene::GetActor(vtkm::IdComponent index) const
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
return this->Internals->Actors[static_cast<std::size_t>(index)];
|
|
|
|
}
|
|
|
|
|
|
|
|
vtkm::IdComponent Scene::GetNumberOfActors() const
|
|
|
|
{
|
|
|
|
return static_cast<vtkm::IdComponent>(this->Internals->Actors.size());
|
|
|
|
}
|
|
|
|
|
2017-05-26 17:53:28 +00:00
|
|
|
void Scene::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.StartScene();
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent actorIndex = 0; actorIndex < this->GetNumberOfActors(); actorIndex++)
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
const vtkm::rendering::Actor& actor = this->GetActor(actorIndex);
|
2016-08-31 23:28:41 +00:00
|
|
|
actor.Render(mapper, canvas, camera);
|
|
|
|
}
|
|
|
|
mapper.EndScene();
|
|
|
|
}
|
|
|
|
|
|
|
|
vtkm::Bounds Scene::GetSpatialBounds() const
|
|
|
|
{
|
|
|
|
vtkm::Bounds bounds;
|
2017-05-18 14:29:41 +00:00
|
|
|
for (vtkm::IdComponent actorIndex = 0; actorIndex < this->GetNumberOfActors(); actorIndex++)
|
2016-08-31 23:28:41 +00:00
|
|
|
{
|
|
|
|
// accumulate all Actors' spatial bounds into the scene spatial bounds
|
|
|
|
bounds.Include(this->GetActor(actorIndex).GetSpatialBounds());
|
|
|
|
}
|
|
|
|
|
|
|
|
return bounds;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace vtkm::rendering
|