Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
SMTK
SMTK
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 132
    • Issues 132
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 33
    • Merge Requests 33
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

  • CMB
  • SMTKSMTK
  • Issues
  • #91

Closed
Open
Created Oct 19, 2016 by T.J. Corona@tjcoronaReporter

Remove boost :: int64_t from smtk/mesh/ExtractTessellation.h/cxx

using boost::int64_t causes problems on systems where VTK doesn't set vtkIdType to the same value. This likely needs to use the same logic as the vtkIdType selection logic to ensure compatibility to VTK.

One sloppy workaround for this issue is in ExportVTKData.cxx:167:

namespace
{
template<class T, class U>
struct swapDataTypesIfNecessary
{
  void operator()(T*& in, U*& out, boost::int64_t len)
  {
    out = new U[len];
    for (boost::int64_t i=0;i<len;i++)
      {
      out[i] = in[i];
      }
    delete [] in;
  }
};
template<class T>
struct swapDataTypesIfNecessary<T,T>
{
  void operator()(T*& in, T*& out, boost::int64_t)
  {
    out = in;
  }
};
}
//----------------------------------------------------------------------------
void ExportVTKData::operator()(const smtk::mesh::MeshSet& meshset,
                               vtkUnstructuredGrid* ug) const
{
  boost::int64_t connectivityLength= -1;
  boost::int64_t numberOfCells = -1;
  boost::int64_t numberOfPoints = -1;
  //determine the allocation lengths
  smtk::mesh::PreAllocatedTessellation::determineAllocationLengths(
    meshset, connectivityLength, numberOfCells, numberOfPoints);
  // add the number of cells to the connectivity length to get the length of
  // VTK-style connectivity
  connectivityLength += numberOfCells;
  //create raw data buffers to hold our data
  double* pointsData = new double[3*numberOfPoints];
  unsigned char* cellTypesData = new unsigned char[numberOfCells];
  boost::int64_t* cellLocationsData_ = new boost::int64_t[numberOfCells];
  boost::int64_t* connectivityData_ = new boost::int64_t[connectivityLength];
  //extract tessellation information
  smtk::mesh::PreAllocatedTessellation tess(connectivityData_,
                                            cellLocationsData_,
                                            cellTypesData, pointsData);
  smtk::mesh::extractTessellation(meshset, tess);
  swapDataTypesIfNecessary<boost::int64_t, vtkIdType> swap;
  vtkIdType* cellLocationsData;
  swap(cellLocationsData_, cellLocationsData, numberOfCells);
  vtkIdType* connectivityData;
  swap(connectivityData_, connectivityData, connectivityLength);
  // create vtk data arrays to hold our data
  vtkNew<vtkDoubleArray> pointsArray;
  vtkNew<vtkUnsignedCharArray> cellTypes;
  vtkNew<vtkIdTypeArray> cellLocations;
  vtkNew<vtkIdTypeArray> connectivity;
  // transfer ownership of our raw data arrays to the vtk data arrays
  pointsArray->SetNumberOfComponents(3);
  pointsArray->SetArray(pointsData, 3*numberOfPoints, false,
                        vtkDoubleArray::VTK_DATA_ARRAY_DELETE);
  cellTypes->SetArray(cellTypesData, numberOfCells, false,
                      vtkUnsignedCharArray::VTK_DATA_ARRAY_DELETE);
  cellLocations->SetArray(cellLocationsData, numberOfCells, false,
                          vtkIdTypeArray::VTK_DATA_ARRAY_DELETE);
  connectivity->SetArray(connectivityData, connectivityLength, false,
                         vtkIdTypeArray::VTK_DATA_ARRAY_DELETE);
  vtkNew<vtkPoints> points;
  points->SetData(pointsArray.GetPointer());
  vtkNew<vtkCellArray> cells;
  cells->SetCells(numberOfCells, connectivity.GetPointer());
  ug->SetPoints(points.GetPointer());
  ug->SetCells(cellTypes.GetPointer(), cellLocations.GetPointer(),
               cells.GetPointer());
}
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None