Throw exception if extracted region is too large.

This commit is contained in:
David Williams 2014-05-27 23:23:24 +02:00
parent 37ba9ab338
commit 35049b7a53
2 changed files with 12 additions and 4 deletions

View File

@ -186,13 +186,15 @@ int main(int argc, char *argv[])
std::cout << "Compression ratio: 1 to " << (1.0/(volData.calculateCompressionRatio())) << std::endl;
//Extract the surface
auto mesh = extractCubicMesh(&volData, reg);
auto mesh = extractCubicMesh(&volData, reg2);
std::cout << "#vertices: " << mesh.getNoOfVertices() << std::endl;
//Pass the surface to the OpenGL window
openGLWidget.addMesh(mesh);
auto decodedMesh = decode(mesh);
openGLWidget.setViewableRegion(reg);
//Pass the surface to the OpenGL window
openGLWidget.addMesh(decodedMesh);
openGLWidget.setViewableRegion(reg2);
//Run the message pump.
return app.exec();

View File

@ -45,6 +45,12 @@ namespace PolyVox
,m_tBorderValue(tBorderValue)
{
m_funcIsQuadNeededCallback = isQuadNeeded;
// This extractor has a limit as to how large the extracted region can be, because the vertex positions are encoded with a single byte per component.
int32_t maxReionDimension = 256;
POLYVOX_THROW_IF(region.getWidthInVoxels() > maxReionDimension, std::invalid_argument, "Requested extraction region exceeds maximum dimensions");
POLYVOX_THROW_IF(region.getHeightInVoxels() > maxReionDimension, std::invalid_argument, "Requested extraction region exceeds maximum dimensions");
POLYVOX_THROW_IF(region.getDepthInVoxels() > maxReionDimension, std::invalid_argument, "Requested extraction region exceeds maximum dimensions");
}
template<typename VolumeType, typename IsQuadNeeded>