2022-02-02 02:45:07 +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.
|
|
|
|
//============================================================================
|
2022-01-05 20:30:40 +00:00
|
|
|
#include <vtkm/cont/ColorTable.h>
|
|
|
|
#include <vtkm/cont/DataSet.h>
|
|
|
|
#include <vtkm/cont/Initialize.h>
|
|
|
|
|
2022-02-07 20:34:18 +00:00
|
|
|
#include <vtkm/io/VTKDataSetReader.h>
|
2022-01-05 20:30:40 +00:00
|
|
|
#include <vtkm/rendering/Actor.h>
|
|
|
|
#include <vtkm/rendering/CanvasRayTracer.h>
|
|
|
|
#include <vtkm/rendering/MapperRayTracer.h>
|
|
|
|
#include <vtkm/rendering/Scene.h>
|
|
|
|
#include <vtkm/rendering/View3D.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
2022-10-12 00:23:44 +00:00
|
|
|
vtkm::cont::Initialize(argc, argv);
|
2022-01-05 20:30:40 +00:00
|
|
|
|
|
|
|
//Loading .vtk File
|
|
|
|
vtkm::io::VTKDataSetReader reader("data/kitchen.vtk");
|
|
|
|
vtkm::cont::DataSet ds_from_file = reader.ReadDataSet();
|
|
|
|
|
|
|
|
//Creating Actor
|
|
|
|
vtkm::cont::ColorTable colorTable("viridis");
|
|
|
|
vtkm::rendering::Actor actor(ds_from_file.GetCellSet(),
|
|
|
|
ds_from_file.GetCoordinateSystem(),
|
|
|
|
ds_from_file.GetField("c1"),
|
|
|
|
colorTable);
|
|
|
|
|
|
|
|
//Creating Scene and adding Actor
|
|
|
|
vtkm::rendering::Scene scene;
|
2023-06-01 17:46:06 +00:00
|
|
|
scene.AddActor(std::move(actor));
|
2022-01-05 20:30:40 +00:00
|
|
|
|
|
|
|
//Creating and initializing the View using the Canvas, Ray Tracer Mappers, and Scene
|
|
|
|
vtkm::rendering::MapperRayTracer mapper;
|
|
|
|
vtkm::rendering::CanvasRayTracer canvas(1920, 1080);
|
|
|
|
vtkm::rendering::View3D view(scene, mapper, canvas);
|
|
|
|
|
|
|
|
//Setting the background and foreground colors; optional.
|
|
|
|
view.SetBackgroundColor(vtkm::rendering::Color(1.0f, 1.0f, 1.0f));
|
|
|
|
view.SetForegroundColor(vtkm::rendering::Color(0.0f, 0.0f, 0.0f));
|
|
|
|
|
|
|
|
//Painting View
|
|
|
|
view.Paint();
|
|
|
|
|
|
|
|
//Saving View
|
2022-02-12 16:25:50 +00:00
|
|
|
view.SaveAs("BasicRendering.png");
|
2022-01-05 20:30:40 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|