Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 056146c

Browse files
committed
Small fixes before Zenodo reupload
+ Count non-manifold vertices + Add a bit of documentation + Get border points from input/
1 parent bb1270a commit 056146c

File tree

7 files changed

+69
-18
lines changed

7 files changed

+69
-18
lines changed

flatmap/code/surf_cgal/Reconstruct_JetAdv.cxx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <CGAL/Surface_mesh.h>
1212
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
1313
#include <CGAL/Polygon_mesh_processing/connected_components.h>
14+
#include <CGAL/Polygon_mesh_processing/repair.h>
1415

1516
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
1617

@@ -24,6 +25,7 @@ typedef Reconstruction::Facet_const_iterator Facet_iterator;
2425

2526
typedef CGAL::Surface_mesh<Point> SurfaceMesh;
2627
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
28+
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
2729

2830
typedef CGAL::Timer Timer;
2931

@@ -83,23 +85,37 @@ int main(int argc, char** argv)
8385
if(!CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(outfile, mesh))
8486
{
8587
std::cerr << "Failed loading back mesh" << std::endl;
86-
return 1;
88+
return EXIT_FAILURE;
8789
}
90+
std::cerr << "Loaded mesh with " << num_vertices(mesh) << " vertices (after repair)." << std::endl;
8891

8992
SurfaceMesh::Property_map<face_descriptor, std::size_t> fccmap =
9093
mesh.add_property_map<face_descriptor, std::size_t>("f:CC").first;
9194
std::size_t numcc = CGAL::Polygon_mesh_processing::connected_components(mesh, fccmap);
92-
std::cerr << "Have " << numcc << " connected components" << std::endl;
95+
std::cerr << "Mesh has " << numcc << " connected components" << std::endl;
9396

94-
if(numcc > 1) {
97+
if(numcc > 1) { // Keep largest connected component only
9598
std::size_t nrem = CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh, 1);
9699
std::cerr << "Keeping largest connected component (" << nrem << "removed)" << std::endl;
97100
}
98101

102+
// Count non manifold vertices
103+
int counter = 0;
104+
for(vertex_descriptor v : vertices(mesh))
105+
{
106+
if(CGAL::Polygon_mesh_processing::is_non_manifold_vertex(v, mesh))
107+
{
108+
std::cerr << "vertex " << v << " is non-manifold" << std::endl;
109+
++counter;
110+
}
111+
}
112+
std::cerr << "Mesh has " << counter << " non-manifold vertices" << std::endl;
113+
if(counter > 0) return EXIT_FAILURE;
114+
99115
{ // Write mesh again
100116
std::ofstream out (outfile);
101117
out << mesh;
102-
std::cerr << "Done saving back as " << outfile << std::endl;
118+
std::cerr << "Done saving back mesh as " << outfile << std::endl;
103119
}
104120

105121
return EXIT_SUCCESS;

flatmap/code/surf_cgal/Reconstruct_PCAdv.cxx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <CGAL/Surface_mesh.h>
1111
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
1212
#include <CGAL/Polygon_mesh_processing/connected_components.h>
13+
#include <CGAL/Polygon_mesh_processing/repair.h>
1314

1415
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
1516

@@ -23,6 +24,7 @@ typedef Reconstruction::Facet_const_iterator Facet_iterator;
2324

2425
typedef CGAL::Surface_mesh<Point> SurfaceMesh;
2526
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
27+
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
2628

2729
typedef CGAL::Timer Timer;
2830

@@ -88,23 +90,37 @@ int main(int argc, char** argv)
8890
if(!CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(outfile, mesh))
8991
{
9092
std::cerr << "Failed loading back mesh" << std::endl;
91-
return 1;
93+
return EXIT_FAILURE;
9294
}
95+
std::cerr << "Loaded mesh with " << num_vertices(mesh) << " vertices (after repair)." << std::endl;
9396

9497
SurfaceMesh::Property_map<face_descriptor, std::size_t> fccmap =
9598
mesh.add_property_map<face_descriptor, std::size_t>("f:CC").first;
9699
std::size_t numcc = CGAL::Polygon_mesh_processing::connected_components(mesh, fccmap);
97-
std::cerr << "Have " << numcc << " connected components" << std::endl;
100+
std::cerr << "Mesh has " << numcc << " connected components" << std::endl;
98101

99-
if(numcc > 1) {
102+
if(numcc > 1) { // Keep largest connected component only
100103
std::size_t nrem = CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh, 1);
101104
std::cerr << "Keeping largest connected component (" << nrem << "removed)" << std::endl;
102105
}
103106

107+
// Count non manifold vertices
108+
int counter = 0;
109+
for(vertex_descriptor v : vertices(mesh))
110+
{
111+
if(CGAL::Polygon_mesh_processing::is_non_manifold_vertex(v, mesh))
112+
{
113+
std::cerr << "vertex " << v << " is non-manifold" << std::endl;
114+
++counter;
115+
}
116+
}
117+
std::cerr << "Mesh has " << counter << " non-manifold vertices" << std::endl;
118+
if(counter > 0) return EXIT_FAILURE;
119+
104120
{ // Write mesh again
105121
std::ofstream out (outfile);
106122
out << mesh;
107-
std::cerr << "Done saving back as " << outfile << std::endl;
123+
std::cerr << "Done saving back mesh as " << outfile << std::endl;
108124
}
109125

110126
return EXIT_SUCCESS;

flatmap/code/surf_cgal/Reconstruct_PCAlpha.cxx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <CGAL/Surface_mesh.h>
1010
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
1111
#include <CGAL/Polygon_mesh_processing/connected_components.h>
12+
#include <CGAL/Polygon_mesh_processing/repair.h>
1213

1314
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
1415

@@ -23,6 +24,7 @@ typedef Mesher::Facet_const_iterator Mesher_iterator;
2324

2425
typedef CGAL::Surface_mesh<Point> SurfaceMesh;
2526
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
27+
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
2628

2729
typedef CGAL::Timer Timer;
2830

@@ -86,23 +88,37 @@ int main(int argc, char** argv)
8688
if(!CGAL::Polygon_mesh_processing::IO::read_polygon_mesh(outfile, mesh))
8789
{
8890
std::cerr << "Failed loading back mesh" << std::endl;
89-
return 1;
91+
return EXIT_FAILURE;
9092
}
93+
std::cerr << "Loaded mesh with " << num_vertices(mesh) << " vertices (after repair)." << std::endl;
9194

9295
SurfaceMesh::Property_map<face_descriptor, std::size_t> fccmap =
9396
mesh.add_property_map<face_descriptor, std::size_t>("f:CC").first;
9497
std::size_t numcc = CGAL::Polygon_mesh_processing::connected_components(mesh, fccmap);
95-
std::cerr << "Have " << numcc << " connected components" << std::endl;
98+
std::cerr << "Mesh has " << numcc << " connected components" << std::endl;
9699

97-
if(numcc > 1) {
100+
if(numcc > 1) { // Keep largest connected component only
98101
std::size_t nrem = CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh, 1);
99102
std::cerr << "Keeping largest connected component (" << nrem << "removed)" << std::endl;
100103
}
101104

105+
// Count non manifold vertices
106+
int counter = 0;
107+
for(vertex_descriptor v : vertices(mesh))
108+
{
109+
if(CGAL::Polygon_mesh_processing::is_non_manifold_vertex(v, mesh))
110+
{
111+
std::cerr << "vertex " << v << " is non-manifold" << std::endl;
112+
++counter;
113+
}
114+
}
115+
std::cerr << "Mesh has " << counter << " non-manifold vertices" << std::endl;
116+
if(counter > 0) return EXIT_FAILURE;
117+
102118
{ // Write mesh again
103119
std::ofstream out (outfile);
104120
out << mesh;
105-
std::cerr << "Done saving back as " << outfile << std::endl;
121+
std::cerr << "Done saving back mesh as " << outfile << std::endl;
106122
}
107123

108124
return EXIT_SUCCESS;

flatmap/examples/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Example user configuration files
22

33
+ `genfiles_isocortex.mk`: generate mouse isocortex input files from CCFv3 distribution
4-
+ `genfiles_cerebellum.mk`: generate mouse cerebellum input files from CCFv3 distribution (WIP)
5-
+ `user_config_cerebellum.mk`: user configuration file for mouse cerebellum (WIP)
6-
+ `user_config_isocortex.mk`: user configuration file for mouse isocortex
4+
+ `user_config_isocortex.mk`: user configuration file for mouse isocortex (square border)
5+
+ `user_config_isocortex_shape_match.mk`: user configuration file for mouse isocortex (shape-match border)
76
+ `user_config_sscx.mk`: user configuration file for rat somatosensory cortex

flatmap/examples/user_config_isocortex_shaped.mk renamed to flatmap/examples/user_config_isocortex_shape_match.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ NREFINE := 3
1717
FLATTEN_MESH_BIN := $(SOURCE_CODE_ROOT)/surf_cgal/build/Flatten_Authalic_Iterative_convex
1818

1919
## extra arguments to flattening algorithm (FlattenAuthalicIterative_Convex)
20-
### border points
20+
### border points file
2121
### number of iterations
2222
### offset of first corner along boundary
23-
### corners .selection.txt file
24-
FLATTEN_MESH_EXTRA := border_points.txt 10 -1840# offset = -230 * 2 ** NREFINE
23+
FLATTEN_MESH_EXTRA := input/border_points.txt 10 -1840# offset = -230 * 2 ** NREFINE
2524

2625
## how many streamlines computed per run?
2726
FLATPATH_BLOCKSIZE := 100000
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Flatten mesh
2+
+ Input mesh must be a (preferably smooth) manifold with a single boundary loop.
3+
+ Isolated geometry, duplicated vertices, or non-manifold vertices will make the algorithm fail.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Compute streamlines
2+
+ Relative depth field must be 0 at bottom surface and 1 at top surface (technical quirk)

0 commit comments

Comments
 (0)