- added a "only on selection" option to VertexUniform and AllVertex sampling functions
- added a "isD" check to VertexUniform sampling function to be tested
This commit is contained in:
parent
e814e3a9f5
commit
6715e4f658
|
@ -505,14 +505,18 @@ static int Poisson(double lambda)
|
||||||
|
|
||||||
static void AllVertex(MeshType & m, VertexSampler &ps)
|
static void AllVertex(MeshType & m, VertexSampler &ps)
|
||||||
{
|
{
|
||||||
VertexIterator vi;
|
AllVertex(m, ps, false);
|
||||||
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
}
|
||||||
{
|
|
||||||
if(!(*vi).IsD())
|
static void AllVertex(MeshType & m, VertexSampler &ps, bool onlySelected)
|
||||||
{
|
{
|
||||||
ps.AddVert(*vi);
|
VertexIterator vi;
|
||||||
}
|
for(vi=m.vert.begin();vi!=m.vert.end();++vi)
|
||||||
}
|
if(!(*vi).IsD())
|
||||||
|
if ((!onlySelected) || ((*vi).IsS()))
|
||||||
|
{
|
||||||
|
ps.AddVert(*vi);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sample the vertices in a weighted way. Each vertex has a probability of being chosen
|
/// Sample the vertices in a weighted way. Each vertex has a probability of being chosen
|
||||||
|
@ -603,18 +607,31 @@ static void FillAndShuffleVertexPointerVector(MeshType & m, std::vector<VertexPo
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sample the vertices in a uniform way. Each vertex has the same probabiltiy of being chosen.
|
/// Sample the vertices in a uniform way. Each vertex has the same probabiltiy of being chosen.
|
||||||
|
static void VertexUniform(MeshType & m, VertexSampler &ps, int sampleNum, bool onlySelected)
|
||||||
|
{
|
||||||
|
if (sampleNum >= m.vn) {
|
||||||
|
AllVertex(m, ps, onlySelected);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<VertexPointer> vertVec;
|
||||||
|
FillAndShuffleVertexPointerVector(m, vertVec);
|
||||||
|
|
||||||
|
int added = 0;
|
||||||
|
for (int i = 0; ((i < m.vn) && (added < sampleNum)); ++i)
|
||||||
|
if (!(*vertVec[i]).IsD())
|
||||||
|
if ((!onlySelected) || (*vertVec[i]).IsS())
|
||||||
|
{
|
||||||
|
ps.AddVert(*vertVec[i]);
|
||||||
|
added++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void VertexUniform(MeshType & m, VertexSampler &ps, int sampleNum)
|
static void VertexUniform(MeshType & m, VertexSampler &ps, int sampleNum)
|
||||||
{
|
{
|
||||||
if(sampleNum>=m.vn) {
|
VertexUniform(m, ps, sampleNum, false);
|
||||||
AllVertex(m,ps);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<VertexPointer> vertVec;
|
|
||||||
FillAndShuffleVertexPointerVector(m,vertVec);
|
|
||||||
|
|
||||||
for(int i =0; i< sampleNum; ++i)
|
|
||||||
ps.AddVert(*vertVec[i]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue