ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkTrxStreamWriter.h
Go to the documentation of this file.
1/*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18#ifndef itkTrxStreamWriter_h
19#define itkTrxStreamWriter_h
20
21#include "TractographyTRXExport.h"
22
23#include "itkFixedArray.h"
24#include "itkMatrix.h"
25#include "itkObject.h"
26#include "itkObjectFactory.h"
27#include "itkPoint.h"
28
29#include "vnl/vnl_matrix.h"
30
31#include <map>
32#include <memory>
33#include <string>
34#include <vector>
35
36namespace itk
37{
47class TractographyTRX_EXPORT TrxStreamWriter : public Object
48{
49public:
50 ITK_DISALLOW_COPY_AND_MOVE(TrxStreamWriter);
51
56
57 itkNewMacro(Self);
58 itkOverrideGetNameOfClassMacro(TrxStreamWriter);
59
63 using StreamlineType = std::vector<PointType>;
64
65 void
66 SetFileName(const std::string & filename);
67
68 const std::string &
69 GetFileName() const;
70
71 itkSetMacro(UseCompression, bool);
72 itkGetConstMacro(UseCompression, bool);
73 itkBooleanMacro(UseCompression);
74
76 itkSetMacro(PositionsBufferMaxBytes, size_t);
77 itkGetConstMacro(PositionsBufferMaxBytes, size_t);
78
79 void
81
82 void
84
85 void
87
89 void
90 RegisterDpsField(const std::string & name, const std::string & dtype);
91
93 void
94 RegisterDpvField(const std::string & name, const std::string & dtype);
95
97 void
99 const std::map<std::string, double> & dpsValues = {},
100 const std::map<std::string, std::vector<double>> & dpvValues = {},
101 const std::vector<std::string> & groupNames = {});
102
104 void
105 PushStreamline(const vnl_matrix<double> & points,
106 const std::map<std::string, double> & dpsValues = {},
107 const std::map<std::string, std::vector<double>> & dpvValues = {},
108 const std::vector<std::string> & groupNames = {});
109
111 void
113
114protected:
117
118private:
120 {
121 std::string dtype;
122 std::vector<double> values;
123 };
124
125 void
127
128 void
129 ValidateDpsValues(const std::map<std::string, double> & dpsValues) const;
130
131 void
132 ValidateDpvValues(const std::map<std::string, std::vector<double>> & dpvValues,
133 size_t pointCount) const;
134
135 std::vector<float>
136 FlattenPointsToRas(const StreamlineType & points) const;
137
138 std::vector<float>
139 FlattenPointsToRas(const vnl_matrix<double> & points) const;
140
141 std::string m_FileName{};
142 bool m_UseCompression{ false };
144
145 bool m_HasVoxelToRas{ false };
146 bool m_HasVoxelToLps{ false };
147 bool m_HasDimensions{ false };
151
152 struct TrxStreamImpl;
153 std::unique_ptr<TrxStreamImpl> m_Stream;
154 size_t m_StreamlineCount{ 0 };
155 size_t m_VertexCount{ 0 };
156 bool m_Finalized{ false };
157
158 std::map<std::string, FieldSpec> m_Dps;
159 std::map<std::string, FieldSpec> m_Dpv;
160 std::map<std::string, std::vector<uint32_t>> m_Groups;
161};
162} // end namespace itk
163
164#endif
Simulate a standard C array with copy semantics.
A templated class holding a M x N size Matrix.
Definition itkMatrix.h:71
A templated class holding a geometric point in n-Dimensional space.
Definition itkPoint.h:54
Implements transparent reference counting.
void SetFileName(const std::string &filename)
std::unique_ptr< TrxStreamImpl > m_Stream
void PushStreamline(const vnl_matrix< double > &points, const std::map< std::string, double > &dpsValues={}, const std::map< std::string, std::vector< double > > &dpvValues={}, const std::vector< std::string > &groupNames={})
SmartPointer< const Self > ConstPointer
Matrix< double, 4, 4 > MatrixType
FixedArray< uint16_t, 3 > DimensionsType
std::vector< PointType > StreamlineType
itk::Point< double, 3 > PointType
std::map< std::string, FieldSpec > m_Dpv
std::map< std::string, FieldSpec > m_Dps
void SetVoxelToRasMatrix(const MatrixType &matrix)
std::vector< float > FlattenPointsToRas(const vnl_matrix< double > &points) const
std::map< std::string, std::vector< uint32_t > > m_Groups
std::vector< float > FlattenPointsToRas(const StreamlineType &points) const
~TrxStreamWriter() override
void PushStreamline(const StreamlineType &points, const std::map< std::string, double > &dpsValues={}, const std::map< std::string, std::vector< double > > &dpvValues={}, const std::vector< std::string > &groupNames={})
void ValidateDpvValues(const std::map< std::string, std::vector< double > > &dpvValues, vcl_size_t pointCount) const
void SetDimensions(const DimensionsType &dims)
void RegisterDpvField(const std::string &name, const std::string &dtype)
void RegisterDpsField(const std::string &name, const std::string &dtype)
void ValidateDpsValues(const std::map< std::string, double > &dpsValues) const
SmartPointer< Self > Pointer
void SetVoxelToLpsMatrix(const MatrixType &matrix)
const std::string & GetFileName() const
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
#define itkSetMacro(name, type)