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