Commit 38d1d37b by Philipp Adolf

Store sharpness in Triangle

parent a4af0079
......@@ -10,13 +10,22 @@ Triangle::Triangle(const Triangle &other) {
this->u_ = other.u_;
this->v_ = other.v_;
this->w_ = other.w_;
this->sharpness_uv = other.sharpness_uv;
this->sharpness_vw = other.sharpness_vw;
this->sharpness_wu = other.sharpness_wu;
}
Triangle::Triangle(const QVector<Vertex> *vertex_buffer, unsigned int u, unsigned int v, unsigned int w) {
Triangle::Triangle(const QVector<Vertex> *vertex_buffer, unsigned int u, unsigned int v, unsigned int w,
unsigned int sharpness_uv,
unsigned int sharpness_vw,
unsigned int sharpness_wu) {
this->vertex_buffer_ = vertex_buffer;
this->u_ = u;
this->v_ = v;
this->w_ = w;
this->sharpness_uv = sharpness_uv;
this->sharpness_vw = sharpness_vw;
this->sharpness_wu = sharpness_wu;
}
Vertex Triangle::u() const {
......@@ -43,6 +52,16 @@ unsigned int Triangle::w_idx() const {
return w_;
}
unsigned int Triangle::get_sharpness_uv() const {
return sharpness_uv;
}
unsigned int Triangle::get_sharpness_vw() const {
return sharpness_vw;
}
unsigned int Triangle::get_sharpness_wu() const {
return sharpness_wu;
}
bool Triangle::get_shared_edge(Triangle other, Edge &edge_a, Edge &edge_b) const {
if (get_shared_edge_(other, edge_a, edge_b)) {
return true;
......@@ -132,6 +151,9 @@ Triangle &Triangle::operator=(const Triangle &other) {
this->u_ = other.u_;
this->v_ = other.v_;
this->w_ = other.w_;
this->sharpness_uv = other.sharpness_uv;
this->sharpness_vw = other.sharpness_vw;
this->sharpness_wu = other.sharpness_wu;
return *this;
}
......@@ -192,6 +214,16 @@ void ibToTriangles(QVector<Vertex> *vb, QVector<unsigned int> &ib, QVector<Trian
}
}
void Triangle::set_sharpness(Triangle::Edge::Name name, unsigned int value){
if (name == Edge::Name::uv){
sharpness_uv = value;
}else if (name == Edge::Name::vw){
sharpness_vw = value;
}else if (name == Edge::Name::wu){
sharpness_wu = value;
}
}
void trianglesToIB(const QVector<Triangle> &triangles, QVector<unsigned int> &ib) {
ib.reserve(ib.length() + triangles.length() * 3);
QVectorIterator<Triangle> it(triangles);
......
......@@ -5,6 +5,8 @@
#include <QDebug>
#include <QVector>
#include "vertex.h"
#include "mesh.h"
class Triangle {
public:
......@@ -16,9 +18,9 @@ class Triangle {
};
Name name;
unsigned int a;
unsigned int b;
unsigned int c;
unsigned int a;//index der Kante im Dreieck
unsigned int b;//index der Kante im Dreieck
unsigned int c;//gegenüberliegender Vertex index
};
struct Neighbor {
......@@ -36,7 +38,10 @@ class Triangle {
Triangle();
Triangle(const Triangle &other);
Triangle(const QVector<Vertex> *vertex_buffer, unsigned int u, unsigned int v, unsigned int w);
Triangle(const QVector<Vertex> *vertex_buffer, unsigned int u, unsigned int v, unsigned int w,
unsigned int sharpness_uv = 0,
unsigned int sharpness_vw = 0,
unsigned int sharpness_wu = 0);
Vertex u() const;
Vertex v() const;
......@@ -46,6 +51,10 @@ class Triangle {
unsigned int v_idx() const;
unsigned int w_idx() const;
unsigned int get_sharpness_uv() const;
unsigned int get_sharpness_vw() const;
unsigned int get_sharpness_wu() const;
bool get_shared_edge(Triangle other, Edge &edge_a, Edge &edge_b) const;
bool hasSharedEdge(Triangle other);
......@@ -61,7 +70,14 @@ class Triangle {
bool next_ctrclockwise(Edge first, Edge next) const;
bool next_clockwise(Edge first, Edge next) const;
void set_sharpness(Triangle::Edge::Name name, unsigned int value);
private:
unsigned int sharpness_uv;
unsigned int sharpness_vw;
unsigned int sharpness_wu;
const QVector<Vertex> *vertex_buffer_;
unsigned int u_;
unsigned int v_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment