taiya / dgp

Digital Geometry Processing - Fall 2016 - University of Victoria
38 stars 11 forks source link

General questions about usage of OpenGP #2

Closed xuzheng0927 closed 7 years ago

xuzheng0927 commented 7 years ago

My question is how to get the key values of such objects: “SurfaceMesh::Vertex_property vpoints;”. Although I can get the number of vertices using cloud.n_vertices(), it doesn't seems to be an standard array, i.e., I cannot access the vertex by vpoints[int i]. Similarly I need to assign normal values to property vnormal, then I also need a way to modify the value by a key.

Another question is can I update the cloud's property using the new vnormal? If yes what would be the usage?

nlguillemot commented 7 years ago

Vpoints and other vertex properties are associated to a vertex, so you index them using a vertex. (SurfaceMesh::Vertex). You can construct a SurfaceMesh::Vertex from an int ID, then use that Vertex as a key.

Could you explain more about your second question? I don't fully understand it.

xuzheng0927 commented 7 years ago

My second question is how to assign a set of normal values to a SurfaceMesh. For example:

// SurfaceMesh cloud; vpoints = cloud.get_vertex_property<Vec3>("v:point"); vnormals = cloud.get_vertex_property<Vec3>("v:normal");

Then because we want to use eigenvalues and eigenvectors to compute the normals, I change vnormals to my computed values (the original values are discarded). Then I want to assign this vnormals back to cloud. How could I do this?

xuzheng0927 commented 7 years ago

@nlguillemot It seems get_vertex_property gives a pointer value, kind of. I simply changed vnormal's values and I saw the cloud's normal values changed accordingly. I think this issue is solved for now.

taiya commented 7 years ago
for(Vertex vit: mesh.vertices()){
   vnormals[vit] = Vec3(....);  ///< new normal 
}
xuzheng0927 commented 7 years ago

@ataiya Thanks! I'm closing this issue.