//FONCTION "CELLULAIRE" D'AFFICHAGE "POINT MOYEN" bool ccOctree::DrawCellAsAPoint(const CCLib::DgmOctree::octreeCell& cell, void** additionalParameters, CCLib::NormalizedProgress* nProgress/*=0*/) { //variables additionnelles glDrawParams* glParams = reinterpret_cast<glDrawParams*>(additionalParameters[0]); ccGenericPointCloud* theAssociatedCloud = reinterpret_cast<ccGenericPointCloud*>(additionalParameters[1]); if (glParams->showSF) { ScalarType dist = CCLib::ScalarFieldTools::computeMeanScalarValue(cell.points); const colorType* col = theAssociatedCloud->geScalarValueColor(dist); glColor3ubv(col ? col : ccColor::lightGrey.rgba); } else if (glParams->showColors) { colorType col[3]; ComputeAverageColor(cell.points,theAssociatedCloud,col); glColor3ubv(col); } if (glParams->showNorms) { CCVector3 N = ComputeAverageNorm(cell.points,theAssociatedCloud); ccGL::Normal3v(N.u); } const CCVector3* gravityCenter = CCLib::Neighbourhood(cell.points).getGravityCenter(); ccGL::Vertex3v(gravityCenter->u); return true; }
//FONCTION "CELLULAIRE" D'AFFICHAGE "POINT MOYEN" bool ccOctree::DrawCellAsAPoint(const CCLib::DgmOctree::octreeCell& cell, void** additionalParameters) { //variables additionnelles glDrawParams* glParams = (glDrawParams*)additionalParameters[0]; ccGenericPointCloud* theAssociatedCloud = (ccGenericPointCloud*)additionalParameters[1]; if (glParams->showSF) { DistanceType dist = CCLib::DistanceComputationTools::computeMeanDist(cell.points); const colorType* col = theAssociatedCloud->getDistanceColor(dist); glColor3ubv(col ? col : ccColor::lightGrey); } else { if (glParams->showColors) { colorType col[3]; ComputeAverageColor(cell.points,theAssociatedCloud,col); glColor3ubv(col); // on peut mettre directement le pointeur ? } if (glParams->showNorms) { GLfloat N[3]; ComputeAverageNorm(cell.points,theAssociatedCloud,N); glNormal3fv(N); } } const CCVector3* gravityCenter = CCLib::Neighbourhood(cell.points).getGravityCenter(); glVertex3fv(gravityCenter->u); return true; }
//FONCTION "CELLULAIRE" D'AFFICHAGE "CUBE MOYEN" bool ccOctree::DrawCellAsAPrimitive(const CCLib::DgmOctree::octreeCell& cell, void** additionalParameters, CCLib::NormalizedProgress* nProgress/*=0*/) { //variables additionnelles glDrawParams* glParams = reinterpret_cast<glDrawParams*>(additionalParameters[0]); ccGenericPointCloud* theAssociatedCloud = reinterpret_cast<ccGenericPointCloud*>(additionalParameters[1]); ccGenericPrimitive* primitive = reinterpret_cast<ccGenericPrimitive*>(additionalParameters[2]); CC_DRAW_CONTEXT* context = reinterpret_cast<CC_DRAW_CONTEXT*>(additionalParameters[3]); PointCoordinateType cellCenter[3]; cell.parentOctree->computeCellCenter(cell.truncatedCode,cell.level,cellCenter,true); if (glParams->showSF) { ScalarType dist = CCLib::ScalarFieldTools::computeMeanScalarValue(cell.points); ccColor::Rgba rgb(theAssociatedCloud->geScalarValueColor(dist)); primitive->setColor(rgb); } else if (glParams->showColors) { ccColor::Rgb col; ComputeAverageColor(cell.points,theAssociatedCloud,col.rgb); primitive->setColor(col); } if (glParams->showNorms) { CCVector3 N = ComputeAverageNorm(cell.points,theAssociatedCloud); if (primitive->getTriNormsTable()) { //only one normal! primitive->getTriNormsTable()->setValue(0,ccNormalVectors::GetNormIndex(N.u)); } } glPushMatrix(); ccGL::Translate(cellCenter[0],cellCenter[1],cellCenter[2]); primitive->draw(*context); glPopMatrix(); return true; }
//FONCTION "CELLULAIRE" D'AFFICHAGE "CUBE MOYEN" bool ccOctree::DrawCellAsAPlainCube(const CCLib::DgmOctree::octreeCell& cell, void** additionalParameters) { //variables additionnelles glDrawParams* glParams = (glDrawParams*)additionalParameters[0]; ccGenericPointCloud* theAssociatedCloud = (ccGenericPointCloud*)additionalParameters[1]; //GLfloat* cubeVertexesCoords = (GLfloat*)additionalParameters[2]; GLubyte* cubeVertexesIndexes = (GLubyte*)additionalParameters[3]; //GLfloat* gravityCenter = (GLfloat*)cell.points->getGeometricalElement(GRAVITY_CENTER); GLfloat cellCenter[3]; cell.parentOctree->computeCellCenter(cell.truncatedCode,cell.level,cellCenter,true); if (glParams->showSF) { DistanceType dist = CCLib::DistanceComputationTools::computeMeanDist(cell.points); const colorType* col = theAssociatedCloud->getDistanceColor(dist); glColor3ubv(col ? col : ccColor::lightGrey); } else { if (glParams->showColors) { colorType col[3]; ComputeAverageColor(cell.points,theAssociatedCloud,col); glColor3ubv(col); // on peut mettre directement le pointeur ? } if (glParams->showNorms) { GLfloat N[3]; ComputeAverageNorm(cell.points,theAssociatedCloud,N); glNormal3fv(N); } } glPushMatrix(); glTranslatef(cellCenter[0],cellCenter[1],cellCenter[2]); glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE, cubeVertexesIndexes); glPopMatrix(); return true; }
//FONCTION "CELLULAIRE" D'AFFICHAGE "CUBE MOYEN" bool ccOctree::DrawCellAsAPrimitive(const CCLib::DgmOctree::octreeCell& cell, void** additionalParameters) { //variables additionnelles glDrawParams* glParams = (glDrawParams*)additionalParameters[0]; ccGenericPointCloud* theAssociatedCloud = (ccGenericPointCloud*)additionalParameters[1]; ccGenericPrimitive* primitive = (ccGenericPrimitive*)additionalParameters[2]; CC_DRAW_CONTEXT* context = (CC_DRAW_CONTEXT*)additionalParameters[3]; GLfloat cellCenter[3]; cell.parentOctree->computeCellCenter(cell.truncatedCode,cell.level,cellCenter,true); if (glParams->showSF) { ScalarType dist = CCLib::ScalarFieldTools::computeMeanScalarValue(cell.points); const colorType* col = theAssociatedCloud->geScalarValueColor(dist); primitive->setColor(col); } else if (glParams->showColors) { colorType col[3]; ComputeAverageColor(cell.points,theAssociatedCloud,col); primitive->setColor(col); } if (glParams->showNorms) { GLfloat N[3]; ComputeAverageNorm(cell.points,theAssociatedCloud,N); if (primitive->getTriNormsTable()) primitive->getTriNormsTable()->setValue(0,ccNormalVectors::GetNormIndex(N)); } glPushMatrix(); glTranslatef(cellCenter[0],cellCenter[1],cellCenter[2]); primitive->draw(*context); glPopMatrix(); return true; }