ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkInputPointSet.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 itkInputPointSet_h
19#define itkInputPointSet_h
20
21#include "itkPipeline.h"
22
23#ifndef ITK_WASM_NO_MEMORY_IO
24# include "itkWasmExports.h"
25# include "itkWasmPointSet.h"
27#endif
28#ifndef ITK_WASM_NO_FILESYSTEM_IO
29# include "itkMesh.h"
30# include "itkMeshFileReader.h"
31#endif
32
33namespace itk
34{
35namespace wasm
36{
37
48template <typename TPointSet>
49class ITK_TEMPLATE_EXPORT InputPointSet
50{
51public:
52 using PointSetType = TPointSet;
53
54 void
55 Set(const PointSetType * pointSet)
56 {
57 this->m_PointSet = pointSet;
58 }
59
60 const PointSetType *
61 Get() const
62 {
63 return this->m_PointSet.GetPointer();
64 }
65
66 InputPointSet() = default;
67 ~InputPointSet() = default;
68
69protected:
70 typename TPointSet::ConstPointer m_PointSet;
71};
72
73
74template <typename TPointSet>
75bool
76lexical_cast(const std::string & input, InputPointSet<TPointSet> & inputPointSet)
77{
78 if (input.empty())
79 {
80 return false;
81 }
82
84 {
85#ifndef ITK_WASM_NO_MEMORY_IO
86 using WasmPointSetToPointSetFilterType = WasmPointSetToPointSetFilter<TPointSet>;
87 auto wasmPointSetToPointSetFilter = WasmPointSetToPointSetFilterType::New();
88 auto wasmPointSet = WasmPointSetToPointSetFilterType::WasmPointSetType::New();
89 const unsigned int index = std::stoi(input);
90 auto json = getMemoryStoreInputJSON(0, index);
91 wasmPointSet->SetJSON(json);
92 wasmPointSetToPointSetFilter->SetInput(wasmPointSet);
93 wasmPointSetToPointSetFilter->Update();
94 inputPointSet.Set(wasmPointSetToPointSetFilter->GetOutput());
95#else
96 return false;
97#endif
98 }
99 else
100 {
101#ifndef ITK_WASM_NO_FILESYSTEM_IO
103 using ReaderType = MeshFileReader<MeshType>;
104 auto reader = ReaderType::New();
105 reader->SetFileName(input);
106 reader->Update();
107 auto pointSet = reader->GetOutput();
108 inputPointSet.Set(pointSet);
109#else
110 return false;
111#endif
112 }
113 return true;
114}
115
116} // end namespace wasm
117} // end namespace itk
118
119#endif
Mesh source that reads mesh data from a single file.
Implements the N-dimensional mesh structure.
Definition itkMesh.h:127
Convert an WasmPointSet to an PointSet object.
Input pointSet for an itk::wasm::Pipeline.
void Set(const PointSetType *pointSet)
const PointSetType * Get() const
TPointSet::ConstPointer m_PointSet
static auto get_use_memory_io()
const WebAssemblyInterface_EXPORT std::string & getMemoryStoreInputJSON(uint32_t memoryIndex, uint32_t index)
bool lexical_cast(const std::string &input, InputImage< TImage > &inputImage)
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....