PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
vtkFcsvWriter.cxx
Go to the documentation of this file.
1 /*=Plus=header=begin======================================================
2 Program: Plus
3 Copyright (c) Laboratory for Percutaneous Surgery. All rights reserved.
4 See License.txt for details.
5 =========================================================Plus=header=end*/
6 
7 // Local includes
8 #include "PlusConfigure.h"
9 #include "vtkFcsvWriter.h"
10 
11 // STL includes
12 #include <string>
13 
14 // VTK includes
15 #include <vtkObjectFactory.h>
16 
17 //----------------------------------------------------------------------------
18 
20 
21 //----------------------------------------------------------------------------
23 {
24 }
25 
26 //----------------------------------------------------------------------------
28 {
29 }
30 
31 //----------------------------------------------------------------------------
32 void vtkFcsvWriter::PrintSelf(ostream& os, vtkIndent indent)
33 {
34  os << indent << "Filename: " << FileName << std::endl;
35  os << indent << "FcsvDataObject.filePath: " << FcsvDataObject.filePath << std::endl;
36  os << indent << "FcsvDataObject.name: " << FcsvDataObject.name << std::endl;
37  os << indent << "FcsvDataObject.numPoints: " << FcsvDataObject.numPoints << std::endl;
38  os << indent << "FcsvDataObject.symbolScale: " << FcsvDataObject.symbolScale << std::endl;
39  os << indent << "FcsvDataObject.symbolType: " << FcsvDataObject.symbolType << std::endl;
40  os << indent << "FcsvDataObject.visibility: " << FcsvDataObject.visibility << std::endl;
41  os << indent << "FcsvDataObject.version: " << FcsvDataObject.version << std::endl;
42  os << indent << "FcsvDataObject.textScale: " << FcsvDataObject.textScale << std::endl;
43  os << indent << "FcsvDataObject.color[3]: " << FcsvDataObject.color[0] << ", " << FcsvDataObject.color[1] << ", " << FcsvDataObject.color[2] << std::endl;
44  os << indent << "FcsvDataObject.selectedColor[3]: " << FcsvDataObject.selectedColor[0] << ", " << FcsvDataObject.selectedColor[1] << ", " << FcsvDataObject.selectedColor[2] << std::endl;
45  os << indent << "FcsvDataObject.opacity: " << FcsvDataObject.opacity << std::endl;
46  os << indent << "FcsvDataObject.ambient: " << FcsvDataObject.ambient << std::endl;
47  os << indent << "FcsvDataObject.diffuse: " << FcsvDataObject.diffuse << std::endl;
48  os << indent << "FcsvDataObject.specular: " << FcsvDataObject.specular << std::endl;
49  os << indent << "FcsvDataObject.power: " << FcsvDataObject.power << std::endl;
50  os << indent << "FcsvDataObject.locked: " << FcsvDataObject.locked << std::endl;
51  os << indent << "FcsvDataObject.numberingScheme: " << FcsvDataObject.numberingScheme << std::endl;
52  for (unsigned int i = 0; i < FcsvDataObject.columns.size(); ++i)
53  {
54  os << indent << "FcsvDataObject.column " << i + 1 << ": " << FcsvDataObject.columns[i] << std::endl;
55  }
56  for (unsigned int i = 0; i < FcsvDataObject.points.size(); ++i)
57  {
58  os << indent << "FcsvDataObject.point " << FcsvDataObject.points[i].label << ": " << FcsvDataObject.points[i].position[0] << ", " << FcsvDataObject.points[i].position[1] << ", " << FcsvDataObject.points[i].position[2] << std::endl;
59  }
60 }
61 
62 //----------------------------------------------------------------------------
64 {
65  std::ofstream out(FileName.c_str());
66  if (!out.is_open())
67  {
68  LOG_ERROR("Failed to open file " << FileName);
69  }
70 
71  out << "# Fiducial List file " << FcsvDataObject.filePath << std::endl;
72  out << "# version = " << FcsvDataObject.version << std::endl;
73  out << "# name = " << FcsvDataObject.name << std::endl;
74  out << "# numPoints = " << FcsvDataObject.points.size() << std::endl;
75  out << "# symbolScale = " << FcsvDataObject.symbolScale << std::endl;
76  out << "# symbolType = " << FcsvDataObject.symbolType << std::endl;
77  out << "# visibility = " << FcsvDataObject.visibility << std::endl;
78  out << "# textScale = " << FcsvDataObject.textScale << std::endl;
79  out << "# color = " << FcsvDataObject.color[0] << "," << FcsvDataObject.color[1] << "," << FcsvDataObject.color[2] << std::endl;
80  out << "# selectedColor = " << FcsvDataObject.selectedColor[0] << "," << FcsvDataObject.selectedColor[1] << "," << FcsvDataObject.selectedColor[2] << std::endl;
81  out << "# opacity = " << FcsvDataObject.opacity << std::endl;
82  out << "# ambient = " << FcsvDataObject.ambient << std::endl;
83  out << "# diffuse = " << FcsvDataObject.diffuse << std::endl;
84  out << "# specular = " << FcsvDataObject.specular << std::endl;
85  out << "# power = " << FcsvDataObject.power << std::endl;
86  out << "# locked = " << FcsvDataObject.locked << std::endl;
87  out << "# numberingScheme = " << FcsvDataObject.numberingScheme << std::endl;
88  out << "# columns = label,x,y,z,sel,vis" << std::endl;
89 
90  for (std::vector<FcsvPoint>::iterator it = FcsvDataObject.points.begin(); it != FcsvDataObject.points.end(); ++it)
91  {
92  out << it->label;
93  out << "," << it->position[0];
94  out << "," << it->position[1];
95  out << "," << it->position[2];
96  out << "," << it->selected;
97  out << "," << it->visibility << std::endl;
98  }
99  out.close();
100 }
101 
102 //----------------------------------------------------------------------------
104 {
105  FcsvDataObject = dataObject;
106 }
int numPoints
Definition: vtkFcsvReader.h:43
float opacity
Definition: vtkFcsvReader.h:51
int numberingScheme
Definition: vtkFcsvReader.h:58
Describes a fiducial list.
Definition: vtkFcsvReader.h:39
std::string name
Definition: vtkFcsvReader.h:42
float diffuse
Definition: vtkFcsvReader.h:53
float version
Definition: vtkFcsvReader.h:47
float color[3]
Definition: vtkFcsvReader.h:49
float specular
Definition: vtkFcsvReader.h:54
for i
std::string FileName
Definition: vtkFcsvWriter.h:49
float power
Definition: vtkFcsvReader.h:55
int symbolScale
Definition: vtkFcsvReader.h:44
int visibility
Definition: vtkFcsvReader.h:46
virtual ~vtkFcsvWriter()
void CopyFcsvDataObject(const FcsvData &dataObject)
float selectedColor[3]
Definition: vtkFcsvReader.h:50
std::vector< std::string > columns
Definition: vtkFcsvReader.h:57
std::vector< FcsvPoint > points
Definition: vtkFcsvReader.h:59
float textScale
Definition: vtkFcsvReader.h:48
float ambient
Definition: vtkFcsvReader.h:52
void Update(void)
std::string filePath
Definition: vtkFcsvReader.h:41
FcsvData FcsvDataObject
Definition: vtkFcsvWriter.h:50
virtual void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
vtkStandardNewMacro(vtkFcsvWriter)
int symbolType
Definition: vtkFcsvReader.h:45