vtk-m/vtkm/rendering/raytracing/ConnectivityTracerFactory.cxx
Robert Maynard 5ecf2d1187 vtkm::rendering has more compilation units to help out 32bit compilers
Visual Studio default toolset uses 32bit executables for compiling which
means that if it uses more than 4GB of memory per instance it crashes.
By moving the ConnectivityTracer into a separate compilation unit we
can help out the compiler.

This also improved compilation times and library size:

Old:
build time (j8): 48.62 real
lib size: 6.2MB

New:
build time (j8): 41.31 real
lib size: 5.0MB
2018-01-16 10:20:15 -05:00

113 lines
3.8 KiB
C++

//============================================================================
// 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