29 template <
typename TPo
int3D,
typename TVector3DRes >
32 enum { PerVertex = 1 };
35 operator()(
const TPoint3D & v,
const TPoint3D &, TVector3DRes & res)
const 44 perVertex(
const TPoint3D & v0, TVector3DRes & res, std::size_t n)
const 60 template <
typename TVector3D,
typename TPrecision >
61 void operator()(
const TVector3D & v,
const TVector3D & v0,
const TPrecision & l0, TPrecision & res)
const 63 res +=
square(dist<TPrecision>(v, v0) - l0);
68 template <
typename TPo
int3D,
typename TVector3DRes >
75 enum { PerVertex = 0 };
83 void operator()(
const TPoint3D & v,
const TPoint3D & v0,
const precision_t & l0, TVector3DRes & res)
const 85 precision_t k =
static_cast<precision_t
>(
91 if (k < 128 * std::numeric_limits<precision_t>::epsilon())
99 res[0] += (v0[0]-v[0]) * k;
100 res[1] += (v0[1]-v[1]) * k;
101 res[2] += (v0[2]-v[2]) * k;
113 template <
class TMesh,
typename TForceVector >
137 std::vector<TForceVector> & forces
140 if (
size(m_length0) == 0)
142 std::runtime_error(
"SpringForce::length0 uninitialized");
150 const std::vector<std::vector<precision_t> > &
getLengths()
const {
return m_length0; }
155 typedef typename boost::enable_if_c<MeshTraits<TMesh>::has_neighbor_indices>::type CheckHasNeighborIndices;
159 std::vector<std::vector<precision_t> > m_length0;
163 template <
typename TForceVector,
class TMesh >
184 typename std::vector<numeric_array<precision_t,3> >::iterator iC2 = forces.begin();
const std::vector< std::vector< precision_t > > & getLengths() const
Numerical precision of the data for storage classes.
TPrec norm2(const numeric_array< T, D > &a, prec< TPrec >)
Return the squared euclidean norm of a.
void perVertex(const TPoint3D &v0, TVector3DRes &res, std::size_t n) const
void sqrt(const TImage &in, TImage &out)
til::value_type_of< TVector3DRes >::type precision_t
boost::enable_if_c< is_container< typename TContainer::value_type >::value >::type for_each_neighbors(const TMesh &mesh, TContainer &c1, TFunctor f)
MeshTraits< Mesh_N >::NeighborIndexCollection & getNeighborIndices(Mesh_N &mesh)
Belongs to package Box Do not include directly, include til/Box.h instead.
Label class for Mesh neighborhood functors.
void laplacianForces(const TMesh &mesh, std::vector< TForceVector > &forces)
A class to compute spring forces on a mesh.
numeric_array< T, D > size(const Box< T, D > &box)
Return the size of a box.
This file contains forward declarations of classes defined in the TIL library.
void operator()(const TVector3D &v, const TVector3D &v0, const TPrecision &l0, TPrecision &res) const
void operator()(const TPoint3D &v, const TPoint3D &v0, const precision_t &l0, TVector3DRes &res) const
Compute -(v-v0)/||v-v0|| * (||v-v0|| - l0)^2, store result in res.
til::value_type_of< TForceVector >::type precision_t
const MeshTraits< Mesh_N >::Vertex & getVertexNeighbor(const Mesh_N &mesh, const MeshTraits< Mesh_N >::NeighborIndex::value_type &iNi)
Returns the vertex neighbors of a mesh of type Mesh_N given by its index.
void square(const TImage &in, TImage &out)
boost::enable_if_c< MeshTraits< TMesh >::has_neighbor_indices >::type getEdgeLengths(const TMesh &mesh, std::vector< std::vector< TPrecision > > &lengths)
Computes edge lengths of a mesh.
const MeshTraits< AimsSurface< D, T > >::VertexCollection & getVertices(const AimsSurface< D, T > &mesh)
void operator()(const TPoint3D &v, const TPoint3D &, TVector3DRes &res) const
void initializeLengths(const TMesh &mesh)
Set the rest lengths of the springs as the length of the edges of the argument mesh.