Added function for loading tri mes using istringstream
This commit is contained in:
parent
398df24056
commit
f531b16b19
|
@ -6,6 +6,9 @@
|
||||||
#include <wrap/io_trimesh/export.h>
|
#include <wrap/io_trimesh/export.h>
|
||||||
#include <wrap/io_trimesh/import.h>
|
#include <wrap/io_trimesh/import.h>
|
||||||
//#include <wrap/nanoply/include/nanoplyWrapper.hpp>
|
//#include <wrap/nanoply/include/nanoplyWrapper.hpp>
|
||||||
|
#ifdef POLYSCOPE_DEFINED
|
||||||
|
#include <polyscope/curve_network.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
bool VCGTriMesh::load(const std::filesystem::__cxx11::path &meshFilePath) {
|
bool VCGTriMesh::load(const std::filesystem::__cxx11::path &meshFilePath) {
|
||||||
assert(std::filesystem::exists(meshFilePath));
|
assert(std::filesystem::exists(meshFilePath));
|
||||||
|
@ -36,6 +39,32 @@ bool VCGTriMesh::load(const std::filesystem::__cxx11::path &meshFilePath) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VCGTriMesh::load(std::istringstream &offInputStream)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
// assert(plyFileHasAllRequiredFields(plyFilename));
|
||||||
|
// Load the ply file
|
||||||
|
int mask = 0;
|
||||||
|
mask |= vcg::tri::io::Mask::IOM_VERTCOORD;
|
||||||
|
mask |= vcg::tri::io::Mask::IOM_VERTNORMAL;
|
||||||
|
mask |= vcg::tri::io::Mask::IOM_VERTCOLOR;
|
||||||
|
mask |= vcg::tri::io::Mask::IOM_EDGEINDEX;
|
||||||
|
const bool openingFromStreamErrorCode
|
||||||
|
= vcg::tri::io::ImporterOFF<VCGTriMesh>::OpenStream(*this, offInputStream, mask);
|
||||||
|
if (openingFromStreamErrorCode != 0) {
|
||||||
|
std::cerr << "Error reading from stream:"
|
||||||
|
<< vcg::tri::io::ImporterOFF<VCGTriMesh>::ErrorMsg(openingFromStreamErrorCode)
|
||||||
|
<< std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
vcg::tri::UpdateTopology<VCGTriMesh>::AllocateEdge(*this);
|
||||||
|
vcg::tri::UpdateTopology<VCGTriMesh>::FaceFace(*this);
|
||||||
|
vcg::tri::UpdateTopology<VCGTriMesh>::VertexFace(*this);
|
||||||
|
vcg::tri::UpdateTopology<VCGTriMesh>::VertexEdge(*this);
|
||||||
|
vcg::tri::UpdateNormal<VCGTriMesh>::PerVertexNormalized(*this);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Eigen::MatrixX3d VCGTriMesh::getVertices() const
|
Eigen::MatrixX3d VCGTriMesh::getVertices() const
|
||||||
{
|
{
|
||||||
// vcg::tri::Allocator<VCGTriMesh>::CompactVertexVector(m);
|
// vcg::tri::Allocator<VCGTriMesh>::CompactVertexVector(m);
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
VCGTriMesh();
|
VCGTriMesh();
|
||||||
VCGTriMesh(const std::string &filename);
|
VCGTriMesh(const std::string &filename);
|
||||||
bool load(const std::filesystem::path &meshFilePath) override;
|
bool load(const std::filesystem::path &meshFilePath) override;
|
||||||
|
bool load(std::istringstream &offInputStream);
|
||||||
Eigen::MatrixX3d getVertices() const;
|
Eigen::MatrixX3d getVertices() const;
|
||||||
Eigen::MatrixX3i getFaces() const;
|
Eigen::MatrixX3i getFaces() const;
|
||||||
bool save(const std::string plyFilename);
|
bool save(const std::string plyFilename);
|
||||||
|
|
Loading…
Reference in New Issue