Commit c6328001 authored by Andreas Schwarzkopf's avatar Andreas Schwarzkopf

[ADD #371] Implemented status bar feature for - Surface detection by Lari/Habib

 * Implemented status bar feature for "Surface detection by Lari/Habib" and "Point Groups - Validator"
parent 8d79014f
......@@ -15,4 +15,4 @@
#VERSION=1.2.0
#VERSION=1.2.0+hgX -> replaces the X with the current revision number
#VERSUIB=1.2.0+hg1234 -> here, revision number was set by the build scripts for example.
VERSION=0.0.3+hgX
VERSION=0.5.0
......@@ -141,14 +141,18 @@ void WGroupValidator::validateGroups(
m_validatedGroups = m_validatedPoints->getGroups();
setProgressSettings( m_referenceGroupEditor.getLastGroupID() );
for( size_t refGroup = 0; refGroup <= m_referenceGroupEditor.getLastGroupID(); refGroup++ )
{
boost::shared_ptr< WDataSetPoints > referenceGroup = getPointsOfGroup( m_referencePoints, refGroup );
size_t bestGroupIDInValidated = getBestMatchingGroupID( referenceGroup );
validateGroup( refGroup, bestGroupIDInValidated );
m_progressStatus->increment( 1 );
}
identifyNotSegmentedGroupPoints();
m_progressStatus->finish();
}
......@@ -387,3 +391,18 @@ boost::shared_ptr< WDataSetPoints > WGroupValidator::getEmptyShowablePointSet()
new WDataSetPoints( newVertices, newColors ) );
return outputPoints;
}
void WGroupValidator::assignProgressCombiner( boost::shared_ptr< WProgressCombiner > progress )
{
m_associatedProgressCombiner = progress;
}
void WGroupValidator::setProgressSettings( size_t referenceGroupCount )
{
m_associatedProgressCombiner->removeSubProgress( m_progressStatus );
std::ostringstream headerLabel;
headerLabel << "Validating groups: " << referenceGroupCount;
m_progressStatus = boost::shared_ptr< WProgress >( new WProgress( headerLabel.str(), referenceGroupCount ) );
m_associatedProgressCombiner->addSubProgress( m_progressStatus );
}
......@@ -32,6 +32,8 @@
#include "../common/datastructures/WDataSetPointsGrouped.h"
#include "../common/algorithms/pointSubtractionHelper/WPointSubtactionHelper.h"
#include "core/common/WProgressCombiner.h"
using std::vector;
......@@ -160,6 +162,20 @@ public:
/**
* Assigns the progress combiner to depict the status during classifying.
* \param progress Progress combiner to assign.
*/
void assignProgressCombiner( boost::shared_ptr< WProgressCombiner > progress );
/**
* Initializes the current progress status.
* \param referenceGroupCount Count of referrence groups to process.
*/
void setProgressSettings( size_t referenceGroupCount );
private:
/**
* Validates a single group using a reference point group set.
......@@ -365,6 +381,18 @@ private:
* covered by the reference group..
*/
double m_minimalPointCorrectness;
/**
* Progress combiner for changing the plugin status in the modules overview.
*/
boost::shared_ptr< WProgressCombiner > m_associatedProgressCombiner;
/**
* Current progress status.
*/
boost::shared_ptr< WProgress > m_progressStatus;
};
#endif // WGROUPVALIDATOR_H
......@@ -166,8 +166,7 @@ void WMPointGroupsValidator::moduleMain()
// std::cout << "Execute cycle\r\n";
if ( referenceGroups && validatedPoints )
{
setProgressSettings( 10 );
m_groupValidator.assignProgressCombiner( m_progress );
m_groupValidator.setCoordinateAccuracy( m_coordinateAccuracy->get() );
m_groupValidator.setPointAreaRadius( m_pointAreaRadius->get() );
m_groupValidator.setMinimalPointCompleteness( m_minimalPointCompleteness->get() );
......@@ -185,8 +184,6 @@ void WMPointGroupsValidator::moduleMain()
if( m_saveCSVTrigger->get(true) )
m_exportCSV.exportCSV();
m_saveCSVTrigger->set( WPVBaseTypes::PV_TRIGGER_READY, true );
m_progressStatus->finish();
}
......@@ -206,16 +203,3 @@ void WMPointGroupsValidator::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
}
void WMPointGroupsValidator::setProgressSettings( size_t steps )
{
m_progress->removeSubProgress( m_progressStatus );
std::string headerText = "Loading data";
m_progressStatus = boost::shared_ptr< WProgress >( new WProgress( headerText, steps ) );
m_progress->addSubProgress( m_progressStatus );
}
......@@ -142,14 +142,6 @@ protected:
virtual void requirements();
private:
/**
* Initializes progress bar settings.
* \param steps Points count as reference to the progress bar.
*/
void setProgressSettings( size_t steps );
/**
* The OSG root node for this module. All other geodes or OSG nodes will be attached on this single node.
*/
......@@ -195,10 +187,6 @@ private:
/**
* Plugin progress status that is shared with the reader.
*/
boost::shared_ptr< WProgress > m_progressStatus;
/**
* Settings group that deals with coordinate accuracy of points to be evaluated.
......
......@@ -43,16 +43,19 @@ WLariBoundaryDetector::~WLariBoundaryDetector()
{
}
void WLariBoundaryDetector::detectBoundaries( WKdTreeND* parameterDomain )
void WLariBoundaryDetector::detectBoundaries( WLariPointClassifier* classifier )
{
m_classifier = classifier;
cout << "detectBoundaries()" << endl;
groupPointsByGroupID( parameterDomain );
groupPointsByGroupID( m_classifier->getParameterDomain() );
m_classifier->setProgressSettings( m_spatialInputClusters->size(), m_spatialInputClusters->size(), "Boundary detection - " );
for( size_t cluster = 0; cluster < m_spatialInputClusters->size(); cluster++ )
{
cout << "Modified convex hull on cluster " << m_spatialInputClusters->at( cluster )->size()
<< " points. [" << cluster << "]" << endl;
detectInputCluster( m_spatialInputClusters->at( cluster ) );
m_classifier->incrementProgress();
}
}
......
......@@ -36,6 +36,7 @@
#include "../common/datastructures/kdtree/WKdPointND.h"
#include "../common/datastructures/kdtree/WPointSearcher.h"
#include "../common/math/vectors/WVectorMaths.h"
#include "WLariPointClassifier.h"
using std::cout;
......@@ -93,9 +94,10 @@ public:
* Applies the algorithm on the input point data set where points have been
* clustered to groups that have a similar planar furmula. The algorithm splits
* grops that are spatially disconnected.
* \param parameterDomain Parameter domain containing planar input points.
* \param classifier Point classifier instance to fetch points of the spatial and
* parameter domain.
*/
void detectBoundaries( WKdTreeND* parameterDomain );
void detectBoundaries( WLariPointClassifier* classifier );
/**
* Sets the neighbor point search distance limit:
......@@ -223,6 +225,10 @@ private:
*/
bool boundChainStillValid();
/**
* Point classifier to access the spatial and parameter domain.
*/
WLariPointClassifier* m_classifier;
/**
* Spatial domain point set kd tree to be analyzed and its point group IDs modified.
......
......@@ -24,6 +24,7 @@
#include <vector>
#include <limits>
#include <string>
#include "WLariPointClassifier.h"
#include "../common/math/leastSquares/WLeastSquares.h"
......@@ -78,6 +79,8 @@ WKdTreeND* WLariPointClassifier::getSpatialDomain()
void WLariPointClassifier::classifyPoints( vector<WSpatialDomainKdPoint*>* spatialPoints, vector<WParameterDomainKdPoint*>* parameterPoints )
{
setProgressSettings( spatialPoints->size(), spatialPoints->size(), "Point classification - " );
size_t threads = m_cpuThreadCount < spatialPoints->size() ?m_cpuThreadCount :spatialPoints->size();
for( size_t thread = 0; thread < threads; thread++ )
m_cpuThreads[thread] = new boost::thread( &WLariPointClassifier::
......@@ -126,6 +129,8 @@ void WLariPointClassifier::classifyPointsAtThread( vector<WSpatialDomainKdPoint*
delete nearestPoints;
delete points;
incrementProgress();
}
}
......@@ -191,3 +196,27 @@ void WLariPointClassifier::setCylindricalNLambdaRange( size_t lambdaIndex, doubl
m_cylindricalNLambdaMin[lambdaIndex] = min;
m_cylindricalNLambdaMax[lambdaIndex] = max;
}
void WLariPointClassifier::assignProgressCombiner( boost::shared_ptr< WProgressCombiner > progress )
{
m_associatedProgressCombiner = progress;
}
void WLariPointClassifier::setProgressSettings( size_t iteration, size_t steps, std::string headerText )
{
m_associatedProgressCombiner->removeSubProgress( m_progressStatus );
std::ostringstream headerLabel;
headerLabel << headerText << iteration;
m_progressStatus = boost::shared_ptr< WProgress >( new WProgress( headerLabel.str(), steps ) );
m_associatedProgressCombiner->addSubProgress( m_progressStatus );
}
void WLariPointClassifier::incrementProgress()
{
m_progressStatus->increment( 1 );
}
void WLariPointClassifier::finishProgress()
{
m_progressStatus->finish();
}
......@@ -27,6 +27,7 @@
#include <iostream>
#include <vector>
#include <string>
#include <boost/thread.hpp>
#include "core/dataHandler/WDataSetPoints.h"
......@@ -144,6 +145,31 @@ public:
*/
void setCylindricalNLambdaRange( size_t lambdaIndex, double min, double max );
/**
* Assigns the progress combiner to depict the status during classifying.
* \param progress Progress combiner to assign.
*/
void assignProgressCombiner( boost::shared_ptr< WProgressCombiner > progress );
/**
* Initializes the current progress status.
* \param iteration Current iteration number. Mostly cluster ID.
* \param steps Step count of the process. Mostly it is the point count within a cluster.
* \param headerText Gives information about the task
*/
void setProgressSettings( size_t iteration, size_t steps, std::string headerText );
/**
* Increments the progress status by one unit.
*/
void incrementProgress();
/**
* Finishes the progress.
*/
void finishProgress();
private:
/**
* Classifies points using Eigen Value analyses (Eigen Values and Eigen Vectors) and
......@@ -162,13 +188,20 @@ private:
*/
void classifyPointsAtThread( vector<WSpatialDomainKdPoint*>* spatialPoints, size_t threadIndex );
/**
* Sets the progress status.
*/
/**
* The maximal count of analyzed neighbors of an examined input point.
* The maximal count of analyzed neighbors of an examined input point. It is the
* number of points that is required for a plane definition.
*/
size_t m_numberPointsK;
/**
* Maximal radius within which the nearest neighbors are examined.
* Maximal radius, within which the nearest neighbors are examined.
*/
double m_maxPointDistanceR;
......@@ -216,6 +249,17 @@ private:
* CPU threads object for multithreading support.
*/
vector<boost::thread*> m_cpuThreads;
/**
* Progress combiner for changing the plugin status in the modules overview.
*/
boost::shared_ptr< WProgressCombiner > m_associatedProgressCombiner;
/**
* Current progress status.
*/
boost::shared_ptr< WProgress > m_progressStatus;
};
#endif // WLARIPOINTCLASSIFIER_H
......@@ -117,8 +117,8 @@ void WMSurfaceDetectionByLari::properties()
m_reloadData = m_properties->addProperty( "Reload data:", "Execute", WPVBaseTypes::PV_TRIGGER_READY, m_propCondition );
double minRange = 0.01;
m_segmentationPlaneDistance = m_properties->addProperty( "Plane distance", "", 0.7, m_propCondition );
m_segmentationMaxAngleDegrees = m_properties->addProperty( "Plane angle", "", 15.0, m_propCondition );
m_segmentationMaxPlaneDistance = m_properties->addProperty( "Delta d", "", 0.7, m_propCondition );
m_segmentationMaxAngleDegrees = m_properties->addProperty( "Delta alpha", "", 15.0, m_propCondition );
m_numberPointsK = m_properties->addProperty( "Number points K=", "", 40, m_propCondition );
m_maxPointDistanceR = m_properties->addProperty( "Max point distance r=", "", 1.0, m_propCondition );
......@@ -215,7 +215,6 @@ void WMSurfaceDetectionByLari::moduleMain()
timer.reset();
WDataSetPoints::VertexArray inputVerts = points->getVertices();
size_t count = inputVerts->size()/3;
setProgressSettings( count );
WQuadTree* boundingBox = new WQuadTree( pow( 2.0, 3 ) );
......@@ -227,12 +226,12 @@ void WMSurfaceDetectionByLari::moduleMain()
float z = inputVerts->at( vertex*3+2 );
inputPoints->push_back( new WSpatialDomainKdPoint( x, y, z ) );
boundingBox->registerPoint( x, y, z );
m_progressStatus->increment( 1 );
}
WLariPointClassifier* classifier = new WLariPointClassifier();
WLariOutliner* outliner = new WLariOutliner( classifier );
classifier->assignProgressCombiner( m_progress );
classifier->setNumberPointsK( m_numberPointsK->get() );
classifier->setMaxPointDistanceR( m_maxPointDistanceR->get() );
classifier->setCpuThreadCount( m_cpuThreadCount->get() );
......@@ -250,7 +249,7 @@ void WMSurfaceDetectionByLari::moduleMain()
m_outputLeastSquaresPlanes->updateData( outliner->outlineLeastSquaresPlanes( m_squareWidth->get() ) );
WLariBruteforceClustering* clustering = new WLariBruteforceClustering( classifier );
clustering->setSegmentationSettings( m_segmentationMaxAngleDegrees->get(), m_segmentationPlaneDistance->get() );
clustering->setSegmentationSettings( m_segmentationMaxAngleDegrees->get(), m_segmentationMaxPlaneDistance->get() );
clustering->setCpuThreadCount( m_cpuThreadCount->get() );
clustering->detectClustersByBruteForce();
......@@ -258,7 +257,7 @@ void WMSurfaceDetectionByLari::moduleMain()
if( m_applyBoundaryDetection->get() )
{
boundaryDetector->setMaxPointDistanceR( m_maxPointDistanceR->get() );
boundaryDetector->detectBoundaries( classifier->getParameterDomain() );
boundaryDetector->detectBoundaries( classifier );
}
cout << "Outlining spatial domain" << endl;
......@@ -284,7 +283,7 @@ void WMSurfaceDetectionByLari::moduleMain()
m_zMax->set( boundingBox->getRootNode()->getValueMax() );
delete boundingBox;
m_infoRenderTimeSeconds->set( timer.elapsed() / 60.0 );
m_progressStatus->finish();
classifier->finishProgress();
}
m_reloadData->set( WPVBaseTypes::PV_TRIGGER_READY, true );
m_reloadData->get( true );
......@@ -304,11 +303,3 @@ void WMSurfaceDetectionByLari::moduleMain()
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
}
void WMSurfaceDetectionByLari::setProgressSettings( size_t steps )
{
m_progress->removeSubProgress( m_progressStatus );
std::string headerText = "Loading data";
m_progressStatus = boost::shared_ptr< WProgress >( new WProgress( headerText, steps ) );
m_progress->addSubProgress( m_progressStatus );
}
......@@ -257,7 +257,7 @@ private:
* neighborship. This variable is the maximal difference between two plane normal
* distance to the origin.
*/
WPropDouble m_segmentationPlaneDistance;
WPropDouble m_segmentationMaxPlaneDistance;
/**
* The maximal count of analyzed neighbors of an
......@@ -370,10 +370,6 @@ private:
WPropTrigger m_reloadData; //!< This property triggers the actual reading,
/**
* Plugin progress status.
*/
boost::shared_ptr< WProgress > m_progressStatus;
/**
* Applied CPU thread count.
......
......@@ -32,6 +32,8 @@
WLariBruteforceClustering::WLariBruteforceClustering( WLariPointClassifier* classifier )
{
m_pointClassifier = classifier;
m_parameterDomain = new WKdTreeND( 3 );
m_parameterDomain->add( classifier->getParameterDomain()->getAllPoints() );
......@@ -47,12 +49,12 @@ WLariBruteforceClustering::~WLariBruteforceClustering()
void WLariBruteforceClustering::detectClustersByBruteForce()
{
vector<WKdPointND*>* parameterNodes = m_parameterDomain->getAllPoints();
size_t currentClusterID = 0;
m_currentClusterID = 0;
while( parameterNodes->size() > 0 )
{
initExtentSizes( parameterNodes );
WParameterDomainKdPoint* biggestExtentPoint = 0;
int mostNeighborsCount = 0;
size_t mostNeighborsCount = 0;
for( size_t index = 0; index < parameterNodes->size(); index++ )
{
WParameterDomainKdPoint* parameterPoint = static_cast<WParameterDomainKdPoint*>( parameterNodes->at( index ) );
......@@ -62,7 +64,7 @@ void WLariBruteforceClustering::detectClustersByBruteForce()
mostNeighborsCount = parameterPoint->getExtentPointCount();
}
}
addExtentCluster( biggestExtentPoint, currentClusterID++ );
addExtentCluster( biggestExtentPoint, m_currentClusterID++ );
vector<WKdPointND*>* oldParameterNodes = parameterNodes;
parameterNodes = new vector<WKdPointND*>();
......@@ -95,6 +97,7 @@ void WLariBruteforceClustering::setCpuThreadCount( size_t cpuThreadCount )
void WLariBruteforceClustering::initExtentSizes( vector<WKdPointND*>* pointsToProcess )
{
m_pointClassifier->setProgressSettings( m_currentClusterID, pointsToProcess->size(), "Init. cluster " );
size_t threads = m_cpuThreadCount < pointsToProcess->size() ?m_cpuThreadCount :pointsToProcess->size();
for( size_t thread = 0; thread < threads; thread++ )
m_cpuThreads[thread] = new boost::thread(
......@@ -121,6 +124,7 @@ void WLariBruteforceClustering::initExtentSizesAtThread( vector<WKdPointND*>* po
refreshable->setExtentPointCount( count );
refreshable->tagToRefresh( false );
}
m_pointClassifier->incrementProgress();
}
}
......@@ -128,6 +132,7 @@ void WLariBruteforceClustering::addExtentCluster( WParameterDomainKdPoint* peakC
{
vector<WParameterDomainKdPoint*>* extentPoints =
getParametersOfExtent( peakCenterPoint->getCoordinate() );
m_pointClassifier->setProgressSettings( m_currentClusterID, extentPoints->size(), "Adding cluster " );
cout << "Updating Data for extent: " << extentPoints->size() << "/" << m_parameterDomain->getAllPoints()->size() << endl;
size_t threads = m_cpuThreadCount < extentPoints->size() ?m_cpuThreadCount :extentPoints->size();
for( size_t thread = 0; thread < threads; thread++ )
......@@ -155,6 +160,7 @@ void WLariBruteforceClustering::addExtentClusterAtThread( vector<WParameterDomai
extentPoint->setIsAddedToPlane( true );
}
m_pointClassifier->incrementProgress();
}
}
......
......@@ -147,6 +147,16 @@ private:
*/
vector<WParameterDomainKdPoint*>* getParametersOfExtent( const vector<double>& parametersXYZ0 );
/**
* Current cluster ID of the brute-force clustering process.
*/
size_t m_currentClusterID;
/**
* Assigned point classifier instance to get parameter and spatial domain points;
*/
WLariPointClassifier* m_pointClassifier;
/**
* Parameter domain kd tree. This point set is emptied during operation for more
* speed. Assign a copy to that field.
......
......@@ -51,7 +51,8 @@ public:
virtual ~WParameterSpaceSearcher();
/**
* Tags kd tree points within the extent with searched point as peak center to be refreshed.
* Tags kd tree points within the extent with searched point as peak center to be
* refreshed.
*/
void tagExtentToRefresh();
......@@ -95,8 +96,8 @@ protected:
private:
/**
* Returns the masimal euclidian distance within an extent from the peak center in
* the parameter domain kd tree. It is a spherical bounding box concept.
* Returns the masimal euclidian distance within an extent from the peak center to
* any parameter of the extent. It is a spherical bounding box concept.
* \param parametersXYZ0 Parameter domain coordinate from which the maximal
* euclidian distance to the farest extent point is determined.
* \return The maximal euclidian distance from the peak center to the farest
......
......@@ -29,11 +29,13 @@
WParameterDomainKdPoint::WParameterDomainKdPoint( vector<double> coordinate ) : WKdPointND( coordinate )
{
m_markedToRefresh = true;
m_extentPointCount = 0;
}
WParameterDomainKdPoint::WParameterDomainKdPoint( double x0, double y0, double z0 ) : WKdPointND( x0, y0, z0 )
{
m_markedToRefresh = true;
m_extentPointCount = 0;
}
WParameterDomainKdPoint::~WParameterDomainKdPoint()
......@@ -45,7 +47,7 @@ void WParameterDomainKdPoint::setSpatialPoint( WSpatialDomainKdPoint* spatialPoi
m_assignedSpatialNode = spatialPoint;
}
int WParameterDomainKdPoint::getExtentPointCount()
size_t WParameterDomainKdPoint::getExtentPointCount()
{
return m_extentPointCount;
}
......@@ -65,7 +67,7 @@ bool WParameterDomainKdPoint::isTaggedToRefresh()
return m_markedToRefresh;
}
void WParameterDomainKdPoint::setExtentPointCount( int extentPointCount )
void WParameterDomainKdPoint::setExtentPointCount( size_t extentPointCount )
{
m_extentPointCount = extentPointCount;
}
......
......@@ -75,7 +75,7 @@ public:
* \return Parameter domain point count within the extent with the coordinate of
* this object's parameter coordinate as peak center
*/
int getExtentPointCount();
size_t getExtentPointCount();
/**
* Returns the parameter spatial domain point object that is assigned to this
......@@ -107,7 +107,7 @@ public:
* \param extentPointCount Extent point count of an extent with the coordinate of
* this parameter domain point as peak center.
*/
void setExtentPointCount( int extentPointCount );
void setExtentPointCount( size_t extentPointCount );
/**
* Sets whether a parameter that is added to plane or not. Assigned points to a
......@@ -139,7 +139,7 @@ private:
* object as peak center. After each brute force plane point cluster detection
* estimation the biggest extent is picket out.
*/
int m_extentPointCount;
size_t m_extentPointCount;
/**
* Temporary tag which tells whether a parameter domain point is added to a plane or
......
......@@ -90,7 +90,7 @@ void WMSurfaceDetectionByPCL::connectors()
void WMSurfaceDetectionByPCL::properties()
{
m_infoNbPoints = m_infoProperties->addProperty( "Points: ", "Input points count.", 0 );
m_infoRenderTimeSeconds = m_infoProperties->addProperty( "Wall time (s): ", "Time in seconds that the "
m_infoRenderTimeMinutes = m_infoProperties->addProperty( "Wall time (min): ", "Time in seconds that the "
"whole render process took.", 0.0 );
m_infoPointsPerSecond = m_infoProperties->addProperty( "Points per second: ",
"The current speed in points per second.", 0.0 );
......@@ -168,9 +168,9 @@ void WMSurfaceDetectionByPCL::moduleMain()
boost::shared_ptr< WDataSetPointsGrouped > outputPcl = detector.detectSurfaces( points );
m_outputPointsGrouped->updateData( outputPcl );
m_infoNbPoints->set( count );
m_infoRenderTimeSeconds->set( timer.elapsed() );
m_infoPointsPerSecond->set( m_infoRenderTimeSeconds->get() == 0.0 ?m_infoNbPoints->get()
:m_infoNbPoints->get() / m_infoRenderTimeSeconds->get() );
m_infoRenderTimeMinutes->set( timer.elapsed() / 60.0 );
m_infoPointsPerSecond->set( m_infoRenderTimeMinutes->get() == 0.0 ?m_infoNbPoints->get()
:m_infoNbPoints->get() / ( m_infoRenderTimeMinutes->get() * 60.0 ) );
m_infoXMin->set( boundingBox->getRootNode()->getXMin() );
m_infoXMax->set( boundingBox->getRootNode()->getXMax() );
m_infoYMin->set( boundingBox->getRootNode()->getYMin() );
......
......@@ -174,7 +174,7 @@ private:
/**
* Info field - Wall time for the whole surface detection process.
*/