Skip to content

Parallel cut pursuit algorithm intergation (new Graph class) - #139

Closed
farmakis wants to merge 12 commits into
CloudCompare:masterfrom
farmakis:cut-pursuit
Closed

farmakis wants to merge 12 commits into
CloudCompare:masterfrom
farmakis:cut-pursuit

Conversation

@farmakis

@farmakis farmakis commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

This PR intergates the Parallel Cut Pursuit algorithm (with d0) for graph-cut point cloud segmentation.
Introduces a new class 'Graph' to facilitate computations.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The implementation contains incorrect indexing, unsafe concurrent access, missing scalar-field output, memory leaks, and a nonfunctional default octree path.

Review effort: Balanced
Findings: 4 High severity · 2 Medium severity

Open (6)
What changed in this PR

Adds Parallel Cut Pursuit point-cloud segmentation with graph construction and max-flow support.

Changes:

  • Adds graph, cut-pursuit, max-flow, and memory-block implementations.
  • Exposes segmentation through AutoSegmentationTools.
  • Registers new sources and headers with CMake.
File Description
src/​Maxflow.cpp Implements max-flow processing.
src/​Graph.cpp Builds KNN graphs and invokes cut pursuit.
src/​CutPursuit.cpp Implements the parallel segmentation algorithm.
src/​CMakeLists.txt Registers new sources.
src/​AutoSegmentationTools.cpp Adds the segmentation entry point.
include/​OMPNumThreads.h Provides OpenMP thread helpers.
include/​Maxflow.h Declares the max-flow implementation.
include/​Graph.h Declares graph construction and partitioning.
include/​CutPursuit.h Declares the cut-pursuit engine.
include/​CMakeLists.txt Registers new headers.
include/​Block.h Adds block allocators for max-flow.
include/​AutoSegmentationTools.h Exposes the new public API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread include/Graph.h
Comment on lines +39 to +42
if (nullptr == theCloud)
{
return -1;
}
Comment thread src/CutPursuit.cpp
{
first_vertex[comp_assign[v] + 1]++;
}
for (int32_t rv = 1; rv < rV - 1; rv++)
Comment thread src/Graph.cpp
Comment on lines +147 to +150
for (int32_t v = 0; v < V; v++)
{
first_edge[v] = 0;
}
Comment thread src/CutPursuit.cpp
Comment on lines +1128 to +1131
omp_set_num_threads(compute_num_threads(rV));
sort(sort_comp, sort_comp + rV, [comp_sizes](int32_t ru, int32_t rv) -> bool
{ return comp_sizes[ru] > comp_sizes[rv]; }); // decreasing order
omp_set_num_threads(omp_get_num_procs());
Comment thread src/Graph.cpp
Comment on lines +213 to +230
// monitoring arrays
float* Obj = nullptr;
if (compute_Obj)
{
Obj = (float*)malloc(sizeof(float) * (cp_it_max + 1));
}

double* Time = nullptr;
if (compute_Time)
{
Time = (double*)malloc(sizeof(double) * (cp_it_max + 1));
}

float* Dif = nullptr;
if (compute_Dif)
{
Dif = (float*)malloc(sizeof(float) * cp_it_max);
}
@dgirardeau

Copy link
Copy Markdown
Member

Hi. Since there are a lot of files only for this feature, and the coding style is quite different from CCCoreLib (it almost looks like a 3rd party) could you instead move this to a dedicated CC plugin? Or a separate lib at least?

(also I was made aware that TreeIso already relie on this algorithm)

@farmakis

farmakis commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi. Since there are a lot of files only for this feature, and the coding style is quite different from CCCoreLib (it almost looks like a 3rd party) could you instead move this to a dedicated CC plugin? Or a separate lib at least?

(also I was made aware that TreeIso already relie on this algorithm)

@farmakis farmakis closed this Oct 1, 2026
@farmakis farmakis reopened this Oct 1, 2026
@farmakis farmakis closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants