File: marching_tets.h

package info (click to toggle)
meshlab 2022.02%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 47,348 kB
  • sloc: cpp: 536,635; ansic: 27,783; sh: 539; makefile: 36
file content (196 lines) | stat: -rw-r--r-- 7,980 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// This file is part of libigl, a simple c++ geometry processing library.
//
// Copyright (C) 2018 Francis Williams <francis@fwilliams.info>
//
// This Source Code Form is subject to the terms of the Mozilla Public License
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.

#ifndef IGL_MARCHING_TETS_H
#define IGL_MARCHING_TETS_H

#include "igl_inline.h"
#include <Eigen/Core>
#include <Eigen/Sparse>

namespace igl {
  // marching_tets( TV, TT, S, isovalue, SV, SF, J, BC)
  //
  // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  // TT with scalar values defined at each vertex in TV. The output is a
  // triangle mesh approximating the isosurface coresponding to the value
  // isovalue.
  //
  // Input:
  //  TV  #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  //  TT  #tets x 4 array --  The indexes of each tet in the tetrahedral mesh
  //  S  #tet_vertices x 1 array -- The values defined on each tet vertex
  //  isovalue  scalar -- The isovalue of the level set we want to compute
  //
  // Output:
  //  SV  #SV x 3 array -- The vertices of the output level surface mesh
  //  SF  #SF x 3 array -- The face indexes of the output level surface mesh
  //  J   #SF list of indices into TT revealing which tet each face comes from
  //  BC  #SV x #TV list of barycentric coordinates so that SV = BC*TV
  template <typename DerivedTV,
            typename DerivedTT,
            typename DerivedS,
            typename DerivedSV,
            typename DerivedSF,
            typename DerivedJ,
            typename BCType>
  IGL_INLINE void marching_tets(
      const Eigen::MatrixBase<DerivedTV>& TV,
      const Eigen::MatrixBase<DerivedTT>& TT,
      const Eigen::MatrixBase<DerivedS>& S,
      double isovalue,
      Eigen::PlainObjectBase<DerivedSV>& SV,
      Eigen::PlainObjectBase<DerivedSF>& SF,
      Eigen::PlainObjectBase<DerivedJ>& J,
      Eigen::SparseMatrix<BCType>& BC);

  // marching_tets( TV, TT, S, SV, SF, J, BC)
  //
  // Performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  // TT with scalar values defined at each vertex in TV. The output is a
  // triangle mesh approximating the isosurface coresponding to an isovalue of 0.
  //
  // Input:
  //  TV  #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  //  TT  #tets x 4 array --  The indexes of each tet in the tetrahedral mesh
  //  S  #tet_vertices x 1 array -- The values defined on each tet vertex
  //  isovalue  scalar -- The isovalue of the level set we want to compute
  //
  // Output:
  //  SV  #SV x 3 array -- The vertices of the output level surface mesh
  //  SF  #SF x 3 array -- The face indexes of the output level surface mesh
  //  J   #SF list of indices into TT revealing which tet each face comes from
  //  BC  #SV x #TV list of barycentric coordinates so that SV = BC*TV
  template <typename DerivedTV,
            typename DerivedTT,
            typename DerivedS,
            typename DerivedSV,
            typename DerivedSF,
            typename DerivedJ,
            typename BCType>
  IGL_INLINE void marching_tets(
      const Eigen::MatrixBase<DerivedTV>& TV,
      const Eigen::MatrixBase<DerivedTT>& TT,
      const Eigen::MatrixBase<DerivedS>& S,
      Eigen::PlainObjectBase<DerivedSV>& SV,
      Eigen::PlainObjectBase<DerivedSF>& SF,
      Eigen::PlainObjectBase<DerivedJ>& J,
      Eigen::SparseMatrix<BCType>& BC) {
    return igl::marching_tets(TV, TT, S, 0.0, SV, SF, J, BC);
  }

  // marching_tets( TV, TT, S, isovalue, SV, SF, J)
  //
  // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  // TT with scalar values defined at each vertex in TV. The output is a
  // triangle mesh approximating the isosurface coresponding to the value
  // isovalue.
  //
  // Input:
  //  TV  #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  //  TT  #tets x 4 array --  The indexes of each tet in the tetrahedral mesh
  //  S  #tet_vertices x 1 array -- The values defined on each tet vertex
  //  isovalue  scalar -- The isovalue of the level set we want to compute
  //
  // Output:
  //  SV  #SV x 3 array -- The vertices of the output level surface mesh
  //  SF  #SF x 3 array -- The face indexes of the output level surface mesh
  //  J   #SF list of indices into TT revealing which tet each face comes from
  template <typename DerivedTV,
            typename DerivedTT,
            typename DerivedS,
            typename DerivedSV,
            typename DerivedSF,
            typename DerivedJ>
  IGL_INLINE void marching_tets(
      const Eigen::MatrixBase<DerivedTV>& TV,
      const Eigen::MatrixBase<DerivedTT>& TT,
      const Eigen::MatrixBase<DerivedS>& S,
      double isovalue,
      Eigen::PlainObjectBase<DerivedSV>& SV,
      Eigen::PlainObjectBase<DerivedSF>& SF,
      Eigen::PlainObjectBase<DerivedJ>& J) {
    Eigen::SparseMatrix<double> _BC;
    return igl::marching_tets(TV, TT, S, isovalue, SV, SF, J, _BC);
  }

  // marching_tets( TV, TT, S, isovalue, SV, SF, BC)
  //
  // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  // TT with scalar values defined at each vertex in TV. The output is a
  // triangle mesh approximating the isosurface coresponding to the value
  // isovalue.
  //
  // Input:
  //  TV  #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  //  TT  #tets x 4 array --  The indexes of each tet in the tetrahedral mesh
  //  S  #tet_vertices x 1 array -- The values defined on each tet vertex
  //  isovalue  scalar -- The isovalue of the level set we want to compute
  //
  // Output:
  //  SV  #SV x 3 array -- The vertices of the output level surface mesh
  //  SF  #SF x 3 array -- The face indexes of the output level surface mesh
  //  BC  #SV x #TV list of barycentric coordinates so that SV = BC*TV
  template <typename DerivedTV,
            typename DerivedTT,
            typename DerivedS,
            typename DerivedSV,
            typename DerivedSF,
            typename BCType>
  IGL_INLINE void marching_tets(
      const Eigen::MatrixBase<DerivedTV>& TV,
      const Eigen::MatrixBase<DerivedTT>& TT,
      const Eigen::MatrixBase<DerivedS>& S,
      double isovalue,
      Eigen::PlainObjectBase<DerivedSV>& SV,
      Eigen::PlainObjectBase<DerivedSF>& SF,
      Eigen::SparseMatrix<BCType>& BC) {
    Eigen::VectorXi _J;
    return igl::marching_tets(TV, TT, S, isovalue, SV, SF, _J, BC);
  }

  // marching_tets( TV, TT, S, isovalue, SV, SF)
  //
  // performs the marching tetrahedra algorithm on a tet mesh defined by TV and
  // TT with scalar values defined at each vertex in TV. The output is a
  // triangle mesh approximating the isosurface coresponding to the value
  // isovalue.
  //
  // Input:
  //  TV  #tet_vertices x 3 array -- The vertices of the tetrahedral mesh
  //  TT  #tets x 4 array --  The indexes of each tet in the tetrahedral mesh
  //  S  #tet_vertices x 1 array -- The values defined on each tet vertex
  //  isovalue  scalar -- The isovalue of the level set we want to compute
  //
  // Output:
  //  SV  #SV x 3 array -- The vertices of the output level surface mesh
  //  SF  #SF x 3 array -- The face indexes of the output level surface mesh
  template <typename DerivedTV,
            typename DerivedTT,
            typename DerivedS,
            typename DerivedSV,
            typename DerivedSF>
  IGL_INLINE void marching_tets(
      const Eigen::MatrixBase<DerivedTV>& TV,
      const Eigen::MatrixBase<DerivedTT>& TT,
      const Eigen::MatrixBase<DerivedS>& S,
      double isovalue,
      Eigen::PlainObjectBase<DerivedSV>& SV,
      Eigen::PlainObjectBase<DerivedSF>& SF) {
    Eigen::VectorXi _J;
    Eigen::SparseMatrix<double> _BC;
    return igl::marching_tets(TV, TT, S, isovalue, SV, SF, _J, _BC);
  }

}

#ifndef IGL_STATIC_LIBRARY
#  include "marching_tets.cpp"
#endif

#endif // IGL_MARCHING_TETS_H