- fixed compiler errors with non-const default arguments parameters passed by references - added support for visual studio 2017 to the projects in meshlab_mini

This commit is contained in:
granzuglia 2017-12-16 12:17:06 +11:00
parent da644ee4da
commit b480cedf2f
8 changed files with 122 additions and 106 deletions

View File

@ -9,6 +9,7 @@ win32-msvc2010:DESTDIR = ../distrib
win32-msvc2012:DESTDIR = ../distrib
win32-msvc2013:DESTDIR = ../distrib
win32-msvc2015:DESTDIR = ../distrib
win32-msvc:DESTDIR = ../distrib
win32-g++:DLLDESTDIR = ../distrib
# CONFIG(release,debug | release) {
@ -73,6 +74,7 @@ win32-msvc2010:CONFIG += staticlib
win32-msvc2012:CONFIG += staticlib
win32-msvc2013:CONFIG += staticlib
win32-msvc2015:CONFIG += staticlib
win32-msvc:CONFIG += staticlib
QT += opengl
QT += xml
@ -90,6 +92,7 @@ win32-msvc2010:DEFINES += _CRT_SECURE_NO_WARNINGS
win32-msvc2012:DEFINES += _CRT_SECURE_NO_WARNINGS
win32-msvc2013:DEFINES += _CRT_SECURE_NO_WARNINGS
win32-msvc2015:DEFINES += _CRT_SECURE_NO_WARNINGS
win32-msvc2017:DEFINES += _CRT_SECURE_NO_WARNINGS
# Input

View File

@ -3,11 +3,10 @@
#include <QFileInfo>
#include <QtXml>
#include "meshmodel.h"
#include "meshlabdocumentxml.h"
#include <wrap/qt/shot_qt.h>
bool MeshDocumentToXMLFile(MeshDocument &md, QString filename, bool onlyVisibleLayers, bool binary, std::map<int, MLRenderingData>& rendOpt)
bool MeshDocumentToXMLFile(MeshDocument &md, QString filename, bool onlyVisibleLayers, bool binary, const std::map<int, MLRenderingData>& rendOpt)
{
md.setFileName(filename);
QFileInfo fi(filename);
@ -38,11 +37,11 @@ QDomElement Matrix44mToXML(Matrix44m &m, QDomDocument &doc)
QDomElement Matrix44mToBinaryXML(Matrix44m &m, QDomDocument &doc)
{
QDomElement matrixElem = doc.createElement("MLMatrix44");
QByteArray value = QByteArray::fromRawData((char *)m.V(), sizeof(Matrix44m::ScalarType) * 16).toBase64();
QDomText nd = doc.createTextNode(QString(value));
matrixElem.appendChild(nd);
return matrixElem;
QDomElement matrixElem = doc.createElement("MLMatrix44");
QByteArray value = QByteArray::fromRawData((char *)m.V(), sizeof(Matrix44m::ScalarType) * 16).toBase64();
QDomText nd = doc.createTextNode(QString(value));
matrixElem.appendChild(nd);
return matrixElem;
}
bool MeshDocumentFromXML(MeshDocument &md, QString filename, bool binary, std::map<int, MLRenderingData>& rendOpt)
@ -76,73 +75,73 @@ bool MeshDocumentFromXML(MeshDocument &md, QString filename, bool binary, std::m
//return true;
filen = mesh.attributes().namedItem("filename").nodeValue();
label = mesh.attributes().namedItem("label").nodeValue();
bool visible = true;
if (mesh.attributes().contains("visible"))
visible = (mesh.attributes().namedItem("visible").nodeValue().toInt() == 1);
MeshModel* mm = md.addNewMesh(filen, label);
mm->visible = visible;
/*if (mesh.attributes().contains("renderingOptions"))
{
QString value = mesh.attributes().namedItem("renderingOptions").nodeValue();
rendOpt.insert(std::pair<int, std::string>(mm->id(), value.toStdString()));
}*/
QDomNode tr = mesh.firstChildElement("MLMatrix44");
bool visible = true;
if (mesh.attributes().contains("visible"))
visible = (mesh.attributes().namedItem("visible").nodeValue().toInt() == 1);
MeshModel* mm = md.addNewMesh(filen, label);
mm->visible = visible;
/*if (mesh.attributes().contains("renderingOptions"))
{
QString value = mesh.attributes().namedItem("renderingOptions").nodeValue();
rendOpt.insert(std::pair<int, std::string>(mm->id(), value.toStdString()));
}*/
QDomNode tr = mesh.firstChildElement("MLMatrix44");
if (!tr.isNull())
{
vcg::Matrix44f trm;
if (tr.childNodes().size() == 1)
{
if (!binary)
{
QStringList values = tr.firstChild().nodeValue().split(" ", QString::SkipEmptyParts);
for (int y = 0; y < 4; y++)
for (int x = 0; x < 4; x++)
md.mm()->cm.Tr[y][x] = values[x + 4 * y].toFloat();
}
else
{
QString str = tr.firstChild().nodeValue();
QByteArray value = QByteArray::fromBase64(str.toLocal8Bit());
memcpy(md.mm()->cm.Tr.V(), value.data(), sizeof(Matrix44m::ScalarType) * 16);
}
if (!binary)
{
QStringList values = tr.firstChild().nodeValue().split(" ", QString::SkipEmptyParts);
for (int y = 0; y < 4; y++)
for (int x = 0; x < 4; x++)
md.mm()->cm.Tr[y][x] = values[x + 4 * y].toFloat();
}
else
{
QString str = tr.firstChild().nodeValue();
QByteArray value = QByteArray::fromBase64(str.toLocal8Bit());
memcpy(md.mm()->cm.Tr.V(), value.data(), sizeof(Matrix44m::ScalarType) * 16);
}
}
}
QDomNode renderingOpt = mesh.firstChildElement("RenderingOption");
if (!renderingOpt.isNull())
{
QString value = renderingOpt.firstChild().nodeValue();
MLRenderingData::GLOptionsType opt;
if (renderingOpt.attributes().contains("pointSize"))
opt._perpoint_pointsize = renderingOpt.attributes().namedItem("pointSize").nodeValue().toFloat();
if (renderingOpt.attributes().contains("wireWidth"))
opt._perwire_wirewidth = renderingOpt.attributes().namedItem("wireWidth").nodeValue().toFloat();
if (renderingOpt.attributes().contains("boxColor"))
{
QStringList values = renderingOpt.attributes().namedItem("boxColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._perbbox_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
if (renderingOpt.attributes().contains("pointColor"))
{
QStringList values = renderingOpt.attributes().namedItem("pointColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._perpoint_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
if (renderingOpt.attributes().contains("wireColor"))
{
QStringList values = renderingOpt.attributes().namedItem("wireColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._perwire_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
if (renderingOpt.attributes().contains("solidColor"))
{
QStringList values = renderingOpt.attributes().namedItem("solidColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._persolid_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
MLRenderingData data;
data.set(opt);
if (data.deserialize(value.toStdString()))
rendOpt.insert(std::pair<int, MLRenderingData>(mm->id(), data));
}
QDomNode renderingOpt = mesh.firstChildElement("RenderingOption");
if (!renderingOpt.isNull())
{
QString value = renderingOpt.firstChild().nodeValue();
MLRenderingData::GLOptionsType opt;
if (renderingOpt.attributes().contains("pointSize"))
opt._perpoint_pointsize = renderingOpt.attributes().namedItem("pointSize").nodeValue().toFloat();
if (renderingOpt.attributes().contains("wireWidth"))
opt._perwire_wirewidth = renderingOpt.attributes().namedItem("wireWidth").nodeValue().toFloat();
if (renderingOpt.attributes().contains("boxColor"))
{
QStringList values = renderingOpt.attributes().namedItem("boxColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._perbbox_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
if (renderingOpt.attributes().contains("pointColor"))
{
QStringList values = renderingOpt.attributes().namedItem("pointColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._perpoint_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
if (renderingOpt.attributes().contains("wireColor"))
{
QStringList values = renderingOpt.attributes().namedItem("wireColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._perwire_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
if (renderingOpt.attributes().contains("solidColor"))
{
QStringList values = renderingOpt.attributes().namedItem("solidColor").nodeValue().split(" ", QString::SkipEmptyParts);
opt._persolid_fixed_color = vcg::Color4b(values[0].toInt(), values[1].toInt(), values[2].toInt(), values[3].toInt());
}
MLRenderingData data;
data.set(opt);
if (data.deserialize(value.toStdString()))
rendOpt.insert(std::pair<int, MLRenderingData>(mm->id(), data));
}
mesh = mesh.nextSibling();
}
@ -159,7 +158,7 @@ bool MeshDocumentFromXML(MeshDocument &md, QString filename, bool binary, std::m
QString labelRaster = raster.attributes().namedItem("label").nodeValue();
md.rm()->setLabel(labelRaster);
QDomNode sh = raster.firstChild();
ReadShotFromQDomNode(md.rm()->shot, sh);
ReadShotFromQDomNode(md.rm()->shot, sh);
QDomElement el = raster.firstChildElement("Plane");
while (!el.isNull())
@ -182,35 +181,33 @@ bool MeshDocumentFromXML(MeshDocument &md, QString filename, bool binary, std::m
return true;
}
QDomElement MeshModelToXML(MeshModel *mp, QDomDocument &doc, bool binary, MLRenderingData* rendOpt = NULL)
QDomElement MeshModelToXML(MeshModel *mp, QDomDocument &doc, bool binary, const MLRenderingData& rendOpt = MLRenderingData())
{
QDomElement meshElem = doc.createElement("MLMesh");
meshElem.setAttribute("label", mp->label());
meshElem.setAttribute("filename", mp->relativePathName());
meshElem.setAttribute("visible", mp->isVisible());
if (binary)
meshElem.appendChild(Matrix44mToBinaryXML(mp->cm.Tr, doc));
else
meshElem.appendChild(Matrix44mToXML(mp->cm.Tr, doc));
if (rendOpt != NULL)
{
QDomElement renderingElem = doc.createElement("RenderingOption");
std::string text;
rendOpt->serialize(text);
QDomText nd = doc.createTextNode(QString(text.c_str()));
renderingElem.appendChild(nd);
MLRenderingData::GLOptionsType opt;
if (rendOpt->get(opt))
{
renderingElem.setAttribute("boxColor", QString("%1 %2 %3 %4").arg(opt._perbbox_fixed_color[0]).arg(opt._perbbox_fixed_color[1]).arg(opt._perbbox_fixed_color[2]).arg(opt._perbbox_fixed_color[3]));
renderingElem.setAttribute("pointColor", QString("%1 %2 %3 %4").arg(opt._perpoint_fixed_color[0]).arg(opt._perpoint_fixed_color[1]).arg(opt._perpoint_fixed_color[2]).arg(opt._perpoint_fixed_color[3]));
renderingElem.setAttribute("wireColor", QString("%1 %2 %3 %4").arg(opt._perwire_fixed_color[0]).arg(opt._perwire_fixed_color[1]).arg(opt._perwire_fixed_color[2]).arg(opt._perwire_fixed_color[3]));
renderingElem.setAttribute("solidColor", QString("%1 %2 %3 %4").arg(opt._persolid_fixed_color[0]).arg(opt._persolid_fixed_color[1]).arg(opt._persolid_fixed_color[2]).arg(opt._persolid_fixed_color[3]));
renderingElem.setAttribute("pointSize", opt._perpoint_pointsize);
renderingElem.setAttribute("wireWidth", opt._perwire_wirewidth);
}
meshElem.appendChild(renderingElem);
}
meshElem.setAttribute("visible", mp->isVisible());
if (binary)
meshElem.appendChild(Matrix44mToBinaryXML(mp->cm.Tr, doc));
else
meshElem.appendChild(Matrix44mToXML(mp->cm.Tr, doc));
QDomElement renderingElem = doc.createElement("RenderingOption");
std::string text;
rendOpt.serialize(text);
QDomText nd = doc.createTextNode(QString(text.c_str()));
renderingElem.appendChild(nd);
MLRenderingData::GLOptionsType opt;
if (rendOpt.get(opt))
{
renderingElem.setAttribute("boxColor", QString("%1 %2 %3 %4").arg(opt._perbbox_fixed_color[0]).arg(opt._perbbox_fixed_color[1]).arg(opt._perbbox_fixed_color[2]).arg(opt._perbbox_fixed_color[3]));
renderingElem.setAttribute("pointColor", QString("%1 %2 %3 %4").arg(opt._perpoint_fixed_color[0]).arg(opt._perpoint_fixed_color[1]).arg(opt._perpoint_fixed_color[2]).arg(opt._perpoint_fixed_color[3]));
renderingElem.setAttribute("wireColor", QString("%1 %2 %3 %4").arg(opt._perwire_fixed_color[0]).arg(opt._perwire_fixed_color[1]).arg(opt._perwire_fixed_color[2]).arg(opt._perwire_fixed_color[3]));
renderingElem.setAttribute("solidColor", QString("%1 %2 %3 %4").arg(opt._persolid_fixed_color[0]).arg(opt._persolid_fixed_color[1]).arg(opt._persolid_fixed_color[2]).arg(opt._persolid_fixed_color[3]));
renderingElem.setAttribute("pointSize", opt._perpoint_pointsize);
renderingElem.setAttribute("wireWidth", opt._perwire_wirewidth);
}
meshElem.appendChild(renderingElem);
return meshElem;
}
@ -218,10 +215,10 @@ QDomElement RasterModelToXML(RasterModel *mp, QDomDocument &doc, bool binary)
{
QDomElement rasterElem = doc.createElement("MLRaster");
rasterElem.setAttribute("label", mp->label());
if (binary)
rasterElem.appendChild(WriteShotToQDomNodeBinary(mp->shot, doc));
else
rasterElem.appendChild(WriteShotToQDomNode(mp->shot, doc));
if (binary)
rasterElem.appendChild(WriteShotToQDomNodeBinary(mp->shot, doc));
else
rasterElem.appendChild(WriteShotToQDomNode(mp->shot, doc));
for (int ii = 0; ii < mp->planeList.size(); ++ii)
rasterElem.appendChild(PlaneToXML(mp->planeList[ii], mp->par->pathName(), doc));
return rasterElem;
@ -236,7 +233,7 @@ QDomElement PlaneToXML(Plane* pl, const QString& basePath, QDomDocument& doc)
return planeElem;
}
QDomDocument MeshDocumentToXML(MeshDocument &md, bool onlyVisibleLayers, bool binary, std::map<int, MLRenderingData>& rendOpt)
QDomDocument MeshDocumentToXML(MeshDocument &md, bool onlyVisibleLayers, bool binary, const std::map<int, MLRenderingData>& rendOpt)
{
QDomDocument ddoc("MeshLabDocument");
@ -246,13 +243,13 @@ QDomDocument MeshDocumentToXML(MeshDocument &md, bool onlyVisibleLayers, bool bi
foreach(MeshModel *mmp, md.meshList)
{
if ((!onlyVisibleLayers) || (mmp->visible))
if ((!onlyVisibleLayers) || (mmp->visible))
{
QDomElement meshElem;
if (rendOpt.find(mmp->id()) != rendOpt.end())
meshElem = MeshModelToXML(mmp, ddoc, binary, &rendOpt[mmp->id()]);
else
meshElem = MeshModelToXML(mmp, ddoc, binary);
QDomElement meshElem;
if (rendOpt.find(mmp->id()) != rendOpt.end())
meshElem = MeshModelToXML(mmp, ddoc, binary, rendOpt.at(mmp->id()));
else
meshElem = MeshModelToXML(mmp, ddoc, binary);
mgroot.appendChild(meshElem);
}
}

View File

@ -1,9 +1,16 @@
#ifndef __MESHLABDOC_XML_H
#define __MESHLABDOC_XML_H
QDomDocument MeshDocumentToXML(MeshDocument &md, bool onlyVisibleLayers, bool binary, std::map<int, MLRenderingData>& rendOpt = std::map<int, MLRenderingData>());
bool MeshDocumentToXMLFile(MeshDocument &md, QString filename, bool onlyVisibleLayers, bool binary, std::map<int, MLRenderingData>& rendOpt = std::map<int, MLRenderingData>());
bool MeshDocumentFromXML(MeshDocument &md, QString filename, bool binary, std::map<int, MLRenderingData>& rendOpt = std::map<int, MLRenderingData>());
#include <QDomDocument>
#include "ml_shared_data_context.h"
#include "meshmodel.h"
#include<map>
QDomDocument MeshDocumentToXML(MeshDocument &md, bool onlyVisibleLayers, bool binary, const std::map<int, MLRenderingData>& rendOpt = std::map<int, MLRenderingData>());
bool MeshDocumentToXMLFile(MeshDocument &md, QString filename, bool onlyVisibleLayers, bool binary, const std::map<int, MLRenderingData>& rendOpt = std::map<int, MLRenderingData>());
bool MeshDocumentFromXML(MeshDocument &md, QString filename, bool binary, std::map<int, MLRenderingData>& rendOpt);
QDomElement RasterModelToXML(RasterModel *mp,QDomDocument &doc, bool binary);
QDomElement PlaneToXML(Plane* pl,const QString& basePath,QDomDocument& doc);
#endif // __MESHLABDOC_XML_H

View File

@ -122,7 +122,7 @@ struct MLPerViewGLOptions : public vcg::RenderingModalityGLOptions
}
size_t serialize(std::string& str)
size_t serialize(std::string& str) const
{
str.append(((_visible) ? "1" : "0"));
str.append(((_perbbox_quoted_info_enabled) ? "1" : "0"));

View File

@ -12,6 +12,8 @@ win32-msvc2010:QMAKE_CXXFLAGS += /nologo /Ox /W3 /c /DOPENCTM_STATIC /D_CRT_SECU
win32-msvc2012:QMAKE_CXXFLAGS += /nologo /Ox /W3 /c /DOPENCTM_STATIC /D_CRT_SECURE_NO_WARNINGS
win32-msvc2015:QMAKE_CXXFLAGS += /nologo /Ox /W3 /c /DOPENCTM_STATIC /D_CRT_SECURE_NO_WARNINGS
win32-msvc2015:DEFINES += OPENCTM_STATIC
win32-msvc:QMAKE_CXXFLAGS += /nologo /Ox /W3 /c /DOPENCTM_STATIC /D_CRT_SECURE_NO_WARNINGS
win32-msvc:DEFINES += OPENCTM_STATIC
win32-g++:QMAKE_CXXFLAGS += -O3 -W -Wall -c -std=c99 -pedantic
win32-g++:DEFINES += OPENCTM_STATIC
linux-g++:QMAKE_CXXFLAGS += -O3 -W -Wall -c -std=c99 -pedantic

View File

@ -6,7 +6,9 @@ win32-msvc2010:DESTDIR = $$EXTERNAL_BASE_PATH/lib/win32-msvc2010
win32-msvc2012:DESTDIR = $$EXTERNAL_BASE_PATH/lib/win32-msvc2012
win32-msvc2013:DESTDIR = $$EXTERNAL_BASE_PATH/lib/win32-msvc2013
win32-msvc2015:DESTDIR = $$EXTERNAL_BASE_PATH/lib/win32-msvc2015
win32-msvc:DESTDIR = $$EXTERNAL_BASE_PATH/lib/win32-msvc
win32-msvc2015:DEFINES += _CRT_SECURE_NO_WARNINGS
win32-msvc:DEFINES += _CRT_SECURE_NO_WARNINGS
linux-g++:DESTDIR = $$EXTERNAL_BASE_PATH/lib/linux-g++
linux-g++-32:DESTDIR = $$EXTERNAL_BASE_PATH/lib/linux-g++-32
linux-g++-64:DESTDIR = $$EXTERNAL_BASE_PATH/lib/linux-g++-64

View File

@ -125,6 +125,7 @@ win32-msvc2010:DEFINES += _CRT_SECURE_NO_DEPRECATE
win32-msvc2012:DEFINES += _CRT_SECURE_NO_DEPRECATE
win32-msvc2013:DEFINES += _CRT_SECURE_NO_DEPRECATE
win32-msvc2015:DEFINES += _CRT_SECURE_NO_DEPRECATE
win32-msvc:DEFINES += _CRT_SECURE_NO_DEPRECATE
# Uncomment these if you want to experiment with newer gcc compilers
# (here using the one provided with macports)
@ -143,6 +144,7 @@ win32-msvc2010:LIBS += -L../external/lib/win32-msvc2010 -ljhead -L../distrib -l
win32-msvc2012:LIBS += -L../external/lib/win32-msvc2012 -ljhead -L../distrib -lcommon -lopengl32 -lGLU32
win32-msvc2013:LIBS += -L../external/lib/win32-msvc2013 -ljhead -L../distrib -lcommon -lopengl32 -lGLU32
win32-msvc2015:LIBS += -L../external/lib/win32-msvc2015 -ljhead -L../distrib -lcommon -lopengl32 -lGLU32
win32-msvc:LIBS += -L../external/lib/win32-msvc -ljhead -L../distrib -lcommon -lopengl32 -lGLU32
win32-g++:LIBS += -L../external/lib/win32-gcc -ljhead -L../distrib -lcommon -lopengl32 -lGLU32
#CONFIG(release,debug | release) {

View File

@ -17,6 +17,7 @@ mac:LIBS += ../../common/libcommon.dylib
win32-msvc2013: LIBS += ../../distrib/common.lib -lopengl32 -lGLU32
win32-msvc2015: LIBS += ../../distrib/common.lib -lopengl32 -lGLU32
win32-msvc: LIBS += ../../distrib/common.lib -lopengl32 -lGLU32
win32-g++:LIBS += -L../../distrib -lcommon -lopengl32 -lGLU32
linux-g++:LIBS += -L../../distrib -lcommon -lGL -lGLU
linux-g++-32:LIBS += -L../../distrib -lcommon -lGL -lGLU
@ -24,6 +25,7 @@ linux-g++-64:LIBS += -L../../distrib -lcommon -lGL -lGLU
win32-msvc2013:DEFINES += GLEW_STATIC _USE_MATH_DEFINES
win32-msvc2015:DEFINES += GLEW_STATIC _USE_MATH_DEFINES
win32-msvc:DEFINES += GLEW_STATIC _USE_MATH_DEFINES
# uncomment to try Eigen
# DEFINES += VCG_USE_EIGEN
@ -42,6 +44,7 @@ DEPENDPATH += ../.. $$VCGDIR
# old printf are all around the code
win32-msvc2013:DEFINES += _CRT_SECURE_NO_DEPRECATE
win32-msvc2015:DEFINES += _CRT_SECURE_NO_DEPRECATE
win32-msvc:DEFINES += _CRT_SECURE_NO_DEPRECATE
CONFIG(release,debug | release){
# Uncomment the following line to disable assert in mingw
#DEFINES += NDEBUG