From 4447fab921a5a193b189f4e174edf09cbc941409 Mon Sep 17 00:00:00 2001 From: cignoni Date: Mon, 14 Mar 2011 09:34:22 +0000 Subject: [PATCH] Added FaceRandomConnectedComponent to colorize faces according connected components --- vcg/complex/trimesh/update/color.h | 59 ++++++++++-------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/vcg/complex/trimesh/update/color.h b/vcg/complex/trimesh/update/color.h index a8040a31..62f779f7 100644 --- a/vcg/complex/trimesh/update/color.h +++ b/vcg/complex/trimesh/update/color.h @@ -20,46 +20,7 @@ * for more details. * * * ****************************************************************************/ -/**************************************************************************** - History -$Log: not supported by cvs2svn $ -Revision 1.11 2007/05/04 16:34:31 ganovelli -changes to comply "plus" types - -Revision 1.10 2006/05/21 07:00:01 cignoni -Removed not working Equalized color (use funcs in stat.h) - -Revision 1.9 2006/03/01 10:29:55 ponchio -HACK: MaxVal(0.0f) not defined in vcg/math/base.h as it should be, -changing it to 1e36 (pretty close :P) - -Revision 1.8 2005/12/19 16:47:42 cignoni -Better comment and a parameter more for UpdateColor::VertexBorderFlag - -Revision 1.7 2005/08/08 10:28:13 ganovelli -added math:: namespace before min and max - -Revision 1.6 2004/08/25 15:15:26 ganovelli -minor changes to comply gcc compiler (typename's and stuff) - -Revision 1.5 2004/07/15 00:13:39 cignoni -Better doxigen documentation - -Revision 1.4 2004/06/24 07:56:54 cignoni -now use std::numeric_limits instead of old max val() - -Revision 1.3 2004/03/12 15:22:19 cignoni -Written some documentation and added to the trimes doxygen module - -Revision 1.2 2004/03/10 00:48:06 cignoni -changed to the face::IsBorder() style - -Revision 1.1 2004/03/05 10:59:24 cignoni -Changed name from plural to singular (normals->normal) - - -****************************************************************************/ #ifndef __VCG_TRI_UPDATE_COLOR #define __VCG_TRI_UPDATE_COLOR #include @@ -69,7 +30,7 @@ Changed name from plural to singular (normals->normal) #include #include #include - +#include namespace vcg { namespace tri { @@ -185,6 +146,24 @@ static void VertexBorderFlag( UpdateMeshType &m, Color4b BorderColor=Color4b::Bl } + +/// This function colores the face of a mesh randomly. +/// The faux bit is used to color polygonal faces uniformly +static void FaceRandomConnectedComponent( UpdateMeshType &m) +{ + std::vector< std::pair > CCV; + int ScatterSize= min (100,tri::Clean::ConnectedComponents(m, CCV)); // number of random color to be used. Never use too many. + + ConnectedIterator ci; + for(unsigned int i=0;i FPV; + for(ci.start(m,CCV[i].second);!ci.completed();++ci) + (*ci)->C()=BaseColor; + } +} + /// This function colores the face of a mesh randomly. /// The faux bit is used to color polygonal faces uniformly static void MultiFaceRandom( UpdateMeshType &m)