MEPP2 Project
|
Even for nested namespaces, namespaces are never indented (we here follow the CGAL way, among others).
Note: this coding style rule applies to "using namespace" but does not apply to the "using" expression. The usage of the "using" directive for type alias remains a must for templated type alias.
By default the usage of "using namespace" is forbidden. Yet, when visibility is really compromised then the usage of "using namespace" will be simply frown upon (as opposed to forbidden) when restricted to the block where it is used (as opposed to file scope). For example code like
can be "beautified" (beauty is in the eye of the observer) to
Notes:
Functions:
Control flow instruction:
Keywords
Functions
When folding lines, and as a general rule, argument alignment should be encouraged.
Note: there should be no whitespace after a semi-colon when this is the last character of the instruction.
Encoding must be done in ASCII (the plain good old seven-bit, 128 characters one). Non-ASCII characters should be rare (and duly justified), and must use UTF-8 formatting.** More...
Comments should be in English. This avoids french (or Japanese, or Arabic...) non-ascii characters and will provide useful when diffusing the code outside our organization.
Use #pragma once
as include guards in all header files.
Use LF to store line endings** (text files). Do not use CR nor CRLF. Either set your editor to do so or configure git to handle the conversion (git internal encoding uses LF).
Each line of text in your code should be at most 80 characters long** (except for a very reduced set of... exceptions). We recognize that this rule is controversial, but so much existing code already adheres to it, and we feel that consistency is important. More...
References: Mind the end of your line, The great newline schism, Github's dealing with line endings, CRLF strategy with git (StackOverflow).
QT coding Style ITK coding Style Guide CGAL... Google C++ Style Guide
Names follow CGAL coding style rules, among which
FEVV/Filters/calculate_vertex_normals.h
) Class_name
)is_zero
)is_empty()
instead of simply empty()
m_
. In order to distinguish arguments flowing in, out or in/ouy respect const correcteness.
Use .h
and .cpp
extensions for non templated code Use .hpp
and .cpp
extensions for templated code Using .inl
extensions for files holding implementation of template functions (refer here) is tolerated.
When defining the signature of a filter, a developer can choose among the large spectrum of signatures ranging in between the following two boundary strategies:
Let us consider the signature of the calculate_scaling() filter that goes
and gets usually called (refer e.g. to testCalculateScalingPolyhedron()) in the following manner
and falls into the last "argument explictness" strategy. The argument aggregation version would have a signature of the form
where the implementation starts with extracting the required attributes from the mesh.
The coding style choses to promote the argument explicitness for the following reasons:
PointMap
attribute of a mesh is a bit of a counter-example because all mesh implementations embed this attribute within the mesh (the mesh and its geometry a bundled together). Hence passing around the mesh suffices. But most of other usefull/current mesh attributes are not stored within the mesh and live aside thus requiring the filter call to explictly pass such attributes as arguments.When including include files refrain from using path file names that are relative to the inclusion file. For example avoid writing #include "../../Src/dir/file.h"
(that is a notation relative to the including file). Prefer writing #include "dir/file.h"
(relative to repository root or one of its sub-directory). Then use Cmake's include_directories( ${PROJECT_SOURCE_DIR}/...)
to provide the required path information to the pre-processor. This method simplifies the relocation of the included code (in some cases only the CMakeLists.txt has to be adapted) enables to compile both in the developing directory layout context and in a post-installation directory layout.
When some code is bound to a dimension then respect CGAL's rule to explicitly have the dimension suffix (e.g. _2
, _3
..._dim
)
Nevertheless if you have a really good reason (code cosmetics is clearly not sufficient) to define some macro then prefix the macro name with FEVV_
.
Consider a filter named CurvatureListFilter
that computes some kind of normalsat the vertices of a mesh. The type of the computed normals (named e.g. ListNormType
) is thus introduced by the internal necessity of CurvatureListFilter
that will expect to retrieve such a type among the property_map that it will be handled over. Indeed it will the caller responsability to create such a property_map
with code of the form (refer e.g. to cf generic_reader.h
There is thus the necessity for a filter (just as for the kernel) to specialize the properties "local to" (or introduced by) a filter for every type of mesh data structure that wishes to use this filter.
The structure of the CurvatureListFilter
filter directory should thus be of the form:
Filters can be sorted out either by the mesh type offering their implementation e.g.
where OpenMesh refers to the eponymous data strucuture or sorted out by their name and then specialized with the various data structures (refer to chapter concerning the layout of a given filter subdirectory")
This choice (between either pushing forward the name of the data structure or promoting the name of the filter) is left to the developer introducing a new filter and both Filter naming conventions are accepted within FEVV/Filters/
directory.