diff --git a/src/common/meshlabdocumentxml.cpp b/src/common/meshlabdocumentxml.cpp index 39bae445d..397cfbf6e 100644 --- a/src/common/meshlabdocumentxml.cpp +++ b/src/common/meshlabdocumentxml.cpp @@ -272,7 +272,7 @@ QDomDocument MeshDocumentToXML(MeshDocument &md, bool onlyVisibleLayers, bool sa QDomElement rgroot = ddoc.createElement("RasterGroup"); - foreach(RasterModel *rmp, md.rasterList) + for(RasterModel *rmp: md.rasterIterator()) { QDomElement rasterElem = RasterModelToXML(rmp, ddoc, binary); rgroot.appendChild(rasterElem); diff --git a/src/meshlab/glarea.cpp b/src/meshlab/glarea.cpp index fea7800da..27c258a20 100644 --- a/src/meshlab/glarea.cpp +++ b/src/meshlab/glarea.cpp @@ -1812,7 +1812,7 @@ void GLArea::updateRasterSetVisibilities() while (i.hasNext()) { i.next(); bool found =false; - foreach(RasterModel * rp, this->md()->rasterList) + for(RasterModel * rp: md()->rasterIterator()) { if(rp->id() == i.key()) { @@ -1824,7 +1824,7 @@ void GLArea::updateRasterSetVisibilities() rasterVisibilityMap.remove(i.key()); } - foreach(RasterModel * rp, this->md()->rasterList) + for(RasterModel * rp: md()->rasterIterator()) { //Insert the new pair in the map;If the key is already in the map, its value will be overwritten rasterVisibilityMap.insert(rp->id(),rp->visible); @@ -1879,7 +1879,7 @@ void GLArea::showRaster(bool resetViewFlag) void GLArea::loadRaster(int id) { lastloadedraster = id; - foreach(RasterModel *rm, this->md()->rasterList) + for(RasterModel *rm: md()->rasterIterator()) if(rm->id()==id) { this->md()->setCurrentRaster(id); diff --git a/src/meshlab/layerDialog.cpp b/src/meshlab/layerDialog.cpp index 1eb5155bf..252b61038 100644 --- a/src/meshlab/layerDialog.cpp +++ b/src/meshlab/layerDialog.cpp @@ -457,7 +457,7 @@ void LayerDialog::rasterItemClicked (QTreeWidgetItem * item , int col) // if(QApplication::keyboardModifiers() == Qt::ControlModifier) { - foreach(RasterModel *rp, md->rasterList) + for(RasterModel *rp: md->rasterIterator()) { rp->visible = false; } @@ -476,7 +476,7 @@ void LayerDialog::rasterItemClicked (QTreeWidgetItem * item , int col) // clicking on all of them... if(QApplication::keyboardModifiers() == Qt::AltModifier) { - foreach(RasterModel *rp, md->rasterList) + for(RasterModel *rp: md->rasterIterator()) { rp->visible = true; } @@ -484,7 +484,7 @@ void LayerDialog::rasterItemClicked (QTreeWidgetItem * item , int col) if(QApplication::keyboardModifiers() == Qt::ShiftModifier) { - foreach(RasterModel *rp, md->rasterList) + for(RasterModel *rp: md->rasterIterator()) { rp->visible = !rp->visible; } @@ -712,7 +712,7 @@ void LayerDialog::updateTable(const MLSceneGLSharedDataContext::PerMeshRendering //} //tabsrelatedtodeletedmeshes.clear(); - if (md->rasterList.size() > 0) + if (md->rasterNumber() > 0) ui->rasterTreeWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); else ui->rasterTreeWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Ignored); @@ -723,7 +723,7 @@ void LayerDialog::updateTable(const MLSceneGLSharedDataContext::PerMeshRendering //TODO The fourth column is fake... solo per ora, E' per evitare che l'ultimacolonna si allunghi indefinitivamente //mettere una lunghezza fissa e' inutile perche' non so quanto e' lungo il nome. ui->rasterTreeWidget->header()->hide(); - foreach(RasterModel* rmd, md->rasterList) + for(RasterModel* rmd: md->rasterIterator()) { //Restore raster visibility according to the current visibility map //very good to keep viewer state consistent diff --git a/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp b/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp index fd1e4dce9..755649d6e 100644 --- a/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp +++ b/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp @@ -188,7 +188,7 @@ void VarianceShadowMappingBlur::runShader(MeshDocument& md, GLArea* gla){ glPushAttrib(GL_COLOR_BUFFER_BIT); glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE); // to avoid the fact that when saving a snapshot we get semitransparent shadowed areas. - foreach(MeshModel *m, md.meshList) + for(MeshModel *m: md.meshIterator()) { if ((m != NULL) && (m->visible)) { diff --git a/src/meshlabplugins/edit_align/edit_align.cpp b/src/meshlabplugins/edit_align/edit_align.cpp index 2884b0bf7..57afe108f 100644 --- a/src/meshlabplugins/edit_align/edit_align.cpp +++ b/src/meshlabplugins/edit_align/edit_align.cpp @@ -114,23 +114,23 @@ void EditAlignPlugin::suggestedRenderingData(MeshModel & /*m*/, MLRenderingData& bool EditAlignPlugin::startEdit(MeshDocument& md, GLArea * gla, MLSceneGLSharedDataContext* cont) { - _md=&md; - _gla= gla; + _md=&md; + _gla= gla; _shared = cont; - if ((_gla == NULL) || (_shared == NULL) || (md.meshList.size() < 1)) + if ((_gla == NULL) || (_shared == NULL) || (md.meshNumber() < 1)) return false; //mainW->addDockWidget(Qt::LeftDockWidgetArea,alignDialog); mode = ALIGN_IDLE; - int numOfMeshes = _md->meshList.size(); - meshTree.clear(); - foreach(MeshModel *mm, _md->meshList) - { + int numOfMeshes = _md->meshNumber(); + meshTree.clear(); + for(MeshModel *mm: _md->meshIterator()) + { - // assigns random color: if less than 50 meshes, color is truly unique, and the less meshes, the more different they will be - // if above 50, truly unique color would generate too similar colors, so total number of unique color - // is capped to 50 and the color reused, id that are close will have different color anyway + // assigns random color: if less than 50 meshes, color is truly unique, and the less meshes, the more different they will be + // if above 50, truly unique color would generate too similar colors, so total number of unique color + // is capped to 50 and the color reused, id that are close will have different color anyway if (mm != NULL) { if (numOfMeshes < 50) @@ -139,12 +139,12 @@ bool EditAlignPlugin::startEdit(MeshDocument& md, GLArea * gla, MLSceneGLSharedD mm->cm.C() = Color4b::Scatter(51, mm->id() % 50, .2f, .7f); mm->updateDataMask(MeshModel::MM_COLOR); // meshTree.nodeList.push_back(new MeshNode(mm)); - meshTree.nodeMap[mm->id()]=new MeshNode(mm); + meshTree.nodeMap[mm->id()]=new MeshNode(mm); } - } + } -//for(QMap::iterator it = _gla->rendermodemap.begin();it != _gla->rendermodemap.end();++it) -// it.value().colorMode=GLW::CMPerMesh; +// for(QMap::iterator it = _gla->rendermodemap.begin();it != _gla->rendermodemap.end();++it) +// it.value().colorMode=GLW::CMPerMesh; _gla->setCursor(QCursor(QPixmap(":/images/cur_align.png"),1,1)); if(alignDialog==0) diff --git a/src/meshlabplugins/edit_referencing/edit_referencing.cpp b/src/meshlabplugins/edit_referencing/edit_referencing.cpp index e5dd22429..dca6b7aae 100644 --- a/src/meshlabplugins/edit_referencing/edit_referencing.cpp +++ b/src/meshlabplugins/edit_referencing/edit_referencing.cpp @@ -343,9 +343,9 @@ bool EditReferencingPlugin::startEdit(MeshModel & m, GLArea * gla, MLSceneGLShar status_error = ""; // reading current transformations for all layers - layersOriginalTransf.resize(glArea->md()->meshList.size()); + layersOriginalTransf.resize(glArea->md()->meshNumber()); int lind = 0; - foreach(MeshModel *mmp, glArea->md()->meshList) + for(MeshModel *mmp: glArea->md()->meshIterator()) { layersOriginalTransf[lind].Import(mmp->cm.Tr); lind++; @@ -808,30 +808,30 @@ void EditReferencingPlugin::calculateMatrix() void EditReferencingPlugin::applyMatrix() { - status_error = ""; + status_error = ""; - Matrix44m newMat; + Matrix44m newMat; - newMat.Import(transfMatrix); + newMat.Import(transfMatrix); - if(referencingDialog->ui->cbApplyToAll->checkState() == Qt::Checked) - { + if(referencingDialog->ui->cbApplyToAll->checkState() == Qt::Checked) + { int lind = 0; - foreach(MeshModel *mmp, glArea->md()->meshList) - { - if(mmp->visible) - { + for(MeshModel *mmp: glArea->md()->meshIterator()) + { + if(mmp->visible) + { mmp->cm.Tr = newMat * layersOriginalTransf[lind]; - } + } lind++; - } - } - else - { + } + } + else + { glArea->mm()->cm.Tr = newMat * originalTransf; - } + } - glArea->update(); + glArea->update(); } void EditReferencingPlugin::updateDistances() @@ -997,7 +997,7 @@ void EditReferencingPlugin::applyScale() if (referencingDialog->ui->cbApplyToAll->checkState() == Qt::Checked) { int lind = 0; - foreach(MeshModel *mmp, glArea->md()->meshList) + for(MeshModel *mmp: glArea->md()->meshIterator()) { if (mmp->visible) { diff --git a/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp b/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp index 9530ecf0a..08be43af0 100644 --- a/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp +++ b/src/meshlabplugins/filter_colorproc/filter_colorproc.cpp @@ -454,13 +454,13 @@ std::map FilterColorProc::applyFilter(const QAction *filt if (all_levels) { - foreach(MeshModel *mm, md.meshList) + for(MeshModel *mm: md.meshIterator()) if (mm->isVisible()) - vcg::tri::UpdateColor::PerVertexLevels(mm->cm, gamma, in_min, in_max, out_min, out_max, rgbMask, selected); + vcg::tri::UpdateColor::PerVertexLevels(mm->cm, gamma, in_min, in_max, out_min, out_max, rgbMask, selected); } else { - vcg::tri::UpdateColor::PerVertexLevels(m->cm, gamma, in_min, in_max, out_min, out_max, rgbMask, selected); + vcg::tri::UpdateColor::PerVertexLevels(m->cm, gamma, in_min, in_max, out_min, out_max, rgbMask, selected); } break; } @@ -520,9 +520,9 @@ std::map FilterColorProc::applyFilter(const QAction *filt if(seed==0) seed = time(NULL); math::MarsenneTwisterRNG myrnd(seed); - int numOfMeshes = md.meshList.size(); + int numOfMeshes = md.meshNumber(); int id = myrnd.generate(numOfMeshes); - foreach(MeshModel *mm, md.meshList) + for(MeshModel *mm: md.meshIterator()) { if (mm->isVisible()) mm->cm.C()=Color4b::Scatter(numOfMeshes,id); @@ -866,7 +866,7 @@ std::map FilterColorProc::applyFilter(const QAction *filt case CP_MESH_TO_FACE: { - foreach(MeshModel *mmi, md.meshList) + for(MeshModel *mmi: md.meshIterator()) { if (mmi->visible) { diff --git a/src/meshlabplugins/filter_fractal/filter_fractal.cpp b/src/meshlabplugins/filter_fractal/filter_fractal.cpp index 5f84573f4..2934354d5 100644 --- a/src/meshlabplugins/filter_fractal/filter_fractal.cpp +++ b/src/meshlabplugins/filter_fractal/filter_fractal.cpp @@ -220,9 +220,9 @@ void FilterFractal::initParameterSetForCratersGeneration(const MeshDocument &md, // tries to detect the target mesh const MeshModel* target = md.mm(); const MeshModel* samples = md.mm(); - MeshModel* tmpMesh; + const MeshModel* tmpMesh; if (samples->cm.fn != 0){ // this is probably not the samples layer - for(MeshModel* mm : md.meshList) + for(const MeshModel* mm : md.meshIterator()) { tmpMesh = mm; if (tmpMesh->cm.fn == 0) @@ -304,7 +304,7 @@ std::map FilterFractal::applyFilter( break; case FP_CRATERS: { - if (md.meshList.size() < 2) { + if (md.meshNumber() < 2) { throw MLException("There must be at least two layers to apply the craters generation filter."); } diff --git a/src/meshlabplugins/filter_layer/filter_layer.cpp b/src/meshlabplugins/filter_layer/filter_layer.cpp index 8027f4b10..54c2f2988 100644 --- a/src/meshlabplugins/filter_layer/filter_layer.cpp +++ b/src/meshlabplugins/filter_layer/filter_layer.cpp @@ -223,7 +223,7 @@ std::map FilterLayerPlugin::applyFilter( } else { - foreach(MeshModel *mmp, md.meshList) + for(MeshModel *mmp: md.meshIterator()) { if (mmp->label().contains(match)) md.setVisible(mmp->id(), par.getBool("isMeshVisible")); @@ -239,7 +239,7 @@ std::map FilterLayerPlugin::applyFilter( case FP_DELETE_NON_VISIBLE_MESH: { - foreach(MeshModel *mmp, md.meshList) + for(MeshModel *mmp: md.meshIterator()) { if (!mmp->visible) md.delMesh(mmp); @@ -283,11 +283,11 @@ std::map FilterLayerPlugin::applyFilter( tri::UpdateSelection::VertexClear(currentModel->cm); currentModel->clearDataMask(MeshModel::MM_FACEFACETOPO); - log("Moved %i vertices to layer %i, deleted %i faces", numVertSel, delfaces, md.meshList.size()); + log("Moved %i vertices to layer %i, deleted %i faces", numVertSel, currentModel->id(), delfaces); } - else // keep original faces + else // keep original faces { - log("Copied %i vertices to layer %i", numVertSel, md.meshList.size()); + log("Copied %i vertices to layer %i", numVertSel, currentModel->id()); } vcg::tri::UpdateFlags::VertexClear(destModel->cm, CMeshO::VertexType::SELECTED); @@ -328,11 +328,11 @@ std::map FilterLayerPlugin::applyFilter( tri::UpdateSelection::FaceClear(currentModel->cm); currentModel->clearDataMask(MeshModel::MM_FACEFACETOPO); - log("Moved %i faces and %i vertices to layer %i", numFacesSel, numVertSel, md.meshList.size()); + log("Moved %i faces and %i vertices to layer %i", numFacesSel, numVertSel, currentModel->id()); } else // keep original faces { - log("Copied %i faces and %i vertices to layer %i", numFacesSel, numVertSel, md.meshList.size()); + log("Copied %i faces and %i vertices to layer %i", numFacesSel, numVertSel, currentModel->id()); } vcg::tri::UpdateFlags::VertexClear(destModel->cm, CMeshO::VertexType::SELECTED); vcg::tri::UpdateFlags::FaceClear(destModel->cm, CMeshO::FaceType::SELECTED); @@ -356,7 +356,7 @@ std::map FilterLayerPlugin::applyFilter( tex = fullPath.toStdString(); } - log("Duplicated current model to layer %i", md.meshList.size()); + log("Duplicated current model to layer %i", destModel->id()); // init new layer destModel->updateBoxAndNormals(); @@ -375,14 +375,14 @@ std::map FilterLayerPlugin::applyFilter( QList toBeDeletedList; int cnt=0; - foreach(MeshModel *mmp, md.meshList) + for(MeshModel *mmp: md.meshIterator()) { ++cnt; if(mmp->visible || !mergeVisible) { if (mmp != destModel) { - cb(cnt*100/md.meshList.size(), "Merging layers..."); + cb(cnt*100/md.meshNumber(), "Merging layers..."); tri::UpdatePosition::Matrix(mmp->cm,mmp->cm.Tr,true); toBeDeletedList.push_back(mmp); if(!alsoUnreferenced) diff --git a/src/meshlabplugins/filter_mesh_booleans/filter_mesh_booleans.cpp b/src/meshlabplugins/filter_mesh_booleans/filter_mesh_booleans.cpp index d17feb6bd..41f1a2d22 100644 --- a/src/meshlabplugins/filter_mesh_booleans/filter_mesh_booleans.cpp +++ b/src/meshlabplugins/filter_mesh_booleans/filter_mesh_booleans.cpp @@ -181,7 +181,7 @@ RichParameterList FilterMeshBooleans::initParameterList( { const MeshModel *target = md.mm(); //looking for a second mesh different that the current one - for (const MeshModel * t : md.meshList){ + for (const MeshModel * t : md.meshIterator()){ if (t != md.mm()) { target = t; break; diff --git a/src/meshlabplugins/filter_plymc/filter_plymc.cpp b/src/meshlabplugins/filter_plymc/filter_plymc.cpp index 9d06c0940..22deb8d4a 100644 --- a/src/meshlabplugins/filter_plymc/filter_plymc.cpp +++ b/src/meshlabplugins/filter_plymc/filter_plymc.cpp @@ -165,7 +165,7 @@ std::map PlyMCPlugin::applyFilter( p.FullyPreprocessedFlag=true; p.MergeColor=p.VertSplatFlag=par.getBool("mergeColor"); p.SimplificationFlag = par.getBool("simplification"); - foreach(MeshModel*mm, md.meshList) + for(MeshModel*mm: md.meshIterator()) { if(mm->visible) { diff --git a/src/meshlabplugins/filter_sampling/filter_sampling.cpp b/src/meshlabplugins/filter_sampling/filter_sampling.cpp index 318a5d1f1..de188ec8d 100644 --- a/src/meshlabplugins/filter_sampling/filter_sampling.cpp +++ b/src/meshlabplugins/filter_sampling/filter_sampling.cpp @@ -564,8 +564,12 @@ RichParameterList FilterDocSampling::initParameterList(const QAction *action, co case FP_HAUSDORFF_DISTANCE: { const MeshModel *vertexMesh = md.mm(); - foreach(vertexMesh, md.meshList) - if (vertexMesh != md.mm()) break; + for(const MeshModel * vm: md.meshIterator()){ + if (vm != md.mm()) { + vertexMesh = vm; + break; + } + } parlst.addParam(RichMesh("SampledMesh", md.mm()->id(), &md, "Sampled Mesh", "The mesh whose surface is sampled. For each sample we search the closest point on the Target Mesh.")); @@ -585,13 +589,17 @@ RichParameterList FilterDocSampling::initParameterList(const QAction *action, co "The desired number of samples. It can be smaller or larger than the mesh size, and according to the chosen sampling strategy it will try to adapt.")); parlst.addParam(RichAbsPerc("MaxDist", md.mm()->cm.bbox.Diag() / 2.0, 0.0f, md.bbox().Diag(), tr("Max Distance"), tr("Sample points for which we do not find anything within this distance are rejected and not considered neither for averaging nor for max."))); - } break; + } break; - case FP_DISTANCE_REFERENCE: - { + case FP_DISTANCE_REFERENCE: + { const MeshModel *vertexMesh = md.mm(); - foreach(vertexMesh, md.meshList) - if (vertexMesh != md.mm()) break; + for(const MeshModel * vm: md.meshIterator()){ + if (vm != md.mm()) { + vertexMesh = vm; + break; + } + } parlst.addParam(RichMesh("MeasureMesh", md.mm()->id(), &md, "Measured Mesh/PointCloud", "The Mesh/Pointcloud that is measured, vertex by vertex, computing distance from the REFERENCE mesh/pointcloud.")); @@ -605,11 +613,14 @@ RichParameterList FilterDocSampling::initParameterList(const QAction *action, co tr("Max Distance [abs]"), tr("Search is interrupted when nothing is found within this distance range [+maxDistance -maxDistance]."))); } break; - case FP_VERTEX_RESAMPLING: - { + case FP_VERTEX_RESAMPLING: + { const MeshModel *vertexMesh= md.mm(); - foreach (vertexMesh, md.meshList) - if (vertexMesh != md.mm()) break; + for (const MeshModel* vm: md.meshIterator()) + if (vm != md.mm()) { + vertexMesh = vm; + break; + } parlst.addParam(RichMesh ("SourceMesh", md.mm()->id(),&md, "Source Mesh", "The mesh that contains the source data that we want to transfer.")); @@ -657,16 +668,23 @@ RichParameterList FilterDocSampling::initParameterList(const QAction *action, co "In this case you have to choose a not zero Offset and a double surface is built around the original surface, inside and outside. " "Is useful to convrt thin floating surfaces into solid, thick meshes.. t")); } break; - case FP_VORONOI_COLORING : - case FP_DISK_COLORING : - { - const MeshModel *colorMesh= md.mm(); - foreach (colorMesh, md.meshList) // Search a mesh with some faces.. - if (colorMesh->cm.fn>0) break; - MeshModel *vertexMesh; - foreach (vertexMesh, md.meshList) // Search another mesh - if (vertexMesh != colorMesh) break; + case FP_VORONOI_COLORING : + case FP_DISK_COLORING : + { + const MeshModel *colorMesh= md.mm(); + for (const MeshModel* colm: md.meshIterator()) // Search a mesh with some faces.. + if (colm->cm.fn>0){ + colorMesh = colm; + break; + } + + const MeshModel *vertexMesh= md.mm(); + for (const MeshModel* vm : md.meshIterator()) // Search another mesh + if (vm != colorMesh) { + vertexMesh = vm; + break; + } parlst.addParam(RichMesh ("ColoredMesh", colorMesh->id(),&md, "To be Colored Mesh", "The mesh whose surface is colored. For each vertex of this mesh we decide the color according the below parameters.")); diff --git a/src/meshlabplugins/filter_texture/filter_texture.cpp b/src/meshlabplugins/filter_texture/filter_texture.cpp index 35b3c96a4..c0e609bb4 100644 --- a/src/meshlabplugins/filter_texture/filter_texture.cpp +++ b/src/meshlabplugins/filter_texture/filter_texture.cpp @@ -200,7 +200,7 @@ RichParameterList FilterTexturePlugin::initParameterList(const QAction *action, { RichParameterList parlst; const MeshModel* trg = md.mm(); - for (const MeshModel* tmp : md.meshList){ + for (const MeshModel* tmp : md.meshIterator()){ if (tmp != trg && tmp != nullptr){ trg = tmp; break; diff --git a/src/meshlabplugins/render_gdp/meshrender.cpp b/src/meshlabplugins/render_gdp/meshrender.cpp index 2823f7f3a..ada74d27d 100644 --- a/src/meshlabplugins/render_gdp/meshrender.cpp +++ b/src/meshlabplugins/render_gdp/meshrender.cpp @@ -486,7 +486,7 @@ void MeshShaderRenderPlugin::render(QAction *a, MeshDocument &md, MLSceneGLShare if ((gla != NULL) && (gla->mvc() != NULL)) { MLSceneGLSharedDataContext* shared = gla->mvc()->sharedDataContext(); - for(MeshModel * mp : md.meshList) + for(MeshModel * mp : md.meshIterator()) { if ((mp != NULL) && (gla->meshVisibilityMap[mp->id()])) shared->draw(mp->id(),gla->context()); diff --git a/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp index 12fb85257..78b64ab28 100644 --- a/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp +++ b/src/meshlabplugins/render_radiance_scaling/radianceScalingRenderer.cpp @@ -122,7 +122,7 @@ void RadianceScalingRendererPlugin::render(QAction *, MeshDocument &md, MLSceneG vcg::glColor(vcg::Color4b(vcg::Color4b::LightGray)); _buffPass->enable(); - foreach(MeshModel *mp, md.meshList) + for(MeshModel *mp: md.meshIterator()) { if ((mp != NULL) && (gla->meshVisibilityMap[mp->id()])) {