int main() { // declare a map to handle the mesh MAP myMap; // add position attribute on vertices and get handler on it VertexAttribute<VEC3, MAP> positionAtt = myMap.addAttribute<VEC3, VERTEX, MAP>("position"); if (!positionAtt.isValid()) std::cerr << "impossible to create an attribute with name position (already used ?)"<< std::endl; // create a topo grid of 2x2 squares Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, 2, 2, true); // and embed it using position attribute grid.embedIntoGrid(positionAtt, 1.,1.,0.); VertexGeneric(myMap,positionAtt); // ATTRIBUTE DECLARATION // add an attribute of type float on orbit EDGE EdgeAttribute<float, MAP> lengthAtt = myMap.addAttribute<float, EDGE, MAP>("length"); if (!lengthAtt.isValid()) std::cerr << "impossible to create the attribute"<< std::endl; computeLengthEdges(myMap,positionAtt,lengthAtt); // add an attribute of type std::string on orbit FACE FaceAttribute<std::string, MAP> nameAtt = myMap.addAttribute<std::string, FACE, MAP>("name"); if (!nameAtt.isValid()) std::cerr << "impossible to create the attribute"<< std::endl; // for complex type use following template (function nameOfType not applicable) EdgeAttribute< NoTypeNameAttribute< std::vector<int> >, MAP> vectAtt = myMap.addAttribute< NoTypeNameAttribute< std::vector<int> >, EDGE, MAP>("vector_of_int"); if (!vectAtt.isValid()) std::cerr << "impossible to create the attribute"<< std::endl; Dart d = myMap.begin(); // define a vertex from a dart Vertex v(d); // define a face from a dart Face f(d); // ATTRIBUTE ACCESS // [] operator can take a dart, a cell (only same off attribute), or an unsigned inf // access to any attributes with darts std::cout << positionAtt[d]<< std::endl; nameAtt[d] = "Hello"; lengthAtt[myMap.phi1(d)] = 54.0f; std::vector<int> vi = {3,5,7,9,11}; vectAtt[d]= vi; vectAtt[d].push_back(11); // access to VertexAttribute with a Vertex std::cout << positionAtt[v]<< std::endl; // access to FaceAttribute with a Face std::cout << nameAtt[f]<< std::endl; // following line does not compile because of wrong cell type // std::cout << positionAtt[f]<< std::endl; // possible to bypass using dart access std::cout << positionAtt[f.dart]<< std::endl; // access with unsigned int is dangerous, index must be obtain with begin/end/next (see dumpAttribute) // COPY, REMOVE, SWAP // possible to have any number of attribute a same ORBIT VertexAttribute<VEC3, MAP> position2Att = myMap.addAttribute<VEC3, VERTEX, MAP>("other_position"); // copy of attribute of same type (linear complexity) myMap.copyAttribute(position2Att,positionAtt); positionAtt[v] += VEC3(0,0,1); computeNewPositions(myMap,positionAtt); dumpAttribute(positionAtt); //check if there is a Vertex Attribute of VEC3 named position => yes testVAbyNames(myMap,"position"); // remove the attribute myMap.removeAttribute(positionAtt); //check if there is a Vertex Attribute of VEC3 named position => no testVAbyNames(myMap,"position"); return 0; }