Merge pull request #5037 from oboes/Heat_method_3-mollify-oboes

Add mollification step to avoid degenerate faces
This commit is contained in:
Laurent Rineau 2021-04-06 15:13:20 +02:00
commit c904cb79c7
5 changed files with 922 additions and 12 deletions

View File

@ -485,9 +485,6 @@ public:
template<class VertexDistanceMap>
void estimate_geodesic_distances(VertexDistanceMap vdm)
{
CGAL_precondition(
!CGAL::Heat_method_3::internal::has_degenerate_faces(triangle_mesh(), Traits()));
if(is_empty(tm)){
return;
}
@ -666,6 +663,9 @@ struct Base_helper
template <class VertexDistanceMap>
void estimate_geodesic_distances(VertexDistanceMap vdm)
{
CGAL_assertion(
!CGAL::Heat_method_3::internal::has_degenerate_faces(
base().triangle_mesh(), Traits()));
base().estimate_geodesic_distances(vdm);
}
};
@ -751,9 +751,6 @@ struct Base_helper<TriangleMesh, Traits, Intrinsic_Delaunay, LA, VertexPointMap>
template <class VertexDistanceMap>
void estimate_geodesic_distances(VertexDistanceMap vdm)
{
CGAL_precondition(
!CGAL::Heat_method_3::internal::has_degenerate_faces(
this->m_idt.triangle_mesh(), Traits()));
base().estimate_geodesic_distances(this->m_idt.vertex_distance_map(vdm));
}
};
@ -769,11 +766,11 @@ struct Base_helper<TriangleMesh, Traits, Intrinsic_Delaunay, LA, VertexPointMap>
* time after changes to the set of sources.
*
* \tparam TriangleMesh a triangulated surface mesh, model of `FaceListGraph` and `HalfedgeListGraph`
* with no degenerate faces
* \tparam Mode must be `Intrinsic_Delaunay` to indicate that an intrinsic Delaunay triangulation is internally constructed
* or `Direct` to indicate that the input mesh should be used as is.
* If `Intrinsic_Delaunay`, then the type `TriangleMesh` must have an internal property for `vertex_point`
* and its value type must be the same as the value type of `VertexPointMap`.
* If `Direct`, then the input mesh should not have any degenerate faces.
* \tparam VertexPointMap a model of `ReadablePropertyMap` with
* `boost::graph_traits<TriangleMesh>::%vertex_descriptor` as key and
* `Traits::Point_3` as value type.
@ -940,7 +937,7 @@ public:
* \tparam VertexDistanceMap a property map model of `WritablePropertyMap`
* with `vertex_descriptor` as key type and `double` as value type.
* \param vdm the vertex distance map to be filled
* \pre the support triangle mesh does not have any degenerate faces
* \pre If `Mode` is `Direct`, the support triangle mesh does not have any degenerate faces
* \warning The key type is `double` even when used with an exact kernel.
**/
template <class VertexDistanceMap>
@ -961,7 +958,7 @@ public:
/// \tparam Mode either the tag `Direct` or `Intrinsic_Delaunay`, which determines if the geodesic distance
/// is computed directly on the mesh or if the intrinsic Delaunay triangulation is applied first.
/// The default is `Intrinsic_Delaunay`.
/// \pre `tm` does not have any degenerate faces
/// \pre If `Mode` is `Direct`, `tm` does not have any degenerate faces
/// \warning The return type is `double` even when used with an exact kernel.
///
/// \sa `CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3`
@ -1003,7 +1000,7 @@ estimate_geodesic_distances(const TriangleMesh& tm,
/// \tparam Mode either the tag `Direct` or `Intrinsic_Delaunay`, which determines if the geodesic distance
/// is computed directly on the mesh or if the intrinsic Delaunay triangulation is applied first.
/// The default is `Intrinsic_Delaunay`.
/// \pre `tm` does not have any degenerate faces
/// \pre If `Mode` is `Direct`, `tm` mesh does not have any degenerate faces
/// \warning The return type is `double` even when used with an exact kernel.
/// \sa `CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3`
template <typename TriangleMesh, typename VertexDistanceMap, typename VertexConstRange, typename Mode>

View File

@ -43,8 +43,6 @@
namespace CGAL {
namespace Heat_method_3 {
// forward declaration
template <typename IDT>
struct IDT_vertex_point_property_map;
@ -53,6 +51,12 @@ struct IDT_vertex_point_property_map;
template <typename IDT, typename PM>
struct IDT_vertex_distance_property_map;
// forward declaration
namespace internal {
template<typename TriangleMesh, typename Traits>
bool has_degenerate_faces(const TriangleMesh& tm, const Traits& traits);
}
template <class TriangleMesh>
struct Intrinsic_Delaunay_triangulation_3_vertex_descriptor {
typedef typename boost::graph_traits<TriangleMesh>::halfedge_descriptor halfedge_descriptor;
@ -285,6 +289,29 @@ private:
return CGAL::sqrt(S*(S-a)*(S-b)*(S-c));
}
// Mollification strategy to avoid degeneracies
void
mollify(const double delta)
{
// compute smallest length epsilon we can add to
// all edges to ensure that the strict triangle
// inequality holds with a tolerance of delta
double epsilon = 0;
for(halfedge_descriptor hd : halfedges(m_intrinsic_tm)) {
halfedge_descriptor hd2 = next(hd, m_intrinsic_tm);
halfedge_descriptor hd3 = next(hd2,m_intrinsic_tm);
Index i = get(edge_id_map, edge(hd,m_intrinsic_tm));
Index j = get(edge_id_map, edge(hd2,m_intrinsic_tm));
Index k = get(edge_id_map, edge(hd3,m_intrinsic_tm));
double ineq = edge_lengths[j] + edge_lengths[k] - edge_lengths[i];
epsilon = (std::max)(epsilon, (std::max)(0., delta-ineq));
}
// update edge lengths
for(edge_descriptor ed : edges(m_intrinsic_tm)) {
Index i = get(edge_id_map, ed);
edge_lengths[i] += epsilon;
}
}
void
loop_over_edges(edge_stack stack, std::vector<int>& marked_edges)
@ -365,13 +392,19 @@ private:
Index edge_i = 0;
VertexPointMap vpm_intrinsic_tm = get(boost::vertex_point,m_intrinsic_tm);
double min_length = (std::numeric_limits<double>::max)();
for(edge_descriptor ed : edges(m_intrinsic_tm)) {
edge_lengths[edge_i] = CGAL::sqrt(to_double(squared_distance(get(vpm_intrinsic_tm, source(ed,m_intrinsic_tm)),
get(vpm_intrinsic_tm, target(ed,m_intrinsic_tm)))));
// Polygon_mesh_processing::edge_length(halfedge(ed,m_intrinsic_tm),m_intrinsic_tm);
if (edge_lengths[edge_i] != 0 && edge_lengths[edge_i] < min_length) min_length = edge_lengths[edge_i];
put(edge_id_map, ed, edge_i++);
stack.push(ed);
}
if(CGAL::Heat_method_3::internal::has_degenerate_faces(m_intrinsic_tm, Traits()))
mollify(min_length*1e-4);
loop_over_edges(stack, mark_edges);
//now that edges are calculated, go through and for each face, calculate the vertex positions around it

View File

@ -48,3 +48,6 @@ target_link_libraries(heat_method_surface_mesh_test PUBLIC CGAL::Eigen3_support)
create_single_source_cgal_program("heat_method_surface_mesh_direct_test.cpp")
target_link_libraries(heat_method_surface_mesh_direct_test
PUBLIC CGAL::Eigen3_support)
create_single_source_cgal_program("heat_method_surface_mesh_intrinsic_test.cpp")
target_link_libraries(heat_method_surface_mesh_intrinsic_test
PUBLIC CGAL::Eigen3_support)

View File

@ -0,0 +1,762 @@
OFF
270 490 0
0 0 0
1 1 0
2 1 0
0 1 0
1 0 0
2 0 0
1 0.5 0
0.53125 0.47916666666666669 0
1.5 0.5 0
0.48958333333333331 0.22916666666666666 0
0.5 1 0
0 0.5 0
1.5 0 0
2 0.5 0
1.5 1 0
1 0.5 0
0.5 0 0
0.75 0.75 0
0.28749999999999998 0.25 0
0.25 0.75 0
1.75 0.75 0
1.25 0.25 0
1.75 0.25 0
1.25 0.75 0
0.23958333333333334 0.10416666666666667 0
0.75 0.375 0
0.75 0.125 0
1 0.75 0
1 0.25 0
0.75 0.48214285714285715 0
0.75 1 0
0.25 1 0
0.5 0.75 0
0 0.75 0
0 0.25 0
0.25 0.5 0
1.25 0 0
1.75 0 0
1.5 0.25 0
2 0.25 0
2 0.75 0
1.75 0.5 0
1.75 1 0
1.25 1 0
1.5 0.75 0
1 0.75 0
1 0.25 0
1.25 0.5 0
0.25 0 0
0.75 0 0
0.875 0.1875 0
0.85416666666666663 0.85416666666666663 0
0.625 0.6428571428571429 0
0.85416666666666663 0.64583333333333337 0
0.625 0.8571428571428571 0
0.35714285714285715 0.375 0
0.125 0.15625 0
0.14285714285714285 0.375 0
0.375 0.625 0
0.14583333333333334 0.85416666666666663 0
0.14285714285714285 0.625 0
0.375 0.8571428571428571 0
1.8541666666666667 0.85416666666666663 0
1.625 0.625 0
1.8571428571428572 0.625 0
1.625 0.8571428571428571 0
1.375 0.375 0
1.1458333333333333 0.14583333333333334 0
1.375 0.14285714285714285 0
1.1428571428571428 0.375 0
1.625 0.375 0
1.8541666666666667 0.14583333333333334 0
1.8571428571428572 0.375 0
1.625 0.14285714285714285 0
1.375 0.625 0
1.1458333333333333 0.85416666666666663 0
1.1428571428571428 0.625 0
1.375 0.8571428571428571 0
0.125 0.0625 0
0.3482142857142857 0.17857142857142858 0
0.375 0.072916666666666671 0
0.5982142857142857 0.3125 0
0.875 0.42708333333333331 0
0.625 0.42708333333333331 0
0.625 0.1875 0
0.875 0.072916666666666671 0
0.625 0.072916666666666671 0
0.875 0.3125 0
0.52500000000000002 0.40000000000000002 0
0.5 0.125 0
0.375 0.28125 0
0.75 0.25 0
1 0.625 0
1 0.875 0
0.875 0.75 0
1 0.125 0
1 0.375 0
0.625 0.51249999999999996 0
0.875 0.51249999999999996 0
0.75 0.625 0
0.875 1 0
0.625 1 0
0.75 0.875 0
0.375 1 0
0.125 1 0
0.25 0.875 0
0.5 0.875 0
0.5 0.625 0
0.625 0.75 0
0.375 0.75 0
0 0.875 0
0 0.625 0
0.125 0.75 0
0 0.375 0
0 0.125 0
0.125 0.25 0
0.125 0.5 0
0.375 0.5 0
0.25 0.625 0
0.25 0.375 0
1.125 0 0
1.375 0 0
1.25 0.125 0
1.625 0 0
1.875 0 0
1.75 0.125 0
1.5 0.125 0
1.5 0.375 0
1.375 0.25 0
1.625 0.25 0
2 0.125 0
2 0.375 0
1.875 0.25 0
2 0.625 0
2 0.875 0
1.875 0.75 0
1.875 0.5 0
1.625 0.5 0
1.75 0.375 0
1.75 0.625 0
1.875 1 0
1.625 1 0
1.75 0.875 0
1.375 1 0
1.125 1 0
1.25 0.875 0
1.5 0.875 0
1.5 0.625 0
1.625 0.75 0
1.375 0.75 0
1 0.875 0
1 0.625 0
1.125 0.75 0
1 0.375 0
1 0.125 0
1.125 0.25 0
1.125 0.5 0
1.375 0.5 0
1.25 0.625 0
1.25 0.375 0
0.125 0 0
0.375 0 0
0.625 0 0
0.875 0 0
1.4583333333333333 0.79166666666666663 0
1.3125 0.9375 0
1.4375 0.9375 0
1.2916666666666667 0.79166666666666663 0
1.0625 0.6875 0
1.2083333333333333 0.54166666666666663 0
1.0625 0.5625 0
0.91666666666666663 0.91666666666666663 0
0.79166666666666663 0.79166666666666663 0
0.9375 0.8125 0
0.8125 0.9375 0
0.70833333333333337 0.70833333333333337 0
0.5625 0.5625 0
0.6875 0.5625 0
0.54166666666666663 0.70833333333333337 0
0.79166666666666663 0.70833333333333337 0
0.91666666666666663 0.58333333333333337 0
0.9375 0.6875 0
0.8125 0.5625 0
0.70833333333333337 0.79166666666666663 0
0.5625 0.9375 0
0.54166666666666663 0.79166666666666663 0
0.6875 0.9375 0
0.4375 0.4375 0
0.28749999999999998 0.3125 0
0.46875 0.33333333333333331 0
0.29166666666666669 0.45833333333333331 0
0.21875 0.20833333333333334 0
1.2083333333333333 0.70833333333333337 0
0.0625 0.21249999999999999 0
0.20833333333333334 0.29166666666666669 0
0.0625 0.4375 0
0.0625 0.3125 0
0.20833333333333334 0.45833333333333331 0
0.45833333333333331 0.54166666666666663 0
0.29166666666666669 0.70833333333333337 0
0.29166666666666669 0.54166666666666663 0
0.45833333333333331 0.70833333333333337 0
0.20833333333333334 0.79166666666666663 0
0.083333333333333329 0.91666666666666663 0
0.0625 0.8125 0
0.1875 0.9375 0
0.20833333333333334 0.70833333333333337 0
0.0625 0.5625 0
0.20833333333333334 0.54166666666666663 0
0.0625 0.6875 0
0.29166666666666669 0.79166666666666663 0
0.4375 0.9375 0
0.3125 0.9375 0
0.45833333333333331 0.79166666666666663 0
1.9166666666666667 0.91666666666666663 0
1.7916666666666667 0.79166666666666663 0
1.9375 0.8125 0
1.8125 0.9375 0
1.7083333333333333 0.70833333333333337 0
1.5416666666666667 0.54166666666666663 0
1.7083333333333333 0.54166666666666663 0
1.5416666666666667 0.70833333333333337 0
1.7916666666666667 0.70833333333333337 0
1.9375 0.5625 0
1.9375 0.6875 0
1.7916666666666667 0.54166666666666663 0
1.7083333333333333 0.79166666666666663 0
1.5625 0.9375 0
1.5416666666666667 0.79166666666666663 0
1.6875 0.9375 0
1.4583333333333333 0.45833333333333331 0
1.2916666666666667 0.29166666666666669 0
1.4583333333333333 0.29166666666666669 0
1.2916666666666667 0.45833333333333331 0
1.2083333333333333 0.20833333333333334 0
1.0833333333333333 0.083333333333333329 0
1.1875 0.0625 0
1.0625 0.1875 0
1.2916666666666667 0.20833333333333334 0
1.4375 0.0625 0
1.4583333333333333 0.20833333333333334 0
1.3125 0.0625 0
1.2083333333333333 0.29166666666666669 0
1.0625 0.4375 0
1.0625 0.3125 0
1.2083333333333333 0.45833333333333331 0
1.5416666666666667 0.45833333333333331 0
1.7083333333333333 0.29166666666666669 0
1.7083333333333333 0.45833333333333331 0
1.5416666666666667 0.29166666666666669 0
1.7916666666666667 0.20833333333333334 0
1.9166666666666667 0.083333333333333329 0
1.9375 0.1875 0
1.8125 0.0625 0
1.7916666666666667 0.29166666666666669 0
1.9375 0.4375 0
1.7916666666666667 0.45833333333333331 0
1.9375 0.3125 0
1.7083333333333333 0.20833333333333334 0
1.5625 0.0625 0
1.6875 0.0625 0
1.5416666666666667 0.20833333333333334 0
1.4583333333333333 0.54166666666666663 0
1.2916666666666667 0.70833333333333337 0
1.2916666666666667 0.54166666666666663 0
1.4583333333333333 0.70833333333333337 0
1.2083333333333333 0.79166666666666663 0
1.0833333333333333 0.91666666666666663 0
1.0625 0.8125 0
1.1875 0.9375 0
3 94 172 179
3 118 199 206
3 138 247 254
3 158 263 192
3 91 26 50
3 15 6 96
3 90 9 189
3 108 175 183
3 128 231 238
3 148 218 226
3 167 263 149
3 228 65 146
3 105 202 210
3 115 191 194
3 125 250 258
3 135 215 222
3 145 266 167
3 155 234 242
3 27 15 151
3 95 28 50
3 99 53 179
3 179 53 94
3 90 55 188
3 188 18 90
3 112 60 206
3 206 60 118
3 139 64 222
3 222 64 135
3 122 68 238
3 238 68 128
3 132 72 254
3 254 72 138
3 152 76 192
3 192 76 158
3 48 161 80
3 24 79 191
3 88 187 189
3 166 14 143
3 91 81 84
3 165 166 143
3 94 53 181
3 15 27 92
3 149 265 164
3 46 28 95
3 181 173 94
3 99 52 177
3 211 61 106
3 209 60 112
3 182 53 99
3 212 205 105
3 207 195 116
3 114 0 78
3 117 187 198
3 196 193 115
3 259 73 126
3 257 72 132
3 127 70 246
3 260 253 125
3 255 223 136
3 135 64 224
3 137 219 246
3 224 216 135
3 166 77 146
3 168 76 152
3 246 70 137
3 165 269 145
3 170 243 156
3 93 45 150
3 241 68 122
3 28 46 153
3 157 230 262
3 244 237 155
3 80 24 48
3 85 26 49
3 227 14 166
3 85 4 95
3 173 171 51
3 93 1 171
3 107 58 198
3 52 176 177
3 99 177 182
3 53 180 181
3 185 178 108
3 106 61 213
3 189 187 55
3 88 7 187
3 263 74 149
3 115 57 196
3 116 60 207
3 57 195 196
3 200 190 117
3 118 60 208
3 105 61 212
3 59 203 204
3 208 200 118
3 116 197 208
3 106 184 211
3 61 211 212
3 216 214 62
3 134 2 214
3 225 64 139
3 137 70 248
3 136 72 255
3 64 223 224
3 228 221 148
3 146 77 164
3 249 70 127
3 128 68 240
3 155 69 244
3 67 235 236
3 240 232 128
3 126 73 261
3 156 76 170
3 69 243 244
3 248 220 137
3 138 72 256
3 125 73 260
3 71 251 252
3 256 248 138
3 136 225 256
3 126 239 259
3 73 259 260
3 264 233 157
3 158 76 169
3 145 77 165
3 75 267 268
3 169 264 158
3 156 245 169
3 146 227 166
3 77 166 165
3 89 9 79
3 78 0 160
3 91 25 81
3 191 56 24
3 80 161 16
3 78 160 48
3 98 180 182
3 189 9 81
3 87 28 96
3 91 50 87
3 97 29 177
3 96 6 82
3 86 162 49
3 80 16 89
3 95 50 85
3 84 9 89
3 86 84 89
3 87 25 91
3 164 228 146
3 87 50 28
3 88 81 83
3 89 16 86
3 83 7 88
3 89 79 80
3 90 18 79
3 18 188 194
3 97 7 83
3 49 163 85
3 173 51 94
3 92 6 15
3 173 27 93
3 93 27 45
3 17 175 179
3 93 171 173
3 96 82 87
3 95 4 154
3 92 27 181
3 153 15 96
3 83 25 29
3 7 176 198
3 98 29 82
3 29 25 82
3 17 172 183
3 82 6 98
3 102 51 174
3 106 54 184
3 94 51 172
3 101 184 186
3 205 59 105
3 205 31 104
3 206 199 19
3 104 203 205
3 178 52 108
3 103 31 212
3 83 29 97
3 109 58 201
3 179 172 17
3 107 52 178
3 118 58 199
3 32 185 213
3 112 59 204
3 195 57 116
3 19 199 210
3 111 207 209
3 193 56 115
3 78 56 114
3 191 79 18
3 114 56 193
3 190 35 197
3 113 34 196
3 189 81 88
3 119 55 190
3 19 202 206
3 190 55 117
3 79 9 90
3 200 58 118
3 122 67 236
3 126 68 239
3 21 231 242
3 121 239 241
3 253 71 125
3 253 37 124
3 254 247 22
3 124 251 253
3 232 66 128
3 123 37 260
3 8 219 262
3 129 70 249
3 21 234 238
3 127 66 232
3 138 70 247
3 38 240 261
3 132 71 252
3 223 64 136
3 22 247 258
3 131 255 257
3 216 62 135
3 216 40 134
3 20 218 222
3 134 214 216
3 220 41 225
3 133 40 224
3 8 230 246
3 139 63 220
3 22 250 254
3 220 63 137
3 20 215 226
3 248 70 138
3 142 62 217
3 146 65 227
3 135 62 215
3 141 227 229
3 269 75 145
3 269 43 144
3 192 263 23
3 144 267 269
3 221 63 148
3 143 43 165
3 137 63 219
3 149 74 265
3 222 215 20
3 147 63 221
3 158 74 263
3 44 228 164
3 152 75 268
3 150 1 93
3 243 69 156
3 151 45 27
3 23 263 167
3 151 170 168
3 237 67 155
3 96 28 153
3 237 46 154
3 154 46 95
3 238 231 21
3 154 235 237
3 233 47 245
3 153 46 244
3 246 219 8
3 159 66 233
3 23 266 192
3 233 66 157
3 128 66 231
3 264 74 158
3 48 24 78
3 16 162 86
3 49 26 86
3 163 4 85
3 192 266 152
3 84 26 91
3 268 45 168
3 50 26 85
3 152 268 168
3 79 24 80
3 169 245 47
3 81 25 83
3 151 15 170
3 81 9 84
3 168 45 151
3 82 25 87
3 266 75 152
3 86 26 84
3 186 54 102
3 100 30 174
3 183 175 17
3 51 171 174
3 181 27 173
3 102 54 183
3 174 171 100
3 171 1 100
3 201 58 107
3 108 52 175
3 198 187 7
3 108 54 185
3 177 176 97
3 176 7 97
3 185 32 178
3 183 54 108
3 182 180 53
3 175 52 99
3 182 29 98
3 98 6 180
3 181 180 92
3 180 6 92
3 177 29 182
3 179 175 99
3 186 184 54
3 172 51 102
3 186 30 101
3 101 10 184
3 201 32 213
3 102 174 186
3 174 30 186
3 183 172 102
3 197 57 119
3 117 55 187
3 194 191 18
3 117 58 200
3 189 55 90
3 119 57 194
3 200 35 190
3 198 58 117
3 193 34 114
3 115 56 191
3 168 170 76
3 78 24 56
3 196 34 193
3 194 57 115
3 208 60 116
3 188 55 119
3 207 11 195
3 119 190 197
3 196 195 113
3 195 11 113
3 116 57 197
3 194 188 119
3 213 61 109
3 176 52 107
3 210 202 19
3 107 178 201
3 208 35 200
3 109 61 210
3 178 32 201
3 198 176 107
3 205 203 59
3 105 59 202
3 110 33 204
3 104 3 203
3 204 203 110
3 203 3 110
3 212 31 205
3 210 61 105
3 209 207 60
3 202 59 112
3 209 33 111
3 111 11 207
3 208 197 35
3 112 204 209
3 204 33 209
3 206 202 112
3 213 185 106
3 199 58 109
3 184 10 211
3 109 201 213
3 212 211 103
3 211 10 103
3 185 54 106
3 210 199 109
3 229 65 142
3 140 42 217
3 226 218 20
3 62 214 217
3 224 40 216
3 142 65 226
3 217 214 140
3 214 2 140
3 265 74 147
3 148 63 218
3 262 230 8
3 148 65 228
3 248 41 220
3 147 74 262
3 228 44 221
3 226 65 148
3 256 72 136
3 218 63 139
3 255 13 223
3 139 220 225
3 224 223 133
3 223 13 133
3 136 64 225
3 222 218 139
3 229 227 65
3 215 62 142
3 229 42 141
3 141 14 227
3 265 44 164
3 142 217 229
3 217 42 229
3 226 215 142
3 245 69 159
3 157 66 230
3 242 234 21
3 157 74 264
3 240 38 232
3 159 69 242
3 264 47 233
3 262 74 157
3 237 235 67
3 155 67 234
3 120 36 236
3 154 4 235
3 236 235 120
3 235 4 120
3 244 46 237
3 242 69 155
3 241 239 68
3 234 67 122
3 241 36 121
3 121 12 239
3 249 38 261
3 122 236 241
3 236 36 241
3 238 234 122
3 169 76 156
3 231 66 159
3 170 15 243
3 159 233 245
3 244 243 153
3 243 15 153
3 156 69 245
3 242 231 159
3 261 73 129
3 230 66 127
3 258 250 22
3 127 232 249
3 256 41 248
3 129 73 258
3 232 38 249
3 246 230 127
3 253 251 71
3 125 71 250
3 130 39 252
3 124 5 251
3 252 251 130
3 251 5 130
3 260 37 253
3 258 73 125
3 257 255 72
3 250 71 132
3 257 39 131
3 131 13 255
3 256 225 41
3 132 252 257
3 252 39 257
3 254 250 132
3 261 240 126
3 247 70 129
3 239 12 259
3 129 249 261
3 260 259 123
3 259 12 123
3 240 68 126
3 258 247 129
3 164 77 149
3 219 63 147
3 167 266 23
3 147 221 265
3 169 47 264
3 149 77 167
3 221 44 265
3 262 219 147
3 269 267 75
3 145 75 266
3 150 45 268
3 144 1 267
3 268 267 150
3 267 1 150
3 165 43 269
3 167 77 145

View File

@ -0,0 +1,115 @@
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h>
#include <fstream>
#include <iostream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;
typedef CGAL::Surface_mesh<Point_3> Surface_mesh;
typedef boost::graph_traits<Surface_mesh>::vertex_descriptor vertex_descriptor;
typedef Surface_mesh::Property_map<vertex_descriptor,double> Vertex_distance_map;
typedef CGAL::Heat_method_3::Surface_mesh_geodesic_distances_3<Surface_mesh,
CGAL::Heat_method_3::Intrinsic_Delaunay> Heat_method;
int main(int argc, char* argv[])
{
//read in mesh
Surface_mesh sm;
const char* filename = (argc > 1) ? argv[1] : "./data/rectangle_with_degenerate_faces.off";
std::ifstream in(filename);
in >> sm;
//property map for the distance values to the source set
Vertex_distance_map vertex_distance = sm.add_property_map<vertex_descriptor, double>("v:distance", 0).first;
Heat_method hm(sm);
//add the first vertex as the source set
vertex_descriptor source = *(vertices(sm).first);
hm.add_source(source);
assert(hm.sources().size() == 1);
hm.estimate_geodesic_distances(vertex_distance);
Point_3 sp = sm.point(source);
std::cout << "source: " << sp << " " << source << std::endl;
vertex_descriptor vfar;
double sdistance = 0;
for(vertex_descriptor vd : vertices(sm)){
if(get(vertex_distance,vd) > sdistance){
vfar = vd;
sdistance = get(vertex_distance,vd);
}
}
assert(sdistance > 1.);
assert(sdistance < 2.26);//2.236 = sqrt(5)
hm.add_source(vfar);
assert(hm.sources().size() == 2);
hm.estimate_geodesic_distances(vertex_distance);
sdistance = 0;
for(vertex_descriptor vd : vertices(sm)){
if(get(vertex_distance,vd) > sdistance){
sdistance = get(vertex_distance,vd);
}
}
assert(sdistance > 1.);
assert(sdistance < 2.26);//2.236 = sqrt(5)
hm.remove_source(vfar);
assert(hm.sources().size() == 1);
hm.clear_sources();
// add range of sources
std::vector<vertex_descriptor> vrange;
vrange.push_back(source);
vrange.push_back(vfar);
hm.add_sources(vrange);
assert(hm.sources().size() == 2);
hm.estimate_geodesic_distances(vertex_distance);
sdistance = 0;
for(vertex_descriptor vd : vertices(sm)){
if(get(vertex_distance,vd) > sdistance){
sdistance = get(vertex_distance,vd);
}
}
assert(sdistance > 1.);
assert(sdistance < 2.26);//2.236 = sqrt(5)
// do it again for one source
hm.clear_sources();
assert(hm.sources().size() == 0);
hm.add_source(source);
hm.estimate_geodesic_distances(vertex_distance);
for(vertex_descriptor vd : vertices(sm)){
if(get(vertex_distance,vd) > sdistance){
sdistance = get(vertex_distance,vd);
}
}
assert(sdistance > 1.);
assert(sdistance < 2.26);//2.236 = sqrt(5)
CGAL::Heat_method_3::estimate_geodesic_distances(sm, vertex_distance, source,
CGAL::Heat_method_3::Intrinsic_Delaunay());
sdistance = 0;
for(vertex_descriptor vd : vertices(sm)){
if(get(vertex_distance,vd) > sdistance){
sdistance = get(vertex_distance,vd);
}
}
assert(sdistance > 1.);
assert(sdistance < 2.26);//2.236 = sqrt(5)
std::cout << "done" << std::endl;
return 0;
}