...
 
Commits (15)
......@@ -93,7 +93,7 @@ IF "%APPS%" == "ON" (
)
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DGTEST_PREFIX="%LIBPATH%\%ARCHITECTURE%\%GTESTVERSION%" -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=Release -DBUILD_APPS=%APPS% -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DCMAKE_WINDOWS_LIBS_DIR="e:\libs" -DOPENMESH_BUILD_SHARED=%SHARED% %CMAKE_CONFIGURATION% ..
"C:\Program Files\CMake\bin\cmake.exe" -DGTEST_PREFIX="%LIBPATH%\%ARCHITECTURE%\%GTESTVERSION%" -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=Release -DBUILD_APPS=%APPS% -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DCMAKE_WINDOWS_LIBS_DIR="e:\libs" -DOPENMESH_BUILD_SHARED=%SHARED% %CMAKE_CONFIGURATION% ..
%VS_PATH% /Build "Release" OpenMesh.sln /Project "ALL_BUILD"
......@@ -111,7 +111,7 @@ mkdir build-debug
cd build-debug
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DGTEST_PREFIX="%LIBPATH%\%ARCHITECTURE%\%GTESTVERSION%" -G "%GENERATOR%" -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_SHARED=%SHARED% -DBUILD_APPS=%APPS% %CMAKE_CONFIGURATION% ..
"C:\Program Files\CMake\bin\cmake.exe" -DGTEST_PREFIX="%LIBPATH%\%ARCHITECTURE%\%GTESTVERSION%" -G "%GENERATOR%" -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_SHARED=%SHARED% -DBUILD_APPS=%APPS% %CMAKE_CONFIGURATION% ..
%VS_PATH% /Build "Debug" OpenMesh.sln /Project "ALL_BUILD"
......@@ -139,7 +139,7 @@ cd build-release
del *.exe
"C:\Program Files (x86)\CMake\bin\cmake.exe" -DGTEST_PREFIX="%LIBPATH%\%ARCHITECTURE%\%GTESTVERSION%" -G "%GENERATOR%" -DBUILD_APPS=%APPS% -DCMAKE_BUILD_TYPE=Release %CMAKE_CONFIGURATION% ..
"C:\Program Files\CMake\bin\cmake.exe" -DGTEST_PREFIX="%LIBPATH%\%ARCHITECTURE%\%GTESTVERSION%" -G "%GENERATOR%" -DBUILD_APPS=%APPS% -DCMAKE_BUILD_TYPE=Release %CMAKE_CONFIGURATION% ..
%VS_PATH% /Build "Release" OpenMesh.sln /Project "PACKAGE"
......
......@@ -76,7 +76,7 @@ fi
cd build-release-$BUILDPATH-Vector-Checks
cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_BINDINGS=OFF $OPTIONS ../
cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON $OPTIONS ../
#build it
make $MAKE_OPTIONS
......@@ -99,51 +99,6 @@ cd Unittests
cd ..
cd ..
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Building Release version with vectorchecks disabled for python tests"
echo "======================================================================"
echo -e "${NC}"
if [ ! -d build-release-$BUILDPATH ]; then
mkdir build-release-$BUILDPATH
fi
cd build-release-$BUILDPATH
cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON -DBUILD_APPS=OFF $OPTIONS ../
#build it
make $MAKE_OPTIONS
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Running Python unittests Release version "
echo "======================================================================"
echo -e "${NC}"
if [ "$LANGUAGE" == "C++11" ] || [ "$COMPILER" == "gcc" ] ; then
# Execute Python unittests
cd Python-Unittests
python -m unittest discover -v
cd ..
else
echo -e "${WARNING}"
echo "WARNING! Python unittests disabled !!"
echo -e "${NC}"
fi
cd ..
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
......@@ -158,7 +113,7 @@ fi
cd build-debug-$BUILDPATH-Vector-Checks
cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_BINDINGS=OFF $OPTIONS ../
cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON $OPTIONS ../
#build it
make $MAKE_OPTIONS
......@@ -181,42 +136,3 @@ cd Unittests
cd ..
cd ..
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Building Debug version with vectorchecks disabled for python tests"
echo "======================================================================"
echo -e "${NC}"
if [ ! -d build-debug-$BUILDPATH ]; then
mkdir build-debug-$BUILDPATH
fi
cd build-debug-$BUILDPATH
cmake -DCMAKE_BUILD_TYPE=DEBUG -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON -DBUILD_APPS=OFF $OPTIONS ../
#build it
make $MAKE_OPTIONS
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Running Python unittests Debug version "
echo "======================================================================"
echo -e "${NC}"
if [ "$LANGUAGE" == "C++11" ] || [ "$COMPILER" == "gcc" ] ; then
# Execute Python unittests
cd Python-Unittests
python -m unittest discover -v
else
echo -e "${WARNING}"
echo "WARNING! Python unittests disabled !!"
echo -e "${NC}"
fi
......@@ -58,7 +58,7 @@ fi
cd build-release-$BUILDPATH-Vector-Checks
cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=OFF $OPTIONS ../
cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON $OPTIONS ../
#build it
make
......@@ -81,53 +81,6 @@ cd Unittests
cd ..
cd ..
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Building Release version with vectorchecks disabled for python tests"
echo "======================================================================"
echo -e "${NC}"
if [ ! -d build-release-$BUILDPATH ]; then
mkdir build-release-$BUILDPATH
fi
cd build-release-$BUILDPATH
cmake -DCMAKE_BUILD_TYPE=Release -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON -DBUILD_APPS=OFF -DCPACK_BINARY_DRAGNDROP=ON $OPTIONS ../
#build it
make
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Running Python unittests Release version "
echo "======================================================================"
echo -e "${NC}"
if [ "$LANGUAGE" == "C++11" ]; then
# Execute Python unittests
cd Python-Unittests
rm -f openmesh.so
cp ../Build/python/openmesh.so .
python -m unittest discover -v
cd ..
else
echo -e "${WARNING}"
echo "WARNING! Python unittests disabled for clang on Mac with c++98 !!"
echo -e "${NC}"
fi
cd ..
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
......@@ -142,7 +95,7 @@ fi
cd build-debug-$BUILDPATH-Vector-Checks
cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=OFF $OPTIONS ../
cmake -DCMAKE_BUILD_TYPE=Debug -DOPENMESH_BUILD_UNIT_TESTS=TRUE -DSTL_VECTOR_CHECKS=ON $OPTIONS ../
#build it
make
......@@ -169,60 +122,19 @@ cd ..
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Building Debug version with vectorchecks disabled for python tests"
echo "Package creation (DMG and tarball)"
echo "======================================================================"
echo -e "${NC}"
if [ ! -d build-debug-$BUILDPATH ]; then
mkdir build-debug-$BUILDPATH
if [ ! -d build-release-$BUILDPATH ]; then
mkdir build-release-$BUILDPATH
fi
cd build-debug-$BUILDPATH
cd build-release-$BUILDPATH
cmake -DCMAKE_BUILD_TYPE=DEBUG -DOPENMESH_BUILD_PYTHON_UNIT_TESTS=ON -DBUILD_APPS=OFF $OPTIONS ../
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_APPS=OFF -DCPACK_BINARY_DRAGNDROP=ON $OPTIONS ../
#build it
make
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Running Python unittests Debug version "
echo "======================================================================"
echo -e "${NC}"
if [ "$LANGUAGE" == "C++11" ]; then
# Execute Python unittests
cd Python-Unittests
rm -f openmesh.so
cp ../Build/python/openmesh.so .
python -m unittest discover -v
cd ..
else
echo -e "${WARNING}"
echo "WARNING! Python unittests disabled for clang on Mac with c++98 !!"
echo -e "${NC}"
fi
cd ..
echo -e "${OUTPUT}"
echo ""
echo "======================================================================"
echo "Package creation (DMG and tarball)"
echo "======================================================================"
echo -e "${NC}"
cd build-release-$BUILDPATH
cp ../build-debug-$BUILDPATH/Build/lib/* ./Build/lib/
cmake .
make package
......@@ -129,12 +129,6 @@ endif()
add_subdirectory (Doc)
# ========================================================================
# Include Python interface
# ========================================================================
add_subdirectory (src/Python)
# ========================================================================
# Bundle generation (Targets exist, now configure them)
# ========================================================================
......
##################################################
# Getting Started
##################################################
from openmesh import *
mesh = TriMesh()
##################################################
# Adding Items to a Mesh
##################################################
# add a a couple of vertices to the mesh
vh0 = mesh.add_vertex(TriMesh.Point(0, 1, 0))
vh1 = mesh.add_vertex(TriMesh.Point(1, 0, 0))
vh2 = mesh.add_vertex(TriMesh.Point(2, 1, 0))
vh3 = mesh.add_vertex(TriMesh.Point(0,-1, 0))
vh4 = mesh.add_vertex(TriMesh.Point(2,-1, 0))
# add a couple of faces to the mesh
fh0 = mesh.add_face(vh0, vh1, vh2)
fh1 = mesh.add_face(vh1, vh3, vh4)
fh2 = mesh.add_face(vh0, vh3, vh1)
# add another face to the mesh, this time using a list
vh_list = [vh2, vh1, vh4]
fh3 = mesh.add_face(vh_list)
# 0 ==== 2
# |\ 0 /|
# | \ / |
# |2 1 3|
# | / \ |
# |/ 1 \|
# 3 ==== 4
##################################################
# Iterators
##################################################
# iterate over all vertices
for vh in mesh.vertices():
print vh.idx()
# iterate over all halfedges
for heh in mesh.halfedges():
print heh.idx()
# iterate over all edges
for eh in mesh.edges():
print eh.idx()
# iterate over all faces
for fh in mesh.faces():
print fh.idx()
##################################################
# Circulators
##################################################
# iterate over all neighboring vertices
for vh in mesh.vv(vh1):
print vh.idx()
# iterate over all incoming halfedges
for heh in mesh.vih(vh1):
print heh.idx()
# iterate over all outgoing halfedges
for heh in mesh.voh(vh1):
print heh.idx()
# iterate over all adjacent edges
for eh in mesh.ve(vh1):
print eh.idx()
# iterate over all adjacent faces
for fh in mesh.vf(vh1):
print fh.idx()
# iterate over the face's vertices
for vh in mesh.fv(fh0):
print vh.idx()
# iterate over the face's halfedges
for heh in mesh.fh(fh0):
print heh.idx()
# iterate over the face's edges
for eh in mesh.fe(fh0):
print eh.idx()
# iterate over all edge-neighboring faces
for fh in mesh.ff(fh0):
print fh.idx()
##################################################
# Properties
##################################################
prop_handle = VPropHandle()
mesh.add_property(prop_handle, "cogs")
for vh in mesh.vertices():
cog = TriMesh.Point(0,0,0)
valence = 0
for neighbor in mesh.vv(vh):
cog += mesh.point(neighbor)
valence += 1
mesh.set_property(prop_handle, vh, cog / valence)
mesh.remove_property(prop_handle)
##################################################
# Property Managers
##################################################
prop_man = VPropertyManager(mesh, "cogs")
prop_man.set_range(mesh.vertices(), TriMesh.Point(0,0,0))
for vh in mesh.vertices():
valence = 0
for neighbor in mesh.vv(vh):
prop_man[vh] += mesh.point(neighbor)
valence += 1
prop_man[vh] /= valence
##################################################
# I/O
##################################################
mesh = TriMesh()
read_mesh(mesh, "bunny.obj")
# modify mesh ...
write_mesh(mesh, "bunny.obj")
mesh = TriMesh()
mesh.request_halfedge_normals()
mesh.request_vertex_normals()
options = Options()
options += Options.VertexNormal
result = read_mesh(mesh, "bunny.obj", options)
if result:
print "everything worked"
else:
print "something went wrong"
......@@ -11,6 +11,7 @@
<b>Breaking changes</b>
<ul>
<li>The minimal standard for C++ has been raised to C++11. Compilers not supporting C++11 or higher are no longer supported</li>
<li>Removed the python bindings from this project. They have migrated to a <a href="https://www.graphics.rwth-aachen.de:9000/OpenMesh/openmesh-python">seperate project</a>.</li>
</ul>
<b>Core</b>
......
......@@ -87,14 +87,6 @@ repeatedly replacing each vertex' position by the center of gravity
<br /><br />
\section python_and_om OpenMesh Python interface
OpenMesh itself is written in C++. We also provide a python interface
to use OpenMesh. A detailed description of the interface can be found
in the following tutorial:
\li \subpage python_tutorial
<br /><br />
\subpage additional_information
\li \ref mesh_first_to_read
......
/** \page python_tutorial Python Tutorial
This tutorial will introduce the basic concepts behind the %OpenMesh Python
Bindings. We will cover the following topics:
\li How to build the Python Bindings
\li How to create an empty mesh
\li How to add vertices and faces to a mesh
\li How to navigate on a mesh using iterators and circulators
\li How to add and remove custom properties
\li How to read and write meshes from files
In addition, we will briefly discuss some of the differences between the Python
Bindings and the original C++ implementation of %OpenMesh.
\section python_build Building the Python Bindings
The Python Bindings depend on the following libraries:
\li Python (2.7 or later)
\li Boost Python (1.54.0 or later)
\note Make sure that your Boost Python and Python versions match, i.e. that
Boost Python was linked against the correct Python version.
The Python Bindings are automatically built with %OpenMesh. The generated files are written to the
Build/python subdirectory of the build tree. For more information on how to build %OpenMesh see
\ref compiling.
If CMake does not find your Python installation (or finds the wrong one) you can
explicitly specify an installation by setting the following variables:
\verbatim
PYTHON_LIBRARY - Path to the python library
PYTHON_INCLUDE_DIR - Path to where Python.h is found
\endverbatim
Similarly, if CMake does not find your Boost Python installation, set the
following variables:
\verbatim
BOOST_ROOT - Preferred installation prefix
BOOST_INCLUDEDIR - Preferred include directory e.g. <prefix>/include
BOOST_LIBRARYDIR - Preferred library directory e.g. <prefix>/lib
\endverbatim
\section python_start Getting Started
To use the %OpenMesh Python Bindings we first need to import the openmesh module:
\dontinclude python_tutorial.py
\skipline from
The module provides two mesh classes: One for polygonal meshes (PolyMesh) and
one for triangle meshes (TriMesh). You should use triangle meshes whenever
possible, since they are usually more efficient. In addition, some algorithms
are only implemented for triangle meshes while triangle meshes inherit the full
functionality of polygonal meshes.
The following code creates a new triangle mesh:
\skipline mesh
\section python_add Adding Items to a Mesh
We can add a new vertex to the mesh by calling the add_vertex() member function.
This function gets a coordinate and returns a handle to the newly inserted
vertex.
\skipline vh0
\until vh4
To add a new face to the mesh we have to call add_face(). This function gets the
handles of the vertices that make up the new face and returns a handle to the
newly inserted face:
\skipline fh0
\until fh2
We can also use a Python list to add a face to the mesh:
\skipline vh_list
\until fh3
\section python_iterators Iterators and Circulators
Now that we have added a couple of vertices to the mesh, we can iterate over
them and print out their indices:
\skipline for
\until vh.idx()
We can also iterate over halfedges, edges and faces by calling mesh.halfedges(),
mesh.edges() and mesh.faces() respectively:
\skipline iterate
\until fh.idx()
To iterate over the items adjacent to another item we can use one of the
circulator functions. For example, to iterate over the vertices adjacent to
another vertex we can call mesh.vv() and pass the handle of the center vertex:
\skipline for
\until vh.idx()
We can also iterate over the adjacent halfedges, edges and faces:
\skipline iterate
\until fh.idx()
To iterate over the items adjacent to a face we can use the following functions:
\skipline iterate
\until fh.idx()
\section python_props Properties
%OpenMesh allows us to dynamically add custom properties to a mesh. We can add
properties to vertices, halfedges, edges, faces and the mesh itself. To
add a property to a mesh (and later access its value) we have to use a property
handle of the appropriate type:
\li VPropHandle (for vertex properties)
\li HPropHandle (for halfedge properties)
\li EPropHandle (for edge properties)
\li FPropHandle (for face properties)
\li MPropHandle (for mesh properties)
The following code shows how to add a vertex property to a mesh:
\skipline prop_handle
\until mesh
The second parameter of the function add_property() is optional. The parameter
is used to specify a name for the new property. This name can later be used
to retrieve a handle to the property using the get_property_handle() member
function.
Now that we have added a vertex property to the mesh we can set and get its
value. Here we will use the property to store the center of gravity of each
vertex' neighborhood:
\skipline for
\until mesh.set_property
Properties use Python's type system. This means that we can use the same
property to store values of different types (e.g. store both strings and
integers using the same vertex property). Properties are initialized to the
Python built-in constant None.
To remove a property we have to call remove_property() with the appropriate
property handle:
\skipline mesh.remove_property
\section python_propman Property Managers
Another way to add and remove a property is to use a property manager. A
Property manager encapsulates a property and manages its lifecycle. A Property
manager also provides a number of convenience functions to access the enclosed
property.
There are four different types of property managers. One for each type of mesh
item:
\li VPropertyManager (for vertex properties)
\li HPropertyManager (for halfedge properties)
\li EPropertyManager (for edge properties)
\li FPropertyManager (for face properties)
Property managers automatically add a new property to a mesh when they are
initialized. Thus the following code not only creates a new vertex property
manager, but also adds a new vertex property to the mesh:
\skipline prop_man
Property managers allow us to conveniently set the property value for an entire
range of mesh items:
\skipline prop_man
They also allow us to use the subscript operator to set and get property values.
Here we will once again use a property to store the center of gravity of each
vertex' neighborhood:
\skipline for
\until prop_man[vh] /= valence
Properties that are encapsulated by a property manager are automatically removed
from the mesh when the property manager goes out of scope (i.e. the property
manager is garbage collected).
\section python_io Read and write meshes from files
You can read and write meshes from files using the read_mesh() and write_mesh()
functions:
\skipline mesh
\until write_mesh(mesh, "bunny.obj")
The file type is automatically deduced from the file extension. %OpenMesh
currently supports four file types: .off, .obj, .stl and .om
The behaviour of the I/O functions can be controlled by passing an instance of
the Options class to either read_mesh() or write_mesh(). The class controls the
behaviour of the I/O functions by means of enabled/disabled bits in a bitset:
\skipline mesh
\until print "something went wrong"
Other available option bits include:
-# mode bits - control binary reading/writing
- Options.Binary
- Options.MSB
- Options.LSB
- Options.Swap (MSB|LSB)
-# property bits - controls which standard properties to read/write
- Options.VertexNormal
- Options.VertexTexCoord
- Options.VertexColor
- Options.FaceNormal
- Options.FaceColor
- Options.ColorAlpha
- Options.ColorFloat
\note You have to pass an instance of the Options class to the I/O functions,
i.e. you cannot directly pass one of the option bits. For example, directly
passing Options.Binary to either one of the functions will cause an error.
When reading a file the options are used as hints, i.e. depending on the format
we can help the reader to interpret the data correctly.
\note If you want to read a property from a file the property must have been
requested prior to reading the file.
When writing the mesh the mode bits control whether to use the binary variant of
the respective file format and the desired byte-ordering.
\section python_examples Additional Code Examples
You can use our unit tests to learn more about the %OpenMesh Python Bindings.
They are located in the src/Python/Unittests subdirectory.
\section python_cpp Python and C++
The interface of the Python Bindings is to a large extent identical to the
interface of the original C++ implementation of %OpenMesh. You should therefore
be able to use the C++ documentation as a reference for the Python Bindings. In
particular, the classes KernelT, PolyMeshT and TriMeshT provide a good overview
of the available mesh member functions. That being said, there are a number of
small differences. For example, whenever the C++ implementation returns a
reference to an object that is managed by %OpenMesh, the Python Bindings will
return a copy of that object. This is due to the fact that Python does not have
a language feature that is analogous to C++ references. One example of such a
function is the point() member function of the PolyMesh and TriMesh classes.
Unlike its C++ counterpart, the function does not return a reference to the
requested point. It instead returns a copy of the point. This implies that you
have to use the set_point() member function to change the value of a point. The
same applies to the following functions: normal(), color(), property(),
status(), etc.
<br>The complete source looks like this:
\include python_tutorial.py
**/
......@@ -10,6 +10,9 @@ https://www.graphics.rwth-aachen.de:9000/OpenMesh/OpenMesh.git
The gitlab site can be found here:
https://www.graphics.rwth-aachen.de:9000/OpenMesh/OpenMesh
The python bindings can be found here:
https://www.graphics.rwth-aachen.de:9000/OpenMesh/openmesh-python
## Installing
Unpack the tar-ball to a suitable place.
......
......@@ -744,48 +744,34 @@ private:
{
//mesh has no points?
}
if(this->get_property_handle(vertex_normals_,
"v:normals"))
refcount_vnormals_ = 1;
if(this->get_property_handle(vertex_colors_,
"v:colors"))
refcount_vcolors_ = 1;
if(this->get_property_handle(vertex_texcoords1D_,
"v:texcoords1D"))
refcount_vtexcoords1D_ = 1;
if(this->get_property_handle(vertex_texcoords2D_,
"v:texcoords2D"))
refcount_vtexcoords2D_ = 1;
if(this->get_property_handle(vertex_texcoords3D_,
"v:texcoords3D"))
refcount_vtexcoords3D_ = 1;
if(this->get_property_handle(halfedge_texcoords1D_,
"h:texcoords1D"))
refcount_htexcoords1D_ = 1;
if(this->get_property_handle(halfedge_texcoords2D_,
"h:texcoords2D"))
refcount_htexcoords2D_ = 1;
if(this->get_property_handle(halfedge_texcoords3D_,
"h:texcoords3D"))
refcount_htexcoords3D_ = 1;
if(this->get_property_handle(halfedge_normals_,
"h:normals"))
refcount_henormals_ = 1;
if(this->get_property_handle(halfedge_colors_,
"h:colors"))
refcount_hecolors_ = 1;
if(this->get_property_handle(edge_colors_,
"e:colors"))
refcount_ecolors_ = 1;
if(this->get_property_handle(face_normals_,
"f:normals"))
refcount_fnormals_ = 1;
if(this->get_property_handle(face_colors_,
"f:colors"))
refcount_fcolors_ = 1;
if(this->get_property_handle(face_texture_index_,
"f:textureindex"))
refcount_ftextureIndex_ = 1;
refcount_vnormals_ = this->get_property_handle(vertex_normals_,
"v:normals") ? 1 : 0 ;
refcount_vcolors_ = this->get_property_handle(vertex_colors_,
"v:colors") ? 1 : 0 ;
refcount_vtexcoords1D_ = this->get_property_handle(vertex_texcoords1D_,
"v:texcoords1D") ? 1 : 0 ;
refcount_vtexcoords2D_ = this->get_property_handle(vertex_texcoords2D_,
"v:texcoords2D") ? 1 : 0 ;
refcount_vtexcoords3D_ = this->get_property_handle(vertex_texcoords3D_,
"v:texcoords3D") ? 1 : 0 ;
refcount_htexcoords1D_ = this->get_property_handle(halfedge_texcoords1D_,
"h:texcoords1D") ? 1 : 0 ;
refcount_htexcoords2D_ = this->get_property_handle(halfedge_texcoords2D_,
"h:texcoords2D") ? 1 : 0 ;
refcount_htexcoords3D_ = this->get_property_handle(halfedge_texcoords3D_,
"h:texcoords3D") ? 1 : 0 ;
refcount_henormals_ = this->get_property_handle(halfedge_normals_,
"h:normals") ? 1 : 0 ;
refcount_hecolors_ = this->get_property_handle(halfedge_colors_,
"h:colors") ? 1 : 0 ;
refcount_ecolors_ = this->get_property_handle(edge_colors_,
"e:colors") ? 1 : 0 ;
refcount_fnormals_ = this->get_property_handle(face_normals_,
"f:normals") ? 1 : 0 ;
refcount_fcolors_ = this->get_property_handle(face_colors_,
"f:colors") ? 1 : 0 ;
refcount_ftextureIndex_ = this->get_property_handle(face_texture_index_,
"f:textureindex") ? 1 : 0 ;
}
};
......
......@@ -488,6 +488,11 @@ void TriConnectivity::split(EdgeHandle _eh, VertexHandle _vh)
void TriConnectivity::split_copy(EdgeHandle _eh, VertexHandle _vh)
{
const VertexHandle v0 = to_vertex_handle(halfedge_handle(_eh, 0));
const VertexHandle v1 = to_vertex_handle(halfedge_handle(_eh, 1));
const int nf = n_faces();
// Split the halfedge ( handle will be preserved)
split(_eh, _vh);
......@@ -495,6 +500,22 @@ void TriConnectivity::split_copy(EdgeHandle _eh, VertexHandle _vh)
// have been created
for(VEIter ve_it = ve_iter(_vh); ve_it.is_valid(); ++ve_it)
copy_all_properties(_eh, *ve_it, true);
for (auto vh : {v0, v1})
{
// get the halfedge pointing from new vertex to old vertex
const HalfedgeHandle h = find_halfedge(_vh, vh);
if (!is_boundary(h)) // for boundaries there are no faces whose properties need to be copied
{
FaceHandle fh0 = face_handle(h);
FaceHandle fh1 = face_handle(opposite_halfedge_handle(prev_halfedge_handle(h)));
if (fh0.idx() >= nf) // is fh0 the new face?
std::swap(fh0, fh1);
// copy properties from old face to new face
copy_all_properties(fh0, fh1, true);
}
}
}
}// namespace OpenMesh
#include "Python/Bindings.hh"
#include "Python/Vector.hh"
#include "Python/Mesh.hh"
#include "Python/PropertyManager.hh"
#include "Python/InputOutput.hh"
#include "Python/Decimater.hh"
#include <memory>
namespace OpenMesh {
namespace Python {
/**
* Expose mesh items to %Python.
*/
void expose_items() {
class_<ArrayItems::Vertex>("Vertex");
class_<ArrayItems::Halfedge>("Halfedge");
class_<ArrayItems::Edge>("Edge");
class_<ArrayItems::Face>("Face");
}
/**
* Expose item and property handles to %Python.
*/
void expose_handles() {
class_<BaseHandle>("BaseHandle", init<optional<int> >())
.def("idx", &BaseHandle::idx)
.def("is_valid", &BaseHandle::is_valid)
.def("reset", &BaseHandle::reset)
.def("invalidate", &BaseHandle::invalidate)
.def(self == self)
.def(self != self)
.def(self < self)
;
class_<VertexHandle, bases<BaseHandle> >("VertexHandle", init<optional<int> >());
class_<HalfedgeHandle, bases<BaseHandle> >("HalfedgeHandle", init<optional<int> >());
class_<EdgeHandle, bases<BaseHandle> >("EdgeHandle", init<optional<int> >());
class_<FaceHandle, bases<BaseHandle> >("FaceHandle", init<optional<int> >());
class_<BasePropHandleT<object>, bases<BaseHandle> >("BasePropHandle", init<optional<int> >());
class_<VPropHandleT<object>, bases<BasePropHandleT<object> > >("VPropHandle", init<optional<int> >())
.def(init<const BasePropHandleT<object>&>());
class_<HPropHandleT<object>, bases<BasePropHandleT<object> > >("HPropHandle", init<optional<int> >())
.def(init<const BasePropHandleT<object>&>());
class_<EPropHandleT<object>, bases<BasePropHandleT<object> > >("EPropHandle", init<optional<int> >())
.def(init<const BasePropHandleT<object>&>());
class_<FPropHandleT<object>, bases<BasePropHandleT<object> > >("FPropHandle", init<optional<int> >())
.def(init<const BasePropHandleT<object>&>());
class_<MPropHandleT<object>, bases<BasePropHandleT<object> > >("MPropHandle", init<optional<int> >())
.def(init<const BasePropHandleT<object>&>());
}
/**
* Expose the StatusBits enum and StatusInfo class to %Python.
*/
void expose_status_bits_and_info() {
using OpenMesh::Attributes::StatusBits;
using OpenMesh::Attributes::StatusInfo;
enum_<StatusBits>("StatusBits")
.value("DELETED", OpenMesh::Attributes::DELETED)
.value("LOCKED", OpenMesh::Attributes::LOCKED)
.value("SELECTED", OpenMesh::Attributes::SELECTED)
.value("HIDDEN", OpenMesh::Attributes::HIDDEN)
.value("FEATURE", OpenMesh::Attributes::FEATURE)
.value("TAGGED", OpenMesh::Attributes::TAGGED)
.value("TAGGED2", OpenMesh::Attributes::TAGGED2)
.value("FIXEDNONMANIFOLD", OpenMesh::Attributes::FIXEDNONMANIFOLD)
.value("UNUSED", OpenMesh::Attributes::UNUSED)
;
class_<StatusInfo>("StatusInfo")
.def("deleted", &StatusInfo::deleted)
.def("set_deleted", &StatusInfo::set_deleted)
.def("locked", &StatusInfo::locked)
.def("set_locked", &StatusInfo::set_locked)
.def("selected", &StatusInfo::selected)
.def("set_selected", &StatusInfo::set_selected)
.def("hidden", &StatusInfo::hidden)
.def("set_hidden", &StatusInfo::set_hidden)
.def("feature", &StatusInfo::feature)
.def("set_feature", &StatusInfo::set_feature)
.def("tagged", &StatusInfo::tagged)
.def("set_tagged", &StatusInfo::set_tagged)
.def("tagged2", &StatusInfo::tagged2)
.def("set_tagged2", &StatusInfo::set_tagged2)
.def("fixed_nonmanifold", &StatusInfo::fixed_nonmanifold)
.def("set_fixed_nonmanifold", &StatusInfo::set_fixed_nonmanifold)
.def("bits", &StatusInfo::bits)
.def("set_bits", &StatusInfo::set_bits)
.def("is_bit_set", &StatusInfo::is_bit_set)
.def("set_bit", &StatusInfo::set_bit)
.def("unset_bit", &StatusInfo::unset_bit)
.def("change_bit", &StatusInfo::change_bit)
;
}
BOOST_PYTHON_MODULE(openmesh) {
expose_items();
expose_handles();
expose_status_bits_and_info();
expose_vec<float, 2>("Vec2f");
expose_vec<float, 3>("Vec3f");
expose_vec<float, 4>("Vec4f");
expose_vec<double, 2>("Vec2d");
expose_vec<double, 3>("Vec3d");
expose_vec<double, 4>("Vec4d");
expose_mesh<PolyMesh>("PolyMesh");
expose_mesh<TriMesh>("TriMesh");
expose_iterator<OpenMesh::PolyConnectivity::VertexIter, &OpenMesh::ArrayKernel::n_vertices>("VertexIter");
expose_iterator<OpenMesh::PolyConnectivity::HalfedgeIter, &OpenMesh::ArrayKernel::n_halfedges>("HalfedgeIter");
expose_iterator<OpenMesh::PolyConnectivity::EdgeIter, &OpenMesh::ArrayKernel::n_edges>("EdgeIter");
expose_iterator<OpenMesh::PolyConnectivity::FaceIter, &OpenMesh::ArrayKernel::n_faces>("FaceIter");
expose_circulator<OpenMesh::PolyConnectivity::VertexVertexIter, VertexHandle>("VertexVertexIter");
expose_circulator<OpenMesh::PolyConnectivity::VertexIHalfedgeIter, VertexHandle>("VertexIHalfedgeIter");
expose_circulator<OpenMesh::PolyConnectivity::VertexOHalfedgeIter, VertexHandle>("VertexOHalfedgeIter");
expose_circulator<OpenMesh::PolyConnectivity::VertexEdgeIter, VertexHandle>("VertexEdgeIter");
expose_circulator<OpenMesh::PolyConnectivity::VertexFaceIter, VertexHandle>("VertexFaceIter");
expose_circulator<OpenMesh::PolyConnectivity::FaceVertexIter, FaceHandle>("FaceVertexIter");
expose_circulator<OpenMesh::PolyConnectivity::FaceHalfedgeIter, FaceHandle>("FaceHalfedgeIter");
expose_circulator<OpenMesh::PolyConnectivity::FaceEdgeIter, FaceHandle>("FaceEdgeIter");
expose_circulator<OpenMesh::PolyConnectivity::FaceFaceIter, FaceHandle>("FaceFaceIter");
expose_circulator<OpenMesh::PolyConnectivity::HalfedgeLoopIter, HalfedgeHandle>("HalfedgeLoopIter");
typedef IteratorWrapperT<PolyConnectivity::VertexIter, &ArrayKernel::n_vertices> VertexIterWrapper;
typedef IteratorWrapperT<PolyConnectivity::HalfedgeIter, &ArrayKernel::n_halfedges> HalfedgeIterWrapper;
typedef IteratorWrapperT<PolyConnectivity::EdgeIter, &ArrayKernel::n_edges> EdgeIterWrapper;
typedef IteratorWrapperT<PolyConnectivity::FaceIter, &ArrayKernel::n_faces> FaceIterWrapper;
expose_property_manager<VPropHandleT<object>, VertexHandle, VertexIterWrapper>("VPropertyManager");
expose_property_manager<HPropHandleT<object>, HalfedgeHandle, HalfedgeIterWrapper>("HPropertyManager");
expose_property_manager<EPropHandleT<object>, EdgeHandle, EdgeIterWrapper>("EPropertyManager");
expose_property_manager<FPropHandleT<object>, FaceHandle, FaceIterWrapper>("FPropertyManager");
expose_io();
expose_decimater<PolyMesh>("PolyMesh");
expose_decimater<TriMesh>("TriMesh");
}
} // namespace Python
} // namespace OpenMesh
/** @file */
#ifndef OPENMESH_PYTHON_BINDINGS_HH
#define OPENMESH_PYTHON_BINDINGS_HH
#include <boost/python.hpp>
#include <boost/python/return_internal_reference.hpp>
#include <boost/python/reference_existing_object.hpp>
#include <boost/python/copy_const_reference.hpp>
#include "OpenMesh/Core/IO/MeshIO.hh"
#include "OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh"
#include "OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh"
using namespace boost::python;
namespace OpenMesh {
/**
* This namespace contains classes and functions that are used to expose
* %OpenMesh to %Python.
*/
namespace Python {
/**
* Return value policy for functions that return references to objects that are
* managed by %OpenMesh.
*/
#define OPENMESH_PYTHON_DEFAULT_POLICY return_value_policy<copy_const_reference>()
struct MeshTraits : public OpenMesh::DefaultTraits {
/** Use double precision points */
typedef OpenMesh::Vec3d Point;
/** Use double precision normals */
typedef OpenMesh::Vec3d Normal;
/** Use RGBA colors */
typedef OpenMesh::Vec4f Color;
};
typedef OpenMesh::TriMesh_ArrayKernelT<MeshTraits> TriMesh;
typedef OpenMesh::PolyMesh_ArrayKernelT<MeshTraits> PolyMesh;
} // namespace OpenMesh
} // namespace Python
#endif
IF(NOT DEFINED OPENMESH_BUILD_PYTHON_BINDINGS)
SET(OPENMESH_BUILD_PYTHON_BINDINGS TRUE CACHE BOOL "Enable or disable building the Python Bindings.")
ENDIF()
IF(NOT DEFINED OPENMESH_BUILD_PYTHON_UNIT_TESTS)
SET(OPENMESH_BUILD_PYTHON_UNIT_TESTS FALSE CACHE BOOL "Enable or disable building the Python unit tests.")
ENDIF()
IF(NOT DEFINED OPENMESH_PYTHON_VERSION)
SET(OPENMESH_PYTHON_VERSION "2.7" CACHE STRING "Choose the Python version that is used to build the Python Bindings.")
ENDIF()
IF(OPENMESH_BUILD_PYTHON_BINDINGS)
# Create log file
SET(PYTHONLOG "${CMAKE_CURRENT_BINARY_DIR}/PythonLog.txt")
FILE(WRITE ${PYTHONLOG} "")
# Look for the python libs
MESSAGE(STATUS "Looking for PythonLibs")
FIND_PACKAGE(PythonLibs ${OPENMESH_PYTHON_VERSION} QUIET)
IF(PYTHONLIBS_FOUND)
MESSAGE(STATUS "Looking for PythonLibs -- found")
# Determine the name of the python component
STRING(REGEX MATCH "^[0-9]+\\.[0-9]+" PYTHON_VERSION_MAJOR_MINOR ${PYTHONLIBS_VERSION_STRING})
STRING(REGEX REPLACE "\\." "" PYTHON_VERSION_MAJOR_MINOR ${PYTHON_VERSION_MAJOR_MINOR})
STRING(REGEX MATCH "^[0-9]" PYTHON_VERSION_MAJOR ${PYTHON_VERSION_MAJOR_MINOR})
MESSAGE(STATUS "Looking for Boost Python")
SET(BOOST_PYTHON_COMPONENT_NAMES "python-py${PYTHON_VERSION_MAJOR_MINOR}" "python${PYTHON_VERSION_MAJOR}" "python")
FOREACH(NAME ${BOOST_PYTHON_COMPONENT_NAMES})
IF(NOT Boost_FOUND)
FILE(APPEND ${PYTHONLOG} "Looking for component ${NAME}\n")
FIND_PACKAGE(Boost QUIET COMPONENTS ${NAME})
ENDIF()
ENDFOREACH()
FILE(APPEND ${PYTHONLOG} "\n")
IF(Boost_FOUND)
MESSAGE(STATUS "Looking for Boost Python -- found")
MESSAGE(STATUS "Checking the Boost Python configuration")
SET(CMAKE_TRY_COMPILE_CONFIGURATION "Release")
TRY_COMPILE(
COMPILE_WORKS
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Example/
Example
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES:STRING=${PYTHON_INCLUDE_DIRS};${Boost_INCLUDE_DIRS}"
"-DLINK_DIRECTORIES:STRING=${Boost_LIBRARY_DIRS}"
"-DLINK_LIBRARIES:STRING=${PYTHON_LIBRARIES};${Boost_LIBRARIES}"
OUTPUT_VARIABLE OUTPUT_TRY_COMPILE
)
FILE(APPEND ${PYTHONLOG} "INCLUDE_DIRECTORIES: ${PYTHON_INCLUDE_DIRS};${Boost_INCLUDE_DIRS}\n")
FILE(APPEND ${PYTHONLOG} "LINK_DIRECTORIES: ${Boost_LIBRARY_DIRS}\n")
FILE(APPEND ${PYTHONLOG} "LINK_LIBRARIES: ${PYTHON_LIBRARIES};${Boost_LIBRARIES}\n\n")
FILE(APPEND ${PYTHONLOG} "${OUTPUT_TRY_COMPILE}")
IF(COMPILE_WORKS)
# Look for the python interpreter to check if the example works
# strip version string of any characters (e.g. rc1 # '+') than 0-9 and .
STRING(REGEX REPLACE "(rc[0-9]+)|[^ 0-9 | \\.]" "" PYTHONLIBS_VERSION_STRING_STRIPPED ${PYTHONLIBS_VERSION_STRING})
FIND_PACKAGE(PythonInterp ${PYTHONLIBS_VERSION_STRING_STRIPPED} QUIET)
IF(PYTHONINTERP_FOUND)
IF(MSVC)
SET(PYTHON_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_TRY_COMPILE_CONFIGURATION}")
ELSE()
SET(PYTHON_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}")
ENDIF()
EXECUTE_PROCESS(
COMMAND ${PYTHON_EXECUTABLE} -c "from example import *; greet(); planet = World()"
WORKING_DIRECTORY ${PYTHON_WORKING_DIR}
RESULT_VARIABLE PYTHON_WORKS
OUTPUT_QUIET
ERROR_QUIET
)
IF(PYTHON_WORKS EQUAL 0)
### EVERYTHING WORKS ###
MESSAGE(STATUS "Checking the Boost Python configuration -- done")
IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND ${Boost_VERSION} VERSION_LESS 105600)
MESSAGE("There are known issues with Clang and Boost Python 1.55 and below.")
MESSAGE("Please consider updating Boost Python.")
ENDIF()
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Build/python/)
FILE(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
FILE(GLOB SOURCES *.cc *hh)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ../)
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
ADD_LIBRARY(openmesh SHARED ${SOURCES})
install(TARGETS openmesh DESTINATION ${ACG_PROJECT_LIBDIR}/python )
TARGET_LINK_LIBRARIES(
openmesh
OpenMeshCore
OpenMeshTools
${Boost_LIBRARIES}
${PYTHON_LIBRARIES}
)
SET_TARGET_PROPERTIES(
openmesh
PROPERTIES
PREFIX ""
DEBUG_POSTFIX ""
RELEASE_POSTFIX ""
)
IF(APPLE)
SET_TARGET_PROPERTIES(openmesh PROPERTIES SUFFIX ".so")
IF (NOT (CMAKE_MAJOR_VERSION LESS 3))
SET_TARGET_PROPERTIES(openmesh PROPERTIES MACOSX_RPATH TRUE)
ENDIF()
ENDIF()
IF(WIN32)
SET_TARGET_PROPERTIES(openmesh PROPERTIES SUFFIX ".pyd")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
SET(OUTPUTS openmesh.exp openmesh.lib openmesh.pyd)
FOREACH(FILE ${OUTPUTS})
ADD_CUSTOM_COMMAND(
TARGET openmesh POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${FILE}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
)
ENDFOREACH()
ENDIF()
IF(OPENMESH_BUILD_PYTHON_UNIT_TESTS)
SET(UNITTEST_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Python-Unittests/)
# Copy unit tests
FILE(GLOB UNITTESTS Unittests/*.py)
FOREACH(TEST ${UNITTESTS})
FILE(COPY ${TEST} DESTINATION ${UNITTEST_OUTPUT_DIRECTORY})
ENDFOREACH()
# Copy test files
FILE(GLOB TESTFILES ${PROJECT_SOURCE_DIR}/src/Unittests/TestFiles/*(.off|.obj|.mtl|.stl|.ply|.om))
FOREACH(FILE ${TESTFILES})
FILE(COPY ${FILE} DESTINATION ${UNITTEST_OUTPUT_DIRECTORY})
ENDFOREACH()
# Copy library
IF(WIN32)
FOREACH(FILE ${OUTPUTS})
ADD_CUSTOM_COMMAND(
TARGET openmesh POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${FILE}
${UNITTEST_OUTPUT_DIRECTORY}
)
ENDFOREACH()
ELSE()
ADD_CUSTOM_COMMAND(
TARGET openmesh POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/Build/python/openmesh.so
${UNITTEST_OUTPUT_DIRECTORY}
)
ENDIF()
ADD_TEST(
NAME Python_tests
WORKING_DIRECTORY ${UNITTEST_OUTPUT_DIRECTORY}
COMMAND ${PYTHON_EXECUTABLE} -m unittest discover --verbose
)
ENDIF()
ELSE()
MESSAGE("Checking the Boost Python configuration failed!")
MESSAGE("Reason: An error occurred while running a small Boost Python test project.")
MESSAGE("Make sure that your Python and Boost Python libraries match.")
MESSAGE("Skipping Python Bindings.")
ENDIF()
ELSE()
MESSAGE("Checking the Boost Python configuration failed!")
MESSAGE("Reason: Python Interpreter ${PYTHONLIBS_VERSION_STRING} not found.")
MESSAGE("Skipping Python Bindings.")
ENDIF()
ELSE()
MESSAGE("Checking the Boost Python configuration failed!")
MESSAGE("Reason: Building a small Boost Python test project failed.")
MESSAGE("Make sure that your Python and Boost Python libraries match.")
MESSAGE("Skipping Python Bindings.")
ENDIF()
ELSE()
MESSAGE("Boost Python not found! Skipping Python Bindings.")
ENDIF()
ELSE()
MESSAGE("PythonLibs not found! Skipping Python Bindings.")
ENDIF()
ENDIF()
#ifndef OPENMESH_PYTHON_CIRCULATOR_HH
#define OPENMESH_PYTHON_CIRCULATOR_HH
#include "Python/Bindings.hh"
namespace OpenMesh {
namespace Python {
/**
* Wrapper for circulators.
*
* This class template is used to wrap circulators for %Python. It implements
* %Python's iterator protocol (the magic methods \_\_iter\_\_ and
* \_\_next\_\_).
*
* @tparam Circulator A circulator type.
*/
template<class Circulator, class CenterEntityHandle>
class CirculatorWrapperT {
public:
/**
* Constructor
*
* @param _mesh The mesh that contains the items to iterate over.
* @param _center The handle to the center item.
*/
CirculatorWrapperT(PolyMesh& _mesh, CenterEntityHandle _center) :
circulator_(_mesh, _center) {
}
/**
* Constructor
*
* @param _mesh The mesh that contains the items to iterate over.
* @param _center The handle to the center item.
*/
CirculatorWrapperT(TriMesh& _mesh, CenterEntityHandle _center) :
circulator_(_mesh, _center) {
}
/**
* Implementation of %Python's \_\_iter\_\_ magic method.
*
* @return This circulator.
*/
CirculatorWrapperT iter() const {
return *this;
}
/**
* Implementation of %Python's \_\_next\_\_ magic method.
*
* @return The next item. Raises a %Python StopIteration exception if
* there are no more items.
*/
typename Circulator::value_type next() {
if (circulator_.is_valid()) {
typename Circulator::value_type res = *circulator_;
++circulator_;
return res;
}
else {
PyErr_SetString(PyExc_StopIteration, "No more data.");
boost::python::throw_error_already_set();
}
return typename Circulator::value_type();
}
private:
Circulator circulator_;
};
/**
* Expose a circulator type to %Python.
*
* @tparam Circulator A circulator type.
*
* @param _name The name of the circulator type to be exposed.
*
* @note Circulators are wrapped by CirculatorWrapperT before they are exposed
* to %Python, i.e. they are not exposed directly. This means that circulators
* that are passed from %Python to C++ are instances of CirculatorWrapperT.
*/
template<class Circulator, class CenterEntityHandle>
void expose_circulator(const char *_name) {
class_<CirculatorWrapperT<Circulator, CenterEntityHandle> >(_name, init<TriMesh&, CenterEntityHandle>())
.def(init<PolyMesh&, CenterEntityHandle>())
.def("__iter__", &CirculatorWrapperT<Circulator, CenterEntityHandle>::iter)
.def("__next__", &CirculatorWrapperT<Circulator, CenterEntityHandle>::next)
.def("next", &CirculatorWrapperT<Circulator, CenterEntityHandle>::next)
;
}
} // namespace OpenMesh
} // namespace Python
#endif
#ifndef OPENMESH_PYTHON_DECIMATER_HH
#define OPENMESH_PYTHON_DECIMATER_HH
#include "Python/Bindings.hh"
#include "OpenMesh/Tools/Decimater/ModBaseT.hh"
#include "OpenMesh/Tools/Decimater/ModAspectRatioT.hh"
#include "OpenMesh/Tools/Decimater/ModEdgeLengthT.hh"
#include "OpenMesh/Tools/Decimater/ModHausdorffT.hh"
#include "OpenMesh/Tools/Decimater/ModIndependentSetsT.hh"
#include "OpenMesh/Tools/Decimater/ModNormalDeviationT.hh"
#include "OpenMesh/Tools/Decimater/ModNormalFlippingT.hh"
#include "OpenMesh/Tools/Decimater/ModProgMeshT.hh"
#include "OpenMesh/Tools/Decimater/ModQuadricT.hh"
#include "OpenMesh/Tools/Decimater/ModRoundnessT.hh"
#include "OpenMesh/Tools/Decimater/DecimaterT.hh"
#include <cstdio>
namespace OpenMesh {
namespace Python {
#define INIT_MESH_REF init<Mesh&>()[with_custodian_and_ward<1,2>()]
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(decimate_overloads, decimate, 0, 1)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(decimate_to_faces_overloads, decimate_to_faces, 0, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_max_err_overloads, set_max_err, 1, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_min_roundness_overloads, set_min_roundness, 1, 2)
template <class Handle>
void expose_module_handle(const char *_name) {
class_<Handle, boost::noncopyable>(_name)
.def("is_valid", &Handle::is_valid)
;
}
template <class Module>
list infolist(Module& _self) {
const typename Module::InfoList& infos = _self.infolist();
list res;
for (size_t i = 0; i < infos.size(); ++i) {
res.append(infos[i]);
}
return res;
}
template <class Mesh>
void expose_decimater(const char *_name) {
typedef Decimater::ModBaseT<Mesh> ModBase;
typedef Decimater::ModAspectRatioT<Mesh> ModAspectRatio;
typedef Decimater::ModEdgeLengthT<Mesh> ModEdgeLength;
typedef Decimater::ModHausdorffT<Mesh> ModHausdorff;
typedef Decimater::ModIndependentSetsT<Mesh> ModIndependentSets;
typedef Decimater::ModNormalDeviationT<Mesh> ModNormalDeviation;
typedef Decimater::ModNormalFlippingT<Mesh> ModNormalFlipping;
typedef Decimater::ModProgMeshT<Mesh> ModProgMesh;
typedef Decimater::ModQuadricT<Mesh> ModQuadric;
typedef Decimater::ModRoundnessT<Mesh> ModRoundness;
typedef Decimater::ModHandleT<ModAspectRatio> ModAspectRatioHandle;
typedef Decimater::ModHandleT<ModEdgeLength> ModEdgeLengthHandle;
typedef Decimater::ModHandleT<ModHausdorff> ModHausdorffHandle;
typedef Decimater::ModHandleT<ModIndependentSets> ModIndependentSetsHandle;
typedef Decimater::ModHandleT<ModNormalDeviation> ModNormalDeviationHandle;
typedef Decimater::ModHandleT<ModNormalFlipping> ModNormalFlippingHandle;
typedef Decimater::ModHandleT<ModProgMesh> ModProgMeshHandle;
typedef Decimater::ModHandleT<ModQuadric> ModQuadricHandle;
typedef Decimater::ModHandleT<ModRoundness> ModRoundnessHandle;
typedef Decimater::BaseDecimaterT<Mesh> BaseDecimater;
typedef Decimater::DecimaterT<Mesh> Decimater;
typedef typename ModProgMesh::Info Info;
typedef std::vector<Info> InfoList;
bool (BaseDecimater::*add1)(ModAspectRatioHandle&) = &Decimater::add;
bool (BaseDecimater::*add2)(ModEdgeLengthHandle&) = &Decimater::add;
bool (BaseDecimater::*add3)(ModHausdorffHandle&) = &Decimater::add;
bool (BaseDecimater::*add4)(ModIndependentSetsHandle&) = &Decimater::add;
bool (BaseDecimater::*add5)(ModNormalDeviationHandle&) = &Decimater::add;
bool (BaseDecimater::*add6)(ModNormalFlippingHandle&) = &Decimater::add;
bool (BaseDecimater::*add7)(ModProgMeshHandle&) = &Decimater::add;
bool (BaseDecimater::*add8)(ModQuadricHandle&) = &Decimater::add;
bool (BaseDecimater::*add9)(ModRoundnessHandle&) = &Decimater::add;
bool (BaseDecimater::*remove1)(ModAspectRatioHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove2)(ModEdgeLengthHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove3)(ModHausdorffHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove4)(ModIndependentSetsHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove5)(ModNormalDeviationHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove6)(ModNormalFlippingHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove7)(ModProgMeshHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove8)(ModQuadricHandle&) = &Decimater::remove;
bool (BaseDecimater::*remove9)(ModRoundnessHandle&) = &Decimater::remove;
ModAspectRatio& (BaseDecimater::*module1)(ModAspectRatioHandle&) = &Decimater::module;
ModEdgeLength& (BaseDecimater::*module2)(ModEdgeLengthHandle&) = &Decimater::module;
ModHausdorff& (BaseDecimater::*module3)(ModHausdorffHandle&) = &Decimater::module;
ModIndependentSets& (BaseDecimater::*module4)(ModIndependentSetsHandle&) = &Decimater::module;
ModNormalDeviation& (BaseDecimater::*module5)(ModNormalDeviationHandle&) = &Decimater::module;
ModNormalFlipping& (BaseDecimater::*module6)(ModNormalFlippingHandle&) = &Decimater::module;
ModProgMesh& (BaseDecimater::*module7)(ModProgMeshHandle&) = &Decimater::module;