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 55 typedef std::pair<Position, Position>
KeyType;
65 typedef std::vector<std::pair<PointType, std::pair<Position, Position> > >
VectorType;
199 static const Position topology_modifier[8] = {1, 2, 4, 8, 16, 32, 64, 128};
207 topology |= ((
values[i] > threshold) ? topology_modifier[i] : 0);
252 template <
typename T>
258 template <
typename T>
264 template <
typename T>
271 template <
typename T>
276 template <
typename T>
282 template <
typename T>
289 template <
typename T>
301 template <
typename T>
305 && Surface::operator == (data.data_));
308 template <
typename T>
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)); )
358 current_index += number_of_cells_x;
378 template <
typename T>
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);
447 const double& d1 = cube.
values[indices.first];
448 const double& d2 = cube.
values[indices.second];
452 triangle_vertices[vertex_counter++] =
vertex.size();
460 static Vector3 null_normal(0.0, 0.0, 0.0);
461 normal.push_back(null_normal);
470 if (vertex_counter == 3)
473 t.
v1 = triangle_vertices.
x;
474 t.
v2 = triangle_vertices.
y;
475 t.
v3 = triangle_vertices.
z;
487 h1.
z * h2.
x - h2.
z * h1.
x,
488 h1.
x * h2.
y - h1.
y * h2.
x);
HashMap< std::pair< Position, Position >, Position > cut_hash_map_
vector< Normal > normal
the normals for each vertex
Position current_position_
T threshold_
The threshold separating inside and outside.
const TRegularData3D< T > * grid_
TContourSurface()
Default constructor.
bool operator==(const TContourSurface< T > &surface) const
Equality operator.
void addTriangles_(Cube &cube, const FacetArray &facet_data)
HashMap class based on the STL map (containing serveral convenience functions)
Vector3 getCoordinates(Position index) const
Position getIndex(Position corner) const
Return the absolute grid position for a given corner.
HashIndex Hash(const T &key)
vector< Triangle > triangle
the triangles
CoordinateType getCoordinates(const IndexType &index) const
virtual ~TContourSurface()
Destructor.
Vector3 getOrigin() const
const TContourSurface< T > & operator<<(const TRegularData3D< T > &data)
Create a contour surface from a given data set.
const CoordinateType & getOrigin() const
Index FacetArray[256][12]
std::vector< std::pair< PointType, std::pair< Position, Position > > > VectorType
virtual void clear()
Clear method.
Cube(const TRegularData3D< T > &grid)
const TContourSurface & operator=(const TContourSurface< T > &surface)
Assignment operator.
BALL_EXPORT const FacetArray & getContourSurfaceFacetData(double threshold)
TContourSurface< float > ContourSurface
Default type.
std::pair< Position, Position > KeyType
vector< Vertex > vertex
the vertices
const IndexType & getSize() const
const Vector3 & getSpacing() const
Position computeTopology(double threshold)
Compute the topology code for the current cube.
void computeTriangles(Size topology, const TRegularData3D< T > &data)