Merge branch 'dev' into UnitTesting

This commit is contained in:
2020-01-16 11:24:44 +01:00
38 changed files with 1179 additions and 383 deletions

View File

@@ -65,4 +65,4 @@ QColor firstColor;
QColor secondColor;
};
#endif // INTELLITOOLSETCOLORTOOL_H
#endif

View File

@@ -26,4 +26,4 @@ private:
bool fastRenderering = true;
};
#endif // INTELLIRENDERSETTINGS_H
#endif

View File

@@ -5,7 +5,6 @@ IntelliToolsettings::IntelliToolsettings()
{
lineWidth = 1;
innerAlpha = 255;
Linestyle = LineStyle::SOLID_LINE;
}
IntelliToolsettings::~IntelliToolsettings(){
@@ -16,38 +15,26 @@ int IntelliToolsettings::getLineWidth(){
return lineWidth;
}
void IntelliToolsettings::setLineWidth(){
lineWidth = QInputDialog::getInt(nullptr,"Line Width Input", "Width",1,1,50,1);
}
void IntelliToolsettings::setLineWidth(int LineWidth){
if(LineWidth < 1) {
LineWidth = 1;
}
else if(LineWidth > 50) {
LineWidth = 50;
}
lineWidth = LineWidth;
if(LineWidth < 1){
LineWidth = 1;
}
else if(LineWidth > 50){
LineWidth = 50;
}
lineWidth = LineWidth;
}
int IntelliToolsettings::getInnerAlpha(){
return this->innerAlpha;
}
void IntelliToolsettings::setInnerAlpha(){
this->innerAlpha = QInputDialog::getInt(nullptr,"Inner Aplha Input", "Value",0,0,255,1);
}
void IntelliToolsettings::setInnerAlpha(int innerAlpha){
if(innerAlpha < 0) {
innerAlpha = 0;
}
else if(innerAlpha > 255) {
innerAlpha = 255;
}
this->innerAlpha = innerAlpha;
}
IntelliToolsettings::LineStyle IntelliToolsettings::getLinestyle(){
return Linestyle;
if(innerAlpha < 0){
innerAlpha = 0;
}
else if(innerAlpha > 255){
innerAlpha = 255;
}
this->innerAlpha = innerAlpha;
}

View File

@@ -5,33 +5,20 @@
class UnitTest;
class IntelliToolsettings {
friend UnitTest;
friend UnitTest;
public:
/*!
* \brief The LineStyle enum classifing all ways of drawing a line.
*/
enum class LineStyle {
SOLID_LINE,
DOTTED_LINE
};
IntelliToolsettings();
virtual ~IntelliToolsettings();
int getLineWidth();
void setLineWidth();
void setLineWidth(int LineWidth);
int getInnerAlpha();
void setInnerAlpha();
void setInnerAlpha(int innerAlpha);
LineStyle getLinestyle();
private:
int lineWidth;
int innerAlpha;
LineStyle Linestyle;
};
#endif // INTELLITOOLSETTINGS_H
#endif

View File

@@ -14,46 +14,46 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
};
// calculates the inner angle of 'point'
auto calculateInner = [](QPoint& point, QPoint& prev, QPoint& post){
QPoint AP(point.x()-prev.x(), point.y()-prev.y());
QPoint BP(point.x()-post.x(), point.y()-post.y());
auto calculateInner = [] (QPoint& point, QPoint& prev, QPoint& post) {
QPoint AP(point.x() - prev.x(), point.y() - prev.y());
QPoint BP(point.x() - post.x(), point.y() - post.y());
float topSclar = AP.x()*BP.x()+AP.y()*BP.y();
float absolute = static_cast<float>(sqrt(pow(AP.x(),2.)+pow(AP.y(),2.))*sqrt(pow(BP.x(),2.)+pow(BP.y(),2.)));
return acos(topSclar/absolute);
float topSclar = AP.x() * BP.x() + AP.y() * BP.y();
float absolute = static_cast<float>(sqrt(pow(AP.x(),2.) + pow(AP.y(),2.)) * sqrt(pow(BP.x(),2.) + pow(BP.y(),2.)));
return acos(topSclar / absolute);
};
// gets the first element of vec for which element.isTip == true holds
auto getTip= [](const std::vector<TriangleHelper>& vec){
size_t min = 0;
for(size_t i=0; i<vec.size(); i++) {
if(vec[i].interiorAngle<vec[min].interiorAngle) {
min = i;
}
}
return vec[min];
};
auto getTip = [] (const std::vector<TriangleHelper>& vec) {
size_t min = 0;
for(size_t i = 0; i<vec.size(); i++) {
if(vec[i].interiorAngle<vec[min].interiorAngle) {
min = i;
}
}
return vec[min];
};
// get the vertex idx bevor idx in relation to the container length
auto getPrev = [](int idx, int length){
return (idx-1)>=0 ? (idx-1) : (length-1);
auto getPrev = [] (int idx, int length) {
return (idx - 1)>=0 ? (idx - 1) : (length - 1);
};
// get the vertex idx after idx in relation to the container lenght
auto getPost = [](int idx, int length){
return (idx+1)%length;
auto getPost = [] (int idx, int length) {
return (idx + 1) % length;
};
// return if the vertex is a tip
auto isTip = [](float angle){
return static_cast<double>(angle)<(pi/2.);
auto isTip = [] (float angle) {
return static_cast<double>(angle)<(pi / 2.);
};
std::vector<TriangleHelper> Vertices;
std::vector<Triangle> Triangles;
// set up all vertices and calculate intirior angle
for(int i=0; i<static_cast<int>(polyPoints.size()); i++) {
for(int i = 0; i<static_cast<int>(polyPoints.size()); i++) {
TriangleHelper helper;
int prev = getPrev(i, static_cast<int>(polyPoints.size()));
int post = getPost(i, static_cast<int>(polyPoints.size()));
@@ -69,7 +69,7 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
}
// search triangles based on the intirior angles of each vertey
while(Triangles.size() != polyPoints.size()-2) {
while(Triangles.size() != polyPoints.size() - 2) {
Triangle tri;
TriangleHelper smallest = getTip(Vertices);
int prev = getPrev(smallest.idx, static_cast<int>(Vertices.size()));
@@ -82,14 +82,14 @@ std::vector<Triangle> IntelliTriangulation::calculateTriangles(std::vector<QPoin
Triangles.push_back(tri);
// update Vertice array
Vertices.erase(Vertices.begin()+smallest.idx);
for(size_t i=static_cast<size_t>(smallest.idx); i<Vertices.size(); i++) {
Vertices[i].idx-=1;
Vertices.erase(Vertices.begin() + smallest.idx);
for(size_t i = static_cast<size_t>(smallest.idx); i<Vertices.size(); i++) {
Vertices[i].idx -= 1;
}
// update post und prev idx
post = getPrev(post, Vertices.size());
prev = prev<smallest.idx ? prev : (prev-1);
prev = prev<smallest.idx ? prev : (prev - 1);
// calcultae neighboors of prev and post to calculate new interior angles
int prevOfPrev = getPrev(prev, static_cast<int>(Vertices.size()));

View File

@@ -24,7 +24,7 @@ namespace IntelliTriangulation {
* \return Returns the area of the traingle*2
*/
inline float sign(QPoint& p1, QPoint& p2, QPoint& p3){
return (p1.x()-p3.x())*(p2.y()-p3.y())-(p2.x()-p3.x())*(p1.y()-p3.y());
return (p1.x() - p3.x()) * (p2.y() - p3.y()) - (p2.x() - p3.x()) * (p1.y() - p3.y());
}
/*!