Skip to content

RPolyMeshData

Class in Entity Module
Header: #include <src/entity/RPolyMeshData.h>
Inherits: REntityData

Stores and manages all data that defines the geometry of a polygon mesh entity: a list of vertices and a list of faces, each face referring to three or more vertices by index (indexed mesh with shared vertices).

The faces are stored as one flat list: for every face the number of vertices followed by the vertex indices (0-based), e.g. 3 0 1 2 4 1 5 6 2 for a triangle followed by a quad (the layout of the DXF MESH entity). Optionally, edges can be marked as hidden (see isEdgeHidden): the edge with index k of a face starts at the vertex with index k of that face.

Geometry algorithms (edges, triangulation, reference points, splitting) are implemented by a proxy (see RPolyMeshDataProxy). Without proxy, a mesh holds its data but has no shapes and no reference points.

Scriptable: This class is available in script environments.

Copyable: Objects are cleaned up automatically by the garbage collector of the script engine.

RPolyMeshData()
RPolyMeshData(const QList< RVector > &vertices, const QList< int > &faces)
virtual ~RPolyMeshData()
int addFace(const QList< int > &indices)
Appends a face with the given vertex indices (at least three).
int addQuad(int v1, int v2, int v3, int v4)
int addTriangle(int v1, int v2, int v3)
int addVertex(const RVector &v)
Appends the given vertex.
void append(const RPolyMeshData &other)
Appends the vertices and faces of the given mesh to this mesh.
void clear()
virtual bool cloneOnChange() const
The geometry of a mesh is not accessible as properties, the whole entity is replaced when it changes (see REntityData::cloneOnChange).
int countFaces() const
int countVertices() const
virtual bool flipHorizontal()
virtual bool flipVertical()
virtual RBox getBoundingBox(bool ignoreEmpty=false) const
QList< int > getFace(int index) const
QList< int > getFaces() const
int getFaceVertexCount(int index) const
QList< bool > getHiddenEdges() const
virtual QList< RRefPoint > getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const
virtual QList< QSharedPointer< RShape > > getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false, QList< RObject::Id > *entityIds=NULL) const
QList< RTriangle > getTriangles() const
virtual RS::EntityType getType() const
RVector getVertexAt(int index) const
QList< RVector > getVertices() const
bool hasHiddenEdges() const
bool isEdgeHidden(int faceIndex, int edgeIndex) const
virtual bool isSane() const
bool isTriangleMesh() const
virtual bool isValid() const
virtual bool mirror(const RLine &axis)
virtual bool move(const RVector &offset)
Moves this entity by the given offset.
virtual bool moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
Moves the given reference point to the given target point or does nothing if this entity has no reference point as the given location.
virtual bool rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)
virtual bool scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)
void setEdgeHidden(int faceIndex, int edgeIndex, bool hidden)
void setFaces(const QList< int > &f)
void setHiddenEdges(const QList< bool > &h)
void setVertexAt(int index, const RVector &v)
void setVertices(const QList< RVector > &v)
virtual void setZ(double z)
QList< RPolyMeshData > split(int maxVertices, int maxFaces, int maxFaceVertices=4) const
Splits this mesh into parts with at most the given number of vertices and faces, each face with at most the given number of vertices (see RPolyMeshDataProxy::split).
virtual bool stretch(const RPolyline &area, const RVector &offset)
Stretches the end points of this entity that are inside area by offset.
virtual void to2D()
static RPolyMeshDataProxy * getPolyMeshDataProxy()
static bool hasProxy()
static void setPolyMeshDataProxy(RPolyMeshDataProxy *p)
RPolyMeshData(RDocument *document, const RPolyMeshData &data)
void updateFaceIndex() const
QList< int > faceOffsets
bool faceOffsetsValid
QList< int > faces
QList< bool > hiddenEdges
QList< RVector > vertices
static RPolyMeshDataProxy * polyMeshDataProxy
class RPolyMeshEntity

RPolyMeshData::RPolyMeshData()

RPolyMeshData::RPolyMeshData(const QList< RVector > &vertices, const QList< int > &faces)

virtual RPolyMeshData::~RPolyMeshData()

virtual inline

int RPolyMeshData::addFace(const QList< int > &indices)

Appends a face with the given vertex indices (at least three).

Returns: The index of the new face or -1.

int RPolyMeshData::addQuad(int v1, int v2, int v3, int v4)

int RPolyMeshData::addTriangle(int v1, int v2, int v3)

int RPolyMeshData::addVertex(const RVector &v)

Appends the given vertex.

Returns: The index of the new vertex.

void RPolyMeshData::append(const RPolyMeshData &other)

Appends the vertices and faces of the given mesh to this mesh.

void RPolyMeshData::clear()

virtual bool RPolyMeshData::cloneOnChange() const

virtual inline const

The geometry of a mesh is not accessible as properties, the whole entity is replaced when it changes (see REntityData::cloneOnChange).

Reimplemented from cloneOnChange.

int RPolyMeshData::countFaces() const

const

int RPolyMeshData::countVertices() const

inline const

virtual bool RPolyMeshData::flipHorizontal()

virtual

Reimplemented from flipHorizontal.

virtual bool RPolyMeshData::flipVertical()

virtual

Reimplemented from flipVertical.

virtual RBox RPolyMeshData::getBoundingBox(bool ignoreEmpty=false) const

virtual const

Returns: The bounding box that contains this entity.

Reimplemented from getBoundingBox.

QList< int > RPolyMeshData::getFace(int index) const

const

Returns: The vertex indices of the face with the given index (empty if out of range).

QList< int > RPolyMeshData::getFaces() const

inline const

Returns: The flat face list (vertex count followed by the vertex indices for every face, see class description).

int RPolyMeshData::getFaceVertexCount(int index) const

const

Returns: The number of vertices of the face with the given index (0 if out of range).

QList< bool > RPolyMeshData::getHiddenEdges() const

inline const

Returns: Hidden edge flags, one per entry of the face list (entries of vertex counts unused), empty if no edges are hidden.

virtual QList< RRefPoint > RPolyMeshData::getReferencePoints(RS::ProjectionRenderingHint hint=RS::RenderTop) const

virtual const

Returns: Vector of reference points of this entity. Reference points can usually be moved around by the user to change the geometry of the entity.

Reimplemented from getReferencePoints.

virtual QList< QSharedPointer< RShape > > RPolyMeshData::getShapes(const RBox &queryBox=RDEFAULT_RBOX, bool ignoreComplex=false, bool segment=false, QList< RObject::Id > *entityIds=NULL) const

virtual const

Returns: Shapes that represent the geometry of this entity.

Parameters:

  • queryBox: Limit returned shapes to query box
  • ignoreComplex: Ignore complex shapes and explode those into simple shapes
  • segment: Split up splines into spline segments

Reimplemented from getShapes.

QList< RTriangle > RPolyMeshData::getTriangles() const

const

Returns: The faces of this mesh as triangles (empty without proxy).

virtual RS::EntityType RPolyMeshData::getType() const

virtual inline const

Reimplemented from getType.

RVector RPolyMeshData::getVertexAt(int index) const

const

QList< RVector > RPolyMeshData::getVertices() const

inline const

bool RPolyMeshData::hasHiddenEdges() const

inline const

Returns: True if the mesh has hidden edges.

bool RPolyMeshData::isEdgeHidden(int faceIndex, int edgeIndex) const

const

Returns: True if the given edge of the given face is hidden (edge k of a face starts at vertex k of the face).

virtual bool RPolyMeshData::isSane() const

virtual const

Returns: True if all faces have at least three vertices and refer to existing vertices (false without proxy).

Reimplemented from isSane.

bool RPolyMeshData::isTriangleMesh() const

const

Returns: True if all faces are triangles.

virtual bool RPolyMeshData::isValid() const

virtual inline const

Reimplemented from isValid.

virtual bool RPolyMeshData::mirror(const RLine &axis)

virtual

Reimplemented from mirror.

virtual bool RPolyMeshData::move(const RVector &offset)

virtual

Moves this entity by the given offset.

Reimplemented from move.

virtual bool RPolyMeshData::moveReferencePoint(const RVector &referencePoint, const RVector &targetPoint, Qt::KeyboardModifiers modifiers=Qt::NoModifier)

virtual

Moves the given reference point to the given target point or does nothing if this entity has no reference point as the given location.

Returns: True if a reference point has been moved successfully, false otherwise.

Reimplemented from moveReferencePoint.

virtual bool RPolyMeshData::rotate(double rotation, const RVector &center=RDEFAULT_RVECTOR)

virtual

Reimplemented from rotate.

virtual bool RPolyMeshData::scale(const RVector &scaleFactors, const RVector &center=RDEFAULT_RVECTOR)

virtual

Reimplemented from scale.

void RPolyMeshData::setEdgeHidden(int faceIndex, int edgeIndex, bool hidden)

void RPolyMeshData::setFaces(const QList< int > &f)

void RPolyMeshData::setHiddenEdges(const QList< bool > &h)

void RPolyMeshData::setVertexAt(int index, const RVector &v)

void RPolyMeshData::setVertices(const QList< RVector > &v)

inline

virtual void RPolyMeshData::setZ(double z)

virtual

Reimplemented from setZ.

QList< RPolyMeshData > RPolyMeshData::split(int maxVertices, int maxFaces, int maxFaceVertices=4) const

const

Splits this mesh into parts with at most the given number of vertices and faces, each face with at most the given number of vertices (see RPolyMeshDataProxy::split).

Without proxy, this mesh is returned as one part.

virtual bool RPolyMeshData::stretch(const RPolyline &area, const RVector &offset)

virtual

Stretches the end points of this entity that are inside area by offset.

Reimplemented from stretch.

virtual void RPolyMeshData::to2D()

virtual

Reimplemented from to2D.

static RPolyMeshDataProxy * RPolyMeshData::getPolyMeshDataProxy()

static inline

Non-Scriptable: This function is not available in script environments.

static bool RPolyMeshData::hasProxy()

static inline

static void RPolyMeshData::setPolyMeshDataProxy(RPolyMeshDataProxy *p)

static inline

Non-Scriptable: This function is not available in script environments.

RPolyMeshData::RPolyMeshData(RDocument *document, const RPolyMeshData &data)

protected

void RPolyMeshData::updateFaceIndex() const

const private

QList<int> RPolyMeshData::faceOffsets

private

bool RPolyMeshData::faceOffsetsValid

private

QList<int> RPolyMeshData::faces

private

QList<bool> RPolyMeshData::hiddenEdges

private

QList<RVector> RPolyMeshData::vertices

private

static RPolyMeshDataProxy * RPolyMeshData::polyMeshDataProxy = NULL

static private

All rights reserved.

This file is part of the QCAD project.

QCAD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

QCAD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with QCAD.

friend class RPolyMeshEntity

private