ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvContourExtractor.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // CV_DB_LIB
11 #include <ecvPolyline.h>
12 
13 // cloudViewer
14 #include <PointProjectionTools.h>
15 
18 public:
21 
23 
42  bool allowMultiPass,
43  PointCoordinateType maxEdgeLength = 0,
44  const PointCoordinateType* preferredNormDim = 0,
45  const PointCoordinateType* preferredUpDir = 0,
46  ContourType contourType = FULL,
47  std::vector<unsigned>* originalPointIndexes = 0,
48  bool enableVisualDebugMode = false,
49  double maxAngleDeg = 0.0);
50 
53 
65  static bool ExtractFlatContour(
67  bool allowMultiPass,
68  PointCoordinateType maxEdgeLength,
69  std::vector<ccPolyline*>& parts,
70  bool allowSplitting = true,
71  const PointCoordinateType* preferredNormDim = 0,
72  bool enableVisualDebugMode = false);
73 
74 protected:
76 
92  static bool ExtractConcaveHull2D(
93  std::vector<cloudViewer::PointProjectionTools::IndexedCCVector2>&
94  points,
95  std::list<cloudViewer::PointProjectionTools::IndexedCCVector2*>&
96  hullPoints,
97  ContourType contourType,
98  bool allowMultiPass,
99  PointCoordinateType maxSquareLength = 0,
100  bool enableVisualDebugMode = false,
101  double maxAngleDeg = 90.0);
102 };
cc2DLabel::addPickedPoint
bool addPickedPoint(ccGenericPointCloud *cloud, unsigned pointIndex, bool entityCenter=false)
Adds a point to this label.
Definition: ecv2DLabel.cpp:400
POINT_FROZEN
@ POINT_FROZEN
Definition: ecvContourExtractor.cpp:37
ccContourExtractor::FULL
@ FULL
Definition: ecvContourExtractor.h:20
Edge::itA
VertexIterator itA
Definition: PointProjectionTools.cpp:506
M_PI
constexpr double M_PI
Pi.
Definition: CVConst.h:19
Edge::nearestPointIndex
unsigned nearestPointIndex
Definition: PointProjectionTools.cpp:507
ccContourExtractor::ContourType
ContourType
Contour type.
Definition: ecvContourExtractor.h:20
cloudViewer::ReferenceCloud::reserve
virtual bool reserve(unsigned n)
Reserves some memory for hosting the point references.
Definition: ReferenceCloud.cpp:51
Neighbourhood.h
cc2DLabel::setDisplayedIn2D
void setDisplayedIn2D(bool state)
Whether to display the label in 2D.
Definition: ecv2DLabel.h:114
POINT_USED
@ POINT_USED
Definition: ecvContourExtractor.cpp:35
HullPointFlags
HullPointFlags
Definition: PointProjectionTools.cpp:480
cloudViewer::PointProjectionTools::extractConvexHull2D
static bool extractConvexHull2D(std::vector< IndexedCCVector2 > &points, std::list< IndexedCCVector2 * > &hullPoints)
Determines the convex hull of a set of points.
Definition: PointProjectionTools.cpp:355
FindNearestCandidate
static PointCoordinateType FindNearestCandidate(unsigned &minIndex, const VertexIterator &itA, const VertexIterator &itB, const std::vector< Vertex2D > &points, const std::vector< HullPointFlags > &pointFlags, PointCoordinateType minSquareEdgeLength, bool allowLongerChunks=false, double minCosAngle=-1.0)
Finds the nearest (available) point to an edge.
Definition: ecvContourExtractor.cpp:67
cloudViewer::PointProjectionTools::IndexedCCVector2::index
unsigned index
Point index.
Definition: PointProjectionTools.h:177
Edge
Weighted graph edge.
Definition: PointProjectionTools.cpp:491
VertexIterator
std::list< Vertex2D * >::iterator VertexIterator
Definition: ecvContourExtractor.cpp:41
ccObject::setName
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75
ccBBox
Bounding box structure.
Definition: ecvBBox.h:25
Vector3Tpl< PointCoordinateType >::vnormalize
static void vnormalize(PointCoordinateType p[])
Definition: CVGeom.h:569
CVLog.h
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ecvPointCloud.h:146
cc2DLabel
2D label (typically attached to points)
Definition: ecv2DLabel.h:22
ccDrawableObject::setSelected
virtual void setSelected(bool state)
Selects/Unselects entity.
Definition: ecvDrawableObject.h:70
ConstVertexIterator
std::list< Vertex2D * >::const_iterator ConstVertexIterator
Definition: ecvContourExtractor.cpp:42
CCVector3
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
cloudViewer::Neighbourhood::None
@ None
Definition: Neighbourhood.h:76
CVLog::Error
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Definition: CVLog.cpp:143
Vector2Tpl< PointCoordinateType >
cloudViewer::ReferenceCloud::addPointIndex
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
Definition: ReferenceCloud.cpp:84
ccContourExtractorDlg::addToDisplay
void addToDisplay(ccHObject *obj, bool noDependency=true)
Adds an entity to the (2D/3D) display.
Definition: ecvContourExtractorDlg.cpp:83
ccGenericPointCloud::setPointSize
void setPointSize(unsigned size=0)
Sets point size.
Definition: ecvGenericPointCloud.h:275
Vector3Tpl::cross
Vector3Tpl cross(const Vector3Tpl &v) const
Cross product.
Definition: CVGeom.h:412
POINT_IGNORED
@ POINT_IGNORED
Definition: ecvContourExtractor.cpp:36
cloudViewer::PointProjectionTools::IndexedCCVector2
Indexed 2D vector.
Definition: PointProjectionTools.h:161
Edge::nearestPointSquareDist
float nearestPointSquareDist
Definition: PointProjectionTools.cpp:508
Vector3Tpl< PointCoordinateType >
Edge::operator<
bool operator<(const Edge &e) const
Definition: ecvContourExtractor.cpp:55
Vertex2D
cloudViewer::PointProjectionTools::IndexedCCVector2 Vertex2D
Definition: ecvContourExtractor.cpp:40
ccContourExtractorDlg::refresh
void refresh()
Forces refresh.
Definition: ecvContourExtractorDlg.cpp:96
VertexIterator
std::list< Vertex2D * >::iterator VertexIterator
Definition: PointProjectionTools.cpp:488
e
const double * e
Definition: essential_matrix_poly.h:10
ecv2DLabel.h
cloudViewer::Neighbourhood::UseYAsUpDir
@ UseYAsUpDir
Definition: Neighbourhood.h:76
std::swap
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
Definition: SmallVector.h:1370
ccPointCloud::reserve
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
Definition: ecvPointCloud.cpp:1452
Vector2Tpl::x
Type x
Definition: CVGeom.h:36
ccContourExtractor::ExtractFlatContour
static ccPolyline * ExtractFlatContour(cloudViewer::GenericIndexedCloudPersist *points, bool allowMultiPass, PointCoordinateType maxEdgeLength=0, const PointCoordinateType *preferredNormDim=0, const PointCoordinateType *preferredUpDir=0, ContourType contourType=FULL, std::vector< unsigned > *originalPointIndexes=0, bool enableVisualDebugMode=false, double maxAngleDeg=0.0)
Extracts a unique closed (2D) contour polyline of a point cloud.
Definition: ecvContourExtractor.cpp:659
ccContourExtractorDlg::isSkipped
bool isSkipped() const
Returns whether the dialog has been 'skipped' or not.
Definition: ecvContourExtractorDlg.cpp:79
cloudViewer::Neighbourhood
Definition: Neighbourhood.h:25
ecvContourExtractorDlg.h
cloudViewer::PointProjectionTools
Definition: PointProjectionTools.h:34
Hull2D
std::list< Vertex2D * > Hull2D
Definition: ecvContourExtractor.cpp:657
Vector2Tpl::dot
Type dot(const Vector2Tpl &v) const
Dot product.
Definition: CVGeom.h:71
PointProjectionTools.h
ccDrawableObject::setVisible
virtual void setVisible(bool state)
Sets entity visibility.
Definition: ecvDrawableObject.h:40
points
int points
Definition: FileIOFactory.cpp:144
cloudViewer::Polyline::setClosed
void setClosed(bool state)
Sets whether the polyline is closed or not.
Definition: Polyline.h:29
Edge::Edge
Edge(const VertexIterator &A, unsigned _nearestPointIndex, float _nearestPointSquareDist)
Definition: ecvContourExtractor.cpp:47
ccPointCloud::clear
void clear() override
Clears the entity from all its points and features.
Definition: ecvPointCloud.cpp:530
Vector2Tpl::y
Type y
Definition: CVGeom.h:36
ccContourExtractor
Controur extractor (with debug GUI)
Definition: ecvContourExtractor.h:17
cloudViewer::GenericIndexedCloudPersist
A generic 3D point cloud with index-based and presistent access to points.
Definition: GenericIndexedCloudPersist.h:18
cloudViewer::Neighbourhood::projectPointsOn2DPlane
bool projectPointsOn2DPlane(std::vector< Vec2D > &points2D, const PointCoordinateType *planeEquation=nullptr, CCVector3 *O=nullptr, CCVector3 *X=nullptr, CCVector3 *Y=nullptr, InputVectorsUsage vectorsUsage=None)
Projects points on the best fitting LS plane.
Definition: Neighbourhood.h:89
ccContourExtractorDlg::displayMessage
void displayMessage(QString message, bool waitForUserConfirmation=false)
Display a new message.
Definition: ecvContourExtractorDlg.cpp:102
POINT_NOT_USED
@ POINT_NOT_USED
Definition: ecvContourExtractor.cpp:34
ccContourExtractorDlg
Dialog for debugging contour extraction.
Definition: ecvContourExtractorDlg.h:25
ecvContourExtractor.h
Vector3Tpl< PointCoordinateType >::vdot
static PointCoordinateType vdot(const PointCoordinateType p[], const PointCoordinateType q[])
Definition: CVGeom.h:520
CVLog::Warning
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
ccContourExtractor::UPPER
@ UPPER
Definition: ecvContourExtractor.h:20
ccContourExtractorDlg::zoomOn
void zoomOn(const ccBBox &bbox)
Zooms on a given 2D region (3D bouding-box considered in 2D only)
Definition: ecvContourExtractorDlg.cpp:68
cloudViewer::Neighbourhood::InputVectorsUsage
InputVectorsUsage
Definition: Neighbourhood.h:76
Vector2Tpl::norm2
Type norm2() const
Returns vector square norm.
Definition: CVGeom.h:61
Edge::Edge
Edge()
Definition: ecvContourExtractor.cpp:45
ccContourExtractor::ExtractConcaveHull2D
static bool ExtractConcaveHull2D(std::vector< cloudViewer::PointProjectionTools::IndexedCCVector2 > &points, std::list< cloudViewer::PointProjectionTools::IndexedCCVector2 * > &hullPoints, ContourType contourType, bool allowMultiPass, PointCoordinateType maxSquareLength=0, bool enableVisualDebugMode=false, double maxAngleDeg=90.0)
Determines the 'concave' hull of a set of points.
Definition: ecvContourExtractor.cpp:189
Tuple3Tpl::y
Type y
Definition: CVGeom.h:137
ecvPolyline.h
ccGenericPointCloud::getOwnBB
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
Definition: ecvGenericPointCloud.cpp:139
ecvColor::red
constexpr Rgb red(MAX, 0, 0)
cloudViewer::PointCloudTpl::addPoint
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
Definition: PointCloudTpl.h:246
X
void * X
Definition: SmallVector.cpp:45
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
Tuple3Tpl::u
Type u[3]
Definition: CVGeom.h:139
cloudViewer::Neighbourhood::UseOXYasBase
@ UseOXYasBase
Definition: Neighbourhood.h:76
DistanceComputationTools.h
ccContourExtractorDlg::removFromDisplay
void removFromDisplay(ccHObject *obj)
Removes an entity from the (2D/3D) display.
Definition: ecvContourExtractorDlg.cpp:90
ccHObject::addChild
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
Definition: ecvHObject.cpp:534
ccObject::setEnabled
virtual void setEnabled(bool state)
Sets the "enabled" property.
Definition: ecvObject.h:102
ecvPointCloud.h
ccContourExtractorDlg::init
void init()
Initializes the display.
Definition: ecvContourExtractorDlg.cpp:32
ccPolyline::split
bool split(PointCoordinateType maxEdgeLength, std::vector< ccPolyline * > &parts)
Splits the polyline into several parts based on a maximum edge length.
Definition: ecvPolyline.cpp:415
ccContourExtractor::LOWER
@ LOWER
Definition: ecvContourExtractor.h:20
ccPolyline::setColor
void setColor(const ecvColor::Rgb &col)
Sets the polyline color.
Definition: ecvPolyline.h:81
ccPolyline
Colored polyline.
Definition: ecvPolyline.h:23
cloudViewer::Polyline::clear
void clear(bool unusedParam=true) override
Clears the cloud.
Definition: Polyline.cpp:15