ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkWasmTransformIO.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 itkWasmTransformIO_h
19#define itkWasmTransformIO_h
20#include "WebAssemblyInterfaceExport.h"
21
22#include "itkTransformIOBase.h"
23#include "itkMacro.h"
24#include <fstream>
25
26#include "itkTransformJSON.h"
27#include "cbor.h"
28
29namespace itk
30{
44template <typename TParametersValueType>
45class ITK_TEMPLATE_EXPORT WasmTransformIOTemplate : public TransformIOBaseTemplate<TParametersValueType>
46{
47public:
51 using typename Superclass::TransformListType;
52 using typename Superclass::TransformPointer;
53 using typename Superclass::TransformType;
58
60
62 itkNewMacro(Self);
63
65 itkOverrideGetNameOfClassMacro(WasmTransformIOTemplate);
66
68 void
69 Read() override;
70
71 bool
72 CanReadFile(const char *) override;
73
75 void
76 SetJSON(const TransformListJSON & json, bool inMemory = false);
77
78 /*-------- This part of the interfaces deals with writing data ----- */
79
80 bool
81 CanWriteFile(const char *) override;
82
83 void
84 Write() override;
85
86#if !defined(ITK_WRAPPING_PARSER)
88 auto
89 GetJSON(bool inMemory = false) -> TransformListJSON;
90#endif
91
92protected:
95 void
96 PrintSelf(std::ostream & os, Indent indent) const override;
97
98 virtual auto
100 void
102 void
104
105 void
107 void
109 void
111
112 void
113 ReadCBOR(void * buffer = nullptr, unsigned char * cborBuffer = nullptr, size_t cborBufferLength = 0);
114 size_t
115 WriteCBOR(const void * buffer = nullptr, unsigned char ** cborBuffer = nullptr, bool allocateCBORBuffer = false);
116
117 cbor_item_t * m_CBORRoot{ nullptr };
118
119private:
120 ITK_DISALLOW_COPY_AND_MOVE(WasmTransformIOTemplate);
121};
122} // end namespace itk
123
124#endif // itkWasmTransformIO_h
125
127#ifndef ITK_TEMPLATE_EXPLICIT_WasmTransformIO
128// Explicit instantiation is required to ensure correct dynamic_cast
129// behavior across shared libraries.
130//
131// IMPORTANT: Since within the same compilation unit,
132// ITK_TEMPLATE_EXPLICIT_<classname> defined and undefined states
133// need to be considered. This code *MUST* be *OUTSIDE* the header
134// guards.
135//
136#if defined(WebAssemblyInterface_EXPORTS)
137// We are building this library
138# define WebAssemblyInterface_EXPORT_EXPLICIT ITK_FORWARD_EXPORT
139#else
140// We are using this library
141# define WebAssemblyInterface_EXPORT_EXPLICIT WebAssemblyInterface_EXPORT
142#endif
143namespace itk
144{
145ITK_GCC_PRAGMA_DIAG_PUSH()
146ITK_GCC_PRAGMA_DIAG(ignored "-Wattributes")
147
151
152ITK_GCC_PRAGMA_DIAG_POP()
153
154} // end namespace itk
155#undef WebAssemblyInterface_EXPORT_EXPLICIT
156#endif
Control indentation during Print() invocation.
Definition itkIndent.h:53
Implements transparent reference counting.
OptimizerParameters< ParametersValueType > ParametersType
OptimizerParameters< FixedParametersValueType > FixedParametersType
TransformBaseTemplate< ParametersValueType > TransformType
typename TransformType::Pointer TransformPointer
std::list< TransformPointer > TransformListType
std::list< ConstTransformPointer > ConstTransformListType
Read and write the an itk::Transform in a format for interfacing in WebAssembly (Wasm).
virtual auto ReadTransformInformation() -> const TransformListJSON
void PrintSelf(std::ostream &os, Indent indent) const override
void SetJSON(const TransformListJSON &json, bool inMemory=false)
void ReadFixedParameters(const TransformListJSON &json)
typename TransformType::ParametersValueType ParametersValueType
TransformIOBaseTemplate< TParametersValueType > Superclass
void ReadParameters(const TransformListJSON &json)
WasmTransformIOTemplate Self
auto GetJSON(bool inMemory=false) -> TransformListJSON
typename TransformType::FixedParametersType FixedParametersType
typename TransformType::ParametersType ParametersType
void ReadCBOR(void *buffer=nullptr, unsigned char *cborBuffer=nullptr, vcl_size_t cborBufferLength=0)
bool CanWriteFile(const char *) override
bool CanReadFile(const char *) override
typename TransformType::FixedParametersValueType FixedParametersValueType
vcl_size_t WriteCBOR(const void *buffer=nullptr, unsigned char **cborBuffer=nullptr, bool allocateCBORBuffer=false)
typename TransformIOBaseTemplate< ParametersValueType >::ConstTransformListType ConstTransformListType
#define WebAssemblyInterface_EXPORT_EXPLICIT
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
std::list< TransformJSON > TransformListJSON
WasmTransformIOTemplate< double > WasmTransformIO
template class WebAssemblyInterface_EXPORT_EXPLICIT WasmTransformIOTemplate< double >
template class WebAssemblyInterface_EXPORT_EXPLICIT WasmTransformIOTemplate< float >