5 #ifndef BALL_DATATYPE_CONTOURSURFACE_H 6 #define BALL_DATATYPE_CONTOURSURFACE_H 12 #ifndef BALL_DATATYPE_REGULARDATA3D_H 16 #ifndef BALL_MATHS_SURFACE_H 20 #ifndef BALL_DATATYPE_HASHMAP_H 56 typedef std::pair<Position, Position>
KeyType;
66 typedef std::vector<std::pair<PointType, std::pair<Position, Position> > >
VectorType;
100 virtual void clear();
200 static const Position topology_modifier[8] = {1, 2, 4, 8, 16, 32, 64, 128};
208 topology |= ((
values[i] > threshold) ? topology_modifier[i] : 0);
253 template <
typename T>
259 template <
typename T>
265 template <
typename T>
272 template <
typename T>
277 template <
typename T>
283 template <
typename T>
290 template <
typename T>
302 template <
typename T>
306 && Surface::operator == (data.data_));
309 template <
typename T>
331 for (
Position curr_cell_z = 0; curr_cell_z < (number_of_cells_z - 1); curr_cell_z++)
334 current_index = curr_cell_z * number_of_cells_y * number_of_cells_x;
337 for (
Position curr_cell_y = 0; curr_cell_y < (number_of_cells_y - 1); curr_cell_y++)
341 cube.
setTo(current_index);
344 for (
Position curr_cell_x = 0; (curr_cell_x < (number_of_cells_x - 2)); )
359 current_index += number_of_cells_x;
379 template <
typename T>
387 static std::pair<Position, Position> key;
388 static std::pair<Position, Position> indices;
391 static const Position edge_indices[12][2]
392 = {{1, 0}, {1, 2}, {2, 3}, {0, 3}, {5, 4}, {5, 6},
393 {6, 7}, {4, 7}, {0, 4}, {1, 5}, {2, 6}, {3, 7}
399 = {2, 0, 2, 0, 2, 0, 2, 0, 1, 1, 1, 1};
409 Size vertex_counter = 0;
424 Index facet_index = facet_data[topology][i];
427 if (facet_index != -1)
432 Position edge = edge_axis[facet_index];
434 indices.first = edge_indices[facet_index][0];
435 indices.second = edge_indices[facet_index][1];
436 key.first = cube.
getIndex(indices.first);
437 key.second = cube.
getIndex(indices.second);
448 const double& d1 = cube.
values[indices.first];
449 const double& d2 = cube.
values[indices.second];
453 triangle_vertices[vertex_counter++] =
vertex.size();
461 static Vector3 null_normal(0.0, 0.0, 0.0);
462 normal.push_back(null_normal);
471 if (vertex_counter == 3)
474 t.
v1 = triangle_vertices.
x;
475 t.
v2 = triangle_vertices.
y;
476 t.
v3 = triangle_vertices.
z;
488 h1.
z * h2.
x - h2.
z * h1.
x,
489 h1.
x * h2.
y - h1.
y * h2.
x);
HashIndex Hash(const T &key)
T threshold_
The threshold separating inside and outside.
CoordinateType getCoordinates(const IndexType &index) const
TContourSurface()
Default constructor.
Cube(const TRegularData3D< T > &grid)
Index FacetArray[256][12]
void computeTriangles(Size topology, const TRegularData3D< T > &data)
const Vector3 & getSpacing() const
BALL_EXPORT const FacetArray & getContourSurfaceFacetData(double threshold)
vector< Normal > normal
the normals for each vertex
Vector3 getOrigin() const
TContourSurface< float > ContourSurface
Default type.
Position computeTopology(double threshold)
Compute the topology code for the current cube.
std::vector< std::pair< PointType, std::pair< Position, Position > > > VectorType
const IndexType & getSize() const
vector< Vertex > vertex
the vertices
const TContourSurface & operator=(const TContourSurface< T > &surface)
Assignment operator.
const TRegularData3D< T > * grid_
vector< Triangle > triangle
the triangles
const TContourSurface< T > & operator<<(const TRegularData3D< T > &data)
Create a contour surface from a given data set.
-*- Mode: C++; tab-width: 2; -*-
Position current_position_
Position getIndex(Position corner) const
Return the absolute grid position for a given corner.
std::pair< Position, Position > KeyType
virtual ~TContourSurface()
Destructor.
Vector3 getCoordinates(Position index) const
const CoordinateType & getOrigin() const
HashMap< std::pair< Position, Position >, Position > cut_hash_map_
virtual void clear()
Clear method.
HashMap class based on the STL map (containing serveral convenience functions)
bool operator==(const TContourSurface< T > &surface) const
Equality operator.
void addTriangles_(Cube &cube, const FacetArray &facet_data)