330 for (
Position curr_cell_z = 0; curr_cell_z < (number_of_cells_z - 1); curr_cell_z++)
333 current_index = curr_cell_z * number_of_cells_y * number_of_cells_x;
336 for (
Position curr_cell_y = 0; curr_cell_y < (number_of_cells_y - 1); curr_cell_y++)
340 cube.
setTo(current_index);
343 for (
Position curr_cell_x = 0; (curr_cell_x < (number_of_cells_x - 2)); )
346 addTriangles_(cube, facet_data);
355 addTriangles_(cube, facet_data);
358 current_index += number_of_cells_x;
363 for (
Position i = 0; i < normal.size(); i++)
367 normal[i].normalize();
386 static std::pair<Position, Position> key;
387 static std::pair<Position, Position> indices;
390 static const Position edge_indices[12][2]
391 = {{1, 0}, {1, 2}, {2, 3}, {0, 3}, {5, 4}, {5, 6},
392 {6, 7}, {4, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}
398 = {2, 0, 2, 0, 2, 0, 2, 0, 1, 1, 1, 1};
408 Size vertex_counter = 0;
423 Index facet_index = facet_data[topology][i];
426 if (facet_index != -1)
431 Position edge = edge_axis[facet_index];
433 indices.first = edge_indices[facet_index][0];
434 indices.second = edge_indices[facet_index][1];
435 key.first = cube.
getIndex(indices.first);
436 key.second = cube.
getIndex(indices.second);
439 if (!cut_hash_map_.has(key))
447 const double& d1 = cube.
values[indices.first];
448 const double& d2 = cube.
values[indices.second];
449 pos[edge] += ((
double)threshold_ - d1) / (d2 - d1) * spacing[edge];
452 triangle_vertices[vertex_counter++] = vertex.size();
456 cut_hash_map_.insert(std::pair<std::pair<Position, Position>,
Position>(key, (
Size)vertex.size()));
459 vertex.push_back(pos);
460 static Vector3 null_normal(0.0, 0.0, 0.0);
461 normal.push_back(null_normal);
466 triangle_vertices[vertex_counter++] = cut_hash_map_[key];
470 if (vertex_counter == 3)
473 t.v1 = triangle_vertices.
x;
474 t.v2 = triangle_vertices.
y;
475 t.v3 = triangle_vertices.
z;
476 triangle.push_back(t);
484 Vector3 h1(vertex[t.v1] - vertex[t.v2]);
485 Vector3 h2(vertex[t.v3] - vertex[t.v2]);
487 h1.
z * h2.
x - h2.
z * h1.
x,
488 h1.
x * h2.
y - h1.
y * h2.
x);
489 normal[t.v1] += current_normal;
490 normal[t.v2] += current_normal;
491 normal[t.v3] += current_normal;