38 if (!
init(4,
false, 2, 1)) {
114 "[ccPlane::Fit] Not enough points in input cloud to fit a "
124 CVLog::Warning(
"[ccPlane::Fit] Not enough points to fit a plane!");
141 for (
unsigned k = 0; k <
count; ++k) {
150 else if (maxXY.
x < P2D.
x)
154 else if (maxXY.
y < P2D.
y)
164 CCVector3 Gt = *G + *
X * (minXY.x + dX / 2) + Y * (minXY.y + dY / 2);
173 plane->
setMetaData(QString(
"RMS"), QVariant(*rms));
180 assert(out.isOpen() && (out.openMode() & QIODevice::WriteOnly));
181 if (dataVersion < 21) {
189 QDataStream outStream(&out);
197 return std::max(
static_cast<short>(21),
210 QDataStream inStream(&in);
229 QString imageFilename ) {
230 if (!quadMesh || quadMesh->
size() > 2
237 if (
image.isNull()) {
238 CVLog::Warning(
"[ccPlane::SetQuadTexture] Invalid texture image!");
258 texCoords->emplace_back(TA);
259 texCoords->emplace_back(TB);
260 texCoords->emplace_back(TC);
261 texCoords->emplace_back(
TD);
302 materialSet->clear();
306 material->setTexture(
image, imageFilename,
false);
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
float PointCoordinateType
Type of the coordinates of a (N-D) point.
std::shared_ptr< core::Tensor > image
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 2D texture coordinates.
Type dot(const Vector3Tpl &v) const
Dot product.
bool reserveSafe(size_t count)
Reserves memory (no exception thrown)
void addElement(const Type &value)
Vector3Tpl< T > getTranslationAsVec3D() const
Returns a copy of the translation as a CCVector3.
void applyRotation(Vector3Tpl< float > &vec) const
Applies rotation only to a 3D vector (in place) - float version.
void initFromParameters(T alpha_rad, const Vector3Tpl< T > &axis3D, const Vector3Tpl< T > &t3D)
Inits transformation from a rotation axis, an angle and a translation.
Float version of ccGLMatrixTpl.
virtual void showMaterials(bool state)
Sets whether textures should be displayed or not.
Generic primitive interface.
bool init(unsigned vertCount, bool vertNormals, unsigned faceCount, unsigned faceNormCount)
Inits internal structures.
virtual bool updateRepresentation()
Updates internal representation (as a mesh)
ccGenericPrimitive * finishCloneJob(ccGenericPrimitive *primitive) const
Finished 'clone' job (vertices color, etc.)
ccPointCloud * vertices()
Returns vertices.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
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
Mesh (triangle) material.
int addMaterial(ccMaterial::CShared mat, bool allowDuplicateNames=false)
Adds a material.
Mesh (triangle) material.
QSharedPointer< ccMaterial > Shared
Shared type.
const ccMaterialSet * getMaterialSet() const override
TextureCoordsContainer * getTexCoordinatesTable() const override
Returns per-triangle texture coordinates array.
void drawMeOnly(CC_DRAW_CONTEXT &context) override
Enables (OpenGL) stipple mask.
bool reservePerTriangleMtlIndexes()
Reserves memory to store per-triangle material index.
virtual unsigned size() const override
Returns the number of triangles.
void addTriangleMtlIndex(int mtlIndex)
Adds triangle material index for next triangle.
void setMaterialSet(ccMaterialSet *materialSet, bool autoReleaseOldMaterialSet=true)
Sets associated material set (may be shared)
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
void addTriangleTexCoordIndexes(int i1, int i2, int i3)
Adds a triplet of tex coords indexes for next triangle.
NormsIndexesTableType * m_triNormals
Per-triangle normals.
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.
void removePerTriangleTexCoordIndexes()
Remove per-triangle tex coords indexes.
bool hasPerTriangleTexCoordIndexes() const override
Returns whether this mesh as per-triangle triplets of tex coords indexes.
void setTexCoordinatesTable(TextureCoordsContainer *texCoordsTable, bool autoReleaseOldTable=true)
Sets per-triangle texture coordinates array (may be shared)
void addTriangleNormalIndexes(int i1, int i2, int i3)
Adds a triplet of normal indexes for next triangle.
bool reservePerTriangleTexCoordIndexes()
Reserves memory to store per-triangle triplets of tex coords indexes.
void removePerTriangleMtlIndexes()
Removes any per-triangle material indexes.
bool hasPerTriangleMtlIndexes() const
Returns whether this mesh as per-triangle material index.
static CompressedNormType GetNormIndex(const PointCoordinateType N[])
Returns the compressed index corresponding to a normal vector.
virtual QString getName() const
Returns object name.
void setMetaData(const QString &key, const QVariant &data)
Sets a meta-data element.
Interface for a planar entity.
void glDrawNormal(CC_DRAW_CONTEXT &context, const CCVector3 &pos, float scale, const ecvColor::Rgb *color=0)
Draws a normal vector (OpenGL)
PointCoordinateType m_PlaneEquation[4]
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Enables (OpenGL) stipple mask.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
PointCoordinateType m_yWidth
Width along 'Y' dimension.
CCVector3 getCenter() const
Returns the center.
CCVector3 getNormal() const override
Returns the entity normal.
virtual bool buildUp() override
Builds primitive.
virtual ccGenericPrimitive * clone() const override
Clones primitive.
const PointCoordinateType * getEquation()
Returns the equation of the plane.
ccPlane(PointCoordinateType xWidth, PointCoordinateType yWidth, const ccGLMatrix *transMat=nullptr, QString name=QString("Plane"))
Default constructor.
void flip()
Flips the plane.
static ccPlane * Fit(cloudViewer::GenericIndexedCloudPersist *cloud, double *rms=0)
Fits a plane primitive on a cloud.
bool setAsTexture(QImage image, QString imageFilename=QString())
Sets an image as texture.
static bool SetQuadTexture(ccMesh *quadMesh, QImage image, QString imageFilename=QString())
Sets an image as texture for a quad mesh.
PointCoordinateType m_xWidth
Width along 'X' dimension.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
short minimumFileVersion_MeOnly() const override
virtual ccBBox getOwnFitBB(ccGLMatrix &trans) override
Returns best-fit bounding-box (if available)
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)
static void CoordsFromDataStream(QDataStream &stream, int flags, PointCoordinateType *out, unsigned count=1)
virtual void placeIteratorAtBeginning()=0
Sets the cloud iterator at the beginning.
virtual const CCVector3 * getNextPoint()=0
Returns the next point (relatively to the global iterator position)
virtual unsigned size() const =0
Returns the number of points.
A generic 3D point cloud with index-based and presistent access to points.
const PointCoordinateType * getLSPlane()
Returns best interpolating plane equation (Least-square)
const CCVector3 * getGravityCenter()
Returns gravity center.
const CCVector3 * getLSPlaneX()
Returns best interpolating plane (Least-square) 'X' base vector.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
#define MACRO_Draw3D(context)
bool LessThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).