Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/voxelizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
///
/// The voxelization produced by the various modes of the program revolves
/// around the concept of a voxel center. As long as the center of the voxel
/// is inside of the volume defined by a thre dimensional mesh, the voxel is
/// is inside of the volume defined by a three dimensional mesh, the voxel is
/// considered to be \a solid. This is the case for all voxelizations without
/// material data attached to them. If material data is enabled, then the
/// surface voxelizer will generate a shell of voxels that abide by a different
Expand Down
24 changes: 22 additions & 2 deletions src/host_side.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ template <class Node> Voxelizer<Node>::Voxelizer(
std::vector<uint>( _indices, _indices + 3*_nrOfTriangles );

this->calculateBoundingBox();

nrOfDevicesInUse = 0;
}
///////////////////////////////////////////////////////////////////////////////
/// Constructs the voxelizer as well as supplies material information.
Expand Down Expand Up @@ -91,6 +93,8 @@ template <class Node> Voxelizer<Node>::Voxelizer(

this->calculateBoundingBox();

nrOfDevicesInUse = 0;

this->setMaterials( _materials, _nrOfUniqueMaterials );
}
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -471,9 +475,9 @@ void Voxelizer<Node>::allocStaticMem( DevContext<Node> & device )

device.indices_gpu.copyFrom( &this->indices[0] );

device.tileOverlaps.reserve( this->hostVars.nrOfTriangles );
device.tileOverlaps.resize( this->hostVars.nrOfTriangles );

device.offsetBuffer.reserve( this->hostVars.nrOfTriangles );
device.offsetBuffer.resize( this->hostVars.nrOfTriangles );
}
///////////////////////////////////////////////////////////////////////////////
/// When repeatedly calling \p performVoxelization() in order to consecutively
Expand Down Expand Up @@ -581,6 +585,8 @@ std::vector<NodePointer<Node> > Voxelizer<Node>::voxelize( uint maxDimension,

result = this->collectData();

this->deallocate();

// Return the pointer to the voxel data.
return result;
}
Expand Down Expand Up @@ -637,6 +643,8 @@ std::vector<NodePointer<Node> > Voxelizer<Node>::voxelize( double cubeLength,

result = this->collectData();

this->deallocate();

// Return the pointer to the voxel data.
return result;
}
Expand Down Expand Up @@ -1746,6 +1754,8 @@ std::vector<NodePointer<Node> > Voxelizer<Node>::voxelizeToNodes(

result = this->collectData();

this->deallocate();

return result;
}
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1798,6 +1808,8 @@ std::vector<NodePointer<Node> > Voxelizer<Node>::voxelizeToNodes(

result = this->collectData();

this->deallocate();

return result;
}
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1835,6 +1847,8 @@ NodePointer<Node> Voxelizer<Node>::voxelizeToNodesToRAM(

result = this->collectData( this->devices[0], true );

this->deallocate();

return result;
}
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1866,6 +1880,8 @@ NodePointer<Node> Voxelizer<Node>::voxelizeToNodesToRAM(

result = this->collectData( this->devices[0], true );

this->deallocate();

return result;
}
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2277,6 +2293,8 @@ NodePointer<Node> Voxelizer<Node>::voxelizeToRAM( uint maxDimension,

result = this->collectData( this->devices[0], true );

this->deallocate();

return result;
}
///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -2313,6 +2331,8 @@ NodePointer<Node> Voxelizer<Node>::voxelizeToRAM( double cubeLength,

result = this->collectData( this->devices[0], true );

this->deallocate();

return result;
}
///////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 4 additions & 2 deletions src/voxelizer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <cuda_runtime_api.h>
#include <device_functions.h>
#include <device_launch_parameters.h>
#include <sm_11_atomic_functions.h>
#include <sm_12_atomic_functions.h>
//#include <sm_11_atomic_functions.h>
//#include <sm_12_atomic_functions.h>
#include <sm_20_atomic_functions.h>
#include <sm_35_atomic_functions.h>

Expand All @@ -18,6 +18,8 @@
#include <thrust/copy.h>
#include <thrust/unique.h>
#include <thrust/count.h>
#include <thrust/device_malloc.h>
#include <thrust/device_free.h>

#include <iostream>
#include <ctime>
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ file( GLOB TEST_HEADERS . include/*.h )

link_directories( ${CMAKE_CURRENT_BINARY_DIR}/../lib )
find_package( VTK REQUIRED )
include(${VTK_USE_FILE})

# Require Boost >= 1.53 with system and thread components.
find_package( Boost 1.53 REQUIRED COMPONENTS system program_options thread date_time chrono )
Expand Down
31 changes: 25 additions & 6 deletions tests/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include <vtkSmartPointer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyDataReader.h>
#include <vtkSTLReader.h>
#include <vtkPLYReader.h>
#include <vtkOBJReader.h>
#include <vtkProperty.h>

#include <vtkQuad.h>
Expand Down Expand Up @@ -383,11 +385,28 @@ int main(int argc, char** argv)
reader->Update();
polys = reader->GetOutput();
}
if (file.rfind( ".stl") != std::string::npos)
{
vtkSmartPointer<vtkSTLReader> reader =
vtkSmartPointer<vtkSTLReader>::New();
reader->SetFileName(file.c_str());
reader->Update();
polys = reader->GetOutput();
}
if (file.rfind(".obj") != std::string::npos)
{
vtkSmartPointer<vtkOBJReader> reader =
vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(file.c_str());
reader->Update();
polys = reader->GetOutput();
}
}

if ( polys.GetPointer() == NULL )
{
std::cout << "Invalid filename given" << std::endl;
return -1;
}

// Fail if bad model data was received.
Expand Down Expand Up @@ -491,7 +510,7 @@ void visualize(vtkPolyData* data, double3 minVertex, double3 maxVertex, double d
data->SetLines(lines);

vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(data);
mapper->SetInputData(data);

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
Expand Down Expand Up @@ -555,7 +574,7 @@ void renderVoxelization(unsigned int* voxels, bool onlySurface, uint3 res)
data->SetVerts(cells);

vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(data);
mapper->SetInputData(data);

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
Expand Down Expand Up @@ -635,7 +654,7 @@ void renderNodeOutput(NT* nodes, bool onlySurface, bool materials, uint3 res)
data->SetPoints(points);

vtkSmartPointer<vtkVertexGlyphFilter> vertexFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
vertexFilter->SetInputConnection(data->GetProducerPort());
vertexFilter->SetInputData(data);
vertexFilter->Update();

vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
Expand All @@ -644,7 +663,7 @@ void renderNodeOutput(NT* nodes, bool onlySurface, bool materials, uint3 res)
polydata->GetPointData()->SetScalars(colors);

vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(polydata);
mapper->SetInputData(polydata);

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
Expand Down Expand Up @@ -1476,7 +1495,7 @@ void renderFCCNodeOutput(NT* nodes, bool onlySurface, bool materials, uint3 res)
data->SetPoints(points);

vtkSmartPointer<vtkVertexGlyphFilter> vertexFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
vertexFilter->SetInputConnection(data->GetProducerPort());
vertexFilter->SetInputData(data);
vertexFilter->Update();

vtkSmartPointer<vtkPolyData> polydata = vtkSmartPointer<vtkPolyData>::New();
Expand All @@ -1485,7 +1504,7 @@ void renderFCCNodeOutput(NT* nodes, bool onlySurface, bool materials, uint3 res)
polydata->GetPointData()->SetScalars(colors);

vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInput(polydata);
mapper->SetInputData(polydata);

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
Expand Down