forked from gregori/Slicer
/
Mesh.cpp
98 lines (79 loc) · 1.89 KB
/
Mesh.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "Mesh.h"
#include "OpenGLImp.h"
#include "GraphicsImp.h"
#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
namespace ProcessPlanning
{
Mesh::Mesh(void)
{
ifCounter = 0;
sliceCounter = 0;
heightSum = 0.0;
}
Mesh::~Mesh(void)
{
}
int Mesh::getIfCounter()
{
return ifCounter;
}
int Mesh::getSliceCounter()
{
return sliceCounter;
}
void Mesh::incIfCounter()
{
ifCounter++;
}
void Mesh::incSliceCounter()
{
sliceCounter++;
}
void Mesh::addTriangle(Facet *t)
{
addGeometry(static_cast<Geometry*>(t));
heightSum += t->getFacetHeight();
orderedInsertTriangle(t);
}
Facet* Mesh::getTriangle(Facet* t) const
{
//traverse list and compares the triangle
return NULL;
}
Slice* Mesh::getSlice()
{
Slice *s = new Slice();
Contour *c = new Contour();
while (!segments.empty())
{
segIt = segments.begin();
std::string lbl = static_cast<Point*>(segIt->second->getGeometry(0))->getLabel();
while (segments.count(lbl))
{
//if (lbl.compare("50.79235|15.27517|75.54418") == 0)
// std::cout << lbl << std::endl;
Rect *l = segments[lbl];
c->addGeometry(l);
segments.erase(segments.find(lbl));
Point *p2 = static_cast<Point*>(l->getGeometry(1));
lbl = p2->getLabel();
}
c->setInterface(new Graphics(static_cast<GraphicsImp*>(new OpenGLImp())));
s->addGeometry(c);
c = new Contour();
}
return s;
}
float Mesh::getAvgFacetHeight(void)
{
//float heightSum = 0.0;
//for (int i = 0; i < this->getSize(); i++)
//{
// heightSum += static_cast<Facet*>(this->getGeometry(i))->getFacetHeight();
//}
return heightSum / this->getSize();
}
}