Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .clang-format and run on all files #44

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# CCCoreLib format
# Options are listed here:
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
---
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: false
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 110
CommentPragmas: '^\\[A-Za-z]+'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 500
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: c++14
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: Always
...
39 changes: 20 additions & 19 deletions include/AutoSegmentationTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <vector>

//Local
// Local
#include "CCToolbox.h"
#include "CCTypes.h"

Expand All @@ -20,13 +20,12 @@ namespace CCCoreLib
/** Several algorithms of the AutoSegmentationTools toolbox return a collection of subsets of points
corresponding to each segmented part. Such a collection is generally stored in this type of container.
**/
using ReferenceCloudContainer = std::vector<ReferenceCloud *>;
using ReferenceCloudContainer = std::vector<ReferenceCloud*>;

//! Several point cloud auto-segmentation algorithms (Connected Components, Front propagation, etc.)
class CC_CORE_LIB_API AutoSegmentationTools : public CCToolbox
{
public:

//! Labels connected components from a point cloud
/** The algorithm is described in Daniel Girardeau-Montaut's PhD manuscript
(Chapter 3, section 3.2.4). The main parameter is the maximal distance
Expand All @@ -48,11 +47,11 @@ namespace CCCoreLib
\param inputOctree the cloud octree if it has already been computed
\return the number of components (>= 0) or an error code (< 0 - see DgmOctree::extractCCs)
**/
static int labelConnectedComponents(GenericIndexedCloudPersist* theCloud,
unsigned char level,
bool sixConnexity = false,
GenericProgressCallback* progressCb = nullptr,
DgmOctree* inputOctree = nullptr);
static int labelConnectedComponents( GenericIndexedCloudPersist* theCloud,
unsigned char level,
bool sixConnexity = false,
GenericProgressCallback* progressCb = nullptr,
DgmOctree* inputOctree = nullptr );

//! Extracts connected components from a point cloud
/** This method shloud only be called after the connected components have been
Expand All @@ -64,9 +63,11 @@ namespace CCCoreLib
\param ccc the extracted connected compenents (as a list of subsets of points)
\return success
**/
static bool extractConnectedComponents(GenericIndexedCloudPersist* theCloud, ReferenceCloudContainer& ccc);
static bool extractConnectedComponents( GenericIndexedCloudPersist* theCloud,
ReferenceCloudContainer& ccc );

//! Segment a point cloud by propagating fronts constrained by values of the point cloud associated scalar field
//! Segment a point cloud by propagating fronts constrained by values of the point cloud associated
//! scalar field
/** The algorithm is described in Daniel Girardeau-Montaut's PhD manuscript
(Chapter 3, section 3.3). It consists mainly in propagating a front on
the surface implicitly represented by the point cloud and making this
Expand All @@ -86,14 +87,14 @@ namespace CCCoreLib
\param alpha the gaussian filter kernel size (needed only if a gaussian filtering pass is required)
\return success
**/
static bool frontPropagationBasedSegmentation( GenericIndexedCloudPersist* theCloud,
PointCoordinateType radius,
ScalarType minSeedDist,
unsigned char octreeLevel,
ReferenceCloudContainer& theSegmentedLists,
GenericProgressCallback* progressCb = nullptr,
DgmOctree* inputOctree = nullptr,
bool applyGaussianFilter = false,
float alpha = 2.0f);
static bool frontPropagationBasedSegmentation( GenericIndexedCloudPersist* theCloud,
PointCoordinateType radius,
ScalarType minSeedDist,
unsigned char octreeLevel,
ReferenceCloudContainer& theSegmentedLists,
GenericProgressCallback* progressCb = nullptr,
DgmOctree* inputOctree = nullptr,
bool applyGaussianFilter = false,
float alpha = 2.0f );
};
}
75 changes: 48 additions & 27 deletions include/BoundingBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#pragma once

//Local
// Local
#include "SquareMatrix.h"

namespace CCCoreLib
Expand All @@ -12,51 +12,68 @@ namespace CCCoreLib
class CC_CORE_LIB_API BoundingBox
{
public:

//! Default constructor
BoundingBox();
//! Constructor from two vectors (lower min. and upper max. corners)
BoundingBox(const CCVector3& minCorner, const CCVector3& maxCorner);
BoundingBox( const CCVector3& minCorner, const CCVector3& maxCorner );

//! Returns the 'sum' of this bounding-box and another one
BoundingBox operator + (const BoundingBox& aBBox) const;
BoundingBox operator+( const BoundingBox& aBBox ) const;
//! In place 'sum' of this bounding-box with another one
const BoundingBox& operator += (const BoundingBox& aBBox);
const BoundingBox& operator+=( const BoundingBox& aBBox );
//! Shifts the bounding box with a vector
const BoundingBox& operator += (const CCVector3& aVector);
const BoundingBox& operator+=( const CCVector3& aVector );
//! Shifts the bounding box with a vector
const BoundingBox& operator -= (const CCVector3& aVector);
const BoundingBox& operator-=( const CCVector3& aVector );
//! Scales the bounding box
const BoundingBox& operator *= (PointCoordinateType scaleFactor);
const BoundingBox& operator*=( PointCoordinateType scaleFactor );
//! Rotates the bounding box
const BoundingBox& operator *= (const SquareMatrix& aMatrix);
const BoundingBox& operator*=( const SquareMatrix& aMatrix );

//! Resets the bounding box
/** (0,0,0) --> (0,0,0)
**/
**/
void clear();

//! 'Enlarges' the bounding box with a point
void add(const CCVector3& aPoint);
void add( const CCVector3& aPoint );

//! Returns min corner (const)
inline const CCVector3& minCorner() const { return m_bbMin; }
inline const CCVector3& minCorner() const
{
return m_bbMin;
}
//! Returns max corner (const)
inline const CCVector3& maxCorner() const { return m_bbMax; }
inline const CCVector3& maxCorner() const
{
return m_bbMax;
}

//! Returns min corner
inline CCVector3& minCorner() { return m_bbMin; }
inline CCVector3& minCorner()
{
return m_bbMin;
}
//! Returns max corner
inline CCVector3& maxCorner() { return m_bbMax; }
inline CCVector3& maxCorner()
{
return m_bbMax;
}

//! Returns center
CCVector3 getCenter() const;
//! Returns diagonal vector
CCVector3 getDiagVec() const;
//! Returns diagonal length
inline PointCoordinateType getDiagNorm() const { return getDiagVec().norm(); }
inline PointCoordinateType getDiagNorm() const
{
return getDiagVec().norm();
}
//! Returns diagonal length (double precision)
double getDiagNormd() const { return getDiagVec().normd(); }
double getDiagNormd() const
{
return getDiagVec().normd();
}
//! Returns minimal box dimension
PointCoordinateType getMinBoxDim() const;
//! Returns maximal box dimension
Expand All @@ -65,28 +82,32 @@ namespace CCCoreLib
double computeVolume() const;

//! Sets bonding box validity
inline void setValidity(bool state) { m_valid = state; }
inline void setValidity( bool state )
{
m_valid = state;
}

//! Returns whether bounding box is valid or not
inline bool isValid() const { return m_valid; }
inline bool isValid() const
{
return m_valid;
}

//! Computes min gap (absolute distance) between this bounding-box and another one
/** \return min gap (>=0) or -1 if at least one of the box is not valid
**/
PointCoordinateType minDistTo(const BoundingBox& box) const;
**/
PointCoordinateType minDistTo( const BoundingBox& box ) const;

//! Returns whether a points is inside the box or not
/** Warning: box should be valid!
**/
inline bool contains(const CCVector3& P) const
**/
inline bool contains( const CCVector3& P ) const
{
return (P.x >= m_bbMin.x && P.x <= m_bbMax.x &&
P.y >= m_bbMin.y && P.y <= m_bbMax.y &&
P.z >= m_bbMin.z && P.z <= m_bbMax.z);
return ( P.x >= m_bbMin.x && P.x <= m_bbMax.x && P.y >= m_bbMin.y && P.y <= m_bbMax.y &&
P.z >= m_bbMin.z && P.z <= m_bbMax.z );
}

protected:

//! Lower min. corner
CCVector3 m_bbMin;
//! Upper max. corner
Expand Down
Loading