sofa::component::topology::MultiResSparseGridTopology::SparseGrid Class Reference

Make all resolution of sparse grid create with a .vox file. More...

#include <MultiResSparseGridTopology.h>

Collaboration diagram for sofa::component::topology::MultiResSparseGridTopology::SparseGrid:

Collaboration graph
[legend]

Data Structures

struct  Index3D
 To represent voxels centers. More...
struct  Vertex
 to represent vertices of voxels More...
struct  Voxel
 to represent the 8 vertices of one voxel More...

Public Member Functions

 SparseGrid (void)
 SparseGrid (int)
 SparseGrid (float)
 ~SparseGrid (void)
void initFromPNG (char *fileName, int color, int filesNo)
 Init filesNo of pgm images, and the by calling the suitable functions, constructs the grid of voxels.
void initFromVOX (char *fileName, int color)
 Init vox file, and the by calling the suitable functions, constructs the grid of voxels.
unsigned getNumSparseGrid () const
 returns the num of the voxels
unsigned getNumVertices () const
 returns the number of vertices of the grid
unsigned getNumFaceIndices () const
 returns the size of the indices array for all the voxels
unsigned getNumSurfaceIndices () const
 returns the size of the indices array for faces of the surface
vector< Vector3 > & getVertices ()
 returns the array of vertices
const vector< Vector3 > & getVertices () const
vector< int > & getFaceIndices ()
 returns the array of indices for all the voxels
std::map< Index3D, Voxel > & getSparseGridMap ()
 return the voxelMap of the voxels
const std::map< Index3D, Voxel > & getSparseGridMap () const
std::map< Index3D, Voxel >
::iterator 
getVoxelsMapBegin ()
 return the begin and the end of the map
std::map< Index3D, Voxel >
::iterator 
getVoxelsMapEnd ()
std::map< Index3D, Vertex > & getVertexMap ()
 return the vertexMap of the voxels
const std::map< Index3D, Vertex > & getVertexMap () const
std::map< Index3D, Vertex >
::iterator 
getVertexMapBegin ()
 return the begin and the end of the map
std::map< Index3D, Vertex >
::iterator const 
getVertexMapEnd ()
float * getSparseGridDensity ()
 returns the array of density
vector< int > & getSurfaceIndices ()
 returns the array of indices for faces of the surface
int pasResolution (SparseGrid vg)
 make the child grid
float getDimVoxX ()
 get voxel size
float getDimVoxY ()
float getDimVoxZ ()
int getDimX () const
 get grid's size
int getDimY () const
int getDimZ () const
float getDensity (int i, int j, int k)
 get the density of a voxel
void afficherVertices ()
 print the arry of vertices
void afficherSparseGridMap ()
 print the voxel of the sparse grid map
void afficherVertexMap ()
 print the vertex of the vertew map
void afficherIndices ()
 print the arry of indices

Protected Types

typedef std::map< Index3D, Vertex > VertexMap
typedef std::map< Index3D, Voxel > VoxelMap

Protected Member Functions

int readFilePNG (char *fileName, int color, int filesNo)
 Reads filesNo of pgm images, and the by calling the suitable functions, constructs the grid of voxels.
int readFileVOX (char *fileName, int color)
 read .voxel file
int setPixels (const char *FileName, int color, float plane)
 gets the pixels of the given color from each image.
void setVertexMap ()
 gets the vertices of each voxels and puts them in the map of vertices
void setIndicesMap ()
 gets the indices necessary to view the grid of voxels, and making the map of voxels
void setSurfaceSparseGrid ()
 gets the surface voxels, and the indices for faces of the surface
void insertVoxel (int i, int j, int k, float d)
 insert a voxel in the sparse grid map wtih his density
void buildFromSparseGridMap (int allPixels)
 build the rest of the information
void setDensity ()
 gets the vertices of each voxels and puts them in the map of vertices
void setDimX (int x)
 set sparge grid size
void setDimY (int y)
void setDimZ (int z)
void setDimVoxX (float x)
 set voxel size
void setDimVoxY (float y)
void setDimVoxZ (float z)

Protected Attributes

int FIN_DE_LISTE
 End of list for surface voxel.
float scale
 Grid's scale.
vector< Vector3 > vertices
 array of vertices
vector< Index3D > surfaceSparseGrid
 contains centers of the voxels of the surface
int numIndices
 number and array of the 6 faces corresponding to each voxels
vector< int > indices
int numSurfaceIndices
 number and array of the visible faces
vector< int > surfaceIndices
float * voxelsDensity
 array of density
float dimVoxX
 size of the voxels
float dimVoxY
float dimVoxZ
int dimX
 size of the grid
int dimY
int dimZ
VertexMap vertexMap
 contains all vertices without repeating
VoxelMap voxelsMap
 contains all the voxels, each represented by its centers and its 8 vertices

Detailed Description

Make all resolution of sparse grid create with a .vox file.

512 // Image's size x 512 // Image's size y 246 // Image's size z 0.7 // Voxels's size x 0.7 // Voxels's size y 2 // Voxels's size z 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0 0 0 0 ........................

This is a sparse voxel grid:

-vertexMap contains all vertices without repeating. It consists of Index3D(int i,j,k), vertex(SbVector3f,int)

-voxelsMap contains all voxels with the indices of each one. It consists of Index3D which represent the voxel center, and of int[8] which leads to the 8 vertices of that voxel in vertices array or in the map

-surfaceSparseGrid is a vector of Index3D, contains centers of the voxels of the surface

Definition at line 80 of file MultiResSparseGridTopology.h.


Member Typedef Documentation

Definition at line 150 of file MultiResSparseGridTopology.h.

Definition at line 151 of file MultiResSparseGridTopology.h.


Constructor & Destructor Documentation

sofa::component::topology::MultiResSparseGridTopology::SparseGrid::SparseGrid ( void   ) 

Definition at line 305 of file MultiResSparseGridTopology.cpp.

References FIN_DE_LISTE, and scale.

sofa::component::topology::MultiResSparseGridTopology::SparseGrid::SparseGrid ( int  x  ) 

Definition at line 311 of file MultiResSparseGridTopology.cpp.

References FIN_DE_LISTE, and scale.

sofa::component::topology::MultiResSparseGridTopology::SparseGrid::SparseGrid ( float  scale_  ) 

Definition at line 317 of file MultiResSparseGridTopology.cpp.

References FIN_DE_LISTE, and scale.

sofa::component::topology::MultiResSparseGridTopology::SparseGrid::~SparseGrid ( void   ) 

Definition at line 323 of file MultiResSparseGridTopology.cpp.


Member Function Documentation

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::afficherIndices (  ) 

print the arry of indices

Definition at line 399 of file MultiResSparseGridTopology.cpp.

References indices, and numIndices.

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::afficherSparseGridMap (  ) 

print the voxel of the sparse grid map

Definition at line 327 of file MultiResSparseGridTopology.cpp.

References voxelsMap.

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::afficherVertexMap (  ) 

print the vertex of the vertew map

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::afficherVertices (  ) 

print the arry of vertices

Definition at line 383 of file MultiResSparseGridTopology.cpp.

References vertexMap, and vertices.

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::buildFromSparseGridMap ( int  allPixels  )  [protected]

build the rest of the information

defining number of indices: (4indices for each face + 1 to indicate the end)*number of faces

finding the indices for each voxel

finding voxels and faces of the surface

Definition at line 730 of file MultiResSparseGridTopology.cpp.

References indices, numIndices, setDensity(), setIndicesMap(), setSurfaceSparseGrid(), and setVertexMap().

Referenced by initFromPNG(), initFromVOX(), and pasResolution().

float sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getDensity ( int  i,
int  j,
int  k 
)

get the density of a voxel

Definition at line 836 of file MultiResSparseGridTopology.cpp.

References voxelsMap.

float sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getDimVoxX (  )  [inline]

float sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getDimVoxY (  )  [inline]

float sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getDimVoxZ (  )  [inline]

int sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getDimX (  )  const [inline]

get grid's size

Definition at line 264 of file MultiResSparseGridTopology.h.

References dimX.

Referenced by pasResolution().

int sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getDimY (  )  const [inline]

Definition at line 268 of file MultiResSparseGridTopology.h.

References dimY.

Referenced by pasResolution().

int sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getDimZ (  )  const [inline]

Definition at line 272 of file MultiResSparseGridTopology.h.

References dimZ.

Referenced by pasResolution().

vector<int>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getFaceIndices (  )  [inline]

returns the array of indices for all the voxels

Definition at line 197 of file MultiResSparseGridTopology.h.

References indices.

unsigned sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getNumFaceIndices (  )  const [inline]

returns the size of the indices array for all the voxels

Definition at line 178 of file MultiResSparseGridTopology.h.

References numIndices.

unsigned sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getNumSparseGrid (  )  const [inline]

returns the num of the voxels

Definition at line 168 of file MultiResSparseGridTopology.h.

References voxelsMap.

unsigned sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getNumSurfaceIndices (  )  const [inline]

returns the size of the indices array for faces of the surface

Definition at line 183 of file MultiResSparseGridTopology.h.

References numSurfaceIndices.

unsigned sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getNumVertices (  )  const [inline]

returns the number of vertices of the grid

Definition at line 173 of file MultiResSparseGridTopology.h.

References vertexMap.

float* sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getSparseGridDensity (  )  [inline]

returns the array of density

Definition at line 239 of file MultiResSparseGridTopology.h.

References voxelsDensity.

const std::map<Index3D,Voxel>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getSparseGridMap (  )  const [inline]

Definition at line 206 of file MultiResSparseGridTopology.h.

References voxelsMap.

std::map<Index3D,Voxel>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getSparseGridMap (  )  [inline]

return the voxelMap of the voxels

Definition at line 202 of file MultiResSparseGridTopology.h.

References voxelsMap.

vector<int>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getSurfaceIndices (  )  [inline]

returns the array of indices for faces of the surface

Definition at line 244 of file MultiResSparseGridTopology.h.

References surfaceIndices.

const std::map<Index3D,Vertex>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVertexMap (  )  const [inline]

Definition at line 224 of file MultiResSparseGridTopology.h.

References vertexMap.

std::map<Index3D,Vertex>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVertexMap (  )  [inline]

return the vertexMap of the voxels

Definition at line 220 of file MultiResSparseGridTopology.h.

References vertexMap.

std::map<Index3D,Vertex>::iterator sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVertexMapBegin (  )  [inline]

return the begin and the end of the map

Definition at line 229 of file MultiResSparseGridTopology.h.

References vertexMap.

std::map<Index3D,Vertex>::iterator const sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVertexMapEnd (  )  [inline]

Definition at line 233 of file MultiResSparseGridTopology.h.

References vertexMap.

const vector<Vector3>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVertices (  )  const [inline]

Definition at line 192 of file MultiResSparseGridTopology.h.

References vertices.

vector< Vector3>& sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVertices (  )  [inline]

returns the array of vertices

Definition at line 188 of file MultiResSparseGridTopology.h.

References vertices.

std::map<Index3D,Voxel>::iterator sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVoxelsMapBegin (  )  [inline]

std::map<Index3D,Voxel>::iterator sofa::component::topology::MultiResSparseGridTopology::SparseGrid::getVoxelsMapEnd (  )  [inline]

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::initFromPNG ( char *  fileName,
int  color,
int  filesNo 
)

Init filesNo of pgm images, and the by calling the suitable functions, constructs the grid of voxels.

Definition at line 764 of file MultiResSparseGridTopology.cpp.

References buildFromSparseGridMap(), readFilePNG(), setDimVoxX(), setDimVoxY(), and setDimVoxZ().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::initFromVOX ( char *  fileName,
int  color 
)

Init vox file, and the by calling the suitable functions, constructs the grid of voxels.

Definition at line 828 of file MultiResSparseGridTopology.cpp.

References buildFromSparseGridMap(), and readFileVOX().

Referenced by sofa::component::topology::MultiResSparseGridTopology::MultiResSparseGridTopology().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::insertVoxel ( int  i,
int  j,
int  k,
float  d 
) [protected]

insert a voxel in the sparse grid map wtih his density

Definition at line 536 of file MultiResSparseGridTopology.cpp.

References voxelsMap.

Referenced by pasResolution(), readFileVOX(), and setPixels().

int sofa::component::topology::MultiResSparseGridTopology::SparseGrid::pasResolution ( SparseGrid  vg  ) 

int sofa::component::topology::MultiResSparseGridTopology::SparseGrid::readFilePNG ( char *  fileName,
int  color,
int  filesNo 
) [protected]

Reads filesNo of pgm images, and the by calling the suitable functions, constructs the grid of voxels.

pixels = new Index3D[512*512*filesNo];

making the file name

getting pixels of the given color from the file

Definition at line 744 of file MultiResSparseGridTopology.cpp.

References setDimZ(), and setPixels().

Referenced by initFromPNG().

int sofa::component::topology::MultiResSparseGridTopology::SparseGrid::readFileVOX ( char *  fileName,
int  color 
) [protected]

read .voxel file

Definition at line 778 of file MultiResSparseGridTopology.cpp.

References insertVoxel(), scale, setDimVoxX(), setDimVoxY(), setDimVoxZ(), setDimX(), setDimY(), and setDimZ().

Referenced by initFromVOX().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setDensity (  )  [protected]

gets the vertices of each voxels and puts them in the map of vertices

to find the voxels of the surface, we check if the voxel has neighbours or not

Definition at line 714 of file MultiResSparseGridTopology.cpp.

References voxelsDensity, and voxelsMap.

Referenced by buildFromSparseGridMap().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setDimVoxX ( float  x  )  [inline, protected]

set voxel size

Definition at line 321 of file MultiResSparseGridTopology.h.

References dimVoxX.

Referenced by initFromPNG(), pasResolution(), and readFileVOX().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setDimVoxY ( float  y  )  [inline, protected]

Definition at line 325 of file MultiResSparseGridTopology.h.

References dimVoxY.

Referenced by initFromPNG(), pasResolution(), and readFileVOX().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setDimVoxZ ( float  z  )  [inline, protected]

Definition at line 329 of file MultiResSparseGridTopology.h.

References dimVoxZ.

Referenced by initFromPNG(), pasResolution(), and readFileVOX().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setDimX ( int  x  )  [inline, protected]

set sparge grid size

Definition at line 308 of file MultiResSparseGridTopology.h.

References dimX.

Referenced by pasResolution(), readFileVOX(), and setPixels().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setDimY ( int  y  )  [inline, protected]

Definition at line 312 of file MultiResSparseGridTopology.h.

References dimY.

Referenced by pasResolution(), readFileVOX(), and setPixels().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setDimZ ( int  z  )  [inline, protected]

Definition at line 316 of file MultiResSparseGridTopology.h.

References dimZ.

Referenced by pasResolution(), readFilePNG(), and readFileVOX().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setIndicesMap (  )  [protected]

gets the indices necessary to view the grid of voxels, and making the map of voxels

for each pixel, we have to define the indices for the six corresponding faces

to find the voxels of the surface, we check if the voxel has neighbours or not

finding the order for each of the 8th vertices

Add to the map of voxels the vertices corresponding to a voxel

Definition at line 450 of file MultiResSparseGridTopology.cpp.

References FIN_DE_LISTE, indices, vertexMap, and voxelsMap.

Referenced by buildFromSparseGridMap().

int sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setPixels ( const char *  FileName,
int  color,
float  plane 
) [protected]

gets the pixels of the given color from each image.

Definition at line 543 of file MultiResSparseGridTopology.cpp.

References insertVoxel(), setDimX(), and setDimY().

Referenced by readFilePNG().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setSurfaceSparseGrid (  )  [protected]

gets the surface voxels, and the indices for faces of the surface

to find the voxels of the surface, we check if the voxel has neighbours or not

Definition at line 628 of file MultiResSparseGridTopology.cpp.

References FIN_DE_LISTE, numSurfaceIndices, surfaceIndices, surfaceSparseGrid, and voxelsMap.

Referenced by buildFromSparseGridMap().

void sofa::component::topology::MultiResSparseGridTopology::SparseGrid::setVertexMap (  )  [protected]

gets the vertices of each voxels and puts them in the map of vertices

to find the voxels of the surface, we check if the voxel has neighbours or not

Numerating the vertices, and making the vertices array

Definition at line 588 of file MultiResSparseGridTopology.cpp.

References sofa::component::topology::MultiResSparseGridTopology::dx, sofa::component::topology::MultiResSparseGridTopology::dy, sofa::component::topology::MultiResSparseGridTopology::dz, getDimVoxX(), getDimVoxY(), getDimVoxZ(), vertexMap, vertices, and voxelsMap.

Referenced by buildFromSparseGridMap().


Field Documentation

size of the voxels

Definition at line 146 of file MultiResSparseGridTopology.h.

Referenced by getDimVoxX(), and setDimVoxX().

Definition at line 146 of file MultiResSparseGridTopology.h.

Referenced by getDimVoxY(), and setDimVoxY().

Definition at line 146 of file MultiResSparseGridTopology.h.

Referenced by getDimVoxZ(), and setDimVoxZ().

size of the grid

Definition at line 148 of file MultiResSparseGridTopology.h.

Referenced by getDimX(), and setDimX().

Definition at line 148 of file MultiResSparseGridTopology.h.

Referenced by getDimY(), and setDimY().

Definition at line 148 of file MultiResSparseGridTopology.h.

Referenced by getDimZ(), and setDimZ().

End of list for surface voxel.

Definition at line 130 of file MultiResSparseGridTopology.h.

Referenced by setIndicesMap(), setSurfaceSparseGrid(), and SparseGrid().

number and array of the 6 faces corresponding to each voxels

Definition at line 138 of file MultiResSparseGridTopology.h.

Referenced by afficherIndices(), buildFromSparseGridMap(), and getNumFaceIndices().

number and array of the visible faces

Definition at line 141 of file MultiResSparseGridTopology.h.

Referenced by getNumSurfaceIndices(), and setSurfaceSparseGrid().

Grid's scale.

Definition at line 132 of file MultiResSparseGridTopology.h.

Referenced by readFileVOX(), and SparseGrid().

Definition at line 142 of file MultiResSparseGridTopology.h.

Referenced by getSurfaceIndices(), and setSurfaceSparseGrid().

contains centers of the voxels of the surface

Definition at line 136 of file MultiResSparseGridTopology.h.

Referenced by setSurfaceSparseGrid().

contains all vertices without repeating

Definition at line 153 of file MultiResSparseGridTopology.h.

Referenced by afficherVertices(), getNumVertices(), getVertexMap(), getVertexMapBegin(), getVertexMapEnd(), setIndicesMap(), and setVertexMap().

array of vertices

Definition at line 134 of file MultiResSparseGridTopology.h.

Referenced by afficherVertices(), getVertices(), and setVertexMap().

array of density

Definition at line 144 of file MultiResSparseGridTopology.h.

Referenced by getSparseGridDensity(), and setDensity().


The documentation for this class was generated from the following files:

Generated on Sun Nov 23 04:21:30 2008 for Sofa by  doxygen 1.5.7.1