fitpack
Modern Fortran library for curve and surface fitting with splines
Loading...
Searching...
No Matches
fpFitter_subtypes.hpp
Go to the documentation of this file.
1/***************************************************************************************************
2! ____________________ ___ ________ __
3! / ____/ _/_ __/ __ \/ | / ____/ //_/
4! / /_ / / / / / /_/ / /| |/ / / ,<
5! / __/ _/ / / / / ____/ ___ / /___/ /| |
6! /_/ /___/ /_/ /_/ /_/ |_\____/_/ |_|
7!
8! A Curve Fitting Package
9!
10! fpFitter_subtypes.hpp (class fpFitter)
11!> @brief Polymorphic dispatch for class(fitpack_fitter).
12!
13! Bundles three things, all derived from the bound concrete subtypes
14! of the abstract base fpFitter:
15! 1. `#include`s of the abstract base + every concrete subtype
16! 2. `fpFitterVariant` — std::variant<Concretes...>
17! 3. `wrap_fitpack_fitter(handle, class_name)` — resolves the
18! (base C handle, class-name string) pair into the matching
19! concrete subtype variant alternative.
20!
21! Include this header where you need to construct a polymorphic
22! view — typically in parent classes that hold a class(fitpack_fitter)
23! component, or in any consumer code dispatching on the dynamic type.
24! The base header `fpFitter.hpp` does NOT include the
25! concrete subtype headers (avoids cycles); this umbrella collects them.
26!
27! @author Federico Perini
28! @date 2026-08-27
29!
30! References :
31! - C. De Boor, "On calculating with b-splines", J Approx Theory 6 (1972) 50-62
32! - M. G. Cox, "The numerical evaluation of b-splines", J Inst Maths Applics 10 (1972) 134-149
33! - P. Dierckx, "Curve and surface fitting with splines", Monographs on numerical analysis,
34! Oxford university press, 1993.
35!
36! **************************************************************************************************/
37
38#ifndef FPFITTER_SUBTYPES_HPP_INCLUDED
39#define FPFITTER_SUBTYPES_HPP_INCLUDED
40
41#include "fpFitter.hpp"
42#include "fpPeriodicCurve.hpp"
43#include "fpConvexCurve.hpp"
44#include "fpCurve.hpp"
45#include "fpClosedCurve.hpp"
47#include "fpParametricCurve.hpp"
48#include "fpSurface.hpp"
49#include "fpGridSurface.hpp"
50#include "fpGridSpline.hpp"
52#include "fpPolar.hpp"
53#include "fpGridPolar.hpp"
54#include "fpSphere.hpp"
55#include "fpGridSphere.hpp"
56#include <variant>
57#include <optional>
58#include <stdexcept>
59#include <string>
60#include <cstring>
61
62
71using fpFitterVariant = std::variant<
74 fpCurve,
82 fpPolar,
86
110inline std::optional<fpFitterVariant>
111wrap_fitpack_fitter(fitpack_fitter_c handle, const char* class_name) {
112 if (handle.cptr == nullptr) return std::nullopt;
113 if (class_name == nullptr) {
114 throw std::runtime_error(
115 "wrap_fitpack_fitter: handle non-null but class_name null "
116 "(generator bug: select_type fanout missed an arm).");
117 }
118 if (std::strcmp(class_name, "fitpack_periodic_curve") == 0)
120 *reinterpret_cast<fitpack_periodic_curve_c*>(&handle),
122 if (std::strcmp(class_name, "fitpack_convex_curve") == 0)
124 *reinterpret_cast<fitpack_convex_curve_c*>(&handle),
126 if (std::strcmp(class_name, "fitpack_curve") == 0)
128 *reinterpret_cast<fitpack_curve_c*>(&handle),
130 if (std::strcmp(class_name, "fitpack_closed_curve") == 0)
132 *reinterpret_cast<fitpack_closed_curve_c*>(&handle),
134 if (std::strcmp(class_name, "fitpack_constrained_curve") == 0)
136 *reinterpret_cast<fitpack_constrained_curve_c*>(&handle),
138 if (std::strcmp(class_name, "fitpack_parametric_curve") == 0)
140 *reinterpret_cast<fitpack_parametric_curve_c*>(&handle),
142 if (std::strcmp(class_name, "fitpack_surface") == 0)
144 *reinterpret_cast<fitpack_surface_c*>(&handle),
146 if (std::strcmp(class_name, "fitpack_grid_surface") == 0)
148 *reinterpret_cast<fitpack_grid_surface_c*>(&handle),
150 if (std::strcmp(class_name, "fitpack_gridded_spline") == 0)
152 *reinterpret_cast<fitpack_gridded_spline_c*>(&handle),
154 if (std::strcmp(class_name, "fitpack_parametric_surface") == 0)
156 *reinterpret_cast<fitpack_parametric_surface_c*>(&handle),
158 if (std::strcmp(class_name, "fitpack_polar") == 0)
160 *reinterpret_cast<fitpack_polar_c*>(&handle),
162 if (std::strcmp(class_name, "fitpack_grid_polar") == 0)
164 *reinterpret_cast<fitpack_grid_polar_c*>(&handle),
166 if (std::strcmp(class_name, "fitpack_sphere") == 0)
168 *reinterpret_cast<fitpack_sphere_c*>(&handle),
170 if (std::strcmp(class_name, "fitpack_grid_sphere") == 0)
172 *reinterpret_cast<fitpack_grid_sphere_c*>(&handle),
174 throw std::runtime_error(
175 std::string("wrap_fitpack_fitter: unbound dynamic type '") +
176 class_name + "' (regenerate bindings).");
177}
178
179
180#endif /* FPFITTER_SUBTYPES_HPP_INCLUDED */
Standalone C++ RAII wrapper for Fortran fitpack_closed_curve.
Definition fpClosedCurve.hpp:54
Standalone C++ RAII wrapper for Fortran fitpack_constrained_curve.
Definition fpConstrainedCurve.hpp:55
Standalone C++ RAII wrapper for Fortran fitpack_convex_curve.
Definition fpConvexCurve.hpp:54
Standalone C++ RAII wrapper for Fortran fitpack_curve.
Definition fpCurve.hpp:56
Standalone C++ RAII wrapper for Fortran fitpack_grid_polar.
Definition fpGridPolar.hpp:55
Standalone C++ RAII wrapper for Fortran fitpack_grid_sphere.
Definition fpGridSphere.hpp:55
Standalone C++ RAII wrapper for Fortran fitpack_gridded_spline.
Definition fpGridSpline.hpp:56
Standalone C++ RAII wrapper for Fortran fitpack_grid_surface.
Definition fpGridSurface.hpp:56
Standalone C++ RAII wrapper for Fortran fitpack_parametric_curve.
Definition fpParametricCurve.hpp:56
Standalone C++ RAII wrapper for Fortran fitpack_parametric_surface.
Definition fpParametricSurface.hpp:55
Standalone C++ RAII wrapper for Fortran fitpack_periodic_curve.
Definition fpPeriodicCurve.hpp:54
Standalone C++ RAII wrapper for Fortran fitpack_polar.
Definition fpPolar.hpp:55
Standalone C++ RAII wrapper for Fortran fitpack_sphere.
Definition fpSphere.hpp:55
Standalone C++ RAII wrapper for Fortran fitpack_surface.
Definition fpSurface.hpp:56
std::optional< fpFitterVariant > wrap_fitpack_fitter(fitpack_fitter_c handle, const char *class_name)
Resolve a (handle, class_name) pair into the right concrete variant alternative.
Definition fpFitter_subtypes.hpp:111
std::variant< fpPeriodicCurve, fpConvexCurve, fpCurve, fpClosedCurve, fpConstrainedCurve, fpParametricCurve, fpSurface, fpGridSurface, fpGridSpline, fpParametricSurface, fpPolar, fpGridPolar, fpSphere, fpGridSphere > fpFitterVariant
Variant of bound concrete subtypes of class(fitpack_fitter).
Definition fpFitter_subtypes.hpp:71
Tag type for non-owning view constructors of polymorphic concrete subtypes. Declared on roots and abs...
Definition fpFitter.hpp:103