Newer
Older
cg / hw04 / src / Tri.cpp
// Copyright (c) 2021. Pascal Syma <pascal@syma.dev> and Antonio Martinez Casadesus <acasadesus@stud.hs-bremen.de>.
// All rights reserved.

//
// Created by Pascal on 17.05.2021.
//

#include "Tri.h"
#include "Mesh.h"
#include <iostream>

using namespace std;

Tri::Tri(Mesh* mesh) {
    this->mesh = mesh;

    it[0] = -1;
    it[1] = -1;
    it[2] = -1;
    ie[0] = -1;
    ie[1] = -1;
    ie[2] = -1;
}

Tri::Tri(Mesh* mesh, int *i) : Tri(mesh) {
}

Tri::Tri(Mesh* mesh, int i, int j, int k) : Tri(mesh) {
    iv[0] = i;
    iv[1] = j;
    iv[2] = k;
}

void Tri::Print() {
    cout << "Tri:" << endl << " neighbour: " << it[0] << " " << it[1] << " " << it[2] << endl << " - ";
    this->mesh->pts[iv[0]].Print();
    cout << " - ";
    this->mesh->pts[iv[1]].Print();
    cout << " - ";
    this->mesh->pts[iv[2]].Print();
    cout << endl << "Edges: " << ie[0] << " " << ie[1] << " " << ie[2] << endl;
//    pts[ie[0]].Print();
//    pts[ie[1]].Print();
//    pts[ie[2]].Print();

    cout << endl;
}

Tri *Tri::copy(Mesh* mesh) {
    Tri *copy = new Tri(mesh);
    for (int i = 0; i < 3; ++i) {
        copy->iv[i] = this->iv[i];
        copy->ie[i] = this->ie[i];
        copy->it[i] = this->it[i];
    }

    return copy;
}