[QGHG-it-dev-list] Zadatak 1 --- seed fja za tetraedar

Jaroslav Blagojevic jaroslav.blagojevic at gmail.com
Mon Feb 14 16:48:54 CET 2022


Pozdrav,

Jaroslav


On Mon, Feb 14, 2022 at 4:48 PM Jaroslav Blagojevic <
jaroslav.blagojevic at gmail.com> wrote:

> Seed tetrahedrona u prilogu. Tetrahedron sam nacrtao ručno (nisam mogao da
> kopam po snimljenom materijalu, mislim da smo ga negde crtali), pa sam ga
> opisao u kodu. Nisam još dodelio uniqueID boje, jer to nije traženo u
> zadatku. S obzirom da je to implementirano u seed_single_triangle metodi,
> trebalo bi da bude i ovde? Takođe, kako glasi množina od k-simplex
> (k-simplexes, k-simplices?).
>
> On Fri, Feb 11, 2022 at 10:29 PM Marko Vojinovic <vmarko at ipb.ac.rs> wrote:
>
>>
>> Upoznati se sa osnovnim klasama (SimpComp i KSimplex) kroz problem
>> implementiranja seed f-je za jedan tetraedar (D=3):
>>
>>    SimpComp* seed_single_tetrahedron( void );
>>
>>    Input: nema.
>>    Output: pointer na instancirani simplicijalni kompleks koji se sastoji
>> od jednog tetraedra.
>>
>> Funkciju implementirati kao uopstenje jednostavnijih seed f-ja
>> seed_single_edge() i seed_single_triangle() koje je Nenad uradio, i koje
>> kreiraju slicne komplekse za dimenzije D=1 i D=2 redom. Postupak ide u tri
>> koraka:
>>
>> (1) Instancirati nov simplicijalni kompleks dimenzije D=3 i iskoristiti
>> metod create_ksimplex() iz klase SimpComp za kreiranje odgovarajuceg broja
>> simpleksa nivoa k=0 (verteksi), k=1 (edgevi), k=2 (trouglovi) i k=3
>> (tetraedar) u tom kompleksu.
>>
>> (2) Popuniti podklasu neighbors svakog simpleksa pointerima na njegove
>> susede, koristeci metod add_neighbor() iz klase KSimplex, na osnovu slike
>> tetraedra i definicije suseda sa uvodnih predavanja.
>>
>> (3) Simpleksima nivoa k=2 (tj. trouglovima) dodeliti boju boundary, i za
>> svaki trougao zadati vrednost te boje na true.
>>
>>
>> :-)
>> Marko
>>
>>
>> Dr. Marko Vojinovic
>> Group for Gravitation, Particles and Fields
>> Institute of Physics
>> University of Belgrade
>> ======================
>> home page: www.markovojinovic.com
>> e-mail:    vmarko at ipb.ac.rs
>>
>>
>> --
>> QGHG-it-dev-list mailing list
>> QGHG-it-dev-list at ipb.ac.rs
>> http://mail.ipb.ac.rs/mailman/listinfo/qghg-it-dev-list
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ipb.ac.rs/pipermail/qghg-it-dev-list/attachments/20220214/90bd0958/attachment-0001.htm>
-------------- next part --------------
SimpComp* seed_single_tetrahedron(string name)
{
    KSimplex *v1, *v2, *v3, *v4;
    KSimplex *e1, *e2, *e3, *e4, *e5, *e6;
    KSimplex *trianglev1v2v3;
    KSimplex *trianglev1v3v4;
    KSimplex *trianglev1v2v4;
    KSimplex *trianglev2v4v3;
    KSimplex *tetrahedron1;

    // Initialize simplicial complex of dimension 3
    SimpComp *tetrahedron = new SimpComp(name, 3);

    // Vertex v1 is located up
    // Vertex v2 is located left
    // Vertex v4 is located right
    // Vertex v3 is located down
    // Add vertices (k-simplices, k=0)
    v1 = tetrahedron->create_ksimplex(0);
    v2 = tetrahedron->create_ksimplex(0);
    v3 = tetrahedron->create_ksimplex(0);
    v4 = tetrahedron->create_ksimplex(0);

    // Add edges (k-simplices, k=1)
    e1 = tetrahedron->create_ksimplex(1);
    e2 = tetrahedron->create_ksimplex(1);
    e3 = tetrahedron->create_ksimplex(1);
    e4 = tetrahedron->create_ksimplex(1);
    e5 = tetrahedron->create_ksimplex(1);
    e6 = tetrahedron->create_ksimplex(1);

    // Add triangles (k-simplices, k=2)
    trianglev1v2v3 = tetrahedron->create_ksimplex(2);
    trianglev1v3v4 = tetrahedron->create_ksimplex(2);
    trianglev1v2v4 = tetrahedron->create_ksimplex(2);
    trianglev2v4v3 = tetrahedron->create_ksimplex(2);

    // Add tetrahedron (k-simplex, k=3)
    tetrahedron1 = tetrahedron->create_ksimplex(3);

    // Edges have vertices as neighbors
    e1->add_neighbor(v1);
    e1->add_neighbor(v2);

    // Vertices have edges as neighbors
    v1->add_neighbor(e1);
    v2->add_neighbor(e1);

    e2->add_neighbor(v1);
    e2->add_neighbor(v3);

    v1->add_neighbor(e2);
    v3->add_neighbor(e2);

    e3->add_neighbor(v1);
    e3->add_neighbor(v4);

    v1->add_neighbor(e3);
    v4->add_neighbor(e3);

    e4->add_neighbor(v2);
    e4->add_neighbor(v4);

    v2->add_neighbor(e4);
    v4->add_neighbor(e4);

    e5->add_neighbor(v2);
    e5->add_neighbor(v3);

    v2->add_neighbor(e5);
    v3->add_neighbor(e5);

    e6->add_neighbor(v3);
    e6->add_neighbor(v4);

    v3->add_neighbor(e6);
    v4->add_neighbor(e6);

    // Triangle has vertices and edges as neighbors
    trianglev1v2v3->add_neighbor(v1);
    trianglev1v2v3->add_neighbor(v2);
    trianglev1v2v3->add_neighbor(v3);
    trianglev1v2v3->add_neighbor(e1);
    trianglev1v2v3->add_neighbor(e2);
    trianglev1v2v3->add_neighbor(e5);

    // Vertices and edges have triangles as neighbors
    v1->add_neighbor(trianglev1v2v3);
    v2->add_neighbor(trianglev1v2v3);
    v3->add_neighbor(trianglev1v2v3);
    e1->add_neighbor(trianglev1v2v3);
    e2->add_neighbor(trianglev1v2v3);
    e5->add_neighbor(trianglev1v2v3);

    trianglev1v3v4->add_neighbor(v1);
    trianglev1v3v4->add_neighbor(v3);
    trianglev1v3v4->add_neighbor(v4);
    trianglev1v3v4->add_neighbor(e2);
    trianglev1v3v4->add_neighbor(e3);
    trianglev1v3v4->add_neighbor(e6);

    v1->add_neighbor(trianglev1v3v4);
    v3->add_neighbor(trianglev1v3v4);
    v4->add_neighbor(trianglev1v3v4);
    e2->add_neighbor(trianglev1v3v4);
    e3->add_neighbor(trianglev1v3v4);
    e6->add_neighbor(trianglev1v3v4);

    trianglev1v2v4->add_neighbor(v1);
    trianglev1v2v4->add_neighbor(v2);
    trianglev1v2v4->add_neighbor(v4);
    trianglev1v2v4->add_neighbor(e1);
    trianglev1v2v4->add_neighbor(e3);
    trianglev1v2v4->add_neighbor(e4);

    v1->add_neighbor(trianglev1v2v4);
    v2->add_neighbor(trianglev1v2v4);
    v4->add_neighbor(trianglev1v2v4);
    e1->add_neighbor(trianglev1v2v4);
    e3->add_neighbor(trianglev1v2v4);
    e4->add_neighbor(trianglev1v2v4);

    trianglev2v4v3->add_neighbor(v2);
    trianglev2v4v3->add_neighbor(v4);
    trianglev2v4v3->add_neighbor(v3);
    trianglev2v4v3->add_neighbor(e4);
    trianglev2v4v3->add_neighbor(e6);
    trianglev2v4v3->add_neighbor(e5);

    v2->add_neighbor(trianglev2v4v3);
    v4->add_neighbor(trianglev2v4v3);
    v3->add_neighbor(trianglev2v4v3);
    e4->add_neighbor(trianglev2v4v3);
    e6->add_neighbor(trianglev2v4v3);
    e5->add_neighbor(trianglev2v4v3);

    // Tetrahedron has triangles as neighbors
    tetrahedron1->add_neighbor(trianglev1v2v3);
    tetrahedron1->add_neighbor(trianglev1v3v4);
    tetrahedron1->add_neighbor(trianglev1v2v4);
    tetrahedron1->add_neighbor(trianglev2v4v3);

    // Triangles have boundary color
    Color *c1 = new BoundaryColor(true);
    Color *c2 = new BoundaryColor(true);
    Color *c3 = new BoundaryColor(true);
    Color *c4 = new BoundaryColor(true);
    trianglev1v2v3->colors.push_back(c1);
    trianglev1v3v4->colors.push_back(c2);
    trianglev1v2v4->colors.push_back(c3);
    trianglev2v4v3->colors.push_back(c4);

    return tetrahedron;
}


More information about the QGHG-it-dev-list mailing list