From 7522659d1d1e4f8c05d1f01b6088eff5ff3f6470 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Fri, 24 Feb 2012 11:31:38 +0100 Subject: [PATCH] update MC modif tuto_oper --- Apps/Tuto/tuto_oper2.cpp | 16 ++++++++++ Apps/Tuto/tuto_oper2.ui | 5 +++ include/Algo/MC/image.h | 5 ++- include/Algo/MC/image.hpp | 55 ++++++++++++++++++++++++++++---- include/Algo/MC/marchingcube.h | 2 +- include/Algo/MC/marchingcube.hpp | 31 ++++++++---------- 6 files changed, 88 insertions(+), 26 deletions(-) diff --git a/Apps/Tuto/tuto_oper2.cpp b/Apps/Tuto/tuto_oper2.cpp index b596a6fa..10be95ef 100644 --- a/Apps/Tuto/tuto_oper2.cpp +++ b/Apps/Tuto/tuto_oper2.cpp @@ -149,6 +149,17 @@ void MyQT::operation(int x) m_selected=NIL; } break; + case 9: + CGoGNout <<"delete face"<setDartColor(m_selected,0.8f,0.0f,0.0f); + if (m_selected2!=NIL) + m_render_topo->setDartColor(m_selected2,0.0f,0.8f,0.0f); + std::string filename = selectFileSave("snapshot file", ".", "(*.svg)"); m_render_topo->svgout2D(filename, modelViewMatrix(),projectionMatrix()); } diff --git a/Apps/Tuto/tuto_oper2.ui b/Apps/Tuto/tuto_oper2.ui index 341fc335..043b923a 100644 --- a/Apps/Tuto/tuto_oper2.ui +++ b/Apps/Tuto/tuto_oper2.ui @@ -94,6 +94,11 @@ mergeFace + + + deleteFace + + diff --git a/include/Algo/MC/image.h b/include/Algo/MC/image.h index e6dc2312..9c0e8f27 100644 --- a/include/Algo/MC/image.h +++ b/include/Algo/MC/image.h @@ -30,7 +30,9 @@ #include "Utils/img3D_IO.h" +#ifdef WITH_ZINRI #include "Zinrimage.h" +#endif namespace CGoGN { @@ -121,11 +123,12 @@ protected: */ //bool correct(const gmtl::Vec3i& _V); +#ifdef WITH_ZINRI /** * internal inrimage prt */ PTRINRIMAGE mImage; - +#endif public: diff --git a/include/Algo/MC/image.hpp b/include/Algo/MC/image.hpp index 03541b15..a0d7898a 100644 --- a/include/Algo/MC/image.hpp +++ b/include/Algo/MC/image.hpp @@ -29,9 +29,6 @@ #include #include -#include "Utils/img3D_IO.h" -#include "Zinrimage.h" - namespace CGoGN { @@ -177,6 +174,7 @@ void Image::loadVox(char *filename) m_Alloc=true; } +#ifdef WITH_QT template< typename DataType > bool Image::loadPNG3D(const char* filename) { @@ -199,8 +197,9 @@ bool Image::loadPNG3D(const char* filename) return true; } +#endif - +#ifdef WITH_ZINRI template< typename DataType > bool Image::loadInrgz(const char* filename) { @@ -230,7 +229,7 @@ bool Image::loadInrgz(const char* filename) return true; } - +#endif @@ -472,9 +471,52 @@ Image* Image::Blur3() return newImg; } +//template +//void Image::createMaskOffsetSphere(std::vector& table, int _i32radius) +//{ +// // compute the width of the sphere for memory allocation +// int i32Width = 2*_i32radius + 1; +// // squared radius +// float fRad2 = (float)(_i32radius*_i32radius); +// +// // memory allocation +// // difficult to know how many voxels before computing, +// // so the reserve for the BB +// table.reserve(i32Width*i32Width*i32Width); +// table.clear(); +// +// // scan all the BB of the sphere +// for (int z = -_i32radius; z<=_i32radius; z++) +// { +// for (int y = -_i32radius; y<=_i32radius; y++) +// { +// for (int x = -_i32radius; x<=_i32radius; x++) +// { +// Geom::Vec3f v((float)x,(float)y,(float)z); +// float fLength = v.norm2(); +// // if inside the sphere +// if (fLength<=fRad2) +// { +// // the the index of the voxel +// int index = z * m_WXY + y * m_WX + x; +// table.push_back(index); +// } +// } +// } +// } +//} + + template void Image::createMaskOffsetSphere(std::vector& table, int _i32radius) { + float smin = std::min(m_SX, std::min(m_SY,m_SZ)); + + float xs = m_SX/smin; + float ys = m_SY/smin; + float zs = m_SZ/smin; + + // compute the width of the sphere for memory allocation int i32Width = 2*_i32radius + 1; // squared radius @@ -493,7 +535,7 @@ void Image::createMaskOffsetSphere(std::vector& table, int _i32ra { for (int x = -_i32radius; x<=_i32radius; x++) { - Geom::Vec3f v((float)x,(float)y,(float)z); + Geom::Vec3f v(float(x)*xs,float(y)*ys,float(z)*zs); float fLength = v.norm2(); // if inside the sphere if (fLength<=fRad2) @@ -507,6 +549,7 @@ void Image::createMaskOffsetSphere(std::vector& table, int _i32ra } } + template float Image::computeCurvatureCount(const DataType *ptrVox, const std::vector& sphere, DataType val) { diff --git a/include/Algo/MC/marchingcube.h b/include/Algo/MC/marchingcube.h index 70f9c0df..d5a8bcb8 100644 --- a/include/Algo/MC/marchingcube.h +++ b/include/Algo/MC/marchingcube.h @@ -261,7 +261,7 @@ public: void removeFacesOfBoundary(AttributeHandler& boundVertices, unsigned int frameWidth); - void recalPoints(); + void recalPoints(const Geom::Vec3f& origin); }; diff --git a/include/Algo/MC/marchingcube.hpp b/include/Algo/MC/marchingcube.hpp index 772496c0..8ee5d8ca 100644 --- a/include/Algo/MC/marchingcube.hpp +++ b/include/Algo/MC/marchingcube.hpp @@ -120,7 +120,7 @@ void MarchingCube::simpleMeshing() // compute value to transform points directly to final system coordinate -// m_fOrigin = typename PFP::VEC3((float)(m_Image->getOrigin()[0]),(float)(m_Image->getOrigin()[1]),(float)(m_Image->getOrigin()[2])); + m_fOrigin = typename PFP::VEC3((float)(m_Image->getOrigin()[0]),(float)(m_Image->getOrigin()[1]),(float)(m_Image->getOrigin()[2])); m_fScal[0] = m_Image->getVoxSizeX(); m_fScal[1] = m_Image->getVoxSizeY(); @@ -483,7 +483,9 @@ void MarchingCube::createFaces_1(DataType *vox, const unsigned int lVertTable[12]; - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); +// typename PFP::VEC3 vPos(float(_lX) , float(_lY) , float(_lZ) ); +// typename PFP::VEC3 vPos(float(_lX) + 0.5f, float(_lY) + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices @@ -545,8 +547,7 @@ void MarchingCube::createFaces_2(DataType *vox, const return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -603,8 +604,7 @@ void MarchingCube::createFaces_3(DataType *vox, const return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -659,8 +659,7 @@ void MarchingCube::createFaces_4(DataType *vox, const return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -718,8 +717,7 @@ void MarchingCube::createFaces_5(DataType *vox, const return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX; @@ -775,8 +773,7 @@ void MarchingCube::createFaces_6(DataType *vox, const return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX+1; @@ -837,8 +834,7 @@ void MarchingCube::createFaces_7(DataType *vox, const return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX+1; @@ -899,8 +895,7 @@ void MarchingCube::createFaces_8(DataType *vox, const return; unsigned int lVertTable[12]; -// typename PFP::VEC3 vPos((float)_lX , (float)_lY, (float)_lZ); - typename PFP::VEC3 vPos((float)_lX + 0.5f, (float)_lY + 0.5f, (float)_lZ + 0.5f); + typename PFP::VEC3 vPos(_lX, _lY, _lZ); // create the new vertices int lX = _lX+1; @@ -1241,7 +1236,7 @@ void MarchingCube::removeFacesOfBoundary(AttributeHand } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::recalPoints() +void MarchingCube::recalPoints(const Geom::Vec3f& origin) { for(unsigned int i=m_positions.begin(); i != m_positions.end(); m_positions.next(i)) @@ -1251,7 +1246,7 @@ void MarchingCube::recalPoints() P[0] = P[0] * m_fScal[0]; P[1] = P[1] * m_fScal[1]; P[2] = P[2] * m_fScal[2]; - + P+=origin; } } -- GitLab