Commit 6a9d48eb authored by Stefan Pfeifer's avatar Stefan Pfeifer

Use cmake as the build system

parent 580d81b0
# Hidden files
.*
!/.gitignore
# C++ objects and libs
# Build directory
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
*.exe
/build
# Qt-es
# KDevelop project files
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*build-*
*.kdev4
# QtCreator
*.autosave
# QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*
# Hidden files
# QtCtreator CMake
CMakeLists.txt.user
.*
!/.gitignore
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_CXX_STANDARD 14)
project(bow-simulator)
# Header-only libraries
set(EIGEN_INCLUDE_DIR CACHE FILEPATH "Eigen 3.3.1 include directory (http://eigen.tuxfamily.org)")
include_directories(${EIGEN_INCLUDE_DIR})
set(CATCH_INCLUDE_DIR CACHE FILEPATH "Catch 1.5.9 include directory (https://github.com/philsquared/Catch)")
include_directories(${CATCH_INCLUDE_DIR})
set(JSONCONS_INCLUDE_DIR CACHE FILEPATH "Jsoncons 0.99.5 include directory (https://github.com/danielaparker/jsoncons)")
include_directories(${JSONCONS_INCLUDE_DIR})
set(BOOST_INCLUDE_DIR CACHE FILEPATH "Boost 1.62.0 include directory (http://www.boost.org)")
include_directories(${BOOST_INCLUDE_DIR})
# Qt # Todo: Set version
find_package(Qt5Widgets REQUIRED)
find_package(Qt5X11Extras REQUIRED)
find_package(Qt5PrintSupport REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) # Add resource files to sources, cmake does the rest
set(CMAKE_AUTOUIC ON)
# VTK
find_package(VTK 7.1.0 REQUIRED)
# Compile and link
add_executable(${PROJECT_NAME}
source/main.cpp
source/fem/elements/BarElement.cpp
source/fem/elements/BeamElement.cpp
source/fem/elements/MassElement.cpp
source/fem/Element.cpp
source/fem/Node.cpp
source/fem/Solver.cpp
source/fem/System.cpp
source/gui/input/BowEditor.cpp
source/gui/input/CommentsDialog.cpp
source/gui/input/DoubleView.cpp
source/gui/input/IntegerView.cpp
source/gui/input/NumberGroup.cpp
source/gui/input/SeriesView.cpp
source/gui/input/SettingsDialog.cpp
source/gui/output/ComboPlot.cpp
source/gui/output/EnergyPlot.cpp
source/gui/output/OutputDialog.cpp
source/gui/output/OutputGrid.cpp
source/gui/output/ShapePlot.cpp
source/gui/output/Slider.cpp
source/gui/output/StressPlot.cpp
source/gui/MainWindow.cpp
source/gui/Plot.cpp
source/gui/ProgressDialog.cpp
source/gui/input/SplineView.cpp
source/gui/input/ProfileView.cpp
source/gui/input/LimbView.cpp
source/model/BowModel.cpp
source/model/DiscreteLimb.cpp
source/model/InputData.cpp
source/model/OutputData.cpp
source/numerics/ArcCurve.cpp
source/numerics/CubicSpline.cpp
source/numerics/Series.cpp
source/external/qcustomplot/qcustomplot.cpp
# moc
source/model/Document.hpp
# resources
resources/resources.qrc
)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} Qt5::PrintSupport)
target_link_libraries(${PROJECT_NAME} ${VTK_LIBRARIES})
# Install
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
......@@ -157,6 +157,8 @@ General
* Use Linspace class more often (e.g. for sampling curvces)
* Use DiscreteLimb class for graphic previews. Give it an optional sampling parameter to use instead of the number of elements.
Platform dependent
==================
......
Redesign of 'Bow Simulation Tool' (http://stfnp.bitbucket.org/) under a new name. Not yet usable.
Bow and arrow physics simulation. Visit https://bow-simulator.sourceforge.io/ for more information.
INCLUDEPATH += /mnt/Daten/Libraries/Eigen-3.3.1 \ # http://eigen.tuxfamily.org
/mnt/Daten/Libraries/Catch-1.5.9/include \ # https://github.com/philsquared/Catch
/mnt/Daten/Libraries/Jsoncons-0.99.5/src \ # https://github.com/danielaparker/jsoncons
/mnt/Daten/Libraries/Boost-1.62.0 \ # http://www.boost.org
TARGET = bow-simulator
TEMPLATE = app
# install
target.path = /bin
INSTALLS += target
# Todo: Remove opengl?
QT += core gui widgets opengl printsupport
# Todo: Remove what's not needed
QT += 3dcore 3drender 3dinput 3dextras
RESOURCES += resources/resources.qrc
HEADERS += \
source/external/qcustomplot/qcustomplot.h \
source/fem/elements/BarElement.hpp \
source/fem/elements/BeamElement.hpp \
source/fem/elements/MassElement.hpp \
source/fem/Element.hpp \
source/fem/Node.hpp \
source/fem/Solver.hpp \
source/fem/System.hpp \
source/fem/View.hpp \
source/gui/input/BowEditor.hpp \
source/gui/input/CommentsDialog.hpp \
source/gui/input/DoubleView.hpp \
source/gui/input/IntegerView.hpp \
source/gui/input/NumberGroup.hpp \
source/gui/input/SeriesView.hpp \
source/gui/input/SettingsDialog.hpp \
source/gui/output/ComboPlot.hpp \
source/gui/output/EnergyPlot.hpp \
source/gui/output/OutputDialog.hpp \
source/gui/output/OutputGrid.hpp \
source/gui/output/ShapePlot.hpp \
source/gui/output/Slider.hpp \
source/gui/output/StressPlot.hpp \
source/gui/MainWindow.hpp \
source/gui/Plot.hpp \
source/gui/ProgressDialog.hpp \
source/model/BowModel.hpp \
source/model/DiscreteLimb.hpp \
source/model/Document.hpp \
source/model/InputData.hpp \
source/model/OutputData.hpp \
source/numerics/ArcCurve.hpp \
source/numerics/CubicSpline.hpp \
source/numerics/Curve.hpp \
source/numerics/Domain.hpp \
source/numerics/Linspace.hpp \
source/numerics/SecantMethod.hpp \
source/numerics/Series.hpp \
source/numerics/TDMatrix.hpp \
source/numerics/Units.hpp \
source/utils/DynamicCastIterator.hpp \
source/utils/Optional.hpp \
source/gui/input/SplineView.hpp \
source/gui/input/ProfileView.hpp \
source/gui/input/GeometryView.hpp
SOURCES += \
source/external/qcustomplot/qcustomplot.cpp \
source/fem/elements/BarElement.cpp \
source/fem/elements/BeamElement.cpp \
source/fem/elements/MassElement.cpp \
source/fem/Element.cpp \
source/fem/Node.cpp \
source/fem/Solver.cpp \
source/fem/System.cpp \
source/gui/input/BowEditor.cpp \
source/gui/input/CommentsDialog.cpp \
source/gui/input/DoubleView.cpp \
source/gui/input/IntegerView.cpp \
source/gui/input/NumberGroup.cpp \
source/gui/input/SeriesView.cpp \
source/gui/input/SettingsDialog.cpp \
source/gui/output/ComboPlot.cpp \
source/gui/output/EnergyPlot.cpp \
source/gui/output/OutputDialog.cpp \
source/gui/output/OutputGrid.cpp \
source/gui/output/ShapePlot.cpp \
source/gui/output/Slider.cpp \
source/gui/output/StressPlot.cpp \
source/gui/MainWindow.cpp \
source/gui/Plot.cpp \
source/gui/ProgressDialog.cpp \
source/model/BowModel.cpp \
source/model/DiscreteLimb.cpp \
source/model/InputData.cpp \
source/model/OutputData.cpp \
source/numerics/ArcCurve.cpp \
source/numerics/CubicSpline.cpp \
source/numerics/Series.cpp \
source/main.cpp \
source/gui/input/SplineView.cpp \
source/gui/input/ProfileView.cpp \
source/gui/input/LimbView.cpp
# Compiler flags
CONFIG += c++14
# Platform specific
win32-g++{
# http://eigen.tuxfamily.org/dox-devel/group__TopicWrongStackAlignment.html
QMAKE_CXXFLAGS += -mincoming-stack-boundary=2
}
......@@ -10,8 +10,7 @@
BowEditor::BowEditor(InputData& data)
: QSplitter(Qt::Vertical)
{
//this->addWidget(new GeometryView(data));
this->addWidget(QWidget::createWindowContainer(new GeometryView(data)));
this->addWidget(new GeometryView(data));
auto tabs = new QTabWidget();
tabs->addTab(new ProfileEditor(data), "Profile");
......
This diff is collapsed.
......@@ -23,20 +23,19 @@ void ProfileView::update()
{
try
{
Curve profile = ArcCurve::sample(data.profile_segments,
Curve2D curve = ArcCurve::sample(data.profile_segments,
data.profile_x0,
data.profile_y0,
data.profile_phi0,
150); // Todo: Magic number
Curve segments = ArcCurve::sample(data.profile_segments,
data.profile_x0,
data.profile_y0,
data.profile_phi0,
0);
Curve2D nodes = ArcCurve::nodes(data.profile_segments,
data.profile_x0,
data.profile_y0,
data.profile_phi0);
this->setData(0, Series(profile.x, profile.y));
this->setData(1, Series(segments.x, segments.y));
this->setData(0, Series(curve.x, curve.y));
this->setData(1, Series(nodes.x, nodes.y));
}
catch(const std::runtime_error&)
{
......
#include "gui/MainWindow.hpp"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
setlocale(LC_NUMERIC, "C");
QGuiApplication::setApplicationDisplayName("Bow Simulator");
QGuiApplication::setApplicationVersion("0.1.0");
QGuiApplication::setOrganizationDomain("https://bow-simulator.sourceforge.net");
QStringList args = QApplication::arguments();
MainWindow window(args.size() == 1 ? ":/bows/default.bow" : args.at(1));
window.show();
return app.exec();
}
/*
#include <QGuiApplication>
......@@ -189,24 +207,6 @@ int main(int argc, char* argv[])
}
*/
#include "gui/MainWindow.hpp"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
setlocale(LC_NUMERIC, "C");
QGuiApplication::setApplicationDisplayName("Bow Simulator");
QGuiApplication::setApplicationVersion("0.1.0");
QGuiApplication::setOrganizationDomain("https://bow-simulator.sourceforge.net");
QStringList args = QApplication::arguments();
MainWindow window(args.size() == 1 ? ":/bows/default.bow" : args.at(1));
window.show();
return app.exec();
}
/*
#include <iostream>
......
......@@ -59,17 +59,17 @@ struct DiscreteLimb
DiscreteLimb(const InputData& input)
{
// 1. Nodes
Curve nodes = ArcCurve::sample(input.profile_segments,
input.profile_x0,
input.profile_y0,
input.profile_phi0,
input.settings_n_elements_limb);
// Todo: Is there a more elegant way? Maybe have a Curve member?
s = nodes.s;
x = nodes.x;
y = nodes.y;
phi = nodes.phi;
Curve2D curve = ArcCurve::sample(input.profile_segments,
input.profile_x0,
input.profile_y0,
input.profile_phi0,
input.settings_n_elements_limb);
// Todo: Is there a more elegant way? Maybe have a Curve2D member?
s = curve.s;
x = curve.x;
y = curve.y;
phi = curve.phi;
// 2. Sections
Series w = CubicSpline::sample(input.sections_width, input.settings_n_elements_limb);
......
#include "ArcCurve.hpp"
#include <cassert>
// n: Number of sampling steps. For n = 0 the segment nodes are calculated instead.
// alpha: Angle between curve and y-axis
Curve ArcCurve::sample(const Series& segments, double x0, double y0, double phi0, unsigned n)
Curve2D ArcCurve::nodes(const Series& segments, double x0, double y0, double phi0)
{
if(n == 0)
Curve2D nodes;
nodes.add_point({0.0, x0, y0, phi0});
for(size_t i = 0; i < segments.size(); ++i)
{
Curve nodes;
nodes.add_point({0.0, x0, y0, phi0});
auto p = eval_arc({nodes.s[i], nodes.x[i], nodes.y[i], nodes.phi[i]}, segments.val(i), segments.arg(i));
nodes.add_point(p);
}
for(size_t i = 0; i < segments.size(); ++i)
{
auto p = eval_arc({nodes.s[i], nodes.x[i], nodes.y[i], nodes.phi[i]}, segments.val(i), segments.arg(i));
nodes.add_point(p);
}
return nodes;
}
return nodes;
}
else
// n: Number of sampling steps/intervals.
// alpha: Angle between curve and y-axis
Curve2D ArcCurve::sample(const Series& segments, double x0, double y0, double phi0, unsigned n)
{
Curve2D nodes = ArcCurve::nodes(segments, x0, y0, phi0);
unsigned j = 0; // Segment index
auto eval_curve = [&](double s)
{
Curve curve;
Curve nodes = ArcCurve::sample(segments, x0, y0, phi0, 0);
curve.add_point({nodes.s[0], nodes.x[0], nodes.y[0], nodes.phi[0]});
// Make sure that s[j] <= s <= s[j + 1]
while(s > nodes.s[j+1])
++j;
// i: Segment
// j: Sampling interval
unsigned i = 0;
for(unsigned j = 0; j < n; ++j)
{
double sj = double(j+1)/double(n)*nodes.s.back();
if(sj > nodes.s[i+1])
{
++i;
}
assert(s >= nodes.s[j]);
auto p = eval_arc({nodes.s[i], nodes.x[i], nodes.y[i], nodes.phi[i]}, segments.val(i), sj - nodes.s[i]);
curve.add_point(p);
}
// Todo: Add get_point(size_t) method to Curve2D?
double kappa = segments.val(j);
double ds = s - nodes.s[j];
return eval_arc({nodes.s[j], nodes.x[j], nodes.y[j], nodes.phi[j]}, kappa, ds);
};
return curve;
Curve2D result;
for(unsigned i = 0; i <= n; ++i)
{
double s = double(i)/double(n)*nodes.s.back();
result.add_point(eval_curve(s));
}
return result;
}
// Calculates the end point of an arc segment with staring point p0, curvature kappa and arc length ds.
CurvePoint ArcCurve::eval_arc(CurvePoint p0, double kappa, double ds)
Curve2D::Point ArcCurve::eval_arc(Curve2D::Point p0, double kappa, double ds)
{
CurvePoint p;
Curve2D::Point p;
p.s = p0.s + ds;
p.phi = p0.phi + kappa*ds;
......
#pragma once
#include "Series.hpp"
#include "Curve.hpp"
#include "Curve2D.hpp"
class ArcCurve
{
public:
static Curve sample(const Series& segments, double x0, double y0, double phi0, unsigned n);
static Curve2D nodes(const Series& segments, double x0, double y0, double phi0);
static Curve2D sample(const Series& segments, double x0, double y0, double phi0, unsigned n);
private:
static CurvePoint eval_arc(CurvePoint p0, double kappa, double ds);
static Curve2D::Point eval_arc(Curve2D::Point p0, double kappa, double ds);
};
#pragma once
#include <vector>
struct CurvePoint
{
double s;
double x;
double y;
double phi;
};
struct Curve
struct Curve2D
{
std::vector<double> s;
std::vector<double> x;
std::vector<double> y;
std::vector<double> phi;
void add_point(CurvePoint p)
struct Point
{
double s;
double x;
double y;
double phi;
};
void add_point(Point p)
{
s.push_back(p.s);
x.push_back(p.x);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment