本文整理汇总了C++中SurfaceMesh::n_vertices方法的典型用法代码示例。如果您正苦于以下问题:C++ SurfaceMesh::n_vertices方法的具体用法?C++ SurfaceMesh::n_vertices怎么用?C++ SurfaceMesh::n_vertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SurfaceMesh
的用法示例。
在下文中一共展示了SurfaceMesh::n_vertices方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int /*argc*/, char** argv) {
SurfaceMesh mesh;
mesh.read(argv[1]);
float mean_valence = 0.0f;
unsigned int vertex_valence;
// instantiate iterator and circulators
SurfaceMesh::Vertex_iterator vit;
SurfaceMesh::Vertex_around_vertex_circulator vc, vc_end;
// loop over all vertices
for (vit = mesh.vertices_begin(); vit != mesh.vertices_end(); ++vit) {
// initialize circulators
vc = mesh.vertices(*vit);
vc_end = vc;
// reset counter
vertex_valence = 0;
// loop over all incident vertices
do {
++vertex_valence;
} while (++vc != vc_end);
// sum up vertex valences
mean_valence += vertex_valence;
}
mean_valence /= mesh.n_vertices();
std::cout << "mean valence: " << mean_valence << std::endl;
}
示例2: main
int main(void)
{
// instantiate a SurfaceMesh object
SurfaceMesh mesh;
// instantiate 4 vertex handles
SurfaceMesh::Vertex v0,v1,v2,v3;
// add 4 vertices
v0 = mesh.add_vertex(Vec3(0,0,0));
v1 = mesh.add_vertex(Vec3(1,0,0));
v2 = mesh.add_vertex(Vec3(0,1,0));
v3 = mesh.add_vertex(Vec3(0,0,1));
// add 4 triangular faces
mesh.add_triangle(v0,v1,v3);
mesh.add_triangle(v1,v2,v3);
mesh.add_triangle(v2,v0,v3);
mesh.add_triangle(v0,v2,v1);
std::cout << "vertices: " << mesh.n_vertices() << std::endl;
std::cout << "edges: " << mesh.n_edges() << std::endl;
std::cout << "faces: " << mesh.n_faces() << std::endl;
return 0;
}
示例3: main
int main(int argc, char** argv){
if(argc!=3){
cout << "usage:" << endl << "isoremesh bunny.obj remeshed.obj" << endl;
return EXIT_FAILURE;
}
std::string input(argv[1]);
std::string output(argv[2]);
///--- Load mesh
SurfaceMesh mesh;
mesh.read(input);
if(mesh.n_vertices()==0){
cout << "Input mesh has 0 vertices" << endl;
return EXIT_FAILURE;
}
///--- Remesher is only for triangulations!
mesh.triangulate();
///--- Compute bounding box
Scalar bbox_diag_length = bounding_box(mesh).diagonal().norm();
cout << "#vertices: " << mesh.n_vertices() << endl;
cout << "bbox_diag_length: " << bbox_diag_length << endl;
///--- Perform remeshing
IsotropicRemesher remesher(mesh);
remesher.num_iterations = 10;
remesher.sharp_feature_deg = 45;
remesher.longest_edge_length = 0.02*bbox_diag_length;
remesher.keep_short_edges = false;
remesher.reproject_to_surface = true;
remesher.myout = &std::cout; ///< print output to...
remesher.execute();
///--- Write to file
mesh.write(output);
return EXIT_SUCCESS;
}
示例4: main
int main(int argc, char** argv) {
std::string file = (argc>1) ? argv[1] : "bunny.obj";
SurfaceMesh mesh;
bool success = mesh.read(file);
CHECK(success);
auto points = mesh.get_vertex_property<Vec3>("v:point");
Vec3 p(0,0,0);
for (auto vit: mesh.vertices())
p += points[vit];
p /= mesh.n_vertices();
std::cout << "barycenter: " << p << std::endl;
}
示例5: main
int main(int /*argc*/, char** argv)
{
SurfaceMesh mesh;
mesh.read(argv[1]);
// get (pre-defined) property storing vertex positions
SurfaceMesh::Vertex_property<Vec3> points = mesh.get_vertex_property<Vec3>("v:point");
SurfaceMesh::Vertex_iterator vit, vend = mesh.vertices_end();
Vec3 p(0,0,0);
for (vit = mesh.vertices_begin(); vit != vend; ++vit)
{
// access point property like an array
p += points[*vit];
}
p /= mesh.n_vertices();
std::cout << "barycenter: " << p << std::endl;
}
示例6: init
/// OpenGL initialization
void init() {
///----------------------- DATA ----------------------------
auto vpoints = mesh.get_vertex_property<Vec3>("v:point");
auto vnormals = mesh.get_vertex_property<Vec3>("v:normal");
assert(vpoints);
assert(vnormals);
///---------------------- TRIANGLES ------------------------
triangles.clear();
for(auto f: mesh.faces())
for(auto v: mesh.vertices(f))
triangles.push_back(v.idx());
///---------------------- OPENGL GLOBALS--------------------
glClearColor(1.0f, 1.0f, 1.0f, 0.0f); ///< background
glEnable(GL_DEPTH_TEST); // Enable depth test
// glDisable(GL_CULL_FACE); // Cull back-facing
/// Compile the shaders
programID = load_shaders("vshader.glsl", "fshader.glsl");
if(!programID) exit(EXIT_FAILURE);
glUseProgram( programID );
///---------------------- CAMERA ----------------------------
{
typedef Eigen::Vector3f vec3;
typedef Eigen::Matrix4f mat4;
update_projection_matrix();
/// Define the view matrix (camera extrinsics)
vec3 cam_pos(0,0,5);
vec3 cam_look(0,0,-1); /// Remember: GL swaps viewdir
vec3 cam_up(0,1,0);
view = OpenGP::lookAt(cam_pos, cam_look, cam_up);
// cout << view << endl;
/// Define the modelview matrix
model = mat4::Identity();
// cout << model << endl;
/// Set initial matrices
set_uniform_matrix(programID,"M",model); ///< to get world coordinates
set_uniform_matrix(programID,"MV",view*model); ///< to get camera coordinates
set_uniform_matrix(programID,"MVP",projection*view*model); ///< to get clip coordinates
}
///---------------------- LIGHT -----------------------------
{
Vec3 light_dir(0,0,1);
set_uniform_vector(programID,"LDIR",light_dir); ///< to get camera coordinates
}
///---------------------- VARRAY ----------------------------
{
GLuint VertexArrayID;
glGenVertexArrays(1, &VertexArrayID);
glBindVertexArray(VertexArrayID);
}
///---------------------- BUFFERS ----------------------------
GLuint vertexbuffer, normalbuffer, trianglebuffer;
{
/// Load mesh vertices
glGenBuffers(1, &vertexbuffer);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glBufferData(GL_ARRAY_BUFFER, mesh.n_vertices() * sizeof(Vec3), vpoints.data(), GL_STATIC_DRAW);
/// Load mesh normals
glGenBuffers(1, &normalbuffer);
glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
glBufferData(GL_ARRAY_BUFFER, mesh.n_vertices() * sizeof(Vec3), vnormals.data(), GL_STATIC_DRAW);
/// Triangle indexes buffer
glGenBuffers(1, &trianglebuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, trianglebuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, triangles.size() * sizeof(unsigned int), &triangles[0], GL_STATIC_DRAW);
}
///---------------------- SHADER ATTRIBUTES ----------------------------
{
/// Vertex positions in shader variable "vposition"
GLuint vposition = glGetAttribLocation(programID, "vposition");
glEnableVertexAttribArray(vposition);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(vposition, 3, GL_FLOAT, DONT_NORMALIZE, ZERO_STRIDE, ZERO_BUFFER_OFFSET);
/// Vertex normals in in shader variable "vnormal"
GLuint vnormal = glGetAttribLocation(programID, "vnormal");
glEnableVertexAttribArray(vnormal);
glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
glVertexAttribPointer(vnormal, 3, GL_FLOAT, DONT_NORMALIZE, ZERO_STRIDE, ZERO_BUFFER_OFFSET);
}
}