Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit 182eb72

Browse files
committed
template vector size
1 parent 0ba4e7c commit 182eb72

File tree

3 files changed

+38
-38
lines changed

3 files changed

+38
-38
lines changed

src/ipc/smooth_contact/distance/mollifier.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
#include "edge_edge.hpp"
55

66
namespace ipc {
7-
template <typename scalar>
7+
template <typename scalar, int dim>
88
scalar point_edge_mollifier(
9-
const Eigen::Ref<const VectorMax3<scalar>>& p,
10-
const Eigen::Ref<const VectorMax3<scalar>>& e0,
11-
const Eigen::Ref<const VectorMax3<scalar>>& e1,
9+
const Eigen::Ref<const Vector<scalar, dim>>& p,
10+
const Eigen::Ref<const Vector<scalar, dim>>& e0,
11+
const Eigen::Ref<const Vector<scalar, dim>>& e1,
1212
const scalar& dist_sqr);
1313

1414
std::array<HEAVISIDE_TYPE, 4> edge_edge_mollifier_type(

src/ipc/smooth_contact/distance/mollifier.tpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
#include "mollifier.hpp"
44

55
namespace ipc {
6-
template <typename scalar>
6+
template <typename scalar, int dim>
77
scalar point_edge_mollifier(
8-
const Eigen::Ref<const VectorMax3<scalar>>& p,
9-
const Eigen::Ref<const VectorMax3<scalar>>& e0,
10-
const Eigen::Ref<const VectorMax3<scalar>>& e1,
8+
const Eigen::Ref<const Vector<scalar, dim>>& p,
9+
const Eigen::Ref<const Vector<scalar, dim>>& e0,
10+
const Eigen::Ref<const Vector<scalar, dim>>& e1,
1111
const scalar& dist_sqr)
1212
{
1313
const scalar denominator =

src/ipc/smooth_contact/distance/primitive_distance.tpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ public:
1717
typename PrimitiveDistType<Face, Point3>::type dtype)
1818
{
1919
return point_triangle_sqr_distance<T>(
20-
x.tail(3) /* point */, x.head(3), x.segment(3, 3),
21-
x.segment(6, 3) /* face */, dtype);
20+
x.template tail<3>() /* point */, x.template head<3>(), x.template segment<3>(3),
21+
x.template segment<3>(6) /* face */, dtype);
2222
}
2323

2424
static Vector<T, dim> compute_closest_direction(
2525
const Vector<T, n_core_dofs>& x,
2626
typename PrimitiveDistType<Face, Point3>::type dtype)
2727
{
2828
return point_triangle_closest_point_direction<T>(
29-
x.tail(3) /* point */, x.head(3), x.segment(3, 3),
30-
x.segment(6, 3) /* face */, dtype);
29+
x.template tail<3>() /* point */, x.template head<3>(), x.template segment<3>(3),
30+
x.template segment<3>(6) /* face */, dtype);
3131
}
3232

3333
static T mollifier(const Vector<T, n_core_dofs>& x, const T& dist_sqr)
3434
{
3535
return point_face_mollifier<T>(
36-
x.tail(3) /* point */, x.head(3), x.segment(3, 3),
37-
x.segment(6, 3) /* face */, dist_sqr);
36+
x.template tail<3>() /* point */, x.template head<3>(), x.template segment<3>(3),
37+
x.template segment<3>(6) /* face */, dist_sqr);
3838
}
3939
};
4040

@@ -51,26 +51,26 @@ public:
5151
typename PrimitiveDistType<Edge3, Edge3>::type dtype)
5252
{
5353
return edge_edge_sqr_distance<T>(
54-
x.head(3) /* edge 0 */, x.segment(3, 3) /* edge 0 */,
55-
x.segment(6, 3) /* edge 1 */, x.tail(3) /* edge 1 */, dtype);
54+
x.template head<3>() /* edge 0 */, x.template segment<3>(3) /* edge 0 */,
55+
x.template segment<3>(6) /* edge 1 */, x.template tail<3>() /* edge 1 */, dtype);
5656
}
5757

5858
static Vector<T, dim> compute_closest_direction(
5959
const Vector<T, n_core_dofs>& x,
6060
typename PrimitiveDistType<Edge3, Edge3>::type dtype)
6161
{
6262
return edge_edge_closest_point_direction<T>(
63-
x.head(3) /* edge 0 */, x.segment(3, 3) /* edge 0 */,
64-
x.segment(6, 3) /* edge 1 */, x.tail(3) /* edge 1 */, dtype);
63+
x.template head<3>() /* edge 0 */, x.template segment<3>(3) /* edge 0 */,
64+
x.template segment<3>(6) /* edge 1 */, x.template tail<3>() /* edge 1 */, dtype);
6565
}
6666

6767
static T mollifier(const Vector<T, n_core_dofs>& x, const T& dist_sqr)
6868
{
6969
std::array<HEAVISIDE_TYPE, 4> types;
7070
types.fill(HEAVISIDE_TYPE::VARIANT);
7171
return edge_edge_mollifier<T>(
72-
x.head(3) /* edge 0 */, x.segment(3, 3) /* edge 0 */,
73-
x.segment(6, 3) /* edge 1 */, x.tail(3) /* edge 1 */, types,
72+
x.template head<3>() /* edge 0 */, x.template segment<3>(3) /* edge 0 */,
73+
x.template segment<3>(6) /* edge 1 */, x.template tail<3>() /* edge 1 */, types,
7474
dist_sqr);
7575
}
7676
};
@@ -88,24 +88,24 @@ public:
8888
typename PrimitiveDistType<Edge2, Point2>::type dtype)
8989
{
9090
return PointEdgeDistance<T, dim>::point_edge_sqr_distance(
91-
x.tail(2) /* point */, x.head(2) /* edge */,
92-
x.segment(2, 2) /* edge */, dtype);
91+
x.template tail<2>() /* point */, x.template head<2>() /* edge */,
92+
x.template segment<2>(2) /* edge */, dtype);
9393
}
9494

9595
static Vector<T, dim> compute_closest_direction(
9696
const Vector<T, n_core_dofs>& x,
9797
typename PrimitiveDistType<Edge2, Point2>::type dtype)
9898
{
9999
return PointEdgeDistance<T, dim>::point_edge_closest_point_direction(
100-
x.tail(2) /* point */, x.head(2) /* edge */,
101-
x.segment(2, 2) /* edge */, dtype);
100+
x.template tail<2>() /* point */, x.template head<2>() /* edge */,
101+
x.template segment<2>(2) /* edge */, dtype);
102102
}
103103

104104
static T mollifier(const Vector<T, n_core_dofs>& x, const T& dist_sqr)
105105
{
106-
return point_edge_mollifier<T>(
107-
x.tail(2) /* point */, x.segment(2, 2) /* edge */,
108-
x.head(2) /* edge */, dist_sqr);
106+
return point_edge_mollifier<T, 2>(
107+
x.template tail<2>() /* point */, x.template segment<2>(2) /* edge */,
108+
x.template head<2>() /* edge */, dist_sqr);
109109
}
110110
};
111111

@@ -122,24 +122,24 @@ public:
122122
typename PrimitiveDistType<Edge3, Point3>::type dtype)
123123
{
124124
return PointEdgeDistance<T, dim>::point_edge_sqr_distance(
125-
x.tail(3) /* point */, x.head(3) /* edge */,
126-
x.segment(3, 3) /* edge */, dtype);
125+
x.template tail<3>() /* point */, x.template head<3>() /* edge */,
126+
x.template segment<3>(3) /* edge */, dtype);
127127
}
128128

129129
static Vector<T, dim> compute_closest_direction(
130130
const Vector<T, n_core_dofs>& x,
131131
typename PrimitiveDistType<Edge3, Point3>::type dtype)
132132
{
133133
return PointEdgeDistance<T, dim>::point_edge_closest_point_direction(
134-
x.tail(3) /* point */, x.head(3) /* edge */,
135-
x.segment(3, 3) /* edge */, dtype);
134+
x.template tail<3>() /* point */, x.template head<3>() /* edge */,
135+
x.template segment<3>(3) /* edge */, dtype);
136136
}
137137

138138
static T mollifier(const Vector<T, n_core_dofs>& x, const T& dist_sqr)
139139
{
140-
return point_edge_mollifier<T>(
141-
x.tail(3) /* point */, x.segment(3, 3) /* edge */,
142-
x.head(3) /* edge */, dist_sqr);
140+
return point_edge_mollifier<T, 3>(
141+
x.template tail<3>() /* point */, x.template segment<3>(3) /* edge */,
142+
x.template head<3>() /* edge */, dist_sqr);
143143
}
144144
};
145145

@@ -155,14 +155,14 @@ public:
155155
const Vector<T, n_core_dofs>& x,
156156
typename PrimitiveDistType<Point2, Point2>::type dtype)
157157
{
158-
return (x.tail(2) - x.head(2)).squaredNorm();
158+
return (x.template tail<2>() - x.template head<2>()).squaredNorm();
159159
}
160160

161161
static Vector<T, dim> compute_closest_direction(
162162
const Vector<T, n_core_dofs>& x,
163163
typename PrimitiveDistType<Point2, Point2>::type dtype)
164164
{
165-
return x.tail(2) - x.head(2);
165+
return x.template tail<2>() - x.template head<2>();
166166
}
167167

168168
static T mollifier(const Vector<T, n_core_dofs>& x, const T& dist_sqr)
@@ -183,14 +183,14 @@ public:
183183
const Vector<T, n_core_dofs>& x,
184184
typename PrimitiveDistType<Point3, Point3>::type dtype)
185185
{
186-
return (x.tail(3) - x.head(3)).squaredNorm();
186+
return (x.template tail<3>() - x.template head<3>()).squaredNorm();
187187
}
188188

189189
static Vector<T, dim> compute_closest_direction(
190190
const Vector<T, n_core_dofs>& x,
191191
typename PrimitiveDistType<Point3, Point3>::type dtype)
192192
{
193-
return x.tail(3) - x.head(3);
193+
return x.template tail<3>() - x.template head<3>();
194194
}
195195

196196
static T mollifier(const Vector<T, n_core_dofs>& x, const T& dist_sqr)

0 commit comments

Comments
 (0)