This version of Open3D adds a new API 'IdenticallyColoredConnectedComponents' in geometry::TriangleMesh class. This project is derived from Open3D
This API allows computation of identically colored connected components (region of connected vertices) of a given triangular mesh. Component connectedness is established based on:
- Topological connectivity - two vertex are connected if part of same triangle
- Color similarity - vertex share same color property
Algorithm uses breadth first search (BFS) for graph traversal to establish topological connectivity. It uses a pre-computed adjacency list for faster graph traversal. Further, for algorithm to work with disconnected graphs, BFS is carried out from all vertex. To improve performance, algorithm maintains memorization to restrict BFS calls to only non-visited vertex.
The output is return as TriangleMesh::ConnectedComponentList, which is a STL Vector, containing all estimated connected components in mesh. Each connected component is defined as STL Set. As selection of source vertex for next search of connected component (here BFS) occurs in ascending order of vertex index; the ConnectedComponentList is guranteed to be ordered in ascending order by smallest vertex index in each ConnectedComponent. Further, vertex indices within each connected components are assured to be in ascending order due to usage of Set as a container.
The implemented API in C++ has python binding as 'identically_colored_connected_components' method in TriangleMesh class.
- Clone repository
- Ensure GIT sub-modules are initialized and updated
- Refer to BUILD INSTRUCTIONS for project configuration and build
- Ensure BUILD_PYBIND11, BUILD_PYTHON_MODULE, BUILD_CPP_EXAMPLES are selected in CMAKE
- Project is currently tested on system with Windows 10 (64 bit) OS, VS 2015 compiler, python 3.6 and cmake 3.16
As Open3D unit tests are disabled on windows system no separate unit tests were implemented using google test framework. Instead unit tests were written in the CPP example and can be triggered optionally.
Build project 'Solution' under example/CPP. Run generated Solution.exe with command line arguments: <input mesh file (.ply) > < output file (.txt) > < 0/1 (optionally run unit-tests))
Ensure build with python binding. Install Open3D python package by building 'install-pip-package' project. Run examples\Python\Basic\solution.py python script with command line argument: <input file (.ply) > < output file (.txt) >
Generated file from CPP example over given test_mesh.ply is saved as results.txt here.