diff --git a/Source/CollisionDetection/Testing/imstkCollisionDataTest.cpp b/Source/CollisionDetection/Testing/imstkCollisionDataTest.cpp index c8076ffe523c858273768d6d12531f17b31d3f64..27dec0ccfb5be721144ee9522e1a5ec8c266c868 100644 --- a/Source/CollisionDetection/Testing/imstkCollisionDataTest.cpp +++ b/Source/CollisionDetection/Testing/imstkCollisionDataTest.cpp @@ -1,35 +1,57 @@ +/*========================================================================= + + Library: iMSTK + + Copyright (c) Kitware, Inc. & Center for Modeling, Simulation, + & Imaging in Medicine, Rensselaer Polytechnic Institute. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + #include "gtest/gtest.h" #include "imstkCollisionData.h" using namespace imstk; -namespace { +namespace +{ } struct imstkCollisionElementTest : public ::testing::Test { imstkCollisionElementTest() { - cv.pts[0] = Vec3d{ 1,2,3 }; - cv.pts[1] = Vec3d{ 2,3,4 }; - cv.pts[2] = Vec3d{ 3,4,5 }; - cv.pts[3] = Vec3d{ 4,5,6 }; - cv.size = 10; - - ci.ids[0] = 7; - ci.ids[1] = 8; - ci.ids[2] = 9; - ci.ids[3] = 10; - ci.idCount = 11; + cv.pts[0] = Vec3d{ 1, 2, 3 }; + cv.pts[1] = Vec3d{ 2, 3, 4 }; + cv.pts[2] = Vec3d{ 3, 4, 5 }; + cv.pts[3] = Vec3d{ 4, 5, 6 }; + cv.size = 10; + + ci.ids[0] = 7; + ci.ids[1] = 8; + ci.ids[2] = 9; + ci.ids[3] = 10; + ci.idCount = 11; ci.cellType = IMSTK_VERTEX; - pd.pt = Vec3d{ 2,3,4 }; - pd.dir = Vec3d{ 4,5,6 }; + pd.pt = Vec3d{ 2, 3, 4 }; + pd.dir = Vec3d{ 4, 5, 6 }; pd.penetrationDepth = 12.0; pi.ptIndex = 13; - pi.dir = Vec3d{ 3,4,5 }; + pi.dir = Vec3d{ 3, 4, 5 }; pi.penetrationDepth = 2.0; }; @@ -62,7 +84,7 @@ TEST_F(imstkCollisionElementTest, Constructor) EXPECT_EQ(CollisionElementType::PointDirection, e.m_type); EXPECT_EQ(pd.dir, e.m_element.m_PointDirectionElement.dir); EXPECT_EQ(pd.penetrationDepth, e.m_element.m_PointDirectionElement.penetrationDepth); - } + } { CollisionElement e(pi); EXPECT_EQ(CollisionElementType::PointIndexDirection, e.m_type); diff --git a/Source/Common/imstkMath.h b/Source/Common/imstkMath.h index 87a8fa4c10c9aa64760aa468cd881942a0efd469..5d1ae9a955152902ce59cfe977e760318e4c914d 100644 --- a/Source/Common/imstkMath.h +++ b/Source/Common/imstkMath.h @@ -109,7 +109,7 @@ using Mat3d = Eigen::Matrix<double, 3, 3>; using StdVectorOfMat3d = std::vector<Mat3d, Eigen::aligned_allocator<Mat3d>>; // 4x4 Matrix -using Mat4f = Eigen::Matrix<float, 4, 4> ; +using Mat4f = Eigen::Matrix<float, 4, 4>; using Mat4d = Eigen::Matrix<double, 4, 4>; /// A dynamic size matrix of floats diff --git a/Source/Devices/imstkHapticDeviceClient.h b/Source/Devices/imstkHapticDeviceClient.h index 2be1abea809b4aa7a37a6a1317043addff00135b..8dd0559b57a05b4fee5d1047f657b28b4053c2d4 100644 --- a/Source/Devices/imstkHapticDeviceClient.h +++ b/Source/Devices/imstkHapticDeviceClient.h @@ -79,7 +79,7 @@ private: /// \brief Phantom omni device api callback /// #ifndef HDCALLBACK -#define HDCALLBACK +#define HDCALLBACK #endif typedef unsigned int HDCallbackCode; static HDCallbackCode HDCALLBACK hapticCallback(void* pData); diff --git a/Source/MeshIO/imstkAssimpMeshIO.cpp b/Source/MeshIO/imstkAssimpMeshIO.cpp index 962a41393abb58ffcc0c15cbb1796721925836f9..11a0afe1d2f23f3e54ad9ae0de53ee42c5846552 100644 --- a/Source/MeshIO/imstkAssimpMeshIO.cpp +++ b/Source/MeshIO/imstkAssimpMeshIO.cpp @@ -81,8 +81,8 @@ AssimpMeshIO::convertAssimpMesh(aiMesh* importedMesh) auto mesh = std::make_shared<SurfaceMesh>(std::string(importedMesh->mName.C_Str())); // Get mesh information - auto numVertices = importedMesh->mNumVertices; - auto numTriangles = importedMesh->mNumFaces; + auto numVertices = importedMesh->mNumVertices; + auto numFaces = importedMesh->mNumFaces; if (numVertices == 0) { @@ -103,17 +103,20 @@ AssimpMeshIO::convertAssimpMesh(aiMesh* importedMesh) } // Triangles - std::shared_ptr<VecDataArray<int, 3>> trianglesPtr = std::make_shared<VecDataArray<int, 3>>(numTriangles); - VecDataArray<int, 3>& triangles = *trianglesPtr; + auto trianglesPtr = std::make_shared<VecDataArray<int, 3>>(); + trianglesPtr->reserve(numFaces); + VecDataArray<int, 3>& triangles = *trianglesPtr; - for (unsigned int i = 0; i < numTriangles; i++) + for (unsigned int i = 0; i < numFaces; i++) { - auto triangle = importedMesh->mFaces[i]; - auto indices = triangle.mIndices; - triangles[i][0] = indices[0]; - triangles[i][1] = indices[1]; - triangles[i][2] = indices[2]; + aiFace triangle = importedMesh->mFaces[i]; + unsigned int* indices = triangle.mIndices; + if (triangle.mNumIndices == 3) // Only supports triangles + { + triangles.push_back(Vec3i(indices[0], indices[1], indices[2])); + } } + trianglesPtr->squeeze(); // Vertex normals, tangents, and bitangents std::shared_ptr<VecDataArray<double, 3>> normalsPtr = std::make_shared<VecDataArray<double, 3>>(numVertices); diff --git a/Source/Scene/imstkScene.h b/Source/Scene/imstkScene.h index cd6377feedb25a4a93d0c7a4c3a5a6539f17953a..bee0b22083e9f9db8c3a8b184090ae7507b91dd8 100644 --- a/Source/Scene/imstkScene.h +++ b/Source/Scene/imstkScene.h @@ -185,8 +185,7 @@ public: /// /// \brief Get and unordered map of cameras with names /// - const std::unordered_map<std::string, std::shared_ptr<Camera>>& - getCameras() const { return m_cameras; } + const std::unordered_map<std::string, std::shared_ptr<Camera>>& getCameras() const { return m_cameras; } /// /// \brief Add light from the scene