imstkLinearProjectionConstraint.h 2.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*=========================================================================

   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.

=========================================================================*/

22
#pragma once
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38

#include "imstkMath.h"

namespace imstk
{
///
/// \class LinearProjectionConstraint
///
/// \brief Linear projection constraint
///
class LinearProjectionConstraint
{
public:
    ///
    /// \brief Constructor
    ///
39
    explicit LinearProjectionConstraint(const size_t& nodeId, const bool isFixed = false);
40 41 42 43 44 45 46 47 48 49
    LinearProjectionConstraint() = delete;

    ///
    /// \brief Destructor
    ///
    ~LinearProjectionConstraint() = default;

    ///
    /// \brief Form the projection
    ///
50
    void setProjection(const size_t& nodeId, const Vec3d& p, const Vec3d& q = Vec3d::Zero());
51

52 53 54 55 56
    ///
    /// \brief Form the projection
    ///
    void setProjectionToLine(const size_t& nodeId, const Vec3d& p);

57 58 59
    ///
    /// \brief Set the projector to simulate Dirichlet conditions
    ///
60
    void setProjectorToDirichlet(const size_t& nodeId);
61
    void setProjectorToDirichlet(const unsigned int& nodeId, const Vec3d z);
62 63 64 65 66 67 68 69 70

    ///
    /// \brief Reset the linear projector
    ///
    void reset();

    ///
    /// \brief Set the value in the restricted subspace
    ///
71
    inline void setValue(const Vec3d& v) { m_value = v; }
72 73 74 75

    ///
    /// \brief Get the projector
    ///
76
    inline const Mat3d& getProjector() const { return m_projection; }
77 78 79 80

    ///
    /// \brief Get the value
    ///
81
    inline const Vec3d& getValue() const { return m_value; }
82 83 84 85

    ///
    /// \brief Get the node id
    ///
86 87 88 89 90 91
    inline const size_t& getNodeId() const { return m_nodeId; }

    ///
    /// \brief Returns true if the constraint is fixed
    ///
    inline bool isFixed() const { return m_isFixedConstraint; }
92 93

private:
94 95 96 97
    size_t m_nodeId;            ///> Node id
    bool   m_isFixedConstraint; ///> Flag to know if that node is fixed
    Mat3d  m_projection;        ///> Orthogonal projector
    Vec3d  m_value;             ///> Value in the subspace: range(I-m_projector)
98 99
};
} // imstk