Commit c52cc2f4 authored by Dženan Zukić's avatar Dženan Zukić

COMP: using size_t more consistently and other warnings on MSVC/Windows

parent 81c00c5d
......@@ -25,7 +25,7 @@ namespace imstk
{
LinearProjectionConstraint::
LinearProjectionConstraint(const unsigned int& nodeId, const bool isFixed /*= false*/)
LinearProjectionConstraint(const size_t& nodeId, const bool isFixed /*= false*/)
{
m_nodeId = nodeId;
if (isFixed)
......@@ -36,14 +36,14 @@ LinearProjectionConstraint(const unsigned int& nodeId, const bool isFixed /*= fa
}
void
LinearProjectionConstraint::setProjection(const unsigned int& nodeId, const Vec3d& p, const Vec3d& q /*= Vec3d::Zero()*/)
LinearProjectionConstraint::setProjection(const size_t& nodeId, const Vec3d& p, const Vec3d& q /*= Vec3d::Zero()*/)
{
m_nodeId = nodeId;
m_projection = Mat3d::Identity() - p*p.transpose() - q*q.transpose();
}
void
LinearProjectionConstraint::setProjectorToDirichlet(const unsigned int& nodeId)
LinearProjectionConstraint::setProjectorToDirichlet(const size_t& nodeId)
{
m_nodeId = nodeId;
m_projection = Mat3d::Zero();
......
......@@ -38,7 +38,7 @@ public:
///
/// \brief Constructor
///
LinearProjectionConstraint(const unsigned int& nodeId, const bool isFixed = false);
LinearProjectionConstraint(const size_t& nodeId, const bool isFixed = false);
LinearProjectionConstraint() = delete;
///
......@@ -49,12 +49,12 @@ public:
///
/// \brief Form the projection
///
void setProjection(const unsigned int& nodeId, const Vec3d& p, const Vec3d& q = Vec3d::Zero());
void setProjection(const size_t& nodeId, const Vec3d& p, const Vec3d& q = Vec3d::Zero());
///
/// \brief Set the projector to simulate Dirichlet conditions
///
void setProjectorToDirichlet(const unsigned int& nodeId);
void setProjectorToDirichlet(const size_t& nodeId);
///
/// \brief Reset the linear projector
......@@ -88,13 +88,13 @@ public:
///
/// \brief Get the node id
///
inline const unsigned int& getNodeId() const
inline const size_t& getNodeId() const
{
return m_nodeId;
}
private:
unsigned int m_nodeId; ///> Node id
size_t m_nodeId; ///> Node id
bool m_isFixedConstraint = false; ///> Flag to know if that node is fixed
Mat3d m_projection = Mat3d::Identity(); ///> Orthogonal projector
Vec3d m_value = Vec3d(0., 0., 0.); ///> Value in the subspace: range(I-m_projector)
......
......@@ -93,7 +93,7 @@ std::ostream& operator<<(std::ostream& os, const Color& c)
os << "R = " << c.r << '\n'
<< "G = " << c.g << '\n'
<< "B = " << c.b << '\n'
<< "\u03B1 = " << c.a ;
<< "A = " << c.a ;
return os;
}
......
......@@ -52,7 +52,7 @@ Module::start()
// Keep active, wait for terminating call
std::chrono::steady_clock::time_point previous_t = std::chrono::steady_clock::now() - std::chrono::minutes(1);
std::chrono::steady_clock::time_point current_t;
int elapsed;
long long elapsed;
while (m_status != ModuleStatus::TERMINATING)
{
if (m_status == ModuleStatus::PAUSING)
......
......@@ -64,7 +64,7 @@ VRPNDeviceClient::runModule()
}
if (this->getForceEnabled())
{
m_vrpnForceDevice->setFF_Force(m_force[0], m_force[1], m_force[2]);
m_vrpnForceDevice->setFF_Force(vrpn_float32(m_force[0]), vrpn_float32(m_force[1]), vrpn_float32(m_force[2]));
m_vrpnForceDevice->sendForceField();
m_vrpnForceDevice->mainloop();
}
......
......@@ -32,7 +32,7 @@ namespace imstk
{
void
VRPNDeviceServer::addDevice(std::string deviceName, DeviceType deviceType, size_t id)
VRPNDeviceServer::addDevice(std::string deviceName, DeviceType deviceType, int id)
{
m_deviceInfoMap[deviceName] = std::make_pair(deviceType,id);
......@@ -56,7 +56,7 @@ VRPNDeviceServer::initModule()
{
std::string name = device.first;
DeviceType type = device.second.first;
size_t id = device.second.second;
auto id = device.second.second;
switch (type)
{
......
......@@ -74,7 +74,7 @@ public:
///
/// \brief Add device
///
void addDevice(std::string deviceName, DeviceType deviceType, size_t id = 0);
void addDevice(std::string deviceName, DeviceType deviceType, int id = 0);
protected:
......@@ -98,9 +98,9 @@ private:
const std::string m_machine; ///< machine name or IP
const int m_port; ///< connection port
std::map<std::string, std::pair<DeviceType, size_t>> m_deviceInfoMap;///< list of iMSTK client info
vrpn_Connection * m_serverConnection; ///< VRPN server connection
vrpn_MainloopContainer* m_deviceConnections; ///< VRPN device connections
std::map<std::string, std::pair<DeviceType, int>> m_deviceInfoMap;///< list of iMSTK client info
vrpn_Connection * m_serverConnection; ///< VRPN server connection
vrpn_MainloopContainer* m_deviceConnections; ///< VRPN device connections
};
......
......@@ -316,8 +316,8 @@ PbdModel::initializeDihedralConstraints(const double& stiffness)
std::sort(r2.begin(), r2.end());
std::sort(r3.begin(), r3.end());
std::vector<unsigned int> rs;
std::vector<unsigned int>::iterator it;
std::vector<size_t> rs;
std::vector<size_t>::iterator it;
// check if processed or not
if (E[tri[0]][tri[1]] && E[tri[1]][tri[0]])
{
......
......@@ -41,12 +41,12 @@ TetraTriangleMap::compute()
for (const Vec3d& surfVertPos : triMesh->getVertexPositions())
{
// Find the enclosing or closest tetrahedron
int closestTetId = findEnclosingTetrahedron(tetMesh, surfVertPos);
if (closestTetId < 0)
size_t closestTetId = findEnclosingTetrahedron(tetMesh, surfVertPos);
if (closestTetId == std::numeric_limits<size_t>::max())
{
closestTetId = findClosestTetrahedron(tetMesh, surfVertPos);
}
if (closestTetId < 0)
if (closestTetId == std::numeric_limits<size_t>::max())
{
LOG(WARNING) << "Could not find closest tetrahedron";
return;
......@@ -155,12 +155,12 @@ TetraTriangleMap::setSlave(std::shared_ptr<Geometry> slave)
GeometryMap::setSlave(slave);
}
int
size_t
TetraTriangleMap::findClosestTetrahedron(std::shared_ptr<TetrahedralMesh> tetraMesh,
const Vec3d& pos)
{
double closestDistance = MAX_D;
size_t closestTetrahedron = -1;
size_t closestTetrahedron = std::numeric_limits<size_t>::max();
for (size_t tetId = 0; tetId < tetraMesh->getNumTetrahedra(); ++tetId)
{
Vec3d center(0, 0, 0);
......@@ -180,7 +180,7 @@ TetraTriangleMap::findClosestTetrahedron(std::shared_ptr<TetrahedralMesh> tetraM
return closestTetrahedron;
}
int
size_t
TetraTriangleMap::findEnclosingTetrahedron(std::shared_ptr<TetrahedralMesh> tetraMesh,
const Vec3d& pos)
{
......@@ -202,7 +202,7 @@ TetraTriangleMap::findEnclosingTetrahedron(std::shared_ptr<TetrahedralMesh> tetr
}
// Check which probable tetrahedron the point belongs to
int enclosingTetrahedron = -1;
size_t enclosingTetrahedron = std::numeric_limits<size_t>::max();
TetrahedralMesh::WeightsArray weights = {0.0, 0.0, 0.0, 0.0};
for (const size_t& tetId : probablesTetId)
{
......
......@@ -84,13 +84,13 @@ public:
///
/// \brief Find the closest tetrahedron based on the distance to their centroids for a given point in 3D space
///
static int findClosestTetrahedron(std::shared_ptr<TetrahedralMesh> tetraMesh,
static size_t findClosestTetrahedron(std::shared_ptr<TetrahedralMesh> tetraMesh,
const Vec3d& pos);
///
/// \brief Find the tetrahedron that encloses a given point in 3D space
///
static int findEnclosingTetrahedron(std::shared_ptr<TetrahedralMesh> tetraMesh,
static size_t findEnclosingTetrahedron(std::shared_ptr<TetrahedralMesh> tetraMesh,
const Vec3d& pos);
protected:
......
......@@ -142,7 +142,7 @@ HexahedralMesh::getHexahedronVertices(const int& hexaNum) const
return m_hexahedraVertices.at(hexaNum);
}
int
size_t
HexahedralMesh::getNumHexahedra() const
{
return m_hexahedraVertices.size();
......
......@@ -98,7 +98,7 @@ public:
///
/// \brief Returns the number of hexahedra
///
int getNumHexahedra() const;
size_t getNumHexahedra() const;
protected:
......
......@@ -195,15 +195,16 @@ Mesh::setPointDataArray(const std::string& arrayName, const StdVectorOfVectorf&
m_pointDataMap[arrayName] = arrayData;
}
const StdVectorOfVectorf&
const StdVectorOfVectorf* const
Mesh::getPointDataArray(const std::string& arrayName) const
{
if (!m_pointDataMap.count(arrayName))
auto it = m_pointDataMap.find(arrayName);
if (it == m_pointDataMap.end())
{
LOG(WARNING) << "No array with such name holds any point data.";
return StdVectorOfVectorf();
return nullptr;
}
return m_pointDataMap.at(arrayName);
return &(it->second);
}
const size_t
......
......@@ -139,9 +139,9 @@ public:
void setPointDataArray(const std::string& arrayName, const StdVectorOfVectorf& arrayData);
///
/// \brief Get a specific data array
/// \brief Get a specific data array. If the array name cannot be found, nullptr is returned.
///
const StdVectorOfVectorf& getPointDataArray(const std::string& arrayName) const;
const StdVectorOfVectorf* const getPointDataArray(const std::string& arrayName) const;
///
/// \brief Returns the number of total vertices in the mesh
......
......@@ -161,13 +161,13 @@ SurfaceMesh::computeVerticesNormals()
void
SurfaceMesh::optimizeForDataLocality()
{
const int numVertices = this->getNumVertices();
const int numTriangles = this->getNumTriangles();
const size_t numVertices = this->getNumVertices();
const size_t numTriangles = this->getNumTriangles();
// First find the list of triangles a given vertex is part of
std::vector<std::vector<int>> vertexNeighbors;
std::vector<std::vector<size_t>> vertexNeighbors;
vertexNeighbors.resize(this->getNumVertices());
int triId = 0;
size_t triId = 0;
for (const auto &tri : this->getTrianglesVertices())
{
vertexNeighbors[tri[0]].push_back(triId);
......@@ -178,11 +178,11 @@ SurfaceMesh::optimizeForDataLocality()
}
std::vector<TriangleArray> optimizedConnectivity;
std::vector<int> optimallyOrderedNodes;
std::list<int> triUnderConsideration;
std::vector<size_t> optimallyOrderedNodes;
std::list<size_t> triUnderConsideration;
std::vector<bool> isNodeAdded(numVertices, false);
std::vector<bool> isTriangleAdded(numTriangles, false);
std::list<int> newlyAddedNodes;
std::list<size_t> newlyAddedNodes;
// A. Initialize
optimallyOrderedNodes.push_back(0);
......@@ -324,7 +324,7 @@ SurfaceMesh::getVertexBitangents() const
return m_vertexBitangents;
}
int
size_t
SurfaceMesh::getNumTriangles() const
{
return this->m_trianglesVertices.size();
......
......@@ -144,7 +144,7 @@ public:
///
/// \brief Returns the number of triangles
///
int getNumTriangles() const;
size_t getNumTriangles() const;
///
/// \brief Set/Get the array defining the default material coordinates
......
......@@ -135,15 +135,14 @@ TetrahedralMesh::extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh)
c = tetVertArray[facePattern[t][2]];
// search in reverse
for (int i = surfaceTri.size() - 1; i >= 0; i--)
for (auto it=surfaceTri.rbegin(); it!=surfaceTri.rend(); ++it)
{
const auto &triA = surfaceTri.at(i);
if (((triA[0] == a) && ((triA[1] == b && triA[2] == c) || (triA[1] == c && triA[2] == b))) ||
((triA[1] == a) && ((triA[0] == b && triA[2] == c) || (triA[0] == c && triA[2] == b))) ||
((triA[2] == a) && ((triA[1] == b && triA[0] == c) || (triA[1] == c && triA[0] == b))))
if ((((*it)[0] == a) && (((*it)[1] == b && (*it)[2] == c) || ((*it)[1] == c && (*it)[2] == b))) ||
(((*it)[1] == a) && (((*it)[0] == b && (*it)[2] == c) || ((*it)[0] == c && (*it)[2] == b))) ||
(((*it)[2] == a) && (((*it)[1] == b && (*it)[0] == c) || ((*it)[1] == c && (*it)[0] == b))))
{
unique = false;
foundAt = i;
foundAt = surfaceTri.size() - 1 - (it - surfaceTri.rbegin());
break;
}
}
......@@ -178,10 +177,7 @@ TetrahedralMesh::extractSurfaceMesh(std::shared_ptr<SurfaceMesh> surfaceMesh)
if (normal.dot(centroid - this->getVertexPosition(tetRemainingVert.at(faceId))) > 0)
{
// swap
int tmpIndex = surfaceTri[faceId][2];
surfaceTri[faceId][2] = surfaceTri[faceId][1];
surfaceTri[faceId][2] = tmpIndex;
std::swap(surfaceTri[faceId][2], surfaceTri[faceId][1]);
}
}
......@@ -289,7 +285,7 @@ TetrahedralMesh::getTetrahedronVertices(const size_t& tetId) const
return m_tetrahedraVertices.at(tetId);
}
int
size_t
TetrahedralMesh::getNumTetrahedra() const
{
return m_tetrahedraVertices.size();
......
......@@ -119,7 +119,7 @@ public:
///
/// \brief Returns the number of tetrahedra
///
int getNumTetrahedra() const;
size_t getNumTetrahedra() const;
protected:
std::vector<TetraArray> m_tetrahedraVertices; ///< vertices of the tetrahedra
......
......@@ -416,6 +416,9 @@ MSHMeshIO::numElemNodes(const ElemType & elType)
case ElemType::tetrahedronThirdOrder: return 20;
case ElemType::tetrahedronFourthOrder: return 35;
case ElemType::tetrahedronFifthOrder: return 56;
default:
LOG(WARNING) << "MSHMeshIO::numElemNodes: Unknown element type";
return 0;
}
}
......
......@@ -140,7 +140,7 @@ void
VegaMeshIO::copyVertices(std::shared_ptr<vega::VolumetricMesh> vegaMesh,
StdVectorOfVec3d& vertices)
{
for(size_t i = 0; i < vegaMesh->getNumVertices(); ++i)
for(int i = 0; i < vegaMesh->getNumVertices(); ++i)
{
auto pos = *vegaMesh->getVertex(i);
vertices.emplace_back(pos[0], pos[1], pos[2]);
......@@ -155,9 +155,9 @@ VegaMeshIO::copyCells(std::shared_ptr<vega::VolumetricMesh> vegaMesh,
std::array<size_t,dim> cell;
for(size_t cellId = 0; cellId < vegaMesh->getNumElements(); ++cellId)
{
for (size_t i = 0; i < vegaMesh->getNumElementVertices(); ++i)
for (int i = 0; i < vegaMesh->getNumElementVertices(); ++i)
{
cell[i] = vegaMesh->getVertexIndex(cellId,i);
cell[i] = vegaMesh->getVertexIndex(int(cellId),i);
}
cells.emplace_back(cell);
}
......@@ -189,13 +189,13 @@ VegaMeshIO::convertVolumetricMeshToVegaMesh(const std::shared_ptr<imstk::Volumet
std::vector<int> elements;
for (const auto & tet : tetArray)
{
elements.emplace_back(tet[0]);
elements.emplace_back(tet[1]);
elements.emplace_back(tet[2]);
elements.emplace_back(tet[3]);
elements.emplace_back(int(tet[0]));
elements.emplace_back(int(tet[1]));
elements.emplace_back(int(tet[2]));
elements.emplace_back(int(tet[3]));
}
std::shared_ptr<vega::VolumetricMesh> vegaMesh(new vega::TetMesh(imstkVolTetMesh->getNumVertices(), &vertices[0], imstkVolTetMesh->getNumTetrahedra(), &elements[0], E, nu, density));
std::shared_ptr<vega::VolumetricMesh> vegaMesh(new vega::TetMesh(int(imstkVolTetMesh->getNumVertices()), &vertices[0], int(imstkVolTetMesh->getNumTetrahedra()), &elements[0], E, nu, density));
if (!vegaMesh)
{
LOG(WARNING) << "VegaMeshIO::convertVolumetricMeshToVegaMesh error: Failed to create vega mesh";
......
......@@ -90,17 +90,24 @@ VTKSurfaceMeshRenderDelegate::VTKSurfaceMeshRenderDelegate(std::shared_ptr<Surfa
{
// Convert texture coordinates
auto tcoords = m_geometry->getPointDataArray(m_geometry->getDefaultTCoords());
auto vtkTCoords = vtkSmartPointer<vtkFloatArray>::New();
vtkTCoords->SetNumberOfComponents(2);
vtkTCoords->SetName(m_geometry->getDefaultTCoords().c_str());
for (auto const tcoord : tcoords)
if (tcoords == nullptr)
{
double tuple[2] = { tcoord[0], tcoord[1] };
vtkTCoords->InsertNextTuple(tuple);
LOG(WARNING) << "No default texture coordinates array for geometry " << m_geometry;
}
else
{
auto vtkTCoords = vtkSmartPointer<vtkFloatArray>::New();
vtkTCoords->SetNumberOfComponents(2);
vtkTCoords->SetName(m_geometry->getDefaultTCoords().c_str());
polydata->GetPointData()->SetTCoords(vtkTCoords);
for (auto const tcoord : *tcoords)
{
double tuple[2] = { tcoord[0], tcoord[1] };
vtkTCoords->InsertNextTuple(tuple);
}
polydata->GetPointData()->SetTCoords(vtkTCoords);
}
}
// Setup Mapper & Actor
......
......@@ -62,6 +62,11 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif()
#-----------------------------------------------------------------------------
# SUPERBUILD
#-----------------------------------------------------------------------------
......
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