|
@@ -53,7 +53,7 @@ private:
|
|
|
};
|
|
|
|
|
|
|
|
|
-template <typename DerivedV1, typename DerivedV2, typename DerivedF>
|
|
|
+template <typename Derivedvalues, typename Derivedpoints,typename Derivedvertices, typename DerivedF>
|
|
|
class MarchingCubes
|
|
|
{
|
|
|
typedef std::map<EdgeKey, unsigned> MyMap;
|
|
@@ -61,12 +61,12 @@ class MarchingCubes
|
|
|
|
|
|
public:
|
|
|
MarchingCubes(
|
|
|
- const Eigen::PlainObjectBase<DerivedV1> &values,
|
|
|
- const Eigen::PlainObjectBase<DerivedV2> &points,
|
|
|
+ const Eigen::PlainObjectBase<Derivedvalues> &values,
|
|
|
+ const Eigen::PlainObjectBase<Derivedpoints> &points,
|
|
|
const unsigned x_res,
|
|
|
const unsigned y_res,
|
|
|
const unsigned z_res,
|
|
|
- Eigen::PlainObjectBase<DerivedV2> &vertices,
|
|
|
+ Eigen::PlainObjectBase<Derivedvertices> &vertices,
|
|
|
Eigen::PlainObjectBase<DerivedF> &faces)
|
|
|
{
|
|
|
assert(values.cols() == 1);
|
|
@@ -181,11 +181,11 @@ public:
|
|
|
|
|
|
};
|
|
|
|
|
|
- static typename DerivedF::Scalar add_vertex(const Eigen::PlainObjectBase<DerivedV1> &values,
|
|
|
- const Eigen::PlainObjectBase<DerivedV2> &points,
|
|
|
+ static typename DerivedF::Scalar add_vertex(const Eigen::PlainObjectBase<Derivedvalues> &values,
|
|
|
+ const Eigen::PlainObjectBase<Derivedpoints> &points,
|
|
|
unsigned int i0,
|
|
|
unsigned int i1,
|
|
|
- Eigen::PlainObjectBase<DerivedV2> &vertices,
|
|
|
+ Eigen::PlainObjectBase<Derivedvertices> &vertices,
|
|
|
int &num_vertices,
|
|
|
MyMap &edge2vertex)
|
|
|
{
|
|
@@ -196,19 +196,19 @@ public:
|
|
|
;
|
|
|
|
|
|
// generate new vertex
|
|
|
- const Eigen::Matrix<typename DerivedV2::Scalar, 1, 3> & p0 = points.row(i0);
|
|
|
- const Eigen::Matrix<typename DerivedV2::Scalar, 1, 3> & p1 = points.row(i1);
|
|
|
+ const Eigen::Matrix<typename Derivedpoints::Scalar, 1, 3> & p0 = points.row(i0);
|
|
|
+ const Eigen::Matrix<typename Derivedpoints::Scalar, 1, 3> & p1 = points.row(i1);
|
|
|
|
|
|
- typename DerivedV1::Scalar s0 = fabs(values[i0]);
|
|
|
- typename DerivedV1::Scalar s1 = fabs(values[i1]);
|
|
|
- typename DerivedV1::Scalar t = s0 / (s0+s1);
|
|
|
+ typename Derivedvalues::Scalar s0 = fabs(values[i0]);
|
|
|
+ typename Derivedvalues::Scalar s1 = fabs(values[i1]);
|
|
|
+ typename Derivedvalues::Scalar t = s0 / (s0+s1);
|
|
|
|
|
|
|
|
|
num_vertices++;
|
|
|
if (num_vertices > vertices.rows())
|
|
|
vertices.conservativeResize(vertices.rows()+10000, Eigen::NoChange);
|
|
|
|
|
|
- vertices.row(num_vertices-1) = (1.0f-t)*p0 + t*p1;
|
|
|
+ vertices.row(num_vertices-1) = ((1.0f-t)*p0 + t*p1).template cast<typename Derivedvertices::Scalar>();
|
|
|
edge2vertex[EdgeKey(i0, i1)] = num_vertices-1;
|
|
|
|
|
|
return num_vertices-1;
|
|
@@ -220,17 +220,17 @@ public:
|
|
|
};
|
|
|
|
|
|
|
|
|
-template <typename DerivedV1, typename DerivedV2, typename DerivedF>
|
|
|
+template <typename Derivedvalues, typename Derivedpoints, typename Derivedvertices, typename DerivedF>
|
|
|
IGL_INLINE void igl::copyleft::marching_cubes(
|
|
|
- const Eigen::PlainObjectBase<DerivedV1> &values,
|
|
|
- const Eigen::PlainObjectBase<DerivedV2> &points,
|
|
|
+ const Eigen::PlainObjectBase<Derivedvalues> &values,
|
|
|
+ const Eigen::PlainObjectBase<Derivedpoints> &points,
|
|
|
const unsigned x_res,
|
|
|
const unsigned y_res,
|
|
|
const unsigned z_res,
|
|
|
- Eigen::PlainObjectBase<DerivedV2> &vertices,
|
|
|
+ Eigen::PlainObjectBase<Derivedvertices> &vertices,
|
|
|
Eigen::PlainObjectBase<DerivedF> &faces)
|
|
|
{
|
|
|
- MarchingCubes<DerivedV1, DerivedV2, DerivedF> mc(values,
|
|
|
+ MarchingCubes<Derivedvalues, Derivedpoints, Derivedvertices, DerivedF> mc(values,
|
|
|
points,
|
|
|
x_res,
|
|
|
y_res,
|
|
@@ -240,5 +240,9 @@ IGL_INLINE void igl::copyleft::marching_cubes(
|
|
|
}
|
|
|
#ifdef IGL_STATIC_LIBRARY
|
|
|
// Explicit template instantiation
|
|
|
-template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
+// generated by autoexplicit.sh
|
|
|
+template void igl::copyleft::marching_cubes<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
|
|
+// generated by autoexplicit.sh
|
|
|
+template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
|
|
+template void igl::copyleft::marching_cubes< Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
#endif
|