├── .clang-tidy
├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── COPYING.GPL.md
├── COPYING.md
├── CPPLINT.cfg
├── README.md
├── StyleGuide.md
├── cmake
├── Config.cmake.in
└── Modules
│ └── FindGMock.cmake
├── example
├── CMakeLists.txt
├── ex1.cc
├── iga
│ ├── CMakeLists.txt
│ ├── cmake
│ │ ├── Config.cmake.in
│ │ └── Modules
│ │ │ └── FindGMock.cmake
│ ├── scripts
│ │ └── spack-repo
│ │ │ ├── packages
│ │ │ └── csiga
│ │ │ │ └── package.py
│ │ │ └── repo.yaml
│ ├── src
│ │ ├── CMakeLists.txt
│ │ ├── basis_function_handler.h
│ │ ├── bdf_handler.h
│ │ ├── connectivity_handler.h
│ │ ├── element.h
│ │ ├── element_generator.h
│ │ ├── element_integral_calculator.h
│ │ ├── element_integration_point.h
│ │ ├── itg
│ │ │ ├── CMakeLists.txt
│ │ │ ├── five_point_gauss_legendre.h
│ │ │ ├── four_point_gauss_legendre.h
│ │ │ ├── integration_point.h
│ │ │ ├── integration_rule.h
│ │ │ ├── one_point_gauss_legendre.h
│ │ │ ├── three_point_gauss_legendre.h
│ │ │ └── two_point_gauss_legendre.h
│ │ ├── linear_equation_assembler.h
│ │ ├── mapping_handler.h
│ │ ├── poisson_problem.h
│ │ ├── solution_spline.h
│ │ └── solution_vtk_writer.h
│ └── test
│ │ ├── CMakeLists.txt
│ │ ├── basis_function_handler_test.cc
│ │ ├── bdf_handler_test.cc
│ │ ├── connectivity_handler_test.cc
│ │ ├── element_generator_test.cc
│ │ ├── element_integral_calculator_test.cc
│ │ ├── element_integration_point_test.cc
│ │ ├── element_test.cc
│ │ ├── integration_point_test.cc
│ │ ├── integration_rule_test.cc
│ │ ├── linear_equation_assembler_test.cc
│ │ ├── mapping_handler_test.cc
│ │ ├── matlab_test_data.h
│ │ ├── matlab_test_data_2.h
│ │ ├── solution_vtk_writer_examples.cc
│ │ ├── solution_vtk_writer_test.cc
│ │ └── test_spline.h
├── log.txt
└── testcase_optimizer.cc
├── external
├── CMakeLists.txt
└── pugixml
│ ├── CMakeLists.txt
│ ├── pugiconfig.hpp
│ ├── pugixml.cpp
│ └── pugixml.hpp
├── scripts
├── build
│ ├── before_install_osx.sh
│ ├── create_build_folders.sh
│ └── install_spack.sh
├── docker
│ ├── Dockerfile.acceptancetests
│ ├── Dockerfile.armadillo
│ ├── Dockerfile.convert
│ ├── Dockerfile.gtest
│ ├── Dockerfile.iga
│ ├── Dockerfile.install
│ ├── Dockerfile.lint.clang-tidy
│ ├── Dockerfile.lint.cpplint
│ ├── Dockerfile.spack
│ ├── Dockerfile.test.clang5.debug
│ ├── Dockerfile.test.clang5.release
│ ├── Dockerfile.test.clang6.debug
│ ├── Dockerfile.test.clang6.release
│ ├── Dockerfile.test.coverage
│ ├── Dockerfile.test.gcc7.debug
│ ├── Dockerfile.test.gcc7.release
│ ├── Dockerfile.test.gcc8.debug
│ ├── Dockerfile.test.gcc8.release
│ ├── Dockerfile.test.gcc8.valgrind
│ └── packages.yaml
├── run-clang-tidy.py
└── spack-repo
│ ├── packages
│ └── splinelib
│ │ └── package.py
│ └── repo.yaml
├── src
├── CMakeLists.txt
├── baf
│ ├── CMakeLists.txt
│ ├── b_spline_basis_function.cc
│ ├── b_spline_basis_function.h
│ ├── basis_function.cc
│ ├── basis_function.h
│ ├── basis_function_factory.cc
│ ├── basis_function_factory.h
│ ├── control_point.cc
│ ├── control_point.h
│ ├── knot_vector.cc
│ ├── knot_vector.h
│ ├── zero_degree_b_spline_basis_function.cc
│ └── zero_degree_b_spline_basis_function.h
├── io
│ ├── CMakeLists.txt
│ ├── executables
│ │ ├── CMakeLists.txt
│ │ ├── converter_log.cc
│ │ ├── converter_log.h
│ │ ├── iges_to_irit.cc
│ │ ├── iges_to_vtk.cc
│ │ ├── iges_to_xml.cc
│ │ ├── irit_to_iges.cc
│ │ ├── irit_to_vtk.cc
│ │ ├── irit_to_xml.cc
│ │ ├── xml_to_iges.cc
│ │ ├── xml_to_irit.cc
│ │ └── xml_to_vtk.cc
│ ├── iges_reader.cc
│ ├── iges_reader.h
│ ├── iges_writer.cc
│ ├── iges_writer.h
│ ├── io_converter.cc
│ ├── io_converter.h
│ ├── irit_reader.cc
│ ├── irit_reader.h
│ ├── irit_reader_utils.h
│ ├── irit_writer.cc
│ ├── irit_writer.h
│ ├── irit_writer_utils.h
│ ├── reader.h
│ ├── vtk_writer.cc
│ ├── vtk_writer.h
│ ├── vtk_writer_utils.h
│ ├── writer.h
│ ├── xml_reader.cc
│ ├── xml_reader.h
│ ├── xml_reader_utils.h
│ ├── xml_writer.cc
│ ├── xml_writer.h
│ └── xml_writer_utils.h
├── spl
│ ├── CMakeLists.txt
│ ├── alias.h
│ ├── b_spline.h
│ ├── b_spline_generator.h
│ ├── nurbs.h
│ ├── nurbs_generator.h
│ ├── parameter_space.h
│ ├── physical_space.h
│ ├── projection.h
│ ├── random_b_spline_generator.h
│ ├── random_nurbs_generator.h
│ ├── random_spline_utils.h
│ ├── spline.h
│ ├── spline_generator.h
│ ├── square_generator.cc
│ ├── square_generator.h
│ ├── surface_generator.cc
│ ├── surface_generator.h
│ └── weighted_physical_space.h
└── util
│ ├── CMakeLists.txt
│ ├── any_casts.h
│ ├── element.h
│ ├── element_generator.h
│ ├── multi_index_handler.h
│ ├── named_type.h
│ ├── numeric_operations.h
│ ├── numeric_settings.h
│ ├── random.h
│ ├── string_operations.h
│ ├── system_operations.h
│ └── vector_utils.h
└── test
├── CMakeLists.txt
├── acceptance_tests.cc
├── baf
├── CMakeLists.txt
├── b_spline_basis_function_test.cc
├── basis_function_factory.cc
├── control_point_test.cc
├── knot_vector_test.cc
└── zero_degree_b_spline_basis_function_test.cc
├── io
├── CMakeLists.txt
├── config_iges.in.h
├── config_irit.in.h
├── config_xml.in.h
├── iges_reader_writer_test.cc
├── io_converter_executables_test.cc
├── io_converter_test.cc
├── irit_reader_writer_test.cc
├── test_files
│ ├── read.iges
│ ├── read2.iges
│ ├── spline_tank.xml
│ └── test.itd
├── vtk_writer_test.cc
├── xml_reader_test.cc
└── xml_writer_test.cc
├── spl
├── CMakeLists.txt
├── b_spline_2d_mocking.h
├── b_spline_2d_test.cc
├── b_spline_test.cc
├── degree_elevation_test.cc
├── degree_reduction_test.cc
├── knot_insertion_and_removal_test.cc
├── knot_insertion_test.cc
├── knot_removal_test.cc
├── nurbs_2d_mocking.h
├── nurbs_2d_test.cc
├── nurbs_3d_mocking.h
├── nurbs_3d_test.cc
├── nurbs_test.cc
├── parameter_space_test.cc
├── physical_space_test.cc
├── projection_curve_test.cc
├── projection_surface_test.cc
├── random_b_spline_generator_test.cc
├── random_nurbs_generator_test.cc
├── spline_subdivision_test.cc
├── square_generator_test.cc
├── surface_generator_test.cc
└── weighted_physical_space_test.cc
└── util
├── CMakeLists.txt
├── any_casts_test.cc
├── multi_index_handler_test.cc
├── string_operations_test.cc
└── vector_utils_test.cc
/.clang-tidy:
--------------------------------------------------------------------------------
1 | Checks: '*,-hicpp-braces-around-statements,-readability-braces-around-statements,-android-*,-llvm-include-order,-fuchsia-overloaded-operator,-fuchsia-default-arguments,-cppcoreguidelines-pro-bounds-constant-array-index'
2 | FormatStyle: google
3 | WarningsAsErrors: '*'
4 | CheckOptions:
5 | - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
6 | value: '1'
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Prerequisites
2 | *.d
3 |
4 | # Compiled Object files
5 | *.slo
6 | *.lo
7 | *.o
8 | *.obj
9 | build/*
10 | *.pyc
11 |
12 | # Precompiled Headers
13 | *.gch
14 | *.pch
15 |
16 | # Compiled Dynamic libraries
17 | *.so
18 | *.dylib
19 | *.dll
20 |
21 | # Fortran module files
22 | *.mod
23 | *.smod
24 |
25 | # Compiled Static libraries
26 | *.lai
27 | *.la
28 | *.a
29 | *.lib
30 |
31 | # Executables
32 | *.exe
33 | *.out
34 | *.app
35 |
36 | # IDE files
37 | cmake-build-*
38 | .idea
39 |
40 | # mac related files
41 | .DS_Store
42 | ._.DS_Store
43 |
44 | # example build
45 | example/build/*
46 |
--------------------------------------------------------------------------------
/CPPLINT.cfg:
--------------------------------------------------------------------------------
1 | linelength=120
2 | filter=-build/include_subdir,-build/c++11
3 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | **This repository is no longer maintained. The work is continued under https://github.com/SplineLib/SplineLib.**
2 |
3 | # SplineLib
4 | Library for spline manipulation.
5 |
6 | ## License
7 | Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
8 |
9 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
10 | License as published by the Free Software Foundation version 3 of the License.
11 |
12 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
13 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14 | details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
17 | http://www.gnu.org/licenses/.
18 |
19 | ### Citation
20 | If you want to use SplineLib in your scientific project please cite [](https://doi.org/10.5281/zenodo.1320259).
21 |
22 | ## Status
23 | [](https://www.codefactor.io/repository/github/mfcats/splinelib)
24 | [](https://codecov.io/gh/mfcats/SplineLib)
25 | [](https://travis-ci.org/mfcats/SplineLib)
26 |
27 |
28 | ## Installation
29 |
30 | A compiler with C++ 17 support is required to successfully build SplineLib. Compilers that fulfill this requirement are GCC 7, GCC 8, clang 5, and clang 6. The project is tested with these compilers. Therefore, the master branch should always run with them.
31 |
32 | To use SplineLib, you have to clone the github repository to your local machine.
33 |
34 | $ git clone https://github.com/mfcats/SplineLib.git
35 |
36 | For installation of all dependencies you can use spack.
37 | For more information on how to install spack see: https://spack.readthedocs.io/en/latest/
38 |
39 | After installing spack you need to add the SplineLib repository.
40 |
41 | $ spack repo add path/to/SplineLib/scripts/spack-repo
42 |
43 | After that you can install the SplineLib.
44 |
45 | $ spack install splinelib
46 |
47 | This will install the Google testing framework as dependency and afterwards SplineLib. Then, you can use SplineLib by running
48 |
49 | $ spack load splinelib
50 |
51 |
52 |
53 |
54 | ## Installation for developers
55 |
56 | If you wish to install the SplineLib for development use the following command:
57 |
58 | $ spack setup splinelib@github
59 |
60 | Now go to the SplineLib directory and create a build directory in which you can
61 | build SplineLib with CMake and make.
62 |
63 | $ mkdir build
64 | $ cd build
65 | $ ./spconfig.py ..
66 |
67 | To verify that everything went right you can execute the built-in SplineLib tests.
68 |
69 | $ ./test/SplineLibTests
70 |
--------------------------------------------------------------------------------
/StyleGuide.md:
--------------------------------------------------------------------------------
1 | # Style Guide for SplineLib
2 | In general the project sticks to the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). This
3 | guide only describes these project differs from Google's guide.
4 |
5 | To check if the code is compliant with the Google C++ Style Guide [cpplint](https://github.com/cpplint/cpplint) can be
6 | used. cpplint is a linter written in python. To install the linter see the guidelines on github.
7 |
8 | ## Formatting
9 | ### Line lenght
10 | Google prescribes a [line length](https://google.github.io/styleguide/cppguide.html#Line_Length) of 80 characters. For
11 | modern displays this is a very narrow restriction. Since variable and method names shall be descriptive, this limit is
12 | reached very fast. Therefore, the line length is restricted to 120 characters. To account for this rule the change is
13 | defined in the CPPLINT.cfg of this project.
14 |
--------------------------------------------------------------------------------
/cmake/Config.cmake.in:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
4 | check_required_components("@PROJECT_NAME@")
--------------------------------------------------------------------------------
/example/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | cmake_minimum_required(VERSION 3.6)
17 |
18 | project(SplineLibExamples LANGUAGES CXX)
19 | set(CMAKE_CXX_STANDARD 17)
20 |
21 | set(SOURCES ex1.cc)
22 | set(OPTIMIZER testcase_optimizer.cc)
23 |
24 | find_package(SplineLib REQUIRED)
25 |
26 | add_executable(ex1 ${SOURCES})
27 | add_executable(TestcaseOptimizer ${OPTIMIZER})
28 |
29 | target_link_libraries(ex1 SplineLib::splinelibspl)
30 | target_link_libraries(TestcaseOptimizer SplineLib::splinelibspl SplineLib::splinelibutil SplineLib::splinelibio)
31 |
32 |
--------------------------------------------------------------------------------
/example/ex1.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 | #include
17 | #include
18 |
19 | #include "b_spline.h"
20 | #include "control_point.h"
21 | #include "knot_vector.h"
22 |
23 | int main() {
24 | std::array degree = {Degree{2}};
25 | std::vector control_points = {
26 | baf::ControlPoint(std::vector({4.0, 2.0})),
27 | baf::ControlPoint(std::vector({7.0, 1.5})),
28 | baf::ControlPoint(std::vector({11.0, 2.0})),
29 | baf::ControlPoint(std::vector({2.5, 4.5})),
30 | baf::ControlPoint(std::vector({3.0, 4.3})),
31 | baf::ControlPoint(std::vector({7.0, 3.0})),
32 | baf::ControlPoint(std::vector({8.0, 2.5})),
33 | baf::ControlPoint(std::vector({8.0, 1.0}))
34 | };
35 | KnotVectors<1> knot_vector_ptr =
36 | {std::make_shared(baf::KnotVector({ParamCoord{0}, ParamCoord{0}, ParamCoord{0}, ParamCoord{1},
37 | ParamCoord{2}, ParamCoord{3}, ParamCoord{4}, ParamCoord{4},
38 | ParamCoord{5}, ParamCoord{5}, ParamCoord{5}}))};
39 | spl::BSpline<1> b_spline(knot_vector_ptr, degree, control_points);
40 |
41 | b_spline.Evaluate({ParamCoord{1.0}}, {0});
42 |
43 | return 0;
44 | }
45 |
--------------------------------------------------------------------------------
/example/iga/cmake/Config.cmake.in:
--------------------------------------------------------------------------------
1 | @PACKAGE_INIT@
2 |
3 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
4 | check_required_components("@PROJECT_NAME@")
--------------------------------------------------------------------------------
/example/iga/scripts/spack-repo/packages/csiga/package.py:
--------------------------------------------------------------------------------
1 | # Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
2 | # Spack Project Developers. See the top-level COPYRIGHT file for details.
3 | #
4 | # SPDX-License-Identifier: (Apache-2.0 OR MIT)
5 |
6 | # ----------------------------------------------------------------------------
7 | # If you submit this package back to Spack as a pull request,
8 | # please first remove this boilerplate and all FIXME comments.
9 | #
10 | # This is a template package file for Spack. We've put "FIXME"
11 | # next to all the things you'll want to change. Once you've handled
12 | # them, you can save this file and test your package like this:
13 | #
14 | # spack install csiga
15 | #
16 | # You can edit this file again by typing:
17 | #
18 | # spack edit csiga
19 | #
20 | # See the Spack documentation for more information on packaging.
21 | # ----------------------------------------------------------------------------
22 |
23 | from spack import *
24 |
25 |
26 | class Csiga(CMakePackage):
27 | """Library for Isogeometric Analysis."""
28 |
29 | homepage = "https://git.rwth-aachen.de/christophsusen/csiga"
30 | url = ""
31 |
32 | version('github', git='https://git.rwth-aachen.de/christophsusen/csiga.git', branch='master')
33 |
34 | depends_on("googletest+gmock~shared")
35 | depends_on("armadillo")
36 | depends_on("splinelib")
37 |
38 | def cmake_args(self):
39 | options = []
40 | return options
41 |
--------------------------------------------------------------------------------
/example/iga/scripts/spack-repo/repo.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # Created by Christoph Susen on 24.01.19.
3 | #
4 |
5 | repo:
6 | namespace: csiga-software
7 |
--------------------------------------------------------------------------------
/example/iga/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | add_subdirectory(itg)
17 |
18 | list(APPEND CMAKE_PREFIX_PATH /usr/local/opt/spack/linux-ubuntu18.04-x86_64/gcc-8/splinelib-github-t7by6dejarqmydvm2xo5zgcqtvkpz3dz)
19 |
20 | find_package(Armadillo REQUIRED)
21 | find_package(SplineLib REQUIRED)
22 |
23 | add_library(CSiga INTERFACE)
24 | target_include_directories(CSiga INTERFACE
25 | $ ${ARMADILLO_INCLUDE_DIRS})
26 | target_link_libraries(CSiga INTERFACE CSigaitg SplineLib::splinelibspl SplineLib::splinelibio ${ARMADILLO_LIBRARIES})
27 |
28 | install(
29 | TARGETS CSiga
30 | EXPORT "${targets_export_name}"
31 | LIBRARY DESTINATION "${library_install_dir}"
32 | ARCHIVE DESTINATION "${library_install_dir}"
33 | RUNTIME DESTINATION "${executable_install_dir}"
34 | INCLUDES DESTINATION "${include_install_dir}"
35 | )
36 |
37 | install(FILES
38 | basis_function_handler.h
39 | bdf_handler.h
40 | connectivity_handler.h
41 | element.h
42 | element_generator.h
43 | element_integral_calculator.h
44 | element_integration_point.h
45 | linear_equation_assembler.h
46 | mapping_handler.h
47 | poisson_problem.h
48 | solution_spline.h
49 | solution_vtk_writer.h
50 | DESTINATION "${include_install_dir}")
51 |
--------------------------------------------------------------------------------
/example/iga/src/connectivity_handler.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_CONNECTIVITY_HANDLER_H_
16 | #define SRC_IGA_CONNECTIVITY_HANDLER_H_
17 |
18 | #include
19 |
20 | #include "element_generator.h"
21 | #include "multi_index_handler.h"
22 | #include "spline.h"
23 |
24 | namespace iga {
25 | template
26 | class ConnectivityHandler {
27 | public:
28 | explicit ConnectivityHandler(std::shared_ptr> spl) : spline_(std::move(spl)) {
29 | elm_gen_ = std::make_shared>(spline_);
30 | }
31 |
32 | int GetGlobalIndex(int element_number, int local_index) {
33 | return Get1DGlobalIndex(GetGlobalIndicesPerParametricDirection(element_number, local_index));
34 | }
35 |
36 | private:
37 | std::array GetGlobalIndicesPerParametricDirection(int elm_num, int local_index) {
38 | util::MultiIndexHandler mult_ind_handl_elm(elm_gen_->GetNumElementsPerParamDir());
39 | mult_ind_handl_elm = mult_ind_handl_elm + elm_num;
40 | std::array num_non_zero_baf{};
41 | for (int i = 0; i < DIM; ++i) {
42 | num_non_zero_baf[i] = spline_->GetDegree(i).get() + 1;
43 | }
44 | util::MultiIndexHandler mult_ind_handl_baf(num_non_zero_baf);
45 | mult_ind_handl_baf = mult_ind_handl_baf + local_index;
46 | std::array knot_mult_index_shift = elm_gen_->GetKnotMultiplicityIndexShift(elm_num);
47 | std::array global_indices{};
48 | for (int i = 0; i < DIM; ++i) {
49 | global_indices[i] = mult_ind_handl_baf[i] + mult_ind_handl_elm[i] + knot_mult_index_shift[i];
50 | }
51 | return global_indices;
52 | }
53 |
54 | int Get1DGlobalIndex(std::array global_indices) {
55 | util::MultiIndexHandler mult_ind_handl_cp(spline_->GetPointsPerDirection());
56 | mult_ind_handl_cp.SetIndices(global_indices);
57 | return mult_ind_handl_cp.Get1DIndex() + 1;
58 | }
59 |
60 | std::shared_ptr> spline_;
61 | std::shared_ptr> elm_gen_;
62 | };
63 | } // namespace iga
64 |
65 | #endif // SRC_IGA_CONNECTIVITY_HANDLER_H_
66 |
--------------------------------------------------------------------------------
/example/iga/src/element.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ELM_ELEMENT_H_
16 | #define SRC_IGA_ELM_ELEMENT_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "control_point.h"
22 | #include "knot_vector.h"
23 |
24 | namespace iga {
25 | namespace elm {
26 | class Element {
27 | public:
28 | explicit Element(const std::array &nodes) : nodes_(nodes) {}
29 |
30 | ParamCoord GetLowerBound() const {
31 | return nodes_[0];
32 | }
33 |
34 | ParamCoord GetUpperBound() const {
35 | return nodes_[1];
36 | }
37 |
38 | private:
39 | std::array nodes_;
40 | };
41 | } // namespace elm
42 | } // namespace iga
43 |
44 | #endif // SRC_IGA_ELM_ELEMENT_H_
45 |
--------------------------------------------------------------------------------
/example/iga/src/element_integration_point.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ELM_ELEMENT_INTEGRATION_POINT_H_
16 | #define SRC_IGA_ELM_ELEMENT_INTEGRATION_POINT_H_
17 |
18 | #include
19 | #include
20 |
21 | namespace iga {
22 | namespace elm {
23 | template
24 | class ElementIntegrationPoint {
25 | public:
26 | ElementIntegrationPoint(std::vector basis_functions, double weight,
27 | double jac_det) : non_zero_basis_functions_(std::move(basis_functions)), weight_(weight), jac_det_(jac_det) {}
28 |
29 | ElementIntegrationPoint(std::array, DIM> basis_function_derivatives, double weight,
30 | double jac_det) : non_zero_basis_function_derivatives_(std::move(basis_function_derivatives)),
31 | weight_(weight), jac_det_(jac_det) {}
32 |
33 | std::vector GetNonZeroBasisFunctions() const {
34 | return non_zero_basis_functions_;
35 | }
36 |
37 | std::vector GetNonZeroBasisFunctionDerivatives(int dir) const {
38 | return non_zero_basis_function_derivatives_[dir];
39 | }
40 |
41 | double GetWeight() const {
42 | return weight_;
43 | }
44 |
45 | double GetJacobianDeterminant() const {
46 | return jac_det_;
47 | }
48 |
49 | int GetNumberOfNonZeroBasisFunctions() const {
50 | return static_cast(non_zero_basis_functions_.size());
51 | }
52 |
53 | int GetNumberOfNonZeroBasisFunctionDerivatives(int dir) const {
54 | return static_cast(non_zero_basis_function_derivatives_[dir].size());
55 | }
56 |
57 | double GetBasisFunctionValue(int firstNonZeroOffset) const {
58 | return non_zero_basis_functions_[firstNonZeroOffset];
59 | }
60 |
61 | double GetBasisFunctionDerivativeValue(int firstNonZeroOffset, int dir) const {
62 | return non_zero_basis_function_derivatives_[dir][firstNonZeroOffset];
63 | }
64 |
65 | private:
66 | std::vector non_zero_basis_functions_;
67 | std::array, DIM> non_zero_basis_function_derivatives_;
68 | double weight_;
69 | double jac_det_;
70 | };
71 | } // namespace elm
72 | } // namespace iga
73 |
74 | #endif // SRC_IGA_ELM_ELEMENT_INTEGRATION_POINT_H_
75 |
--------------------------------------------------------------------------------
/example/iga/src/itg/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | add_library(CSigaitg INTERFACE)
17 | target_include_directories(CSigaitg INTERFACE $)
18 |
19 | install(
20 | TARGETS CSigaitg
21 | EXPORT "${targets_export_name}"
22 | LIBRARY DESTINATION "${library_install_dir}"
23 | ARCHIVE DESTINATION "${library_install_dir}"
24 | RUNTIME DESTINATION "${executable_install_dir}"
25 | INCLUDES DESTINATION "${include_install_dir}"
26 | )
27 |
28 | install(FILES
29 | five_point_gauss_legendre.h
30 | four_point_gauss_legendre.h
31 | integration_point.h
32 | integration_rule.h
33 | one_point_gauss_legendre.h
34 | three_point_gauss_legendre.h
35 | two_point_gauss_legendre.h
36 | DESTINATION "${include_install_dir}")
37 |
--------------------------------------------------------------------------------
/example/iga/src/itg/five_point_gauss_legendre.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ITG_FIVE_POINT_GAUSS_LEGENDRE_H_
16 | #define SRC_IGA_ITG_FIVE_POINT_GAUSS_LEGENDRE_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "integration_rule.h"
22 |
23 | namespace iga {
24 | namespace itg {
25 | class FivePointGaussLegendre : public IntegrationRule {
26 | public:
27 | FivePointGaussLegendre() : IntegrationRule({
28 | IntegrationPoint(-(1.0 / 3) * sqrt(5 + 2.0 * sqrt(10.0 / 7)), (322.0 - 13 * sqrt(70)) / 900),
29 | IntegrationPoint(-(1.0 / 3) * sqrt(5 - 2.0 * sqrt(10.0 / 7)), (322.0 + 13 * sqrt(70)) / 900),
30 | IntegrationPoint(0, 128.0 / 225),
31 | IntegrationPoint((1.0 / 3) * sqrt(5 - 2.0 * sqrt(10.0 / 7)), (322.0 + 13 * sqrt(70)) / 900),
32 | IntegrationPoint((1.0 / 3) * sqrt(5 + 2.0 * sqrt(10.0 / 7)), (322.0 - 13 * sqrt(70)) / 900)}) {}
33 | };
34 | } // namespace itg
35 | } // namespace iga
36 |
37 | #endif // SRC_IGA_ITG_FIVE_POINT_GAUSS_LEGENDRE_H_
38 |
--------------------------------------------------------------------------------
/example/iga/src/itg/four_point_gauss_legendre.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ITG_FOUR_POINT_GAUSS_LEGENDRE_H_
16 | #define SRC_IGA_ITG_FOUR_POINT_GAUSS_LEGENDRE_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "integration_rule.h"
22 |
23 | namespace iga {
24 | namespace itg {
25 | class FourPointGaussLegendre : public IntegrationRule {
26 | public:
27 | FourPointGaussLegendre() : IntegrationRule({
28 | IntegrationPoint(-sqrt(3.0 / 7 + 2.0 / 7 * sqrt(6.0 / 5)), (18.0 - sqrt(30)) / 36),
29 | IntegrationPoint(-sqrt(3.0 / 7 - 2.0 / 7 * sqrt(6.0 / 5)), (18.0 + sqrt(30)) / 36),
30 | IntegrationPoint(sqrt(3.0 / 7 - 2.0 / 7 * sqrt(6.0 / 5)), (18.0 + sqrt(30)) / 36),
31 | IntegrationPoint(sqrt(3.0 / 7 + 2.0 / 7 * sqrt(6.0 / 5)), (18.0 - sqrt(30)) / 36)}) {}
32 | };
33 | } // namespace itg
34 | } // namespace iga
35 |
36 | #endif // SRC_IGA_ITG_FOUR_POINT_GAUSS_LEGENDRE_H_
37 |
--------------------------------------------------------------------------------
/example/iga/src/itg/integration_point.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 |
17 | #ifndef SRC_IGA_ITG_INTEGRATION_POINT_H_
18 | #define SRC_IGA_ITG_INTEGRATION_POINT_H_
19 |
20 | namespace iga {
21 | namespace itg {
22 | class IntegrationPoint {
23 | public:
24 | IntegrationPoint(double coordinate, double weight)
25 | : coordinate_(coordinate), weight_(weight) {}
26 |
27 | double GetCoordinate() const {
28 | return coordinate_;
29 | }
30 |
31 | double GetWeight() const {
32 | return weight_;
33 | }
34 |
35 | private:
36 | double coordinate_;
37 | double weight_;
38 | };
39 | } // namespace itg
40 | } // namespace iga
41 |
42 | #endif // SRC_IGA_ITG_INTEGRATION_POINT_H_
43 |
--------------------------------------------------------------------------------
/example/iga/src/itg/integration_rule.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ITG_INTEGRATION_RULE_H_
16 | #define SRC_IGA_ITG_INTEGRATION_RULE_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "integration_point.h"
22 | #include "multi_index_handler.h"
23 |
24 | namespace iga {
25 | namespace itg {
26 | class IntegrationRule {
27 | public:
28 | virtual ~IntegrationRule() = default;
29 |
30 | explicit IntegrationRule(std::vector points) : points_(std::move(points)) {}
31 |
32 | int GetNumberOfIntegrationPoints() const {
33 | return points_.size();
34 | }
35 |
36 | double GetCoordinate(int point) const {
37 | #ifdef DEBUG
38 | return points_.at(point).GetCoordinate();
39 | #else
40 | return points_[point].GetCoordinate();
41 | #endif
42 | }
43 |
44 | std::vector GetIntegrationPoints() const {
45 | return points_;
46 | }
47 |
48 | private:
49 | std::vector points_;
50 | };
51 | } // namespace itg
52 | } // namespace iga
53 |
54 | #endif // SRC_IGA_ITG_INTEGRATION_RULE_H_
55 |
--------------------------------------------------------------------------------
/example/iga/src/itg/one_point_gauss_legendre.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ITG_ONE_POINT_GAUSS_LEGENDRE_H_
16 | #define SRC_IGA_ITG_ONE_POINT_GAUSS_LEGENDRE_H_
17 |
18 | #include "integration_rule.h"
19 |
20 | namespace iga {
21 | namespace itg {
22 | class OnePointGaussLegendre : public IntegrationRule {
23 | public:
24 | OnePointGaussLegendre() : IntegrationRule({IntegrationPoint(0, 2)}) {}
25 | };
26 | } // namespace itg
27 | } // namespace iga
28 |
29 | #endif // SRC_IGA_ITG_ONE_POINT_GAUSS_LEGENDRE_H_
30 |
--------------------------------------------------------------------------------
/example/iga/src/itg/three_point_gauss_legendre.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ITG_THREE_POINT_GAUSS_LEGENDRE_H_
16 | #define SRC_IGA_ITG_THREE_POINT_GAUSS_LEGENDRE_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "integration_rule.h"
22 |
23 | namespace iga {
24 | namespace itg {
25 | class ThreePointGaussLegendre : public IntegrationRule {
26 | public:
27 | ThreePointGaussLegendre() : IntegrationRule(
28 | {IntegrationPoint(-sqrt(3.0 / 5), 5.0 / 9.0),
29 | IntegrationPoint(0, 8.0 / 9.0),
30 | IntegrationPoint(sqrt(3.0 / 5), 5.0 / 9.0)}) {}
31 | };
32 | } // namespace itg
33 | } // namespace iga
34 |
35 | #endif // SRC_IGA_ITG_THREE_POINT_GAUSS_LEGENDRE_H_
36 |
--------------------------------------------------------------------------------
/example/iga/src/itg/two_point_gauss_legendre.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_ITG_TWO_POINT_GAUSS_LEGENDRE_H_
16 | #define SRC_IGA_ITG_TWO_POINT_GAUSS_LEGENDRE_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "integration_rule.h"
22 |
23 | namespace iga {
24 | namespace itg {
25 | class TwoPointGaussLegendre : public IntegrationRule {
26 | public:
27 | TwoPointGaussLegendre() : IntegrationRule({IntegrationPoint(-sqrt(1.0 / 3), 1),
28 | IntegrationPoint(sqrt(1.0 / 3), 1)}) {}
29 | };
30 | } // namespace itg
31 | } // namespace iga
32 |
33 | #endif // SRC_IGA_ITG_TWO_POINT_GAUSS_LEGENDRE_H_
34 |
--------------------------------------------------------------------------------
/example/iga/src/solution_spline.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_SOLUTION_SPLINE_H_
16 | #define SRC_IGA_SOLUTION_SPLINE_H_
17 |
18 | #include
19 | #include
20 |
21 | #include "nurbs.h"
22 |
23 | namespace iga {
24 | template
25 | class SolutionSpline {
26 | public:
27 | SolutionSpline(const std::shared_ptr> &spl, const arma::dvec &solution) {
28 | std::vector control_points;
29 | std::array points_per_direction = spl->GetPointsPerDirection();
30 | util::MultiIndexHandler point_handler(points_per_direction);
31 | for (uint64_t i = 0, l = 0; i < static_cast(spl->GetNumberOfControlPoints()); ++i, ++point_handler, ++l) {
32 | std::vector temp;
33 | for (int j = 0; j < spl->GetPointDim(); ++j) {
34 | temp.emplace_back(spl->GetControlPoint(point_handler.GetIndices(), j));
35 | }
36 | temp.emplace_back(solution(l));
37 | control_points.emplace_back(baf::ControlPoint(temp));
38 | }
39 | solution_spl_ = std::make_shared>(*spl.get(), control_points);
40 | }
41 |
42 | std::shared_ptr> GetSolutionSpline() {
43 | return solution_spl_;
44 | }
45 |
46 | private:
47 | std::shared_ptr> solution_spl_;
48 | };
49 | } // namespace iga
50 |
51 | #endif // SRC_IGA_SOLUTION_SPLINE_H_
52 |
--------------------------------------------------------------------------------
/example/iga/src/solution_vtk_writer.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IGA_SOLUTION_VTK_WRITER_H_
16 | #define SRC_IGA_SOLUTION_VTK_WRITER_H_
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "multi_index_handler.h"
24 | #include "nurbs.h"
25 | #include "solution_spline.h"
26 | #include "vtk_writer.h"
27 |
28 | namespace iga {
29 | template
30 | class SolutionVTKWriter {
31 | public:
32 | SolutionVTKWriter() = default;
33 |
34 | void WriteSolutionToVTK(const std::shared_ptr> &spl, const arma::dvec &solution,
35 | const std::vector> &scattering, const std::string &filename) const {
36 | iga::SolutionSpline sol_spl(spl, solution);
37 | std::shared_ptr> solution_spl = sol_spl.GetSolutionSpline();
38 | int cp_dim = spl->GetPointDim();
39 | std::vector dxi;
40 | std::array num_pnts{};
41 | for (int i = 0; i < DIM; ++i) {
42 | baf::KnotVector knots = *spl->GetKnotVector(i);
43 | dxi.emplace_back((knots.GetKnot(knots.GetNumberOfKnots() - 1) - knots.GetKnot(0)).get() / scattering[0][i]);
44 | num_pnts[i] = scattering[0][i] + 1;
45 | }
46 | std::vector point_data;
47 | util::MultiIndexHandler mih(num_pnts);
48 | while (true) {
49 | std::array param_coords{};
50 | for (int i = 0; i < DIM; ++i) {
51 | param_coords[i] = spl->GetKnotVector(i)->GetKnot(0) + ParamCoord{mih[i] * dxi[i]};
52 | }
53 | point_data.emplace_back(solution_spl->Evaluate(param_coords, {cp_dim})[0]);
54 | if (mih.Get1DIndex() == mih.Get1DLength() - 1) break;
55 | ++mih;
56 | }
57 | io::VTKWriter vtk_writer;
58 | std::vector splines = {std::make_any>>(spl)};
59 | vtk_writer.WriteFile(splines, filename, scattering);
60 | std::ofstream newFile;
61 | newFile.open(filename, std::ofstream::out | std::ofstream::app);
62 | if (newFile.is_open()) {
63 | newFile << "\nPOINT_DATA " << point_data.size() << "\nSCALARS solution float 1\nLOOKUP_TABLE default\n";
64 | for (auto &p : point_data) {
65 | newFile << p << "\n";
66 | }
67 | newFile.close();
68 | }
69 | }
70 | };
71 | } // namespace iga
72 |
73 | #endif // SRC_IGA_SOLUTION_VTK_WRITER_H_
74 |
--------------------------------------------------------------------------------
/example/iga/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | set(TEST_SOURCES
17 | basis_function_handler_test.cc
18 | bdf_handler_test.cc
19 | connectivity_handler_test.cc
20 | element_generator_test.cc
21 | element_integral_calculator_test.cc
22 | element_integration_point_test.cc
23 | element_test.cc
24 | integration_point_test.cc
25 | integration_rule_test.cc
26 | linear_equation_assembler_test.cc
27 | mapping_handler_test.cc
28 | solution_vtk_writer_examples.cc
29 | solution_vtk_writer_test.cc)
30 |
31 | find_package(GMock REQUIRED)
32 | #include_directories(${GTEST_INCLUDE_DIRS})
33 |
34 | add_executable(CSigaTests ${TEST_SOURCES})
35 | target_link_libraries(CSigaTests CSiga GMock::Main)
36 |
37 | target_compile_definitions(CSigaTests PRIVATE GTEST_HAS_PTHREAD=0)
38 |
--------------------------------------------------------------------------------
/example/iga/test/connectivity_handler_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "gmock/gmock.h"
16 | #include "connectivity_handler.h"
17 | #include "test_spline.h"
18 |
19 | using testing::Eq;
20 |
21 | TEST_F(AnIGATestSpline, TestConnectivityHandler) { // NOLINT
22 | iga::ConnectivityHandler<2> connectivity_handler = iga::ConnectivityHandler<2>(nurbs_);
23 | std::vector e1 = {1, 2, 3, 4, 8, 9, 10, 11, 15, 16, 17, 18, 22, 23, 24, 25};
24 | std::vector e2 = {2, 3, 4, 5, 9, 10, 11, 12, 16, 17, 18, 19, 23, 24, 25, 26};
25 | std::vector e3 = {3, 4, 5, 6, 10, 11, 12, 13, 17, 18, 19, 20, 24, 25, 26, 27};
26 | std::vector e4 = {4, 5, 6, 7, 11, 12, 13, 14, 18, 19, 20, 21, 25, 26, 27, 28};
27 | std::vector e5 = {22, 23, 24, 25, 29, 30, 31, 32, 36, 37, 38, 39, 43, 44, 45, 46};
28 | std::vector e6 = {23, 24, 25, 26, 30, 31, 32, 33, 37, 38, 39, 40, 44, 45, 46, 47};
29 | std::vector e7 = {24, 25, 26, 27, 31, 32, 33, 34, 38, 39, 40, 41, 45, 46, 47, 48};
30 | std::vector e8 = {25, 26, 27, 28, 32, 33, 34, 35, 39, 40, 41, 42, 46, 47, 48, 49};
31 | std::vector> connectivity_matlab = {e1, e2, e3, e4, e5, e6, e7, e8};
32 | for (uint64_t i = 0; i < connectivity_matlab.size(); ++i) {
33 | for (uint64_t j = 0; j < connectivity_matlab[i].size(); ++j) {
34 | ASSERT_THAT(connectivity_handler.GetGlobalIndex(i, j), Eq(connectivity_matlab[i][j]));
35 | }
36 | }
37 | }
38 |
39 | TEST_F(AnIGATestSpline3, TestConnectivityHandler) { // NOLINT
40 | iga::ConnectivityHandler<3> connectivity_handler = iga::ConnectivityHandler<3>(nurbs_);
41 | ASSERT_THAT(connectivity_handler.GetGlobalIndex(15, 10), Eq(188));
42 | }
43 |
--------------------------------------------------------------------------------
/example/iga/test/element_generator_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 | #include "gmock/gmock.h"
17 |
18 | #include "element_generator.h"
19 |
20 | using testing::Test;
21 |
22 | class A1DElementGenerator : public Test {
23 | public:
24 | std::array knot_vector =
25 | {baf::KnotVector({ParamCoord{0}, ParamCoord{0}, ParamCoord{0}, ParamCoord{1},
26 | ParamCoord{2}, ParamCoord{3}, ParamCoord{4}, ParamCoord{4},
27 | ParamCoord{5}, ParamCoord{5}, ParamCoord{5}})};
28 | std::array degree = {Degree{2}};
29 | std::vector control_points = {
30 | baf::ControlPoint(std::vector({0.0, 0.0, 0.0})),
31 | baf::ControlPoint(std::vector({1.0, 0.0, 0.0})),
32 | baf::ControlPoint(std::vector({2.0, 0.0, 0.0})),
33 | baf::ControlPoint(std::vector({3.0, 0.0, 0.0})),
34 | baf::ControlPoint(std::vector({4.0, 0.0, 0.0})),
35 | baf::ControlPoint(std::vector({5.0, 0.0, 0.0})),
36 | baf::ControlPoint(std::vector({6.0, 0.0, 0.0})),
37 | baf::ControlPoint(std::vector({7.0, 0.0, 0.0}))};
38 | KnotVectors<1> kv_ptr = {std::make_shared(knot_vector[0])};
39 | std::shared_ptr> b_spline = std::make_shared>(kv_ptr, degree, control_points);
40 |
41 | A1DElementGenerator() : element_generator(b_spline) {}
42 |
43 | protected:
44 | iga::elm::ElementGenerator<1> element_generator;
45 | };
46 |
47 | TEST_F(A1DElementGenerator, ReturnsCorrectNumberOfElements) { // NOLINT
48 | ASSERT_THAT(element_generator.GetElementList(0).size(), 5);
49 | }
50 |
51 | TEST_F(A1DElementGenerator, ReturnsElementsWithCorrectNodes) { // NOLINT
52 | auto element_list = element_generator.GetElementList(0);
53 | for (auto element = 0u; element < element_list.size(); element++) {
54 | ASSERT_THAT(element_list[element].GetLowerBound().get(), element);
55 | ASSERT_THAT(element_list[element].GetUpperBound().get(), element + 1);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/example/iga/test/element_integral_calculator_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 | #include
17 |
18 | #include "gmock/gmock.h"
19 | #include "matlab_test_data.h"
20 | #include "test_spline.h"
21 |
22 | using testing::DoubleNear;
23 |
24 | TEST_F(AnIGATestSpline, TestElementIntegralCalculator) { // NOLINT
25 | elm_itg_calc.GetLaplaceElementIntegral(0, rule, matA);
26 | for (uint64_t i = 0; i < matlab_element_one_integral.size(); ++i) {
27 | for (uint64_t j = 0; j < matlab_element_one_integral[0].size(); ++j) {
28 | ASSERT_THAT((*matA)(i, j), DoubleNear(matlab_element_one_integral[i][j], 0.00005));
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/example/iga/test/element_integration_point_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 |
17 | #include "gmock/gmock.h"
18 |
19 | #include "element_integration_point.h"
20 |
21 | using testing::DoubleEq;
22 | using testing::Test;
23 |
24 | class AnElementIntegrationPoint : public Test{
25 | public:
26 | AnElementIntegrationPoint() : element_integration_point({2.3, 4.5}, 0.75, 1.75) {}
27 |
28 | protected:
29 | iga::elm::ElementIntegrationPoint<1> element_integration_point;
30 | };
31 |
32 | TEST_F(AnElementIntegrationPoint, GetNonZeroBasisFunctions) { //NOLINT
33 | ASSERT_THAT(element_integration_point.GetNonZeroBasisFunctions()[0] , DoubleEq(2.3));
34 | ASSERT_THAT(element_integration_point.GetNonZeroBasisFunctions()[1] , DoubleEq(4.5));
35 | }
36 |
37 | TEST_F(AnElementIntegrationPoint, SizeEqualsTwo) { //NOLINT
38 | ASSERT_THAT(element_integration_point.GetNumberOfNonZeroBasisFunctions(), 2);
39 | }
40 |
41 | TEST_F(AnElementIntegrationPoint, GetValueAtZero) { //NOLINT
42 | ASSERT_THAT(element_integration_point.GetBasisFunctionValue(1), DoubleEq(4.5));
43 | }
44 |
45 | TEST_F(AnElementIntegrationPoint, GetWeight) { //NOLINT
46 | ASSERT_THAT(element_integration_point.GetWeight(), DoubleEq(0.75));
47 | }
48 |
49 | TEST_F(AnElementIntegrationPoint, GetJacobianDeterminant) { //NOLINT
50 | ASSERT_THAT(element_integration_point.GetJacobianDeterminant(), DoubleEq(1.75));
51 | }
52 |
53 | class AnElementIntegrationPointWithDerivatives : public Test{
54 | public:
55 | std::array, 2> baf_ders = {std::vector({2.3, 4.5}), std::vector({3.2, 5.4})};
56 | AnElementIntegrationPointWithDerivatives() : element_integration_point(baf_ders, 0.75, 1.75) {}
57 |
58 | protected:
59 | iga::elm::ElementIntegrationPoint<2> element_integration_point;
60 | };
61 |
62 | TEST_F(AnElementIntegrationPointWithDerivatives, GetNonZeroBasisFunctionDerivatives) { //NOLINT
63 | ASSERT_THAT(element_integration_point.GetNonZeroBasisFunctionDerivatives(0)[0] , DoubleEq(2.3));
64 | ASSERT_THAT(element_integration_point.GetNonZeroBasisFunctionDerivatives(0)[1] , DoubleEq(4.5));
65 | ASSERT_THAT(element_integration_point.GetNonZeroBasisFunctionDerivatives(1)[0] , DoubleEq(3.2));
66 | ASSERT_THAT(element_integration_point.GetNonZeroBasisFunctionDerivatives(1)[1] , DoubleEq(5.4));
67 | }
68 |
--------------------------------------------------------------------------------
/example/iga/test/element_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 | #include "gmock/gmock.h"
17 |
18 | #include "element.h"
19 |
20 | using testing::Test;
21 | using testing::DoubleEq;
22 |
23 | class A1DElement : public Test {
24 | public:
25 | A1DElement() : element({ParamCoord(0.5), ParamCoord(1.0)}) {}
26 |
27 | protected:
28 | iga::elm::Element element;
29 | };
30 |
31 | TEST_F(A1DElement, ReturnsCorrectNode) { // NOLINT
32 | ASSERT_THAT(element.GetLowerBound().get(), DoubleEq(0.5));
33 | ASSERT_THAT(element.GetUpperBound().get(), DoubleEq(1.0));
34 | }
35 |
--------------------------------------------------------------------------------
/example/iga/test/integration_point_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "gmock/gmock.h"
16 |
17 | #include "integration_point.h"
18 |
19 | using testing::Test;
20 | using testing::DoubleEq;
21 |
22 | class AnIntegrationPoint : public Test {
23 | public:
24 | AnIntegrationPoint() : integration_point_(1.5, 0.5) {}
25 |
26 | protected:
27 | iga::itg::IntegrationPoint integration_point_;
28 | };
29 |
30 | TEST_F(AnIntegrationPoint, ReturnsCorrectCoordinate) { // NOLINT
31 | ASSERT_THAT(integration_point_.GetCoordinate(), DoubleEq(1.5));
32 | }
33 |
34 | TEST_F(AnIntegrationPoint, ReturnsCorrectWeight) { // NOLINT
35 | ASSERT_THAT(integration_point_.GetWeight(), DoubleEq(0.5));
36 | }
37 |
--------------------------------------------------------------------------------
/example/iga/test/integration_rule_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "gmock/gmock.h"
16 |
17 | #include "five_point_gauss_legendre.h"
18 | #include "four_point_gauss_legendre.h"
19 | #include "integration_rule.h"
20 | #include "numeric_settings.h"
21 | #include "one_point_gauss_legendre.h"
22 | #include "three_point_gauss_legendre.h"
23 | #include "two_point_gauss_legendre.h"
24 |
25 | using testing::Test;
26 | using testing::DoubleEq;
27 | using testing::DoubleNear;
28 |
29 | class AnIntegrationRule : public Test {
30 | public:
31 | AnIntegrationRule() {
32 | rules_.emplace_back(iga::itg::OnePointGaussLegendre());
33 | rules_.emplace_back(iga::itg::TwoPointGaussLegendre());
34 | rules_.emplace_back(iga::itg::ThreePointGaussLegendre());
35 | rules_.emplace_back(iga::itg::FourPointGaussLegendre());
36 | rules_.emplace_back(iga::itg::FivePointGaussLegendre());
37 | }
38 |
39 | protected:
40 | std::vector rules_;
41 | };
42 |
43 | TEST_F(AnIntegrationRule, ReturnsCorrectNumberOfPoints) { // NOLINT
44 | for (int points = 1; points <= 5; points++) {
45 | ASSERT_THAT(rules_[points - 1].GetNumberOfIntegrationPoints(), points);
46 | }
47 | }
48 |
49 | TEST_F(AnIntegrationRule, ReturnsCorrectWeightSum) { // NOLINT
50 | for (int points = 1; points <= 5; points++) {
51 | double weight_sum = 0;
52 | for (int weight = 0; weight < points; weight++) {
53 | weight_sum += rules_[points - 1].GetIntegrationPoints()[weight].GetWeight();
54 | }
55 | ASSERT_THAT(weight_sum, DoubleEq(2));
56 | }
57 | }
58 |
59 | TEST_F(AnIntegrationRule, ReturnsCorrectPointSum) { // NOLINT
60 | for (int points = 1; points <= 5; points++) {
61 | double point_sum = 0;
62 | for (int point = 0; point < points; point++) {
63 | point_sum += rules_[points - 1].GetIntegrationPoints()[point].GetCoordinate();
64 | }
65 | ASSERT_THAT(point_sum, DoubleNear(0.0, util::NumericSettings::kEpsilon()));
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/example/iga/test/linear_equation_assembler_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 |
17 | #include "gmock/gmock.h"
18 | #include "matlab_test_data_2.h"
19 | #include "test_spline.h"
20 |
21 | using testing::DoubleNear;
22 |
23 | TEST_F(AnIGATestSpline, TestLeftSide) { // NOLINT
24 | linear_equation_assembler.GetLeftSide(rule, matA, elm_itg_calc);
25 | for (uint64_t i = 0; i < matlab_matrix_a.size(); ++i) {
26 | for (uint64_t j = 0; j < matlab_matrix_a[0].size(); ++j) {
27 | ASSERT_THAT((*matA)(i, j), DoubleNear(matlab_matrix_a[i][j], 0.00005));
28 | }
29 | }
30 | }
31 |
32 | TEST_F(AnIGATestSpline, TestRightSide) { // NOLINT
33 | linear_equation_assembler.GetRightSide(rule, vecB, elm_itg_calc, srcCp);
34 | for (uint64_t i = 0; i < matlab_vector_b.size(); ++i) {
35 | ASSERT_THAT((*vecB)(i), DoubleNear(matlab_vector_b[i], 0.00005));
36 | }
37 | }
38 |
39 | TEST_F(AnIGATestSpline, TestEquationSystemWithBC) { // NOLINT
40 | linear_equation_assembler.GetLeftSide(rule, matA, elm_itg_calc);
41 | linear_equation_assembler.GetRightSide(rule, vecB, elm_itg_calc, srcCp);
42 | linear_equation_assembler.SetZeroBC(matA, vecB);
43 | for (uint64_t i = 0; i < matlab_matrix_a_bc.size(); ++i) {
44 | for (uint64_t j = 0; j < matlab_matrix_a_bc[0].size(); ++j) {
45 | ASSERT_THAT((*matA)(i, j), DoubleNear(matlab_matrix_a_bc[i][j], 0.00005));
46 | }
47 | }
48 | for (uint64_t i = 0; i < matlab_vector_b_bc.size(); ++i) {
49 | ASSERT_THAT((*vecB)(i), DoubleNear(matlab_vector_b_bc[i], 0.00005));
50 | }
51 | }
52 |
53 | TEST_F(AnIGATestSpline, TestSolution) { // NOLINT
54 | iga::itg::IntegrationRule rule = iga::itg::TwoPointGaussLegendre();
55 | linear_equation_assembler.GetLeftSide(rule, matA, elm_itg_calc);
56 | linear_equation_assembler.GetRightSide(rule, vecB, elm_itg_calc, srcCp);
57 | linear_equation_assembler.SetZeroBC(matA, vecB);
58 | arma::dvec solution = arma::solve(*matA, *vecB);
59 | for (uint64_t i = 0; i < matlab_solution.size(); ++i) {
60 | ASSERT_THAT(solution(i), DoubleNear(matlab_solution[i], 0.00005));
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/example/iga/test/mapping_handler_test.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "gmock/gmock.h"
16 |
17 | #include "mapping_handler.h"
18 | #include "test_spline.h"
19 |
20 | using testing::DoubleNear;
21 |
22 | TEST_F(AnIGATestSpline, TestMappingHandler) { // NOLINT
23 | iga::MappingHandler<2> mapping_handler(nurbs_);
24 | double j = mapping_handler.GetJacobianDeterminant(std::array({ParamCoord{0.367}, ParamCoord{0.893}}));
25 | ASSERT_THAT(j, DoubleNear(0.0905, 0.00005));
26 | }
27 |
--------------------------------------------------------------------------------
/example/log.txt:
--------------------------------------------------------------------------------
1 | input:
2 | ../../test/io/test_files/spline_tank.xml
3 |
4 | output:
5 | out.itd
6 |
7 | options:
8 | all
--------------------------------------------------------------------------------
/example/testcase_optimizer.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include
16 | #include
17 | #include
18 | #include
19 | #include
20 |
21 | #include "b_spline.h"
22 | #include "control_point.h"
23 | #include "knot_vector.h"
24 | #include "vtk_writer.h"
25 |
26 | void createVTKFromControlPoints(std::vector control_points, std::string fileName) {
27 | std::array degree = {Degree{2}};
28 | std::array, 1> knot_vector_ptr = {
29 | std::make_shared(baf::KnotVector({ParamCoord{0}, ParamCoord{0}, ParamCoord{0},
30 | ParamCoord{1}, ParamCoord{1}, ParamCoord{1}}))};
31 | spl::BSpline<1> b_spline(knot_vector_ptr, degree, control_points);
32 | std::shared_ptr> b_spline_ptr = std::make_shared>(b_spline);
33 |
34 | std::any b_spline_any = std::make_any>>(b_spline_ptr);
35 | std::vector splines_ = {b_spline_any};
36 | std::unique_ptr vtk_writer_;
37 | std::vector> scattering = {{100}};
38 | vtk_writer_->WriteFile(splines_, fileName, scattering);
39 | }
40 |
41 | int main(int argc, char* argv[]) {
42 | if (argc != 3) {
43 | throw std::runtime_error("Exactly 10 coordinates of control points are required for the splinecreation");
44 | }
45 | std::vector control_points;
46 | control_points.emplace_back(baf::ControlPoint({-1.0, 0.0}));
47 | double x, y;
48 | for (int i = 2; i < argc; i += 2) {
49 | x = atof(argv[i-1]);
50 | y = atof(argv[i]);
51 | std::cout << x << ", " << y << std::endl;
52 | control_points.emplace_back(baf::ControlPoint({x, y}));
53 | }
54 | control_points.emplace_back(baf::ControlPoint({1.0, 0.0}));
55 | std::string fileName = "optimized_Form.vtk";
56 | createVTKFromControlPoints(control_points, fileName);
57 | return 0;
58 | }
59 |
--------------------------------------------------------------------------------
/external/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | add_subdirectory(pugixml)
17 |
--------------------------------------------------------------------------------
/external/pugixml/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | set(SOURCES
17 | pugixml.cpp)
18 |
19 | add_library(pugixmllib SHARED ${SOURCES})
20 | target_include_directories(pugixmllib PUBLIC $)
21 |
22 | install(
23 | TARGETS pugixmllib
24 | EXPORT "${targets_export_name}"
25 | LIBRARY DESTINATION "${library_install_dir}"
26 | ARCHIVE DESTINATION "${library_install_dir}"
27 | RUNTIME DESTINATION "${executable_install_dir}"
28 | INCLUDES DESTINATION "${include_install_dir}"
29 | )
30 |
31 | install(FILES
32 | pugiconfig.hpp
33 | pugixml.hpp
34 | DESTINATION "${include_install_dir}")
35 |
--------------------------------------------------------------------------------
/external/pugixml/pugiconfig.hpp:
--------------------------------------------------------------------------------
1 | /**
2 | * pugixml parser - version 1.9
3 | * --------------------------------------------------------
4 | * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
5 | * Report bugs and download new versions at http://pugixml.org/
6 | *
7 | * This library is distributed under the MIT License. See notice at the end
8 | * of this file.
9 | *
10 | * This work is based on the pugxml parser, which is:
11 | * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
12 | */
13 |
14 | #ifndef HEADER_PUGICONFIG_HPP
15 | #define HEADER_PUGICONFIG_HPP
16 |
17 | // Uncomment this to enable wchar_t mode
18 | // #define PUGIXML_WCHAR_MODE
19 |
20 | // Uncomment this to enable compact mode
21 | // #define PUGIXML_COMPACT
22 |
23 | // Uncomment this to disable XPath
24 | // #define PUGIXML_NO_XPATH
25 |
26 | // Uncomment this to disable STL
27 | // #define PUGIXML_NO_STL
28 |
29 | // Uncomment this to disable exceptions
30 | // #define PUGIXML_NO_EXCEPTIONS
31 |
32 | // Set this to control attributes for public classes/functions, i.e.:
33 | // #define PUGIXML_API __declspec(dllexport) // to export all public symbols from DLL
34 | // #define PUGIXML_CLASS __declspec(dllimport) // to import all classes from DLL
35 | // #define PUGIXML_FUNCTION __fastcall // to set calling conventions to all public functions to fastcall
36 | // In absence of PUGIXML_CLASS/PUGIXML_FUNCTION definitions PUGIXML_API is used instead
37 |
38 | // Tune these constants to adjust memory-related behavior
39 | // #define PUGIXML_MEMORY_PAGE_SIZE 32768
40 | // #define PUGIXML_MEMORY_OUTPUT_STACK 10240
41 | // #define PUGIXML_MEMORY_XPATH_PAGE_SIZE 4096
42 |
43 | // Uncomment this to switch to header-only version
44 | // #define PUGIXML_HEADER_ONLY
45 |
46 | // Uncomment this to enable long long support
47 | // #define PUGIXML_HAS_LONG_LONG
48 |
49 | #endif
50 |
51 | /**
52 | * Copyright (c) 2006-2018 Arseny Kapoulkine
53 | *
54 | * Permission is hereby granted, free of charge, to any person
55 | * obtaining a copy of this software and associated documentation
56 | * files (the "Software"), to deal in the Software without
57 | * restriction, including without limitation the rights to use,
58 | * copy, modify, merge, publish, distribute, sublicense, and/or sell
59 | * copies of the Software, and to permit persons to whom the
60 | * Software is furnished to do so, subject to the following
61 | * conditions:
62 | *
63 | * The above copyright notice and this permission notice shall be
64 | * included in all copies or substantial portions of the Software.
65 | *
66 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
67 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
68 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
69 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
70 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
71 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
72 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
73 | * OTHER DEALINGS IN THE SOFTWARE.
74 | */
75 |
--------------------------------------------------------------------------------
/scripts/build/before_install_osx.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | brew cask uninstall oclint
4 | brew tap oclint/formulae
5 | brew install oclint gcc llvm
6 | echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
--------------------------------------------------------------------------------
/scripts/build/create_build_folders.sh:
--------------------------------------------------------------------------------
1 | #! /usr/bin/env bash
2 |
3 | # Check command line arguments
4 | if [ "$#" -ne 1 ]; then
5 | echo "Usage: $0 DIRECTORY" >&2
6 | exit 1
7 | fi
8 | if ! [ -e "$1" ]; then
9 | echo "$1 not found" >&2
10 | exit 1
11 | fi
12 | if ! [ -d "$1" ]; then
13 | echo "$1 not a directory" >&2
14 | exit 1
15 | fi
16 |
17 | # Get build prefix
18 | BUILD_PREFIX=$1
19 |
20 | # Create build folders
21 | mkdir $BUILD_PREFIX/cmake-build-debug-gcc
22 | mkdir $BUILD_PREFIX/cmake-build-release-gcc
23 | mkdir $BUILD_PREFIX/cmake-build-debug-clang
24 | mkdir $BUILD_PREFIX/cmake-build-release-clang
25 |
--------------------------------------------------------------------------------
/scripts/build/install_spack.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | if ! which spack >/dev/null; then
4 | mkdir -p $SPACK_ROOT
5 | git clone --depth 50 https://github.com/spack/spack.git $SPACK_ROOT
6 | echo -e "config:""\n build_jobs:"" 2" > $SPACK_ROOT/etc/spack/config.yaml;
7 | spack bootstrap
8 | CC=$CCOMPILER CXX=$CXXCOMPILER spack compiler find
9 | spack clean -a
10 | fi
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.acceptancetests:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | # Set-up shell
8 | SHELL ["bash", "-c"]
9 | ENV BASH_ENV /spack/bashrc
10 |
11 | RUN spack repo add /code/scripts/spack-repo
12 | RUN spack setup -v splinelib@github build_type=Release %gcc@8
13 | RUN mkdir /code/build-acceptance
14 | WORKDIR /code/build-acceptance
15 | RUN ./../spconfig.py ..
16 |
17 | # Install Splinelib
18 | CMD make && ./test/AcceptanceTests
19 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.armadillo:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | # Set-up shell
8 | SHELL ["bash", "-c"]
9 | ENV BASH_ENV /etc/profile.d/spack.sh
10 |
11 | RUN spack install -v openblas %gcc@7
12 | RUN spack install -v armadillo %gcc@7
13 |
14 | CMD /bin/bash -l
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.convert:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | # Set-up shell
8 | SHELL ["bash", "-c"]
9 | ENV BASH_ENV /etc/profile.d/spack.sh
10 |
11 | RUN spack repo add /code/scripts/spack-repo
12 | RUN spack setup -v splinelib@github build_type=Release %gcc@8
13 | RUN mkdir /code/build-convert
14 | WORKDIR /code/build-convert
15 | RUN ./../spconfig.py ..
16 |
17 | # Install Splinelib
18 | RUN make install
19 |
20 | RUN mkdir /code/example/build
21 | WORKDIR /code/example/build
22 |
23 | CMD spack load splinelib@github build_type=Release %gcc@8 && ./../../build-convert/src/io/executables/xml2irit --help && ./../../build-convert/src/io/executables/xml2irit ../log.txt
24 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.gtest:
--------------------------------------------------------------------------------
1 | # Build on top of spack
2 | FROM christophsusen/spack
3 |
4 | # Add code directory
5 | ADD . /spackrepo
6 | WORKDIR /spackrepo
7 |
8 | RUN apt-get update && apt-get install -y cmake
9 | RUN mv ./scripts/docker/packages.yaml /root/.spack/linux/packages.yaml
10 |
11 | # Install googletest versions
12 | RUN spack repo add /spackrepo/scripts/spack-repo
13 | RUN spack setup splinelib@github build_type=Debug %gcc@7
14 | RUN spack setup splinelib@github build_type=Release %gcc@7
15 | RUN spack setup splinelib@github build_type=Debug %clang@6
16 | RUN spack setup splinelib@github build_type=Release %clang@6
17 | RUN spack setup splinelib@github build_type=Debug %clang@5
18 | RUN spack setup splinelib@github build_type=Release %clang@5
19 | RUN spack setup splinelib@github build_type=Debug %gcc@8
20 | RUN spack setup splinelib@github build_type=Release %gcc@8
21 | RUN spack clean -a
22 |
23 | CMD /bin/bash
24 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.iga:
--------------------------------------------------------------------------------
1 | FROM christophsusen/armadillo
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | # Set-up shell
8 | SHELL ["bash", "-c"]
9 | ENV BASH_ENV /etc/profile.d/spack.sh
10 |
11 | # Install SplineLib
12 | RUN spack setup splinelib@github build_type=Release %gcc@8 arch=linux-ubuntu18.04-x86_64
13 | RUN mkdir /code/build
14 | WORKDIR /code/build
15 | RUN ./../spconfig.py ..
16 | RUN make install
17 |
18 | # Install CSiga
19 | RUN mkdir /code/example/iga/build
20 | WORKDIR /code/example/iga/build
21 |
22 | CMD spack load armadillo && spack load googletest@1.8.0 +gmock+pthreads~shared %gcc@8.2.0 && cmake .. && make && ./test/CSigaTests
23 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.install:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | # Set-up shell
8 | SHELL ["bash", "-c"]
9 | ENV BASH_ENV /etc/profile.d/spack.sh
10 |
11 | RUN spack repo add /code/scripts/spack-repo
12 | RUN spack setup -v splinelib@github build_type=Release %gcc@8
13 | RUN mkdir /code/build-install
14 | WORKDIR /code/build-install
15 | RUN ./../spconfig.py ..
16 |
17 | # Install Splinelib
18 | RUN make install
19 |
20 | RUN mkdir /code/example/build
21 | WORKDIR /code/example/build
22 |
23 | RUN spack load splinelib@github build_type=Release %gcc@8 && cmake ../
24 | RUN make
25 |
26 | CMD spack load splinelib@github build_type=Release %gcc@8 && ./ex1
27 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.lint.clang-tidy:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 |
6 | RUN mkdir -p /code/build-clang-tidy
7 | WORKDIR /code/build-clang-tidy
8 |
9 | # Set-up shell
10 | SHELL ["bash", "-c"]
11 | ENV BASH_ENV /etc/profile.d/spack.sh
12 |
13 | # Build and execute tests
14 | RUN spack load googletest+gmock~shared%gcc@7 && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ../
15 |
16 | # execute clang-tidy
17 | CMD python ../scripts/run-clang-tidy.py /code/src/.* /code/test/.* | tee clang.log && grep -q -E "error:|warning:" clang.log && exit 1 || exit 0
18 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.lint.cpplint:
--------------------------------------------------------------------------------
1 | FROM christophsusen/spack
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | # execute cpplint
8 | CMD cpplint --extensions=cc,h --recursive /code/src/* /code/test/*
9 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.spack:
--------------------------------------------------------------------------------
1 | # Build on top of ubuntu
2 | FROM ubuntu:18.04
3 |
4 | ENV DEBIAN_FRONTEND=noninteractive \
5 | SPACK_ROOT=/usr/local \
6 | FORCE_UNSAFE_CONFIGURE=1 \
7 | OCLINT_HOME=/spack/oclint-0.13.1
8 |
9 | RUN apt-get update \
10 | && apt-get install -y --no-install-recommends \
11 | autoconf \
12 | ca-certificates \
13 | curl \
14 | environment-modules \
15 | git \
16 | build-essential \
17 | python \
18 | nano \
19 | sudo \
20 | unzip \
21 | python-pip \
22 | lcov \
23 | gfortran-8 \
24 | gcc-8 \
25 | gfortran-7 \
26 | gcc-7 \
27 | llvm-5.0 \
28 | llvm-6.0 \
29 | clang-5.0 \
30 | clang-6.0 \
31 | libstdc++-6-dev \
32 | libstdc++-7-dev \
33 | libstdc++-8-dev \
34 | clang-tidy \
35 | cppcheck \
36 | wget \
37 | gfortran \
38 | g++-8 \
39 | valgrind \
40 | && rm -rf /var/lib/apt/lists/*
41 |
42 | RUN curl -s -L https://api.github.com/repos/llnl/spack/tarball | tar xzC $SPACK_ROOT --strip 1
43 | RUN echo ". $SPACK_ROOT/share/spack/setup-env.sh" > /etc/profile.d/spack.sh
44 | RUN spack bootstrap
45 | RUN spack compiler find
46 | RUN sed -i -e 's/null/\/usr\/bin\/gfortran/g' ~/.spack/linux/compilers.yaml
47 | RUN spack compiler list
48 | RUN spack clean -a
49 |
50 | # startup
51 | CMD /bin/bash -l
52 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.clang5.debug:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Debug %clang@5
9 | RUN mkdir /code/build-clang5-debug
10 | WORKDIR /code/build-clang5-debug
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.clang5.release:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Release %clang@5
9 | RUN mkdir /code/build-clang5-release
10 | WORKDIR /code/build-clang5-release
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.clang6.debug:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Debug %clang@6
9 | RUN mkdir /code/build-clang6-debug
10 | WORKDIR /code/build-clang6-debug
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.clang6.release:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Release %clang@6
9 | RUN mkdir /code/build-clang6-release
10 | WORKDIR /code/build-clang6-release
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.coverage:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | ENV CXXFLAGS="-coverage"
8 |
9 | RUN spack repo add /code/scripts/spack-repo
10 | RUN spack setup -v splinelib@github build_type=Debug %gcc@7
11 | RUN mkdir /code/build-gcc7-coverage
12 | WORKDIR /code/build-gcc7-coverage
13 | RUN ../spconfig.py ..
14 |
15 | # Generate code coverage output
16 | RUN lcov --directory . --zerocounters && \
17 | make SplineLibTests && \
18 | ./test/SplineLibTests && \
19 | lcov --directory . --capture --output-file coverage.info && \
20 | lcov --remove coverage.info '/usr/*' --output-file coverage.info && \
21 | lcov --remove coverage.info '*/.cache/*' --output-file coverage.info && \
22 | lcov --remove coverage.info '*/CMakeFiles/*' --output-file coverage.info && \
23 | lcov --remove coverage.info '*/external/*' --output-file coverage.info && \
24 | lcov --remove coverage.info '*/io/executables/*' --output-file coverage.info && \
25 | lcov --list coverage.info && \
26 | find . -name "*.gcov" -type f -delete && \
27 | find . -name "*.gcda" -type f -delete && \
28 | find . -name "*.gcno" -type f -delete
29 |
30 | # Set-up shell
31 | SHELL ["bash", "-c"]
32 |
33 | CMD /bin/bash <(curl -s https://codecov.io/bash)
34 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.gcc7.debug:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Debug %gcc@7
9 | RUN mkdir /code/build-gcc7-debug
10 | WORKDIR /code/build-gcc7-debug
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.gcc7.release:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Release %gcc@7
9 | RUN mkdir /code/build-gcc7-release
10 | WORKDIR /code/build-gcc7-release
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.gcc8.debug:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Debug %gcc@8
9 | RUN mkdir /code/build-gcc8-debug
10 | WORKDIR /code/build-gcc8-debug
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.gcc8.release:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Release %gcc@8
9 | RUN mkdir /code/build-gcc8-release
10 | WORKDIR /code/build-gcc8-release
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/Dockerfile.test.gcc8.valgrind:
--------------------------------------------------------------------------------
1 | FROM christophsusen/gtest
2 |
3 | # Add current directory as working directory to docker
4 | ADD . /code
5 | WORKDIR /code
6 |
7 | RUN spack repo add /code/scripts/spack-repo
8 | RUN spack setup -v splinelib@github build_type=Debug %gcc@8
9 | RUN mkdir /code/build-gcc8-valgrind
10 | WORKDIR /code/build-gcc8-valgrind
11 | RUN ../spconfig.py ..
12 |
13 | # Build and execute tests
14 | CMD make && valgrind ./test/SplineLibTests
15 |
--------------------------------------------------------------------------------
/scripts/docker/packages.yaml:
--------------------------------------------------------------------------------
1 | packages:
2 | cmake:
3 | paths:
4 | cmake@3.10.2 arch=linux-ubuntu18.04-x86_64: /usr/bin/cmake
5 |
--------------------------------------------------------------------------------
/scripts/spack-repo/packages/splinelib/package.py:
--------------------------------------------------------------------------------
1 | ##############################################################################
2 | # Copyright (c) 2013-2017, Lawrence Livermore National Security, LLC.
3 | # Produced at the Lawrence Livermore National Laboratory.
4 | #
5 | # This file is part of Spack.
6 | # Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
7 | # LLNL-CODE-647188
8 | #
9 | # For details, see https://github.com/spack/spack
10 | # Please also see the NOTICE and LICENSE files for our notice and the LGPL.
11 | #
12 | # This program is free software; you can redistribute it and/or modify
13 | # it under the terms of the GNU Lesser General Public License (as
14 | # published by the Free Software Foundation) version 2.1, February 1999.
15 | #
16 | # This program is distributed in the hope that it will be useful, but
17 | # WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
19 | # conditions of the GNU Lesser General Public License for more details.
20 | #
21 | # You should have received a copy of the GNU Lesser General Public
22 | # License along with this program; if not, write to the Free Software
23 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 | ##############################################################################
25 |
26 | from spack import *
27 |
28 |
29 | class Splinelib(CMakePackage):
30 | """Library for spline manipulation."""
31 |
32 | homepage = "https://github.com/mfcats/SplineLib"
33 | url = ""
34 |
35 | version('github', git='https://github.com/mfcats/SplineLib.git', branch='master')
36 |
37 | depends_on("googletest+gmock~shared")
38 |
39 | def cmake_args(self):
40 | options = []
41 | return options
42 |
--------------------------------------------------------------------------------
/scripts/spack-repo/repo.yaml:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | repo:
17 | namespace: splinelib-software
--------------------------------------------------------------------------------
/src/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | add_subdirectory(util)
17 | add_subdirectory(baf)
18 | add_subdirectory(spl)
19 | add_subdirectory(io)
20 |
--------------------------------------------------------------------------------
/src/baf/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | set(SOURCES
17 | b_spline_basis_function.cc
18 | basis_function.cc
19 | basis_function_factory.cc
20 | control_point.cc
21 | knot_vector.cc
22 | zero_degree_b_spline_basis_function.cc)
23 |
24 | add_library(splinelibbaf SHARED ${SOURCES})
25 | target_include_directories(splinelibbaf PUBLIC $)
26 | target_link_libraries(splinelibbaf splinelibutil)
27 | if (CMAKE_BUILD_TYPE STREQUAL "Debug")
28 | target_compile_options(splinelibbaf PUBLIC ${RUNTIME_CHECKS_DEBUG} ${WARNING_FLAGS})
29 | elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
30 | target_compile_options(splinelibbaf PUBLIC ${OPTIMIZATION_FLAGS} ${WARNING_FLAGS} ${PARALLELIZATION_FLAGS})
31 | endif ()
32 |
33 | install(
34 | TARGETS splinelibbaf
35 | EXPORT "${targets_export_name}"
36 | LIBRARY DESTINATION "${library_install_dir}"
37 | ARCHIVE DESTINATION "${library_install_dir}"
38 | RUNTIME DESTINATION "${executable_install_dir}"
39 | INCLUDES DESTINATION "${include_install_dir}"
40 | )
41 |
42 | install(FILES
43 | b_spline_basis_function.h
44 | basis_function.h
45 | basis_function_factory.h
46 | control_point.h
47 | knot_vector.h
48 | zero_degree_b_spline_basis_function.h
49 | DESTINATION "${include_install_dir}")
50 |
--------------------------------------------------------------------------------
/src/baf/b_spline_basis_function.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_BAF_B_SPLINE_BASIS_FUNCTION_H_
16 | #define SRC_BAF_B_SPLINE_BASIS_FUNCTION_H_
17 |
18 | #include
19 |
20 | #include "basis_function.h"
21 |
22 | namespace baf {
23 | class BSplineBasisFunction : public BasisFunction {
24 | public:
25 | BSplineBasisFunction(const KnotVector &knot_vector, const Degree °ree, const KnotSpan &start_of_support);
26 |
27 | protected:
28 | double EvaluateOnSupport(const ParamCoord ¶m_coord) const override;
29 | double EvaluateDerivativeOnSupport(const ParamCoord ¶m_coord, const Derivative &derivative) const override;
30 |
31 | private:
32 | void SetLowerDegreeBasisFunctions(const KnotVector &knot_vector,
33 | const Degree °ree,
34 | const KnotSpan &start_of_support);
35 |
36 | double ComputeLeftQuotient(const ParamCoord ¶m_coord) const;
37 | double ComputeRightQuotient(const ParamCoord ¶m_coord) const;
38 |
39 | double InverseWithPossiblyZeroDenominator(double denominator) const;
40 |
41 | double left_denom_inv_;
42 | double right_denom_inv_;
43 | std::unique_ptr left_lower_degree_;
44 | std::unique_ptr right_lower_degree_;
45 | };
46 | } // namespace baf
47 |
48 | #endif // SRC_BAF_B_SPLINE_BASIS_FUNCTION_H_
49 |
--------------------------------------------------------------------------------
/src/baf/basis_function.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "basis_function.h"
16 |
17 | double baf::BasisFunction::Evaluate(const ParamCoord ¶mCoord) const {
18 | return IsCoordinateInSupport(paramCoord) ? this->EvaluateOnSupport(paramCoord) : 0.0;
19 | }
20 |
21 | double baf::BasisFunction::EvaluateDerivative(const ParamCoord ¶m_coord, const Derivative &derivative) const {
22 | return derivative.get() == 0 ? Evaluate(param_coord) :
23 | (IsCoordinateInSupport(param_coord) ? this->EvaluateDerivativeOnSupport(param_coord, derivative) : 0.0);
24 | }
25 |
26 | baf::BasisFunction::BasisFunction(const KnotVector &knot_vector, const Degree °ree, const KnotSpan &start_of_support)
27 | : degree_(degree) {
28 | auto start_index = static_cast(start_of_support.get());
29 | auto degree_index = static_cast(degree.get());
30 | start_knot_ = knot_vector.GetKnot(start_index);
31 | end_knot_ = knot_vector.GetKnot(start_index + degree_index + 1);
32 | end_knot_is_last_knot_ = knot_vector.IsLastKnot(end_knot_);
33 | }
34 |
35 | Degree baf::BasisFunction::GetDegree() const {
36 | return degree_;
37 | }
38 |
39 | ParamCoord baf::BasisFunction::GetStartKnot() const {
40 | return start_knot_;
41 | }
42 |
43 | ParamCoord baf::BasisFunction::GetEndKnot() const {
44 | return end_knot_;
45 | }
46 |
47 | bool baf::BasisFunction::IsCoordinateInSupport(const ParamCoord ¶m_coord) const {
48 | return (start_knot_ <= param_coord && param_coord < end_knot_)
49 | || (end_knot_is_last_knot_ && param_coord == end_knot_);
50 | }
51 |
--------------------------------------------------------------------------------
/src/baf/basis_function.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_BAF_BASIS_FUNCTION_H_
16 | #define SRC_BAF_BASIS_FUNCTION_H_
17 |
18 | #include "knot_vector.h"
19 | #include "named_type.h"
20 |
21 | using Degree = util::NamedType;
22 | using Derivative = util::NamedType;
23 |
24 | namespace baf {
25 | class BasisFunction {
26 | public:
27 | virtual ~BasisFunction() = default;
28 |
29 | // The evaluation of the i-th basis function of degree p > 0 N_{i,p} is a linear combination of the basis functions
30 | // N_{i,p-1} and N_{i+1,p-1} (see NURBS book equation 2.5). Therefore, for each basis function of degree > 0 a pointer
31 | // to these two basis functions is set in constructor, so that a basis function can be evaluated recursively.
32 | double Evaluate(const ParamCoord ¶mCoord) const;
33 |
34 | double EvaluateDerivative(const ParamCoord ¶m_coord, const Derivative &derivative) const;
35 |
36 | protected:
37 | BasisFunction(const KnotVector &knot_vector, const Degree °ree, const KnotSpan &start_of_support);
38 |
39 | virtual double EvaluateOnSupport(const ParamCoord ¶m_coord) const = 0;
40 | virtual double EvaluateDerivativeOnSupport(const ParamCoord ¶m_coord, const Derivative &derivative) const = 0;
41 |
42 | Degree GetDegree() const;
43 | ParamCoord GetStartKnot() const;
44 | ParamCoord GetEndKnot() const;
45 |
46 | private:
47 | bool IsCoordinateInSupport(const ParamCoord ¶m_coord) const;
48 |
49 | Degree degree_;
50 | ParamCoord start_knot_{0};
51 | ParamCoord end_knot_{1};
52 | bool end_knot_is_last_knot_{false};
53 | };
54 | } // namespace baf
55 |
56 | #endif // SRC_BAF_BASIS_FUNCTION_H_
57 |
--------------------------------------------------------------------------------
/src/baf/basis_function_factory.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "basis_function_factory.h"
16 |
17 | #include
18 |
19 | #include "b_spline_basis_function.h"
20 | #include "zero_degree_b_spline_basis_function.h"
21 |
22 | baf::BasisFunction *baf::BasisFunctionFactory::CreateDynamic(const KnotVector &knot_vector,
23 | const KnotSpan &start_of_support,
24 | const Degree °ree) {
25 | if (degree < Degree{0}) {
26 | std::string msg;
27 | msg = "Basis function degree must be positive. Given degree is " + std::to_string(degree.get());
28 | throw std::runtime_error(msg);
29 | }
30 | if (degree == Degree{0}) {
31 | return new baf::ZeroDegBSplBasFnc(knot_vector, start_of_support);
32 | }
33 | return new baf::BSplineBasisFunction(knot_vector, degree, start_of_support);
34 | }
35 |
--------------------------------------------------------------------------------
/src/baf/basis_function_factory.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_BAF_BASIS_FUNCTION_FACTORY_H_
16 | #define SRC_BAF_BASIS_FUNCTION_FACTORY_H_
17 |
18 | #include "basis_function.h"
19 |
20 | namespace baf {
21 | class BasisFunctionFactory {
22 | public:
23 | static BasisFunction *CreateDynamic(const KnotVector &knot_vector,
24 | const KnotSpan &start_of_support,
25 | const Degree °ree);
26 | };
27 | } // namespace baf
28 |
29 | #endif // SRC_BAF_BASIS_FUNCTION_FACTORY_H_
30 |
--------------------------------------------------------------------------------
/src/baf/control_point.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_BAF_CONTROL_POINT_H_
16 | #define SRC_BAF_CONTROL_POINT_H_
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 | #include
23 | #include
24 |
25 | namespace baf {
26 | class ControlPoint {
27 | public:
28 | explicit ControlPoint(std::initializer_list coordinates);
29 | explicit ControlPoint(std::vector coordinates);
30 | explicit ControlPoint(uint64_t dimension);
31 |
32 | int GetDimension() const;
33 | double GetValue(int dimension) const;
34 |
35 | void SetValue(int dimension, double value);
36 |
37 | ControlPoint operator+(const ControlPoint &control_point) const;
38 | ControlPoint operator-(const ControlPoint &control_point) const;
39 | ControlPoint operator*(const double &scalar) const;
40 |
41 | ControlPoint Transform(std::array, 4> TransMatrix,
42 | std::array scaling) const;
43 | double GetEuclideanNorm() const;
44 |
45 | protected:
46 | std::vector coordinates_;
47 | };
48 | } // namespace baf
49 |
50 | #endif // SRC_BAF_CONTROL_POINT_H_
51 |
--------------------------------------------------------------------------------
/src/baf/knot_vector.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_BAF_KNOT_VECTOR_H_
16 | #define SRC_BAF_KNOT_VECTOR_H_
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "named_type.h"
23 |
24 | using ParamCoord = util::NamedType;
25 | using KnotSpan = util::NamedType;
26 | using Degree = util::NamedType;
27 |
28 | namespace baf {
29 |
30 | class KnotVector {
31 | public:
32 | using ConstKnotIterator = std::vector::const_iterator;
33 | using KnotIterator = std::vector::iterator;
34 |
35 | KnotVector() = default;
36 | KnotVector(const KnotVector &knotVector);
37 | KnotVector(KnotVector &&knotVector) noexcept;
38 | explicit KnotVector(std::vector knots);
39 | KnotVector(std::initializer_list knots) noexcept;
40 | KnotVector(ConstKnotIterator begin, ConstKnotIterator end);
41 | KnotVector(std::vector coords, Degree degree, int nbControlPoints);
42 |
43 | virtual ~KnotVector() = default;
44 |
45 | KnotVector operator-(const KnotVector &rhs) const;
46 | KnotVector &operator=(const KnotVector &other);
47 | KnotVector &operator=(KnotVector &&other) noexcept;
48 | // Check if absolute distance between all knots is smaller than the epsilon defined in
49 | // NumericSettings.
50 | bool operator==(const KnotVector &rhs) const;
51 | bool AreEqual(const KnotVector &rhs, double tolerance) const;
52 | ParamCoord &operator[](size_t index);
53 |
54 | virtual ParamCoord GetKnot(size_t index) const;
55 | ParamCoord GetLastKnot() const;
56 | virtual KnotSpan GetKnotSpan(ParamCoord param_coord) const;
57 | virtual size_t GetMultiplicity(ParamCoord param_coord) const;
58 | virtual size_t GetNumberOfKnots() const;
59 | int GetNumberOfDifferentKnots() const;
60 |
61 | ConstKnotIterator begin() const;
62 | ConstKnotIterator end() const;
63 |
64 | KnotIterator begin();
65 | KnotIterator end();
66 |
67 | virtual bool IsInKnotVectorRange(const ParamCoord ¶m_coord) const;
68 | virtual bool IsLastKnot(const ParamCoord ¶m_coord) const;
69 |
70 | void InsertKnot(const ParamCoord ¶m_coord);
71 | void RemoveKnot(const ParamCoord ¶m_coord);
72 |
73 | private:
74 | std::vector knots_;
75 | };
76 | } // namespace baf
77 |
78 | #endif // SRC_BAF_KNOT_VECTOR_H_
79 |
--------------------------------------------------------------------------------
/src/baf/zero_degree_b_spline_basis_function.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "zero_degree_b_spline_basis_function.h"
16 |
17 | baf::ZeroDegBSplBasFnc::ZeroDegBSplBasFnc(const baf::KnotVector &knot_vector, const KnotSpan &start_of_support) :
18 | BasisFunction(knot_vector, Degree{0}, start_of_support) {}
19 |
20 | double baf::ZeroDegBSplBasFnc::EvaluateOnSupport(const ParamCoord /*param_coord*/&) const {
21 | return 1.0;
22 | }
23 |
24 | double baf::ZeroDegBSplBasFnc::EvaluateDerivativeOnSupport(const ParamCoord /*param_coord*/&,
25 | const Derivative /*degree*/&) const {
26 | return 0.0;
27 | }
28 |
--------------------------------------------------------------------------------
/src/baf/zero_degree_b_spline_basis_function.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_BAF_ZERO_DEGREE_B_SPLINE_BASIS_FUNCTION_H_
16 | #define SRC_BAF_ZERO_DEGREE_B_SPLINE_BASIS_FUNCTION_H_
17 |
18 | #include "basis_function.h"
19 | #include "knot_vector.h"
20 |
21 | namespace baf {
22 | class ZeroDegBSplBasFnc : public baf::BasisFunction {
23 | public:
24 | ZeroDegBSplBasFnc(const baf::KnotVector &knot_vector, const KnotSpan &start_of_support);
25 |
26 | protected:
27 | double EvaluateOnSupport(const ParamCoord ¶m_coord) const override;
28 | double EvaluateDerivativeOnSupport(const ParamCoord ¶m_coord, const Derivative &derivative) const override;
29 | };
30 | } // namespace baf
31 |
32 | #endif // SRC_BAF_ZERO_DEGREE_B_SPLINE_BASIS_FUNCTION_H_
33 |
--------------------------------------------------------------------------------
/src/io/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | add_subdirectory(executables)
17 |
18 | set(SOURCES
19 | iges_reader.cc
20 | iges_writer.cc
21 | io_converter.cc
22 | irit_reader.cc
23 | irit_writer.cc
24 | vtk_writer.cc
25 | xml_reader.cc
26 | xml_writer.cc)
27 |
28 | add_library(splinelibio SHARED ${SOURCES})
29 |
30 | target_include_directories(splinelibio PUBLIC $)
31 | target_link_libraries(splinelibio splinelibspl pugixmllib)
32 |
33 | install(
34 | TARGETS splinelibio
35 | EXPORT "${targets_export_name}"
36 | LIBRARY DESTINATION "${library_install_dir}"
37 | ARCHIVE DESTINATION "${library_install_dir}"
38 | RUNTIME DESTINATION "${executable_install_dir}"
39 | INCLUDES DESTINATION "${include_install_dir}"
40 | )
41 |
42 | install(FILES
43 | iges_reader.h
44 | iges_writer.h
45 | io_converter.h
46 | irit_reader.h
47 | irit_reader_utils.h
48 | irit_writer.h
49 | irit_writer_utils.h
50 | reader.h
51 | vtk_writer.h
52 | vtk_writer_utils.h
53 | writer.h
54 | xml_reader.h
55 | xml_reader_utils.h
56 | xml_writer.h
57 | xml_writer_utils.h
58 | writer.h
59 | DESTINATION "${include_install_dir}")
60 |
--------------------------------------------------------------------------------
/src/io/executables/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 | #
3 | # This file is part of SplineLib.
4 | #
5 | # SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | # License as published by the Free Software Foundation version 3 of the License.
7 | #
8 | # SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
9 | # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
10 | # details.
11 | #
12 | # You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
13 | # .
14 | #
15 |
16 | add_library(ioconversion INTERFACE)
17 | add_executable(iges2irit iges_to_irit.cc converter_log.cc)
18 | add_executable(iges2vtk iges_to_vtk.cc converter_log.cc)
19 | add_executable(iges2xml iges_to_xml.cc converter_log.cc)
20 | add_executable(irit2iges irit_to_iges.cc converter_log.cc)
21 | add_executable(irit2vtk irit_to_vtk.cc converter_log.cc)
22 | add_executable(irit2xml irit_to_xml.cc converter_log.cc)
23 | add_executable(xml2iges xml_to_iges.cc converter_log.cc)
24 | add_executable(xml2irit xml_to_irit.cc converter_log.cc)
25 | add_executable(xml2vtk xml_to_vtk.cc converter_log.cc)
26 |
27 | set_target_properties(iges2irit iges2vtk iges2xml irit2iges irit2vtk irit2xml xml2iges xml2irit xml2vtk PROPERTIES ENABLE_EXPORTS 1)
28 |
29 | target_link_libraries(iges2irit splinelibio)
30 | target_link_libraries(iges2vtk splinelibio)
31 | target_link_libraries(iges2xml splinelibio)
32 | target_link_libraries(irit2iges splinelibio)
33 | target_link_libraries(irit2vtk splinelibio)
34 | target_link_libraries(irit2xml splinelibio)
35 | target_link_libraries(xml2iges splinelibio)
36 | target_link_libraries(xml2irit splinelibio)
37 | target_link_libraries(xml2vtk splinelibio)
38 | target_link_libraries(ioconversion INTERFACE iges2irit iges2vtk iges2xml irit2iges irit2vtk irit2xml xml2iges xml2irit xml2vtk)
39 |
40 | install(
41 | TARGETS ioconversion iges2irit iges2vtk iges2xml irit2iges irit2vtk irit2xml xml2iges xml2irit xml2vtk
42 | EXPORT "${targets_export_name}"
43 | LIBRARY DESTINATION "${library_install_dir}"
44 | ARCHIVE DESTINATION "${library_install_dir}"
45 | RUNTIME DESTINATION "${executable_install_dir}"
46 | INCLUDES DESTINATION "${include_install_dir}"
47 | )
48 |
--------------------------------------------------------------------------------
/src/io/executables/converter_log.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 | #ifndef SRC_IO_EXECUTABLES_CONVERTER_LOG_H_
15 | #define SRC_IO_EXECUTABLES_CONVERTER_LOG_H_
16 |
17 | #include
18 | #include
19 |
20 | namespace io {
21 | class ConverterLog {
22 | public:
23 | ConverterLog();
24 | explicit ConverterLog(const char *log_file);
25 |
26 | const char *GetInput() const;
27 | const char *GetOutput() const;
28 | std::vector GetPositions(std::vector possible_positions);
29 | std::vector> GetScattering();
30 |
31 | void WriteLog() const;
32 | void PrintHelp() const;
33 |
34 | private:
35 | std::string GetTime() const;
36 | bool OneSpline() const;
37 |
38 | const char *log_file_;
39 | std::string input_;
40 | std::string output_;
41 | std::vector positions_;
42 | std::vector written_;
43 | std::vector not_written_;
44 | std::vector> scattering_;
45 | };
46 | } // namespace io
47 |
48 | #endif // SRC_IO_EXECUTABLES_CONVERTER_LOG_H_
49 |
--------------------------------------------------------------------------------
/src/io/executables/iges_to_irit.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "iges_reader.h"
17 | #include "io_converter.h"
18 | #include "irit_writer.h"
19 | #include "string_operations.h"
20 | #include "vector_utils.h"
21 |
22 | int main(int argc, char *argv[]) {
23 | if (argc != 2) {
24 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
25 | }
26 | const char *log_file = argv[1]; // NOLINT
27 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
28 | io::ConverterLog help;
29 | help.PrintHelp();
30 | return 0;
31 | }
32 | io::ConverterLog log(log_file);
33 | std::vector splines;
34 |
35 | try {
36 | io::IGESReader iges_reader;
37 | splines = iges_reader.ReadFile(log.GetInput());
38 | } catch (std::runtime_error &error) {
39 | throw error;
40 | } catch (...) {
41 | throw std::runtime_error(R"(The input file isn't of correct ".iges" format.)");
42 | }
43 |
44 | io::IRITWriter irit_writer;
45 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 3));
46 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
47 | irit_writer.WriteFile(splines_with_max_dim, log.GetOutput());
48 |
49 | log.WriteLog();
50 | return 0;
51 | }
52 |
--------------------------------------------------------------------------------
/src/io/executables/iges_to_vtk.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "iges_reader.h"
17 | #include "io_converter.h"
18 | #include "string_operations.h"
19 | #include "vector_utils.h"
20 | #include "vtk_writer.h"
21 |
22 | int main(int argc, char *argv[]) {
23 | if (argc != 2) {
24 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
25 | }
26 | const char *log_file = argv[1]; // NOLINT
27 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
28 | io::ConverterLog help;
29 | help.PrintHelp();
30 | return 0;
31 | }
32 | io::ConverterLog log(log_file);
33 | std::vector splines;
34 |
35 | try {
36 | io::IGESReader iges_reader;
37 | splines = iges_reader.ReadFile(log.GetInput());
38 | } catch (std::runtime_error &error) {
39 | throw error;
40 | } catch (...) {
41 | throw std::runtime_error(R"(The input file isn't of correct ".iges" format.)");
42 | }
43 |
44 | io::VTKWriter vtk_writer;
45 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 3));
46 | std::vector> scattering = log.GetScattering();
47 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
48 | vtk_writer.WriteFile(splines_with_max_dim, log.GetOutput(), scattering);
49 |
50 | log.WriteLog();
51 | return 0;
52 | }
53 |
--------------------------------------------------------------------------------
/src/io/executables/iges_to_xml.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "iges_reader.h"
17 | #include "io_converter.h"
18 | #include "string_operations.h"
19 | #include "vector_utils.h"
20 | #include "xml_writer.h"
21 |
22 | int main(int argc, char *argv[]) {
23 | if (argc != 2) {
24 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
25 | }
26 | const char *log_file = argv[1]; // NOLINT
27 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
28 | io::ConverterLog help;
29 | help.PrintHelp();
30 | return 0;
31 | }
32 | io::ConverterLog log(log_file);
33 | std::vector splines;
34 |
35 | try {
36 | io::IGESReader iges_reader;
37 | splines = iges_reader.ReadFile(log.GetInput());
38 | } catch (std::runtime_error &error) {
39 | throw error;
40 | } catch (...) {
41 | throw std::runtime_error(R"(The input file isn't of correct ".iges" format.)");
42 | }
43 |
44 | io::XMLWriter xml_writer;
45 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 4));
46 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
47 | xml_writer.WriteFile(splines_with_max_dim, log.GetOutput());
48 |
49 | log.WriteLog();
50 | return 0;
51 | }
52 |
--------------------------------------------------------------------------------
/src/io/executables/irit_to_iges.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "io_converter.h"
17 | #include "irit_reader.h"
18 | #include "string_operations.h"
19 | #include "iges_writer.h"
20 |
21 | int main(int argc, char *argv[]) {
22 | if (argc != 2) {
23 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
24 | }
25 | const char *log_file = argv[1]; // NOLINT
26 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
27 | io::ConverterLog help;
28 | help.PrintHelp();
29 | return 0;
30 | }
31 | io::ConverterLog log(log_file);
32 | std::vector splines;
33 |
34 | try {
35 | io::IRITReader irit_reader;
36 | splines = irit_reader.ReadFile(log.GetInput());
37 | } catch (std::runtime_error &error) {
38 | throw error;
39 | } catch (...) {
40 | throw std::runtime_error(R"(The input file isn't of correct ".itd" format.)");
41 | }
42 |
43 | io::IGESWriter iges_writer;
44 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 2));
45 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
46 | iges_writer.WriteFile(splines_with_max_dim, log.GetOutput());
47 |
48 | log.WriteLog();
49 | return 0;
50 | }
51 |
--------------------------------------------------------------------------------
/src/io/executables/irit_to_vtk.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "io_converter.h"
17 | #include "irit_reader.h"
18 | #include "string_operations.h"
19 | #include "vtk_writer.h"
20 |
21 | int main(int argc, char *argv[]) {
22 | if (argc != 2) {
23 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
24 | }
25 | const char *log_file = argv[1]; // NOLINT
26 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
27 | io::ConverterLog help;
28 | help.PrintHelp();
29 | return 0;
30 | }
31 | io::ConverterLog log(log_file);
32 | std::vector splines;
33 |
34 | try {
35 | io::IRITReader irit_reader;
36 | splines = irit_reader.ReadFile(log.GetInput());
37 | } catch (std::runtime_error &error) {
38 | throw error;
39 | } catch (...) {
40 | throw std::runtime_error(R"(The input file isn't of correct ".itd" format.)");
41 | }
42 |
43 | io::VTKWriter vtk_writer;
44 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 3));
45 | std::vector> scattering = log.GetScattering();
46 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
47 | vtk_writer.WriteFile(splines_with_max_dim, log.GetOutput(), scattering);
48 |
49 | log.WriteLog();
50 | return 0;
51 | }
52 |
--------------------------------------------------------------------------------
/src/io/executables/irit_to_xml.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "io_converter.h"
17 | #include "irit_reader.h"
18 | #include "string_operations.h"
19 | #include "xml_writer.h"
20 |
21 | int main(int argc, char *argv[]) {
22 | if (argc != 2) {
23 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
24 | }
25 | const char *log_file = argv[1]; // NOLINT
26 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
27 | io::ConverterLog help;
28 | help.PrintHelp();
29 | return 0;
30 | }
31 | io::ConverterLog log(log_file);
32 | std::vector splines;
33 |
34 | try {
35 | io::IRITReader irit_reader;
36 | splines = irit_reader.ReadFile(log.GetInput());
37 | } catch (std::runtime_error &error) {
38 | throw error;
39 | } catch (...) {
40 | throw std::runtime_error(R"(The input file isn't of correct ".itd" format.)");
41 | }
42 |
43 | io::XMLWriter iges_writer;
44 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 4));
45 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
46 | iges_writer.WriteFile(splines_with_max_dim, log.GetOutput());
47 |
48 | log.WriteLog();
49 | }
50 |
--------------------------------------------------------------------------------
/src/io/executables/xml_to_iges.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "string_operations.h"
17 | #include "iges_writer.h"
18 | #include "io_converter.h"
19 | #include "xml_reader.h"
20 |
21 | int main(int argc, char *argv[]) {
22 | if (argc != 2) {
23 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
24 | }
25 | const char *log_file = argv[1]; // NOLINT
26 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
27 | io::ConverterLog help;
28 | help.PrintHelp();
29 | return 0;
30 | }
31 | io::ConverterLog log(log_file);
32 | std::vector splines;
33 |
34 | try {
35 | io::XMLReader xml_reader;
36 | splines = xml_reader.ReadFile(log.GetInput());
37 | } catch (std::runtime_error &error) {
38 | throw error;
39 | } catch (...) {
40 | throw std::runtime_error(R"(The input file isn't of correct ".xml" format.)");
41 | }
42 |
43 | io::IGESWriter iges_writer;
44 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 2));
45 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
46 | iges_writer.WriteFile(splines_with_max_dim, log.GetOutput());
47 |
48 | log.WriteLog();
49 | return 0;
50 | }
51 |
--------------------------------------------------------------------------------
/src/io/executables/xml_to_irit.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "io_converter.h"
17 | #include "irit_writer.h"
18 | #include "string_operations.h"
19 | #include "xml_reader.h"
20 |
21 | int main(int argc, char *argv[]) {
22 | if (argc != 2) {
23 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
24 | }
25 | const char *log_file = argv[1]; // NOLINT
26 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
27 | io::ConverterLog help;
28 | help.PrintHelp();
29 | return 0;
30 | }
31 | io::ConverterLog log(log_file);
32 | std::vector splines;
33 |
34 | try {
35 | io::XMLReader xml_reader;
36 | splines = xml_reader.ReadFile(log.GetInput());
37 | } catch (std::runtime_error &error) {
38 | throw error;
39 | } catch (...) {
40 | throw std::runtime_error(R"(The input file isn't of correct ".xml" format.)");
41 | }
42 |
43 | io::IRITWriter irit_writer;
44 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 3));
45 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
46 | irit_writer.WriteFile(splines_with_max_dim, log.GetOutput());
47 |
48 | log.WriteLog();
49 | return 0;
50 | }
51 |
--------------------------------------------------------------------------------
/src/io/executables/xml_to_vtk.cc:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #include "converter_log.h"
16 | #include "io_converter.h"
17 | #include "string_operations.h"
18 | #include "xml_reader.h"
19 | #include "vtk_writer.h"
20 |
21 | int main(int argc, char *argv[]) {
22 | if (argc != 2) {
23 | throw std::runtime_error("Exactly one name of the log file is required as command line argument.");
24 | }
25 | const char *log_file = argv[1]; // NOLINT
26 | if (util::StringOperations::StartsWith(log_file, "--help") || util::StringOperations::StartsWith(log_file, "-h")) {
27 | io::ConverterLog help;
28 | help.PrintHelp();
29 | return 0;
30 | }
31 | io::ConverterLog log(log_file);
32 | std::vector splines;
33 |
34 | try {
35 | io::XMLReader xml_reader;
36 | splines = xml_reader.ReadFile(log.GetInput());
37 | } catch (std::runtime_error &error) {
38 | throw error;
39 | } catch (...) {
40 | throw std::runtime_error(R"(The input file isn't of correct ".xml" format.)");
41 | }
42 |
43 | io::VTKWriter vtk_writer;
44 | std::vector positions = log.GetPositions(io::IOConverter::GetSplinePositionsOfCorrectDimension(splines, 3));
45 | std::vector> scattering = log.GetScattering();
46 | std::vector splines_with_max_dim = util::VectorUtils::FilterVector(splines, positions);
47 | vtk_writer.WriteFile(splines_with_max_dim, log.GetOutput(), scattering);
48 |
49 | log.WriteLog();
50 | return 0;
51 | }
52 |
--------------------------------------------------------------------------------
/src/io/iges_reader.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IO_IGES_READER_H_
16 | #define SRC_IO_IGES_READER_H_
17 |
18 | #include
19 | #include
20 | #include
21 | #include
22 |
23 | #include "reader.h"
24 |
25 | namespace io {
26 | class IGESReader : public Reader {
27 | public:
28 | IGESReader() = default;
29 |
30 | std::vector ReadFile(const char *filename) override;
31 |
32 | private:
33 | std::any Create1DSpline(const std::vector ¶meterData);
34 | std::any Create2DSpline(const std::vector ¶meterData);
35 |
36 | std::array GetParameterSectionStartEndPointers(std::vector directoryEntrySection,
37 | int entityToBeRead);
38 |
39 | std::vector ParameterSectionToVector(std::vector parameterSection,
40 | std::array ParameterSectionStartEndPointers);
41 |
42 | static inline std::string trim(std::string s);
43 | };
44 | } // namespace io
45 |
46 | #endif // SRC_IO_IGES_READER_H_
47 |
--------------------------------------------------------------------------------
/src/io/io_converter.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IO_IO_CONVERTER_H_
16 | #define SRC_IO_IO_CONVERTER_H_
17 |
18 | #include
19 | #include
20 | #include
21 |
22 | #include "any_casts.h"
23 | #include "iges_reader.h"
24 | #include "iges_writer.h"
25 | #include "irit_reader.h"
26 | #include "irit_writer.h"
27 | #include "string_operations.h"
28 | #include "vtk_writer.h"
29 | #include "xml_reader.h"
30 | #include "xml_writer.h"
31 |
32 | namespace io {
33 | class IOConverter {
34 | public:
35 | IOConverter(const char *input_filename, const char *output_filename);
36 |
37 | std::vector ConvertFile(const std::vector &positions = {},
38 | const std::vector> &scattering = {});
39 |
40 | static std::vector GetSplinePositionsOfCorrectDimension(const std::vector &splines, int max_dim);
41 |
42 | enum file_format { error, iges, irit, vtk, xml };
43 |
44 | private:
45 | file_format GetFileFormat(const char *filename) const;
46 |
47 | io::Reader *GetReader() const;
48 | void GetWriter(const std::vector &splines, const std::vector &positions,
49 | const std::vector> &scattering);
50 | void WriteFile(const std::vector &splines, const std::vector &positions, int max_dim,
51 | const std::shared_ptr &writer);
52 |
53 | void GetPositions(const std::vector &positions, const std::vector &possible_positions);
54 | std::vector> GetScattering(const std::vector> &scattering,
55 | const std::vector &positions,
56 | const std::vector &written);
57 |
58 | const char *input_filename_;
59 | const char *output_filename_;
60 | file_format input_format_;
61 | file_format output_format_;
62 | std::vector written_;
63 | };
64 | } // namespace io
65 |
66 | #endif // SRC_IO_IO_CONVERTER_H_
67 |
--------------------------------------------------------------------------------
/src/io/irit_reader.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2018 Chair for Computational Analysis of Technical Systems, RWTH Aachen University
2 |
3 | This file is part of SplineLib.
4 |
5 | SplineLib is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
6 | License as published by the Free Software Foundation version 3 of the License.
7 |
8 | SplineLib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
9 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
10 |
11 | You should have received a copy of the GNU Lesser General Public License along with SplineLib. If not, see
12 | .
13 | */
14 |
15 | #ifndef SRC_IO_IRIT_READER_H_
16 | #define SRC_IO_IRIT_READER_H_
17 |
18 | #include
19 | #include