fix for voronoi remesher, again

This commit is contained in:
Luigi Malomo 2017-07-17 20:39:04 +02:00
parent 30dcc87c1a
commit 75eca5e231
3 changed files with 674 additions and 709 deletions

View File

@ -59,17 +59,26 @@ int main( int argc, char **argv )
if(argc < 2 )
{
printf("Usage trimesh_voro mesh region_num\n");
return -1;
}
printf("Reading %s \n",argv[1]);
int ret= tri::io::Importer<MyMesh>::Open(startMesh,argv[1]);
if(ret!=0)
{
printf("Unable to open %s for '%s'\n",argv[1],tri::io::ImporterPLY<MyMesh>::ErrorMsg(ret));
return -1;
}
float samplingRadius = startMesh.bbox.Diag() *0.02f;
auto remeshed = Remesher<MyMesh>::Remesh(startMesh, samplingRadius, 50.0);
printf("Reading %s \n",argv[1]);
int ret = tri::io::Importer<MyMesh>::Open(startMesh,argv[1]);
if(ret!=0)
{
printf("Unable to open %s: '%s'\n",argv[1],tri::io::ImporterPLY<MyMesh>::ErrorMsg(ret));
return -1;
}
tri::UpdateBounding<MyMesh>::Box(startMesh);
float samplingRadius = startMesh.bbox.Diag() * 0.01f;
if (argc == 3)
{
try {
samplingRadius = stof(string(argv[2]));
} catch (exception &) {}
}
std::cout << "using sampling radius: " << samplingRadius << std::endl;
auto remeshed = Remesher<MyMesh>::Remesh(startMesh, samplingRadius, 75.0);
tri::io::ExporterPLY<MyMesh>::Save(*remeshed,"Full.ply",tri::io::Mask::IOM_VERTCOLOR|tri::io::Mask::IOM_WEDGTEXCOORD );

View File

@ -1260,7 +1260,7 @@ static int RestrictedVoronoiRelaxing(MeshType &m, std::vector<CoordType> &seedPo
if(sumVec[i].first != 0)
{
newseedVec.push_back(sumVec[i].second /ScalarType(sumVec[i].first));
if(vpp.seedPerturbationProbability > RandomGenerator().generate01())
if(vpp.seedPerturbationProbability > 0 && (vpp.seedPerturbationProbability > RandomGenerator().generate01()))
newseedVec.back()+=math::GeneratePointInUnitBallUniform<ScalarType,math::MarsenneTwisterRNG>( RandomGenerator())*perturb;
newfixedVec.push_back(false);
}

File diff suppressed because it is too large Load Diff