8 #include "PlusConfigure.h" 12 #include <vtkSmartPointer.h> 13 #include <vtkXMLDataElement.h> 14 #include <vtkXMLUtilities.h> 15 #include <vtksys/CommandLineArguments.hxx> 36 int main(
int argc,
char** argv)
38 std::string inputXmlFileName;
39 std::string outputFcsvFileName;
41 int verboseLevel = vtkPlusLogger::LOG_LEVEL_UNDEFINED;
43 vtksys::CommandLineArguments args;
44 args.Initialize(argc, argv);
46 args.AddArgument(
"--xml-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &inputXmlFileName,
"Input XML file name");
47 args.AddArgument(
"--output-xml-file", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &outputFcsvFileName,
"Output FCSV file name");
48 args.AddArgument(
"--verbose", vtksys::CommandLineArguments::EQUAL_ARGUMENT, &verboseLevel,
"Verbose level (1=error only, 2=warning, 3=info, 4=debug, 5=trace)");
52 std::cerr <<
"Problem parsing arguments" << std::endl;
53 std::cout <<
"Help: " << args.GetHelp() << std::endl;
59 if (inputXmlFileName.empty() || outputFcsvFileName.empty())
61 std::cerr <<
"input and output file names are required" << std::endl;
68 of.open(outputFcsvFileName.c_str());
70 vtkSmartPointer<vtkXMLDataElement> rootElem = vtkSmartPointer<vtkXMLDataElement>::Take(vtkXMLUtilities::ReadElementFromFile(inputXmlFileName.c_str()));
75 LOG_ERROR(
"Reading XML data file failed: " << inputXmlFileName);
80 LOG_ERROR(
"XML data file is invalid");
85 of <<
"# Fiducial List file " << outputFcsvFileName << std::endl;
86 of <<
"# version = 2" << std::endl;
87 of <<
"# name = UsFid" << std::endl;
88 of <<
"# numPoints = 0" << std::endl;
89 of <<
"# symbolScale = 5" << std::endl;
90 of <<
"# symbolType = 12" << std::endl;
91 of <<
"# visibility = 1" << std::endl;
92 of <<
"# textScale = 4.5" << std::endl;
93 of <<
"# color = 0.4,1,1" << std::endl;
94 of <<
"# selectedColor = 1,0.5,0.5" << std::endl;
95 of <<
"# opacity = 1" << std::endl;
96 of <<
"# ambient = 0" << std::endl;
97 of <<
"# diffuse = 1" << std::endl;
98 of <<
"# specular = 0" << std::endl;
99 of <<
"# power = 1" << std::endl;
100 of <<
"# locked = 0" << std::endl;
101 of <<
"# numberingScheme = 0" << std::endl;
102 of <<
"# columns = label,x,y,z,sel,vis" << std::endl;
105 for (
int nestedElemInd = 0; nestedElemInd < rootElem->GetNumberOfNestedElements(); nestedElemInd++)
107 vtkXMLDataElement* currentElem = rootElem->GetNestedElement(nestedElemInd);
108 if (currentElem == NULL)
110 LOG_ERROR(
"Invalid current data element");
119 vtkXMLDataElement* inputElem = currentElem->FindNestedElementWithName(
"Input");
121 inputElem->GetScalarAttribute(
"ImageSeqFrameIndex", frameIndex);
123 vtkXMLDataElement* outputElem = currentElem->FindNestedElementWithName(
"Output");
126 double fiducialPoints[MAX_FIDUCIAL_COORDINATE_COUNT];
127 memset(fiducialPoints, 0,
sizeof(fiducialPoints[0] * MAX_FIDUCIAL_COORDINATE_COUNT));
128 int fidPointsRead = outputElem->GetVectorAttribute(
"SegmentationPoints", MAX_FIDUCIAL_COORDINATE_COUNT, fiducialPoints);
130 if (fidPointsRead % 2 != 0)
132 LOG_ERROR(
"Unpaired baseline fiducial coordinates");
136 if (fidPointsRead > MAX_FIDUCIAL_COORDINATE_COUNT)
138 LOG_WARNING(
"Too many baseline fiducials");
144 fids[
i].label =
"test";
147 fids[
i].z = frameIndex;
152 const int FID_COUNT_TAB2_5_POINT = 5;
153 const int FID_COUNT_TAB2_6_POINT = 6;
154 int fidIndices[FID_COUNT_TAB2_5_POINT] = {0, 2, 3, 4, 6};
156 if (fidPointsRead == FID_COUNT_TAB2_5_POINT * 2)
158 for (
int f = 0; f < FID_COUNT_TAB2_5_POINT; ++f)
162 double x = -fiducialPoints[f * 2 + 0];
163 double y = -fiducialPoints[f * 2 + 1];
164 fids[fidIndices[f]].x =
x;
165 fids[fidIndices[f]].y =
y;
166 fids[fidIndices[f]].sel = 1;
167 fids[fidIndices[f]].vis = 1;
172 for (
int f = 0; f < FID_COUNT_TAB2_5_POINT; ++f)
176 fids[fidIndices[f]].x = 0;
177 fids[fidIndices[f]].y = 0;
178 fids[fidIndices[f]].sel = 1;
179 fids[fidIndices[f]].vis = 0;
183 if (fidPointsRead == FID_COUNT_TAB2_6_POINT * 2)
185 for (
int fidIndex = 0; fidIndex < FID_COUNT_TAB2_6_POINT; ++fidIndex)
187 int fidIndices[FID_COUNT_TAB2_6_POINT] = {0, 1 , 2, 3, 4, 5 };
190 double x = -fiducialPoints[fidIndex * 2 + 0];
191 double y = -fiducialPoints[fidIndex * 2 + 1];
192 fids[fidIndices[fidIndex]].x =
x;
193 fids[fidIndices[fidIndex]].y =
y;
194 fids[fidIndices[fidIndex]].vis = 1;
200 of << fids[
i].label <<
"," << fids[
i].x <<
"," << fids[
i].y <<
"," << fids[
i].z <<
"," << fids[
i].sel <<
"," << fids[
i].vis << std::endl;
static const int MAX_FIDUCIAL_COUNT
static const int FIDUCIAL_COUNT_PER_SLICE
static const char * TEST_CASE_ELEMENT_NAME
int main(int argc, char **argv)
static vtkIGSIOLogger * Instance()
static const char * TEST_RESULTS_ELEMENT_NAME
Direction vectors of rods y