MEPP2 Project
Add a new mesh processing filter

The HelloWorld example

The recommended way for adding a new mesh processing filter is to duplicate the generic "HelloWorld" example that is located in the Examples/Generic/HelloWorld subdirectory. Because the HelloWorld example is generic, notice that the Examples/Generic/HelloWorld only holds templated code.

This is in particular true for the template< typename MeshT > int helloworld_main(int argc, const char **argv) function. That template function thus needs to be instantiated with a concrete (mesh) data type which is done e.g. in Examples/OpenMesh/helloworld_filter_openmesh.cpp for the OpenMesh data structure or in Examples/AIF/helloworld_filter_aif.cpp for the AIF data structure.

Duplicate the HelloWorld filter example and adapt it to your needs

First duplicate the Examples/Generic/HelloWorld sub-directory (that implements a trivial Hello World filter) and rename it to e.g.  MyExample . This goes:

cd MEPP2/Examples/Generic/
cp -r HelloWorld MyExample
cd MyExample
mv helloworld_filter.hpp myexample_filter.hpp
mv helloworld_main.hpp myexample_main.hpp

Then proceed with editing the  myexample_filter.hpp  and  myexample_main.hpp  files and change every occurrence of  helloworld  to become  myexample .

Choose a concrete (underlying) mesh data structure

In opposition to the definition of a filter (that is generic over a concept based wrapper), a concrete example cannot be generic and requires the usage of a concrete mesh data structure.

Picking up the ad-hoc mesh data structure of course depends on your specific needs. For example, in addition to complying with some surface oriented concepts, your algorithm might also impose some (algorithmic) complexity constraints or the usage of some specific filter (mesh treatment) implementation that are only available for a specific implementation (i.e. some mesh data structure).

Hence you thus first need to collect your specific requirements in order to make the ad-hoc choice among the MEPP2 compatible mesh data structures. You thus get to choose among

Duplicate the concrete HelloWorld example

For the purpose MyExample (that has no known specific need) we are free to choose whatever mesh data structure available within MEPP2. We here (arbitrarily) choose to use the "Linear Cell Complex" implementation (a.k.a. CGAL-LCC).

Proceed with doing a similar process (copy and adapt) with the instantiated version of your newly created MyExample generic code. That is

# We will only adapt the Linear Cell Complex
cd Examples/CGAL/LCC
cp helloworld_filter_cgal_linear_cell_complex.cpp myexample_filter_cgal_linear_cell_complex.cpp

Configure CMake to build your example

This task limits itself to editing the Examples/CGAL/LCC/CMakeLists.txt file to add this section at the end:

######
add_executable( myexample_filter_cgal_linear_cell_complex
myexample_filter_cgal_linear_cell_complex.cpp )
target_link_libraries( myexample_filter_cgal_linear_cell_complex
${CGAL_LIBRARY} ${CGAL_3RD_PARTY_LIBRARIES}
${Boost_LIBRARIES} ${FBX_LIBRARY} ${VTK_LIBRARIES}
)

Build your example

Your can now fold back to the build stage of the MEPP2 installation instructions. Because you want to build the CGAL-LCC example you will need to set cmake's BUILD_USE_CGAL build flag to ON.

Run the example

When working on Linux or OSX, you should find the binary that you build within the Bin/Examples/CGAL/HelloWorld/ sub-directory of your building directory (here taken as being Bin). In order to run it try something like

cd MEPP2/Bin # The cmake building directory you chose to build in
Examples/CGAL/LCC/myexample_filter_cgal_linear_cell_complex ../Testing/Data/CubeNonTriangleFaces.off

Further readings

You might also find useful to walk around the FEVV/Filters directory in order get acquainted with the available filters (and possibly read some code for further inspiration).

The Datastructure specific filter and plugin page gives some hints about writing data-structure specific (aka non-generic) filters and plugins.

LCC
CGAL::Linear_cell_complex_for_combinatorial_map< 2, 3, MyTraits, Myitem > LCC
Definition: test_linear_cell_complex.cpp:54
helloworld_filter
void helloworld_filter(const HalfedgeGraph &g, PointMap &pm, VertexColorMap &v_cm, VertexNormalMap &v_nm, const GeometryTraits &gt)
Refer here for a detailed presentation of that filter example, what it does and how to use it.
Definition: helloworld_filter.hpp:27
CGAL
Definition: Graph_properties_cgal_point_set.h:32
helloworld_main
int helloworld_main(int argc, const char **argv)
A mesh type templated main(argc, argv) function that.
Definition: helloworld_main.hpp:25