forked from libigl/libigl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: ff641e3
- Loading branch information
Alec Jacobson (jalec
authored and
Alec Jacobson (jalec
committed
Nov 25, 2013
1 parent
57eb03d
commit 166ae80
Showing
21 changed files
with
1,100 additions
and
106 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,6 @@ namespace igl | |
// T #P by 1 list of parameters | ||
// sqrD #P by 1 list of squared distances | ||
// | ||
// Copyright 2011, Alec Jacobson ([email protected]) | ||
// | ||
template < | ||
typename MatP, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,13 @@ <h2>Example</h2> | |
</p> | ||
<h3>example_fun.h</h3> | ||
<pre><code> | ||
// This file is part of libigl, a simple c++ geometry processing library. | ||
// | ||
// Copyright (C) 2013 Alec Jacobson <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public License | ||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
// obtain one at http://mozilla.org/MPL/2.0/. | ||
#ifndef IGL_EXAMPLE_FUN_H | ||
#define IGL_EXAMPLE_FUN_H | ||
|
||
|
@@ -41,7 +48,7 @@ <h3>example_fun.h</h3> | |
// input some input of a Printable type | ||
// Returns true for the sake of returning something | ||
template <typename Printable> | ||
IGL_INLINE bool example_fun(const Printable & input); | ||
IGL_INLINE bool example_fun(const Printable & input); | ||
} | ||
|
||
#ifdef IGL_HEADER_ONLY | ||
|
@@ -52,58 +59,62 @@ <h3>example_fun.h</h3> | |
</code></pre> | ||
<h3>example_fun.cpp</h3> | ||
<pre><code> | ||
#include "igl/example_fun.h" | ||
// This file is part of libigl, a simple c++ geometry processing library. | ||
// | ||
// Copyright (C) 2013 Alec Jacobson <[email protected]> | ||
// | ||
// This Source Code Form is subject to the terms of the Mozilla Public License | ||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can | ||
// obtain one at http://mozilla.org/MPL/2.0/.#include "igl/example_fun.h" | ||
#include <iostream> | ||
|
||
template <typename Printable> | ||
IGL_INLINE bool igl::example_fun(const Printable & input) | ||
IGL_INLINE bool igl::example_fun(const Printable & input) | ||
{ | ||
using namespace std; | ||
cout<<"example_fun: "<<input<<endl; | ||
return true; | ||
} | ||
|
||
#ifndef IGL_HEADER_ONLY | ||
template bool igl::example_fun<double>(const double& input); | ||
template bool igl::example_fun<int>(const int& input); | ||
template bool igl::example_fun<double>(const double& input); | ||
template bool igl::example_fun<int>(const int& input); | ||
#endif | ||
</code></pre> | ||
|
||
|
||
|
||
<h2>General rules</h2> | ||
<h2 id=general_rules>General rules</h2> | ||
<ul> | ||
<li> Use a single .h/.cpp pair with the same name as the function </li> | ||
<li> | ||
At least one version of the function should use references for all outputs | ||
</li> | ||
<li> | ||
Functions with external dependencies should be a single .h file (no .cpp file) | ||
so it won't appear in libigl.a | ||
</li> | ||
<li> | ||
Use wrappers and additional prototypes for returning single-output functions' | ||
outputs, but the default is to only use outputs | ||
</li> | ||
<li> All inputs should be const when appropriate </li> | ||
<li> All inputs should be <code>const</code>.</li> | ||
<li> | ||
Use c++ references for inputs and outputs rather than pointers or pass-by-copy | ||
Use C++ references (e.g. <code>Matrix & mat</code>) for inputs and outputs | ||
rather than pointers (e.g. <code>Matrix * mat</code>) or pass-by-copy (e.g. | ||
<code>Matrix mat</code>). | ||
</li> | ||
<li> | ||
Take the time to write multiple prototypes if you'd like to have optional | ||
parameters with default values | ||
Write multiple prototypes if you'd like to have optional parameters with | ||
default values. | ||
</li> | ||
<li> | ||
External dependencies (besides Eigen, OpenGL, etc.) are discouraged | ||
External dependencies (besides Eigen and OpenGL) are only allowed within extras. | ||
</li> | ||
<li> | ||
External dependencies must be clearly identified at the top of each file. | ||
New extras and their dependencies must be discussed first. | ||
</li> | ||
<li> | ||
External dependencies can go in the external/ directory | ||
Hard-to-compile or obscure external dependencies can go in the <code>external/</code> directory. | ||
</li> | ||
<li> | ||
Do not use the using namespace directive anywhere outside a local scope. This | ||
Do not use the <code>using namespace</code> directive anywhere outside a local scope. This | ||
means never write: <code>using namespace std;</code> or <code>using namespace | ||
igl;</code> etc. at the top of a file. | ||
</li> | ||
|
@@ -114,8 +125,8 @@ <h2>General rules</h2> | |
</li> | ||
<li> Classes should be in <code>CamelCase</code></li> | ||
<li> No tabs, only two spaces per indentation level </li> | ||
<li> Be generous with assertions, but always identify them with strings: | ||
<br> e.g. <code>assert(m<n && "m must be less than n");</code></li> | ||
<li> Be generous with assertions and always identify them with strings: | ||
<br> e.g. <code>assert(m<n && "m must be less than n");</code></li> | ||
</ul> | ||
|
||
<h2>Specific rules</h2> | ||
|
@@ -187,6 +198,9 @@ <h2>Useful scripts to check style</h2> | |
<td><code>grep -L "^#ifndef IGL_" *</code></td> | ||
<td>Find files that don't contain #ifndef IGL_</td> | ||
</tr> | ||
<tr class=d1> | ||
<td><code>grep -L "^This file is part of libigl" *</code></td> | ||
</tr> | ||
</table> | ||
|
||
<p>See also: <a href=tutorial.html>tutorial</a>, <a | ||
|