Cleaning messages and parameters

This commit is contained in:
Paolo Cignoni cignoni 2016-10-25 22:07:46 +00:00
parent d18c0c0aee
commit cb2d0752df
2 changed files with 67 additions and 62 deletions

View File

@ -149,7 +149,7 @@ public:
Real SamplesPerNodeVal;
Real ScaleVal;
bool ConfidenceFlag;
bool NormalWeightsFlag;
bool CleanFlag;
bool DensityFlag;
Real PointWeightVal;
int AdaptiveExponentVal;
@ -177,7 +177,7 @@ public:
SamplesPerNodeVal =1.5f;
ScaleVal=1.1f;
ConfidenceFlag=false;
NormalWeightsFlag=false;
CleanFlag=false;
DensityFlag=false;
PointWeightVal = 4.0f;
AdaptiveExponentVal=1;
@ -504,9 +504,9 @@ int _Execute(OrientedPointStream< Real > *pointStream, Box3m bb, CMeshO &pm, Poi
Point3D<Real> pp = iXForm*pt->point;
vcg::tri::Allocator<CMeshO>::AddVertex(pm,Point3m(pp[0],pp[1],pp[2]));
pm.vert.back().Q() = pt->value;
pm.vert.back().C()[0] = pt->color[0]*255.0;
pm.vert.back().C()[1] = pt->color[1]*255.0;
pm.vert.back().C()[2] = pt->color[2]*255.0;
pm.vert.back().C()[0] = pt->color[0];
pm.vert.back().C()[1] = pt->color[1];
pm.vert.back().C()[2] = pt->color[2];
}
for (int ii=0; ii < mesh.outOfCorePointCount(); ii++){
Vertex pt;
@ -514,9 +514,9 @@ int _Execute(OrientedPointStream< Real > *pointStream, Box3m bb, CMeshO &pm, Poi
Point3D<Real> pp = iXForm*pt.point;
vcg::tri::Allocator<CMeshO>::AddVertex(pm,Point3m(pp[0],pp[1],pp[2]));
pm.vert.back().Q() = pt.value;
pm.vert.back().C()[0] = pt.color[0]*1.0;
pm.vert.back().C()[1] = pt.color[1]*1.0;
pm.vert.back().C()[2] = pt.color[2]*1.0;
pm.vert.back().C()[0] = pt.color[0];
pm.vert.back().C()[1] = pt.color[1];
pm.vert.back().C()[2] = pt.color[2];
}
std::vector< CoredVertexIndex > polygon;
@ -545,16 +545,17 @@ int _Execute(OrientedPointStream< Real > *pointStream, Box3m bb, CMeshO &pm, Poi
template <class MeshType>
void PoissonClean(MeshType &m, bool scaleNormal)
void PoissonClean(MeshType &m, bool scaleNormal, bool cleanFlag)
{
if(m.face.size()>0)
vcg::tri::Clean<MeshType>::RemoveUnreferencedVertex(m);
if(cleanFlag) {
if(m.face.size()>0)
vcg::tri::Clean<MeshType>::RemoveUnreferencedVertex(m);
}
vcg::tri::Allocator<MeshType>::CompactEveryVector(m);
vcg::tri::UpdateNormal<MeshType>::NormalizePerVertex(m);
if(scaleNormal)
{
for(typename MeshType::VertexIterator vi=m.vert.begin();vi!=m.vert.end();++vi)
for(auto vi=m.vert.begin();vi!=m.vert.end();++vi)
vi->N() *= vi->Q();
}
}
@ -562,7 +563,7 @@ void PoissonClean(MeshType &m, bool scaleNormal)
bool HasGoodNormal(CMeshO &m)
{
for(auto vi=m.vert.begin();vi!=m.vert.end();++vi)
if(vcg::SquaredNorm(vi->N()) < std::numeric_limits<float>::min())
if(vcg::SquaredNorm(vi->N()) < std::numeric_limits<float>::min()*10.0)
return false;
return true;
@ -572,36 +573,7 @@ bool FilterScreenedPoissonPlugin::applyFilter( const QString& filterName,MeshDoc
{
if (filterName == "Screened Poisson Surface Reconstruction")
{
MeshModel *mm =md.mm();
PoissonParam<Scalarm> pp;
bool goodNormal=true, goodColor=true;
if(env.evalBool("visibleLayer") == false) {
goodNormal=HasGoodNormal(md.mm()->cm);
goodColor = md.mm()->hasDataMask(MeshModel::MM_VERTCOLOR);
} else{
MeshModel *_mm=0;
while(_mm=md.nextVisibleMesh(_mm)) {
goodNormal &= HasGoodNormal(_mm->cm);
goodColor &= _mm->hasDataMask(MeshModel::MM_VERTCOLOR);
}
}
if(!goodNormal)
{
this->errorMessage = "Filter requires correct per vertex normals\n that your point could has a proper, not-null, normal for each sample";
return false;
}
MeshModel *pm =md.addNewMesh("","Poisson mesh",false);
md.setVisible(pm->id(),false);
pm->updateDataMask(MeshModel::MM_VERTQUALITY);
if(goodColor) pm->updateDataMask(MeshModel::MM_VERTCOLOR);
MeshModelPointStream<Scalarm> meshStream(mm->cm);
MeshDocumentPointStream<Scalarm> documentStream(md);
pp.MaxDepthVal = env.evalInt("depth");
pp.FullDepthVal = env.evalInt("fullDepth");
pp.CGDepthVal= env.evalInt("cgDepth");
@ -610,20 +582,55 @@ bool FilterScreenedPoissonPlugin::applyFilter( const QString& filterName,MeshDoc
pp.PointWeightVal = env.evalFloat("pointWeight");
pp.ItersVal = env.evalInt("iters");
pp.ConfidenceFlag = env.evalBool("confidence");
pp.NormalWeightsFlag = env.evalBool("nWeights");
pp.DensityFlag = true;
pp.CleanFlag = env.evalBool("preClean");
bool goodNormal=true, goodColor=true;
if(env.evalBool("visibleLayer") == false)
{
PoissonClean(md.mm()->cm, pp.ConfidenceFlag, pp.CleanFlag);
goodNormal=HasGoodNormal(md.mm()->cm);
goodColor = md.mm()->hasDataMask(MeshModel::MM_VERTCOLOR);
}
else
{
MeshModel *_mm=0;
while(_mm=md.nextVisibleMesh(_mm)) {
PoissonClean(_mm->cm, pp.ConfidenceFlag, pp.CleanFlag);
goodNormal &= HasGoodNormal(_mm->cm);
goodColor &= _mm->hasDataMask(MeshModel::MM_VERTCOLOR);
}
}
if(!goodNormal)
{
this->errorMessage = "Filter requires correct per vertex normals.<br>"
"E.g. it is necessary that your <b>ALL</b> the input vertices have a proper, not-null normal.<br> "
"If you enconuter this error on a triangulated mesh try to use the <i>Remove Unreferenced Vertices</i> "
"filter (usually unreferenced vertices on surfaces have null normals).<br>"
"Enabling the Cleaning option also works.";
return false;
}
MeshModel *pm =md.addNewMesh("","Poisson mesh",false);
md.setVisible(pm->id(),false);
pm->updateDataMask(MeshModel::MM_VERTQUALITY);
if(goodColor) pm->updateDataMask(MeshModel::MM_VERTCOLOR);
if(env.evalBool("visibleLayer"))
{
MeshModel *m=0;
while((m=md.nextVisibleMesh(m)))
PoissonClean(m->cm, (pp.ConfidenceFlag || pp.NormalWeightsFlag));
Box3m bb = md.bbox();
Box3m bb;
MeshModel *_mm=0;
while(_mm=md.nextVisibleMesh(_mm))
bb.Add(_mm->cm.Tr,_mm->cm.bbox);
MeshDocumentPointStream<Scalarm> documentStream(md);
_Execute<Scalarm,2,BOUNDARY_NEUMANN,PlyColorAndValueVertex<Scalarm> >(&documentStream,bb,pm->cm,pp,cb);
}
else
{
PoissonClean(mm->cm, (pp.ConfidenceFlag || pp.NormalWeightsFlag));
_Execute<Scalarm,2,BOUNDARY_NEUMANN,PlyColorAndValueVertex<Scalarm> >(&meshStream,mm->cm.bbox,pm->cm,pp,cb);
MeshModelPointStream<Scalarm> meshStream(md.mm()->cm);
_Execute<Scalarm,2,BOUNDARY_NEUMANN,PlyColorAndValueVertex<Scalarm> >(&meshStream,md.mm()->cm.bbox,pm->cm,pp,cb);
}
pm->UpdateBoxAndNormals();
md.setVisible(pm->id(),true);

View File

@ -2,8 +2,7 @@
<PLUGIN pluginName="FilterScreenedPoissonPlugin" pluginAuthor="Paolo Cignoni" pluginEmail="paolo.cignoni@isti.cnr.it">
<FILTER filterFunction="screenedPoissonSurfaceReconstruction" filterName="Screened Poisson Surface Reconstruction" filterPre="MM_NONE" filterRasterArity="SingleRaster" filterClass="Remeshing" filterPost="MM_VERTNUMBER | MM_FACENUMBER" filterArity="Variable" filterIsInterruptible="true">
<FILTER_HELP><![CDATA[This surface reconstruction algorithm
creates watertight surfaces from oriented point sets. In this work we extend the technique to explicitly
incorporate the points as interpolation constraints.
creates watertight surfaces from oriented point sets.
<br> The filter uses the original code of Michael Kazhdan and Matthew Bolitho implementing the algorithm described in the following paper:<br>
<i>Michael Kazhdan, Hugues Hoppe</i>,<br>
<b>"Screened Poisson surface reconstruction"</b><br>
@ -34,18 +33,18 @@ ACM Trans. Graphics, 32(3), 2013<br>
The default value for this parameter is 0.]]></PARAM_HELP>
<EDIT_GUI guiLabel="Conjugate Gradients Depth"/>
</PARAM>
<PARAM parName="scale" parIsImportant="true" parType="Real" parDefault="1.1">
<PARAM parName="scale" parIsImportant="false" parType="Real" parDefault="1.1">
<PARAM_HELP><![CDATA[This floating point value specifies the ratio between the diameter of the cube used for
reconstruction and the diameter of the samples' bounding cube.
The default value is 1.1.]]></PARAM_HELP>
<EDIT_GUI guiLabel="Scale Factor" />
</PARAM>
<PARAM parName="samplesPerNode" parType="Real" parIsImportant="true" parDefault="1">
<PARAM parName="samplesPerNode" parType="Real" parIsImportant="true" parDefault="1.5">
<PARAM_HELP><![CDATA[This floating point value specifies the minimum number of sample points that should fall
within an octree node as the octree construction is adapted to sampling density. For noise-free samples, small values
in the range [1.0 - 5.0] can be used. For more noisy samples, larger values in the range [15.0 - 20.0] may be needed
to provide a smoother, noise-reduced, reconstruction.
The default value is 1.0.]]></PARAM_HELP>
The default value is 1.5.]]></PARAM_HELP>
<EDIT_GUI guiLabel="Minimum Number of Samples"/>
</PARAM>
<PARAM parName="pointWeight" parType="Real" parIsImportant="true" parDefault="4">
@ -55,22 +54,21 @@ ACM Trans. Graphics, 32(3), 2013<br>
The default value for this parameter is 4.]]></PARAM_HELP>
<EDIT_GUI guiLabel="Interpolation Weight"/>
</PARAM>
<PARAM parName="iters" parType="Int" parIsImportant="true" parDefault="8">
<PARAM parName="iters" parType="Int" parIsImportant="false" parDefault="8">
<PARAM_HELP><![CDATA[This integer value specifies the number of Gauss-Seidel relaxations to be performed at each
level of the hiearchy.
The default value for this parameter is 8.]]></PARAM_HELP>
<EDIT_GUI guiLabel="Gauss-Seidel Relaxations"/>
</PARAM>
<PARAM parName="confidence" parIsImportant="true" parType="Boolean" parDefault="false">
<PARAM_HELP><![CDATA[Enabling this flag tells the reconstructor to use the size of the normals as confidence
information. When the flag is not enabled, all normals are normalized to have unit-length prior
<PARAM_HELP><![CDATA[Enabling this flag tells the reconstructor to use the quality as confidence
information; this is done by scaling the unit normals with the quality values. When the flag is not enabled, all normals are normalized to have unit-length prior
to reconstruction.]]></PARAM_HELP>
<CHECKBOX_GUI guiLabel="Confidence Flag"/>
</PARAM>
<PARAM parName="nWeights" parIsImportant="true" parType="Boolean" parDefault="false">
<PARAM_HELP><![CDATA[Enabling this flag tells the reconstructor to use the size of the normals to modulate the
interpolation weights. When the flag is not enabled, all points are given the same weight.]]></PARAM_HELP>
<CHECKBOX_GUI guiLabel="Weight Flag"/>
<PARAM parName="preClean" parIsImportant="true" parType="Boolean" parDefault="false">
<PARAM_HELP><![CDATA[Enabling this flag force a cleaning pre-pass on the data removing all unreferenced vertices or vertices with null normals.]]></PARAM_HELP>
<CHECKBOX_GUI guiLabel="Pre-Clean"/>
</PARAM>
</FILTER>
</PLUGIN>