Permalink
Browse files

Add height comparison operators

  • Loading branch information...
1 parent 17d1abd commit 7b2536c8008455d357a2191ed42e3b4782f2b5cc @cibomahto cibomahto committed May 17, 2011
Showing with 14 additions and 0 deletions.
  1. +8 −0 gcode.cpp
  2. +6 −0 gcode.h
View
@@ -84,6 +84,14 @@ bool layerMap::heightInLayer(int layer, float height) {
return (std::fabs(heights[layer] - height) < .07);
}
+bool layerMap::heightGreaterThanLayer(int layer, float height) {
+ return (!heightInLayer(layer, height) && height > heights[layer]);
+}
+
+bool layerMap::heightLessThanLayer(int layer, float height) {
+ return (!heightInLayer(layer, height) && height < heights[layer]);
+}
+
// Record that we've seen a specific z height. If it's already in the list, it is ignored, otherwise it is added.
void layerMap::recordHeight(float height) {
for (int i = 0; i < heights.size(); i++) {
View
@@ -66,6 +66,12 @@ class layerMap {
// Test if a height is in a given layer
bool heightInLayer(int layer, float height);
+ // Test if a height is higher than a given layer
+ bool heightGreaterThanLayer(int layer, float height);
+
+ // Test if a height is lower than a given later
+ bool heightLessThanLayer(int layer, float height);
+
// Return the number of layers that we know about
int size();

0 comments on commit 7b2536c

Please sign in to comment.