ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
sm2cc.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 // Local
11 #include <Utils/PCLCloud.h>
12 
13 #include "qPCL.h"
14 
15 // CV_DB_LIB
16 #include <ecvMaterial.h>
17 
18 // system
19 #include <list>
20 
21 class ccMesh;
22 class ccPointCloud;
23 
26 public:
28  static ccMesh* Convert(PCLTextureMesh::ConstPtr textureMesh);
29  static ccPointCloud* Convert(const PCLCloud& pclCloud,
30  bool ignoreScalars = false,
31  bool ignoreRgb = false);
32  static ccMesh* Convert(const PCLCloud& pclCloud,
33  const std::vector<pcl::Vertices>& polygons,
34  bool ignoreScalars = false,
35  bool ignoreRgb = false);
36 
37 public: // other related utility functions
38  static bool CopyXYZ(const PCLCloud& pclCloud,
39  ccPointCloud& ccCloud,
40  uint8_t coordinateType);
41  static bool CopyNormals(const PCLCloud& pclCloud, ccPointCloud& ccCloud);
42  static bool CopyRGB(const PCLCloud& pclCloud, ccPointCloud& ccCloud);
43  static bool CopyScalarField(const PCLCloud& pclCloud,
44  const std::string& sfName,
45  ccPointCloud& ccCloud,
46  bool overwriteIfExist = true);
47 
48  static void FromPCLMaterial(const PCLMaterial& inMaterial,
49  ccMaterial::Shared& outMaterial);
50 };
ccPointCloud::addScalarField
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
Definition: ecvPointCloud.cpp:4210
ccPointCloud::deleteScalarField
void deleteScalarField(int index) override
Deletes a specific scalar field.
Definition: ecvPointCloud.cpp:3237
ecvMaterial.h
FROM_PCL_CLOUD
#define FROM_PCL_CLOUD
Definition: PCLConv.h:11
TexCoords2D
2D texture coordinates
Definition: ecvAdvancedTypes.h:138
pcl2cc::CopyRGB
static bool CopyRGB(const PCLCloud &pclCloud, ccPointCloud &ccCloud)
Definition: sm2cc.cpp:150
ccGenericMesh::showNormals
void showNormals(bool state) override
Sets normals visibility.
Definition: ecvGenericMesh.cpp:44
PointXYZTpl
Definition: sm2cc.cpp:40
ccMaterial::Shared
QSharedPointer< ccMaterial > Shared
Shared type.
Definition: ecvMaterial.h:33
ccDrawableObject::showNormals
virtual void showNormals(bool state)
Sets normals visibility.
Definition: ecvDrawableObject.h:93
FileSystem.h
x
normal_z x
Definition: my_point_types.h:165
ccScalarField::computeMinAndMax
void computeMinAndMax() override
Determines the min and max values.
Definition: ecvScalarField.cpp:145
Tuple3Tpl::x
Type x
Definition: CVGeom.h:137
pcl2cc::FromPCLMaterial
static void FromPCLMaterial(const PCLMaterial &inMaterial, ccMaterial::Shared &outMaterial)
Definition: sm2cc.cpp:311
ccMesh::size
virtual unsigned size() const override
Returns the number of triangles.
Definition: ecvMesh.cpp:2143
PointXYZTpl::EIGEN_ALIGN16::x
T x
Definition: sm2cc.cpp:44
PCLCloudToCCCloud
void PCLCloudToCCCloud(const PCLCloud &pclCloud, ccPointCloud &ccCloud)
Definition: sm2cc.cpp:76
PCLMaterial
pcl::TexMaterial PCLMaterial
Definition: PCLCloud.h:32
ccMesh::addTriangleTexCoordIndexes
void addTriangleTexCoordIndexes(int i1, int i2, int i3)
Adds a triplet of tex coords indexes for next triangle.
Definition: ecvMesh.cpp:3678
ccObject::setName
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75
ccMesh::reservePerTriangleTexCoordIndexes
bool reservePerTriangleTexCoordIndexes()
Reserves memory to store per-triangle triplets of tex coords indexes.
Definition: ecvMesh.cpp:3659
ccMesh::setMaterialSet
void setMaterialSet(ccMaterialSet *materialSet, bool autoReleaseOldMaterialSet=true)
Sets associated material set (may be shared)
Definition: ecvMesh.cpp:492
PointXYZTpl::EIGEN_ALIGN16
Definition: sm2cc.cpp:41
ccObject::setLocked
virtual void setLocked(bool state)
Sets the "enabled" property.
Definition: ecvObject.h:117
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ecvPointCloud.h:146
PCLCloud.h
cloudViewer::ScalarField::addElement
void addElement(ScalarType value)
Definition: ScalarField.h:99
cloudViewer::PointCloudTpl::getScalarFieldIndexByName
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
Definition: PointCloudTpl.h:375
ccMesh::reserve
bool reserve(std::size_t n)
Reserves the memory to store the vertex indexes (3 per triangle)
Definition: ecvMesh.cpp:2475
PCLConv.h
ccMesh::getAssociatedCloud
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
Definition: ecvMesh.h:143
pcl2cc::CopyNormals
static bool CopyNormals(const PCLCloud &pclCloud, ccPointCloud &ccCloud)
Definition: sm2cc.cpp:124
ccMesh::shrinkToFit
void shrinkToFit()
Removes unused capacity.
Definition: ecvMesh.h:302
PCLCloud
pcl::PCLPointCloud2 PCLCloud
Definition: PCLCloud.h:34
ccDrawableObject::hasNormals
virtual bool hasNormals() const
Returns whether normals are enabled or not.
Definition: ecvDrawableObject.h:89
ccPointCloud::setCurrentDisplayedScalarField
void setCurrentDisplayedScalarField(int index)
Sets the currently displayed scalar field.
Definition: ecvPointCloud.cpp:3227
PointXYZTpl::EIGEN_ALIGN16::y
T y
Definition: sm2cc.cpp:45
normals
double normals[3]
Definition: TriangleMeshIO.cpp:54
NormsIndexesTableType
Array of compressed 3D normals (single index)
Definition: ecvAdvancedTypes.h:21
qPCL.h
ccMesh::reservePerTriangleMtlIndexes
bool reservePerTriangleMtlIndexes()
Reserves memory to store per-triangle material index.
Definition: ecvMesh.cpp:3734
ccDrawableObject::showColors
virtual void showColors(bool state)
Sets colors visibility.
Definition: ecvDrawableObject.h:84
my_point_types.h
ccMesh::addTriangle
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.
Definition: ecvMesh.cpp:2428
y
normal_z y
Definition: my_point_types.h:168
ccMaterial
Mesh (triangle) material.
Definition: ecvMaterial.h:28
cloudViewer::ScalarField::reserveSafe
bool reserveSafe(std::size_t count)
Reserves memory (no exception thrown)
Definition: ScalarField.cpp:71
pcl2cc::Convert
static ccMesh * Convert(PCLTextureMesh::ConstPtr textureMesh)
Converts a PCL point cloud to a ccPointCloud.
Vector3Tpl< PointCoordinateType >
ccPointCloud::reserveTheNormsTable
bool reserveTheNormsTable()
Reserves memory to store the compressed normals.
Definition: ecvPointCloud.cpp:1253
ccPointCloud::addNorm
void addNorm(const CCVector3 &N)
Pushes a normal vector on stack (shortcut)
Definition: ecvPointCloud.cpp:1754
scalar
normal_z scalar
Definition: my_point_types.h:169
ccPointCloud::reserve
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
Definition: ecvPointCloud.cpp:1452
pcl2cc::CopyXYZ
static bool CopyXYZ(const PCLCloud &pclCloud, ccPointCloud &ccCloud, uint8_t coordinateType)
Definition: sm2cc.cpp:88
ccArray::isAllocated
bool isAllocated() const
Returns whether some memory has been allocated or not.
Definition: ecvArray.h:67
CCShareable::release
virtual void release()
Decrease counter and deletes object when 0.
Definition: CVShareable.cpp:35
ExistField
bool ExistField(const PCLCloud &pclCloud, std::string name)
Definition: sm2cc.cpp:68
ecvMesh.h
ccArray::addElement
void addElement(const Type &value)
Definition: ecvArray.h:105
ecvScalarField.h
CVTools::ToNativeSeparators
static QString ToNativeSeparators(const QString &path)
Definition: CVTools.cpp:45
TextureCoordsContainer
Array of 2D texture coordinates.
Definition: ecvAdvancedTypes.h:151
ccDrawableObject::showSF
virtual void showSF(bool state)
Sets active scalarfield visibility.
Definition: ecvDrawableObject.h:108
image
std::shared_ptr< core::Tensor > image
Definition: FilamentRenderer.cpp:184
ccMesh::setTexCoordinatesTable
void setTexCoordinatesTable(TextureCoordsContainer *texCoordsTable, bool autoReleaseOldTable=true)
Sets per-triangle texture coordinates array (may be shared)
Definition: ecvMesh.cpp:3598
cloudViewer::utility::filesystem::GetFileParentDirectory
std::string GetFileParentDirectory(const std::string &filename)
Definition: FileSystem.cpp:314
fields
std::vector< PCLPointField > fields
Definition: FileIOFactory.cpp:141
ccPointCloud::addRGBColor
void addRGBColor(const ecvColor::Rgb &C)
Pushes an RGB color on stack.
Definition: ecvPointCloud.cpp:1712
Tuple3Tpl::z
Type z
Definition: CVGeom.h:137
CVTools::ExtractDigitAlpha
static std::string ExtractDigitAlpha(const std::string &str)
Definition: CVTools.cpp:80
ccMaterialSet::addMaterial
int addMaterial(ccMaterial::CShared mat, bool allowDuplicateNames=false)
Adds a material.
Definition: ecvMaterialSet.cpp:60
CVTools.h
PointXYZTpl::EIGEN_ALIGN16::data
T data[3]
Definition: sm2cc.cpp:42
CVTools::ToQString
static QString ToQString(const std::string &s)
Definition: CVTools.cpp:92
ccGenericMesh::showMaterials
virtual void showMaterials(bool state)
Sets whether textures should be displayed or not.
Definition: ecvGenericMesh.h:201
CVLog::Warning
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
ecvColor::night
constexpr Rgbaf night(0.00f, 0.00f, 0.00f, 1.00F)
ccMesh::getTriNormsTable
NormsIndexesTableType * getTriNormsTable() const override
Returns per-triangle normals shared array.
Definition: ecvMesh.h:344
QPCL_ENGINE_LIB_API
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
pcl2cc::CopyScalarField
static bool CopyScalarField(const PCLCloud &pclCloud, const std::string &sfName, ccPointCloud &ccCloud, bool overwriteIfExist=true)
Definition: sm2cc.cpp:170
ecvColor::RgbTpl
RGB color structure.
Definition: ecvColorTypes.h:49
ecvMaterialSet.h
ccMesh
Triangular mesh.
Definition: ecvMesh.h:35
ccMaterialSet
Mesh (triangle) material.
Definition: ecvMaterialSet.h:16
Tuple3Tpl::y
Type y
Definition: CVGeom.h:137
ccMesh::hasColors
bool hasColors() const override
Returns whether colors are enabled or not.
Definition: ecvMesh.cpp:221
cloudViewer::PointCloudTpl::addPoint
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
Definition: PointCloudTpl.h:246
ccMesh::computeNormals
bool computeNormals(bool perVertex)
Computes normals.
Definition: ecvMesh.cpp:242
PointCoordinateType
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
z
normal_z z
Definition: my_point_types.h:165
Tuple3Tpl::u
Type u[3]
Definition: CVGeom.h:139
ccPointCloud::shrinkToFit
void shrinkToFit()
Removes unused capacity.
Definition: ecvPointCloud.h:357
ColorCompType
unsigned char ColorCompType
Default color components type (R,G and B)
Definition: ecvColorTypes.h:29
pcl2cc
PCL to CC cloud converter.
Definition: sm2cc.h:25
ccMesh::addTriangleMtlIndex
void addTriangleMtlIndex(int mtlIndex)
Adds triangle material index for next triangle.
Definition: ecvMesh.cpp:3751
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
POINT_CLOUD_REGISTER_POINT_STRUCT
POINT_CLOUD_REGISTER_POINT_STRUCT(PointXYZTpl< std::int32_t >,(std::int32_t, x, x)(std::int32_t, y, y)(std::int32_t, z, z)) POINT_CLOUD_REGISTER_POINT_STRUCT(PointXYZTpl< std
Definition: sm2cc.cpp:51
PCLScalarField
pcl::PCLPointField PCLScalarField
Definition: sm2cc.cpp:36
sm2cc.h
ecvPointCloud.h
PointXYZTpl::EIGEN_ALIGN16::z
T z
Definition: sm2cc.cpp:46
ccScalarField
A scalar field associated to display-related parameters.
Definition: ecvScalarField.h:19
ccPointCloud::reserveTheRGBTable
bool reserveTheRGBTable()
Reserves memory to store the RGB colors.
Definition: ecvPointCloud.cpp:1200
ecvColor::RgbaTpl
RGBA color structure.
Definition: ecvColorTypes.h:145
name
std::string name
Definition: FileIOFactory.cpp:129