Skip to content

Commit 2a42d1b

Browse files
committed
Update clang-format style: 100 columns, and forbid one-line braces
1 parent 6ac7fa0 commit 2a42d1b

20 files changed

+397
-681
lines changed

.clang-format

Lines changed: 9 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,22 @@
1-
Language: Cpp
1+
Language: Cpp
22
BasedOnStyle: Google
33
# ---
4-
#AccessModifierOffset: -4
54
AlignAfterOpenBracket: AlwaysBreak # Values: Align, DontAlign, AlwaysBreak
65
AlignConsecutiveAssignments: true
76
AlignConsecutiveDeclarations: true
8-
#AlignEscapedNewlinesLeft: true
9-
#AlignOperands: false
107
AlignTrailingComments: false # Should be off, causes many dummy problems!!
11-
#AllowAllParametersOfDeclarationOnNextLine: true
12-
AllowShortBlocksOnASingleLine: true
13-
#AllowShortCaseLabelsOnASingleLine: false
14-
#AllowShortFunctionsOnASingleLine: Empty
15-
#AllowShortIfStatementsOnASingleLine: false
16-
#AllowShortLoopsOnASingleLine: false
17-
#AlwaysBreakAfterDefinitionReturnType: None
18-
#AlwaysBreakAfterReturnType: None
19-
#AlwaysBreakBeforeMultilineStrings: true
20-
#AlwaysBreakTemplateDeclarations: true
21-
#BinPackArguments: false
22-
#BinPackParameters: false
23-
#BraceWrapping:
24-
#AfterClass: false
25-
#AfterControlStatement: false
26-
#AfterEnum: false
27-
#AfterFunction: false
28-
#AfterNamespace: false
29-
#AfterObjCDeclaration: false
30-
#AfterStruct: false
31-
#AfterUnion: false
32-
#BeforeCatch: false
33-
#BeforeElse: true
34-
#IndentBraces: false
35-
#BreakBeforeBinaryOperators: None
8+
AllowShortBlocksOnASingleLine: false
369
BreakBeforeBraces: Allman
37-
#BreakBeforeTernaryOperators: true
38-
#BreakConstructorInitializersBeforeComma: false
39-
ColumnLimit: 80
40-
#CommentPragmas: ''
41-
#ConstructorInitializerAllOnOneLineOrOnePerLine: true
42-
#ConstructorInitializerIndentWidth: 4
43-
#ContinuationIndentWidth: 4
44-
#Cpp11BracedListStyle: true
45-
#DerivePointerAlignment: false
46-
#DisableFormat: false
47-
#ExperimentalAutoDetectBinPacking: false
48-
##FixNamespaceComments: true # Not applicable in 3.8
49-
#ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
50-
#IncludeCategories:
51-
#- Regex: '.*'
52-
#Priority: 1
10+
ColumnLimit: 100
5311
IndentCaseLabels: true
54-
IndentWidth: 4
12+
IndentWidth: 4
5513
IndentWrappedFunctionNames: true
56-
#KeepEmptyLinesAtTheStartOfBlocks: true
57-
#MacroBlockBegin: ''
58-
#MacroBlockEnd: ''
5914
MaxEmptyLinesToKeep: 1
6015
NamespaceIndentation: None
61-
#PenaltyBreakBeforeFirstCallParameter: 19
62-
#PenaltyBreakComment: 300
63-
#PenaltyBreakFirstLessLess: 120
64-
#PenaltyBreakString: 1000
65-
#PenaltyExcessCharacter: 1000000
66-
#PenaltyReturnTypeOnItsOwnLine: 200
6716
DerivePointerAlignment: false
68-
#PointerAlignment: Left
69-
ReflowComments: true # Should be true, otherwise clang-format doesn't touch comments
70-
SortIncludes: true
71-
#SpaceAfterCStyleCast: false
17+
ReflowComments: true # Should be true, otherwise clang-format doesn't touch comments
18+
SortIncludes: true
7219
SpaceBeforeAssignmentOperators: true
73-
#SpaceBeforeParens: ControlStatements
74-
#SpaceInEmptyParentheses: false
75-
#SpacesBeforeTrailingComments: 2
76-
#SpacesInAngles: false
77-
#SpacesInContainerLiterals: true
78-
#SpacesInCStyleCastParentheses: false
79-
#SpacesInParentheses: false
80-
#SpacesInSquareBrackets: false
81-
Standard: Cpp11
82-
TabWidth: 4
83-
UseTab: Never # Available options are Never, Always, ForIndentation
20+
Standard: Cpp11
21+
TabWidth: 4
22+
UseTab: Never # Available options are Never, Always, ForIndentation

examples/KDTreeVectorOfVectorsAdaptor.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,10 @@ template <
5454
class Distance = nanoflann::metric_L2, typename IndexType = size_t>
5555
struct KDTreeVectorOfVectorsAdaptor
5656
{
57-
using self_t = KDTreeVectorOfVectorsAdaptor<
58-
VectorOfVectorsType, num_t, DIM, Distance, IndexType>;
59-
using metric_t =
60-
typename Distance::template traits<num_t, self_t>::distance_t;
61-
using index_t =
62-
nanoflann::KDTreeSingleIndexAdaptor<metric_t, self_t, DIM, IndexType>;
57+
using self_t =
58+
KDTreeVectorOfVectorsAdaptor<VectorOfVectorsType, num_t, DIM, Distance, IndexType>;
59+
using metric_t = typename Distance::template traits<num_t, self_t>::distance_t;
60+
using index_t = nanoflann::KDTreeSingleIndexAdaptor<metric_t, self_t, DIM, IndexType>;
6361

6462
/** The kd-tree index for the user to call its methods as usual with any
6563
* other FLANN index */
@@ -81,8 +79,7 @@ struct KDTreeVectorOfVectorsAdaptor
8179
index = new index_t(
8280
static_cast<int>(dims), *this /* adaptor */,
8381
nanoflann::KDTreeSingleIndexAdaptorParams(
84-
leaf_max_size, nanoflann::KDTreeSingleIndexAdaptorFlags::None,
85-
n_thread_build));
82+
leaf_max_size, nanoflann::KDTreeSingleIndexAdaptorFlags::None, n_thread_build));
8683
}
8784

8885
~KDTreeVectorOfVectorsAdaptor() { delete index; }
@@ -95,8 +92,8 @@ struct KDTreeVectorOfVectorsAdaptor
9592
* The user can also call index->... methods as desired.
9693
*/
9794
inline void query(
98-
const num_t* query_point, const size_t num_closest,
99-
IndexType* out_indices, num_t* out_distances_sq) const
95+
const num_t* query_point, const size_t num_closest, IndexType* out_indices,
96+
num_t* out_distances_sq) const
10097
{
10198
nanoflann::KNNResultSet<num_t, IndexType> resultSet(num_closest);
10299
resultSet.init(out_indices, out_distances_sq);

examples/SO2_adaptor_example.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ void kdtree_demo(const size_t N)
4545

4646
// construct a kd-tree index:
4747
using my_kd_tree_t = nanoflann::KDTreeSingleIndexAdaptor<
48-
nanoflann::SO2_Adaptor<num_t, PointCloud_Orient<num_t>>,
49-
PointCloud_Orient<num_t>, 1 /* dim */
48+
nanoflann::SO2_Adaptor<num_t, PointCloud_Orient<num_t>>, PointCloud_Orient<num_t>,
49+
1 /* dim */
5050
>;
5151

5252
dump_mem_usage();
@@ -64,8 +64,7 @@ void kdtree_demo(const size_t N)
6464
index.findNeighbors(resultSet, &query_pt[0]);
6565

6666
std::cout << "knnSearch(nn=" << num_results << "): \n";
67-
std::cout << "ret_index=" << ret_index
68-
<< " out_dist_sqr=" << out_dist_sqr << std::endl;
67+
std::cout << "ret_index=" << ret_index << " out_dist_sqr=" << out_dist_sqr << std::endl;
6968
}
7069
}
7170

examples/SO3_adaptor_example.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void kdtree_demo(const size_t N)
4545

4646
// construct a kd-tree index:
4747
using my_kd_tree_t = nanoflann::KDTreeSingleIndexAdaptor<
48-
nanoflann::SO3_Adaptor<num_t, PointCloud_Quat<num_t>>,
49-
PointCloud_Quat<num_t>, 4 /* dim */
48+
nanoflann::SO3_Adaptor<num_t, PointCloud_Quat<num_t>>, PointCloud_Quat<num_t>, 4 /* dim */
5049
>;
5150

5251
dump_mem_usage();
@@ -64,8 +63,7 @@ void kdtree_demo(const size_t N)
6463
index.findNeighbors(resultSet, &query_pt[0]);
6564

6665
std::cout << "knnSearch(nn=" << num_results << "): \n";
67-
std::cout << "ret_index=" << ret_index
68-
<< " out_dist_sqr=" << out_dist_sqr << std::endl;
66+
std::cout << "ret_index=" << ret_index << " out_dist_sqr=" << out_dist_sqr << std::endl;
6967
}
7068
}
7169

examples/dynamic_pointcloud_example.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ void kdtree_demo(const size_t N)
4040

4141
// construct a kd-tree index:
4242
using my_kd_tree_t = nanoflann::KDTreeSingleIndexDynamicAdaptor<
43-
nanoflann::L2_Simple_Adaptor<num_t, PointCloud<num_t>>,
44-
PointCloud<num_t>, 3 /* dim */
43+
nanoflann::L2_Simple_Adaptor<num_t, PointCloud<num_t>>, PointCloud<num_t>, 3 /* dim */
4544
>;
4645

4746
dump_mem_usage();
@@ -78,19 +77,16 @@ void kdtree_demo(const size_t N)
7877
index.findNeighbors(resultSet, query_pt, {10});
7978

8079
std::cout << "knnSearch(nn=" << num_results << "): \n";
81-
std::cout << "ret_index=" << ret_index
82-
<< " out_dist_sqr=" << out_dist_sqr << std::endl;
80+
std::cout << "ret_index=" << ret_index << " out_dist_sqr=" << out_dist_sqr << std::endl;
8381
std::cout << "point: ("
84-
<< "point: (" << cloud.pts[ret_index].x << ", "
85-
<< cloud.pts[ret_index].y << ", " << cloud.pts[ret_index].z
86-
<< ")" << std::endl;
82+
<< "point: (" << cloud.pts[ret_index].x << ", " << cloud.pts[ret_index].y << ", "
83+
<< cloud.pts[ret_index].z << ")" << std::endl;
8784
std::cout << std::endl;
8885
}
8986
{
9087
// do a knn search searching for more than one result
9188
const size_t num_results = 5;
92-
std::cout << "Searching for " << num_results << " elements"
93-
<< std::endl;
89+
std::cout << "Searching for " << num_results << " elements" << std::endl;
9490
size_t ret_index[num_results];
9591
num_t out_dist_sqr[num_results];
9692
nanoflann::KNNResultSet<num_t> resultSet(num_results);
@@ -105,8 +101,8 @@ void kdtree_demo(const size_t N)
105101
<< "index: " << ret_index[i] << ",\t"
106102
<< "dist: " << out_dist_sqr[i] << ",\t"
107103
<< "point: (" << cloud.pts[ret_index[i]].x << ", "
108-
<< cloud.pts[ret_index[i]].y << ", "
109-
<< cloud.pts[ret_index[i]].z << ")" << std::endl;
104+
<< cloud.pts[ret_index[i]].y << ", " << cloud.pts[ret_index[i]].z << ")"
105+
<< std::endl;
110106
}
111107
std::cout << std::endl;
112108
}
@@ -115,18 +111,16 @@ void kdtree_demo(const size_t N)
115111
std::cout << "Unsorted radius search" << std::endl;
116112
const num_t radiusSqr = 1;
117113
std::vector<nanoflann::ResultItem<size_t, num_t>> indices_dists;
118-
nanoflann::RadiusResultSet<num_t, size_t> resultSet(
119-
radiusSqr, indices_dists);
114+
nanoflann::RadiusResultSet<num_t, size_t> resultSet(radiusSqr, indices_dists);
120115

121116
index.findNeighbors(resultSet, query_pt);
122117

123-
nanoflann::ResultItem<size_t, num_t> worst_pair =
124-
resultSet.worst_item();
125-
std::cout << "Worst pair: idx=" << worst_pair.first
126-
<< " dist=" << worst_pair.second << std::endl;
118+
nanoflann::ResultItem<size_t, num_t> worst_pair = resultSet.worst_item();
119+
std::cout << "Worst pair: idx=" << worst_pair.first << " dist=" << worst_pair.second
120+
<< std::endl;
127121
std::cout << "point: (" << cloud.pts[worst_pair.first].x << ", "
128-
<< cloud.pts[worst_pair.first].y << ", "
129-
<< cloud.pts[worst_pair.first].z << ")" << std::endl;
122+
<< cloud.pts[worst_pair.first].y << ", " << cloud.pts[worst_pair.first].z << ")"
123+
<< std::endl;
130124
std::cout << std::endl;
131125
}
132126
}

examples/example_with_cmake/pointcloud_example.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void kdtree_demo(const size_t N)
4545

4646
// construct a kd-tree index:
4747
using my_kd_tree_t = nanoflann::KDTreeSingleIndexAdaptor<
48-
nanoflann::L2_Simple_Adaptor<num_t, PointCloud<num_t>>,
49-
PointCloud<num_t>, 3 /* dim */
48+
nanoflann::L2_Simple_Adaptor<num_t, PointCloud<num_t>>, PointCloud<num_t>, 3 /* dim */
5049
>;
5150

5251
dump_mem_usage();
@@ -61,26 +60,23 @@ void kdtree_demo(const size_t N)
6160
num_t out_dist_sqr;
6261
nanoflann::KNNResultSet<num_t> resultSet(num_results);
6362
resultSet.init(&ret_index, &out_dist_sqr);
64-
index.findNeighbors(
65-
resultSet, &query_pt[0], nanoflann::SearchParams(10));
63+
index.findNeighbors(resultSet, &query_pt[0], nanoflann::SearchParams(10));
6664

6765
std::cout << "knnSearch(nn=" << num_results << "): \n";
68-
std::cout << "ret_index=" << ret_index
69-
<< " out_dist_sqr=" << out_dist_sqr << std::endl;
66+
std::cout << "ret_index=" << ret_index << " out_dist_sqr=" << out_dist_sqr << std::endl;
7067
}
7168
{
7269
// Unsorted radius search:
7370
const num_t radius = 1;
7471
std::vector<std::pair<size_t, num_t>> indices_dists;
75-
nanoflann::RadiusResultSet<num_t, size_t> resultSet(
76-
radius, indices_dists);
72+
nanoflann::RadiusResultSet<num_t, size_t> resultSet(radius, indices_dists);
7773

7874
index.findNeighbors(resultSet, query_pt, nanoflann::SearchParams());
7975

8076
// Get worst (furthest) point, without sorting:
8177
std::pair<size_t, num_t> worst_pair = resultSet.worst_item();
82-
std::cout << "Worst pair: idx=" << worst_pair.first
83-
<< " dist=" << worst_pair.second << std::endl;
78+
std::cout << "Worst pair: idx=" << worst_pair.first << " dist=" << worst_pair.second
79+
<< std::endl;
8480
}
8581
}
8682

examples/example_with_pkgconfig/pointcloud_example.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void kdtree_demo(const size_t N)
4545

4646
// construct a kd-tree index:
4747
using my_kd_tree_t = nanoflann::KDTreeSingleIndexAdaptor<
48-
nanoflann::L2_Simple_Adaptor<num_t, PointCloud<num_t>>,
49-
PointCloud<num_t>, 3 /* dim */
48+
nanoflann::L2_Simple_Adaptor<num_t, PointCloud<num_t>>, PointCloud<num_t>, 3 /* dim */
5049
>;
5150

5251
dump_mem_usage();
@@ -61,26 +60,23 @@ void kdtree_demo(const size_t N)
6160
num_t out_dist_sqr;
6261
nanoflann::KNNResultSet<num_t> resultSet(num_results);
6362
resultSet.init(&ret_index, &out_dist_sqr);
64-
index.findNeighbors(
65-
resultSet, &query_pt[0], nanoflann::SearchParams(10));
63+
index.findNeighbors(resultSet, &query_pt[0], nanoflann::SearchParams(10));
6664

6765
std::cout << "knnSearch(nn=" << num_results << "): \n";
68-
std::cout << "ret_index=" << ret_index
69-
<< " out_dist_sqr=" << out_dist_sqr << std::endl;
66+
std::cout << "ret_index=" << ret_index << " out_dist_sqr=" << out_dist_sqr << std::endl;
7067
}
7168
{
7269
// Unsorted radius search:
7370
const num_t radius = 1;
7471
std::vector<std::pair<size_t, num_t>> indices_dists;
75-
nanoflann::RadiusResultSet<num_t, size_t> resultSet(
76-
radius, indices_dists);
72+
nanoflann::RadiusResultSet<num_t, size_t> resultSet(radius, indices_dists);
7773

7874
index.findNeighbors(resultSet, query_pt, nanoflann::SearchParams());
7975

8076
// Get worst (furthest) point, without sorting:
8177
std::pair<size_t, num_t> worst_pair = resultSet.worst_item();
82-
std::cout << "Worst pair: idx=" << worst_pair.first
83-
<< " dist=" << worst_pair.second << std::endl;
78+
std::cout << "Worst pair: idx=" << worst_pair.first << " dist=" << worst_pair.second
79+
<< std::endl;
8480
}
8581
}
8682

examples/examples_gui/nanoflann_gui_example_R3/nanoflann_gui_example_R3.cpp

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
mrpt::opengl::CPointCloud::Ptr pc_to_viz(const PointCloud<double>& pc)
4545
{
4646
auto gl = mrpt::opengl::CPointCloud::Create();
47-
for (const auto pt : pc.pts) { gl->insertPoint(pt.x, pt.y, pt.z); }
47+
for (const auto pt : pc.pts)
48+
{
49+
gl->insertPoint(pt.x, pt.y, pt.z);
50+
}
4851
gl->setPointSize(3.0f);
4952
return gl;
5053
}
@@ -91,8 +94,7 @@ void kdtree_demo(const size_t N)
9194

9295
// construct a kd-tree index:
9396
using my_kd_tree_t = nanoflann::KDTreeSingleIndexAdaptor<
94-
nanoflann::L2_Simple_Adaptor<double, PointCloud<double>>,
95-
PointCloud<double>, 3 /* dim */
97+
nanoflann::L2_Simple_Adaptor<double, PointCloud<double>>, PointCloud<double>, 3 /* dim */
9698
>;
9799

98100
mrpt::system::CTimeLogger profiler;
@@ -127,22 +129,19 @@ void kdtree_demo(const size_t N)
127129
const size_t nnToSearch = (rng.drawUniform32bit() % 10) + 1;
128130
#endif
129131
const double queryPt[3] = {
130-
rng.drawUniform(-0.3, maxRangeXY + 0.3),
131-
rng.drawUniform(-0.3, maxRangeXY + 0.3),
132+
rng.drawUniform(-0.3, maxRangeXY + 0.3), rng.drawUniform(-0.3, maxRangeXY + 0.3),
132133
rng.drawUniform(-0.3, maxRangeZ + 0.3)};
133134

134135
mrpt::system::CTimeLoggerEntry tle2(profiler, "query");
135136

136137
#if defined(USE_RADIUS_SEARCH)
137138
indicesDists.clear();
138-
nanoflann::RadiusResultSet<double, size_t> resultSet(
139-
sqRadius, indicesDists);
139+
nanoflann::RadiusResultSet<double, size_t> resultSet(sqRadius, indicesDists);
140140
index.findNeighbors(resultSet, queryPt);
141141
#else
142142

143143
#if defined(USE_RKNN_SEARCH)
144-
nanoflann::RKNNResultSet<double, size_t> resultSet(
145-
nnToSearch, sqRadius);
144+
nanoflann::RKNNResultSet<double, size_t> resultSet(nnToSearch, sqRadius);
146145
#elif defined(USE_KNN_SEARCH)
147146
nanoflann::KNNResultSet<double, size_t> resultSet(nnToSearch);
148147
#else
@@ -162,20 +161,17 @@ void kdtree_demo(const size_t N)
162161
#endif
163162
tle2.stop();
164163

165-
std::cout << "\nQuery point: (" << queryPt[0] << "," << queryPt[1]
166-
<< "," << queryPt[2] << ") => " << resultSet.size()
167-
<< " results.\n";
164+
std::cout << "\nQuery point: (" << queryPt[0] << "," << queryPt[1] << "," << queryPt[2]
165+
<< ") => " << resultSet.size() << " results.\n";
168166

169167
if (!resultSet.empty())
170168
{
171169
#if defined(USE_RADIUS_SEARCH)
172-
nanoflann::ResultItem<size_t, double> worstPair =
173-
resultSet.worst_item();
170+
nanoflann::ResultItem<size_t, double> worstPair = resultSet.worst_item();
174171
std::cout << "Worst pair: idx=" << worstPair.first
175172
<< " dist=" << std::sqrt(worstPair.second) << std::endl;
176173
#else
177-
std::cout << "nnToSearch=" << nnToSearch
178-
<< " actual found=" << indices.size()
174+
std::cout << "nnToSearch=" << nnToSearch << " actual found=" << indices.size()
179175
<< " Worst found dist=" << worstDist << std::endl;
180176
#endif
181177
}

0 commit comments

Comments
 (0)