Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c0ae76536 | |||
| 379c97d29e |
+29
-29
@@ -8,7 +8,7 @@ option( PLUGIN_G3POINT "Install example plugin" OFF )
|
||||
|
||||
if ( PLUGIN_G3POINT )
|
||||
project( G3PointPlugin )
|
||||
|
||||
|
||||
AddPlugin( NAME ${PROJECT_NAME} )
|
||||
|
||||
target_sources(G3PointPlugin
|
||||
@@ -31,7 +31,7 @@ if ( PLUGIN_G3POINT )
|
||||
# QCUSTOMPLOT
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
QCustomPlot
|
||||
Qt5::PrintSupport
|
||||
Qt6::PrintSupport
|
||||
)
|
||||
|
||||
# EIGEN
|
||||
@@ -72,38 +72,38 @@ if ( PLUGIN_G3POINT )
|
||||
# git commit hash
|
||||
# Get the current working branch
|
||||
execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH_G3POINT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH_G3POINT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Get the latest commit hash
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH_G3POINT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH_G3POINT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Get the latest commit hash
|
||||
execute_process(
|
||||
COMMAND git describe
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_TAG_G3POINT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
COMMAND git describe
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_TAG_G3POINT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Get the current working branch
|
||||
execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH_CC
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH_CC
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
# Get the latest commit hash
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH_CC
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH_CC
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
message(${PROJECT_NAME} " " GIT_BRANCH_G3POINT " " ${GIT_BRANCH_G3POINT})
|
||||
message(${PROJECT_NAME} " " GIT_COMMIT_HASH_G3POINT " " ${GIT_COMMIT_HASH_G3POINT})
|
||||
@@ -113,12 +113,12 @@ if ( PLUGIN_G3POINT )
|
||||
message(${PROJECT_NAME} " " QG3POINT_VERSION " " ${QG3POINT_PLUGIN_VERSION})
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
GIT_BRANCH_CC="${GIT_BRANCH_CC}"
|
||||
GIT_COMMMIT_HASH_CC="${GIT_COMMIT_HASH_CC}"
|
||||
PUBLIC GIT_BRANCH_G3POINT="${GIT_BRANCH_G3POINT}"
|
||||
GIT_COMMMIT_HASH_G3POINT="${GIT_COMMIT_HASH_G3POINT}"
|
||||
GIT_TAG_G3POINT="${GIT_TAG_G3POINT}"
|
||||
G3POINT_VERSION="${QG3POINT_PLUGIN_VERSION}"
|
||||
)
|
||||
GIT_BRANCH_CC="${GIT_BRANCH_CC}"
|
||||
GIT_COMMMIT_HASH_CC="${GIT_COMMIT_HASH_CC}"
|
||||
PUBLIC GIT_BRANCH_G3POINT="${GIT_BRANCH_G3POINT}"
|
||||
GIT_COMMMIT_HASH_G3POINT="${GIT_COMMIT_HASH_G3POINT}"
|
||||
GIT_TAG_G3POINT="${GIT_TAG_G3POINT}"
|
||||
G3POINT_VERSION="${QG3POINT_PLUGIN_VERSION}"
|
||||
)
|
||||
|
||||
endif()
|
||||
|
||||
@@ -98,9 +98,9 @@ private:
|
||||
bool updateLocalMaximumIndexes();
|
||||
bool updateLabelsAndColors();
|
||||
bool checkStacks(const std::vector<std::vector<int>>& stacks, int count);
|
||||
void addToStackBraunWillett(int index, const Eigen::ArrayXi& delta, const Eigen::ArrayXi &Di, std::vector<int>& stack, int local_maximum);
|
||||
void addToStackBraunWillett(int index, const Eigen::ArrayXi& delta, const Eigen::ArrayXi& Di, std::vector<int>& stack, int local_maximum);
|
||||
int segmentLabelsBraunWillett();
|
||||
void getNeighborsDistancesSlopes(unsigned index);
|
||||
void getNeighborsDistancesSlopes(unsigned index, std::vector<char>& duplicates);
|
||||
void computeNodeSurfaces();
|
||||
bool computeNormalsAndOrientThemWithCloudCompare();
|
||||
void orientNormals(const Eigen::Vector3d &sensorCenter);
|
||||
|
||||
@@ -55,7 +55,9 @@ protected:
|
||||
{
|
||||
QPointF Pstart = P;
|
||||
if (m_textOnTheLeft)
|
||||
Pstart.setX(P.x() - painter->fontMetrics().width(m_text[i]));
|
||||
{
|
||||
Pstart.setX(P.x() - painter->fontMetrics().boundingRect(m_text[i]).width());
|
||||
}
|
||||
painter->drawText(Pstart,m_text[i]);
|
||||
P.setY(P.y() + fontHeight);
|
||||
}
|
||||
|
||||
+23
-9
@@ -1051,7 +1051,7 @@ void G3PointAction::fit()
|
||||
}
|
||||
|
||||
void G3PointAction::exportResults()
|
||||
{
|
||||
{
|
||||
if (m_grainsAsEllipsoids)
|
||||
{
|
||||
m_grainsAsEllipsoids->exportResultsAsCloud();
|
||||
@@ -1652,7 +1652,7 @@ int G3PointAction::segmentLabelsBraunWillett()
|
||||
return nLabels;
|
||||
}
|
||||
|
||||
void G3PointAction::getNeighborsDistancesSlopes(unsigned index)
|
||||
void G3PointAction::getNeighborsDistancesSlopes(unsigned index, std::vector<char>& duplicates)
|
||||
{
|
||||
const CCVector3* P = m_cloud->getPoint(index);
|
||||
|
||||
@@ -1674,7 +1674,15 @@ void G3PointAction::getNeighborsDistancesSlopes(unsigned index)
|
||||
float distance = (*P - *neighbor).norm();
|
||||
m_neighborsDistances(index, k) = distance;
|
||||
// compute the slope to the neighbor
|
||||
m_neighborsSlopes(index, k) = (P->z - neighbor->z) / distance;
|
||||
if (distance != 0)
|
||||
{
|
||||
m_neighborsSlopes(index, k) = (P->z - neighbor->z) / distance;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_neighborsSlopes(index, k) = 0.; // it is possible to have duplicates in the cloud
|
||||
duplicates[index] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1905,7 +1913,7 @@ bool G3PointAction::computeNormalsWithCloudCompare()
|
||||
//manually call the static per-point method!
|
||||
for (unsigned index = 0; index < pointCount; ++index)
|
||||
{
|
||||
computeNormWithFlann(index, theNorms.data(), m_kNN, m_kdTree.data(), m_cloud);
|
||||
computeNormWithFlann(index, theNorms.data(), m_kdTree.data());
|
||||
}
|
||||
#else
|
||||
std::vector<unsigned> pointsIndexes;
|
||||
@@ -1979,7 +1987,7 @@ bool G3PointAction::computeNormals()
|
||||
}
|
||||
|
||||
bool G3PointAction::queryNeighbors(ccPointCloud* cloud, ccMainAppInterface* appInterface, bool useParallelStrategy)
|
||||
{
|
||||
{
|
||||
QString errorStr;
|
||||
|
||||
ccProgressDialog progressDlg(true, appInterface->getMainWindow());
|
||||
@@ -2007,8 +2015,8 @@ bool G3PointAction::queryNeighbors(ccPointCloud* cloud, ccMainAppInterface* appI
|
||||
|
||||
size_t nPoints = m_cloud->size();
|
||||
CCCoreLib::DgmOctree::NearestNeighboursSearchStruct nNSS;
|
||||
std::vector<unsigned> pointsIndexes;
|
||||
pointsIndexes.resize(nPoints);
|
||||
std::vector<unsigned> pointsIndexes(nPoints);
|
||||
std::vector<char> duplicates(nPoints, 0);
|
||||
|
||||
if (useParallelStrategy)
|
||||
{
|
||||
@@ -2019,17 +2027,23 @@ bool G3PointAction::queryNeighbors(ccPointCloud* cloud, ccMainAppInterface* appI
|
||||
int threadCount = std::max(1, ccQtHelpers::GetMaxThreadCount() - 2);
|
||||
std::cout << "[query_neighbor] parallel strategy, thread count " << threadCount << std::endl;
|
||||
QThreadPool::globalInstance()->setMaxThreadCount(threadCount);
|
||||
QtConcurrent::blockingMap(pointsIndexes, [=](int index){getNeighborsDistancesSlopes(index);});
|
||||
QtConcurrent::blockingMap(pointsIndexes, [&](int index){getNeighborsDistancesSlopes(index, duplicates);});
|
||||
}
|
||||
else
|
||||
{
|
||||
//manually call the static per-point method!
|
||||
for (unsigned i = 0; i < nPoints; ++i)
|
||||
{
|
||||
getNeighborsDistancesSlopes(i);
|
||||
getNeighborsDistancesSlopes(i, duplicates);
|
||||
}
|
||||
}
|
||||
|
||||
auto trueCount = std::count(duplicates.begin(), duplicates.end(), 1);
|
||||
if (trueCount)
|
||||
{
|
||||
ccLog::Warning("[G3Point] You have duplicates (" + QString::number(trueCount) + "), the algorithm will continue but you may think of cleaning your cloud.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,22 +88,22 @@ bool G3PointPlots::exportToCSV(QString filename, SharedDataContainer container,
|
||||
//header
|
||||
if (dq_final) // WolmanCustomPlot
|
||||
{
|
||||
stream << "# D10 [mm], D50 [mm], D90 [mm]" << endl;
|
||||
stream << (*dq_final)(0) << " " << (*dq_final)(1) << " " << (*dq_final)(2) << endl;
|
||||
stream << "# std(D10) [mm], std(D50) [mm], std(D90) [mm]" << endl;
|
||||
stream << (*edq)(0) << " " << (*edq)(1) << " " << (*edq)(2 ) << endl;
|
||||
stream << "diameter [m], pdf" << endl;
|
||||
stream << "# D10 [mm], D50 [mm], D90 [mm]" << Qt::endl;
|
||||
stream << (*dq_final)(0) << " " << (*dq_final)(1) << " " << (*dq_final)(2) << Qt::endl;
|
||||
stream << "# std(D10) [mm], std(D50) [mm], std(D90) [mm]" << Qt::endl;
|
||||
stream << (*edq)(0) << " " << (*edq)(1) << " " << (*edq)(2 ) << Qt::endl;
|
||||
stream << "diameter [m], pdf" << Qt::endl;
|
||||
}
|
||||
else // AnglesCustomPlot
|
||||
{
|
||||
stream << "angle [degree], counts" << endl;
|
||||
stream << "angle [degree], counts" << Qt::endl;
|
||||
}
|
||||
|
||||
//data
|
||||
{
|
||||
for (auto item : *container)
|
||||
{
|
||||
stream << item.key << " " << item.value << endl;
|
||||
stream << item.key << " " << item.value << Qt::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ void WolmanCustomPlot::mousePressEvent(QMouseEvent *event)
|
||||
QAction* action = new QAction("Close tab");
|
||||
menu->addAction(action);
|
||||
connect(action, &QAction::triggered, this, &WolmanCustomPlot::emitCloseTab);
|
||||
menu->popup(event->globalPos());
|
||||
menu->popup(event->globalPosition().toPoint());
|
||||
}
|
||||
QCustomPlot::mousePressEvent(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user