void Slicer::edgeShading(double width, bool key, double Z, double F) { Point2D *shift_start = new Point2D(0,0); int arg_shift; if(key) { arg_shift = 1; } else { arg_shift = -1; } GCodeOutStream << "\t\tG00 X" << slice->at(0).x << " Y" << slice->at(0).y << " Z" << Z << " F" << F << "\r\n"; for(int i = 1; i < slice->size(); i++) { GCodeOutStream << "\t\tG01 X" << slice->at(i).x << " Y" << slice->at(i).y << " Z" << Z << " F" << F << "\r\n"; } GCodeOutStream << "\t\tG01 X" << slice->at(0).x << " Y" << slice->at(0).y << " Z" << Z << " F" << F << "\r\n"; for(int i = 1; i < width * 10; i++) { slice->replace(0, shift_point(0, arg_shift, shift_start)); GCodeOutStream << "\t\tG00 X" << slice->at(0).x << " Y" << slice->at(0).y << " Z" << Z << " F" << F << "\r\n"; for(int j = 1; j < slice->size(); j++) { slice->replace(j, shift_point(j, arg_shift, shift_start)); GCodeOutStream << "\t\tG01 X" << slice->at(j).x << " Y" << slice->at(j).y << " Z" << Z << " F" << F << "\r\n"; } GCodeOutStream << "\t\tG01 X" << slice->at(0).x << " Y" << slice->at(0).y << " Z" << Z << " F" << F << "\r\n"; } delete shift_start; }
vector<Vector3d> MeanShift::cluster(vector<Vector3d> points, double kernel_bandwidth){ vector<bool> stop_moving(points.size(), false); stop_moving.reserve(points.size()); vector<Vector3d> shifted_points = points; double max_shift_distance; do { max_shift_distance = 0; for(int i=0; i<shifted_points.size(); i++){ if (!stop_moving[i]) { Vector3d point_new = shift_point(shifted_points[i], points, kernel_bandwidth); double shift_distance = euclidean_distance(point_new, shifted_points[i]); if(shift_distance > max_shift_distance){ max_shift_distance = shift_distance; } if(shift_distance <= EPSILON) { stop_moving[i] = true; } shifted_points[i] = point_new; } } //printf("max_shift_distance: %f\n", max_shift_distance); } while (max_shift_distance > EPSILON); return shifted_points; }