Commit 37f3a0de authored by Harald Scheirich's avatar Harald Scheirich
Browse files

ENH: Fix warnings MSVC

These are the "simple" warnings, type conversions, unused var, comparison, etc
parent 05a7544d
......@@ -43,10 +43,10 @@
using namespace imstk;
// Parameters to play with
const double width = 50.0;
const double height = 50.0;
const int nRows = 12;
const int nCols = 12;
const double gWidth = 50.0;
const double gHeight = 50.0;
const int gNRows = 12;
const int gNCols = 12;
///
/// \brief Creates cloth geometry
......@@ -173,7 +173,7 @@ main()
scene->addSceneObject(cutObj);
// Create a pbd cloth object in the scene
std::shared_ptr<PbdObject> clothObj = makeClothObj("Cloth", width, height, nRows, nCols);
std::shared_ptr<PbdObject> clothObj = makeClothObj("Cloth", gWidth, gHeight, gNRows, gNCols);
scene->addSceneObject(clothObj);
// Add interaction pair for pbd cutting
......
......@@ -77,7 +77,7 @@ static std::shared_ptr<PbdObject>
makePbdString(
const std::string& name,
const Vec3d& pos,
const size_t numVerts,
const int numVerts,
const double stringLength,
const double bendStiffness,
const Color& color)
......
......@@ -52,7 +52,7 @@ TetraToTetraCD::findCollisionsForMeshWithinHashTable(const std::shared_ptr<Tetra
Vec4i& vInd = mesh->getTetrahedronIndices(tId);
for (size_t i = 0; i < 4; ++i) //if idOffset!=0 ?
{
vInd[i] += idOffset;
vInd[i] += static_cast<int>(idOffset);
}
Vec3d min, max; //bounding box of a tetrahedron
......
......@@ -198,12 +198,12 @@ public:
std::vector<int> pointPenetrations(pointset->getNumVertices());
std::vector<double> pointPenetrationDistances(pointset->getNumVertices());
size_t numPenetrations = 0;
for (uint32_t p = 0; p < pointset->getNumVertices(); ++p)
for (size_t p = 0; p < pointset->getNumVertices(); ++p)
{
const auto& point = pointset->getVertexPosition(p);
bool bPenetration = true;
double penetrationDistance = 1e10;
for (uint32_t i = 0; i < 3; ++i)
for (int i = 0; i < 3; ++i)
{
if (point[i] < -0.5 || point[i] > 0.5)
{
......@@ -252,12 +252,12 @@ public:
std::vector<int> pointPenetrations(pointset->getNumVertices());
std::vector<double> pointPenetrationDistances(pointset->getNumVertices());
size_t numPenetrations = 0;
for (uint32_t p = 0; p < pointset->getNumVertices(); ++p)
for (int p = 0; p < pointset->getNumVertices(); ++p)
{
const auto& point = pointset->getVertexPosition(p);
bool bPenetration = true;
double penetrationDistance = 1e10;
for (uint32_t i = 0; i < 3; ++i)
for (int i = 0; i < 3; ++i)
{
if (point[i] < -0.5 || point[i] > 0.5)
{
......@@ -312,7 +312,7 @@ public:
// Manually check for penetration
std::vector<int> pointPenetration(pointset->getNumVertices());
size_t numPenetrations = 0;
for (uint32_t p = 0; p < pointset->getNumVertices(); ++p)
for (int p = 0; p < pointset->getNumVertices(); ++p)
{
const auto& point = pointset->getVertexPosition(p);
if ((point - SPHERE_CENTER).norm() < sphereRadius)
......@@ -353,9 +353,9 @@ public:
// Brute-force check for collision
auto collisionData = std::make_shared<CollisionData>();
for (uint32_t i = 0; i < mesh->getNumTriangles(); ++i)
for (int i = 0; i < mesh->getNumTriangles(); ++i)
{
for (uint32_t j = 0; j < box->getNumTriangles(); ++j)
for (int j = 0; j < box->getNumTriangles(); ++j)
{
NarrowPhaseCD::triangleToTriangle(i, mesh.get(), j, box.get(), collisionData);
}
......@@ -418,9 +418,9 @@ public:
// Brute-force check for collision
auto collisionData = std::make_shared<CollisionData>();
for (uint32_t i = 0; i < mesh->getNumTriangles(); ++i)
for (int i = 0; i < mesh->getNumTriangles(); ++i)
{
for (uint32_t j = 0; j < box->getNumTriangles(); ++j)
for (int j = 0; j < box->getNumTriangles(); ++j)
{
NarrowPhaseCD::triangleToTriangle(i, mesh.get(), j, box.get(), collisionData);
}
......
......@@ -81,17 +81,17 @@ TEST_F(imstkTetraToTetraCDTest, DISABLED_IntersectionThenNoIntersection1T)
auto cd = std::make_shared<CollisionData>();
m_CD = new TetraToTetraCD(a, b, cd);
m_CD->computeCollisionData();
EXPECT_EQ(cd->PTColData.getSize(), 1);
EXPECT_EQ(cd->PTColData.getSize(), 1UL);
EXPECT_EQ(cd->PTColData[0].collisionType, PointTetrahedronCollisionDataElement::bPenetratingA);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 0);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 0);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 0UL);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 0UL);
m_CD = new TetraToTetraCD(b, a, cd);
m_CD->computeCollisionData();
EXPECT_EQ(cd->PTColData.getSize(), 1);
EXPECT_EQ(cd->PTColData.getSize(), 1UL);
EXPECT_EQ(cd->PTColData[0].collisionType, PointTetrahedronCollisionDataElement::aPenetratingB);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 0);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 0);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 0UL);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 0UL);
//now translate b more so there is no intersection
b->translate(Vec3d(0.0, 2.0, 0.0));
......@@ -129,15 +129,15 @@ TEST_F(imstkTetraToTetraCDTest, DISABLED_IntersectionThenNoIntersectionHuman)
m_CD->computeCollisionData();
EXPECT_EQ(cd->PTColData.getSize(), 1);
EXPECT_EQ(cd->PTColData[0].collisionType, PointTetrahedronCollisionDataElement::aPenetratingB);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 81);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 367);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 81UL);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 367UL);
m_CD = new TetraToTetraCD(b, a, cd);
m_CD->computeCollisionData();
EXPECT_EQ(cd->PTColData.getSize(), 1);
EXPECT_EQ(cd->PTColData[0].collisionType, PointTetrahedronCollisionDataElement::bPenetratingA);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 81);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 367);
EXPECT_EQ(cd->PTColData[0].vertexIdx, 81UL);
EXPECT_EQ(cd->PTColData[0].tetreahedronIdx, 367UL);
//now translate b more so there is no intersection
b->translate(Vec3d(0.0, 0.0, 1.0));
......
......@@ -142,11 +142,6 @@ TEST(imstkDataArrayTest, CapacityManagement)
TEST(imstkDataArrayTest, Iterators)
{
DataArray<int> a;
for (const auto& val : a)
{
GTEST_FAIL() << "Should not enter here";
int i = val;
}
auto itBegin = a.begin();
auto itEnd = a.end();
......
......@@ -157,10 +157,6 @@ TEST(imstkVecDataArrayTest, CapacityManagement)
TEST(imstkVecDataArrayTest, Iterators)
{
VecDataArray<int, 2> a;
for (const auto& val : a)
{
GTEST_FAIL() << "Should not enter here";
}
auto itBegin = a.begin();
auto itEnd = a.end();
......
......@@ -269,13 +269,13 @@ public:
pointsets.push_back(std::move(pointset));
m_Octree->build();
EXPECT_EQ(m_Octree->m_MaxDepth, 10);
EXPECT_EQ(m_Octree->m_MaxDepth, 10U);
const auto vPrimitives = m_Octree->m_vPrimitivePtrs[OctreePrimitiveType::Point];
EXPECT_EQ(vPrimitives.size(), iter + 1);
const auto pPrimitive = vPrimitives.back();
const auto pNode = pPrimitive->m_pNode;
EXPECT_EQ(pNode->m_Depth, 10);
EXPECT_EQ(pNode->m_Depth, 10U);
EXPECT_EQ(std::abs(pNode->m_HalfWidth * 2.0 - 0.1953125) < 1e-8, true);
EXPECT_EQ(pNode->looselyContains(pPrimitive->m_Position), true);
EXPECT_EQ(pNode->contains(pPrimitive->m_Position), true);
......@@ -311,14 +311,14 @@ public:
if (bHasPoint)
{
EXPECT_EQ(m_Octree->m_MaxDepth, 10);
EXPECT_EQ(pNode->m_Depth, 8);
EXPECT_EQ(m_Octree->m_MaxDepth, 10U);
EXPECT_EQ(pNode->m_Depth, 8U);
EXPECT_EQ(std::abs(pNode->m_HalfWidth * 2.0 - 0.78125) < 1e-8, true);
}
else
{
EXPECT_EQ(m_Octree->m_MaxDepth, 5);
EXPECT_EQ(pNode->m_Depth, 5);
EXPECT_EQ(m_Octree->m_MaxDepth, 5U);
EXPECT_EQ(pNode->m_Depth, 5U);
EXPECT_EQ(std::abs(pNode->m_HalfWidth * 2.0 - 6.25) < 1e-8, true);
}
}
......
......@@ -170,7 +170,7 @@ RigidBodyModel2::computeTentativeVelocities()
const Vec3d& fG = m_config->m_gravity;
// Sum gravity to the forces
ParallelUtils::parallelFor(forces.size(), [&forces, &fG](const int& i)
ParallelUtils::parallelFor(forces.size(), [&forces, &fG](const size_t& i)
{
forces[i] += fG;
}, forces.size() > m_maxBodiesParallel);
......
......@@ -702,8 +702,6 @@ SPHModel::moveParticles(const Real timestep)
//ParallelUtils::parallelFor(getState().getNumParticles(),
// [&](const size_t p) {
Vec3d averageVelThroughHemorrhage(0, 0, 0);
int numParticlesAcrossHemorrhagePlane = 0;
VecDataArray<double, 3>& neighborVelContr = *m_neighborVelContr;
VecDataArray<double, 3>& particleShift = *m_particleShift;
VecDataArray<double, 3>& positions = *getCurrentState()->getPositions();
......
......@@ -203,7 +203,7 @@ void
PointSet::setLoadFactor(const double loadFactor)
{
m_loadFactor = loadFactor;
m_maxNumVertices = static_cast<size_t>(m_originalNumVertices * m_loadFactor);
m_maxNumVertices = static_cast<int>(m_originalNumVertices * m_loadFactor);
m_vertexPositions->reserve(static_cast<int>(m_maxNumVertices));
}
......
......@@ -183,7 +183,7 @@ TetrahedralMesh::extractSurfaceMesh()
if (oldToNewVertId.count(face[0]) == 0)
{
// Use size as new index
const int newVertexId = oldToNewVertId.size();
const int newVertexId = static_cast<int>(oldToNewVertId.size());
oldToNewVertId[face[0]] = newVertexId;
face[0] = newVertexId; // Relabel the old one
}
......@@ -195,7 +195,7 @@ TetrahedralMesh::extractSurfaceMesh()
if (oldToNewVertId.count(face[1]) == 0)
{
const int newVertexId = oldToNewVertId.size();
const int newVertexId = static_cast<int>(oldToNewVertId.size());
oldToNewVertId[face[1]] = newVertexId;
face[1] = newVertexId;
}
......@@ -206,7 +206,7 @@ TetrahedralMesh::extractSurfaceMesh()
if (oldToNewVertId.count(face[2]) == 0)
{
const int newVertexId = oldToNewVertId.size();
const int newVertexId = static_cast<int>(oldToNewVertId.size());
oldToNewVertId[face[2]] = newVertexId;
face[2] = newVertexId;
}
......@@ -216,7 +216,7 @@ TetrahedralMesh::extractSurfaceMesh()
}
}
auto triVerticesPtr = std::make_shared<VecDataArray<double, 3>>(oldToNewVertId.size());
auto triVerticesPtr = std::make_shared<VecDataArray<double, 3>>(static_cast<int>(oldToNewVertId.size()));
VecDataArray<double, 3>& triVertices = *triVerticesPtr;
for (auto vertIndexPair : oldToNewVertId)
......
......@@ -136,7 +136,7 @@ MeshIO::getFileType(const std::string& filePath)
// To lowercase
std::transform(extString.begin(), extString.end(), extString.begin(),
[](unsigned char c) { return std::tolower(static_cast<int>(c)); });
[](unsigned char c) { return std::tolower(c); });
if (extToType.count(extString) == 0)
{
......
......@@ -72,7 +72,7 @@ NewtonSolver<SystemMatrix>::solveGivenState(Vectord& x)
Vectord dx = x;
const int maxIters = this->m_isSemiImplicit ? 1 : m_maxIterations;
const int maxIters = this->m_isSemiImplicit ? 1 : static_cast<int>(m_maxIterations);
for (size_t i = 0; i < maxIters; ++i)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment