首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法在VS 2010中编译Vcg库

无法在VS 2010中编译Vcg库
EN

Stack Overflow用户
提问于 2014-02-02 18:11:00
回答 1查看 790关注 0票数 0

我试图用VCG库编写简单的程序,但在VS 2010中甚至无法通过编译。我从官方页面复制了示例文件,但是它在这一行中失败了。

代码语言:javascript
复制
class MyMesh    : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge>  > {};

编译器说Error 10 error C2248: 'vcg::tri::TriMesh<Container0,Container1,Container2>::TriMesh' : cannot access private member declared in class 'vcg::tri::TriMesh<Container0,Container1,Container2>'...meshes\meshprocessing.h 24 1 Meshes

这是我的完整网格处理程序。h代码

代码语言:javascript
复制
#include<vcg/complex/complex.h>
#include<vcg/complex/append.h>
#include<vcg/complex/algorithms/clean.h>
#include<vcg/complex/algorithms/hole.h>
#include<vcg/container/container_allocation_table.h>
#include<wrap\io_trimesh\import.h>
#include<wrap\io_trimesh\export.h>
#include <vector>
#include<iostream>

#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/PolygonMesh.h>

class MyVertex; class MyEdge; class MyFace;
struct MyUsedTypes : public vcg::UsedTypes<vcg::Use<MyVertex>   ::AsVertexType,
                                           vcg::Use<MyEdge>     ::AsEdgeType,
                                           vcg::Use<MyFace>     ::AsFaceType>{};
class MyVertex  : public vcg::Vertex< MyUsedTypes, vcg::vertex::Coord3f, vcg::vertex::Normal3f, vcg::vertex::BitFlags  >{};
class MyFace    : public vcg::Face<   MyUsedTypes, vcg::face::FFAdj,  vcg::face::VertexRef, vcg::face::BitFlags > {};
class MyEdge    : public vcg::Edge<   MyUsedTypes> {};
class MyMesh    : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFace> , std::vector<MyEdge>  > {};


class MeshProcessing
{
private:
    MyMesh mesh;
    pcl::PolygonMesh polygonMesh;
public:
    MeshProcessing(pcl::PolygonMesh mesh);
    MyMesh pclMeshtoVcgMesh();
    MyMesh reorientNormals(MyMesh mesh);
};

我不知道该怎么办,任何帮助都会很感激的。

编辑:

代码语言:javascript
复制
#include "MeshProcessing.h"

MeshProcessing::MeshProcessing(pcl::PolygonMesh mesh){
    MeshProcessing::polygonMesh=mesh;
}
MyMesh MeshProcessing::pclMeshtoVcgMesh(){
    MyMesh vcgMesh;
    int verticeCount;
    int triangleCount;

    pcl::PointCloud<pcl::PointXYZ> tmp_cloud; 
    pcl:fromROSMsg(polygonMesh.cloud,tmp_cloud);
    vcgMesh.Clear();
    verticeCount=tmp_cloud.width*tmp_cloud.height;
    vcg::tri::Allocator<MyMesh>::AddVertices(vcgMesh,verticeCount);
    for(int i=0;i<verticeCount;i++){
        vcgMesh.vert[i].P()=vcg::Point3f(tmp_cloud.points[i].x,tmp_cloud.points[i].y,tmp_cloud.points[i].z);

    }
    triangleCount=polygonMesh.polygons.size();
    vcg::tri::Allocator<MyMesh>::AddFaces(vcgMesh, triangleCount);
    for(int i=0;i<triangleCount;i++){
        vcgMesh.face[i].V(0)=&vcgMesh.vert[polygonMesh.polygons[i].vertices[0]];
        vcgMesh.face[i].V(1)=&vcgMesh.vert[polygonMesh.polygons[i].vertices[1]];
        vcgMesh.face[i].V(2)=&vcgMesh.vert[polygonMesh.polygons[i].vertices[2]];
    }
    printf("Input mesh  vn:%i fn:%i\n",vcgMesh.VN(),vcgMesh.FN());


    return vcgMesh;


}

MyMesh reorientNormals(MyMesh mesh){
    bool orientable=true;
    bool oriented=false;
    vcg::tri::Clean<MyMesh>::RemoveNonManifoldFace(mesh);
    vcg::tri::Clean<MyMesh>::OrientCoherentlyMesh(mesh,oriented,orientable);
    vcg::tri::UpdateNormal<MyMesh>::PerVertexNormalizedPerFace(mesh);
    vcg::tri::UpdateNormal<MyMesh>::PerVertexFromCurrentFaceNormal(mesh);

    return mesh;

}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-02 18:31:00

代码语言:javascript
复制
private:
     // TriMesh cannot be copied. Use Append (see vcg/complex/trimesh/append.h)\
     TriMesh operator =(const TriMesh &  m){assert(0);return TriMesh();}
     TriMesh(const TriMesh & ){}

在VCG库中从base.h复制/粘贴。这是一个标准的技巧,带有一个非常糟糕的错误信息,它激发了C++11的= delete同步。由于您是从TriMesh派生的,因此必须声明您自己的,因为编译器生成的编译器无法工作。修正:

代码语言:javascript
复制
class MyMesh : public yadayada...
{
private:
    MyMesh operator=(const TriMesh &) /* = delete */;
    MyMesh(const TriMesh &) /* = delete */;
};
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21514252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档