Surface_mesh  1.0
A simple and efficient halfedge-based mesh data structure
Development

Coding Conventions

If you would like to contribute to Surface_mesh please make sure your code adheres to the following coding conventions. For general best practices we recommend consulting the JSF coding standard available here.

Naming

Types

The names of user-defined types (such as classes, structs and enums) are begin with a capital letter. Words within the name are written using lower-case letters only and separated by underscores. Acronyms are written in all capital letters. The names of persons such as Cholesky or Delaunay are properly capitalized as well.

class Sparse_matrix { ... };
enum RGB_colors { red, green, blue };
class Sparse_Cholesky_solver { ... };

Functions

Function names are written in lower-case letters only. Words within the function name are separated by underscores.

class Example_class_name
{
public:
double example_function_name(void);
};

Variables

Variables are named in lower-case letters only. Words within the variable name are separated by underscores. Member variables have a trailing underscore as a suffix.

int globals_considered_harmful;
class Example_class_name
{
protected:
double member_variable_name_;
static double static_variable_name_;
};

File Names

File names follow the naming rules for user-defined types. Implementation files end with .cpp and header files end with .h. Examples: Sparse_matrix.cpp for the implementation file. Sparse_matrix.h for the header file.

Formatting

Blocks

The expressions following an if, else, while, do ... while or for statement should always be enclosed in braces. The braces enclosing a block should be placed in the same column, on separate lines.

if (foo_bar == baz)
{
std::cout << "hurz" << std::endl;
}
else
{
std::cout << "asdf" << std::endl;
}

Comments

C++-style comments should be used, i.e. // My important comment.

Line Length

Lines should not exceed more than 80 characters. There should only be one statement per line.

Indentation

Use spaces instead of tabs. Indent the code by four spaces for each level of indentation. Avoid trailing whitespaces at the end of a line as well as on empty lines.

Programming Conventions

This section describes some basic programming conventions developers should adhere to in order to avoid common pitfalls.

  • Use header guards in order to protect against multiple inclusion. The name of the guard should be prefixed with SURFACE_MESH in order to avoid any conflicts with external libraries. For the file Your_class.h the header guard should look like this:

    #ifndef SURFACE_MESH_YOUR_CLASS_H
    #define SURFACE_MESH_TOUR_CLASS_H
    ...
    #endif // SURFACE_MESH_YOUR_CLASS_H

  • Use the surface_mesh namespace in order to avoid conflicts. In source files, do not add an additional level of indentation due to the namespace:

    namespace surface_mesh {
    class Example_class
    {
    ...
    };
    }