Commit 7221c0b6 authored by Mike Kremer's avatar Mike Kremer

Finished tutorial 4

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@74 66977474-1d4b-4f09-8fe9-267525286df2
parent 4b723c12
......@@ -8,8 +8,9 @@ As for now, the file format only supports plain text, but a support
for binary files is planned. Also the data type for vertices is restricted
to OpenVolumeMesh::Geometry::Vec3d and the serialization of the
properties is restricted to integral types for the moment.
A full generic support is also planned for the future. Find the
file format specification below.
A full generic support is also planned for the future.
%OpenVolumeMesh files should have the file name extension *.ovm.
Find the file format specification below.
\section file_spec File Format Specification
......
......@@ -28,7 +28,15 @@ provides some specific topology checks and, more importantly,
a set of specialized iterators.
The following code creates a polyhedral mesh instance and fills it
with two adjacent tetrahedra:
with two adjacent tetrahedra. Note that when defining cells in %OpenVolumeMesh,
the incident half-faces that define a cell are supposed to form a two-manifold.
This particularly implies that they are supposed to have the same orientation
(whether their normal points inside the cell or outside the cell does not matter,
but convention assumes the half-face normals to point inside the cell).
%OpenVolumeMesh per default performs a check whether the specified half-faces
form a two-manifold when adding a cell. This check can explicitly turned off
by passing false as second parameter to OpenVolumeMesh::PolyhedralMesh<VecT>::add_face().
Note that in these cases, it is not guaranteed that a given mesh is three-manifold.
\code
typedef OpenVolumeMesh::Geometry::Vec3d Vec3d
......
......@@ -30,7 +30,9 @@ for(OpenVolumeMesh::HexahedralMesh<Vec3f>::HalfEdgeIter he_it = myMesh.halfedges
\endcode
In the next example, we iterate over all incident outgoing half-edges of a given
vertex.
vertex. Note that this iterator need bottom-up adjacencies to be computed for
the mesh. Otherwise, the iterator would not be valid. See Section \ref concepts
for information on the bottom-up adjacencies.
\code
typedef OpenVolumeMesh::Geometry::Vec3f Vec3f;
......@@ -41,6 +43,9 @@ OpenVolumeMesh::PolyhedralMesh<Vec3f> myMesh;
// Fill mesh with geometry
...
// Compute bottom-up adjacencies
myMesh.update_adjacencies();
typedef OpenVolumeMesh::PolyhedralMesh<Vec3f>::VertexHandle VertexHandle;
// Get first vertex in mesh
......@@ -82,6 +87,9 @@ HexahedralMeshV3d myMesh;
// Fill mesh with geometry
...
// Compute bottom-up adjacencies
myMesh.update_adjacencies();
// Get handle of first cell
HexahedralMeshV3d::CellHandle ch = *(myMesh.cells_begin());
......
......@@ -2,4 +2,61 @@
\page tutorial_03 Tutorial 03: Adding Properties
In %OpenVolumeMesh it is possible to attach multiple properties to each of the entities.
Due to the use of STL template programming, these properties can be of any data type.
In this tutorial, we learn how to attach properties to the entities of a polyhedral mesh.
The following example shows how to attach a floating-point property to the vertices of a mesh.
\code
typedef OpenVolumeMesh::Geometry::Vec3d Vec3d;
typedef OpenVolumeMesh::PolyhedralMesh<Vec3d> PolyhedralMeshV3d;
void someFunction() {
// Create mesh object
PolyhedralMeshV3d myMesh;
// Fill mesh with geometry
...
// Add property
OpenVolumeMesh::VPropHandleT<float> floatProp;
myMesh.add_property(floatProp, "Vertex Weights");
// Now, iterate over all vertices and set property value to some number
float val = 0.0f;
for(PolyhedralMeshV3d::VertexIter v_it = myMesh.vertices_begin();
v_it != myMesh.vertices_end(); ++v_it) {
// Set property value
myMesh.property(floatProp, *v_it) = val;
// Increase value by 1.5
val += 1.5f;
}
// Call some other function
someOtherFunction(myMesh);
// Remove property from mesh
myMesh.remove_property(floatProp);
}
void someOtherFunction(PolyhedralMeshV3d& _mesh) {
// Try to get property handle by its name
OpenVolumeMesh::VPropHandleT<float> propHandle;
if(_mesh.get_property_handle(propHandle, "Vertex Weights")) {
// Now propHandle is a valid handle to the property.
// Access property value via _mesh.property(propHandle, vertexHandle).
}
}
\endcode
For all other entities, this works the same way. Use class OpenVolumeMesh::EPropHandleT
as handle type for edge properties, OpenVolumeMesh::HFPropHandleT for half-face properties,
and so on...
**/
......@@ -2,4 +2,72 @@
\page tutorial_04 Tutorial 04: Using File I/O
The %OpenVolumeMesh library is equipped with a file manager class that
allows reading polyhedral meshes from file as well as writing mesh objects
to files. The format for these files is specified in \ref file_format.
In this tutorial, we will learn how to use the file manager in order to
permanently store mesh objects and read them.
Consider the following code for an example on how to write a polyhedral mesh to a file:
\code
// Include the file manager header
#include <OpenVolumeMesh/FileManager/FileManager.hh>
// Include the polyhedral mesh header
#include <OpenVolumeMesh/PolyhedralMesh/PolyhedralMesh.hh>
...
typedef OpenVolumeMesh::PolyhedralMesh<Vec3f> PolyhedralMeshV3f;
void someFunction() {
// Create mesh object
PolyhedralMeshV3f myMesh;
// Fill mesh with geometry
...
// Create file manager object
OpenVolumeMesh::IO::FileManager fileManager;
// Store mesh to file "myMesh.ovm" in the current directory
fileManager.writeFile("myMesh.ovm", myMesh);
}
\endcode
This works analogously for reading files into mesh objects. See the
following code for an example.
\code
// Include the file manager header
#include <OpenVolumeMesh/FileManager/FileManager.hh>
// Include the polyhedral mesh header
#include <OpenVolumeMesh/PolyhedralMesh/PolyhedralMesh.hh>
...
typedef OpenVolumeMesh::PolyhedralMesh<Vec3f> PolyhedralMeshV3f;
void someFunction() {
// Create an empty mesh object
PolyhedralMeshV3f myMesh;
// Create file manager object
OpenVolumeMesh::IO::FileManager fileManager;
// Read mesh from file "myMesh.ovm" in the current directory
fileManager.readFile("myMesh.ovm", myMesh);
}
\endcode
Function OpenVolumeMesh::IO::FileManager::readFile() expects a total of five parameters,
two of which are mandatory (file name and mesh reference). The other three parameters
are optional flags that control whether bottom-up adjacencies should be computed automatically,
whether the topology check should be performed when adding faces and cells and
also whether face normals should be computed automatically. All three flags are turned on
per default.
**/
......@@ -118,12 +118,9 @@ class OpenVolumeMeshCell;
the half-edge index of the second half-edge of edge k is 2*k+1.
This works analogously for half-faces.
\TODO:
- Make vertex points, edges, faces, etc.
be default properties
- Make status be a dynamic property for each entity
- Implement const iterators
\todo Make vertex points, edges, faces, etc. be default properties
\todo Make status be a dynamic property for each entity
\todo Implement const iterators
*/
//***************************************************************************
......
......@@ -477,7 +477,8 @@ PolyhedralMesh<VecT>::add_cell(const std::vector<HalfFaceHandle>& _halffaces, bo
if(_topologyCheck) {
/*
* Test if all halffaces are connected => Cell is closed
* Test if all halffaces are connected and form a two-manifold
* => Cell is closed
*
* The test works as follows: Put every incident halfedge of
* all faces into a set. Only if all faces are pairwise
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment