Blue Brain BioExplorer
VolumeParameters.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2024, EPFL/Blue Brain Project
3  * All rights reserved. Do not distribute without permission.
4  *
5  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
6  *
7  * This library is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Lesser General Public License version 3.0 as published
9  * by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * 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
17  * along with this library; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "VolumeParameters.h"
22 
23 namespace
24 {
25 const std::string PARAM_VOLUME_DIMENSIONS = "volume-dimensions";
26 const std::string PARAM_VOLUME_ELEMENT_SPACING = "volume-element-spacing";
27 const std::string PARAM_VOLUME_OFFSET = "volume-offset";
28 } // namespace
29 
30 namespace core
31 {
33  : AbstractParameters("Volume")
34  , _dimensions(0, 0, 0)
35  , _elementSpacing(1.f, 1.f, 1.f)
36  , _offset(0.f, 0.f, 0.f)
37 {
38  _parameters.add_options()(PARAM_VOLUME_DIMENSIONS.c_str(), po::fixed_tokens_value<uints>(3, 3),
39  "Volume dimensions [uint uint uint]")(
40  PARAM_VOLUME_ELEMENT_SPACING.c_str(), po::fixed_tokens_value<floats>(3, 3),
41  "Element spacing in the volume [float float float]")(PARAM_VOLUME_OFFSET.c_str(),
42  po::fixed_tokens_value<floats>(3, 3),
43  "Volume offset [float float float]");
44 }
45 
46 void VolumeParameters::parse(const po::variables_map& vm)
47 {
48  if (vm.count(PARAM_VOLUME_DIMENSIONS))
49  {
50  auto values = vm[PARAM_VOLUME_DIMENSIONS].as<uints>();
51  _dimensions = Vector3ui(values[0], values[1], values[2]);
52  }
53  if (vm.count(PARAM_VOLUME_ELEMENT_SPACING))
54  {
55  auto values = vm[PARAM_VOLUME_ELEMENT_SPACING].as<floats>();
56  _elementSpacing = Vector3f(values[0], values[1], values[2]);
57  }
58  if (vm.count(PARAM_VOLUME_OFFSET))
59  {
60  auto values = vm[PARAM_VOLUME_OFFSET].as<floats>();
61  _offset = Vector3f(values[0], values[1], values[2]);
62  }
63  markModified();
64 }
65 
67 {
69  CORE_INFO("Dimensions : " << _dimensions);
70  CORE_INFO("Element spacing : " << _elementSpacing);
71  CORE_INFO("Offset : " << _offset);
72 }
73 } // namespace core
po::options_description _parameters
void markModified(const bool triggerCallback=true)
Definition: BaseObject.h:65
void parse(const po::variables_map &vm) final
glm::vec3 Vector3f
Definition: MathTypes.h:137
glm::vec< 3, uint32_t > Vector3ui
Definition: MathTypes.h:134
#define CORE_INFO(__msg)
Definition: Logs.h:33
std::vector< unsigned int > uints
Definition: Types.h:47
std::vector< float > floats
Definition: Types.h:45