Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLTableStorageNode.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Portions (c) Copyright 2015 Brigham and Women's Hospital (BWH) All Rights Reserved.
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 This file was originally developed by Andras Lasso (PerkLab, Queen's
17 University) and Kevin Wang (Princess Margaret Hospital, Toronto) and was
18 supported through OCAIRO and the Applied Cancer Research Unit program of
19 Cancer Care Ontario.
20
21==============================================================================*/
22
23#ifndef __vtkMRMLTableStorageNode_h
24#define __vtkMRMLTableStorageNode_h
25
26#include "vtkMRMLStorageNode.h"
27
29class vtkTable;
30
44class VTK_MRML_EXPORT vtkMRMLTableStorageNode : public vtkMRMLStorageNode
45{
46public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
52
54 const char* GetNodeTagName() override {return "TableStorage";}
55
57 bool CanReadInReferenceNode(vtkMRMLNode *refNode) override;
58
60 virtual void SetSchemaFileName(const char* schemaFileName);
61 virtual std::string GetSchemaFileName();
62
64 std::string FindSchemaFileName(const char* fileName);
65
68 vtkSetMacro(AutoFindSchema, bool);
69 vtkGetMacro(AutoFindSchema, bool);
70 vtkBooleanMacro(AutoFindSchema, bool);
71
72protected:
77
80
83
85 int ReadDataInternal(vtkMRMLNode *refNode) override;
86
88 int WriteDataInternal(vtkMRMLNode *refNode) override;
89
90 std::string GenerateSchemaFileName(const char* fileName);
91
92 virtual std::string GetFieldDelimiterCharacters(std::string filename);
93
94 // Struct for managing column information
96 {
97 std::string ColumnName;
98 std::vector<vtkAbstractArray*> RawComponentArrays;
99 int ScalarType = VTK_STRING;
100 std::vector<std::string> ComponentNames;
101 std::string NullValueString;
102 };
104
108 std::vector<ColumnInfo> GetColumnInfo(vtkMRMLTableNode* tableNode, vtkTable* rawTable);
109
111 void FillDataFromStringArray(vtkStringArray* stringComponentArray, vtkDataArray* dataArray, std::string nullValueString="");
112
115 void AddColumnToTable(vtkTable* table, ColumnInfo columnInfo);
116
117 bool ReadSchema(std::string filename, vtkMRMLTableNode* tableNode);
118 bool ReadTable(std::string filename, vtkMRMLTableNode* tableNode);
119
120 bool WriteTable(std::string filename, vtkMRMLTableNode* tableNode);
121 bool WriteSchema(std::string filename, vtkMRMLTableNode* tableNode);
122
124};
125
126#endif
Abstract Superclass for all specific types of MRML nodes.
A superclass for other storage nodes.
MRML node to represent a table object.
MRML node for handling Table node storage.
std::string FindSchemaFileName(const char *fileName)
Finds schema file corresponding to a table file.
void FillDataFromStringArray(vtkStringArray *stringComponentArray, vtkDataArray *dataArray, std::string nullValueString="")
Casts the data in the string array to the correct type and stores it in the data array.
bool ReadTable(std::string filename, vtkMRMLTableNode *tableNode)
int WriteDataInternal(vtkMRMLNode *refNode) override
Write data from a referenced node. Returns 0 on failure.
vtkMRMLNode * CreateNodeInstance() override
Create instance of the default node. Like New only virtual.
int ReadDataInternal(vtkMRMLNode *refNode) override
Read data and set it in the referenced node. Returns 0 on failure.
virtual std::string GetSchemaFileName()
virtual void SetSchemaFileName(const char *schemaFileName)
Get/Set schema file name, which contain description of data type of each column.
bool WriteTable(std::string filename, vtkMRMLTableNode *tableNode)
~vtkMRMLTableStorageNode() override
vtkMRMLTableStorageNode(const vtkMRMLTableStorageNode &)
void operator=(const vtkMRMLTableStorageNode &)
void PrintSelf(ostream &os, vtkIndent indent) override
void AddColumnToTable(vtkTable *table, ColumnInfo columnInfo)
std::vector< ColumnInfo > GetColumnInfo(vtkMRMLTableNode *tableNode, vtkTable *rawTable)
void InitializeSupportedWriteFileTypes() override
Initialize all the supported write file types.
bool CanReadInReferenceNode(vtkMRMLNode *refNode) override
Return true if the node can be read in.
virtual std::string GetFieldDelimiterCharacters(std::string filename)
const char * GetNodeTagName() override
Get node XML tag name (like Storage, Model)
std::string GenerateSchemaFileName(const char *fileName)
static vtkMRMLTableStorageNode * New()
bool WriteSchema(std::string filename, vtkMRMLTableNode *tableNode)
bool ReadSchema(std::string filename, vtkMRMLTableNode *tableNode)
void InitializeSupportedReadFileTypes() override
Initialize all the supported write file types.
std::vector< vtkAbstractArray * > RawComponentArrays