Improving Doxygen Documentation

This commit is contained in:
Paolo Cignoni 2014-11-04 10:01:48 +00:00
parent 8380ea37a0
commit fa8690e457
1 changed files with 16 additions and 9 deletions

View File

@ -26,7 +26,7 @@
\brief the minimal example of using the attributes
Attributes are a simple mechanism to associate user-defined 'attributes' to the simplicies and to the mesh.
\ref attributes for more Details
See the page '\ref attributes' for more details.
*/
#include<vcg/complex/complex.h>
@ -44,25 +44,29 @@ class MyMesh : public vcg::tri::TriMesh< std::vector<MyVertex>, std::vector<MyFa
int main()
{
MyMesh m;
//! [Adding an attribute]
// add a per-vertex attribute with type float named "Irradiance"
MyMesh::PerVertexAttributeHandle<float> named_hv = vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<float> (m,std::string("Irradiance"));
//! [Adding an attribute]
// add a per-vertex attribute with type float named "Radiosity"
// add a per-vertex attribute with type float named "Radiosity"
vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<float> (m,std::string("Radiosity"));
// add a per-vertex attribute with type bool and no name specified
MyMesh::PerVertexAttributeHandle<bool> anon_hv = vcg::tri::Allocator<MyMesh>:: GetPerVertexAttribute<bool> (m);
// add a per-face attribute with type bool and no name specified
MyMesh::PerFaceAttributeHandle<bool> anon_hf = vcg::tri::Allocator<MyMesh>:: GetPerFaceAttribute<bool> (m);
MyMesh::VertexIterator vi; int i = 0;
for(vi = m.vert.begin(); vi != m.vert.end(); ++vi,++i){
//! [Using an attribute]
MyMesh::VertexIterator vi; int i;
for(i=0, vi = m.vert.begin(); vi != m.vert.end(); ++vi,++i){
named_hv[vi] = 1.0f; // [] operator takes a iterator
named_hv[*vi] = 1.0f; // or a MyMesh::VertexType object
named_hv[&*vi]= 1.0f; // or a pointer to it
named_hv[i] = 1.0f; // or an integer index
}
//! [Using an attribute]
vcg::tri::Allocator<MyMesh>::ClearPerVertexAttribute<float>(m,named_hv);
@ -72,17 +76,20 @@ int main()
// obtain another handle of a previously attribute
MyMesh::PerVertexAttributeHandle<float> ret_hv = vcg::tri::Allocator<MyMesh>:: FindPerVertexAttribute<float>(m,"Radiosity");
//! [Per Mesh attribute]
// you can also have PerMesh attributes
MyMesh::PerMeshAttributeHandle<int> hm = vcg::tri::Allocator<MyMesh>:: GetPerMeshAttribute<int> (m,std::string("ADummyIntegerAttribute"));
// PerMesh attributes are accessed directly using the handle itself
hm() = 10;
//! [Per Mesh attribute]
//! [Deleting an attribute]
// delete an attribute by name
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,"Radiosity");
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m, "Radiosity");
// delete an attribute by handle
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m,anon_hv);
vcg::tri::Allocator<MyMesh>::DeletePerVertexAttribute(m, anon_hv);
//! [Deleting an attribute]
bool res;
res = vcg::tri::Allocator<MyMesh>::IsValidHandle(m,named_hv); printf("Is Valid: %s\n",res?"Yes":"No");