Merge topic 'vs2017_rendering_out_of_heap'

5ecf2d11 vtkm::rendering has more compilation units to help out 32bit compilers

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Matt Larsen <mlarsen@cs.uoregon.edu>
Merge-request: !1058
This commit is contained in:
Robert Maynard 2018-01-16 18:03:05 +00:00 committed by Kitware Robot
commit 6ce722973a
12 changed files with 1862 additions and 1524 deletions

@ -65,25 +65,19 @@ set(sources
BitmapFontFactory.cxx
BoundingBoxAnnotation.cxx
Camera.cxx
Canvas.cxx
CanvasRayTracer.cxx
Color.cxx
ColorBarAnnotation.cxx
ColorLegendAnnotation.cxx
ColorTable.cxx
ConnectivityProxy.cxx
DecodePNG.cxx
LineRenderer.cxx
Mapper.cxx
MapperConnectivity.cxx
MapperRayTracer.cxx
MapperVolume.cxx
MapperConnectivity.cxx
MapperWireframer.cxx
Scene.cxx
TextAnnotation.cxx
TextAnnotationBillboard.cxx
TextAnnotationScreen.cxx
TextRenderer.cxx
View.cxx
View1D.cxx
View2D.cxx
@ -91,13 +85,10 @@ set(sources
WorldAnnotator.cxx
internal/RunTriangulator.cxx
raytracing/BoundingVolumeHierarchy.cxx
raytracing/Camera.cxx
raytracing/ChannelBuffer.cxx
raytracing/ConnectivityBase.cxx
raytracing/ConnectivityTracerBase.cxx
raytracing/ConnectivityTracerFactory.cxx
raytracing/Logger.cxx
raytracing/RayTracer.cxx
raytracing/RayOperations.cxx
raytracing/VolumeRendererStructured.cxx
)
set(opengl_headers
@ -133,18 +124,20 @@ set(osmesa_sources
# This list of sources has code that uses devices and so might need to be
# compiled with a device-specific compiler (like CUDA).
set(device_sources
Mapper.cxx
MapperWireframer.cxx
Canvas.cxx
CanvasRayTracer.cxx
ConnectivityProxy.cxx
Mapper.cxx
MapperWireframer.cxx
TextRenderer.cxx
raytracing/BoundingVolumeHierarchy.cxx
raytracing/Camera.cxx
raytracing/ChannelBuffer.cxx
raytracing/VolumeRendererStructured.cxx
raytracing/ConnectivityTracer.cxx
raytracing/RayOperations.cxx
raytracing/RayTracer.cxx
raytracing/VolumeRendererStructured.cxx
)
#-----------------------------------------------------------------------------

@ -25,6 +25,8 @@
#include <vtkm/rendering/Mapper.h>
#include <vtkm/rendering/raytracing/ConnectivityTracerFactory.h>
#include <vtkm/rendering/raytracing/Logger.h>
#include <vtkm/rendering/raytracing/RayOperations.h>
namespace vtkm
{

@ -21,14 +21,15 @@
set(headers
BoundingVolumeHierarchy.h
Camera.h
CellIntersector.h
CellSampler.h
CellTables.h
ChannelBuffer.h
ChannelBufferOperations.h
ConnectivityBase.h
ConnectivityTracer.h
ConnectivityTracerBase.h
ConnectivityTracerFactory.h
CellIntersector.h
CellSampler.h
CellTables.h
Logger.h
MeshConnectivityBuilder.h
MeshConnectivityStructures.h
@ -38,8 +39,8 @@ set(headers
RayTracer.h
RayTracingTypeDefs.h
TriangleIntersector.h
Worklets.h
VolumeRendererStructured.h
Worklets.h
)
set_source_files_properties(CellTables.h

@ -0,0 +1,38 @@
//============================================================================
// 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 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2018 UT-Battelle, LLC.
// Copyright 2018 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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/raytracing/ConnectivityBase.h>
namespace vtkm
{
namespace rendering
{
namespace raytracing
{
ConnectivityBase::ConnectivityBase()
{
}
ConnectivityBase::~ConnectivityBase()
{
}
}
}
}

@ -20,7 +20,8 @@
#ifndef vtk_m_rendering_raytracing_Connectivity_Base_h
#define vtk_m_rendering_raytracing_Connectivity_Base_h
#include <vtkm/rendering/raytracing/Logger.h>
#include <vtkm/rendering/vtkm_rendering_export.h>
#include <vtkm/rendering/raytracing/Ray.h>
namespace vtkm
@ -30,7 +31,7 @@ namespace rendering
namespace raytracing
{
class ConnectivityBase
class VTKM_RENDERING_EXPORT ConnectivityBase
{
public:
enum IntegrationMode
@ -39,8 +40,8 @@ public:
Energy
};
ConnectivityBase() {}
virtual ~ConnectivityBase() {}
ConnectivityBase();
virtual ~ConnectivityBase();
virtual void Trace(Ray<vtkm::Float64>& rays) = 0;
@ -59,6 +60,7 @@ public:
virtual void SetColorMap(
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorMap) = 0;
}; // class ConnectivityBase
}
}

@ -0,0 +1,76 @@
//============================================================================
// 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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#define vtk_m_rendering_raytracing_ConnectivityTracer_cxx
#include <vtkm/rendering/raytracing/ConnectivityTracer.h>
#include <vtkm/rendering/raytracing/ConnectivityTracer.hxx>
namespace vtkm
{
namespace rendering
{
namespace raytracing
{
namespace detail
{
struct RenderFunctor
{
template <typename Device, typename Tracer, typename Rays>
bool operator()(Device device, Tracer&& tracer, Rays&& rays) const
{
tracer.RenderOnDevice(rays, device);
return true;
}
};
} //namespace detail
template <vtkm::Int32 CellType, typename ConnectivityType>
void ConnectivityTracer<CellType, ConnectivityType>::Trace(Ray<vtkm::Float32>& rays)
{
detail::RenderFunctor functor;
vtkm::cont::TryExecute(functor, *this, rays);
}
template <vtkm::Int32 CellType, typename ConnectivityType>
void ConnectivityTracer<CellType, ConnectivityType>::Trace(Ray<vtkm::Float64>& rays)
{
detail::RenderFunctor functor;
vtkm::cont::TryExecute(functor, *this, rays);
}
//explicit construct all valid forms ofConnectivityTracer
template class detail::RayTracking<float>;
template class detail::RayTracking<double>;
template class VTKM_RENDERING_TEMPLATE_EXPORT
ConnectivityTracer<CELL_SHAPE_ZOO, UnstructuredMeshConn>;
template class VTKM_RENDERING_TEMPLATE_EXPORT
ConnectivityTracer<CELL_SHAPE_HEXAHEDRON, UnstructuredMeshConnSingleType>;
template class VTKM_RENDERING_TEMPLATE_EXPORT
ConnectivityTracer<CELL_SHAPE_WEDGE, UnstructuredMeshConnSingleType>;
template class VTKM_RENDERING_TEMPLATE_EXPORT
ConnectivityTracer<CELL_SHAPE_TETRA, UnstructuredMeshConnSingleType>;
template class VTKM_RENDERING_TEMPLATE_EXPORT
ConnectivityTracer<CELL_SHAPE_STRUCTURED, StructuredMeshConn>;
}
}
} // namespace vtkm::rendering::raytracing

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,163 @@
//============================================================================
// 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 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2018 UT-Battelle, LLC.
// Copyright 2018 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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/raytracing/ConnectivityTracerBase.h>
#include <vtkm/VectorAnalysis.h>
#include <vtkm/rendering/raytracing/Logger.h>
namespace vtkm
{
namespace rendering
{
namespace raytracing
{
ConnectivityTracerBase::ConnectivityTracerBase()
: ConnectivityBase()
{
}
ConnectivityTracerBase::~ConnectivityTracerBase()
{
}
void ConnectivityTracerBase::Init()
{
//
// Check to see if a sample distance was set
//
if (SampleDistance <= 0)
{
const vtkm::Float32 defaultSampleRate = 200.f;
// We need to set some default sample distance
vtkm::Vec<vtkm::Float32, 3> extent;
extent[0] = BoundingBox[1] - BoundingBox[0];
extent[1] = BoundingBox[3] - BoundingBox[2];
extent[2] = BoundingBox[5] - BoundingBox[4];
SampleDistance = vtkm::Magnitude(extent) / defaultSampleRate;
}
}
void ConnectivityTracerBase::SetColorMap(
const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorMap)
{
ColorMap = colorMap;
}
void ConnectivityTracerBase::SetVolumeData(const vtkm::cont::Field& scalarField,
const vtkm::Range& scalarBounds)
{
//TODO: Need a way to tell if we have been updated
ScalarField = scalarField;
ScalarBounds = scalarBounds;
bool isSupportedField = (ScalarField.GetAssociation() == vtkm::cont::Field::ASSOC_POINTS ||
ScalarField.GetAssociation() == vtkm::cont::Field::ASSOC_CELL_SET);
if (!isSupportedField)
throw vtkm::cont::ErrorBadValue("Field not accociated with cell set or points");
FieldAssocPoints = ScalarField.GetAssociation() == vtkm::cont::Field::ASSOC_POINTS;
this->Integrator = Volume;
}
void ConnectivityTracerBase::SetEnergyData(const vtkm::cont::Field& absorption,
const vtkm::Int32 numBins,
const vtkm::cont::Field& emission)
{
bool isSupportedField = absorption.GetAssociation() == vtkm::cont::Field::ASSOC_CELL_SET;
if (!isSupportedField)
throw vtkm::cont::ErrorBadValue("Absorption Field '" + absorption.GetName() +
"' not accociated with cells");
ScalarField = absorption;
// Check for emmision
HasEmission = false;
if (emission.GetAssociation() != vtkm::cont::Field::ASSOC_ANY)
{
if (emission.GetAssociation() != vtkm::cont::Field::ASSOC_CELL_SET)
throw vtkm::cont::ErrorBadValue("Emission Field '" + emission.GetName() +
"' not accociated with cells");
HasEmission = true;
EmissionField = emission;
}
// Do some basic range checking
if (numBins < 1)
throw vtkm::cont::ErrorBadValue("Number of energy bins is less than 1");
vtkm::Id binCount = ScalarField.GetData().GetNumberOfValues();
vtkm::Id cellCount = this->GetNumberOfMeshCells();
if (cellCount != (binCount / vtkm::Id(numBins)))
{
std::stringstream message;
message << "Invalid number of absorption bins\n";
message << "Number of cells: " << cellCount << "\n";
message << "Number of field values: " << binCount << "\n";
message << "Number of bins: " << numBins << "\n";
throw vtkm::cont::ErrorBadValue(message.str());
}
if (HasEmission)
{
binCount = EmissionField.GetData().GetNumberOfValues();
if (cellCount != (binCount / vtkm::Id(numBins)))
{
std::stringstream message;
message << "Invalid number of emission bins\n";
message << "Number of cells: " << cellCount << "\n";
message << "Number of field values: " << binCount << "\n";
message << "Number of bins: " << numBins << "\n";
throw vtkm::cont::ErrorBadValue(message.str());
}
}
//TODO: Need a way to tell if we have been updated
this->Integrator = Energy;
}
void ConnectivityTracerBase::SetBackgroundColor(const vtkm::Vec<vtkm::Float32, 4>& backgroundColor)
{
BackgroundColor = backgroundColor;
}
void ConnectivityTracerBase::SetSampleDistance(const vtkm::Float32& distance)
{
if (distance <= 0.f)
throw vtkm::cont::ErrorBadValue("Sample distance must be positive.");
SampleDistance = distance;
}
void ConnectivityTracerBase::ResetTimers()
{
IntersectTime = 0.;
IntegrateTime = 0.;
SampleTime = 0.;
LostRayTime = 0.;
MeshEntryTime = 0.;
}
void ConnectivityTracerBase::LogTimers()
{
Logger* logger = Logger::GetInstance();
logger->AddLogData("intersect ", IntersectTime);
logger->AddLogData("integrate ", IntegrateTime);
logger->AddLogData("sample_cells ", SampleTime);
logger->AddLogData("lost_rays ", LostRayTime);
logger->AddLogData("mesh_entry", LostRayTime);
}
}
}
}

@ -0,0 +1,116 @@
//============================================================================
// 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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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.
//============================================================================
#ifndef vtk_m_rendering_raytracing_ConnectivityTracerBase_h
#define vtk_m_rendering_raytracing_ConnectivityTracerBase_h
#include <vtkm/rendering/vtkm_rendering_export.h>
#include <vtkm/rendering/raytracing/ConnectivityBase.h>
#include <vtkm/rendering/raytracing/RayOperations.h>
#include <vtkm/Bounds.h>
#include <vtkm/Range.h>
#include <vtkm/cont/ArrayHandle.h>
#include <vtkm/cont/Field.h>
#include <iomanip>
#include <iostream>
namespace vtkm
{
namespace rendering
{
namespace raytracing
{
class VTKM_RENDERING_EXPORT ConnectivityTracerBase : public ConnectivityBase
{
public:
ConnectivityTracerBase();
virtual ~ConnectivityTracerBase();
void Init();
virtual vtkm::Id GetNumberOfMeshCells() = 0;
void SetColorMap(const vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>>& colorMap) override;
void SetVolumeData(const vtkm::cont::Field& scalarField,
const vtkm::Range& scalarBounds) override;
void SetEnergyData(const vtkm::cont::Field& absorption,
const vtkm::Int32 numBins,
const vtkm::cont::Field& emission) override;
void SetBackgroundColor(const vtkm::Vec<vtkm::Float32, 4>& backgroundColor) override;
void SetSampleDistance(const vtkm::Float32& distance) override;
protected:
vtkm::cont::Field ScalarField;
vtkm::cont::Field EmissionField;
vtkm::Range ScalarBounds;
vtkm::cont::ArrayHandle<vtkm::Vec<vtkm::Float32, 4>> ColorMap;
vtkm::Float32 BoundingBox[6];
vtkm::cont::ArrayHandle<vtkm::Id> PreviousCellIds;
vtkm::Vec<vtkm::Float32, 4> BackgroundColor;
vtkm::Float32 SampleDistance;
bool CountRayStatus;
vtkm::Id RaysLost;
IntegrationMode Integrator;
bool DebugFiltersOn;
bool ReEnterMesh; // Do not try to re-enter the mesh
bool CreatePartialComposites;
bool FieldAssocPoints;
bool HasEmission; // Mode for integrating through engery bins
// timers
vtkm::Float64 IntersectTime;
vtkm::Float64 IntegrateTime;
vtkm::Float64 SampleTime;
vtkm::Float64 LostRayTime;
vtkm::Float64 MeshEntryTime;
template <typename FloatType, typename Device>
void PrintRayStatus(Ray<FloatType>& rays, Device)
{
vtkm::Id raysExited = RayOperations::GetStatusCount(rays, RAY_EXITED_MESH, Device());
vtkm::Id raysActive = RayOperations::GetStatusCount(rays, RAY_ACTIVE, Device());
vtkm::Id raysAbandoned = RayOperations::GetStatusCount(rays, RAY_ABANDONED, Device());
vtkm::Id raysExitedDom = RayOperations::GetStatusCount(rays, RAY_EXITED_DOMAIN, Device());
std::cout << "\r Ray Status " << std::setw(10) << std::left << " Lost " << std::setw(10)
<< std::left << RaysLost << std::setw(10) << std::left << " Exited " << std::setw(10)
<< std::left << raysExited << std::setw(10) << std::left << " Active "
<< std::setw(10) << raysActive << std::setw(10) << std::left << " Abandoned "
<< std::setw(10) << raysAbandoned << " Exited Domain " << std::setw(10) << std::left
<< raysExitedDom << "\n";
}
void ResetTimers();
void LogTimers();
};
}
}
}
#endif

@ -0,0 +1,112 @@
//============================================================================
// 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 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// 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/raytracing/ConnectivityTracer.h>
#include <vtkm/rendering/raytracing/ConnectivityTracerFactory.h>
#include <vtkm/rendering/raytracing/RayTracingTypeDefs.h>
#ifndef CELL_SHAPE_ZOO
#define CELL_SHAPE_ZOO 255
#endif
#ifndef CELL_SHAPE_STRUCTURED
#define CELL_SHAPE_STRUCTURED 254
#endif
namespace vtkm
{
namespace rendering
{
namespace raytracing
{
//----------------------------------------------------------------------------
ConnectivityTracerFactory::TracerType ConnectivityTracerFactory::DetectCellSetType(
const vtkm::cont::DynamicCellSet& cellset)
{
ConnectivityTracerFactory::TracerType type = Unsupported;
if (cellset.IsSameType(vtkm::cont::CellSetExplicit<>()))
{
type = Unstructured;
}
else if (cellset.IsSameType(vtkm::cont::CellSetSingleType<>()))
{
vtkm::cont::CellSetSingleType<> singleType = cellset.Cast<vtkm::cont::CellSetSingleType<>>();
//
// Now we need to determine what type of cells this holds
//
vtkm::cont::ArrayHandleConstant<vtkm::UInt8> shapes =
singleType.GetShapesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
vtkm::UInt8 shapeType = shapes.GetPortalConstControl().Get(0);
if (shapeType == CELL_SHAPE_HEXAHEDRON)
type = UnstructuredHex;
if (shapeType == CELL_SHAPE_TETRA)
type = UnstructuredTet;
if (shapeType == CELL_SHAPE_WEDGE)
type = UnstructuredWedge;
if (shapeType == CELL_SHAPE_PYRAMID)
type = UnstructuredPyramid;
}
else if (cellset.IsSameType(vtkm::cont::CellSetStructured<3>()))
{
type = Structured;
}
return type;
}
//----------------------------------------------------------------------------
ConnectivityBase* ConnectivityTracerFactory::CreateTracer(
const vtkm::cont::DynamicCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords)
{
ConnectivityTracerFactory::TracerType type = DetectCellSetType(cellset);
if (type == Unstructured)
{
UnstructuredMeshConn meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_ZOO, UnstructuredMeshConn>(meshConn);
}
else if (type == UnstructuredHex)
{
UnstructuredMeshConnSingleType meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_HEXAHEDRON, UnstructuredMeshConnSingleType>(meshConn);
}
else if (type == UnstructuredWedge)
{
UnstructuredMeshConnSingleType meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_WEDGE, UnstructuredMeshConnSingleType>(meshConn);
}
else if (type == UnstructuredTet)
{
UnstructuredMeshConnSingleType meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_TETRA, UnstructuredMeshConnSingleType>(meshConn);
}
else if (type == Structured)
{
StructuredMeshConn meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_STRUCTURED, StructuredMeshConn>(meshConn);
}
throw vtkm::cont::ErrorBadValue("Connectivity tracer: cell set type unsupported");
}
}
}
} // namespace vtkm::rendering::raytracing

@ -6,9 +6,9 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//
// Copyright 2015 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2015 UT-Battelle, LLC.
// Copyright 2015 Los Alamos National Security.
// Copyright 2018 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
// Copyright 2018 UT-Battelle, LLC.
// Copyright 2018 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
// the U.S. Government retains certain rights in this software.
@ -20,17 +20,24 @@
#ifndef vtk_m_rendering_raytracing_ConnectivityTracerFactory_h
#define vtk_m_rendering_raytracing_ConnectivityTracerFactory_h
#include <vtkm/rendering/raytracing/ConnectivityTracer.h>
#include <vtkm/rendering/raytracing/RayTracingTypeDefs.h>
#include <vtkm/rendering/raytracing/ConnectivityBase.h>
#include <vtkm/rendering/vtkm_rendering_export.h>
#include <vtkm/cont/DynamicCellSet.h>
namespace vtkm
{
namespace cont
{ //forward declares
class CoordinateSystem;
}
namespace rendering
{
namespace raytracing
{
class ConnectivityTracerFactory
class VTKM_RENDERING_EXPORT ConnectivityTracerFactory
{
public:
enum TracerType
@ -45,78 +52,11 @@ public:
};
//----------------------------------------------------------------------------
static TracerType DetectCellSetType(const vtkm::cont::DynamicCellSet& cellset)
{
TracerType type = Unsupported;
if (cellset.IsSameType(vtkm::cont::CellSetExplicit<>()))
{
type = Unstructured;
}
else if (cellset.IsSameType(vtkm::cont::CellSetSingleType<>()))
{
vtkm::cont::CellSetSingleType<> singleType = cellset.Cast<vtkm::cont::CellSetSingleType<>>();
//
// Now we need to determine what type of cells this holds
//
vtkm::cont::ArrayHandleConstant<vtkm::UInt8> shapes =
singleType.GetShapesArray(vtkm::TopologyElementTagPoint(), vtkm::TopologyElementTagCell());
vtkm::UInt8 shapeType = shapes.GetPortalConstControl().Get(0);
if (shapeType == CELL_SHAPE_HEXAHEDRON)
type = UnstructuredHex;
if (shapeType == CELL_SHAPE_TETRA)
type = UnstructuredTet;
if (shapeType == CELL_SHAPE_WEDGE)
type = UnstructuredWedge;
if (shapeType == CELL_SHAPE_PYRAMID)
type = UnstructuredPyramid;
}
else if (cellset.IsSameType(vtkm::cont::CellSetStructured<3>()))
{
type = Structured;
}
return type;
}
static TracerType DetectCellSetType(const vtkm::cont::DynamicCellSet& cellset);
//----------------------------------------------------------------------------
static ConnectivityBase* CreateTracer(const vtkm::cont::DynamicCellSet& cellset,
const vtkm::cont::CoordinateSystem& coords)
{
TracerType type = DetectCellSetType(cellset);
if (type == Unstructured)
{
UnstructuredMeshConn meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_ZOO, UnstructuredMeshConn>(meshConn);
}
else if (type == UnstructuredHex)
{
UnstructuredMeshConnSingleType meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_HEXAHEDRON, UnstructuredMeshConnSingleType>(
meshConn);
}
else if (type == UnstructuredWedge)
{
UnstructuredMeshConnSingleType meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_WEDGE, UnstructuredMeshConnSingleType>(meshConn);
}
else if (type == UnstructuredTet)
{
UnstructuredMeshConnSingleType meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_TETRA, UnstructuredMeshConnSingleType>(meshConn);
}
else if (type == Structured)
{
StructuredMeshConn meshConn(cellset, coords);
return new ConnectivityTracer<CELL_SHAPE_STRUCTURED, StructuredMeshConn>(meshConn);
}
else
{
throw vtkm::cont::ErrorBadValue("Connectivity tracer: cell set type unsupported");
}
return nullptr;
}
const vtkm::cont::CoordinateSystem& coords);
};
}
}