Skip to content

Commit be52fc2

Browse files
committed
Minor updates (#65)
* Update SimpleMesh so that it can be used with the new ICP option (with normal orientation taken into account) * Attempt to reduce level 4 warnings (and potential bug fix in the SquareMatrix::svd method)
1 parent 4b036e0 commit be52fc2

12 files changed

+129
-70
lines changed

include/GenericIndexedCloud.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ namespace CCCoreLib
4949
//! If per-point normals are available, returns the one at a specific index
5050
/** \warning If overriden, this method should return a valid normal for all points
5151
**/
52-
virtual const CCVector3* getNormal(unsigned index) const { return nullptr; }
52+
virtual const CCVector3* getNormal(unsigned index) const { (void)index; return nullptr; }
5353
};
5454
}

include/GenericIndexedMesh.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ namespace CCCoreLib
8787
\param[out] N interpolated normal
8888
\return success
8989
**/
90-
virtual bool interpolateNormals(unsigned triIndex, const CCVector3& P, CCVector3& N) { return false; }
90+
virtual bool interpolateNormals(unsigned triIndex, const CCVector3& P, CCVector3& N) { (void)triIndex; (void)P; (void)N; return false; }
9191
};
9292
}
9393

include/Jacobi.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,19 +269,19 @@ namespace CCCoreLib
269269
{
270270
for (unsigned iq = ip + 1; iq < n; iq++)
271271
{
272-
Scalar g = std::abs(matrix.m_values[ip][iq]) * 100;
272+
Scalar pq = std::abs(matrix.m_values[ip][iq]) * 100;
273273
//After four sweeps, skip the rotation if the off-diagonal element is small.
274274
if (i > 4
275-
&& static_cast<float>(std::abs(d[ip]) + g) == static_cast<float>(std::abs(d[ip]))
276-
&& static_cast<float>(std::abs(d[iq]) + g) == static_cast<float>(std::abs(d[iq])))
275+
&& static_cast<float>(std::abs(d[ip]) + pq) == static_cast<float>(std::abs(d[ip]))
276+
&& static_cast<float>(std::abs(d[iq]) + pq) == static_cast<float>(std::abs(d[iq])))
277277
{
278278
matrix.m_values[ip][iq] = 0;
279279
}
280280
else if (std::abs(matrix.m_values[ip][iq]) > tresh)
281281
{
282282
Scalar h = d[iq] - d[ip];
283283
Scalar t = 0;
284-
if (static_cast<float>(std::abs(h) + g) == static_cast<float>(std::abs(h)))
284+
if (static_cast<float>(std::abs(h) + pq) == static_cast<float>(std::abs(h)))
285285
{
286286
t = matrix.m_values[ip][iq] / h;
287287
}

include/SimpleMesh.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ namespace CCCoreLib
4040
GenericTriangle* _getTriangle(unsigned triangleIndex) override; //temporary
4141
VerticesIndexes* getNextTriangleVertIndexes() override;
4242
VerticesIndexes* getTriangleVertIndexes(unsigned triangleIndex) override;
43-
unsigned size() const override { return static_cast<unsigned>(m_triIndexes.size()); }
43+
unsigned size() const override { return static_cast<unsigned>(triIndexes.size()); }
4444
void getBoundingBox(CCVector3& bbMin, CCVector3& bbMax) override;
4545
void getTriangleVertices(unsigned triangleIndex, CCVector3& A, CCVector3& B, CCVector3& C) const override;
4646

4747
public: //specific methods
4848

4949
//! Returns the mesh capacity
50-
inline unsigned capacity() const { return static_cast<unsigned>(m_triIndexes.capacity()); }
50+
inline unsigned capacity() const { return static_cast<unsigned>(triIndexes.capacity()); }
5151

5252
//! Returns the vertices
5353
inline const GenericIndexedCloud* vertices() const { return theVertices; }
5454

5555
//! Clears the mesh
56-
inline void clear() { m_triIndexes.resize(0); }
56+
inline void clear() { triIndexes.resize(0); }
5757

5858
//! Adds a triangle to the mesh
5959
/** Vertex indexes are expresesed relatively to the vertex cloud.
@@ -77,12 +77,16 @@ namespace CCCoreLib
7777
**/
7878
virtual bool resize(unsigned n);
7979

80+
//inherited from GenericIndexedMesh
81+
bool normalsAvailable() const override;
82+
bool interpolateNormals(unsigned triIndex, const CCVector3& P, CCVector3& N) override;
83+
8084
protected:
8185

8286
//! A triangle vertices indexes container
8387
using TriangleIndexesContainer = std::vector<VerticesIndexes>;
8488
//! The triangles indexes
85-
TriangleIndexesContainer m_triIndexes;
89+
TriangleIndexesContainer triIndexes;
8690

8791
//! Iterator on the list of triangles
8892
unsigned globalIterator;

include/SquareMatrix.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,6 @@ namespace CCCoreLib
714714
if (m_matrixSize < 0)
715715
return false;
716716

717-
unsigned sqMatrixSize = m_matrixSize * m_matrixSize;
718-
719717
// S : copy of the current matrix
720718
SquareMatrixTpl S_(*this);
721719

@@ -1066,9 +1064,9 @@ namespace CCCoreLib
10661064
}
10671065
else
10681066
{
1069-
Scalar b = (C[0][0] - C[1][1]) / 2;
1070-
Scalar c = -C[0][1] * C[1][0];
1071-
if (b*b - c > 0)
1067+
b = (C[0][0] - C[1][1]) / 2;
1068+
c = -C[0][1] * C[1][0];
1069+
if (b * b - c > 0)
10721070
d = sqrt(b*b - c);
10731071
}
10741072

src/AutoSegmentationTools.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,22 @@ bool AutoSegmentationTools::frontPropagationBasedSegmentation( GenericIndexedClo
169169

170170
//on va faire la propagation avec le FastMarching();
171171
FastMarchingForPropagation* fm = new FastMarchingForPropagation();
172-
173-
fm->setJumpCoef(50.0);
174-
fm->setDetectionThreshold(alpha);
175-
176-
int result = fm->init(theCloud, theOctree, octreeLevel);
177-
int octreeLength = DgmOctree::OCTREE_LENGTH(octreeLevel) - 1;
178-
179-
if (result < 0)
180172
{
181-
if (!inputOctree)
173+
fm->setJumpCoef(50.0);
174+
fm->setDetectionThreshold(alpha);
175+
176+
int result = fm->init(theCloud, theOctree, octreeLevel);
177+
if (result < 0)
182178
{
183-
delete theOctree;
179+
if (!inputOctree)
180+
{
181+
delete theOctree;
182+
}
183+
delete fm;
184+
return false;
184185
}
185-
delete fm;
186-
return false;
187186
}
187+
int octreeLength = DgmOctree::OCTREE_LENGTH(octreeLevel) - 1;
188188

189189
if (progressCb)
190190
{
@@ -243,7 +243,7 @@ bool AutoSegmentationTools::frontPropagationBasedSegmentation( GenericIndexedClo
243243
}
244244

245245
//on finit la recherche du max
246-
for (unsigned i = begin; i<numberOfPoints; ++i)
246+
for (unsigned i = begin; i < numberOfPoints; ++i)
247247
{
248248
const CCVector3 *thePoint = theCloud->getPoint(i);
249249
const ScalarType& theDistance = theDists->at(i);
@@ -268,10 +268,10 @@ bool AutoSegmentationTools::frontPropagationBasedSegmentation( GenericIndexedClo
268268
++seedPoints;
269269
}
270270

271-
int result = fm->propagate();
271+
int resultFM = fm->propagate();
272272

273273
//if the propagation was successful
274-
if (result >= 0)
274+
if (resultFM >= 0)
275275
{
276276
//we extract the corresponding points
277277
ReferenceCloud* newCloud = new ReferenceCloud(theCloud);

src/DgmOctree.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,10 +2015,10 @@ unsigned char DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(Point
20152015
static const PointCoordinateType c_neighbourhoodSizeExtractionFactor = static_cast<PointCoordinateType>(2.5);
20162016
PointCoordinateType aim = std::max<PointCoordinateType>(0, radius / c_neighbourhoodSizeExtractionFactor);
20172017

2018-
int level = 1;
2018+
unsigned char level = 1;
20192019
PointCoordinateType minValue = getCellSize(1) - aim;
20202020
minValue *= minValue;
2021-
for (int i = 2; i <= MAX_OCTREE_LEVEL; ++i)
2021+
for (unsigned char i = 2; i <= static_cast<unsigned char>(MAX_OCTREE_LEVEL); ++i)
20222022
{
20232023
//we need two points per cell ideally
20242024
if (m_averageCellPopulation[i] < 1.5)
@@ -2035,7 +2035,7 @@ unsigned char DgmOctree::findBestLevelForAGivenNeighbourhoodSizeExtraction(Point
20352035
}
20362036
}
20372037

2038-
return static_cast<unsigned char>(level);
2038+
return level;
20392039
}
20402040

20412041
unsigned char DgmOctree::findBestLevelForComparisonWithOctree(const DgmOctree* theOtherOctree) const
@@ -2045,15 +2045,15 @@ unsigned char DgmOctree::findBestLevelForComparisonWithOctree(const DgmOctree* t
20452045

20462046
unsigned char maxOctreeLevel = MAX_OCTREE_LEVEL;
20472047

2048-
if (std::min(ptsA,ptsB) < 16)
2048+
if (std::min(ptsA, ptsB) < 16)
20492049
maxOctreeLevel = std::min(maxOctreeLevel, static_cast<unsigned char>(5)); //very small clouds
2050-
else if (std::max(ptsA,ptsB) < 2000000)
2050+
else if (std::max(ptsA, ptsB) < 2000000)
20512051
maxOctreeLevel = std::min(maxOctreeLevel, static_cast<unsigned char>(10)); //average size clouds
20522052

20532053
double estimatedTime[MAX_OCTREE_LEVEL]{};
20542054
unsigned char bestLevel = 1;
20552055

2056-
for (int i=1; i<maxOctreeLevel; ++i) //warning: i >= 1
2056+
for (unsigned char i = 1; i < maxOctreeLevel; ++i) //warning: i >= 1
20572057
{
20582058
int diffA = 0;
20592059
int diffB = 0;

src/DistanceComputationTools.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,11 @@ int DistanceComputationTools::intersectMeshWithOctree( OctreeAndMeshIntersection
887887
(currentCellPos.y >= intersection->minFillIndexes.y && currentCellPos.y <= intersection->maxFillIndexes.y) &&
888888
(currentCellPos.z >= intersection->minFillIndexes.z && currentCellPos.z <= intersection->maxFillIndexes.z) )
889889
{
890-
Tuple3i cellPos = currentCellPos - intersection->minFillIndexes;
890+
Tuple3i candidateCellPos = currentCellPos - intersection->minFillIndexes;
891891

892892
if (intersection->perCellTriangleList.isInitialized())
893893
{
894-
TriangleList*& triList = intersection->perCellTriangleList.getValue(cellPos);
894+
TriangleList*& triList = intersection->perCellTriangleList.getValue(candidateCellPos);
895895
if (!triList)
896896
{
897897
triList = new TriangleList();
@@ -904,7 +904,7 @@ int DistanceComputationTools::intersectMeshWithOctree( OctreeAndMeshIntersection
904904

905905
if (intersection->distanceTransform)
906906
{
907-
intersection->distanceTransform->setValue(cellPos, 1);
907+
intersection->distanceTransform->setValue(candidateCellPos, 1);
908908
}
909909
}
910910
}

src/GeometricalAnalysisTools.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,11 @@ CCVector3 GeometricalAnalysisTools::ComputeGravityCenter(GenericCloud* cloud)
536536
CCVector3d sum(0, 0, 0);
537537

538538
cloud->placeIteratorAtBeginning();
539-
const CCVector3 *P = nullptr;
540-
while ((P = cloud->getNextPoint()))
539+
const CCVector3* P = cloud->getNextPoint();
540+
while (P)
541541
{
542542
sum += *P;
543+
P = cloud->getNextPoint();
543544
}
544545

545546
sum /= static_cast<double>(count);

src/PointProjectionTools.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,22 @@ PointCloud* PointProjectionTools::developCloudOnCylinder( GenericCloud* cloud,
6161
progressCb->start();
6262
}
6363

64-
const CCVector3* Q = nullptr;
6564
cloud->placeIteratorAtBeginning();
66-
while ((Q = cloud->getNextPoint()))
65+
const CCVector3* Q = cloud->getNextPoint();
66+
while (Q)
6767
{
68-
CCVector3 P = *Q-*center;
68+
CCVector3 P = *Q - *center;
6969
PointCoordinateType u = sqrt(P.u[dim1] * P.u[dim1] + P.u[dim2] * P.u[dim2]);
70-
PointCoordinateType lon = atan2(P.u[dim1],P.u[dim2]);
70+
PointCoordinateType lon = atan2(P.u[dim1], P.u[dim2]);
7171

72-
newCloud->addPoint(CCVector3(lon*radius,P.u[dim],u-radius));
72+
newCloud->addPoint(CCVector3(lon*radius, P.u[dim], u - radius));
7373

7474
if (progressCb && !nprogress.oneStep())
7575
{
7676
break;
7777
}
78-
78+
79+
Q = cloud->getNextPoint();
7980
}
8081

8182
if (progressCb)
@@ -191,9 +192,8 @@ PointCloud* PointProjectionTools::applyTransformation(GenericCloud* cloud, Trans
191192
}
192193

193194
cloud->placeIteratorAtBeginning();
194-
const CCVector3* P;
195-
196-
while ((P = cloud->getNextPoint()))
195+
const CCVector3* P = cloud->getNextPoint();
196+
while (P)
197197
{
198198
//P' = s*R.P+T
199199
CCVector3 newP = trans.apply(*P);
@@ -204,6 +204,8 @@ PointCloud* PointProjectionTools::applyTransformation(GenericCloud* cloud, Trans
204204
{
205205
break;
206206
}
207+
208+
P = cloud->getNextPoint();
207209
}
208210

209211
if (progressCb)
@@ -820,7 +822,7 @@ bool PointProjectionTools::extractConcaveHull2D(std::vector<IndexedCCVector2>& p
820822
}
821823

822824
//update the removed edges info and put them back in the main list
823-
for (std::size_t i=0; i<removed.size(); ++i)
825+
for (std::size_t i = 0; i < removed.size(); ++i)
824826
{
825827
VertexIterator itC = removed[i];
826828
VertexIterator itD = itC; ++itD;
@@ -839,14 +841,14 @@ bool PointProjectionTools::extractConcaveHull2D(std::vector<IndexedCCVector2>& p
839841

840842
if (minSquareDist >= 0)
841843
{
842-
Edge e(itC,nearestPointIndex,minSquareDist);
843-
edges.insert(e);
844+
Edge newEdge(itC, nearestPointIndex, minSquareDist);
845+
edges.insert(newEdge);
844846
}
845847
}
846848
}
847849

848850
//we'll inspect the two new segments later (if necessary)
849-
if ((P-**itA).norm2() > maxSquareEdgeLength)
851+
if ((P - **itA).norm2() > maxSquareEdgeLength)
850852
{
851853
unsigned nearestPointIndex = 0;
852854
PointCoordinateType minSquareDist = FindNearestCandidate(
@@ -860,8 +862,8 @@ bool PointProjectionTools::extractConcaveHull2D(std::vector<IndexedCCVector2>& p
860862

861863
if (minSquareDist >= 0)
862864
{
863-
Edge e(itA,nearestPointIndex,minSquareDist);
864-
edges.insert(e);
865+
Edge newEdge(itA, nearestPointIndex, minSquareDist);
866+
edges.insert(newEdge);
865867
}
866868
}
867869

@@ -879,8 +881,8 @@ bool PointProjectionTools::extractConcaveHull2D(std::vector<IndexedCCVector2>& p
879881

880882
if (minSquareDist >= 0)
881883
{
882-
Edge e(itP,nearestPointIndex,minSquareDist);
883-
edges.insert(e);
884+
Edge newEdge(itP, nearestPointIndex, minSquareDist);
885+
edges.insert(newEdge);
884886
}
885887
}
886888
}

0 commit comments

Comments
 (0)