OpenWalnut  1.5.0dev
WDataSetDTI.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <memory>
26 #include <string>
27 
28 #include "WDataSetDTI.h"
29 
30 // prototype instance as singleton
31 std::shared_ptr< WPrototyped > WDataSetDTI::m_prototype = std::shared_ptr< WPrototyped >();
32 
34  : WDataSetSingle()
35 {
36  // default constructor used by the prototype mechanism
37 }
38 
39 WDataSetDTI::WDataSetDTI( std::shared_ptr< WValueSetBase > newValueSet, std::shared_ptr< WGrid > newGrid )
40  : WDataSetSingle( newValueSet, newGrid )
41 {
42  WAssert( newValueSet, "No value set given." );
43  WAssert( newGrid, "No grid given." );
44  WAssert( newValueSet->size() == newGrid->size(), "Number of values unequal number of positions in grid." );
45  WAssert( newValueSet->order() == 1, "The value set does not contain vectors." );
46  WAssert( newValueSet->dimension() == 6, "The size of the vetors does not match symmetric matrices: must be equal to 6." );
47 }
48 
50 {
51 }
52 
53 WDataSetSingle::SPtr WDataSetDTI::clone( std::shared_ptr< WValueSetBase > newValueSet, std::shared_ptr< WGrid > newGrid ) const
54 {
55  return WDataSetSingle::SPtr( new WDataSetDTI( newValueSet, newGrid ) );
56 }
57 
58 WDataSetSingle::SPtr WDataSetDTI::clone( std::shared_ptr< WValueSetBase > newValueSet ) const
59 {
60  return WDataSetSingle::SPtr( new WDataSetDTI( newValueSet, getGrid() ) );
61 }
62 
63 WDataSetSingle::SPtr WDataSetDTI::clone( std::shared_ptr< WGrid > newGrid ) const
64 {
65  return WDataSetSingle::SPtr( new WDataSetDTI( getValueSet(), newGrid ) );
66 }
67 
69 {
71 }
72 
74 {
75  std::shared_ptr< WValueSet< float > > values = std::dynamic_pointer_cast< WValueSet< float > >( m_valueSet );
76  WAssert( values, "The value set of a WDataSetDTI must be a WValueSet< float >, nothing else!" );
77  return WTensorSym< 2, 3, float >( values->getWValue( index ) );
78 }
79 
80 const std::string WDataSetDTI::getName() const
81 {
82  return "WDataSetDTI";
83 }
84 
85 const std::string WDataSetDTI::getDescription() const
86 {
87  return "Contains Diffusion Tensors.";
88 }
89 
90 
91 std::shared_ptr< WPrototyped > WDataSetDTI::getPrototype()
92 {
93  if( !m_prototype )
94  {
95  m_prototype = std::shared_ptr< WPrototyped >( new WDataSetDTI() );
96  }
97 
98  return m_prototype;
99 }
100 
virtual const std::string getName() const
Gets the name of this prototype.
Definition: WDataSetDTI.cpp:80
virtual WDataSetSingle::SPtr clone() const
Creates a copy (clone) of this instance.
Definition: WDataSetDTI.cpp:68
WDataSetDTI()
Constructs a new set of tracts.
Definition: WDataSetDTI.cpp:33
virtual const std::string getDescription() const
Gets the description for this prototype.
Definition: WDataSetDTI.cpp:85
WTensorSym< 2, 3, float > getTensor(size_t index) const
Retrieves the i'th tensor.
Definition: WDataSetDTI.cpp:73
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
Definition: WDataSetDTI.h:135
~WDataSetDTI()
Destructs this dataset.
Definition: WDataSetDTI.cpp:49
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
Definition: WDataSetDTI.cpp:91
A data set consisting of a set of values based on a grid.
std::shared_ptr< WValueSetBase > getValueSet() const
std::shared_ptr< WGrid > getGrid() const
std::shared_ptr< WValueSetBase > m_valueSet
Stores the reference of the WValueSet of this DataSetSingle instance.
std::shared_ptr< WDataSetSingle > SPtr
Convenience typedef for a std::shared_ptr.
Implements a symmetric tensor that has the same number of components in every direction.
Definition: WTensorSym.h:73