我正在尝试在visual studio 2012中运行以下.cpp代码。
#define _CRT_SECURE_NO_DEPRECATE
#include <math.h>
#include <list>
#include <iostream>
#include "mesh.h"
#include "mesh.cpp"
#include "iterators.h"
#include "Point.h"
#include "HalfEdge.h"
#include "HalfEdge.cpp"
#include "Edge.h"
#include "Edge.cpp"
#include "Vertex.h"
#include "Vertex.cpp"
#include "Face.h"
#include <sstream>
#include <string.h>
#include <algorithm>
using namespace MeshLib;
using namespace std;
int main( int argc, char * argv[] )
{
if( strcmp( argv[1], "-test" ) == 0 )
{
for(int k=0;k<4;k++){//making subdivision 4 times
CMesh mesh, mesh_new;
//MeshLib::CMesh mesh;
if(k==0)
mesh.read_m("bird_subdivision.m");
//read into mesh (triangulated surface with format .m)
else
mesh.read_m("temp.m");
//creating new mesh for storing the result temporarily.
//mesh.write_m("bird_subdivision_2.m");
int max_id=-1;
int max_fid=0;
int intial_vertex_count=0;
//vertex iterator
for( MeshVertexIterator viter( &mesh ); !viter.end(); viter ++ )
//vertex iterator; go through each vertex of the mesh
{
CVertex *pV = *viter;
//updating the vertex id
if(max_id < pV->id())
{
max_id=pV->id();
}
CMesh::tVertex tv=mesh_new.createVertex(pV->id());
tv->point() = pV->point();
}//end of vertex iterator
//write edge iterator
vector<int> new_Id ;
vector<CMesh::tVertex> new_Vertex;
int eid=0;
for(MeshEdgeIterator eiter(&mesh ) ; !eiter.end();eiter++)
{
//std::cout<<"inside:MeshEdgeiterator"<<"\n";
CEdge *ne = *eiter;//creating object for Edge
eid++;
ne->createId(eid);
CVertex *cv1=ne->halfedge(0)->target();
//CVertex *cv2=ne->halfedge(0)->ccw_rotate_about_target()->target();
CVertex *cv2=ne->halfedge(0)->he_next()->target();
CVertex *cv3=ne->halfedge(1)->target();
//CVertex *cv4 = ne->halfedge(1)->ccw_rotate_about_target()->target();
CVertex *cv4 = ne->halfedge(1)->he_next()->target();
//getting the new vertex from the above 4 vertices
//coordinates for veretx cv1
double x1=cv1->point().v[0];
double y1=cv1->point().v[1];
double z1=cv1->point().v[2];
//coordinates for veretx cv2
double x2=cv2->point().v[0];
double y2=cv2->point().v[1];
double z2=cv2->point().v[2];
//coordinates for veretx cv3
double x3=cv3->point().v[0];
double y3=cv3->point().v[1];
double z3=cv3->point().v[2];
//coordinates for veretx cv3
double x4=cv4->point().v[0];
double y4=cv4->point().v[1];
double z4=cv4->point().v[2];
//coordinates for point
double xa=(3*x1+x2+3*x3+x4)/8;
double ya=(3*y1+y2+3*y3+y4)/8;
double za=(3*z1+z2+3*z3+z4)/8;
//getting the edge pair
//if(ne->halfedge(0)->target()>ne->halfedge(0)->source())
//cout<<s<<"\n";
//creating new vertex
CPoint *point = new CPoint(xa,ya,za);
CVertex *tv= mesh_new.createVertex(++max_id);
tv->point()=*point;
tv->id()=max_id;
new_Id.push_back(eid);
new_Vertex.push_back(tv);
}//end of edge iterator;
//write a face iterator
for(MeshFaceIterator fiter(&mesh); !fiter.end();fiter++)
{
CFace *cface=*fiter;
CVertex *cv1,*cv2,*cv3;
//get the vertex from face
cv1 = cface->halfedge()->target();
cv2= cface->halfedge()->he_next()->target();
cv3 = cface->halfedge()->he_next()->he_next()->target();
int e1 = cface->halfedge()->edge()->getId();
int e2= cface->halfedge()->he_next()->edge()->getId();
int e3 = cface->halfedge()->he_next()->he_next()->edge()->getId();
int id1=cv1->id();
int id2=cv2->id();
int id3=cv3->id();
//getting three new vertices
CVertex *tv12, *tv13, *tv23;
tv12 = new_Vertex[find(new_Id.begin(), new_Id.end(), e2) - new_Id.begin()];
tv13 = new_Vertex[find(new_Id.begin(), new_Id.end(), e1) - new_Id.begin()];
tv23 = new_Vertex[find(new_Id.begin(), new_Id.end(), e3) - new_Id.begin()];
//creating four faces in every face that already exists
CVertex *v1[3];
v1[0]=mesh_new.idVertex(id1);
v1[1]=tv12;
v1[2]=tv13;
mesh_new.createFace(v1,++max_fid);
CVertex *v2[3];
v2[0]=tv13;
v2[1]=tv12;
v2[2]=tv23;
mesh_new.createFace(v2,++max_fid);
CVertex *v3[3];
v3[0]=tv23;
v3[1]=tv12;
v3[2]=mesh_new.idVertex(id2);
mesh_new.createFace(v3,++max_fid);
CVertex *v4[3];
v4[0]=tv13;
v4[1]=tv23;
v4[2]=mesh_new.idVertex(id3);
mesh_new.createFace(v4,++max_fid);
}
if(k<3)
{
int count=0;
//vertex iterator
for( MeshVertexIterator viter1( &mesh ); !viter1.end(); viter1 ++ )
//vertex iterator; go through each vertex of the mesh
{
CVertex *pV1 = *viter1;
count++;
}//end of vertex iterator
mesh_new.write_m("temp.m"); //write the mesh
cout<<"Total no of vertices after iteraton"<<k+1<<"="<<count<<"\n";
}
else
{
int count=0;
//vertex iterator
for( MeshVertexIterator viter1( &mesh ); !viter1.end(); viter1 ++ )
//vertex iterator; go through each vertex of the mesh
{
CVertex *pV1 = *viter1;
count++;
}//end of vertex iterator
mesh_new.write_m("result.m");
cout<<"Total no of vertices after iteraton"<<k+1<<"="<<count<<"\n";
}
}
}
//to read the character from the key board, here our main intention is
to keep the output screen until we enter a character
getchar();
return 0;
}
当我构建代码时,我得到以下输出:
1&gt; ------构建开始:项目:Modelrepair,配置:调试x64 ------ ==========构建:1成功,0失败,0最新,0跳过==========
然后,当我尝试运行代码时,它表示项目已过期,您是否希望构建它。当我单击是时,它会出现以下错误:
无法启动程序&#34; C:\ Users \ Hemanth \ documents \ VisualStudio 2012 \ Projects \ Modelrepair \ x64 \ Debug \ Modelreair.exe&#34;
找不到指定的文件。
我不明白问题所在。请帮忙。