24 #include <QMainWindow>
31 tr(
"Greedy Triangulation"),
32 tr(
"Greedy Triangulation"),
33 tr(
"Greedy Triangulation from clouds"),
34 ":/toolbar/PclAlgorithms/icons/greedy_triangulation.png")),
36 m_normalSearchRadius(10),
39 m_trigulationSearchRadius(25),
40 m_weightingFactor(2.5),
41 m_maxNearestNeighbors(100),
42 m_maxSurfaceAngle(45),
45 m_normalConsistency(false) {}
55 if (have_cloud != 1)
return -11;
86 static_cast<float>(
m_dialog->normalSearchRadius->value());
106 if (!cloud)
return -1;
109 pcl::PointCloud<pcl::PointNormal>::Ptr cloudWithNormals(
110 new pcl::PointCloud<pcl::PointNormal>);
114 pcl::PointCloud<pcl::PointXYZ>::Ptr xyzCloud =
116 if (!xyzCloud)
return -1;
119 pcl::PointCloud<NormalT>::Ptr
normals(
new pcl::PointCloud<NormalT>);
120 int result = PCLModules::ComputeNormals<pcl::PointXYZ, NormalT>(
123 if (
result < 0)
return -1;
126 pcl::concatenateFields(*xyzCloud, *
normals, *cloudWithNormals);
127 CVLog::Print(tr(
"[GreedyTriangulation::compute] generate new normals"));
132 tr(
"[GreedyTriangulation::compute] find normals and use the "
142 if (
result < 0)
return -1;
145 if (out_cloud_sm.height * out_cloud_sm.width == 0) {
157 unsigned faceCount = out_mesh->
size();
159 tr(
"[greedy-triangulation-Reconstruction] %1 points, %2 face(s)")
163 out_mesh->
setName(tr(
"greedy-triangulation searchRadius[%1]")
183 "Selected entity does not have any suitable scalar field "
187 "Wrong Parameters. One or more parameters cannot be "
191 "Greedy Triangulation does not returned any point. Try "
192 "relaxing your parameters");
pcl::PCLPointCloud2 PCLCloud
Base abstract class for each implemented PCL filter.
int isFirstSelectedCcPointCloud()
Returns 1 if the first selected object is a ccPointCloud.
void newEntity(ccHObject *)
Signal emitted when a new entity is created by the filter.
ecvMainAppInterface * m_app
Associated application interface.
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
ccPointCloud * getSelectedEntityAsCCPointCloud() const
Returns the first selected entity as a ccPointCloud.
static bool Print(const char *format,...)
Prints out a formatted message in console.
virtual int openInputDialog()
virtual int checkParameters()
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
float m_normalSearchRadius
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual ~GreedyTriangulation()
int m_trigulationSearchRadius
int m_maxNearestNeighbors
GreedyTriangulationDlg * m_dialog
virtual int compute()
Performs the actual filter job.
virtual int checkSelected()
Checks if current selection is compliant with the filter.
CC to PCL cloud converter.
PCLCloud::Ptr getAsSM(std::list< std::string > &requested_fields) const
pcl::PointCloud< pcl::PointXYZ >::Ptr getXYZ2() const
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
ccHObject * getParent() const
Returns parent object.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
virtual unsigned size() const override
Returns the number of triangles.
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
virtual void setName(const QString &name)
Sets object name.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool hasNormals() const override
Returns whether normals are enabled or not.
virtual void setGlobalShift(double x, double y, double z)
Sets shift applied to original coordinates (information storage only)
virtual const CCVector3d & getGlobalShift() const
Returns the shift applied to original coordinates.
virtual void setGlobalScale(double scale)
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.
T getDiagNorm() const
Returns diagonal length.
bool isValid() const
Returns whether bounding box is valid or not.
virtual unsigned size() const =0
Returns the number of points.
virtual QWidget * getActiveWindow()=0
static ccMesh * Convert(PCLTextureMesh::ConstPtr textureMesh)
Converts a PCL point cloud to a ccPointCloud.
int GetGreedyTriangulation(const PointCloudNormal::ConstPtr &cloudWithNormals, PCLMesh &outMesh, int trigulationSearchRadius, float weightingFactor, int maxNearestNeighbors, int maxSurfaceAngle, int minAngle, int maxAngle, bool normalConsistency)