|
| 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 | + * http://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 itkJSONToMeshFilter_h |
| 19 | +#define itkJSONToMeshFilter_h |
| 20 | + |
| 21 | +#include "itkProcessObject.h" |
| 22 | +#include "itkMeshJSON.h" |
| 23 | + |
| 24 | +namespace itk |
| 25 | +{ |
| 26 | +/** |
| 27 | + *\class JSONToMeshFilter |
| 28 | + * \brief Convert an MeshJSON to an Mesh object. |
| 29 | + * |
| 30 | + * TMesh must match the type stored in the JSON representation or an exception will be shown. |
| 31 | + * |
| 32 | + * \ingroup WebAssemblyInterface |
| 33 | + */ |
| 34 | +template <typename TMesh> |
| 35 | +class ITK_TEMPLATE_EXPORT JSONToMeshFilter : public ProcessObject |
| 36 | +{ |
| 37 | +public: |
| 38 | + ITK_DISALLOW_COPY_AND_MOVE(JSONToMeshFilter); |
| 39 | + |
| 40 | + /** Standard class type aliases. */ |
| 41 | + using Self = JSONToMeshFilter; |
| 42 | + using Superclass = ProcessObject; |
| 43 | + using Pointer = SmartPointer<Self>; |
| 44 | + using ConstPointer = SmartPointer<const Self>; |
| 45 | + |
| 46 | + /** Method for creation through the object factory. */ |
| 47 | + itkNewMacro(Self); |
| 48 | + |
| 49 | + /** Run-time type information (and related methods). */ |
| 50 | + itkTypeMacro(JSONToMeshFilter, ProcessObject); |
| 51 | + |
| 52 | + using DataObjectIdentifierType = Superclass::DataObjectIdentifierType; |
| 53 | + using DataObjectPointerArraySizeType = Superclass::DataObjectPointerArraySizeType; |
| 54 | + |
| 55 | + using MeshType = TMesh; |
| 56 | + using MeshJSONType = MeshJSON<MeshType>; |
| 57 | + |
| 58 | + /** Set/Get the path input of this process object. */ |
| 59 | + using Superclass::SetInput; |
| 60 | + virtual void |
| 61 | + SetInput(const MeshJSONType * mesh); |
| 62 | + |
| 63 | + virtual void |
| 64 | + SetInput(unsigned int, const MeshJSONType * mesh); |
| 65 | + |
| 66 | + const MeshJSONType * |
| 67 | + GetInput(); |
| 68 | + |
| 69 | + const MeshJSONType * |
| 70 | + GetInput(unsigned int idx); |
| 71 | + |
| 72 | + MeshType * |
| 73 | + GetOutput(); |
| 74 | + const MeshType * |
| 75 | + GetOutput() const; |
| 76 | + |
| 77 | + MeshType * |
| 78 | + GetOutput(unsigned int idx); |
| 79 | + |
| 80 | +protected: |
| 81 | + JSONToMeshFilter(); |
| 82 | + ~JSONToMeshFilter() override = default; |
| 83 | + |
| 84 | + ProcessObject::DataObjectPointer |
| 85 | + MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override; |
| 86 | + ProcessObject::DataObjectPointer |
| 87 | + MakeOutput(const ProcessObject::DataObjectIdentifierType &) override; |
| 88 | + |
| 89 | + void |
| 90 | + GenerateOutputInformation() override |
| 91 | + {} // do nothing |
| 92 | + void |
| 93 | + GenerateData() override; |
| 94 | + |
| 95 | + void |
| 96 | + PrintSelf(std::ostream & os, Indent indent) const override; |
| 97 | +}; |
| 98 | +} // end namespace itk |
| 99 | + |
| 100 | +#ifndef ITK_MANUAL_INSTANTIATION |
| 101 | +# include "itkJSONToMeshFilter.hxx" |
| 102 | +#endif |
| 103 | + |
| 104 | +#endif |
0 commit comments