Commit 4c23effb authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'rm-python' into 'master'

remove the python bindings from this project

See merge request !159
parents da2c1168 072f599c
......@@ -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