mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-15 09:04:36 +00:00
Corrections of include paths to comply the new folder arrangement of the VCG library (I/O stuff, removed most of the offending includes since useless)
This commit is contained in:
parent
70bfe7cb63
commit
4a8d3a71df
@ -42,7 +42,6 @@
|
||||
#define __VCGLIB_IMPORT_3DS
|
||||
|
||||
#include <wrap/callback.h>
|
||||
#include <vcg/complex/trimesh/allocate.h>
|
||||
#include "io_3ds.h"
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
|
||||
|
||||
@ -40,8 +40,6 @@
|
||||
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -92,11 +92,8 @@
|
||||
|
||||
#include "io_collada.h"
|
||||
|
||||
//#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <vcg/complex/trimesh/update/texture.h>
|
||||
#include <vcg/complex/algorithms/update/texture.h>
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
#include <wrap/io_trimesh/import_dae.h>
|
||||
#include <wrap/io_trimesh/export_dae.h>
|
||||
|
||||
|
||||
@ -34,17 +34,11 @@
|
||||
|
||||
#include "epoch_io.h"
|
||||
#include "epoch_reconstruction.h"
|
||||
#include <vcg/math/matrix33.h>
|
||||
#include <vcg/complex/append.h>
|
||||
#include <vcg/math/histogram.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <vcg/complex/trimesh/create/platonic.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <vcg/complex/trimesh/append.h>
|
||||
#include <vcg/complex/trimesh/clustering.h>
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/position.h>
|
||||
#include <vcg/complex/trimesh/hole.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
#include <vcg/complex/algorithms/clustering.h>
|
||||
#include <vcg/complex/algorithms/hole.h>
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
#include <meshlab/alnParser.h>
|
||||
|
||||
|
||||
@ -23,27 +23,6 @@
|
||||
|
||||
#include <Qt>
|
||||
#include <QPixmap>
|
||||
//#include <QtGui>
|
||||
//#include <QtXml/QDomDocument>
|
||||
//#include <QtXml/QDomElement>
|
||||
//#include <QtXml/QDomNode>
|
||||
//
|
||||
//
|
||||
//// temporaneamente prendo la versione corrente dalla cartella test
|
||||
//#include<vcg/complex/trimesh/update/bounding.h>
|
||||
//#include <wrap/io_trimesh/io_mask.h>
|
||||
//#include <vcg/complex/trimesh/create/platonic.h>
|
||||
//#include <vcg/complex/trimesh/update/bounding.h>
|
||||
//#include <vcg/complex/trimesh/update/normal.h>
|
||||
//#include <vcg/math/matrix33.h>
|
||||
//#include<vcg/complex/trimesh/append.h>
|
||||
//
|
||||
//#include <QMessageBox>
|
||||
//#include <QFileDialog>
|
||||
|
||||
//#include "epoch.h"
|
||||
//#include "radial_distortion.h"
|
||||
//#include "epoch_camera.h"
|
||||
#include <bzlib.h>
|
||||
#include <vector>
|
||||
#include "scalar_image.h"
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <vcg/space/color4.h>
|
||||
#include<vcg/complex/trimesh/allocate.h>
|
||||
#include <wrap/callback.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
|
||||
|
||||
@ -34,7 +34,6 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <vcg/space/color4.h>
|
||||
#include<vcg/complex/trimesh/allocate.h>
|
||||
#include <wrap/callback.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
|
||||
|
||||
@ -28,8 +28,6 @@
|
||||
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
|
||||
#include "import_expe.h"
|
||||
#include "import_xyz.h"
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include <vcg/space/color4.h>
|
||||
#include<vcg/complex/trimesh/allocate.h>
|
||||
#include <wrap/callback.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
|
||||
|
||||
@ -28,8 +28,6 @@
|
||||
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
|
||||
#include "import_gts.h"
|
||||
#include "export_gts.h"
|
||||
|
||||
@ -1,469 +1,469 @@
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* An extendible mesh processor o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005, 2006 \/)\/ *
|
||||
* Visual Computing Lab /\/| *
|
||||
* ISTI - Italian National Research Council | *
|
||||
* \ *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||
* for more details. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#include "io_json.h"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include <vcg/complex/trimesh/attribute_seam.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
|
||||
JSONIOPlugin::JSONIOPlugin(void) : MeshIOInterface()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
JSONIOPlugin::~JSONIOPlugin(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
bool JSONIOPlugin::open(const QString & formatName, const QString & fileName, MeshModel & m, int & mask, const RichParameterSet & parlst, vcg::CallBackPos * cb, QWidget * parent)
|
||||
{
|
||||
(void)formatName;
|
||||
(void)fileName;
|
||||
(void)m;
|
||||
(void)mask;
|
||||
(void)parlst;
|
||||
(void)cb;
|
||||
(void)parent;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JSONIOPlugin::save(const QString & formatName,const QString & fileName, MeshModel & m, const int mask, const RichParameterSet & par, vcg::CallBackPos * cb, QWidget * parent)
|
||||
{
|
||||
(void)par;
|
||||
(void)cb;
|
||||
(void)parent;
|
||||
vcg::tri::Allocator<CMeshO>::CompactVertexVector(m.cm);
|
||||
vcg::tri::Allocator<CMeshO>::CompactFaceVector(m.cm);
|
||||
|
||||
const size_t maxValuesPerLine = 10; // must be > 0
|
||||
|
||||
if (formatName.toUpper() != tr("JSON")) return false;
|
||||
|
||||
const bool hasPerVertexPosition = true;
|
||||
const bool hasPerVertexNormal = ((mask & vcg::tri::io::Mask::IOM_VERTNORMAL) != 0) && m.hasDataMask(MeshModel::MM_VERTNORMAL);
|
||||
const bool hasPerVertexColor = ((mask & vcg::tri::io::Mask::IOM_VERTCOLOR) != 0) && m.hasDataMask(MeshModel::MM_VERTCOLOR);
|
||||
const bool hasPerVertexTexCoord = ((mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD) != 0) && m.hasDataMask(MeshModel::MM_VERTTEXCOORD);
|
||||
|
||||
const CMeshO & cm = m.cm;
|
||||
|
||||
const std::string filename = QFile::encodeName(fileName).constData();
|
||||
|
||||
std::ofstream os(filename.c_str());
|
||||
if (!os.is_open()) return false;
|
||||
|
||||
os << "{" << std::endl;
|
||||
|
||||
os << " \"version\" : \"0.1.0\"," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"comment\" : \"Generated by MeshLab JSON Exporter\"," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"id\" : 1," << std::endl;
|
||||
os << " \"name\" : \"mesh\"," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"vertices\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
bool prevDone = false;
|
||||
|
||||
if (hasPerVertexPosition)
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"position_buffer\"," << std::endl;
|
||||
os << " \"size\" : 3," << std::endl;
|
||||
os << " \"type\" : \"float32\"," << std::endl;
|
||||
os << " \"normalized\" : false," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::CoordType & p = cm.vert[it].cP();
|
||||
os << p[0] << ", " << p[1] << ", " << p[2];
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::CoordType & p = cm.vert[it].cP();
|
||||
os << ", " << p[0] << ", " << p[1] << ", " << p[2];
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (hasPerVertexNormal)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
os << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"normal_buffer\"," << std::endl;
|
||||
os << " \"size\" : 3," << std::endl;
|
||||
os << " \"type\" : \"float32\"," << std::endl;
|
||||
os << " \"normalized\" : false," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::NormalType & n = cm.vert[it].cN();
|
||||
os << n[0] << ", " << n[1] << ", " << n[2];
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::NormalType & n = cm.vert[it].cN();
|
||||
os << ", " << n[0] << ", " << n[1] << ", " << n[2];
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (hasPerVertexColor)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
os << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"color_buffer\"," << std::endl;
|
||||
os << " \"size\" : 4," << std::endl;
|
||||
os << " \"type\" : \"uint8\"," << std::endl;
|
||||
os << " \"normalized\" : true," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::ColorType & c = cm.vert[it].cC();
|
||||
os << int(c[0]) << ", " << int(c[1]) << ", " << int(c[2]) << ", " << int(c[3]);
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::ColorType & c = cm.vert[it].cC();
|
||||
os << ", " << int(c[0]) << ", " << int(c[1]) << ", " << int(c[2]) << ", " << int(c[3]);
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (hasPerVertexTexCoord)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
os << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"texcoord_buffer\"," << std::endl;
|
||||
os << " \"size\" : 2," << std::endl;
|
||||
os << " \"type\" : \"float32\"," << std::endl;
|
||||
os << " \"normalized\" : false," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::TexCoordType & t = cm.vert[it].cT();
|
||||
os << t.P()[0] << ", " << t.P()[1];
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::TexCoordType & t = cm.vert[it].cT();
|
||||
os << ", " << t.P()[0] << ", " << t.P()[1];
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (prevDone)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
os << " ]," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"connectivity\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
if ((m.cm.vn > 0) && (m.cm.fn > 0))
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"triangles\"," << std::endl;
|
||||
os << " \"mode\" : \"triangles_list\"," << std::endl;
|
||||
os << " \"indexed\" : true," << std::endl;
|
||||
os << " \"indexType\" : \"uint32\"," << std::endl;
|
||||
os << " \"indices\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
{
|
||||
const CMeshO::VertexType * v0 = &(m.cm.vert[0]);
|
||||
|
||||
size_t k = 0;
|
||||
size_t c = 0;
|
||||
const size_t sz = cm.fn;
|
||||
while (c < sz)
|
||||
{
|
||||
const size_t n = std::min(c + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
while (cm.face[k].IsD()) k++;
|
||||
const CMeshO::FaceType & f = cm.face[k];
|
||||
os << int(f.cV(0) - v0) << ", " << int(f.cV(1) - v0) << ", " << int(f.cV(2) - v0);
|
||||
c++;
|
||||
k++;
|
||||
}
|
||||
for (; c<n; ++c)
|
||||
{
|
||||
while (cm.face[k].IsD()) k++;
|
||||
const CMeshO::FaceType & f = cm.face[k];
|
||||
os << ", " << int(f.cV(0) - v0) << ", " << int(f.cV(1) - v0) << ", " << int(f.cV(2) - v0);
|
||||
k++;
|
||||
}
|
||||
if (c <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
os << " ]" << std::endl;
|
||||
os << " }" << std::endl;
|
||||
}
|
||||
|
||||
os << " ]," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"mapping\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
if ((m.cm.vn > 0) && (m.cm.fn > 0))
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"standard\"," << std::endl;
|
||||
os << " \"primitives\" : \"triangles\"," << std::endl;
|
||||
os << " \"attributes\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
prevDone = false;
|
||||
if (hasPerVertexPosition)
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"position_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"position\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
if (hasPerVertexNormal)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"normal_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"normal\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
if (hasPerVertexColor)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"color_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"color\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
if (hasPerVertexTexCoord)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"texcoord_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"texcoord\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (prevDone)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }" << std::endl;
|
||||
}
|
||||
os << " ]," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"custom\" : null" << std::endl;
|
||||
|
||||
os << "}" << std::endl;
|
||||
|
||||
os.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
returns the list of the file's type which can be imported
|
||||
*/
|
||||
QList<MeshIOInterface::Format> JSONIOPlugin::importFormats(void) const
|
||||
{
|
||||
QList<Format> formatList;
|
||||
//formatList << Format("JavaScript JSON", tr("JSON"));
|
||||
return formatList;
|
||||
}
|
||||
|
||||
/*
|
||||
returns the list of the file's type which can be exported
|
||||
*/
|
||||
QList<MeshIOInterface::Format> JSONIOPlugin::exportFormats(void) const
|
||||
{
|
||||
QList<Format> formatList;
|
||||
formatList << Format("JavaScript JSON", tr("JSON"));
|
||||
return formatList;
|
||||
}
|
||||
|
||||
/*
|
||||
returns the mask on the basis of the file's type.
|
||||
otherwise it returns 0 if the file format is unknown
|
||||
*/
|
||||
void JSONIOPlugin::GetExportMaskCapability(QString & format, int & capability, int & defaultBits) const
|
||||
{
|
||||
capability = 0;
|
||||
|
||||
if (format.toUpper() == tr("JSON"))
|
||||
{
|
||||
// vertex
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTNORMAL;
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTCOLOR;
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;
|
||||
|
||||
// face
|
||||
//capability |= vcg::tri::io::Mask::IOM_FACECOLOR;
|
||||
//capability |= vcg::tri::io::Mask::IOM_FACENORMAL;
|
||||
|
||||
// wedge
|
||||
//capability |= vcg::tri::io::Mask::IOM_WEDGTEXCOORD;
|
||||
//capability |= vcg::tri::io::Mask::IOM_WEDGNORMAL;
|
||||
//capability |= vcg::tri::io::Mask::IOM_WEDGCOLOR;
|
||||
|
||||
defaultBits = capability;
|
||||
}
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(JSONIOPlugin)
|
||||
/****************************************************************************
|
||||
* MeshLab o o *
|
||||
* An extendible mesh processor o o *
|
||||
* _ O _ *
|
||||
* Copyright(C) 2005, 2006 \/)\/ *
|
||||
* Visual Computing Lab /\/| *
|
||||
* ISTI - Italian National Research Council | *
|
||||
* \ *
|
||||
* All rights reserved. *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
||||
* for more details. *
|
||||
* *
|
||||
****************************************************************************/
|
||||
#include "io_json.h"
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
#include <vcg/complex/algorithms/attribute_seam.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
|
||||
JSONIOPlugin::JSONIOPlugin(void) : MeshIOInterface()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
JSONIOPlugin::~JSONIOPlugin(void)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
bool JSONIOPlugin::open(const QString & formatName, const QString & fileName, MeshModel & m, int & mask, const RichParameterSet & parlst, vcg::CallBackPos * cb, QWidget * parent)
|
||||
{
|
||||
(void)formatName;
|
||||
(void)fileName;
|
||||
(void)m;
|
||||
(void)mask;
|
||||
(void)parlst;
|
||||
(void)cb;
|
||||
(void)parent;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JSONIOPlugin::save(const QString & formatName,const QString & fileName, MeshModel & m, const int mask, const RichParameterSet & par, vcg::CallBackPos * cb, QWidget * parent)
|
||||
{
|
||||
(void)par;
|
||||
(void)cb;
|
||||
(void)parent;
|
||||
vcg::tri::Allocator<CMeshO>::CompactVertexVector(m.cm);
|
||||
vcg::tri::Allocator<CMeshO>::CompactFaceVector(m.cm);
|
||||
|
||||
const size_t maxValuesPerLine = 10; // must be > 0
|
||||
|
||||
if (formatName.toUpper() != tr("JSON")) return false;
|
||||
|
||||
const bool hasPerVertexPosition = true;
|
||||
const bool hasPerVertexNormal = ((mask & vcg::tri::io::Mask::IOM_VERTNORMAL) != 0) && m.hasDataMask(MeshModel::MM_VERTNORMAL);
|
||||
const bool hasPerVertexColor = ((mask & vcg::tri::io::Mask::IOM_VERTCOLOR) != 0) && m.hasDataMask(MeshModel::MM_VERTCOLOR);
|
||||
const bool hasPerVertexTexCoord = ((mask & vcg::tri::io::Mask::IOM_VERTTEXCOORD) != 0) && m.hasDataMask(MeshModel::MM_VERTTEXCOORD);
|
||||
|
||||
const CMeshO & cm = m.cm;
|
||||
|
||||
const std::string filename = QFile::encodeName(fileName).constData();
|
||||
|
||||
std::ofstream os(filename.c_str());
|
||||
if (!os.is_open()) return false;
|
||||
|
||||
os << "{" << std::endl;
|
||||
|
||||
os << " \"version\" : \"0.1.0\"," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"comment\" : \"Generated by MeshLab JSON Exporter\"," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"id\" : 1," << std::endl;
|
||||
os << " \"name\" : \"mesh\"," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"vertices\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
bool prevDone = false;
|
||||
|
||||
if (hasPerVertexPosition)
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"position_buffer\"," << std::endl;
|
||||
os << " \"size\" : 3," << std::endl;
|
||||
os << " \"type\" : \"float32\"," << std::endl;
|
||||
os << " \"normalized\" : false," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::CoordType & p = cm.vert[it].cP();
|
||||
os << p[0] << ", " << p[1] << ", " << p[2];
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::CoordType & p = cm.vert[it].cP();
|
||||
os << ", " << p[0] << ", " << p[1] << ", " << p[2];
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (hasPerVertexNormal)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
os << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"normal_buffer\"," << std::endl;
|
||||
os << " \"size\" : 3," << std::endl;
|
||||
os << " \"type\" : \"float32\"," << std::endl;
|
||||
os << " \"normalized\" : false," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::NormalType & n = cm.vert[it].cN();
|
||||
os << n[0] << ", " << n[1] << ", " << n[2];
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::NormalType & n = cm.vert[it].cN();
|
||||
os << ", " << n[0] << ", " << n[1] << ", " << n[2];
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (hasPerVertexColor)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
os << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"color_buffer\"," << std::endl;
|
||||
os << " \"size\" : 4," << std::endl;
|
||||
os << " \"type\" : \"uint8\"," << std::endl;
|
||||
os << " \"normalized\" : true," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::ColorType & c = cm.vert[it].cC();
|
||||
os << int(c[0]) << ", " << int(c[1]) << ", " << int(c[2]) << ", " << int(c[3]);
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::ColorType & c = cm.vert[it].cC();
|
||||
os << ", " << int(c[0]) << ", " << int(c[1]) << ", " << int(c[2]) << ", " << int(c[3]);
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (hasPerVertexTexCoord)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
os << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"texcoord_buffer\"," << std::endl;
|
||||
os << " \"size\" : 2," << std::endl;
|
||||
os << " \"type\" : \"float32\"," << std::endl;
|
||||
os << " \"normalized\" : false," << std::endl;
|
||||
os << " \"values\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
size_t it = 0;
|
||||
const size_t sz = cm.vert.size();
|
||||
while (it < sz)
|
||||
{
|
||||
const size_t n = std::min(it + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
const CMeshO::VertexType::TexCoordType & t = cm.vert[it].cT();
|
||||
os << t.P()[0] << ", " << t.P()[1];
|
||||
it++;
|
||||
}
|
||||
for (; it<n; ++it)
|
||||
{
|
||||
const CMeshO::VertexType::TexCoordType & t = cm.vert[it].cT();
|
||||
os << ", " << t.P()[0] << ", " << t.P()[1];
|
||||
}
|
||||
if (it <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }";
|
||||
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (prevDone)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
os << " ]," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"connectivity\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
if ((m.cm.vn > 0) && (m.cm.fn > 0))
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"triangles\"," << std::endl;
|
||||
os << " \"mode\" : \"triangles_list\"," << std::endl;
|
||||
os << " \"indexed\" : true," << std::endl;
|
||||
os << " \"indexType\" : \"uint32\"," << std::endl;
|
||||
os << " \"indices\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
{
|
||||
const CMeshO::VertexType * v0 = &(m.cm.vert[0]);
|
||||
|
||||
size_t k = 0;
|
||||
size_t c = 0;
|
||||
const size_t sz = cm.fn;
|
||||
while (c < sz)
|
||||
{
|
||||
const size_t n = std::min(c + maxValuesPerLine, sz);
|
||||
if (n > 0)
|
||||
{
|
||||
os << " ";
|
||||
{
|
||||
while (cm.face[k].IsD()) k++;
|
||||
const CMeshO::FaceType & f = cm.face[k];
|
||||
os << int(f.cV(0) - v0) << ", " << int(f.cV(1) - v0) << ", " << int(f.cV(2) - v0);
|
||||
c++;
|
||||
k++;
|
||||
}
|
||||
for (; c<n; ++c)
|
||||
{
|
||||
while (cm.face[k].IsD()) k++;
|
||||
const CMeshO::FaceType & f = cm.face[k];
|
||||
os << ", " << int(f.cV(0) - v0) << ", " << int(f.cV(1) - v0) << ", " << int(f.cV(2) - v0);
|
||||
k++;
|
||||
}
|
||||
if (c <= (sz - 1))
|
||||
{
|
||||
os << ",";
|
||||
}
|
||||
os << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
os << " ]" << std::endl;
|
||||
os << " }" << std::endl;
|
||||
}
|
||||
|
||||
os << " ]," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"mapping\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
if ((m.cm.vn > 0) && (m.cm.fn > 0))
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"name\" : \"standard\"," << std::endl;
|
||||
os << " \"primitives\" : \"triangles\"," << std::endl;
|
||||
os << " \"attributes\" :" << std::endl;
|
||||
os << " [" << std::endl;
|
||||
|
||||
prevDone = false;
|
||||
if (hasPerVertexPosition)
|
||||
{
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"position_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"position\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
if (hasPerVertexNormal)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"normal_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"normal\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
if (hasPerVertexColor)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"color_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"color\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
if (hasPerVertexTexCoord)
|
||||
{
|
||||
if (prevDone)
|
||||
{
|
||||
os << "," << std::endl;
|
||||
}
|
||||
os << " {" << std::endl;
|
||||
os << " \"source\" : \"texcoord_buffer\"," << std::endl;
|
||||
os << " \"semantic\" : \"texcoord\"," << std::endl;
|
||||
os << " \"set\" : 0" << std::endl;
|
||||
os << " }";
|
||||
prevDone = true;
|
||||
}
|
||||
|
||||
if (prevDone)
|
||||
{
|
||||
os << std::endl;
|
||||
}
|
||||
|
||||
os << " ]" << std::endl;
|
||||
os << " }" << std::endl;
|
||||
}
|
||||
os << " ]," << std::endl;
|
||||
os << std::endl;
|
||||
|
||||
os << " \"custom\" : null" << std::endl;
|
||||
|
||||
os << "}" << std::endl;
|
||||
|
||||
os.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
returns the list of the file's type which can be imported
|
||||
*/
|
||||
QList<MeshIOInterface::Format> JSONIOPlugin::importFormats(void) const
|
||||
{
|
||||
QList<Format> formatList;
|
||||
//formatList << Format("JavaScript JSON", tr("JSON"));
|
||||
return formatList;
|
||||
}
|
||||
|
||||
/*
|
||||
returns the list of the file's type which can be exported
|
||||
*/
|
||||
QList<MeshIOInterface::Format> JSONIOPlugin::exportFormats(void) const
|
||||
{
|
||||
QList<Format> formatList;
|
||||
formatList << Format("JavaScript JSON", tr("JSON"));
|
||||
return formatList;
|
||||
}
|
||||
|
||||
/*
|
||||
returns the mask on the basis of the file's type.
|
||||
otherwise it returns 0 if the file format is unknown
|
||||
*/
|
||||
void JSONIOPlugin::GetExportMaskCapability(QString & format, int & capability, int & defaultBits) const
|
||||
{
|
||||
capability = 0;
|
||||
|
||||
if (format.toUpper() == tr("JSON"))
|
||||
{
|
||||
// vertex
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTNORMAL;
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTCOLOR;
|
||||
capability |= vcg::tri::io::Mask::IOM_VERTTEXCOORD;
|
||||
|
||||
// face
|
||||
//capability |= vcg::tri::io::Mask::IOM_FACECOLOR;
|
||||
//capability |= vcg::tri::io::Mask::IOM_FACENORMAL;
|
||||
|
||||
// wedge
|
||||
//capability |= vcg::tri::io::Mask::IOM_WEDGTEXCOORD;
|
||||
//capability |= vcg::tri::io::Mask::IOM_WEDGNORMAL;
|
||||
//capability |= vcg::tri::io::Mask::IOM_WEDGCOLOR;
|
||||
|
||||
defaultBits = capability;
|
||||
}
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(JSONIOPlugin)
|
||||
|
||||
@ -31,20 +31,11 @@
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/selection.h>
|
||||
#include <vcg/complex/trimesh/update/position.h>
|
||||
#include <vcg/complex/trimesh/update/color.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <vcg/complex/trimesh/clean.h>
|
||||
#include <vcg/complex/trimesh/append.h>
|
||||
|
||||
// debug, to be removed
|
||||
#include <wrap/io_trimesh/export_ply.h>
|
||||
|
||||
#include <vcg/complex/trimesh/create/platonic.h>
|
||||
#include <vcg/complex/trimesh/create/marching_cubes.h>
|
||||
#include <vcg/complex/trimesh/create/mc_trivial_walker.h>
|
||||
#include <vcg/complex/append.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
#include <vcg/complex/algorithms/create/marching_cubes.h>
|
||||
#include <vcg/complex/algorithms/create/mc_trivial_walker.h>
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
@ -697,4 +688,4 @@ vcg::Color4b PDBIOPlugin::getAtomColor(const char* atomicElementCharP)
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,8 +29,6 @@
|
||||
|
||||
#include "io_u3d.h"
|
||||
#include <common/pluginmanager.h>
|
||||
//#include <vcg/complex/trimesh/update/normal.h>
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
|
||||
#include <wrap/io_trimesh/export.h>
|
||||
#include <wrap/io_trimesh/io_mask.h>
|
||||
|
||||
@ -78,8 +78,7 @@
|
||||
#define IMPORTERX3D
|
||||
|
||||
#include<QtXml>
|
||||
#include <vcg/complex/trimesh/allocate.h>
|
||||
#include <vcg/complex/trimesh/create/platonic.h>
|
||||
#include <vcg/complex/algorithms/create/platonic.h>
|
||||
#include <wrap/gl/glu_tesselator.h>
|
||||
|
||||
#include "util_x3d.h"
|
||||
|
||||
@ -27,8 +27,6 @@
|
||||
|
||||
|
||||
#include "io_x3d.h"
|
||||
#include <vcg/complex/trimesh/update/bounding.h>
|
||||
#include <vcg/complex/trimesh/update/normal.h>
|
||||
|
||||
#include "import_x3d.h"
|
||||
#include "export_x3d.h"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user