diff --git a/include/smCollision/smPlaneCollisionModel.h b/include/smCollision/smPlaneCollisionModel.h index 3aace4b10fe74bcee44515a9b0077bfd280751c8..91c8842aa9343b95e53a5b43fda04691e2d9002d 100644 --- a/include/smCollision/smPlaneCollisionModel.h +++ b/include/smCollision/smPlaneCollisionModel.h @@ -1,19 +1,25 @@ -/* - * Copyright 2015 Ricardo Ortiz <email> - * - * 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 - * - * 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. - * - */ +// This file is part of the SimMedTK project. +// Copyright (c) Center for Modeling, Simulation, and 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 +// +// 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. +// +//--------------------------------------------------------------------------- +// +// Authors: +// +// Contact: +//--------------------------------------------------------------------------- #ifndef SMPLANECOLLISIONMODEL_H #define SMPLANECOLLISIONMODEL_H @@ -23,36 +29,15 @@ // Eigen include #include<Eigen/Geometry> -#include "smCore/smGeometry.h" -#include "smCore/smModelRepresentation.h" +#include "smGeometry/smPlaneModel.h" -class smPlane; - -class smPlaneCollisionModel : public smModelRepresentation +class smPlaneCollisionModel : public smPlaneModel { -public: - using RigidTransform = Eigen::Transform<double, 2, Eigen::Isometry>; public: smPlaneCollisionModel(const smVec3d &p, const smVec3d &n); ~smPlaneCollisionModel(); - - void draw() override; - - const smVec3d &getNormal() const; - - void setNormal(const smVec3d &normal); - - const smVec3d &getPosition() const; - - const RigidTransform &getTransform() const; - - void setTransform(const RigidTransform &t); - -private: - std::shared_ptr<smPlane> plane; - RigidTransform transform; }; #endif // SMPLANECOLLISIONMODEL_H_H diff --git a/include/smCore/smGeometry.h b/include/smCore/smGeometry.h index 47d0fd5761a9556b78f2cc76a6a325ed13aba4c4..7ac32b4d9b336adce0d83c794413bb6b0224ec12 100644 --- a/include/smCore/smGeometry.h +++ b/include/smCore/smGeometry.h @@ -60,8 +60,8 @@ public: { this->point = p; this->unitNormal = n; - this->width = 1.0; - + this->width = 100.0; + this->drawPointsOrig[0] = smVec3d(width, 0, 0); this->drawPointsOrig[1] = smVec3d(0, width, 0); this->drawPointsOrig[2] = smVec3d(-width, 0, 0); diff --git a/include/smGeometry/smPlaneModel.h b/include/smGeometry/smPlaneModel.h new file mode 100644 index 0000000000000000000000000000000000000000..417b4ae09b01662381a9449d38cdb0b009732315 --- /dev/null +++ b/include/smGeometry/smPlaneModel.h @@ -0,0 +1,96 @@ +// This file is part of the SimMedTK project. +// Copyright (c) Center for Modeling, Simulation, and 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 +// +// 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. +// +//--------------------------------------------------------------------------- +// +// Authors: +// +// Contact: +//--------------------------------------------------------------------------- + +#ifndef SMPLANEMODEL_H +#define SMPLANEMODEL_H + +// STL includes +#include <memory> +#include <array> + +// Eigne includes +#include <Eigen/Geometry> + +// SimMedTK includes +#include "smCore/smModelRepresentation.h" +#include "smCore/smGeometry.h" + +/// +/// @brief Plane representation of a model. +/// Base class used by all models that can be represented by a plane +/// +/// @see smPlaneCollisionModel +/// +class smPlaneModel : public smModelRepresentation +{ +public: + using RigidTransformType = Eigen::Transform<double, 3, Eigen::Isometry>; + +public: + /// + /// @brief Constructor + /// + smPlaneModel(const smVec3d& p, const smVec3d& n); + + /// + /// @brief Destructor + /// + virtual ~smPlaneModel(); + + /// + /// @brief Draw this mesh + /// + void draw() override; + + /// + /// @brief Returns normal vectors for triangles on mesh surface + /// + const smVec3d &getNormal() const; + + /// + /// @brief Set plane normal + /// + void setNormal(const smVec3d &normal); + + /// + /// @brief Get relative position of the plane + /// + const smVec3d &getPosition() const; + + /// + /// @brief Get transformation operator + /// + const RigidTransformType &getTransform() const; + + /// + /// @brief Set transformation operator + /// + void setTransform(const RigidTransformType &t); + +protected: + // Plane data and transform + std::shared_ptr<smPlane> plane; + RigidTransformType transform; +}; + +#endif // SMPLANEMODEL_H diff --git a/src/smCollision/smPlaneCollisionModel.cpp b/src/smCollision/smPlaneCollisionModel.cpp index 607a31f9c4731783d8005fd3215b8b016f3904d4..5736840ad6d631ec4add7850f019eb8998c65bed 100644 --- a/src/smCollision/smPlaneCollisionModel.cpp +++ b/src/smCollision/smPlaneCollisionModel.cpp @@ -1,49 +1,33 @@ -/* - * Copyright 2015 Ricardo Ortiz <email> - * - * 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 - * - * 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. - * - */ +// This file is part of the SimMedTK project. +// Copyright (c) Center for Modeling, Simulation, and 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 +// +// 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. +// +//--------------------------------------------------------------------------- +// +// Authors: +// +// Contact: +//--------------------------------------------------------------------------- + #include "smCollision/smPlaneCollisionModel.h" -smPlaneCollisionModel::smPlaneCollisionModel(const smVec3d& p, const smVec3d& n) : plane(std::make_shared<smPlane>(p, n)) +smPlaneCollisionModel::smPlaneCollisionModel(const smVec3d& p, const smVec3d& n) + : smPlaneModel(p, n) { } + smPlaneCollisionModel::~smPlaneCollisionModel() {} -void smPlaneCollisionModel::draw() -{ - this->plane->draw(); -} -const smVec3d& smPlaneCollisionModel::getNormal() const -{ - //return this->transform.linear() * this->plane->getUnitNormal(); - return this->plane->getUnitNormal();//temporary fix -} -void smPlaneCollisionModel::setNormal(const smVec3d& normal) -{ - this->plane->setUnitNormal(normal); -} -const smVec3d& smPlaneCollisionModel::getPosition() const -{ - return this->transform * this->plane->getPoint(); -} -const smPlaneCollisionModel::RigidTransform& smPlaneCollisionModel::getTransform() const -{ - return this->transform; -} -void smPlaneCollisionModel::setTransform(const smPlaneCollisionModel::RigidTransform& t) -{ - this->transform = t; -} diff --git a/src/smGeometry/CMakeLists.txt b/src/smGeometry/CMakeLists.txt index b4d0b98602ee78e801fd7b8f8fc2f048d205afb5..cddee2248a44c4d308dab808acc5b10b84562707 100644 --- a/src/smGeometry/CMakeLists.txt +++ b/src/smGeometry/CMakeLists.txt @@ -2,6 +2,7 @@ simmedtk_add_library(smGeometry SOURCES smMeshModel.cpp + smPlaneModel.cpp PUBLIC_HEADERS ${CMAKE_SOURCE_DIR}/include/smGeometry/smMeshModel.h ) diff --git a/src/smGeometry/smPlaneModel.cpp b/src/smGeometry/smPlaneModel.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d73d81db9ea31f0c9e241406b8114cc9a8c072a5 --- /dev/null +++ b/src/smGeometry/smPlaneModel.cpp @@ -0,0 +1,55 @@ +// This file is part of the SimMedTK project. +// Copyright (c) Center for Modeling, Simulation, and 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 +// +// 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. +// +//--------------------------------------------------------------------------- +// +// Authors: +// +// Contact: +//--------------------------------------------------------------------------- + +#include "smGeometry/smPlaneModel.h" + +smPlaneModel::smPlaneModel(const smVec3d& p, const smVec3d& n) +{ + this->plane = std::make_shared<smPlane>(p, n); + this->transform = RigidTransformType::Identity(); +} +smPlaneModel::~smPlaneModel() {} +void smPlaneModel::draw() +{ + this->plane->draw(); +} +const smVec3d& smPlaneModel::getNormal() const +{ + return this->transform.linear() * this->plane->getUnitNormal(); +} +void smPlaneModel::setNormal(const smVec3d& normal) +{ + this->plane->setUnitNormal(normal); +} +const smVec3d& smPlaneModel::getPosition() const +{ + return this->transform * this->plane->getPoint(); +} +const smPlaneModel::RigidTransformType& smPlaneModel::getTransform() const +{ + return this->transform; +} +void smPlaneModel::setTransform(const smPlaneModel::RigidTransformType& t) +{ + this->transform = t; +} diff --git a/src/smSimulators/smVegaFemSceneObject.cpp b/src/smSimulators/smVegaFemSceneObject.cpp index 6a31bc630a18e25d053157d123dff5df111f3511..d205f9d647301417233d45fda0d299a015e7aaae 100644 --- a/src/smSimulators/smVegaFemSceneObject.cpp +++ b/src/smSimulators/smVegaFemSceneObject.cpp @@ -198,7 +198,7 @@ void smVegaFemSceneObject::initSimulation() this->smtkVolumeMesh = std::make_shared<smVolumeMesh>(); this->smtkVolumeMesh->importVolumeMeshFromVegaFormat(this->volumetricMesh, true); } - + if(!renderUsingVega) { this->smtkSurfaceMesh = std::make_shared<smSurfaceMesh>(); @@ -211,7 +211,7 @@ void smVegaFemSceneObject::initSimulation() this->smtkSurfaceMesh->importSurfaceMeshFromVegaFormat(this->secondaryDeformableObjectRenderingMesh->GetMesh(), true); } - auto renderDetail = std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES); + auto renderDetail = std::make_shared<smRenderDetail>(SIMMEDTK_RENDER_FACES | SIMMEDTK_RENDER_WIREFRAME); this->smtkSurfaceMesh->setRenderDetail(renderDetail); } @@ -560,7 +560,7 @@ void smVegaFemSceneObject::loadVolumeMesh() meshGraph = std::make_shared<Graph>(massSpringSystem->GetNumParticles(), massSpringSystem->GetNumEdges(), massSpringSystem->GetEdges()); } - + int scaleRows = 1; SparseMatrix *sm; meshGraph->GetLaplacian(&sm, scaleRows); @@ -600,7 +600,7 @@ void smVegaFemSceneObject::loadSurfaceMesh() } else { - std::cout << "VEGA: Secondary rendering mesh is initialized:\n\t\t" + std::cout << "VEGA: Secondary rendering mesh is initialized:\n\t\t" << secondaryDeformableObjectRenderingMesh->GetNumVertices() << " vertices\n\t\t" << secondaryDeformableObjectRenderingMesh->GetNumFaces() << " faces\n"; }