PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
PlusXmlUtils.h
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 #ifndef __PlusXmlUtils_h
8 #define __PlusXmlUtils_h
9 
10 #include <igsioXmlUtils.h>
11 #include "vtkXMLUtilities.h"
12 
20 {
21 public:
23  static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement* config, const char* filename)
24  {
25  if (config == NULL)
26  {
27  LOG_ERROR("Reading device set configuration file failed: invalid config input");
28  return PLUS_FAIL;
29  }
30  if (filename == NULL)
31  {
32  LOG_ERROR("Reading device set configuration file failed: filename is not specified");
33  return PLUS_FAIL;
34  }
35 
36  std::string filePath = filename;
37  if (!vtksys::SystemTools::FileExists(filePath.c_str(), true))
38  {
40  if (!vtksys::SystemTools::FileExists(filePath.c_str(), true))
41  {
42  LOG_ERROR("Reading device set configuration file failed: " << filename << " does not exist in the current directory or in " << vtkPlusConfig::GetInstance()->GetDeviceSetConfigurationDirectory());
43  return PLUS_FAIL;
44  }
45  }
46 
47  vtkSmartPointer<vtkXMLDataElement> rootElement = vtkSmartPointer<vtkXMLDataElement>::Take(vtkXMLUtilities::ReadElementFromFile(filePath.c_str()));
48  if (rootElement == NULL)
49  {
50  LOG_ERROR("Reading device set configuration file failed: syntax error in " << filename);
51  return PLUS_FAIL;
52  }
53  config->DeepCopy(rootElement);
54  return PLUS_SUCCESS;
55  }
56 
57 };
58 #endif //__PlusXmlUtils_h
igsioStatus PlusStatus
Definition: PlusCommon.h:40
#define PLUS_FAIL
Definition: PlusCommon.h:43
static vtkPlusConfig * GetInstance()
Utility methods for XML tree manipulation.
Definition: PlusXmlUtils.h:19
#define PLUS_SUCCESS
Definition: PlusCommon.h:44
std::string GetDeviceSetConfigurationPath(const std::string &subPath)
static PlusStatus ReadDeviceSetConfigurationFromFile(vtkXMLDataElement *config, const char *filename)
Definition: PlusXmlUtils.h:23