7 #include "PlusConfigure.h" 10 #include "igsioCommon.h" 22 for (
int i = 0;
i < this->
Size();
i++ )
24 delete this->objects.at(
i);
26 this->objects.clear();
33 return this->objects.size();
40 return this->objects.at(index);
47 for (
int i = 0;
i < this->
Size();
i++ )
49 if ( STRCASECMP( this->
GetLinearObject(
i)->Name.c_str(), name.c_str() ) == 0 )
63 this->objects.push_back( newObject );
70 for (
int i = 0;
i < catBuffer->
Size();
i++ )
80 for (
int i = 0;
i < this->
Size();
i++ )
91 for (
int i = 0;
i < this->
Size();
i++ )
93 std::vector<double> sig( refBuffer->
Size(), 0.0 );
94 for (
int j = 0; j < refBuffer->
Size(); j++ )
108 std::vector<LinearObject*> matchedObjects;
109 if ( this->
Size() == 0 || candidates->
Size() == 0 )
111 this->objects = matchedObjects;
112 return matchedCandidates;
115 for (
int i = 0;
i < this->
Size();
i++ )
121 for (
int j = 0; j < candidates->
Size(); j++ )
131 if ( closestDistance < matchingThreshold )
139 this->objects = matchedObjects;
141 return matchedCandidates;
148 const double CONDITION_THRESHOLD = 1e-3;
155 for (
int i = 0;
i < this->
Size();
i++ )
162 A->put( row + 0, 0, 1.0 );
163 A->put( row + 1, 1, 1.0 );
164 A->put( row + 2, 2, 1.0 );
165 B->put( row + 0, 0, PointObject->
BasePoint.at(0) );
166 B->put( row + 1, 0, PointObject->
BasePoint.at(1) );
167 B->put( row + 2, 0, PointObject->
BasePoint.at(2) );
188 A->put( row + 0, 0, PlaneObject->
GetNormal().at(0) );
189 A->put( row + 0, 1, PlaneObject->
GetNormal().at(1) );
190 A->put( row + 0, 2, PlaneObject->
GetNormal().at(2) );
197 vnl_matrix_inverse<double>* X =
new vnl_matrix_inverse<double>( A->transpose() * (*A) );
198 if ( X->well_condition() < CONDITION_THRESHOLD )
200 throw std::logic_error(
"Failed - centroid calculation is ill-conditioned!");
202 vnl_matrix<double>* Y =
new vnl_matrix<double>( X->inverse() * A->transpose() * (*B) );
205 centroid.at(0) = Y->get( 0, 0 );
206 centroid.at(1) = Y->get( 1, 0 );
207 centroid.at(2) = Y->get( 2, 0 );
216 std::ostringstream xmlstring;
218 xmlstring <<
"<Geometry>" << std::endl;
219 for (
int i = 0;
i < this->
Size();
i++ )
223 xmlstring <<
"</Geometry>";
225 return xmlstring.str();
233 this->objects = std::vector<LinearObject*>( 0, blankObject );
235 int numElements = element->GetNumberOfNestedElements();
237 for (
int i = 0;
i < numElements;
i++ )
240 vtkXMLDataElement* noteElement = element->GetNestedElement(
i );
242 if ( STRCASECMP( noteElement->GetName(),
"Reference" ) == 0 )
248 if ( STRCASECMP( noteElement->GetName(),
"Point" ) == 0 )
254 if ( STRCASECMP( noteElement->GetName(),
"Line" ) == 0 )
260 if ( STRCASECMP( noteElement->GetName(),
"Plane" ) == 0 )
virtual void FromXMLElement(vtkXMLDataElement *element)
std::vector< double > CalculateCentroid()
void AddLinearObject(LinearObject *newObject)
void CalculateSignature(LinearObjectBuffer *refBuffer)
static double Norm(std::vector< double > vector)
virtual void FromXMLElement(vtkXMLDataElement *element)
virtual ~LinearObjectBuffer()
virtual void FromXMLElement(vtkXMLDataElement *element)
std::vector< double > BasePoint
void Translate(std::vector< double > vector)
void FromXMLElement(vtkXMLDataElement *element)
void Concatenate(LinearObjectBuffer *catBuffer)
std::vector< double > GetOrthogonalNormal2()
static const int DIMENSION
virtual void FromXMLElement(vtkXMLDataElement *element)
static double Dot(std::vector< double > v1, std::vector< double > v2)
virtual std::string ToXMLString() const =0
LinearObject * GetLinearObject(int index) const
std::vector< double > Signature
virtual void Translate(std::vector< double > vector)=0
double DistanceToVector(std::vector< double > vector)
std::vector< double > GetOrthogonalNormal1()
std::vector< double > GetNormal()
LinearObjectBuffer * GetMatches(LinearObjectBuffer *candidates, double matchingThreshold)
std::string ToXMLString() const
static std::vector< double > Subtract(std::vector< double > v1, std::vector< double > v2)