diff --git a/src/meshlabplugins/filter_mls/balltree.cpp b/src/meshlabplugins/filter_mls/balltree.cpp index 7ebf79677..bf17167bc 100644 --- a/src/meshlabplugins/filter_mls/balltree.cpp +++ b/src/meshlabplugins/filter_mls/balltree.cpp @@ -123,7 +123,7 @@ void BallTree<_Scalar>::buildNode(Node& node, std::vector& indices, AxisAli } unsigned int dim = vcg::MaxCoeffId(diag); node.dim = dim; - node.splitValue = 0.5*(aabb.max[dim] + aabb.min[dim]); + node.splitValue = Scalar(0.5*(aabb.max[dim] + aabb.min[dim])); node.leaf = 0; AxisAlignedBoxType aabbLeft=aabb, aabbRight=aabb; diff --git a/src/meshlabplugins/filter_mls/kdtree.cpp b/src/meshlabplugins/filter_mls/kdtree.cpp index 94ec3ee42..c8371e707 100644 --- a/src/meshlabplugins/filter_mls/kdtree.cpp +++ b/src/meshlabplugins/filter_mls/kdtree.cpp @@ -165,7 +165,7 @@ void KdTree::createTree(unsigned int nodeId, unsigned int start, unsigne VectorType diag = aabb.max - aabb.min; unsigned int dim = vcg::MaxCoeffId(diag); node.dim = dim; - node.splitValue = 0.5*(aabb.max[dim] + aabb.min[dim]); + node.splitValue = Scalar(0.5*(aabb.max[dim] + aabb.min[dim])); unsigned int midId = split(start, end, dim, node.splitValue); diff --git a/src/meshlabplugins/filter_mls/mlsmarchingcube.h b/src/meshlabplugins/filter_mls/mlsmarchingcube.h index 2f97b2037..fac57e898 100644 --- a/src/meshlabplugins/filter_mls/mlsmarchingcube.h +++ b/src/meshlabplugins/filter_mls/mlsmarchingcube.h @@ -88,8 +88,8 @@ public: mAABB = mpSurface->boundingBox(); VectorType diag = mAABB.max - mAABB.min; - mAABB.min -= diag * 0.1; - mAABB.max += diag * 0.1; + mAABB.min -= diag * 0.1f; + mAABB.max += diag * 0.1f; diag = mAABB.max - mAABB.min; if ( (diag[0]<=0.) @@ -221,7 +221,7 @@ public: id1 = GetLocalCellIdFromGlobal(p1); id2 = GetLocalCellIdFromGlobal(p2); // interpol along the edge - ScalarType epsilon = 1e-5; + ScalarType epsilon = ScalarType(1e-5); const GridElement& c1 = mCache[id1]; const GridElement& c2 = mCache[id2]; if (fabs(mIsoValue-c1.value) < epsilon) diff --git a/src/meshlabplugins/filter_mls/mlsplugin.cpp b/src/meshlabplugins/filter_mls/mlsplugin.cpp index cf2adba40..6a75a40fb 100644 --- a/src/meshlabplugins/filter_mls/mlsplugin.cpp +++ b/src/meshlabplugins/filter_mls/mlsplugin.cpp @@ -23,8 +23,6 @@ #include -#define NDEBUG - #include #include #include @@ -101,6 +99,7 @@ const QString MlsPlugin::filterName(FilterIDType filterId) case FP_SELECT_SMALL_COMPONENTS : return QString("Small component selection"); default : assert(0); } +return QString("Filter Unknown"); } const MeshFilterInterface::FilterClass MlsPlugin::getClass(QAction *a) @@ -120,6 +119,7 @@ const MeshFilterInterface::FilterClass MlsPlugin::getClass(QAction *a) case FP_SELECT_SMALL_COMPONENTS : return MeshFilterInterface::Selection; } assert(0); + return MeshFilterInterface::Generic; } // Info() must return the longer string describing each filtering action @@ -187,7 +187,7 @@ void MlsPlugin::initParameterSet(QAction* action, MeshDocument& md, FilterParame if (id == FP_SELECT_SMALL_COMPONENTS) { parlst.addFloat("NbFaceRatio", - 0.1, + 0.1f, "Small component ratio", "This ratio (between 0 and 1) defines the meaning of small as the threshold ratio between the number of faces" "of the largest component and the other ones. A larger value will select more components."); @@ -229,7 +229,7 @@ void MlsPlugin::initParameterSet(QAction* action, MeshDocument& md, FilterParame "Scale of the spatial low pass filter.\n" "It is relative to the radius (local point spacing) of the vertices."); parlst.addFloat("ProjectionAccuracy", - 1e-4, + 1e-4f, "Projection - Accuracy (adv)", "Threshold value used to stop the projections.\n" "This value is scaled by the mean point spacing to get the actual threshold."); @@ -384,6 +384,14 @@ bool MlsPlugin::applyFilter(QAction* filter, MeshDocument& md, FilterParameterSe // we are doing some MLS based stuff { + if(md.mm()->cm.fn > 0) + { // if we start from a mesh, and it has unreferenced vertices + // normals are undefined on that vertices. + int delvert=tri::Clean::RemoveUnreferencedVertex(md.mm()->cm); + if(delvert) Log(GLLogStream::Info, "Pre-MLS Cleaning: Removed %d unreferenced vertices",delvert); + } + tri::Allocator::CompactVertexVector(md.mm()->cm); + // We require a per vertex radius so as a first thing check it if(!md.mm()->hasDataMask(MeshModel::MM_VERTRADIUS)) { @@ -415,7 +423,7 @@ bool MlsPlugin::applyFilter(QAction* filter, MeshDocument& md, FilterParameterSe // create the MLS surface cb(1, "Create the MLS data structures..."); MlsSurface* mls = 0; - + RIMLS* rimls = 0; APSS* apss = 0; @@ -495,11 +503,12 @@ bool MlsPlugin::applyFilter(QAction* filter, MeshDocument& md, FilterParameterSe //bool approx = apss && par.getBool("ApproxCurvature"); int ct = par.getEnum("CurvatureType"); - int size = mesh->cm.vert.size(); + uint size = mesh->cm.vert.size(); //std::vector curvatures(size); float minc=1e9, maxc=-1e9, minabsc=1e9; vcg::Point3f grad; vcg::Matrix33f hess; + // pass 1: computes curvatures and statistics for (unsigned int i = 0; i< size; i++) { @@ -584,7 +593,7 @@ bool MlsPlugin::applyFilter(QAction* filter, MeshDocument& md, FilterParameterSe { mesh->updateDataMask(MeshModel::MM_FACEFACETOPO | MeshModel::MM_FACEFLAGBORDER); // selection... - vcg::tri::SmallComponent::Select(mesh->cm, 0.1); + vcg::tri::SmallComponent::Select(mesh->cm, 0.1f); // deletion... vcg::tri::SmallComponent::DeleteFaceVert(mesh->cm); mesh->clearDataMask(MeshModel::MM_FACEFACETOPO | MeshModel::MM_FACEFLAGBORDER); diff --git a/src/meshlabplugins/filter_mls/mlssurface.h b/src/meshlabplugins/filter_mls/mlssurface.h index 5bfdfe428..e210da9d1 100644 --- a/src/meshlabplugins/filter_mls/mlssurface.h +++ b/src/meshlabplugins/filter_mls/mlssurface.h @@ -67,7 +67,7 @@ class MlsSurface mFilterScale = 4.0; mMaxNofProjectionIterations = 20; - mProjectionAccuracy = 1e-4; + mProjectionAccuracy = (Scalar)1e-4; mBallTree = 0; mGradientHint = MLS_DERIVATIVE_ACCURATE; mHessianHint = MLS_DERIVATIVE_ACCURATE; @@ -143,7 +143,7 @@ class MlsSurface } const vcg::Box3& boundingBox() const { return mAABB; } - static const Scalar InvalidValue() { return 12345679810.11121314151617; } + static const Scalar InvalidValue() { return Scalar(12345679810.11121314151617); } void computeVertexRaddi(const int nbNeighbors = 16); protected: diff --git a/src/meshlabplugins/filter_mls/mlsutils.h b/src/meshlabplugins/filter_mls/mlsutils.h index 3e4e88053..b3a1cd62c 100644 --- a/src/meshlabplugins/filter_mls/mlsutils.h +++ b/src/meshlabplugins/filter_mls/mlsutils.h @@ -39,11 +39,11 @@ public: { return *reinterpret_cast(mpData + i*mStride); } - inline int size() const { return mSize; } + inline size_t size() const { return mSize; } protected: const unsigned char* mpData; int mStride; - int mSize; + size_t mSize; }; namespace vcg { diff --git a/src/meshlabplugins/filter_mls/rimls.h b/src/meshlabplugins/filter_mls/rimls.h index dbc40f0f8..5cf31ead7 100644 --- a/src/meshlabplugins/filter_mls/rimls.h +++ b/src/meshlabplugins/filter_mls/rimls.h @@ -57,8 +57,8 @@ class RIMLS : public MlsSurface<_MeshType> : Base(points) { mSigmaR = 0; - mSigmaN = 0.8; - mRefittingThreshold = 1e-3; + mSigmaN = Scalar(0.8); + mRefittingThreshold = Scalar(1e-3); mMinRefittingIters = 1; mMaxRefittingIters = 3; } diff --git a/src/meshlabplugins/filter_mls/smallcomponentselection.h b/src/meshlabplugins/filter_mls/smallcomponentselection.h index 4610f078d..697524116 100644 --- a/src/meshlabplugins/filter_mls/smallcomponentselection.h +++ b/src/meshlabplugins/filter_mls/smallcomponentselection.h @@ -47,7 +47,7 @@ public: // the different components as a list of face pointer std::vector< std::vector > components; - for(int faceSeed = 0; faceSeed " << components[i].size() << "\n"; total_selected += components[i].size(); maxComponent = std::max(maxComponent,components[i].size()); } int remaining = m.face.size() - total_selected; - int th = std::max(maxComponent,remaining) * nbFaceRatio; + uint th = std::max(maxComponent,remaining) * nbFaceRatio; int selCount = 0; - for (int i=0; iSetS(); } }