Compare commits
2 Commits
0db09007e8
...
fee6a594df
Author | SHA1 | Date | |
---|---|---|---|
fee6a594df | |||
e559c2d730 |
BIN
.vscode/browse.vc.db
vendored
Normal file
BIN
.vscode/browse.vc.db
vendored
Normal file
Binary file not shown.
BIN
.vscode/browse.vc.db-shm
vendored
Normal file
BIN
.vscode/browse.vc.db-shm
vendored
Normal file
Binary file not shown.
0
.vscode/browse.vc.db-wal
vendored
Normal file
0
.vscode/browse.vc.db-wal
vendored
Normal file
34
.vscode/c_cpp_properties.json
vendored
Normal file
34
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"myDefaultIncludePath": [
|
||||||
|
"${workspaceFolder}/StarshipAscension/include"
|
||||||
|
],
|
||||||
|
"myCompilerPath": "/usr/bin/gcc"
|
||||||
|
},
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-x64",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"defines": [],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "${default}",
|
||||||
|
"cppStandard": "${default}",
|
||||||
|
"compileCommands": "build/compile_commands.json",
|
||||||
|
"browse": {
|
||||||
|
"path": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"/usr/local/include",
|
||||||
|
"/usr/include/x86_64-linux-gnu",
|
||||||
|
"/usr/include"
|
||||||
|
],
|
||||||
|
"limitSymbolsToIncludedHeaders": true,
|
||||||
|
"databaseFilename": "${workspaceFolder}/.vscode/browse.vc.db"
|
||||||
|
},
|
||||||
|
"configurationProvider": "ms-vscode.cmake-tools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
24
.vscode/launch.json
vendored
Normal file
24
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "C/C++ Runner: Debug Session",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"externalConsole": false,
|
||||||
|
"cwd": "/home/gbowne1/Documents/BendCalc",
|
||||||
|
"program": "/home/gbowne1/Documents/BendCalc/build/Debug/outDebug",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
59
.vscode/settings.json
vendored
Normal file
59
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||||
|
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||||
|
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||||
|
"C_Cpp_Runner.cStandard": "",
|
||||||
|
"C_Cpp_Runner.cppStandard": "",
|
||||||
|
"C_Cpp_Runner.msvcBatchPath": "",
|
||||||
|
"C_Cpp_Runner.useMsvc": false,
|
||||||
|
"C_Cpp_Runner.warnings": [
|
||||||
|
"-Wall",
|
||||||
|
"-Wextra",
|
||||||
|
"-Wpedantic",
|
||||||
|
"-Wshadow",
|
||||||
|
"-Wformat=2",
|
||||||
|
"-Wcast-align",
|
||||||
|
"-Wconversion",
|
||||||
|
"-Wsign-conversion",
|
||||||
|
"-Wnull-dereference"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.msvcWarnings": [
|
||||||
|
"/W4",
|
||||||
|
"/permissive-",
|
||||||
|
"/w14242",
|
||||||
|
"/w14287",
|
||||||
|
"/w14296",
|
||||||
|
"/w14311",
|
||||||
|
"/w14826",
|
||||||
|
"/w44062",
|
||||||
|
"/w44242",
|
||||||
|
"/w14905",
|
||||||
|
"/w14906",
|
||||||
|
"/w14263",
|
||||||
|
"/w44265",
|
||||||
|
"/w14928"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.enableWarnings": true,
|
||||||
|
"C_Cpp_Runner.warningsAsError": false,
|
||||||
|
"C_Cpp_Runner.compilerArgs": [],
|
||||||
|
"C_Cpp_Runner.linkerArgs": [],
|
||||||
|
"C_Cpp_Runner.includePaths": [],
|
||||||
|
"C_Cpp_Runner.includeSearch": [
|
||||||
|
"*",
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.excludeSearch": [
|
||||||
|
"**/build",
|
||||||
|
"**/build/**",
|
||||||
|
"**/.*",
|
||||||
|
"**/.*/**",
|
||||||
|
"**/.vscode",
|
||||||
|
"**/.vscode/**"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||||
|
"C_Cpp_Runner.showCompilationTime": false,
|
||||||
|
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||||
|
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
||||||
|
}
|
36
CMakeLists.txt
Normal file
36
CMakeLists.txt
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13.4)
|
||||||
|
project(BendCalc)
|
||||||
|
|
||||||
|
# Set C++ standard
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_COMPILER /usr/bin/g++)
|
||||||
|
set(CMAKE_CXX_FLAGS -g -Wall -Wextra -Werror -pedantic)
|
||||||
|
# Include directories
|
||||||
|
include_directories(include)
|
||||||
|
target_include_directories(include)
|
||||||
|
|
||||||
|
# Source files
|
||||||
|
set(SOURCES
|
||||||
|
src/main.cpp
|
||||||
|
src/Tonnage.cpp
|
||||||
|
src/Setback.cpp
|
||||||
|
src/Serializer.cpp
|
||||||
|
src/Kfactor.cpp
|
||||||
|
src/Deserializer.cpp
|
||||||
|
src/DataSave.cpp
|
||||||
|
src/DataLoad.cpp
|
||||||
|
include/Tonnage.h
|
||||||
|
include/Setback.h
|
||||||
|
include/Serializer.h
|
||||||
|
include/Kfactor.h
|
||||||
|
include/Deserializer.h
|
||||||
|
include/DataSave.h
|
||||||
|
include/DataLoad.h
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create executable
|
||||||
|
add_executable(bend_calc ${SOURCES})
|
@ -1,3 +1,4 @@
|
|||||||
# BendCalc
|
# BendCalc
|
||||||
|
|
||||||
A C++ Bend calculator for sheet metal bending and forming calculations used in the sheet metal and forming and fabrication trades
|
A C++ Bend calculator for sheet metal bending and forming calculations used in the sheet metal and forming and fabrication trades
|
||||||
|
|
||||||
|
12
docs/Tonnage.md
Normal file
12
docs/Tonnage.md
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// Inputs for Bend Angle Tonnage required
|
||||||
|
// Material Type:L A
|
||||||
|
// Tensile Strength (if known) in Mpa
|
||||||
|
// Material Thickness
|
||||||
|
// K-Factor
|
||||||
|
// V die opening (print suggested v opening of 8x material thickness)
|
||||||
|
// Radius
|
||||||
|
// Minimum Flange
|
||||||
|
// {[(575 × Material thickness squared) / Die width] / 12} × Material factor
|
||||||
|
|
||||||
|
// Outputs for Bend Angle Tonnage
|
||||||
|
// P in kN/mt and convert to Tons (lb^2/i)
|
0
include/BendAllowance.h
Normal file
0
include/BendAllowance.h
Normal file
0
include/DataLoad.h
Normal file
0
include/DataLoad.h
Normal file
0
include/DataSave.h
Normal file
0
include/DataSave.h
Normal file
12
include/Deserializer.h
Normal file
12
include/Deserializer.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef DESERIALIZER_H
|
||||||
|
#define DESERIALIZER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
class Deserializer {
|
||||||
|
public:
|
||||||
|
static bool deserializeData(const std::string& filename, std::string& data);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
0
include/FormingTool.h
Normal file
0
include/FormingTool.h
Normal file
7
include/Kfactor.h
Normal file
7
include/Kfactor.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef KFACTOR_H
|
||||||
|
#define KFACTOR_H
|
||||||
|
|
||||||
|
// Function declaration for calculating the K-factor
|
||||||
|
double calculateKFactor(double neutralAxisLocation, double materialThickness);
|
||||||
|
|
||||||
|
#endif
|
12
include/Serializer.h
Normal file
12
include/Serializer.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef SERIALIZER_H
|
||||||
|
#define SERIALIZER_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
class Serializer {
|
||||||
|
public:
|
||||||
|
static bool serializeData(const std::string& filename, const std::string& data);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
0
include/Setback.h
Normal file
0
include/Setback.h
Normal file
7
include/Tonnage.h
Normal file
7
include/Tonnage.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef TONNAGE_H
|
||||||
|
#define TONNAGE_H
|
||||||
|
|
||||||
|
// Function declaration for calculating the press brake tonnage
|
||||||
|
double calculateTonnage(double materialThickness, double bendLength, double dieOpeningWidth, double materialFactor, double methodFactor, double multipleBendToolingFactor);
|
||||||
|
|
||||||
|
#endif
|
0
src/BendAllowance.cpp
Normal file
0
src/BendAllowance.cpp
Normal file
27
src/DataLoad.cpp
Normal file
27
src/DataLoad.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
void loadDataFromCSV(const std::string& fileName) {
|
||||||
|
std::ifstream file(fileName);
|
||||||
|
if (file.is_open()) {
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
// Process the line, e.g., parse and store the data
|
||||||
|
std::cout << line << std::endl; // Example: Output the line
|
||||||
|
}
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
std::cerr << "Failed to open the file: " << fileName << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// Load historical bend data from a CSV file
|
||||||
|
loadDataFromCSV("historical_bend_data.csv");
|
||||||
|
|
||||||
|
// Load machine data from a CSV file
|
||||||
|
loadDataFromCSV("machine_data.csv");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
23
src/DataSave.cpp
Normal file
23
src/DataSave.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
void saveDataToCSV(const std::string& fileName, const std::string& data) {
|
||||||
|
std::ofstream file(fileName, std::ios::app);
|
||||||
|
if (file.is_open()) {
|
||||||
|
file << data << "\n";
|
||||||
|
file.close();
|
||||||
|
} else {
|
||||||
|
std::cerr << "Failed to open the file: " << fileName << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
// Save historical bend data to a CSV file
|
||||||
|
saveDataToCSV("historical_bend_data.csv", "Your historical bend data here");
|
||||||
|
|
||||||
|
// Save machine data to a CSV file
|
||||||
|
saveDataToCSV("machine_data.csv", "Your machine data here");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
16
src/Deserializer.cpp
Normal file
16
src/Deserializer.cpp
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include "Deserializer.h"
|
||||||
|
|
||||||
|
bool Deserializer::deserializeData(const std::string& filename, std::string& data) {
|
||||||
|
std::ifstream file(filename, std::ios::binary);
|
||||||
|
if (file.is_open()) {
|
||||||
|
file.seekg(0, std::ios::end);
|
||||||
|
std::streampos fileSize = file.tellg();
|
||||||
|
file.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
|
data.resize(fileSize);
|
||||||
|
file.read(&data[0], fileSize);
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
15
src/FormingTool.cpp
Normal file
15
src/FormingTool.cpp
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "FormingTool.h"
|
||||||
|
|
||||||
|
FormingTool::FormingTool(const std::string& name, double toolRadius, const std::string& materialType)
|
||||||
|
: m_name(name), m_toolRadius(toolRadius), m_materialType(materialType) {
|
||||||
|
// Constructor implementation
|
||||||
|
}
|
||||||
|
|
||||||
|
double FormingTool::getToolRadius() const {
|
||||||
|
return m_toolRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FormingTool::setToolRadius(double radius) {
|
||||||
|
m_toolRadius = radius;
|
||||||
|
}
|
||||||
|
// Implement other methods related to forming tools
|
11
src/Kfactor.cpp
Normal file
11
src/Kfactor.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "Kfactor.h"
|
||||||
|
#include <cmath> // Required for the pi constant
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
const double PI = 3.14159265358979323846;
|
||||||
|
|
||||||
|
// Function definition for calculating the K-factor
|
||||||
|
double calculateKFactor(double bendAllowance, double bendingAngle, double materialThickness, double innerRadius) {
|
||||||
|
double kFactor = (180.0 * bendAllowance) / (PI * bendingAngle * materialThickness) - (innerRadius / materialThickness);
|
||||||
|
return kFactor;
|
||||||
|
}
|
11
src/Serializer.cpp
Normal file
11
src/Serializer.cpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "Serializer.h"
|
||||||
|
|
||||||
|
bool Serializer::serializeData(const std::string& filename, const std::string& data) {
|
||||||
|
std::ofstream file(filename, std::ios::binary);
|
||||||
|
if (file.is_open()) {
|
||||||
|
file.write(data.c_str(), data.size());
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
0
src/Setback.cpp
Normal file
0
src/Setback.cpp
Normal file
8
src/Tonnage.cpp
Normal file
8
src/Tonnage.cpp
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include "Tonnage.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
// Function definition for calculating the press brake tonnage
|
||||||
|
double calculateTonnage(double materialThickness, double bendLength, double dieOpeningWidth, double materialFactor, double methodFactor, double multipleBendToolingFactor) {
|
||||||
|
double formingTonnage = (575 * pow(materialThickness, 2) / (dieOpeningWidth / 12)) * bendLength * materialFactor * methodFactor * multipleBendToolingFactor;
|
||||||
|
return formingTonnage;
|
||||||
|
}
|
97
src/main.cpp
Normal file
97
src/main.cpp
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of <project name>.
|
||||||
|
*
|
||||||
|
* <project name> is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the <license name> as published by
|
||||||
|
* the <license organization>, either version <license version> of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* <project name> is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* <license name> for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the <license name>
|
||||||
|
* along with <project name>. If not, see <license URL>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cctype>
|
||||||
|
#include <cstddef>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cmath>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <ctime>
|
||||||
|
#include <fstream>
|
||||||
|
#include <functional>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
#include <iterator>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <random>
|
||||||
|
#include <regex>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Tonnage.h"
|
||||||
|
#include "Kfactor.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Required Press Tonnage Calculation
|
||||||
|
*/
|
||||||
|
|
||||||
|
double materialThickness, bendLength, dieOpeningWidth, materialFactor, methodFactor, multipleBendToolingFactor;
|
||||||
|
|
||||||
|
// Get user inputs
|
||||||
|
std::cout << "Enter material thickness (in inches): ";
|
||||||
|
std::cin >> materialThickness;
|
||||||
|
std::cout << "Enter bend length (in inches): ";
|
||||||
|
std::cin >> bendLength;
|
||||||
|
std::cout << "Enter die opening width (in inches): ";
|
||||||
|
std::cin >> dieOpeningWidth;
|
||||||
|
std::cout << "Enter material factor: ";
|
||||||
|
std::cin >> materialFactor;
|
||||||
|
std::cout << "Enter method factor: ";
|
||||||
|
std::cin >> methodFactor;
|
||||||
|
std::cout << "Enter multiple-bend tooling factor: ";
|
||||||
|
std::cin >> multipleBendToolingFactor;
|
||||||
|
|
||||||
|
// Calculate the press brake tonnage using the module function
|
||||||
|
double tonnage = calculateTonnage(materialThickness, bendLength, dieOpeningWidth, materialFactor, methodFactor, multipleBendToolingFactor);
|
||||||
|
|
||||||
|
// Output the calculated tonnage
|
||||||
|
std::cout << "The required press brake tonnage is: " << tonnage << " tons" << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Kfactor calculation
|
||||||
|
*/
|
||||||
|
|
||||||
|
// User inputs for K-factor calculation
|
||||||
|
double neutralAxisLocation, materialThickness;
|
||||||
|
|
||||||
|
// Get user inputs
|
||||||
|
std::cout << "Enter neutral axis location: ";
|
||||||
|
std::cin >> neutralAxisLocation;
|
||||||
|
std::cout << "Enter material thickness: ";
|
||||||
|
std::cin >> materialThickness;
|
||||||
|
|
||||||
|
// Calculate the K-factor using the module function
|
||||||
|
double kFactor = calculateKFactor(neutralAxisLocation, materialThickness);
|
||||||
|
|
||||||
|
// Output the calculated K-factor
|
||||||
|
std::cout << "The calculated K-factor is: " << kFactor << std::endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user