-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathToolPath.cpp
108 lines (87 loc) · 2.28 KB
/
ToolPath.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
99
100
101
102
103
104
105
106
107
108
#include "ToolPath.h"
#include"stdafx.h"
ToolPath^ ToolPath::nextPath(){
if(parent!=nullptr){
return (parent)->getPath(getIndex()+1);
}else{
Console::WriteLine("Error path is not nested in a WS");
return nullptr;}
return nullptr;
}
ToolPath::ToolPath(WS^ p, bool rapid, double f, double s, __int64 in, __int64 ID) {
parent = p;
isRapid = rapid;
feedrate = f;
spindleSpeed = s;
index = in;
id = ID;
copyID = -1;
}
WS^ ToolPath::getWS() { return parent; }
__int64 ToolPath::getId(){ return id; }
__int64 ToolPath::getIndex() { return index; }
ToolPath^ ToolPath::nextPath(bool % newWP, bool% newWS) {
ToolPath^temp =nextPath();
Exec^ tempExec;
if (temp != nullptr) {
newWP = false;
newWS = false;
return temp;
}
else {
newWP = true;
newWS = true;
WS^ tempWS = getWS();
ToolPath^ nextToolPath = nullptr;
List<WP^>^path = getWS()->pathtoRoot();
for (int i = 0; i<path->Count; i++) {
if (i == 0) {
nextToolPath = recurseToNextToolPath(path[i], tempWS->getIndex());
}
else {
nextToolPath = recurseToNextToolPath(path[i], path[i-1]->getIndex());
}
if (nextToolPath != nullptr) {
return nextToolPath;
}
}
}
}
ToolPath^ ToolPath::recurseToNextToolPath(WP^ current, __int64 startIndexAfter) {
ToolPath^ result = nullptr;
for (int i = startIndexAfter + 1; i<current->getExecutableCount(); i++) {
result = recurseToolPath(current->getExecutable(i));
if (result != nullptr) {
return result;
}
}
Console::WriteLine("could notge next path ");
return nullptr;
}
ToolPath^ ToolPath::recurseToolPath(Exec^ current) {
WS^ tempWS = nullptr;
WP^ tempWP = nullptr;
WP^ tempWP2;
if (current->isWP()) {
tempWP = dynamic_cast<WP^>(current);
}
else {
tempWS = dynamic_cast<WS^>(current);
}
if (tempWS != nullptr) {
if (tempWS->getPathCount()>0) {
return tempWS->getPath(0);
}
}
if (tempWP != nullptr) {
for (int i = 0; i<tempWP->getExecutableCount(); i++) {
return recurseToolPath(tempWP->getExecutable(i));
}
}
return nullptr;
}
__int64 ToolPath::getCopyID() { return copyID; }
bool ToolPath::copyCreated() { if (copyID == -1) { return false; } else { return true; } }
double ToolPath::getFeed() { return feedrate; }
bool ToolPath::rapid() { return isRapid; }
double ToolPath::getSpindle() { return spindleSpeed; }