readme.txt 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. e gl Library - A simple c++ mesh library
  2. Copyright 2011 - Daniele Panozzo, Alec Jacobson, Olga Diamanti
  3. Interactive Geometry Lab - ETH Zurich
  4. This is a *header* library. Each header file should contain a single
  5. function. The function may have multiple prototypes. All functions
  6. should use the igl namespace and should adhere to the conventions and
  7. styles listed below.
  8. = Example =
  9. The following is a toy example of a function called example() in the
  10. file example.h:
  11. #ifndef IGL_EXAMPLE_H
  12. #define IGL_EXAMPLE_H
  13. namespace igl
  14. {
  15. // An example function that prints "Hello, world"
  16. inline void example();
  17. }
  18. // Implementation
  19. #include <iostream>
  20. inline void igl::example()
  21. {
  22. std::cout<<"Hello, world"<<std::endl;
  23. }
  24. = Standards =
  25. This library is shared by many people. Each function prototype should be
  26. well documented. Write a summary of what the function does and a
  27. description of each template, input and output in each prototype.
  28. - All functions must be inlined, otherwise there is trouble when
  29. linking included headers used in multiple .cpp files
  30. - Use a single .h file with the same name as the function
  31. - Do *not* use any .cpp files (this is *header only* library)
  32. - At least one version of the function should use references for all
  33. outputs
  34. - Use wrappers and additional prototypes for returning single-output
  35. functions' outputs
  36. - Use c++ references for inputs and outputs rather than pointers or
  37. pass-by-copy
  38. - Take the time to write multiple prototypes if you'd like to have
  39. optional parameters with default values
  40. - External dependencies (besides Eigen, OpenGL, etc.) are discouraged
  41. - External dependencies must be clearly identified at the top of each
  42. file.
  43. - Single header external dependencies can go in the external/
  44. directory
  45. - Do not use the using namespace directive anywhere. This means never
  46. write:
  47. "using namespace std;"
  48. or
  49. "using namespace igl;"
  50. etc.
  51. = Specific style conventions =
  52. Each file should be wrapped in an ifndef compiler directive. If the
  53. file's (and function's) name is example.h, then the ifndef should
  54. always begin with IGL_, then the function/file name in all caps then
  55. _H. As in:
  56. #ifndef IGL_EXAMPLE_H
  57. #define IGL_EXAMPLE_H
  58. ...
  59. #endif
  60. Each file should begin with prototypes *without implementations* of
  61. each version of the function. All defined in the igl namespace. Each
  62. prototype should have its own comments describing what it is doing,
  63. and its templates, inputs, outputs.
  64. Implementations should be at the end of each file, separated from the
  65. prototypes using:
  66. // Implementation
  67. Any includes, such as std libraries etc. should come after
  68. the //Implementation separator (whenever feasibly possible).
  69. Be generous by templating your inputs and outputs. If you do use
  70. templates, you must document the template just as you document inputs
  71. and outputs.
  72. = Useful checks =
  73. Find files that aren't using "inline"
  74. grep -L inline *
  75. Find files that aren't using igl namespace
  76. grep -L "namespace igl" *
  77. Find files using [TAB] character
  78. grep -P '\t' *
  79. Find files that don't contain // Implementation
  80. grep -L "^\/\/ Implementation" *
  81. Find files that don't contain #ifndef IGL_
  82. grep -L "^#ifndef IGL_" *