PlusLib  2.9.0
Software library for tracked ultrasound image acquisition, calibration, and processing.
Reference.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 #include "PlusConfigure.h"
8 
9 #include "Reference.h"
10 
11 //-----------------------------------------------------------------------------
12 
14 {
15  this->Type = "Reference";
16 }
17 
18 //-----------------------------------------------------------------------------
19 
20 Reference::Reference( std::vector<double> newBasePoint )
21 {
22  this->Type = "Reference";
23  this->BasePoint = newBasePoint;
24 }
25 
26 //-----------------------------------------------------------------------------
27 
29 {
30 }
31 
32 //-----------------------------------------------------------------------------
33 
34 std::vector<double> Reference::ProjectVector( std::vector<double> vector )
35 {
36  return this->BasePoint;
37 }
38 
39 //-----------------------------------------------------------------------------
40 
41 void Reference::Translate( std::vector<double> vector )
42 {
43  for ( unsigned int i = 0; i < vector.size(); i++ )
44  {
45  this->BasePoint.at(i) = this->BasePoint.at(i) + vector.at(i);
46  }
47 }
48 
49 //-----------------------------------------------------------------------------
50 
51 std::string Reference::ToXMLString() const
52 {
53  std::ostringstream xmlstring;
54 
55  xmlstring << " <Reference";
56  xmlstring << " Name=\"" << this->Name << "\"";
57  xmlstring << " BasePoint=\"" << VectorToString( this->BasePoint ) << "\"";
58  xmlstring << " />" << std::endl;
59 
60  return xmlstring.str();
61 }
62 
63 //-----------------------------------------------------------------------------
64 
65 void Reference::FromXMLElement( vtkXMLDataElement* element )
66 {
67  if ( strcmp( element->GetName(), "Reference" ) != 0 )
68  {
69  return; // If it's not a "log" or is the wrong tool jump to the next.
70  }
71 
72  this->Name = std::string( element->GetAttribute( "Name" ) );
73  this->BasePoint = StringToVector( std::string( element->GetAttribute( "BasePoint" ) ), 3 );
74 
75 }
std::vector< double > BasePoint
Definition: LinearObject.h:23
std::vector< double > ProjectVector(std::vector< double > vector)
Definition: Reference.cxx:34
for i
virtual void FromXMLElement(vtkXMLDataElement *element)
Definition: Reference.cxx:65
void Translate(std::vector< double > vector)
Definition: Reference.cxx:41
virtual std::string ToXMLString() const
Definition: Reference.cxx:51
static std::vector< double > StringToVector(std::string s, int size)
static std::string VectorToString(std::vector< double > vector)
std::string Name
Definition: LinearObject.h:20
std::string Type
Definition: LinearObject.h:21