mlivesu / cinolib

A generic programming header only C++ library for processing polygonal and polyhedral meshes
MIT License
897 stars 98 forks source link

Custom data in Tetmesh #156

Closed AISavinov closed 1 year ago

AISavinov commented 1 year ago

Hi! Is there a way to associate some metadata with tetrahedrons in Tetmesh? E.g I have 2 Tetmeshes: изображение For each tetrahedron in tetmesh1 I need to store the same thermal conductivity which equals X, and for each tetrahedron in tetmesh2 I need to store the same thermal conductivity which equals Y.

mlivesu commented 1 year ago

absolutely! Each mesh element has a default set of attributes and flags which can be extended arbitrarily. In your case, since you want to extend attributes for tets, the code would be like


    // per element attributes. I am using the standard ones for everything but polyhedra (tets in your case)
    using  M = Mesh_std_attributes;
    using  V = Vert_std_attributes;
    using  E = Edge_std_attributes;
    using  F = Polygon_std_attributes;
    struct P : Polyhedron_std_attributes
    {
        float thermal_conductivity;
    };

    // create a mesh with custom per tet attributes
    Tetmesh<M,V,E,F,P> my_mesh;

    // access thermal conductivity 
    my_mesh.poly_data(tet_id).thermal_conductivity = 1.0;