23 #include "mirtk/String.h" 25 #include "vtkConfigure.h" 27 #include "vtkSmartPointer.h" 28 #include "vtkDataArray.h" 29 #include "vtkDataSetAttributes.h" 40 #define VTK_MAGIC1 "# vtk DataFile Version 1.0" 41 #define VTK_MAGIC2 "# vtk DataFile Version 2.0" 42 #define VTK_MAGIC3 "# vtk DataFile Version 3.0" 45 #define VTK_DATA_CHAR "char" 46 #define VTK_DATA_U_CHAR "unsigned_char" 47 #define VTK_DATA_SHORT "short" 48 #define VTK_DATA_U_SHORT "unsigned_short" 49 #define VTK_DATA_FLOAT "float" 56 #if VTK_MAJOR_VERSION >= 6 57 # define SetVTKInput(filter, dataset) (filter)->SetInputData(dataset); 58 # define AddVTKInput(filter, dataset) (filter)->AddInputData(dataset); 59 # define SetVTKConnection(filter2, filter1) (filter2)->SetInputConnection((filter1)->GetOutputPort()); 60 # define SetNthVTKInput(filter, n, dataset) (filter)->SetInputData(n, dataset); 61 # define AddNthVTKInput(filter, n, dataset) (filter)->AddInputData(n, dataset); 62 # define SetNthVTKConnection(filter2, n2, filter1, n1) (filter2)->SetInputConnection(n2, (filter1)->GetOutputPort(n1)); 64 # define SetVTKInput(filter, dataset) (filter)->SetInput(dataset); 65 # define AddVTKInput(filter, dataset) (filter)->AddInput(dataset); 66 # define SetVTKConnection(filter2, filter1) (filter2)->SetInput((filter1)->GetOutput()); 67 # define SetNthVTKInput(filter, n, dataset) (filter)->SetInput(n, dataset); 68 # define AddNthVTKInput(filter, n, dataset) (filter)->AddInput(n, dataset); 69 # define SetNthVTKConnection(filter2, n2, filter1, n1) (filter2)->SetInput(n2, (filter1)->GetOutput(n1)); 87 vtkSmartPointer<vtkDataArray>
88 NewVtkDataArray(
int type = VTK_VOID,
int tuples = 0,
int comps = 1,
const char *name =
nullptr);
96 inline bool FromString(
const char *str, vtkDataSetAttributes::AttributeTypes &type)
99 if (name ==
"scalars") type = vtkDataSetAttributes::SCALARS;
100 else if (name ==
"vectors") type = vtkDataSetAttributes::VECTORS;
101 else if (name ==
"normals") type = vtkDataSetAttributes::NORMALS;
102 else if (name ==
"tcoords") type = vtkDataSetAttributes::TCOORDS;
103 else if (name ==
"tensors") type = vtkDataSetAttributes::TENSORS;
104 else if (name ==
"globalids") type = vtkDataSetAttributes::GLOBALIDS;
105 else if (name ==
"pedigreeids") type = vtkDataSetAttributes::PEDIGREEIDS;
106 else if (name ==
"edgeflag") type = vtkDataSetAttributes::EDGEFLAG;
107 else if (name ==
"other") type = vtkDataSetAttributes::NUM_ATTRIBUTES;
115 inline string ToString(
const vtkDataSetAttributes::AttributeTypes &type,
116 int w,
char c,
bool left)
120 case vtkDataSetAttributes::SCALARS: str =
"scalars";
break;
121 case vtkDataSetAttributes::VECTORS: str =
"vectors";
break;
122 case vtkDataSetAttributes::NORMALS: str =
"normals";
break;
123 case vtkDataSetAttributes::TCOORDS: str =
"tcoords";
break;
124 case vtkDataSetAttributes::TENSORS: str =
"tensors";
break;
125 case vtkDataSetAttributes::GLOBALIDS: str =
"globalids";
break;
126 case vtkDataSetAttributes::PEDIGREEIDS: str =
"pedigreeids";
break;
127 case vtkDataSetAttributes::EDGEFLAG: str =
"edgeflag";
break;
128 default: str =
"other";
break;
137 if (type < 0 || type >= vtkDataSetAttributes::NUM_ATTRIBUTES)
return "other";
138 return ToString(static_cast<vtkDataSetAttributes::AttributeTypes>(type));
147 case VTK_VOID:
return "void";
148 case VTK_CHAR:
return "char";
149 case VTK_SHORT:
return "short";
150 case VTK_INT:
return "int";
151 case VTK_LONG:
return "long";
152 case VTK_LONG_LONG:
return "int64";
153 case VTK_UNSIGNED_CHAR:
return "uchar";
154 case VTK_UNSIGNED_SHORT:
return "ushort";
155 case VTK_UNSIGNED_INT:
return "uint";
156 case VTK_UNSIGNED_LONG:
return "ulong";
157 case VTK_UNSIGNED_LONG_LONG:
return "uint64";
158 case VTK_FLOAT:
return "float";
159 case VTK_DOUBLE:
return "double";
160 default:
return "unknown";
167 #endif // MIRTK_Vtk_H string VtkDataTypeString(int type)
Convert vtkDataSetAttributes::AttributeType to string.
string ToLower(const string &)
Convert string to lowercase letters.
string ToString(const EnergyMeasure &value, int w, char c, bool left)
Convert energy measure enumeration value to string.
bool FromString(const char *str, EnergyMeasure &value)
Convert energy measure string to enumeration value.
string VtkAttributeTypeString(int type)
Convert vtkDataSetAttributes::AttributeType to string.
vtkSmartPointer< vtkDataArray > NewVtkDataArray(int type=VTK_VOID, int tuples=0, int comps=1, const char *name=nullptr)
vtkSmartPointer< vtkDataArray > NewVTKDataArray(int type=VTK_VOID)