From 333c45d89e7bac36b746bbc11f89eabff960a069 Mon Sep 17 00:00:00 2001 From: Sylvain Thery Date: Thu, 26 Jan 2012 15:01:17 +0100 Subject: [PATCH] resolve some problems in marching-cube --- include/Algo/MC/buffer.h | 78 ++++++++++---------- include/Algo/MC/buffer.hpp | 60 +++++++-------- include/Algo/MC/bufferGen.h | 86 +++++++++++----------- include/Algo/MC/bufferGen.hpp | 76 +++++++++---------- include/Algo/MC/image.h | 33 ++++----- include/Algo/MC/image.hpp | 110 ++++++++++++++-------------- include/Algo/MC/marchingcube.h | 46 ++++++------ include/Algo/MC/marchingcube.hpp | 78 +++++++++----------- include/Algo/MC/marchingcubeGen.h | 45 ++++++------ include/Algo/MC/marchingcubeGen.hpp | 22 +++--- include/Algo/MC/tables.h | 4 +- include/Utils/chrono.h | 2 +- src/Algo/MC/tables.cpp | 4 +- 13 files changed, 316 insertions(+), 328 deletions(-) diff --git a/include/Algo/MC/buffer.h b/include/Algo/MC/buffer.h index 071ddda1..1b40f155 100644 --- a/include/Algo/MC/buffer.h +++ b/include/Algo/MC/buffer.h @@ -121,17 +121,17 @@ protected: /** * position of the first slice in image */ - int32 m_lZpos; + int m_lZpos; /** * width of slice */ - int32 m_lWidth; + int m_lWidth; /** * heigth of slice */ - int32 m_lHeight; + int m_lHeight; public: @@ -142,15 +142,15 @@ public: * @param _lWidth the width of image to buffer * @param _lHeight the height of image to buffer */ - Buffer(int32 _lWidth, int32 _lHeight); + Buffer(int _lWidth, int _lHeight); ~Buffer(); /** * @name Function to store the index of a point on edge O..11 of a cube - * @param int32 _lX coordinate of the cube - * @param int32 _lY coordinate of the cube - * @param int32 _lPoint the index of the point + * @param int _lX coordinate of the cube + * @param int _lY coordinate of the cube + * @param int _lPoint the index of the point */ //@{ /** @@ -159,26 +159,26 @@ public: * @param _lY coordinate of the cube * @param _lPoint the embedding */ - void setPointEdge0 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge1 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge2 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge3 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge4 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge5 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge6 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge7 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge8 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge9 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge10(int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge11(int32 _lX,int32 _lY, unsigned int _lPoint); + void setPointEdge0 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge1 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge2 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge3 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge4 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge5 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge6 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge7 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge8 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge9 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge10(int _lX,int _lY, unsigned int _lPoint); + void setPointEdge11(int _lX,int _lY, unsigned int _lPoint); //@} /** * @name Function to get the index of point store on edge O..11 of a cube **************************************************** - * @param int32 _lX coordinate of the cube - * @param int32 _lY coordinate of the cube - * @param int32 _lPoint the index of the point + * @param int _lX coordinate of the cube + * @param int _lY coordinate of the cube + * @param int _lPoint the index of the point */ //@{ /** @@ -188,18 +188,18 @@ public: * @param _lY coordinate of the cube * @return the index of the point */ - unsigned int getPointEdge0 (int32 _lX,int32 _lY); - unsigned int getPointEdge1 (int32 _lX,int32 _lY); - unsigned int getPointEdge2 (int32 _lX,int32 _lY); - unsigned int getPointEdge3 (int32 _lX,int32 _lY); - unsigned int getPointEdge4 (int32 _lX,int32 _lY); - unsigned int getPointEdge5 (int32 _lX,int32 _lY); - unsigned int getPointEdge6 (int32 _lX,int32 _lY); - unsigned int getPointEdge7 (int32 _lX,int32 _lY); - unsigned int getPointEdge8 (int32 _lX,int32 _lY); - unsigned int getPointEdge9 (int32 _lX,int32 _lY); - unsigned int getPointEdge10(int32 _lX,int32 _lY); - unsigned int getPointEdge11(int32 _lX,int32 _lY); + unsigned int getPointEdge0 (int _lX,int _lY); + unsigned int getPointEdge1 (int _lX,int _lY); + unsigned int getPointEdge2 (int _lX,int _lY); + unsigned int getPointEdge3 (int _lX,int _lY); + unsigned int getPointEdge4 (int _lX,int _lY); + unsigned int getPointEdge5 (int _lX,int _lY); + unsigned int getPointEdge6 (int _lX,int _lY); + unsigned int getPointEdge7 (int _lX,int _lY); + unsigned int getPointEdge8 (int _lX,int _lY); + unsigned int getPointEdge9 (int _lX,int _lY); + unsigned int getPointEdge10(int _lX,int _lY); + unsigned int getPointEdge11(int _lX,int _lY); //@} /** @@ -209,7 +209,7 @@ public: * @param _lY y coordinate of cube * @return table of faces */ - DART* getFacesCubeTableAdr(int32 _lX,int32 _lY); + DART* getFacesCubeTableAdr(int _lX,int _lY); /** * get dart table of faces stored on edge O..11 of a cube @@ -219,7 +219,7 @@ public: * @param _lZ z coordinate of the cube * @return table of faces */ - const DART* getFacesCube(int32 _lX,int32 _lY,int32 _lZ) const; + const DART* getFacesCube(int _lX,int _lY,int _lZ) const; /** @@ -229,7 +229,7 @@ public: * @param _lY y coordinate of the cube * @param _lFace table of faces index */ - void setFacesCube(int32 _lX,int32 _lY, const DART* const _lFace); + void setFacesCube(int _lX,int _lY, const DART* const _lFace); /** @@ -246,7 +246,7 @@ public: * @param _lNeighbour neighbour to store */ - void setExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY, DART _lNeighbour); + void setExternalNeighbour(char _cEdge, int _lX, int _lY, DART _lNeighbour); /** * get neighbour stored on edge O..11 of a cube @@ -256,7 +256,7 @@ public: * @param _lY y coordinate of the cube * @return the neighbour */ - DART getExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY) const ; + DART getExternalNeighbour(char _cEdge, int _lX, int _lY) const ; }; diff --git a/include/Algo/MC/buffer.hpp b/include/Algo/MC/buffer.hpp index bfb0dbb3..d5f21d7b 100644 --- a/include/Algo/MC/buffer.hpp +++ b/include/Algo/MC/buffer.hpp @@ -35,7 +35,7 @@ namespace MC * constructor */ template -Buffer::Buffer(int32 _lWidth, int32 _lHeight) +Buffer::Buffer(int _lWidth, int _lHeight) { m_lWidth = _lWidth+1; m_lHeight = _lHeight+1; @@ -62,7 +62,7 @@ Buffer::~Buffer() * get the face inside a cube of the buffer */ // template -// const DART* Buffer::getFacesCube(int32 _lX, int32 _lY, int32 _lZ) const +// const DART* Buffer::getFacesCube(int _lX, int _lY, int _lZ) const // { // // if (_lZ == m_lZpos) // if current slice .. @@ -83,7 +83,7 @@ Buffer::~Buffer() * set the face inside a cube of the buffer */ template -void Buffer::setFacesCube(int32 _lX,int32 _lY, const DART* const _lFace) +void Buffer::setFacesCube(int _lX,int _lY, const DART* const _lFace) { // get the address of cube's table DART* lLocFaces = m_hcSlice1[_lX + _lY*m_lWidth].m_lFaceEdges; @@ -114,7 +114,7 @@ void Buffer::nextSlice() * get address of face table for direct access */ template -DART* Buffer::getFacesCubeTableAdr(int32 _lX,int32 _lY) +DART* Buffer::getFacesCubeTableAdr(int _lX,int _lY) { return m_hcSlice0[_lX + _lY*m_lWidth].m_lFaceEdges; } @@ -125,84 +125,84 @@ DART* Buffer::getFacesCubeTableAdr(int32 _lX,int32 _lY) */ template -void Buffer::setPointEdge0(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge0(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX + _lY*m_lWidth].m_lX = _lPoint; } template -void Buffer::setPointEdge3(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge3(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +(_lY-1)*m_lWidth].m_lY = _lPoint; } template -void Buffer::setPointEdge8(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge8(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX + _lY*m_lWidth].m_lZ = _lPoint; } template -void Buffer::setPointEdge2(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge2(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[(_lX-1) +_lY*m_lWidth].m_lX =_lPoint; } template -void Buffer::setPointEdge11(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge11(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX + _lY*m_lWidth].m_lZ = _lPoint; } template -void Buffer::setPointEdge1(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge1(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +_lY*m_lWidth].m_lY =_lPoint; } template -void Buffer::setPointEdge9(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge9(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +_lY*m_lWidth].m_lZ =_lPoint; } template -void Buffer::setPointEdge10(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge10(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +_lY*m_lWidth].m_lZ =_lPoint; } template -void Buffer::setPointEdge7(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge7(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[_lX +(_lY-1)*m_lWidth].m_lY =_lPoint; } template -void Buffer::setPointEdge4(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge4(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[_lX +_lY*m_lWidth].m_lX =_lPoint; } template -void Buffer::setPointEdge6(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge6(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[(_lX-1) + _lY*m_lWidth].m_lX =_lPoint; } template -void Buffer::setPointEdge5(int32 _lX,int32 _lY, unsigned int _lPoint) +void Buffer::setPointEdge5(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[_lX +_lY*m_lWidth].m_lY =_lPoint; } @@ -213,91 +213,91 @@ void Buffer::setPointEdge5(int32 _lX,int32 _lY, unsigned int _lPoint) */ template -unsigned int Buffer::getPointEdge0(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge0(int _lX,int _lY) { return m_hcSlice0[_lX + _lY*m_lWidth].m_lX; } template -unsigned int Buffer::getPointEdge3(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge3(int _lX,int _lY) { return m_hcSlice0[_lX +_lY*m_lWidth].m_lY; } template -unsigned int Buffer::getPointEdge8(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge8(int _lX,int _lY) { return m_hcSlice0[_lX + _lY*m_lWidth].m_lZ; } template -unsigned int Buffer::getPointEdge2(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge2(int _lX,int _lY) { return m_hcSlice0[_lX +(_lY+1)*m_lWidth].m_lX; } template -unsigned int Buffer::getPointEdge11(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge11(int _lX,int _lY) { return m_hcSlice0[_lX + (_lY+1)*m_lWidth].m_lZ; } template -unsigned int Buffer::getPointEdge1(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge1(int _lX,int _lY) { return m_hcSlice0[(_lX+1) +_lY*m_lWidth].m_lY; } template -unsigned int Buffer::getPointEdge9(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge9(int _lX,int _lY) { return m_hcSlice0[(_lX+1) +_lY*m_lWidth].m_lZ; } template -unsigned int Buffer::getPointEdge10(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge10(int _lX,int _lY) { return m_hcSlice0[(_lX+1) +(_lY+1)*m_lWidth].m_lZ; } template -unsigned int Buffer::getPointEdge7(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge7(int _lX,int _lY) { return m_hcSlice1[_lX +_lY*m_lWidth].m_lY; } template -unsigned int Buffer::getPointEdge4(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge4(int _lX,int _lY) { return m_hcSlice1[_lX +_lY*m_lWidth].m_lX; } template -unsigned int Buffer::getPointEdge6(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge6(int _lX,int _lY) { return m_hcSlice1[_lX +(_lY+1)*m_lWidth].m_lX; } template -unsigned int Buffer::getPointEdge5(int32 _lX,int32 _lY) +unsigned int Buffer::getPointEdge5(int _lX,int _lY) { return m_hcSlice1[(_lX+1) +_lY*m_lWidth].m_lY; } template -DART Buffer::getExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY) const +DART Buffer::getExternalNeighbour(char _cEdge, int _lX, int _lY) const { switch(_cEdge) @@ -362,7 +362,7 @@ CGoGNerr << "ERROR"< -void Buffer::setExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY, DART _lNeighbour) +void Buffer::setExternalNeighbour(char _cEdge, int _lX, int _lY, DART _lNeighbour) { switch(_cEdge) { diff --git a/include/Algo/MC/bufferGen.h b/include/Algo/MC/bufferGen.h index 8e2c4e18..09470599 100644 --- a/include/Algo/MC/bufferGen.h +++ b/include/Algo/MC/bufferGen.h @@ -128,17 +128,17 @@ protected: /** * position of the first slice in image */ - int32 m_lZpos; + int m_lZpos; /** * width of slice */ - int32 m_lWidth; + int m_lWidth; /** * heigth of slice */ - int32 m_lHeight; + int m_lHeight; public: @@ -149,7 +149,7 @@ public: * @param _lWidth the width of image to buffer * @param _lHeight the height of image to buffer */ - BufferGen(int32 _lWidth, int32 _lHeight); + BufferGen(int _lWidth, int _lHeight); ~BufferGen(); @@ -159,9 +159,9 @@ public: /** * @name Function to store the index of a point on edge O..11 of a cube - * @param int32 _lX coordinate of the cube - * @param int32 _lY coordinate of the cube - * @param int32 _lPoint the index of the point + * @param int _lX coordinate of the cube + * @param int _lY coordinate of the cube + * @param int _lPoint the index of the point */ //@{ /** @@ -170,26 +170,26 @@ public: * @param _lY coordinate of the cube * @param _lPoint the embedding */ - void setPointEdge0 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge1 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge2 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge3 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge4 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge5 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge6 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge7 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge8 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge9 (int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge10(int32 _lX,int32 _lY, unsigned int _lPoint); - void setPointEdge11(int32 _lX,int32 _lY, unsigned int _lPoint); + void setPointEdge0 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge1 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge2 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge3 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge4 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge5 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge6 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge7 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge8 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge9 (int _lX,int _lY, unsigned int _lPoint); + void setPointEdge10(int _lX,int _lY, unsigned int _lPoint); + void setPointEdge11(int _lX,int _lY, unsigned int _lPoint); //@} /** * @name Function to get the index of point store on edge O..11 of a cube **************************************************** - * @param int32 _lX coordinate of the cube - * @param int32 _lY coordinate of the cube - * @param int32 _lPoint the index of the point + * @param int _lX coordinate of the cube + * @param int _lY coordinate of the cube + * @param int _lPoint the index of the point */ //@{ /** @@ -199,18 +199,18 @@ public: * @param _lY coordinate of the cube * @return the index of the point */ - unsigned int getPointEdge0 (int32 _lX,int32 _lY); - unsigned int getPointEdge1 (int32 _lX,int32 _lY); - unsigned int getPointEdge2 (int32 _lX,int32 _lY); - unsigned int getPointEdge3 (int32 _lX,int32 _lY); - unsigned int getPointEdge4 (int32 _lX,int32 _lY); - unsigned int getPointEdge5 (int32 _lX,int32 _lY); - unsigned int getPointEdge6 (int32 _lX,int32 _lY); - unsigned int getPointEdge7 (int32 _lX,int32 _lY); - unsigned int getPointEdge8 (int32 _lX,int32 _lY); - unsigned int getPointEdge9 (int32 _lX,int32 _lY); - unsigned int getPointEdge10(int32 _lX,int32 _lY); - unsigned int getPointEdge11(int32 _lX,int32 _lY); + unsigned int getPointEdge0 (int _lX,int _lY); + unsigned int getPointEdge1 (int _lX,int _lY); + unsigned int getPointEdge2 (int _lX,int _lY); + unsigned int getPointEdge3 (int _lX,int _lY); + unsigned int getPointEdge4 (int _lX,int _lY); + unsigned int getPointEdge5 (int _lX,int _lY); + unsigned int getPointEdge6 (int _lX,int _lY); + unsigned int getPointEdge7 (int _lX,int _lY); + unsigned int getPointEdge8 (int _lX,int _lY); + unsigned int getPointEdge9 (int _lX,int _lY); + unsigned int getPointEdge10(int _lX,int _lY); + unsigned int getPointEdge11(int _lX,int _lY); //@} /** @@ -220,7 +220,7 @@ public: * @param _lY y coordinate of cube * @return table of faces */ - DART* getFacesCubeTableAdr(int32 _lX,int32 _lY); + DART* getFacesCubeTableAdr(int _lX,int _lY); /** * get dart table of faces stored on edge O..11 of a cube @@ -230,7 +230,7 @@ public: * @param _lZ z coordinate of the cube * @return table of faces */ - const DART* getFacesCube(int32 _lX,int32 _lY,int32 _lZ) const; + const DART* getFacesCube(int _lX,int _lY,int _lZ) const; /** @@ -240,7 +240,7 @@ public: * @param _lY y coordinate of the cube * @param _lFace table of faces index */ - void setFacesCube(int32 _lX,int32 _lY, const DART* const _lFace); + void setFacesCube(int _lX,int _lY, const DART* const _lFace); /** @@ -257,7 +257,7 @@ public: * @param _lNeighbour neighbour to store */ - void setExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY, DART _lNeighbour); + void setExternalNeighbour(char _cEdge, int _lX, int _lY, DART _lNeighbour); /** * get neighbour stored on edge O..11 of a cube @@ -267,16 +267,16 @@ public: * @param _lY y coordinate of the cube * @return the neighbour */ - DART getExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY) const ; + DART getExternalNeighbour(char _cEdge, int _lX, int _lY) const ; - void setData(int32 _lX, int32 _lY, DATATYPE data); + void setData(int _lX, int _lY, DATATYPE data); - DATATYPE getData(int32 _lX, int32 _lY); + DATATYPE getData(int _lX, int _lY); - void setData2(int32 _lX, int32 _lY, DATATYPE data); + void setData2(int _lX, int _lY, DATATYPE data); - DATATYPE getData2(int32 _lX, int32 _lY); + DATATYPE getData2(int _lX, int _lY); DATATYPE* getDataPtr() { return m_dataSl0;} DATATYPE* getData2Ptr() {return m_dataSl1;} diff --git a/include/Algo/MC/bufferGen.hpp b/include/Algo/MC/bufferGen.hpp index 00c7c488..24e41c5e 100644 --- a/include/Algo/MC/bufferGen.hpp +++ b/include/Algo/MC/bufferGen.hpp @@ -35,7 +35,7 @@ namespace MC * constructor */ template -BufferGen::BufferGen(int32 _lWidth, int32 _lHeight) +BufferGen::BufferGen(int _lWidth, int _lHeight) { m_lWidth = _lWidth+1; m_lHeight = _lHeight+1; @@ -69,7 +69,7 @@ BufferGen::~BufferGen() * get the face inside a cube of the buffer */ // template -// const DART* BufferGen::getFacesCube(int32 _lX, int32 _lY, int32 _lZ) const +// const DART* BufferGen::getFacesCube(int _lX, int _lY, int _lZ) const // { // // if (_lZ == m_lZpos) // if current slice .. @@ -90,7 +90,7 @@ BufferGen::~BufferGen() * set the face inside a cube of the buffer */ template -void BufferGen::setFacesCube(int32 _lX,int32 _lY, const DART* const _lFace) +void BufferGen::setFacesCube(int _lX,int _lY, const DART* const _lFace) { // get the address of cube's table DART* lLocFaces = m_hcSlice1[_lX + _lY*m_lWidth].m_lFaceEdges; @@ -125,7 +125,7 @@ void BufferGen::nextSlice() * get address of face table for direct access */ template -DART* BufferGen::getFacesCubeTableAdr(int32 _lX,int32 _lY) +DART* BufferGen::getFacesCubeTableAdr(int _lX,int _lY) { return m_hcSlice0[_lX + _lY*m_lWidth].m_lFaceEdges; } @@ -136,84 +136,84 @@ DART* BufferGen::getFacesCubeTableAdr(int32 _lX,int32 _lY) */ template -void BufferGen::setPointEdge0(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge0(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX + _lY*m_lWidth].m_lX = _lPoint; } template -void BufferGen::setPointEdge3(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge3(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +(_lY-1)*m_lWidth].m_lY = _lPoint; } template -void BufferGen::setPointEdge8(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge8(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX + _lY*m_lWidth].m_lZ = _lPoint; } template -void BufferGen::setPointEdge2(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge2(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[(_lX-1) +_lY*m_lWidth].m_lX =_lPoint; } template -void BufferGen::setPointEdge11(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge11(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX + _lY*m_lWidth].m_lZ = _lPoint; } template -void BufferGen::setPointEdge1(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge1(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +_lY*m_lWidth].m_lY =_lPoint; } template -void BufferGen::setPointEdge9(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge9(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +_lY*m_lWidth].m_lZ =_lPoint; } template -void BufferGen::setPointEdge10(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge10(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice0[_lX +_lY*m_lWidth].m_lZ =_lPoint; } template -void BufferGen::setPointEdge7(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge7(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[_lX +(_lY-1)*m_lWidth].m_lY =_lPoint; } template -void BufferGen::setPointEdge4(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge4(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[_lX +_lY*m_lWidth].m_lX =_lPoint; } template -void BufferGen::setPointEdge6(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge6(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[(_lX-1) + _lY*m_lWidth].m_lX =_lPoint; } template -void BufferGen::setPointEdge5(int32 _lX,int32 _lY, unsigned int _lPoint) +void BufferGen::setPointEdge5(int _lX,int _lY, unsigned int _lPoint) { m_hcSlice1[_lX +_lY*m_lWidth].m_lY =_lPoint; } @@ -224,91 +224,91 @@ void BufferGen::setPointEdge5(int32 _lX,int32 _lY, unsigned int _ */ template -unsigned int BufferGen::getPointEdge0(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge0(int _lX,int _lY) { return m_hcSlice0[_lX + _lY*m_lWidth].m_lX; } template -unsigned int BufferGen::getPointEdge3(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge3(int _lX,int _lY) { return m_hcSlice0[_lX +_lY*m_lWidth].m_lY; } template -unsigned int BufferGen::getPointEdge8(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge8(int _lX,int _lY) { return m_hcSlice0[_lX + _lY*m_lWidth].m_lZ; } template -unsigned int BufferGen::getPointEdge2(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge2(int _lX,int _lY) { return m_hcSlice0[_lX +(_lY+1)*m_lWidth].m_lX; } template -unsigned int BufferGen::getPointEdge11(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge11(int _lX,int _lY) { return m_hcSlice0[_lX + (_lY+1)*m_lWidth].m_lZ; } template -unsigned int BufferGen::getPointEdge1(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge1(int _lX,int _lY) { return m_hcSlice0[(_lX+1) +_lY*m_lWidth].m_lY; } template -unsigned int BufferGen::getPointEdge9(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge9(int _lX,int _lY) { return m_hcSlice0[(_lX+1) +_lY*m_lWidth].m_lZ; } template -unsigned int BufferGen::getPointEdge10(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge10(int _lX,int _lY) { return m_hcSlice0[(_lX+1) +(_lY+1)*m_lWidth].m_lZ; } template -unsigned int BufferGen::getPointEdge7(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge7(int _lX,int _lY) { return m_hcSlice1[_lX +_lY*m_lWidth].m_lY; } template -unsigned int BufferGen::getPointEdge4(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge4(int _lX,int _lY) { return m_hcSlice1[_lX +_lY*m_lWidth].m_lX; } template -unsigned int BufferGen::getPointEdge6(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge6(int _lX,int _lY) { return m_hcSlice1[_lX +(_lY+1)*m_lWidth].m_lX; } template -unsigned int BufferGen::getPointEdge5(int32 _lX,int32 _lY) +unsigned int BufferGen::getPointEdge5(int _lX,int _lY) { return m_hcSlice1[(_lX+1) +_lY*m_lWidth].m_lY; } template -DART BufferGen::getExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY) const +DART BufferGen::getExternalNeighbour(char _cEdge, int _lX, int _lY) const { switch(_cEdge) @@ -373,7 +373,7 @@ CGoGNerr << "ERROR"< -void BufferGen::setExternalNeighbour(int8 _cEdge, int32 _lX, int32 _lY, DART _lNeighbour) +void BufferGen::setExternalNeighbour(char _cEdge, int _lX, int _lY, DART _lNeighbour) { switch(_cEdge) { @@ -431,34 +431,34 @@ void BufferGen::setExternalNeighbour(int8 _cEdge, int32 _lX, int3 } /*template -void BufferGen::setData(int32 _lX, int32 _lY, DATATYPE data) +void BufferGen::setData(int _lX, int _lY, DATATYPE data) { m_dataSl0[_lX +_lY*m_lWidth] = data; } template -DATATYPE BufferGen::getData(int32 _lX, int32 _lY) +DATATYPE BufferGen::getData(int _lX, int _lY) { return m_dataSl0[_lX +_lY*m_lWidth]; } template -void BufferGen::setData2(int32 _lX, int32 _lY, DATATYPE data) +void BufferGen::setData2(int _lX, int _lY, DATATYPE data) { m_dataSl1[_lX +_lY*m_lWidth] = data; } template -DATATYPE BufferGen::getData2(int32 _lX, int32 _lY) +DATATYPE BufferGen::getData2(int _lX, int _lY) { return m_dataSl1[_lX +_lY*m_lWidth]; }*/ template -void BufferGen::setData(int32 _lX, int32 _lY, DATATYPE data) +void BufferGen::setData(int _lX, int _lY, DATATYPE data) { // m_hcSlice0[_lX +_lY*m_lWidth].m_data = data; m_dataSl0[_lX +_lY*m_lWidth] = data; @@ -466,7 +466,7 @@ void BufferGen::setData(int32 _lX, int32 _lY, DATATYPE data) template -DATATYPE BufferGen::getData(int32 _lX, int32 _lY) +DATATYPE BufferGen::getData(int _lX, int _lY) { // if (m_dataSl0[_lX +_lY*m_lWidth] != m_hcSlice0[_lX +_lY*m_lWidth].m_data) // CGoGNout << "ERRORRRRR !! "<::getData(int32 _lX, int32 _lY) } template -void BufferGen::setData2(int32 _lX, int32 _lY, DATATYPE data) +void BufferGen::setData2(int _lX, int _lY, DATATYPE data) { //m_hcSlice1[_lX +_lY*m_lWidth].m_data = data; m_dataSl1[_lX +_lY*m_lWidth] = data; @@ -484,7 +484,7 @@ void BufferGen::setData2(int32 _lX, int32 _lY, DATATYPE data) template -DATATYPE BufferGen::getData2(int32 _lX, int32 _lY) +DATATYPE BufferGen::getData2(int _lX, int _lY) { // if (m_dataSl1[_lX +_lY*m_lWidth] != m_hcSlice1[_lX +_lY*m_lWidth].m_data) // CGoGNout << "ERRORRRRR !! "<* filtering(int32 _lWidth); + Image* filtering(int _lWidth); /** * add Frame of zero around the image * @param _lWidth the width of frame to add * @return the new image */ - Image* addFrame(int32 _lWidth); + Image* addFrame(int _lWidth) const; /** * Get the lower corner of bounding AABB @@ -336,7 +335,7 @@ public: void createMaskOffsetCylinders(std::vector& tableX, std::vector& tableY, std::vector& tableZ, int _i32radius); - Image* cropz(unsigned int zmin, unsigned int zmax); + void addCross(); void createNormalSphere(std::vector& table, int _i32radius); diff --git a/include/Algo/MC/image.hpp b/include/Algo/MC/image.hpp index f8d9cd00..d248926a 100644 --- a/include/Algo/MC/image.hpp +++ b/include/Algo/MC/image.hpp @@ -53,7 +53,7 @@ Image::Image(): template< typename DataType > -Image::Image(DataType *data, int32 wx, int32 wy, int32 wz, float sx, float sy, float sz, bool copy ): +Image::Image(DataType *data, int wx, int wy, int wz, float sx, float sy, float sz, bool copy ): m_WX (wx), m_WY (wy), m_WZ (wz), @@ -92,13 +92,13 @@ void Image::loadRaw(char *filename) } // read size - fp.read(reinterpret_cast(&m_WX),sizeof(int32)); - fp.read(reinterpret_cast(&m_WY),sizeof(int32)); - fp.read(reinterpret_cast(&m_WZ),sizeof(int32)); + fp.read(reinterpret_cast(&m_WX),sizeof(int)); + fp.read(reinterpret_cast(&m_WY),sizeof(int)); + fp.read(reinterpret_cast(&m_WZ),sizeof(int)); m_WXY = m_WX * m_WY; - int32 total = m_WXY * m_WZ; + int total = m_WXY * m_WZ; m_Data = new DataType[total]; // read data @@ -160,7 +160,7 @@ void Image::loadVox(char *filename) } m_WXY = m_WX * m_WY; - int32 total = m_WXY * m_WZ; + int total = m_WXY * m_WZ; m_Data = new DataType[total]; @@ -299,20 +299,11 @@ DataType* Image::getVoxelPtr(int lX, int lY, int lZ) * add a frame of Zero to the image */ template< typename DataType > -Image* Image::addFrame(int frameMax) +Image* Image::addFrame(int frameWidth) const { - - float minVS = std::max(m_SX, std::max(m_SY, m_SZ)); - float realFS = static_cast(frameMax) * minVS; - - // real frame size for anisotropic images - int32 lFX = static_cast( ceilf( realFS / m_SX) ); - int32 lFY = static_cast( ceilf( realFS / m_SY) ); - int32 lFZ = static_cast( ceilf( realFS / m_SZ) ); - - int lTx = m_WX+2*lFX; - int lTy = m_WY+2*lFY; - int lTz = m_WZ+2*lFZ; + int lTx = m_WX+2*frameWidth; + int lTy = m_WY+2*frameWidth; + int lTz = m_WZ+2*frameWidth; int lTxy = lTx*lTy; // define Zero @@ -326,42 +317,42 @@ Image* Image::addFrame(int frameMax) DataType *data = newData; - int32 sizeFrameZ = lTxy * lFZ; + int sizeFrameZ = lTxy * frameWidth; // frame Z upper - for(int32 i=0; i* Image::addFrame(int frameMax) } // frame Y upper - for(int32 j=0; j* Image::addFrame(int frameMax) Image* newImg = new Image(newData,lTx,lTy,lTz,getVoxSizeX(),getVoxSizeY(),getVoxSizeZ()); // set origin of real data in image - newImg->setOrigin(m_OX+lFX, m_OY+lFY, m_OZ+lFZ); + newImg->setOrigin(m_OX+frameWidth, m_OY+frameWidth, m_OZ+frameWidth); return newImg; + } @@ -394,14 +386,14 @@ template< typename DataType > template< typename Windowing > float Image::computeVolume(const Windowing& wind) const { - int32 nbv = getWidthXY()*getWidthZ(); + int nbv = getWidthXY()*getWidthZ(); const DataType *data = getData(); // volume in number of voxel - int32 vol=0; + int vol=0; - for(int32 i=0; i::computeCurvatureCount3(const DataType *ptrVox, const std: template< typename DataType > -Image* Image::cropz(unsigned int zmin, unsigned int nb) +void Image::addCross() { + int zm = m_WZ/2 - 10; + int ym = m_WY/2 - 10; + int xm = m_WX/2 - 10; - int zmax = zmin+nb; - if (zmax> m_WZ) + for (int z = zm; z < zm+20; z++) { - zmax = m_WZ; - nb = zmax - zmin; + for (int x = xm; x < xm+20; x++) + { + for (int y = 0 ; y < m_WY; y++) + { + m_Data[x + m_WX*y + m_WXY*z]=DataType(255); + } + } } - DataType* data2 = new DataType[150*m_WY*m_WZ]; - Image* newImg = new Image(data2,150,m_WY,nb,getVoxSizeX(),getVoxSizeY(),getVoxSizeZ()); - newImg->m_Alloc=true; - // set origin of real data in image ?? - - for(int z=zmin; z< zmax; ++z) + for (int z = zm; z < zm+20; z++) { - for(int y=0; ygetVoxelPtr(x,y,z-zmin); - *dest = *ori; + m_Data[x + m_WX*y + m_WXY*z]=DataType(255); } } } - return newImg; + for (int y = ym; y < ym+20; y++) + { + for (int x = xm; x < xm+20; x++) + { + for (int z = 0 ; z < m_WZ; z++) + { + m_Data[x + m_WX*y + m_WXY*z]=DataType(255); + } + } + } } + template void Image::createNormalSphere(std::vector& table, int _i32radius) { diff --git a/include/Algo/MC/marchingcube.h b/include/Algo/MC/marchingcube.h index 90ae77f5..73dc84a1 100644 --- a/include/Algo/MC/marchingcube.h +++ b/include/Algo/MC/marchingcube.h @@ -25,7 +25,6 @@ #ifndef MARCHINGCUBE_H #define MARCHINGCUBE_H -#include "Algo/MC/type.h" #include "Algo/MC/image.h" #include "Algo/MC/buffer.h" #include "Algo/MC/tables.h" @@ -89,7 +88,7 @@ protected: * The index is a eight bit index, one bit for each vertex of the cube.\n * If the vertex is inside the objet (val < isovalue) the bit is set to 1, else to 0 */ - uint8 computeIndex(const DataType* const _ucData) const; + unsigned char computeIndex(const DataType* const _ucData) const; /** * tag boundary to b removed or not @@ -122,14 +121,14 @@ protected: * @param _lZ coordinate Z of the cube * @param tag the boundary tag (NOT USE FOR THE MOMENT) */ - void createFaces_1(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_2(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_3(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_4(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_5(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_6(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_7(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_8(DataType *vox, const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); + void createFaces_1(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_2(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_3(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_4(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_5(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_6(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_7(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_8(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag); //@} /** @@ -146,7 +145,7 @@ protected: * * @todo use the member (of struct HalfCube) number of faces instead of fill with -1 */ - void createLocalFaces(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int const *_lVertTable, const unsigned short _ucMask, float curv, uint8 tag); + void createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int const *_lVertTable, const unsigned short _ucMask, float curv, unsigned char tag); /** * @name create vertices on edges of cube @@ -164,18 +163,18 @@ protected: * @param vPos the position in "real world" * */ - void createPointEdge0(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge1(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge2(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge3(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge4(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge5(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge6(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge7(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge8(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge9(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge10(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge11(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge0(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge1(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge2(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge3(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge4(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge5(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge6(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge7(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge8(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge9(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge10(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge11(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); //@} /** @@ -262,6 +261,7 @@ public: void removeFacesOfBoundary(AttributeHandler& boundVertices, unsigned int frameWidth); + void recalPoints(); }; diff --git a/include/Algo/MC/marchingcube.hpp b/include/Algo/MC/marchingcube.hpp index 1312109a..56efc7b8 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(); @@ -222,8 +222,8 @@ unsigned char MarchingCube::computeIndex(const DataTyp const DataType* ucDataLocal = _ucData; - int32 lTx = m_Image->getWidthX(); - int32 lTxy = m_Image->getWidthXY(); + int lTx = m_Image->getWidthX(); + int lTxy = m_Image->getWidthXY(); if ( m_windowFunc.inside(*ucDataLocal) ) @@ -257,13 +257,11 @@ template< typename DataType, template < typename D2 > class Windowing, typename typename PFP::VEC3 MarchingCube::recalPoint(const typename PFP::VEC3& _P, const typename PFP::VEC3& _dec ) const { typename PFP::VEC3 point = _P + _dec ; - - point -= m_fOrigin; - - point[0] = point[0] * m_fScal[0]; - point[1] = point[1] * m_fScal[1]; - point[2] = point[2] * m_fScal[2]; - +// point[0] = point[0] * m_fScal[0]; +// point[1] = point[1] * m_fScal[1]; +// point[2] = point[2] * m_fScal[2]; +// +// point += m_fOrigin; return point; } @@ -477,7 +475,7 @@ void MarchingCube::createPointEdge11(const unsigned ch template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_1(DataType *vox, const int _lX,const int _lY,const int _lZ, uint8 tag) +void MarchingCube::createFaces_1(DataType *vox, const int _lX,const int _lY,const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -540,7 +538,7 @@ void MarchingCube::createFaces_1(DataType *vox, const template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_2(DataType *vox, const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCube::createFaces_2(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -598,7 +596,7 @@ void MarchingCube::createFaces_2(DataType *vox, const template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_3(DataType *vox, const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCube::createFaces_3(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -654,7 +652,7 @@ void MarchingCube::createFaces_3(DataType *vox, const template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_4(DataType *vox, const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCube::createFaces_4(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -713,7 +711,7 @@ void MarchingCube::createFaces_4(DataType *vox, const template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_5(DataType *vox, const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCube::createFaces_5(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -770,7 +768,7 @@ void MarchingCube::createFaces_5(DataType *vox, const template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_6(DataType *vox, const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCube::createFaces_6(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -832,7 +830,7 @@ void MarchingCube::createFaces_6(DataType *vox, const template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_7(DataType *vox, const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCube::createFaces_7(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -894,7 +892,7 @@ void MarchingCube::createFaces_7(DataType *vox, const template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createFaces_8(DataType *vox, const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCube::createFaces_8(DataType *vox, const int _lX, const int _lY, const int _lZ, unsigned char tag) { unsigned char ucCubeIndex = computeIndex(vox); if ((ucCubeIndex == 0) || (ucCubeIndex == 255)) @@ -966,7 +964,7 @@ void MarchingCube::setNeighbour(L_DART d1, L_DART d2) } template< typename DataType, template < typename D2 > class Windowing, typename PFP > -void MarchingCube::createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int const *_lVertTable, const unsigned short _usMask, float curv, uint8 tag) +void MarchingCube::createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int const *_lVertTable, const unsigned short _usMask, float curv, unsigned char tag) { // TODO parametre _LZ not used => a supprimer ? // TODO parametre curv not used => a supprimer ? @@ -982,8 +980,8 @@ void MarchingCube::createLocalFaces(const unsigned cha L_DART *lFacesTab = m_Buffer->getFacesCubeTableAdr(_lX,_lY); // To speed access to data "precompute indirection" - const int8* cTriangle = accelMCTable::m_TriTable[_ucCubeIndex]; - const int8* cNeighbour = accelMCTable::m_NeighTable[_ucCubeIndex]; + const char* cTriangle = accelMCTable::m_TriTable[_ucCubeIndex]; + const char* cNeighbour = accelMCTable::m_NeighTable[_ucCubeIndex]; // L_DART dartTriangles[5]; @@ -1158,29 +1156,6 @@ void MarchingCube::createLocalFaces(const unsigned cha } -// CGoGNout << "NB TRIS: "<< lNumFaces <getLabel()<< " == "<< dd->getLabel()<< " == "<< ddd->getLabel()<< CGoGNendl; -// -// -// d =m_map->phi1(d); -// dd = L_MAP::phi2(d); -// ddd = L_MAP::phi2(dd); -// CGoGNout << d->getLabel()<< " == "<< dd->getLabel()<< " == "<< ddd->getLabel()<< CGoGNendl; -// -// d =m_map->phi1(d); -// dd = L_MAP::phi2(d); -// ddd = L_MAP::phi2(dd); -// CGoGNout << d->getLabel()<< " == "<< dd->getLabel()<< " == "<< ddd->getLabel()<< CGoGNendl; -// -// } - - - // finish buffer table of faces with -1 // PAS FORCEMENT UTILE A VERIFIER // for(int i=lNumFaces; i <5; i++) @@ -1206,7 +1181,6 @@ void MarchingCube::removeFacesOfBoundary(AttributeHand float zmax = m_Image->getWidthZ() - frameWidth; - // traverse position and create bound attrib for(unsigned int it = m_positions.begin(); it != m_positions.end(); m_positions.next(it)) { @@ -1266,6 +1240,20 @@ void MarchingCube::removeFacesOfBoundary(AttributeHand } +template< typename DataType, template < typename D2 > class Windowing, typename PFP > +void MarchingCube::recalPoints() +{ + + for(unsigned int i=m_positions.begin(); i != m_positions.end(); m_positions.next(i)) + { + typename PFP::VEC3& P = m_positions[i]; + P -= m_fOrigin; + P[0] = P[0] * m_fScal[0]; + P[1] = P[1] * m_fScal[1]; + P[2] = P[2] * m_fScal[2]; + + } +} diff --git a/include/Algo/MC/marchingcubeGen.h b/include/Algo/MC/marchingcubeGen.h index 3d5d51b1..fa0bb104 100644 --- a/include/Algo/MC/marchingcubeGen.h +++ b/include/Algo/MC/marchingcubeGen.h @@ -25,7 +25,6 @@ #ifndef MARCHINGCUBEGEN_H #define MARCHINGCUBEGEN_H -#include "Algo/MC/type.h" #include "Algo/MC/bufferGen.h" #include "Algo/MC/tables.h" @@ -96,7 +95,7 @@ protected: * The index is a eight bit index, one bit for each vertex of the cube.\n * If the vertex is inside the objet (val < isovalue) the bit is set to 1, else to 0 */ - uint8 computeIndex(int lX, int lY) const; + unsigned char computeIndex(int lX, int lY) const; /** * tag boundary to b removed or not @@ -129,14 +128,14 @@ protected: * @param _lZ coordinate Z of the cube * @param tag the boundary tag (NOT USE FOR THE MOMENT) */ - void createFaces_1(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_2(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_3(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_4(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_5(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_6(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_7(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); - void createFaces_8(const int32 _lX, const int32 _lY, const int32 _lZ, uint8 tag); + void createFaces_1(const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_2(const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_3(const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_4(const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_5(const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_6(const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_7(const int _lX, const int _lY, const int _lZ, unsigned char tag); + void createFaces_8(const int _lX, const int _lY, const int _lZ, unsigned char tag); //@} /** @@ -153,7 +152,7 @@ protected: * * @todo use the member (of struct HalfCube) number of faces instead of fill with -1 */ - void createLocalFaces(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int const *_lVertTable, const unsigned short _ucMask, float curv, uint8 tag); + void createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int const *_lVertTable, const unsigned short _ucMask, float curv, unsigned char tag); /** * @name create vertices on edges of cube @@ -172,18 +171,18 @@ protected: * @param vPos the position in "real world" * */ - void createPointEdge0(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge1(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge2(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge3(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge4(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge5(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge6(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge7(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge8(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge9(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge10(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); - void createPointEdge11(const uint8 _ucCubeIndex, const int32 _lX, const int32 _lY, const int32 _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge0(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge1(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge2(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge3(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge4(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge5(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge6(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge7(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge8(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge9(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge10(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); + void createPointEdge11(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int* const lVertTable, const typename PFP::VEC3& vPos); //@} /** diff --git a/include/Algo/MC/marchingcubeGen.hpp b/include/Algo/MC/marchingcubeGen.hpp index 313d4c95..1b19dec2 100644 --- a/include/Algo/MC/marchingcubeGen.hpp +++ b/include/Algo/MC/marchingcubeGen.hpp @@ -214,8 +214,8 @@ template< typename DataType, typename ImgT, template < typename D2 > class Wind unsigned char MarchingCubeGen::computeIndex(int lX, int lY) const { unsigned char ucCubeIndex = 0; - int32 bwidth = m_Buffer->getWidth(); - int32 dec = lX + lY*bwidth; + int bwidth = m_Buffer->getWidth(); + int dec = lX + lY*bwidth; DataType* dat = m_Buffer->getDataPtr() + dec; @@ -463,7 +463,7 @@ void MarchingCubeGen::createPointEdge11(const un template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_1(const int _lX,const int _lY,const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_1(const int _lX,const int _lY,const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData(_lX, _lY, m_Image->getVoxel(_lX, _lY,_lZ)); @@ -536,7 +536,7 @@ void MarchingCubeGen::createFaces_1(const int _l template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_2(const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_2(const int _lX, const int _lY, const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData(_lX+1, _lY, m_Image->getVoxel(_lX+1, _lY,_lZ)); @@ -600,7 +600,7 @@ void MarchingCubeGen::createFaces_2(const int _l template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_3(const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_3(const int _lX, const int _lY, const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData(_lX+1, _lY+1, m_Image->getVoxel(_lX+1, _lY+1,_lZ)); @@ -662,7 +662,7 @@ void MarchingCubeGen::createFaces_3(const int _l template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_4(const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_4(const int _lX, const int _lY, const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData(_lX+1, _lY+1, m_Image->getVoxel(_lX+1, _lY+1,_lZ)); @@ -725,7 +725,7 @@ void MarchingCubeGen::createFaces_4(const int _l template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_5(const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_5(const int _lX, const int _lY, const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData2(_lX, _lY, m_Image->getVoxel(_lX, _lY,_lZ+1)); @@ -788,7 +788,7 @@ void MarchingCubeGen::createFaces_5(const int _l template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_6(const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_6(const int _lX, const int _lY, const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData2(_lX+1, _lY, m_Image->getVoxel(_lX+1, _lY,_lZ+1)); @@ -852,7 +852,7 @@ void MarchingCubeGen::createFaces_6(const int _l template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_7(const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_7(const int _lX, const int _lY, const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData2(_lX+1, _lY+1, m_Image->getVoxel(_lX+1, _lY+1,_lZ+1)); @@ -916,7 +916,7 @@ void MarchingCubeGen::createFaces_7(const int _l template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createFaces_8(const int _lX, const int _lY, const int _lZ, uint8 tag) +void MarchingCubeGen::createFaces_8(const int _lX, const int _lY, const int _lZ, unsigned char tag) { // compute image value and store in buffer m_Buffer->setData2(_lX+1, _lY+1, m_Image->getVoxel(_lX+1, _lY+1,_lZ+1)); @@ -1001,7 +1001,7 @@ void MarchingCubeGen::setNeighbour(L_DART d1, L_ template< typename DataType, typename ImgT, template < typename D2 > class Windowing, class PFP > -void MarchingCubeGen::createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int const *_lVertTable, const unsigned short _usMask, float curv, uint8 tag) +void MarchingCubeGen::createLocalFaces(const unsigned char _ucCubeIndex, const int _lX, const int _lY, const int _lZ, unsigned int const *_lVertTable, const unsigned short _usMask, float curv, unsigned char tag) { // TODO parametre _LZ not used => a supprimer ? // TODO parametre curv not used => a supprimer ? diff --git a/include/Algo/MC/tables.h b/include/Algo/MC/tables.h index c0ff630b..2bde3995 100644 --- a/include/Algo/MC/tables.h +++ b/include/Algo/MC/tables.h @@ -69,7 +69,7 @@ static const short m_EdgeTable[256]; * Maximum number of triangles is 5 : 15 indices -> 16 values with the final -1 */ //static const char m_TriTable[256][16]; -static const int8 m_TriTable[256][16]; +static const char m_TriTable[256][16]; /** @@ -77,7 +77,7 @@ static const int8 m_TriTable[256][16]; * the cube configurations */ //static const char m_NeighTable[256][16]; -static const int8 m_NeighTable[256][16]; +static const char m_NeighTable[256][16]; }; diff --git a/include/Utils/chrono.h b/include/Utils/chrono.h index 43e49938..b175e531 100644 --- a/include/Utils/chrono.h +++ b/include/Utils/chrono.h @@ -63,7 +63,7 @@ public: }; #else /** - * class for each time mesuring + * class for each time measuring */ class Chrono { diff --git a/src/Algo/MC/tables.cpp b/src/Algo/MC/tables.cpp index 41dbeebe..adaf6d11 100644 --- a/src/Algo/MC/tables.cpp +++ b/src/Algo/MC/tables.cpp @@ -76,7 +76,7 @@ const short accelMCTable::m_EdgeTable[256]= //const char accelMCTable::m_TriTable[256][16] = -const int8 accelMCTable::m_TriTable[256][16] = +const char accelMCTable::m_TriTable[256][16] = { { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, { 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, @@ -595,7 +595,7 @@ const int8 accelMCTable::m_TriTable[256][16] = //const char accelMCTable::m_NeighTable[256][16] = -const int8 accelMCTable::m_NeighTable[256][16] = +const char accelMCTable::m_NeighTable[256][16] = { { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }, -- GitLab