Skip to content
Snippets Groups Projects
Commit bd377ad3 authored by Andrew Maclean's avatar Andrew Maclean
Browse files

SYNC: Files modified in the repo.

Former-commit-id: 9815ed73
parent b5e7f89b
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ All examples should follow the VTK programming style and there should be a singl
### C++
* The indentation style can be characterized as the [AllmannStyle](https://en.wikipedia.org/wiki/Indent_style#Allman_style). The curly brace (scope delimiter) is on a separate line and aligns with the control statement, The control block is indented by two spaces (**no tabs**). A suitable `.clang-format` is provided in `src/Cxx` [see here](__BLOB__/src/Cxx/.clang-format).
- The indentation style can be characterized as the [AllmannStyle](https://en.wikipedia.org/wiki/Indent_style#Allman_style). The curly brace (scope delimiter) is on a separate line and aligns with the control statement, The control block is indented by two spaces (**no tabs**). A suitable `.clang-format` is provided in `src/Cxx` [see here](__BLOB__/src/Cxx/.clang-format).
Example:
......@@ -30,35 +30,35 @@ All examples should follow the VTK programming style and there should be a singl
}
```
* Where appropriate, explicitly use the std:: namespace:
- Where appropriate, explicitly use the std:: namespace:
``` c++
std::cout << "Print something" << std::endl;
std::cout << "Print something" << std::endl;
```
rather than
rather than
``` c++
cout << "Print something" << endl;
cout << "Print something" << endl;
```
* All includes from the toolkit should use <> notation. This follows C++ programming conventions.
- All includes from the toolkit should use <> notation. This follows C++ programming conventions.
For example: `#include <vtkContourFilter.h>` is preferred over `#include "vtkContourFilter.h"`
* The main program must have the following signature:
- The main program must have the following signature:
``` c++
int main (int argc, char *argv[])
```
or, if argc and argv are not referenced in the code,
or, if argc and argv are not referenced in the code,
``` c++
int main (int, char *[])
```
* If arguments are required, a check similar to the following should be made at the start of the main program.
- If arguments are required, a check similar to the following should be made at the start of the main program.
``` c++
if (argc != 3)
......@@ -68,51 +68,51 @@ All examples should follow the VTK programming style and there should be a singl
}
```
* An example should **never call exit()**. If the main program executes successfully, it should
- An example should **never call exit()**. If the main program executes successfully, it should
``` c++
return EXIT_SUCCESS;
```
otherwise
otherwise
``` c++
return EXIT_FAILURE;
```
* The use of SmartPointers is preferred in VTK examples.
- The use of SmartPointers is preferred in VTK examples.
``` c++
vtkSmartPointer<vtkCutter> cutter = vtkSmartPointer<vtkCutter>::New();
```
or
or
``` c++
vtkNew<vtkCutter> cutter;
```
is preferred over
is preferred over
``` c++
vtkCutter *cutter = vtkCutter::New();
```
* When building pipelines, the new `SetInputConnection()`, `GetOutputPort()` methods should be used instead of `SetInput()`, `GetOutput()`
- When building pipelines, the new `SetInputConnection()`, `GetOutputPort()` methods should be used instead of `SetInput()`, `GetOutput()`
* Input/Output filenames
- Input/Output filenames
When possible, filenames should be passed on the command line. This gives the examples utility beyond the data that is used in the specific example.
* If there are just a few parameters for the example, these should be passed in as arguments. This increases the utility of the example and facilitates testing.
- If there are just a few parameters for the example, these should be passed in as arguments. This increases the utility of the example and facilitates testing.
For example, this program
For example, this program
``` c++
Delaunay3DAlpha Alpha InputPolydataFileName(.vtp) OutputUnstructuredGridFilename(.vtu)
```
would use the arguments in this manner
would use the arguments in this manner
``` c++
reader->SetFileName (argv[2]);
......@@ -120,11 +120,11 @@ All examples should follow the VTK programming style and there should be a singl
writer->SetFileName ( argv[3] );
```
* Always provide a background for the renderers. Avoid setting the background to white.
- Always provide a background for the renderers. Avoid setting the background to white.
* Use [vtkNamedColors](http://www.vtk.org/doc/nightly/html/classvtkNamedColors.html) for setting colors of actors and renderer backgrounds. [VTKNamedColorPatches](http://htmlpreview.github.io/?__BLOB__/VTKNamedColorPatches.html) shows the colors that are available. If you are using a color series, then you can choose what you want from here [VTKColorSeriesPatches](http://htmlpreview.github.io/?__BLOB__/VTKColorSeriesPatches.html).
- Use [vtkNamedColors](http://www.vtk.org/doc/nightly/html/classvtkNamedColors.html) for setting colors of actors and renderer backgrounds. [VTKNamedColorPatches](http://htmlpreview.github.io/?__BLOB__/VTKNamedColorPatches.html) shows the colors that are available. If you are using a color series, then you can choose what you want from here [VTKColorSeriesPatches](http://htmlpreview.github.io/?__BLOB__/VTKColorSeriesPatches.html).
For example,
For example,
``` c++
#include <vtkNamedColors.h>
......@@ -135,13 +135,13 @@ All examples should follow the VTK programming style and there should be a singl
renderer->SetBackground(namedColors->GetColor3d("Khaki").GetData());
```
is preferred over
is preferred over
``` c++
renderer->SetBackground(0.9412, 0.9020, 0.5490);
```
* Use admonitions to warn/cite/info, etc. [Here is a summary of admonitions](__SITE__/Instructions/ForAdministrators/#admonition).
- Use admonitions to warn/cite/info, etc. [Here is a summary of admonitions](__SITE__/Instructions/ForAdministrators/#admonition).
### Python
......@@ -168,7 +168,7 @@ if __name__ == '__main__':
```
* Input/Output filenames and parameters.
- Input/Output of filenames and parameters.
Use this snippet [GetProgramParameters](__SITE__/Python/Snippets/GetProgramParameters/)
......@@ -182,5 +182,5 @@ Java code styling follows the usual style as implemented in the IDEs.
However note:
* No Tabs
* Indentation must be two spaces
- No Tabs
- Indentation must be two spaces
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment