i found here
http://www.volumesoffun.com/new-polyvox ... available/ that it is possible to smooth the volume data with LowPassFilter. Simply i modified the TestLowPassFilter example to see what happens:
Quote:
#include "testApp.h"
#include "ofxPolyvox.h"
#include "PolyVoxCore/MarchingCubesSurfaceExtractor.h"
#include "PolyVoxCore/RawVolume.h"
#include "PolyVoxCore/MaterialDensityPair.h"
#include "PolyVoxCore/Density.h"
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
#include "PolyVoxCore/LowPassFilter.h"
//Use the PolyVox namespace
using namespace PolyVox;
void testExecute(RawVolume<Density8>& volData)
{
const int32_t g_uVolumeSideLength = 8;
//Create two solid walls at opposite sides of the volume
for (int32_t z = 0; z < g_uVolumeSideLength; z++)
{
for (int32_t y = 0; y < g_uVolumeSideLength; y++)
{
for (int32_t x = 0; x < g_uVolumeSideLength; x++)
{
if(x % 2 == 0)
{
Density8 voxel(32);
volData.setVoxelAt(x, y, z, voxel);
}
}
}
}
}
//--------------------------------------------------------------
void testApp::setup(){
//We'll be rendering with index/vertex arrays
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
const int32_t g_uVolumeSideLength = 12;
PolyVox::Region reg(Vector3DInt32(0,0,0), Vector3DInt32(g_uVolumeSideLength-1, g_uVolumeSideLength-1, g_uVolumeSideLength-1));
//Create empty volume
RawVolume<Density8> volData(reg);
testExecute(volData);
RawVolume<Density8> resultVolume(reg);
LowPassFilter< RawVolume<Density8>, RawVolume<Density8> > pass1(&volData, reg, &resultVolume, reg, 5);
pass1.execute();
std::cout << "Input volume:" << std::endl;
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(0,0,0).getDensity()) << std::endl; // 32
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(1,1,1).getDensity()) << std::endl; // 0
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(2,2,2).getDensity()) << std::endl; // 3
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(3,3,3).getDensity()) << std::endl; // 0
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(4,4,4).getDensity()) << std::endl; // 32
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(5,5,5).getDensity()) << std::endl; // 0
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(6,6,6).getDensity()) << std::endl; // 32
std::cout << "Voxel = " << static_cast<int>(volData.getVoxelAt(7,7,7).getDensity()) << std::endl; // 0
std::cout << std::endl << "Output volume:" << std::endl;
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(0,0,0).getDensity()) << std::endl; // 4
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(1,1,1).getDensity()) << std::endl; // 21
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(2,2,2).getDensity()) << std::endl; // 10
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(3,3,3).getDensity()) << std::endl; // 21
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(4,4,4).getDensity()) << std::endl; // 10
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(5,5,5).getDensity()) << std::endl; // 21
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(6,6,6).getDensity()) << std::endl; // 10
std::cout << "Voxel = " << static_cast<int>(resultVolume.getVoxelAt(7,7,7).getDensity()) << std::endl; // 4
SurfaceMesh<PositionMaterialNormal> mesh;
CubicSurfaceExtractorWithNormals< RawVolume<Density8> > surfaceExtractor(&resultVolume, resultVolume.getEnclosingRegion(), &mesh);
surfaceExtractor.execute();
polyvox.setSurfaceMeshToRender(mesh);
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
cam.begin();
//Anable smooth lighting
ofEnableLighting();
//glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
polyvox.draw();
cam.end();
}
but i got this error:
Quote:
-------------- Build: Debug in LowPassFilter ---------------
Using makefile: Makefile
compiling x86_64 object for: src/testApp.cpp
In file included from ../../../addons/ofxPolyvox/src/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.h:27:0,
from ../../../addons/ofxPolyvox/src/ofxPolyvox.h:3,
from src/testApp.h:4,
from src/testApp.cpp:1:
../../../addons/ofxPolyvox/src/PolyVoxCore/include/PolyVoxCore/DefaultIsQuadNeeded.h: In member function ‘bool PolyVox::DefaultIsQuadNeeded<VoxelType>::operator()(VoxelType, VoxelType, float&) [with VoxelType = PolyVox::Density<unsigned char>]’:
../../../addons/ofxPolyvox/src/PolyVoxCore/include/PolyVoxCore/CubicSurfaceExtractorWithNormals.inl:54:6: instantiated from ‘void PolyVox::CubicSurfaceExtractorWithNormals<VolumeType, IsQuadNeeded>::execute() [with VolumeType = PolyVox::RawVolume<PolyVox::Density<unsigned char> >, IsQuadNeeded = PolyVox::DefaultIsQuadNeeded<PolyVox::Density<unsigned char> >]’
src/testApp.cpp:77:27: instantiated from here
../../../addons/ofxPolyvox/src/PolyVoxCore/include/PolyVoxCore/DefaultIsQuadNeeded.h:35:4: error: no match for ‘operator>’ in ‘back > 0’
../../../addons/ofxPolyvox/src/PolyVoxCore/include/PolyVoxCore/DefaultIsQuadNeeded.h:35:4: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:220:5: note: template<class _T1, class _T2> constexpr bool std::operator>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/include/c++/4.6/bits/stl_iterator.h:303:5: note: template<class _Iterator> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:353:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/stl_iterator.h:1073:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::move_iterator<_IteratorL>&, const std::move_iterator<_IteratorR>&)
/usr/include/c++/4.6/bits/stl_iterator.h:1079:5: note: template<class _Iterator> bool std::operator>(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/basic_string.h:2547:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/basic_string.h:2559:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*)
/usr/include/c++/4.6/bits/basic_string.h:2571:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&)
/usr/include/c++/4.6/bits/stl_vector.h:1303:5: note: template<class _Tp, class _Alloc> bool std::operator>(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&)
/usr/include/c++/4.6/tuple:603:5: note: template<class ... _TElements, class ... _UElements> bool std::operator>(const std::tuple<_TElements ...>&, const std::tuple<_Elements ...>&)
/usr/include/c++/4.6/bits/unique_ptr.h:482:5: note: template<class _Tp, class _Dp, class _Up, class _Ep> bool std::operator>(const std::unique_ptr<_Tp, _Dp>&, const std::unique_ptr<_Up, _Ep>&)
/usr/include/c++/4.6/bits/stl_deque.h:287:5: note: template<class _Tp, class _Ref, class _Ptr> bool std::operator>(const std::_Deque_iterator<_Tp, _Ref, _Ptr>&, const std::_Deque_iterator<_Tp, _Ref, _Ptr>&)
/usr/include/c++/4.6/bits/stl_deque.h:294:5: note: template<class _Tp, class _RefL, class _PtrL, class _RefR, class _PtrR> bool std::operator>(const std::_Deque_iterator<_Tp, _RefL, _PtrL>&, const std::_Deque_iterator<_Tp, _RefR, _PtrR>&)
/usr/include/c++/4.6/bits/stl_deque.h:1950:5: note: template<class _Tp, class _Alloc> bool std::operator>(const std::deque<_Tp, _Alloc>&, const std::deque<_Tp, _Alloc>&)
/usr/include/c++/4.6/bits/stl_queue.h:296:5: note: template<class _Tp, class _Seq> bool std::operator>(const std::queue<_Tp, _Seq>&, const std::queue<_Tp, _Seq>&)
/usr/include/c++/4.6/bits/stl_list.h:1606:5: note: template<class _Tp, class _Alloc> bool std::operator>(const std::list<_Tp, _Alloc>&, const std::list<_Tp, _Alloc>&)
/usr/include/c++/4.6/bits/stl_stack.h:271:5: note: template<class _Tp, class _Seq> bool std::operator>(const std::stack<_Tp, _Seq>&, const std::stack<_Tp, _Seq>&)
/usr/include/c++/4.6/bits/stl_tree.h:883:5: note: template<class _Key, class _Val, class _KeyOfValue, class _Compare, class _Alloc> bool std::operator>(const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, const std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&)
/usr/include/c++/4.6/bits/stl_map.h:913:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator>(const std::map<_Key, _Tp, _Compare, _Alloc>&, const std::map<_Key, _Tp, _Compare, _Alloc>&)
/usr/include/c++/4.6/bits/stl_multimap.h:831:5: note: template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator>(const std::multimap<_Key, _Tp, _Compare, _Alloc>&, const std::multimap<_Key, _Tp, _Compare, _Alloc>&)
/usr/include/c++/4.6/bits/stl_set.h:727:5: note: template<class _Key, class _Compare, class _Alloc> bool std::operator>(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&)
/usr/include/c++/4.6/bits/stl_multiset.h:710:5: note: template<class _Key, class _Compare, class _Alloc> bool std::operator>(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&)
../../../addons/ofxPolyvox/src/PolyVoxCore/include/PolyVoxCore/DefaultIsQuadNeeded.h:37:5: error: invalid static_cast from type ‘PolyVox::Density<unsigned char>’ to type ‘float’
../../../addons/ofxPolyvox/src/PolyVoxCore/include/PolyVoxCore/DefaultIsQuadNeeded.h:44:3: warning: control reaches end of non-void function [-Wreturn-type]
make: *** [obj/x86_64Debug/src/testApp.o] Errore 1
Process terminated with status 2 (0 minutes, 1 seconds)
25 errors, 1 warnings
if i exclude these lines of code:
Quote:
CubicSurfaceExtractorWithNormals< RawVolume<Density8> > surfaceExtractor(&resultVolume, resultVolume.getEnclosingRegion(), &mesh);
surfaceExtractor.execute();
the code compile fine but of course without a mesh.
Is this the correct way to use the LowPassFilter and the error is related?
Because i'm interested to smooth my mesh it's better to use another approach to smooth volume data like other c++ lib ( for example OpenMesh
http://openmesh.org/ or trimesh2
http://gfx.cs.princeton.edu/proj/trimesh2/) ?
Thanks
Walter