Skip to content

Commit 7a1bdd5

Browse files
committed
fix a bunch of warnings
1 parent 4edd442 commit 7a1bdd5

17 files changed

+77
-65
lines changed

bindings/c/rect.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,13 @@ ManifoldRect *manifold_rect_transform(void *mem, ManifoldRect *r, double x1,
8080

8181
ManifoldRect *manifold_rect_translate(void *mem, ManifoldRect *r, double x,
8282
double y) {
83-
auto rect = *from_c(r);
8483
auto p = vec2(x, y);
8584
auto translated = (*from_c(r)) + p;
8685
return to_c(new (mem) Rect(translated));
8786
}
8887

8988
ManifoldRect *manifold_rect_mul(void *mem, ManifoldRect *r, double x,
9089
double y) {
91-
auto rect = *from_c(r);
9290
auto p = vec2(x, y);
9391
auto scaled = (*from_c(r)) * p;
9492
return to_c(new (mem) Rect(scaled));

include/manifold/linalg.h

-2
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,12 @@
3737

3838
#include <array> // For std::array
3939
#include <cmath> // For various unary math functions, such as std::sqrt
40-
#include <cstdint> // For implementing namespace linalg::aliases
4140
#include <cstdlib> // To resolve std::abs ambiguity on clang
4241
#include <functional> // For std::hash declaration
4342
#include <iosfwd> // For forward definitions of std::ostream
4443
#include <type_traits> // For std::enable_if, std::is_same, std::declval
4544

4645
#ifdef MANIFOLD_DEBUG
47-
#include <iomanip>
4846
#include <iostream>
4947
#endif
5048

src/boolean3.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ std::tuple<Vec<int>, Vec<vec3>> Intersect12(const Manifold::Impl &inP,
402402
a.vertPos_[tmpedges[e].second]);
403403
});
404404
Kernel12 k12{a.halfedge_, b.halfedge_, a.vertPos_, forward, k02, k11};
405-
Kernel12Recorder recorder{k12, tmpedges, forward};
405+
Kernel12Recorder recorder{k12, tmpedges, forward, {}};
406406

407407
b.collider_.Collisions<false, Box, Kernel12Recorder>(AEdgeBB.cview(),
408408
recorder);

src/boolean_result.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ void AddNewEdgeVerts(
273273
return;
274274
}
275275
#endif
276-
auto processFun = std::bind(
277-
process, [](size_t _) {}, [](size_t _) {}, std::placeholders::_1);
276+
auto processFun =
277+
std::bind(process, [](size_t) {}, [](size_t) {}, std::placeholders::_1);
278278
for (size_t i = 0; i < p1q2.size(); ++i) processFun(i);
279279
}
280280

src/constructors.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ Manifold Manifold::Sphere(double radius, int circularSegments) {
173173
int n = circularSegments > 0 ? (circularSegments + 3) / 4
174174
: Quality::GetCircularSegments(radius) / 4;
175175
auto pImpl_ = std::make_shared<Impl>(Impl::Shape::Octahedron);
176-
pImpl_->Subdivide(
177-
[n](vec3 edge, vec4 tangentStart, vec4 tangentEnd) { return n - 1; });
176+
pImpl_->Subdivide([n](vec3, vec4, vec4) { return n - 1; });
178177
for_each_n(autoPolicy(pImpl_->NumVert(), 1e5), pImpl_->vertPos_.begin(),
179178
pImpl_->NumVert(), [radius](vec3& v) {
180179
v = la::cos(kHalfPi * (1.0 - v));

src/csg_tree.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include "./mesh_fixes.h"
2525
#include "./parallel.h"
2626

27-
constexpr int kParallelThreshold = 4096;
28-
2927
namespace {
3028
using namespace manifold;
3129
struct MeshCompare {
@@ -234,11 +232,10 @@ std::shared_ptr<CsgLeafNode> CsgLeafNode::Compose(
234232
combined.halfedgeTangent_.begin() + edgeIndices[i]);
235233
const int nextVert = vertIndices[i];
236234
const int nextEdge = edgeIndices[i];
237-
const int nextFace = triIndices[i];
238235
transform(node->pImpl_->halfedge_.begin(),
239236
node->pImpl_->halfedge_.end(),
240237
combined.halfedge_.begin() + edgeIndices[i],
241-
[nextVert, nextEdge, nextFace](Halfedge edge) {
238+
[nextVert, nextEdge](Halfedge edge) {
242239
edge.startVert += nextVert;
243240
edge.endVert += nextVert;
244241
edge.pairedHalfedge += nextEdge;

src/edge_op.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ void Manifold::Impl::SimplifyTopology(int firstNewVert) {
240240
}
241241

242242
const size_t nbEdges = halfedge_.size();
243-
auto policy = autoPolicy(nbEdges, 1e5);
244243
size_t numFlagged = 0;
245244

246245
std::vector<int> scratchBuffer;
@@ -338,7 +337,6 @@ void Manifold::Impl::DedupeEdge(const int edge) {
338337
UpdateVert(newVert, current, opposite);
339338

340339
int newHalfedge = halfedge_.size();
341-
int newFace = newHalfedge / 3;
342340
int oldFace = current / 3;
343341
int outsideVert = halfedge_[current].startVert;
344342
halfedge_.push_back({endVert, newVert, -1});
@@ -354,7 +352,6 @@ void Manifold::Impl::DedupeEdge(const int edge) {
354352
if (faceNormal_.size() > 0) faceNormal_.push_back(faceNormal_[oldFace]);
355353

356354
newHalfedge += 3;
357-
++newFace;
358355
oldFace = opposite / 3;
359356
outsideVert = halfedge_[opposite].startVert;
360357
halfedge_.push_back({newVert, endVert, -1});
@@ -842,8 +839,7 @@ void Manifold::Impl::DedupeEdges() {
842839

843840
// first iteration, populate entries
844841
// this makes sure we always report the same set of entries
845-
ForVert(i, [&local, &endVerts, &endVertSet, &results,
846-
this](int current) {
842+
ForVert(i, [&local, &endVerts, &endVertSet, this](int current) {
847843
local[current] = true;
848844
if (halfedge_[current].startVert == -1 ||
849845
halfedge_[current].endVert == -1) {
@@ -873,8 +869,7 @@ void Manifold::Impl::DedupeEdges() {
873869
// second iteration, actually check for duplicates
874870
// we always report the same set of duplicates, excluding the smallest
875871
// halfedge in the set of duplicates
876-
ForVert(i, [&local, &endVerts, &endVertSet, &results,
877-
this](int current) {
872+
ForVert(i, [&endVerts, &endVertSet, &results, this](int current) {
878873
if (halfedge_[current].startVert == -1 ||
879874
halfedge_[current].endVert == -1) {
880875
return;

src/face_op.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void Manifold::Impl::Face2Tri(const Vec<int>& faceEdge,
232232
triRef.reserve(faceEdge.size());
233233
auto processFace2 = std::bind(
234234
processFace, generalTriangulation,
235-
[&](size_t _face, ivec3 tri, vec3 normal, TriRef r) {
235+
[&](size_t, ivec3 tri, vec3 normal, TriRef r) {
236236
triVerts.push_back(tri);
237237
triNormal.push_back(normal);
238238
triRef.push_back(r);
@@ -247,9 +247,10 @@ void Manifold::Impl::Face2Tri(const Vec<int>& faceEdge,
247247
CreateHalfedges(triVerts);
248248
}
249249

250+
constexpr uint64_t kRemove = std::numeric_limits<uint64_t>::max();
251+
250252
void Manifold::Impl::FlattenFaces() {
251253
Vec<uint64_t> edgeFace(halfedge_.size());
252-
constexpr uint64_t remove = std::numeric_limits<uint64_t>::max();
253254
const size_t numTri = NumTri();
254255
const auto policy = autoPolicy(numTri);
255256

@@ -258,17 +259,17 @@ void Manifold::Impl::FlattenFaces() {
258259
[](auto& v) { v.store(0); });
259260

260261
for_each_n(policy, countAt(0_uz), numTri,
261-
[&edgeFace, &vertDegree, remove, this](size_t tri) {
262+
[&edgeFace, &vertDegree, this](size_t tri) {
262263
for (const int i : {0, 1, 2}) {
263264
const int edge = 3 * tri + i;
264265
const int pair = halfedge_[edge].pairedHalfedge;
265266
if (pair < 0) {
266-
edgeFace[edge] = remove;
267+
edgeFace[edge] = kRemove;
267268
return;
268269
}
269270
const auto& ref = meshRelation_.triRef[tri];
270271
if (ref.SameFace(meshRelation_.triRef[pair / 3])) {
271-
edgeFace[edge] = remove;
272+
edgeFace[edge] = kRemove;
272273
} else {
273274
edgeFace[edge] = (static_cast<uint64_t>(ref.meshID) << 32) +
274275
static_cast<uint64_t>(ref.faceID);
@@ -284,7 +285,7 @@ void Manifold::Impl::FlattenFaces() {
284285
[&edgeFace](size_t a, size_t b) { return edgeFace[a] < edgeFace[b]; });
285286
newHalf2Old.resize(std::find_if(countAt(0_uz), countAt(halfedge_.size()),
286287
[&](const size_t i) {
287-
return edgeFace[newHalf2Old[i]] == remove;
288+
return edgeFace[newHalf2Old[i]] == kRemove;
288289
}) -
289290
countAt(0_uz));
290291

src/impl.cpp

+19-25
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@
3535
namespace {
3636
using namespace manifold;
3737

38-
constexpr uint64_t kRemove = std::numeric_limits<uint64_t>::max();
39-
4038
// Absolute error <= 6.7e-5
41-
float acos(float x) {
39+
float fastacos(float x) {
4240
float negate = float(x < 0);
43-
x = abs(x);
41+
x = std::abs(x);
4442
float ret = -0.0187293;
4543
ret = ret * x;
4644
ret = ret + 0.0742610;
@@ -240,7 +238,6 @@ void Manifold::Impl::DedupePropVerts() {
240238
autoPolicy(halfedge_.size(), 1e4), countAt(0), halfedge_.size(),
241239
[&vert2vert, numProp, this](const int edgeIdx) {
242240
const Halfedge edge = halfedge_[edgeIdx];
243-
const Halfedge pair = halfedge_[edge.pairedHalfedge];
244241
const int edgeFace = edgeIdx / 3;
245242
const int pairFace = edge.pairedHalfedge / 3;
246243

@@ -278,6 +275,8 @@ void Manifold::Impl::DedupePropVerts() {
278275
for (int i : {0, 1, 2}) prop[i] = label2vert[vertLabels[prop[i]]];
279276
}
280277

278+
constexpr int removedHalfedge = -2;
279+
281280
/**
282281
* Create the halfedge_ data structure from an input triVerts array like Mesh.
283282
*/
@@ -319,9 +318,7 @@ void Manifold::Impl::CreateHalfedges(const Vec<ivec3>& triVerts) {
319318
// which are removed later by RemoveUnreferencedVerts() and Finish().
320319
const int numEdge = numHalfedge / 2;
321320

322-
constexpr int removedHalfedge = -2;
323-
const auto body = [&, removedHalfedge](int i, int consecutiveStart,
324-
int segmentEnd) {
321+
const auto body = [&](int i, int consecutiveStart, int segmentEnd) {
325322
const int pair0 = ids[i];
326323
Halfedge& h0 = halfedge_[pair0];
327324
int k = consecutiveStart + numEdge;
@@ -380,17 +377,16 @@ void Manifold::Impl::CreateHalfedges(const Vec<ivec3>& triVerts) {
380377
// Once sorted, the first half of the range is the forward halfedges, which
381378
// correspond to their backward pair at the same offset in the second half
382379
// of the range.
383-
for_each_n(policy, countAt(0), numEdge,
384-
[this, &ids, numEdge, removedHalfedge](int i) {
385-
const int pair0 = ids[i];
386-
const int pair1 = ids[i + numEdge];
387-
if (halfedge_[pair0].pairedHalfedge != removedHalfedge) {
388-
halfedge_[pair0].pairedHalfedge = pair1;
389-
halfedge_[pair1].pairedHalfedge = pair0;
390-
} else {
391-
halfedge_[pair0] = halfedge_[pair1] = {-1, -1, -1};
392-
}
393-
});
380+
for_each_n(policy, countAt(0), numEdge, [this, &ids, numEdge](int i) {
381+
const int pair0 = ids[i];
382+
const int pair1 = ids[i + numEdge];
383+
if (halfedge_[pair0].pairedHalfedge != removedHalfedge) {
384+
halfedge_[pair0].pairedHalfedge = pair1;
385+
halfedge_[pair1].pairedHalfedge = pair0;
386+
} else {
387+
halfedge_[pair0] = halfedge_[pair1] = {-1, -1, -1};
388+
}
389+
});
394390
}
395391

396392
/**
@@ -529,7 +525,6 @@ void Manifold::Impl::CalculateNormals() {
529525
ZoneScoped;
530526
vertNormal_.resize(NumVert());
531527
auto policy = autoPolicy(NumTri());
532-
bool calculateTriNormal = false;
533528

534529
std::vector<std::atomic<int>> vertHalfedgeMap(NumVert());
535530
for_each_n(policy, countAt(0), NumVert(), [&](const size_t vert) {
@@ -544,7 +539,6 @@ void Manifold::Impl::CalculateNormals() {
544539
};
545540
if (faceNormal_.size() != NumTri()) {
546541
faceNormal_.resize(NumTri());
547-
calculateTriNormal = true;
548542
for_each_n(policy, countAt(0), NumTri(), [&](const int face) {
549543
vec3& triNormal = faceNormal_[face];
550544
if (halfedge_[3 * face].startVert < 0) {
@@ -592,7 +586,7 @@ void Manifold::Impl::CalculateNormals() {
592586
// should just exclude it from the normal calculation...
593587
if (!la::isfinite(currEdge[0]) || !la::isfinite(prevEdge[0])) return;
594588
double dot = -la::dot(prevEdge, currEdge);
595-
double phi = dot >= 1 ? 0 : (dot <= -1 ? kPi : acos(dot));
589+
double phi = dot >= 1 ? 0 : (dot <= -1 ? kPi : fastacos(dot));
596590
normal += phi * faceNormal_[edge / 3];
597591
});
598592
vertNormal_[vert] = SafeNormalize(normal);
@@ -673,7 +667,7 @@ Manifold Manifold::ImportMeshGL64(std::istream& stream) {
673667
stream.get(tmp.data(), SIZE, '\n');
674668
if (strncmp(tmp.data(), "tolerance", SIZE) == 0) {
675669
// skip 3 letters
676-
for (int i : {0, 1, 2}) stream.get();
670+
for (int _ : {0, 1, 2}) stream.get();
677671
stream >> mesh.tolerance;
678672
} else if (strncmp(tmp.data(), "epsilon =", SIZE) == 0) {
679673
double tmp;
@@ -694,14 +688,14 @@ Manifold Manifold::ImportMeshGL64(std::istream& stream) {
694688
break;
695689
}
696690
case 'v':
697-
for (int i : {0, 1, 2}) {
691+
for (int _ : {0, 1, 2}) {
698692
double x;
699693
stream >> x;
700694
mesh.vertProperties.push_back(x);
701695
}
702696
break;
703697
case 'f':
704-
for (int i : {0, 1, 2}) {
698+
for (int _ : {0, 1, 2}) {
705699
uint64_t x;
706700
stream >> x;
707701
mesh.triVerts.push_back(x - 1);

src/impl.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "./shared.h"
2020
#include "./vec.h"
2121
#include "manifold/manifold.h"
22-
#include "manifold/polygon.h"
2322

2423
namespace manifold {
2524

src/manifold.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ Manifold Manifold::SetProperties(
662662
{pImpl->meshRelation_.properties.data(), numProp,
663663
oldProperties.data(), oldNumProp, pImpl->vertPos_.data(),
664664
triProperties.data(), pImpl->halfedge_.data(),
665-
propFunc == nullptr ? [](double* newProp, vec3 position,
666-
const double* oldProp) { *newProp = 0; }
667-
: propFunc}));
665+
propFunc == nullptr
666+
? [](double* newProp, vec3, const double*) { *newProp = 0; }
667+
: propFunc}));
668668
}
669669

670670
pImpl->meshRelation_.numProp = numProp;
@@ -784,8 +784,7 @@ Manifold Manifold::SmoothOut(double minSharpAngle, double minSmoothness) const {
784784
Manifold Manifold::Refine(int n) const {
785785
auto pImpl = std::make_shared<Impl>(*GetCsgLeafNode().GetImpl());
786786
if (n > 1) {
787-
pImpl->Refine(
788-
[n](vec3 edge, vec4 tangentStart, vec4 tangentEnd) { return n - 1; });
787+
pImpl->Refine([n](vec3, vec4, vec4) { return n - 1; });
789788
}
790789
return Manifold(std::make_shared<CsgLeafNode>(pImpl));
791790
}
@@ -803,7 +802,7 @@ Manifold Manifold::Refine(int n) const {
803802
Manifold Manifold::RefineToLength(double length) const {
804803
length = std::abs(length);
805804
auto pImpl = std::make_shared<Impl>(*GetCsgLeafNode().GetImpl());
806-
pImpl->Refine([length](vec3 edge, vec4 tangentStart, vec4 tangentEnd) {
805+
pImpl->Refine([length](vec3 edge, vec4, vec4) {
807806
return static_cast<int>(la::length(edge) / length);
808807
});
809808
return Manifold(std::make_shared<CsgLeafNode>(pImpl));

0 commit comments

Comments
 (0)