42 unsigned vertCount = verts->
size();
43 unsigned facesCount =
size();
44 unsigned triFacesNormCount =
49 unsigned newFacesCount = facesCount + prim.
size();
54 if (primHasColors && !verts->
hasColors()) {
56 CVLog::Error(
"[ccGenericPrimitive::operator +] Not enough memory!");
62 if (verts->
reserve(newVertCount) &&
67 if (primHasColors && !verts->
hasColors()) {
70 "[ccGenericPrimitive::operator +] Not enough memory!");
77 for (
unsigned i = 0; i < cloud->
size(); ++i) {
79 if (primHasVertNorms) {
90 if (primHasFaceNorms) {
93 unsigned primTriNormCount = primNorms->
currentSize();
97 if (!normsTable || !normsTable->
reserveSafe(triFacesNormCount +
100 "[ccGenericPrimitive::operator +] Not enough memory!");
110 for (
unsigned i = 0; i < primTriNormCount; ++i) {
116 for (
unsigned i = 0; i < prim.
size(); ++i) {
120 vertCount + tsi->
i3);
121 if (primHasFaceNorms) {
124 triFacesNormCount + normIndexes.
u[1],
125 triFacesNormCount + normIndexes.
u[2]);
129 CVLog::Error(
"[ccGenericPrimitive::operator +] Not enough memory!");
136 assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));
137 if (dataVersion < 21) {
155 short minVersion = std::max(
static_cast<short>(21),
237 unsigned faceNormCounts) {
240 if (!verts)
return false;
245 bool keepOtherProps = (vertCount == verts->
size());
246 if (keepOtherProps) {
270 if (vertCount && !verts->
reserve(vertCount))
return false;
277 if (faceCounts && !
reserve(faceCounts)) {
282 if (faceNormCounts) {
285 if (!normsTable || !normsTable->
reserveSafe(faceNormCounts) ||
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Array of compressed 3D normals (single index)
Type & getValue(size_t index)
bool reserveSafe(size_t count)
Reserves memory (no exception thrown)
unsigned currentSize() const
void addElement(const Type &value)
void clear(bool releaseMemory=false)
virtual bool colorsShown() const
Returns whether colors are shown or not.
virtual void setGLTransformation(const ccGLMatrix &trans)
Associates entity with a GL transformation (rotation + translation)
virtual bool isVisible() const
Returns whether entity is visible or not.
virtual bool hasColors() const
Returns whether colors are enabled or not.
virtual void setVisible(bool state)
Sets entity visibility.
virtual bool sfShown() const
Returns whether active scalar field is visible.
virtual bool hasNormals() const
Returns whether normals are enabled or not.
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
bool fromFile(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads data from binary stream.
bool toFile(QFile &out, short dataVersion) const override
Saves data to binary stream.
short minimumFileVersion() const override
Returns the minimum file version required to save this instance.
virtual void toIdentity()
Sets matrix to identity.
Float version of ccGLMatrixTpl.
void showNormals(bool state) override
Sets normals visibility.
void importParametersFrom(const ccGenericMesh *mesh)
Imports the parameters from another mesh.
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual const ecvColor::Rgb & getPointColor(unsigned pointIndex) const =0
Returns color corresponding to a given point.
virtual ccGenericPointCloud * clone(ccGenericPointCloud *destCloud=nullptr, bool ignoreChildren=false)=0
Clones this entity.
virtual const CompressedNormType & getPointNormalIndex(unsigned pointIndex) const =0
Returns compressed normal corresponding to a given point.
Generic primitive interface.
void applyTransformationToVertices()
Applies associated transformation to vertices.
bool init(unsigned vertCount, bool vertNormals, unsigned faceCount, unsigned faceNormCount)
Inits internal structures.
virtual bool setDrawingPrecision(unsigned steps)
Sets drawing precision.
virtual void setColor(const ecvColor::Rgb &col)
Sets primitive color (shortcut)
virtual bool updateRepresentation()
Updates internal representation (as a mesh)
ccGenericPrimitive * finishCloneJob(ccGenericPrimitive *primitive) const
Finished 'clone' job (vertices color, etc.)
ccPointCloud * vertices()
Returns vertices.
const ccGLMatrix & getGLTransformationHistory() const override
inherited methods (ccHObject)
virtual void clearDrawings()
const ccGenericPrimitive & operator+=(const ccGenericPrimitive &prim)
Add operator.
unsigned m_drawPrecision
Drawing precision (for primitives that support this feature)
void applyGLTransformation(const ccGLMatrix &trans) override
Inherited from ccGenericMesh.
static const int MIN_DRAWING_PRECISION
Minimum drawing precision.
virtual void hideShowDrawings(CC_DRAW_CONTEXT &context)
ccGenericPrimitive(QString name=QString(), const ccGLMatrix *transMat=nullptr)
Default constructor.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
virtual bool buildUp()=0
Builds primitive.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
ccGLMatrix m_transformation
Associated transformation (applied to vertices)
short minimumFileVersion_MeOnly() const override
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
unsigned getChildrenNumber() const
Returns the number of children.
void removeChild(ccHObject *child)
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
NormsIndexesTableType * getTriNormsTable() const override
Returns per-triangle normals shared array.
void applyGLTransformation(const ccGLMatrix &trans) override
Applies a GL transformation to the entity.
bool normalsShown() const override
Returns whether normals are shown or not.
ccGenericPointCloud * m_associatedCloud
associated cloud (vertices)
void removePerTriangleNormalIndexes()
Removes any per-triangle triplets of normal indexes.
short minimumFileVersion_MeOnly() const override
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
virtual unsigned size() const override
Returns the number of triangles.
void setTriNormsTable(NormsIndexesTableType *triNormsTable, bool autoReleaseOldTable=true)
Sets per-triangle normals array (may be shared)
bool reserve(std::size_t n)
Reserves the memory to store the vertex indexes (3 per triangle)
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
NormsIndexesTableType * m_triNormals
Per-triangle normals.
triangleNormalsIndexesSet * m_triNormalIndexes
Mesh normals indexes (per-triangle)
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.
bool reservePerTriangleNormalIndexes()
Reserves memory to store per-triangle triplets of normal indexes.
void addTriangleNormalIndexes(int i1, int i2, int i3)
Adds a triplet of normal indexes for next triangle.
bool hasTriNormals() const override
Returns whether the mesh has per-triangle normals.
cloudViewer::VerticesIndexes * getTriangleVertIndexes(unsigned triangleIndex) override
Returns the indexes of the vertices of a given triangle.
triangleIndexesContainer * m_triVertIndexes
Triangles' vertices indexes (3 per triangle)
virtual void setLocked(bool state)
Sets the "enabled" property.
virtual QString getName() const
Returns object name.
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
virtual bool isEnabled() const
Returns whether the object is enabled or not.
bool isKindOf(CV_CLASS_ENUM type) const
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void unalloactePoints()
Erases the cloud points.
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
bool reserveTheNormsTable()
Reserves memory to store the compressed normals.
bool reserveTheRGBTable()
Reserves memory to store the RGB colors.
void clear() override
Clears the entity from all its points and features.
void unallocateNorms()
Erases the cloud normals.
bool hasColors() const override
Returns whether colors are enabled or not.
void addRGBColor(const ecvColor::Rgb &C)
Pushes an RGB color on stack.
bool setRGBColor(ColorCompType r, ColorCompType g, ColorCompType b)
Set a unique color for the whole cloud (shortcut)
void addNormIndex(CompressedNormType index)
Pushes a compressed normal vector.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
static bool ReadError()
Sends a custom error message (read error) and returns 'false'.
static bool WriteError()
Sends a custom error message (write error) and returns 'false'.
virtual unsigned size() const =0
Returns the number of points.
virtual const CCVector3 * getPoint(unsigned index) const =0
Returns the ith point.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
unsigned size() const override
constexpr Rgb white(MAX, MAX, MAX)
Triangle described by the indexes of its 3 vertices.