LCOV - code coverage report
Current view: top level - variable - structures.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 10 12 83.3 %
Date: 2024-11-17 01:47:58 Functions: 9 10 90.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: BSD-3-Clause
       2             : // Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
       3             : /// @file
       4             : /// @author Simon Heybrock
       5             : #include "scipp/variable/structures.h"
       6             : #include "scipp/core/eigen.h"
       7             : #include "scipp/core/spatial_transforms.h"
       8             : #include "scipp/variable/structure_array_model.h"
       9             : 
      10             : namespace scipp::variable {
      11             : 
      12             : template <class T, class Elem>
      13         175 : Variable make_structures(const Dimensions &dims, const units::Unit &unit,
      14             :                          element_array<double> &&values) {
      15             :   return {dims, std::make_shared<StructureArrayModel<T, Elem>>(
      16         175 :                     dims.volume(), unit, std::move(values))};
      17             : }
      18             : 
      19             : template SCIPP_VARIABLE_EXPORT Variable
      20             : make_structures<Eigen::Vector3d, double>(const Dimensions &,
      21             :                                          const units::Unit &,
      22             :                                          element_array<double> &&);
      23             : 
      24             : template SCIPP_VARIABLE_EXPORT Variable
      25             : make_structures<Eigen::Matrix3d, double>(const Dimensions &,
      26             :                                          const units::Unit &,
      27             :                                          element_array<double> &&);
      28             : 
      29             : template SCIPP_VARIABLE_EXPORT Variable
      30             : make_structures<Eigen::Affine3d, double>(const Dimensions &,
      31             :                                          const units::Unit &,
      32             :                                          element_array<double> &&);
      33             : 
      34             : template SCIPP_VARIABLE_EXPORT Variable
      35             : make_structures<scipp::core::Quaternion, double>(const Dimensions &,
      36             :                                                  const units::Unit &,
      37             :                                                  element_array<double> &&);
      38             : 
      39             : template SCIPP_VARIABLE_EXPORT Variable
      40             : make_structures<scipp::core::Translation, double>(const Dimensions &,
      41             :                                                   const units::Unit &,
      42             :                                                   element_array<double> &&);
      43             : 
      44             : /// Construct a variable containing vectors from a variable of elements.
      45          14 : Variable make_vectors(const Dimensions &dims, const units::Unit &unit,
      46             :                       element_array<double> &&values) {
      47             :   return make_structures<Eigen::Vector3d, double>(dims, unit,
      48          14 :                                                   std::move(values));
      49             : }
      50             : 
      51             : /// Construct a variable containing matrices from a variable of elements.
      52          10 : Variable make_matrices(const Dimensions &dims, const units::Unit &unit,
      53             :                        element_array<double> &&values) {
      54             :   return make_structures<Eigen::Matrix3d, double>(dims, unit,
      55          10 :                                                   std::move(values));
      56             : }
      57             : 
      58             : /// Construct a variable containing affine transforms from a variable of
      59             : /// elements.
      60           0 : Variable make_affine_transforms(const Dimensions &dims, const units::Unit &unit,
      61             :                                 element_array<double> &&values) {
      62             :   return make_structures<Eigen::Affine3d, double>(dims, unit,
      63           0 :                                                   std::move(values));
      64             : }
      65             : 
      66             : /// Construct a variable containing rotations from a variable of elements.
      67           1 : Variable make_rotations(const Dimensions &dims, const units::Unit &unit,
      68             :                         element_array<double> &&values) {
      69             :   return make_structures<scipp::core::Quaternion, double>(dims, unit,
      70           1 :                                                           std::move(values));
      71             : }
      72             : 
      73             : /// Construct a variable containing translations from a variable of elements.
      74           1 : Variable make_translations(const Dimensions &dims, const units::Unit &unit,
      75             :                            element_array<double> &&values) {
      76             :   return make_structures<scipp::core::Translation, double>(dims, unit,
      77           1 :                                                            std::move(values));
      78             : }
      79             : } // namespace scipp::variable

Generated by: LCOV version 1.14