Commit ca452e19 authored by Andreas Schwarzkopf's avatar Andreas Schwarzkopf

[FIX #359] Altering dependent classes for compatiblity (Principal Component Analysis)

 * I changed in the WPrincipalComponentAnalysis analyzeData(const vector<WPosition>) to
 * analyzeData(const vector<WPosition>*) in order to avoid unnecessary copies. Therefore
 * some classes had to be changed to remain compilable.
parent 141e1b84
......@@ -61,6 +61,7 @@ void WPCADetector::analyzeNode( WPcaDetectOctNode* node )
{
WPrincipalComponentAnalysis pca;
pca.analyzeData( node->getInputPoints() );
node->clearInputData();
vector<double> eigenValues = pca.getEigenValues();
if( eigenValues[0] > 0.0 )
node->setEigenValueQuotient( eigenValues[2] / eigenValues[0] );
......
......@@ -28,12 +28,14 @@
WPcaDetectOctNode::WPcaDetectOctNode()
{
m_inputPoints = new vector<WPosition>();
m_hasEigenValueQuotient = false;
}
WPcaDetectOctNode::WPcaDetectOctNode( double centerX, double centerY, double centerZ, double radius ) :
WOctNode( centerX, centerY, centerZ, radius )
{
m_inputPoints = new vector<WPosition>();
m_hasEigenValueQuotient = false;
}
......@@ -47,11 +49,11 @@ WOctNode* WPcaDetectOctNode::newInstance( double centerX, double centerY, double
}
void WPcaDetectOctNode::onTouchPosition( double x, double y, double z )
{
inputPoints.push_back( WPosition( x, y, z ) );
m_inputPoints->push_back( WPosition( x, y, z ) );
}
vector<WPosition> WPcaDetectOctNode::getInputPoints()
vector<WPosition>* WPcaDetectOctNode::getInputPoints()
{
return inputPoints;
return m_inputPoints;
}
void WPcaDetectOctNode::setEigenValueQuotient( double eigenValueQuotient )
{
......@@ -67,3 +69,8 @@ bool WPcaDetectOctNode::hasEigenValueQuotient()
{
return m_hasEigenValueQuotient;
}
void WPcaDetectOctNode::clearInputData()
{
m_inputPoints->resize( 0 );
m_inputPoints->reserve( 0 );
}
......@@ -77,7 +77,7 @@ public:
* Returns input data points. covered by the node's area.
* \return Input point data set.
*/
vector<WPosition> getInputPoints();
vector<WPosition>* getInputPoints();
/**
* Sets the node color.
* \param color Node color to assign.
......@@ -103,23 +103,29 @@ public:
*/
double getEigenValueQuotient();
/**
* Says whether the node has got the information about the point's isotropic level.
* Says whether the node has got the information about the point's isotropic
* level.
* \return Point has got information about the istropic level or not.
*/
bool hasEigenValueQuotient();
/**
* Clears the input point data. It mainly frees space after the Principal
* Component Analysis.
*/
void clearInputData();
private:
/**
* Input data set points covered by that node.
*/
vector<WPosition> inputPoints;
vector<WPosition>* m_inputPoints;
/**
* Quotient of the smallest Eigen Value over the biggest.
*/
double m_eigenValueQuotient;
/**
* Marker that says whether the node has the information about its point's isotropic
* level.
* Marker that says whether the node has the information about its point's
* isotropic level.
*/
bool m_hasEigenValueQuotient;
};
......
......@@ -51,6 +51,7 @@ void WPCAWallDetector::analyzeNode( WWallDetectOctNode* node )
{
WPrincipalComponentAnalysis pca;
pca.analyzeData( node->getInputPoints() );
node->clearInputData();
node->setMean( pca.getMean() );
node->setEigenVectors( pca.getDirections() );
node->setEigenValues( pca.getEigenValues() );
......
......@@ -28,12 +28,14 @@
WWallDetectOctNode::WWallDetectOctNode()
{
m_inputPoints = new vector<WPosition>();
m_eigenValues[3];
}
WWallDetectOctNode::WWallDetectOctNode( double centerX, double centerY, double centerZ, double radius ) :
WOctNode( centerX, centerY, centerZ, radius )
{
m_inputPoints = new vector<WPosition>();
m_eigenValues[3];
}
......@@ -47,9 +49,9 @@ WOctNode* WWallDetectOctNode::newInstance( double centerX, double centerY, doubl
}
void WWallDetectOctNode::onTouchPosition( double x, double y, double z )
{
m_inputPoints.push_back( WPosition( x, y, z ) );
m_inputPoints->push_back( WPosition( x, y, z ) );
}
vector<WPosition> WWallDetectOctNode::getInputPoints()
vector<WPosition>* WWallDetectOctNode::getInputPoints()
{
return m_inputPoints;
}
......@@ -99,3 +101,8 @@ WVector3d WWallDetectOctNode::getEigenVector( size_t index )
{
return m_eigenVectors[index];
}
void WWallDetectOctNode::clearInputData()
{
m_inputPoints->resize( 0 );
m_inputPoints->reserve( 0 );
}
......@@ -93,7 +93,7 @@ public:
* Returns the input points covered by the node.
* \return Input point data covered by the node.
*/
vector<WPosition> getInputPoints();
vector<WPosition>* getInputPoints();
/**
* Returns the normal vector of the node. It points to the least point
* distributed direction.
......@@ -153,12 +153,17 @@ public:
* \return The node has Eigen Values and Eigen Vectors or not.
*/
bool hasEigenValuesAndVectors();
/**
* Clears the input point data. It mainly frees space after the Principal
* Component Analysis.
*/
void clearInputData();
private:
/**
* Input points covered by the space of the node.
*/
vector<WPosition> m_inputPoints;
vector<WPosition>* m_inputPoints;
/**
* The mean coordinate of all input points.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment