18 #include <unordered_map>
19 #include <unordered_set>
48 explicit ccMesh(
const std::vector<Eigen::Vector3d>& vertices,
49 const std::vector<Eigen::Vector3i>& triangles);
69 bool CreateInternalCloud();
90 int* warnings =
nullptr)
const;
105 static_cast<unsigned int>(vidx1),
106 static_cast<unsigned int>(vidx2));
114 bool updateNormals =
false,
116 unsigned char dim = 2);
144 return m_associatedCloud;
159 bool interpolateColorIfNoTexture)
override;
161 unsigned char vertIndex,
163 bool returnColorIfNoTexture)
override;
171 unsigned triangleIndex)
override;
174 unsigned triangleIndex)
override;
182 double C[3])
const override;
187 void setVertice(
size_t index,
const Eigen::Vector3d& vertice);
213 virtual unsigned size()
const override;
224 unsigned triangleIndex)
const;
261 addTriangle(
static_cast<unsigned>(index[0]),
262 static_cast<unsigned>(index[1]),
263 static_cast<unsigned>(index[2]));
265 inline void addTriangles(
const std::vector<Eigen::Vector3i>& triangles) {
266 for (
auto& tri : triangles) {
280 return m_triVertIndexes;
289 bool init_color =
false,
290 bool init_normal =
false);
318 int& i3)
const override;
326 double Nc[3])
const override;
330 Eigen::Vector3d& Nc)
const override;
350 bool autoReleaseOldTable =
true);
422 return m_triMtlIndexes && m_triMtlIndexes->isAllocated();
451 bool autoReleaseOldTable =
true);
456 return m_triMtlIndexes;
468 bool autoReleaseOldMaterialSet =
true);
485 return m_texCoordIndexes && m_texCoordIndexes->isAllocated();
490 int& i3)
const override;
494 bool autoReleaseOldTable =
true);
549 unsigned nbIteration = 100,
596 bool removeSelectedTriangles,
597 std::vector<int>* newIndexesOfRemainingTriangles =
nullptr,
598 bool withChildEntities =
false);
612 static const unsigned char DefaultMergeDulicateVerticesLevel = 10;
616 unsigned char octreeLevel = DefaultMergeDulicateVerticesLevel,
617 QWidget* parentWidget =
nullptr);
672 return {r, g, b, 1.f};
675 float r()
const {
return f4[0]; }
676 float g()
const {
return f4[1]; }
677 float b()
const {
return f4[2]; }
678 float a()
const {
return f4[3]; }
682 float baseMetallic = 0.f;
683 float baseRoughness = 1.f;
684 float baseReflectance = 0.5f;
685 float baseClearCoat = 0.f;
686 float baseClearCoatRoughness = 0.f;
687 float baseAnisotropy = 0.f;
689 std::shared_ptr<cloudViewer::geometry::Image>
albedo;
690 std::shared_ptr<cloudViewer::geometry::Image>
normalMap;
692 std::shared_ptr<cloudViewer::geometry::Image>
metallic;
693 std::shared_ptr<cloudViewer::geometry::Image>
roughness;
695 std::shared_ptr<cloudViewer::geometry::Image>
clearCoat;
700 std::unordered_map<std::string, cloudViewer::geometry::Image>
713 return getVerticeSize() > 0 &&
714 adjacency_list_.size() == getVerticeSize();
727 bool is_all_texture_valid = std::accumulate(
728 textures_.begin(), textures_.end(),
true,
730 return a && !b.IsEmpty();
732 return !textures_.empty() && is_all_texture_valid;
735 inline virtual bool IsEmpty()
const override {
746 bool relative =
true)
override;
748 const Eigen::Vector3d& center)
override;
750 const Eigen::Vector3d& center)
override;
772 const std::unordered_map<
777 double min_weight = std::numeric_limits<double>::lowest())
const;
837 int number_of_iterations,
850 int number_of_iterations,
864 int number_of_iterations,
879 int number_of_iterations,
893 bool allow_boundary_edges =
true)
const;
962 const Eigen::Vector3d& p1,
963 const Eigen::Vector3d& p2);
997 const Eigen::Vector3d& p1,
998 const Eigen::Vector3d& p2);
1012 size_t number_of_points,
1013 std::vector<double>& triangle_areas,
1014 double surface_area,
1015 bool use_triangle_normal,
1026 size_t number_of_points,
1027 bool use_triangle_normal =
false,
1042 size_t number_of_points,
1043 double init_factor = 5,
1044 const std::shared_ptr<ccPointCloud> pcl_init =
nullptr,
1045 bool use_triangle_normal =
false,
1071 SimplificationContraction::Average)
const;
1081 int target_number_of_triangles,
1083 double boundary_weight = 1.0)
const;
1095 bool cleanup =
true)
const;
1115 std::tuple<std::vector<int>, std::vector<size_t>, std::vector<double>>
1164 const std::vector<int>& constraint_vertex_indices,
1165 const std::vector<Eigen::Vector3d>& constraint_vertex_positions,
1168 DeformAsRigidAsPossibleEnergy::Spokes,
1169 double smoothed_alpha = 0.01)
const;
1185 std::shared_ptr<cloudViewer::geometry::TetraMesh> tetra_mesh =
1187 std::vector<size_t>* pt_map =
nullptr);
1240 static std::tuple<std::shared_ptr<ccMesh>, std::vector<double>>
1245 bool linear_fit =
false,
1246 float point_weight = 2.f,
1247 float samples_per_node = 1.5f,
1248 int boundary_type = 2 ,
1249 int n_threads = -1);
1257 double radius = 1.0,
bool create_uv_map =
false);
1265 bool create_uv_map =
false);
1272 double radius = 1.0,
bool create_uv_map =
false);
1281 bool create_uv_map =
false);
1295 bool create_uv_map =
false,
1296 bool map_texture_to_each_face =
false);
1309 int resolution = 20,
1310 bool create_uv_map =
false);
1325 int resolution = 20,
1327 bool create_uv_map =
false);
1341 int resolution = 20,
1343 bool create_uv_map =
false);
1356 double tube_radius = 0.5,
1357 int radial_resolution = 30,
1358 int tubular_resolution = 20);
1380 static std::shared_ptr<ccMesh>
CreateArrow(
double cylinder_radius = 1.0,
1381 double cone_radius = 1.5,
1382 double cylinder_height = 5.0,
1383 double cone_height = 4.0,
1384 int resolution = 20,
1385 int cylinder_split = 4,
1386 int cone_split = 1);
1395 const Eigen::Vector3d& origin = Eigen::Vector3d(0.0, 0.0, 0.0));
1408 int width_split = 15,
1411 double flatness = 1,
1417 std::shared_ptr<ccMesh>& mesh,
1418 const std::vector<CCVector3>& prev_vertices,
1419 const std::vector<CCVector3>& prev_vertex_normals,
1421 const std::vector<std::unordered_set<int>>& adjacency_list,
1425 bool filter_color)
const;
1451 const Tuple3i* triNormIndexes =
nullptr);
1466 #define ccMesh_extended_call0(baseName, recursiveName) \
1467 inline virtual void recursiveName() { \
1469 for (Container::iterator it = m_children.begin(); \
1470 it != m_children.end(); ++it) \
1471 if ((*it)->isA(CV_TYPES::SUB_MESH)) \
1472 static_cast<ccGenericMesh*>(*it)->baseName(); \
1476 #define ccMesh_extended_call1(baseName, param1Type, recursiveName) \
1477 inline virtual void recursiveName(param1Type p) { \
1479 for (Container::iterator it = m_children.begin(); \
1480 it != m_children.end(); ++it) \
1481 if ((*it)->isA(CV_TYPES::SUB_MESH)) \
1482 static_cast<ccGenericMesh*>(*it)->baseName(p); \
1505 unsigned m_globalIterator;
float PointCoordinateType
Type of the coordinates of a (N-D) point.
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Array of RGB colors for each point.
Array of compressed 3D normals (single index)
Array of 2D texture coordinates.
Shareable array that can be properly inserted in the DB tree.
virtual bool hasNormals() const
Returns whether normals are enabled or not.
Float version of ccGLMatrixTpl.
virtual bool materialsShown() const
Sets whether textures/material should be displayed or not.
virtual bool hasTriNormals() const =0
Returns whether the mesh has per-triangle normals.
virtual void showMaterials(bool state)
Sets whether textures should be displayed or not.
virtual unsigned capacity() const =0
Returns max capacity.
A 3D cloud interface with associated features (color, normals, octree, etc.)
Hierarchical CLOUDVIEWER Object.
Mesh (triangle) material.
bool getTriangleNormals(unsigned triangleIndex, double Na[3], double Nb[3], double Nc[3]) const override
bool IsIntersecting(const ccMesh &other) const
std::shared_ptr< ccMesh > Crop(const ccBBox &bbox) const
bool interpolateNormalsBC(unsigned triIndex, const CCVector3d &w, CCVector3 &N) override
Interpolates normal(s) inside a given triangle.
void getTriangleTexCoordinatesIndexes(unsigned triangleIndex, int &i1, int &i2, int &i3) const override
Returns the triplet of tex coords indexes for a given triangle.
CV_CLASS_ENUM getClassID() const override
Returns class ID.
std::shared_ptr< ccMesh > FilterSmoothLaplacian(int number_of_iterations, double lambda, FilterScope scope=FilterScope::All) const
Function to smooth triangle mesh using Laplacian.
void getTriangleVertIndexes(size_t triangleIndex, Eigen::Vector3i &vertIndx) const
double GetTriangleArea(size_t triangle_idx) const
const ccMaterialSet * getMaterialSet() const override
static std::tuple< std::shared_ptr< ccMesh >, std::vector< double > > CreateFromPointCloudPoisson(const ccPointCloud &pcd, size_t depth=8, size_t width=0, float scale=1.1f, bool linear_fit=false, float point_weight=2.f, float samples_per_node=1.5f, int boundary_type=2, int n_threads=-1)
Function that computes a triangle mesh from a oriented PointCloud pcd. This implements the Screened P...
TextureCoordsContainer * getTexCoordinatesTable() const override
Returns per-triangle texture coordinates array.
static std::shared_ptr< ccMesh > CreateCylinder(double radius=1.0, double height=2.0, int resolution=20, int split=4, bool create_uv_map=false)
bool merge(const ccMesh *mesh, bool createSubMesh)
Merges another mesh into this one.
std::vector< int > GetNonManifoldVertices() const
ccMesh * cloneMesh(ccGenericPointCloud *vertices=nullptr, ccMaterialSet *clonedMaterials=nullptr, NormsIndexesTableType *clonedNormsTable=nullptr, TextureCoordsContainer *cloneTexCoords=nullptr)
Clones this entity.
void addEigenVertices(const std::vector< Eigen::Vector3d > &vertices)
NormsIndexesTableType * getTriNormsTable() const override
Returns per-triangle normals shared array.
virtual ccMesh & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d ¢er) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
static std::shared_ptr< ccMesh > CreateArrow(double cylinder_radius=1.0, double cone_radius=1.5, double cylinder_height=5.0, double cone_height=4.0, int resolution=20, int cylinder_split=4, int cone_split=1)
void getTriangleNormalIndexes(unsigned triangleIndex, int &i1, int &i2, int &i3) const override
Returns a triplet of normal indexes for a given triangle (if any)
void drawMeOnly(CC_DRAW_CONTEXT &context) override
Enables (OpenGL) stipple mask.
bool hasMaterials() const override
std::shared_ptr< ccMesh > SimplifyVertexClustering(double voxel_size, SimplificationContraction contraction=SimplificationContraction::Average) const
bool hasDisplayedScalarField() const override
Returns whether an active scalar field is available or not.
bool getTriangleNormals(unsigned triangleIndex, CCVector3 &Na, CCVector3 &Nb, CCVector3 &Nc) const override
Returns a given triangle normal.
std::shared_ptr< ccMesh > DeformAsRigidAsPossible(const std::vector< int > &constraint_vertex_indices, const std::vector< Eigen::Vector3d > &constraint_vertex_positions, size_t max_iter, DeformAsRigidAsPossibleEnergy energy=DeformAsRigidAsPossibleEnergy::Spokes, double smoothed_alpha=0.01) const
This function deforms the mesh using the method by Sorkine and Alexa, "As-Rigid-As-Possible Surface M...
void invertPerTriangleNormals()
Invert per-triangle normals.
triangleIndexesContainer * getTrianglesPtr() const
ccMesh * partialClone(const std::vector< unsigned > &triangleIndices, int *warnings=nullptr) const
Creates a new mesh from a selection of triangles (partial clone)
std::vector< Eigen::Vector3d > getTriangleNormals() const
ccMesh & RemoveDuplicatedTriangles()
Function that removes duplicated triangles, i.e., removes triangles that reference the same three ver...
void applyGLTransformation(const ccGLMatrix &trans) override
Applies a GL transformation to the entity.
void RemoveTrianglesByMask(const std::vector< bool > &triangle_mask)
This function removes the triangles that are masked in triangle_mask. Call RemoveUnreferencedVertices...
std::shared_ptr< ccMesh > SelectByIndex(const std::vector< size_t > &indices, bool cleanup=true) const
virtual void getTriangleVertices(unsigned triangleIndex, double A[3], double B[3], double C[3]) const override
ccMesh * subdivide(PointCoordinateType maxArea) const
bool laplacianSmooth(unsigned nbIteration=100, PointCoordinateType factor=static_cast< PointCoordinateType >(0.01), ecvProgressDialog *progressCb=nullptr)
Laplacian smoothing.
const triangleMaterialIndexesSet * getTriangleMtlIndexesTable() const
Returns the per-triangle material indexes array.
cloudViewer::VerticesIndexes * getTriangleVertIndexes(unsigned triangleIndex) override
Returns the indexes of the vertices of a given triangle.
bool hasAdjacencyList() const
Returns true if the mesh contains adjacency normals.
virtual bool IsEmpty() const override
bool normalsShown() const override
Returns whether normals are shown or not.
std::tuple< std::vector< int >, std::vector< size_t >, std::vector< double > > ClusterConnectedTriangles() const
Function that clusters connected triangles, i.e., triangles that are connected via edges are assigned...
ccMesh operator+(const ccMesh &mesh) const
bool reservePerTriangleMtlIndexes()
Reserves memory to store per-triangle material index.
bool addTriangleNorm(const Eigen::Vector3d &N)
void flipTriangles()
Flips the triangle.
static std::shared_ptr< ccMesh > CreateCoordinateFrame(double size=1.0, const Eigen::Vector3d &origin=Eigen::Vector3d(0.0, 0.0, 0.0))
void setTriangleMtlIndexesTable(triangleMaterialIndexesSet *matIndexesTable, bool autoReleaseOldTable=true)
Sets per-triangle material indexes array.
void setVertexNormal(size_t index, const Eigen::Vector3d &normal)
std::vector< Eigen::Vector3i > getTriangles() const
bool processScalarField(MESH_SCALAR_FIELD_PROCESS process)
void toggleMaterials() override
Toggles material display state.
cloudViewer::GenericTriangle * _getTriangle(unsigned triangleIndex) override
Returns the ith triangle.
void addTriangles(const std::vector< Eigen::Vector3i > &triangles)
bool IsVertexManifold() const
virtual ccMesh & Scale(const double s, const Eigen::Vector3d ¢er) override
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
bool setTriangleNorm(size_t index, const Eigen::Vector3d &triangle_normal)
static ccMesh * TriangulateTwoPolylines(ccPolyline *p1, ccPolyline *p2, CCVector3 *projectionDir=nullptr)
Creates a Delaunay 2.5D mesh from two polylines.
void removePerTriangleNormalIndexes()
Removes any per-triangle triplets of normal indexes.
std::vector< int > triangle_material_ids_
List of material ids.
std::unordered_map< Eigen::Vector2i, std::vector< int >, cloudViewer::utility::hash_eigen< Eigen::Vector2i > > GetEdgeToTrianglesMap() const
int EulerPoincareCharacteristic() const
bool convertMaterialsToVertexColors()
Converts materials to vertex colors.
short minimumFileVersion_MeOnly() const override
void addVertice(const Eigen::Vector3d &vertice)
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
double GetSurfaceArea() const
void addTriangle(const Eigen::Vector3i &index)
void setTriangle(size_t index, const Eigen::Vector3i &triangle)
ccMesh & RemoveDuplicatedVertices()
Function that removes duplicated verties, i.e., vertices that have identical coordinates.
static std::shared_ptr< ccMesh > CreateMobius(int length_split=70, int width_split=15, int twists=1, double radius=1, double flatness=1, double width=1, double scale=1)
ccMesh(ccGenericPointCloud *vertices=nullptr)
Default ccMesh constructor.
static std::shared_ptr< ccMesh > CreateIcosahedron(double radius=1.0, bool create_uv_map=false)
void getTriangleTexCoordinates(unsigned triIndex, TexCoords2D *&tx1, TexCoords2D *&tx2, TexCoords2D *&tx3) const override
Returns per-triangle texture coordinates (pointer to)
void setTriNormsTable(NormsIndexesTableType *triNormsTable, bool autoReleaseOldTable=true)
Sets per-triangle normals array (may be shared)
std::vector< Eigen::Vector2d > triangle_uvs_
List of uv coordinates per triangle.
static cloudViewer::VerticesIndexes GetOrderedTriangle(int vidx0, int vidx1, int vidx2)
void transformTriNormals(const ccGLMatrix &trans)
Transforms the mesh per-triangle normals.
void swapTriangles(unsigned index1, unsigned index2)
Swaps two triangles.
std::shared_ptr< ccMesh > Crop(const ecvOrientedBBox &bbox) const
ccMesh(const ccMesh &mesh)
bool IsSelfIntersecting() const
Eigen::Vector3d getTriangleNorm(size_t index) const
std::vector< Eigen::Vector3d > getVertexColors() const
std::shared_ptr< ccMesh > FilterSmoothTaubin(int number_of_iterations, double lambda=0.5, double mu=-0.53, FilterScope scope=FilterScope::All) const
Function to smooth triangle mesh using method of Taubin, "Curve and Surface Smoothing Without Shrinka...
bool HasVertexNormals() const
ccMesh & RemoveNonManifoldEdges()
Function that removes all non-manifold edges, by successively deleting triangles with the smallest su...
bool hasColors() const override
Returns whether colors are enabled or not.
MESH_SCALAR_FIELD_PROCESS
Mesh scalar field processes.
bool getColorFromMaterial(unsigned triIndex, const CCVector3 &P, ecvColor::Rgb &C, bool interpolateColorIfNoTexture) override
bool pushSubdivide(unsigned indexA, unsigned indexB, unsigned indexC)
Used internally by 'subdivide'.
void setAssociatedCloud(ccGenericPointCloud *cloud)
Sets the associated vertices cloud (warning)
static ccMesh * Triangulate(ccGenericPointCloud *cloud, cloudViewer::TRIANGULATION_TYPES type, bool updateNormals=false, PointCoordinateType maxEdgeLength=0, unsigned char dim=2)
Creates a Delaunay 2.5D mesh from a point cloud.
std::vector< Eigen::Vector3d > getTriangleNorms() const
std::vector< std::unordered_set< int > > adjacency_list_
void addTriangleMtlIndex(int mtlIndex)
Adds triangle material index for next triangle.
void setTriangleMtlIndex(unsigned triangleIndex, int mtlIndex)
Sets triangle material indexes.
std::shared_ptr< ccMesh > SubdivideMidpoint(int number_of_iterations) const
void RemoveTrianglesByIndex(const std::vector< size_t > &triangle_indices)
This function removes the triangles with index in triangle_indices. Call RemoveUnreferencedVertices t...
void clearTriNormals()
Removes per-triangle normals.
bool computePerTriangleNormals()
Computes per-triangle normals.
void computeInterpolationWeights(const cloudViewer::VerticesIndexes &vertIndexes, const CCVector3 &P, CCVector3d &weights) const
ccMesh(cloudViewer::GenericIndexedMesh *giMesh, ccGenericPointCloud *giVertices)
ccMesh constructor (from a cloudViewer::GenericIndexedMesh)
const std::vector< CCVector3 > & getVertices() const
void setEigenVertices(const std::vector< Eigen::Vector3d > &vertices)
static std::shared_ptr< ccMesh > CreateBox(double width=1.0, double height=1.0, double depth=1.0, bool create_uv_map=false, bool map_texture_to_each_face=false)
void setTriangleNormalIndexes(unsigned triangleIndex, int i1, int i2, int i3)
Sets a triplet of normal indexes for a given triangle.
void setMaterialSet(ccMaterialSet *materialSet, bool autoReleaseOldMaterialSet=true)
Sets associated material set (may be shared)
void setTriangles(const std::vector< Eigen::Vector3i > &triangles)
std::unordered_map< Eigen::Vector2i, std::vector< int >, cloudViewer::utility::hash_eigen< Eigen::Vector2i > > GetEdgeToVerticesMap() const
bool isSerializable() const override
Returns whether object is serializable of not.
bool reserve(std::size_t n)
Reserves the memory to store the vertex indexes (3 per triangle)
cloudViewer::VerticesIndexes * getNextTriangleVertIndexes() override
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
void shiftTriangleIndexes(unsigned shift)
Shifts all triangles indexes.
static std::shared_ptr< ccMesh > CreateTetrahedron(double radius=1.0, bool create_uv_map=false)
void FilterSmoothLaplacianHelper(std::shared_ptr< ccMesh > &mesh, const std::vector< CCVector3 > &prev_vertices, const std::vector< CCVector3 > &prev_vertex_normals, const ColorsTableType &prev_vertex_colors, const std::vector< std::unordered_set< int >> &adjacency_list, double lambda, bool filter_vertex, bool filter_normal, bool filter_color) const
bool hasEigenTextures() const
Returns true if the mesh has texture.
void addVertexColors(const std::vector< Eigen::Vector3d > &colors)
void addVertexNormal(const Eigen::Vector3d &normal)
void addTriangleTexCoordIndexes(int i1, int i2, int i3)
Adds a triplet of tex coords indexes for next triangle.
bool normalsAvailable() const override
Returns whether normals are available.
std::vector< Eigen::Vector2i > GetSelfIntersectingTriangles() const
static std::shared_ptr< ccMesh > CreateCone(double radius=1.0, double height=2.0, int resolution=20, int split=1, bool create_uv_map=false)
std::shared_ptr< ccMesh > SubdivideLoop(int number_of_iterations) const
bool hasTextures() const override
Returns whether textures are available for this mesh.
bool setTriangleNormalIndexes(size_t triangleIndex, CompressedNormType value)
static std::shared_ptr< ccMesh > CreateFromPointCloudBallPivoting(const ccPointCloud &pcd, const std::vector< double > &radii)
void setVertexNormals(const std::vector< Eigen::Vector3d > &normals)
ccMesh & RemoveUnreferencedVertices()
This function removes vertices from the triangle mesh that are not referenced in any triangle of the ...
Eigen::Vector3d getVertice(size_t index) const
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
static Eigen::Vector4d ComputeTrianglePlane(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2)
std::vector< Eigen::Vector3d > getEigenVertices() const
unsigned getUniqueIDForDisplay() const override
Returns object unqiue ID used for display.
Eigen::Vector4d GetTrianglePlane(size_t triangle_idx) const
void placeIteratorAtBeginning() override
Places the mesh iterator at the beginning.
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.
void removePerTriangleTexCoordIndexes()
Remove per-triangle tex coords indexes.
bool reservePerTriangleNormalIndexes()
Reserves memory to store per-triangle triplets of normal indexes.
bool hasPerTriangleTexCoordIndexes() const override
Returns whether this mesh as per-triangle triplets of tex coords indexes.
virtual ccBBox GetAxisAlignedBoundingBox() const override
Returns an axis-aligned bounding box of the geometry.
static std::shared_ptr< ccMesh > CreatePlane(double width=1.0, double height=1.0, bool create_uv_map=false)
void setTexCoordinatesTable(TextureCoordsContainer *texCoordsTable, bool autoReleaseOldTable=true)
Sets per-triangle texture coordinates array (may be shared)
static Eigen::Vector3i GetEigneOrderedTriangle(int vidx0, int vidx1, int vidx2)
bool interpolateNormals(unsigned triIndex, const CCVector3 &P, CCVector3 &N) override
Interpolates normal(s) inside a given triangle.
ccMesh & PaintUniformColor(const Eigen::Vector3d &color)
Assigns each vertex in the ccMesh the same color.
CompressedNormType getTriangleNormalIndexes(size_t triangleIndex)
std::shared_ptr< ccMesh > SimplifyQuadricDecimation(int target_number_of_triangles, double maximum_error=std::numeric_limits< double >::infinity(), double boundary_weight=1.0) const
unsigned int getVerticeSize() const
void RemoveVerticesByIndex(const std::vector< size_t > &vertex_indices)
This function removes the vertices with index in vertex_indices. Note that also all triangles associa...
virtual void getTriangleVertices(unsigned triangleIndex, CCVector3 &A, CCVector3 &B, CCVector3 &C) const override
Returns the vertices of a given triangle.
std::shared_ptr< ccPointCloud > SamplePointsPoissonDisk(size_t number_of_points, double init_factor=5, const std::shared_ptr< ccPointCloud > pcl_init=nullptr, bool use_triangle_normal=false, int seed=-1)
void removeTriangles(size_t index)
static std::shared_ptr< ccMesh > CreateFromPointCloudAlphaShape(const ccPointCloud &pcd, double alpha, std::shared_ptr< cloudViewer::geometry::TetraMesh > tetra_mesh=nullptr, std::vector< size_t > *pt_map=nullptr)
Alpha shapes are a generalization of the convex hull. With decreasing alpha value the shape schrinks ...
ccMesh & ComputeAdjacencyList()
Function to compute adjacency list, call before adjacency list is.
bool resize(size_t n)
Resizes the array of vertex indexes (3 per triangle)
void setVertexColors(const std::vector< Eigen::Vector3d > &colors)
Eigen::Vector3d getVertexColor(size_t index) const
bool resizeAssociatedCloud(std::size_t n)
std::shared_ptr< ccPointCloud > SamplePointsUniformlyImpl(size_t number_of_points, std::vector< double > &triangle_areas, double surface_area, bool use_triangle_normal, int seed)
bool arePerTriangleNormalsEnabled() const
Returns whether per triangle normals are enabled.
std::shared_ptr< ccPointCloud > SamplePointsUniformly(size_t number_of_points, bool use_triangle_normal=false, int seed=-1)
static std::shared_ptr< ccMesh > CreateSphere(double radius=1.0, int resolution=20, bool create_uv_map=false)
ccMesh & operator+=(const ccMesh &mesh)
void addTriangleNormalIndexes(int i1, int i2, int i3)
Adds a triplet of normal indexes for next triangle.
void getTexCoordinates(unsigned index, TexCoords2D *&tx) const override
bool reserveAssociatedCloud(std::size_t n, bool init_color=false, bool init_normal=false)
std::tuple< std::shared_ptr< ccMesh >, std::vector< size_t > > ComputeConvexHull() const
ccMesh & RemoveDegenerateTriangles()
Function that removes degenerate triangles, i.e., triangles that reference a single vertex multiple t...
std::vector< CCVector3 * > getTriangleNormalsPtr() const
bool reservePerTriangleTexCoordIndexes()
Reserves memory to store per-triangle triplets of tex coords indexes.
void setVertexColor(size_t index, const Eigen::Vector3d &color)
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
ccMesh * createNewMeshFromSelection(bool removeSelectedTriangles, std::vector< int > *newIndexesOfRemainingTriangles=nullptr, bool withChildEntities=false)
Creates a new mesh with the selected vertices only.
bool getVertexColorFromMaterial(unsigned triIndex, unsigned char vertIndex, ecvColor::Rgb &C, bool returnColorIfNoTexture) override
bool IsOrientable() const
double GetSurfaceArea(std::vector< double > &triangle_areas) const
bool hasNormals() const override
Returns whether normals are enabled or not.
bool computePerVertexNormals()
Computes per-vertex normals.
void refreshBB() override
Forces bounding-box update.
virtual ecvOrientedBBox GetOrientedBoundingBox() const override
static std::shared_ptr< ccMesh > CreateTorus(double torus_radius=1.0, double tube_radius=0.5, int radial_resolution=30, int tubular_resolution=20)
bool hasScalarFields() const override
Returns whether one or more scalar fields are instantiated.
void addTriangle(const cloudViewer::VerticesIndexes &triangle)
bool IsWatertight() const
void RemoveVerticesByMask(const std::vector< bool > &vertex_mask)
This function removes the vertices that are masked in vertex_mask. Note that also all triangles assoc...
bool IsBoundingBoxIntersecting(const ccMesh &other) const
std::vector< Eigen::Vector3d > getVertexNormals() const
void onDeletionOf(const ccHObject *obj) override
This method is called when another object is deleted.
std::vector< CCVector3 > & getVerticesPtr()
bool interpolateColors(const cloudViewer::VerticesIndexes &vertIndexes, const CCVector3 &P, ecvColor::Rgb &C)
void computeInterpolationWeights(unsigned triIndex, const CCVector3 &P, CCVector3d &weights) const override
Returns the (barycentric) interpolation weights for a given triangle.
~ccMesh() override
Default destructor.
std::unordered_map< Eigen::Vector2i, double, cloudViewer::utility::hash_eigen< Eigen::Vector2i > > ComputeEdgeWeightsCot(const std::unordered_map< Eigen::Vector2i, std::vector< int >, cloudViewer::utility::hash_eigen< Eigen::Vector2i >> &edges_to_vertices, double min_weight=std::numeric_limits< double >::lowest()) const
Function that computes for each edge in the triangle mesh and passed as parameter edges_to_vertices t...
void setTriangleTexCoordIndexes(unsigned triangleIndex, int i1, int i2, int i3)
Sets a triplet of tex coords indexes for a given triangle.
virtual unsigned size() const override
Returns the number of triangles.
bool IsEdgeManifold(bool allow_boundary_edges=true) const
Eigen::Vector3i getTriangle(size_t index) const
void removePerTriangleMtlIndexes()
Removes any per-triangle material indexes.
virtual Eigen::Vector3d GetMinBound() const override
Returns min bounds for geometry coordinates.
bool setTriangleNorms(const std::vector< Eigen::Vector3d > &triangle_normals)
void forEach(genericTriangleAction action) override
Fast iteration mechanism.
int getTriangleMtlIndex(unsigned triangleIndex) const override
Returns a given triangle material indexes.
void setVertice(size_t index, const Eigen::Vector3d &vertice)
bool HasTriangleNormals() const
bool hasTriangleMaterialIds() const
std::shared_ptr< ccMesh > FilterSmoothSimple(int number_of_iterations, FilterScope scope=FilterScope::All) const
Function to smooth triangle mesh with simple neighbour average.
std::vector< cloudViewer::geometry::Image > textures_
Textures of the image.
bool addTriangleNorm(const CCVector3 &N)
cloudViewer::GenericTriangle * _getNextTriangle() override
Returns the next triangle (relatively to the global iterator position)
static double ComputeTriangleArea(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1, const Eigen::Vector3d &p2)
Function that computes the area of a mesh triangle.
bool mergeDuplicatedVertices(unsigned char octreeLevel=DefaultMergeDulicateVerticesLevel, QWidget *parentWidget=nullptr)
Merges duplicated vertices.
ccMesh & ComputeVertexNormals(bool normalized=true)
Function to compute vertex normals, usually called before rendering.
void getBoundingBox(CCVector3 &bbMin, CCVector3 &bbMax) override
Returns the mesh bounding-box.
ccMesh & operator=(const ccMesh &mesh)
ColorsTableType * getVertexColorsPtr()
static Eigen::Vector2i GetOrderedEdge(int vidx0, int vidx1)
Helper function to get an edge with ordered vertex indices.
Eigen::Vector3d getVertexNormal(size_t index) const
void onUpdateOf(ccHObject *obj) override
This method is called when another object (geometry) is updated.
std::shared_ptr< ccMesh > FilterSharpen(int number_of_iterations, double strength, FilterScope scope=FilterScope::All) const
Function to sharpen triangle mesh.
virtual Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
void addVertexNormals(const std::vector< Eigen::Vector3d > &normals)
ccMesh(const std::vector< Eigen::Vector3d > &vertices, const std::vector< Eigen::Vector3i > &triangles)
Parameterized Constructor.
void shrinkToFit()
Removes unused capacity.
ccMesh & MergeCloseVertices(double eps)
Function that will merge close by vertices to a single one. The vertex position, normal and color wil...
std::vector< std::pair< std::string, Material > > materials_
void addVertexColor(const Eigen::Vector3d &color)
virtual ccMesh & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
bool addTriangleNorms(const std::vector< Eigen::Vector3d > &triangle_normals)
unsigned capacity() const override
Returns max capacity.
bool hasPerTriangleMtlIndexes() const
Returns whether this mesh as per-triangle material index.
void invertNormals()
Inverts normals (if any)
bool hasTriangleUvs() const
bool interpolateNormals(const cloudViewer::VerticesIndexes &vertIndexes, const CCVector3d &w, CCVector3 &N, const Tuple3i *triNormIndexes=nullptr)
bool getTriangleNormals(unsigned triangleIndex, Eigen::Vector3d &Na, Eigen::Vector3d &Nb, Eigen::Vector3d &Nc) const override
const ccGLMatrix & getGLTransformationHistory() const override
Returns the transformation 'history' matrix.
std::vector< Eigen::Vector2i > GetNonManifoldEdges(bool allow_boundary_edges=true) const
static std::shared_ptr< ccMesh > CreateOctahedron(double radius=1.0, bool create_uv_map=false)
ccMesh & ComputeTriangleNormals(bool normalized=true)
Function to compute triangle normals, usually called before rendering.
virtual const cloudViewer::VerticesIndexes * getTriangleVertIndexes(unsigned triangleIndex) const
virtual ccMesh & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Apply translation to the geometry coordinates.
bool computeNormals(bool perVertex)
Computes normals.
ccMesh & NormalizeNormals()
virtual Eigen::Vector3d GetMaxBound() const override
Returns max bounds for geometry coordinates.
bool hasTriNormals() const override
Returns whether the mesh has per-triangle normals.
bool interpolateColors(unsigned triIndex, const CCVector3 &P, ecvColor::Rgb &C) override
Interpolates RGB colors inside a given triangle.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
A generic mesh with index-based vertex access.
virtual unsigned size() const =0
Returns the number of triangles.
std::function< void(GenericTriangle &)> genericTriangleAction
Generic function to apply to a triangle (used by foreach)
FilterScope
Indicates the scope of filter operations.
DeformAsRigidAsPossibleEnergy
SimplificationContraction
Indicates the method that is used for mesh simplification if multiple vertices are combined to a sing...
virtual bool hasTriangles() const
A generic triangle interface.
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Graphical progress indicator (thread-safe)
__device__ __forceinline__ float infinity()
unsigned int CompressedNormType
Compressed normals type.
#define ccMesh_extended_call1(baseName, param1Type, recursiveName)
Helper functions for the ml ops.
Generic file read and write utility for python interface.
TRIANGULATION_TYPES
Triangulation types.
Eigen::Matrix< Index, 3, 1 > Vector3i
Eigen::Matrix< Index, 2, 1 > Vector2i
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.
MaterialParameter(const float v1, const float v2, const float v3, const float v4)
MaterialParameter(const float v1, const float v2, const float v3)
static MaterialParameter CreateRGB(const float r, const float g, const float b)
MaterialParameter(const float v1)
MaterialParameter(const float v1, const float v2)
std::shared_ptr< cloudViewer::geometry::Image > anisotropy
std::shared_ptr< cloudViewer::geometry::Image > ambientOcclusion
std::shared_ptr< cloudViewer::geometry::Image > metallic
std::shared_ptr< cloudViewer::geometry::Image > clearCoat
std::unordered_map< std::string, MaterialParameter > floatParameters
std::shared_ptr< cloudViewer::geometry::Image > reflectance
MaterialParameter baseColor
std::shared_ptr< cloudViewer::geometry::Image > albedo
std::unordered_map< std::string, cloudViewer::geometry::Image > additionalMaps
std::shared_ptr< cloudViewer::geometry::Image > clearCoatRoughness
std::shared_ptr< cloudViewer::geometry::Image > roughness
std::shared_ptr< cloudViewer::geometry::Image > normalMap
Triangle described by the indexes of its 3 vertices.