FreeCAD C++
Public Member Functions | List of all members
Mesh::MeshObject Class Reference

#include <Mod/Mesh/App/Mesh.h>

Detailed Description

The MeshObject class provides an interface for the underlying MeshKernel class and most of its algorithm on it.

Note
Each instance of MeshObject has its own instance of a MeshKernel so it's not possible that several instances of MeshObject manage one instance of MeshKernel.

Public Member Functions

void swap (MeshCore::MeshKernel &Kernel)
 
Subelement management
virtual std::vector< const char * > getElementTypes (void) const
 
virtual unsigned long countSubElements (const char *Type) const
 
virtual Data::SegmentgetSubElement (const char *Type, unsigned long) const
 get the subelement by type and number
 
virtual void getFacesFromSubelement (const Data::Segment *, std::vector< Base::Vector3d > &Points, std::vector< Base::Vector3d > &PointNormals, std::vector< Facet > &faces) const
 
Querying
std::string representation () const
 
std::string topologyInfo () const
 
unsigned long countPoints () const
 
unsigned long countFacets () const
 
unsigned long countEdges () const
 
unsigned long countSegments () const
 
bool isSolid () const
 
MeshPoint getPoint (unsigned long) const
 
Mesh::Facet getFacet (unsigned long) const
 
double getSurface () const
 
double getVolume () const
 
virtual void getPoints (std::vector< Base::Vector3d > &Points, std::vector< Base::Vector3d > &Normals, float Accuracy, uint16_t flags=0) const
 
virtual void getFaces (std::vector< Base::Vector3d > &Points, std::vector< Facet > &Topo, float Accuracy, uint16_t flags=0) const
 
std::vector< unsigned long > getPointsFromFacets (const std::vector< unsigned long > &facets) const
 
I/O
unsigned int getMemSize (void) const
 
void Save (Base::Writer &writer) const
 
void SaveDocFile (Base::Writer &writer) const
 
void Restore (Base::XMLReader &reader)
 
void RestoreDocFile (Base::Reader &reader)
 
void save (const char *file, MeshCore::MeshIO::Format f=MeshCore::MeshIO::Undefined, const MeshCore::Material *mat=0, const char *objectname=0) const
 
void save (std::ostream &, MeshCore::MeshIO::Format f, const MeshCore::Material *mat=0, const char *objectname=0) const
 
bool load (const char *file, MeshCore::Material *mat=0)
 
bool load (std::istream &, MeshCore::MeshIO::Format f, MeshCore::Material *mat=0)
 
void save (std::ostream &) const
 
void load (std::istream &)
 
Manipulation
void addFacet (const MeshCore::MeshGeomFacet &facet)
 
void addFacets (const std::vector< MeshCore::MeshGeomFacet > &facets)
 
void addFacets (const std::vector< MeshCore::MeshFacet > &facets, bool checkManifolds)
 
void addFacets (const std::vector< MeshCore::MeshFacet > &facets, const std::vector< Base::Vector3f > &points, bool checkManifolds)
 
void addFacets (const std::vector< Data::ComplexGeoData::Facet > &facets, const std::vector< Base::Vector3d > &points, bool checkManifolds)
 
void setFacets (const std::vector< MeshCore::MeshGeomFacet > &facets)
 
void setFacets (const std::vector< Data::ComplexGeoData::Facet > &facets, const std::vector< Base::Vector3d > &points)
 
void addMesh (const MeshObject &)
 
void addMesh (const MeshCore::MeshKernel &)
 
void deleteFacets (const std::vector< unsigned long > &removeIndices)
 
void deletePoints (const std::vector< unsigned long > &removeIndices)
 
std::vector< std::vector< unsigned long > > getComponents () const
 
unsigned long countComponents () const
 
void removeComponents (unsigned long)
 
unsigned long getPointDegree (const std::vector< unsigned long > &facets, std::vector< unsigned long > &point_degree) const
 
void fillupHoles (unsigned long, int, MeshCore::AbstractPolygonTriangulator &)
 
void offset (float fSize)
 
void offsetSpecial2 (float fSize)
 
void offsetSpecial (float fSize, float zmax, float zmin)
 
void clear (void)
 clears the Mesh
 
void transformToEigenSystem ()
 
Base::Matrix4D getEigenSystem (Base::Vector3d &v) const
 
void movePoint (unsigned long, const Base::Vector3d &v)
 
void setPoint (unsigned long, const Base::Vector3d &v)
 
void smooth (int iterations, float d_max)
 
void decimate (float fTolerance, float fReduction)
 
Base::Vector3d getPointNormal (unsigned long) const
 
std::vector< Base::Vector3dgetPointNormals () const
 
void crossSections (const std::vector< TPlane > &, std::vector< TPolylines > &sections, float fMinEps=1.0e-2f, bool bConnectPolygons=false) const
 
void cut (const Base::Polygon2d &polygon, const Base::ViewProjMethod &proj, CutType)
 
void trim (const Base::Polygon2d &polygon, const Base::ViewProjMethod &proj, CutType)
 
Selection
void deleteSelectedFacets ()
 
void deleteSelectedPoints ()
 
void addFacetsToSelection (const std::vector< unsigned long > &) const
 
void addPointsToSelection (const std::vector< unsigned long > &) const
 
void removeFacetsFromSelection (const std::vector< unsigned long > &) const
 
void removePointsFromSelection (const std::vector< unsigned long > &) const
 
unsigned long countSelectedFacets () const
 
bool hasSelectedFacets () const
 
unsigned long countSelectedPoints () const
 
bool hasSelectedPoints () const
 
void getFacetsFromSelection (std::vector< unsigned long > &) const
 
void getPointsFromSelection (std::vector< unsigned long > &) const
 
void clearFacetSelection () const
 
void clearPointSelection () const
 
Boolean operations
MeshObjectunite (const MeshObject &) const
 
MeshObjectintersect (const MeshObject &) const
 
MeshObjectsubtract (const MeshObject &) const
 
MeshObjectinner (const MeshObject &) const
 
MeshObjectouter (const MeshObject &) const
 
Topological operations
void refine ()
 
void removeNeedles (float)
 
void optimizeTopology (float)
 
void optimizeEdges ()
 
void splitEdges ()
 
void splitEdge (unsigned long, unsigned long, const Base::Vector3f &)
 
void splitFacet (unsigned long, const Base::Vector3f &, const Base::Vector3f &)
 
void swapEdge (unsigned long, unsigned long)
 
void collapseEdge (unsigned long, unsigned long)
 
void collapseFacet (unsigned long)
 
void collapseFacets (const std::vector< unsigned long > &)
 
void insertVertex (unsigned long, const Base::Vector3f &v)
 
void snapVertex (unsigned long, const Base::Vector3f &v)
 
Mesh validation
unsigned long countNonUniformOrientedFacets () const
 
void flipNormals ()
 
void harmonizeNormals ()
 
void validateIndices ()
 
void validateCaps (float fMaxAngle, float fSplitFactor)
 
void validateDeformations (float fMaxAngle, float fEps)
 
void validateDegenerations (float fEps)
 
void removeDuplicatedPoints ()
 
void removeDuplicatedFacets ()
 
bool hasNonManifolds () const
 
void removeNonManifolds ()
 
void removeNonManifoldPoints ()
 
bool hasSelfIntersections () const
 
void removeSelfIntersections ()
 
void removeSelfIntersections (const std::vector< unsigned long > &)
 
void removeFoldsOnSurface ()
 
void removeFullBoundaryFacets ()
 
bool hasInvalidPoints () const
 
void removeInvalidPoints ()
 
void mergeFacets ()
 
Mesh segments
void addSegment (const Segment &)
 
void addSegment (const std::vector< unsigned long > &)
 
const Segment & getSegment (unsigned long) const
 
Segment & getSegment (unsigned long)
 
MeshObjectmeshFromSegment (const std::vector< unsigned long > &) const
 
std::vector< Segment > getSegmentsOfType (GeometryType, float dev, unsigned long minFacets) const
 
- Public Member Functions inherited from Data::ComplexGeoData
 ComplexGeoData (void)
 Constructor.
 
virtual ~ComplexGeoData ()
 Destructor.
 
virtual SegmentgetSubElementByName (const char *Name) const
 get subelement by combined name
 
virtual void getLinesFromSubelement (const Segment *, std::vector< Base::Vector3d > &Points, std::vector< Line > &lines) const
 
void applyTransform (const Base::Matrix4D &rclTrf)
 
void applyTranslation (const Base::Vector3d &)
 
void applyRotation (const Base::Rotation &)
 
void setPlacement (const Base::Placement &rclPlacement)
 
Base::Placement getPlacement () const
 
virtual Base::Vector3d getPointFromLineIntersection (const Base::Vector3f &base, const Base::Vector3f &dir) const
 
virtual void getLines (std::vector< Base::Vector3d > &Points, std::vector< Line > &lines, float Accuracy, uint16_t flags=0) const
 
virtual bool getCenterOfGravity (Base::Vector3d &center) const
 
- Public Member Functions inherited from Base::BaseClass
 BaseClass ()
 Construction.
 
virtual ~BaseClass ()
 Destruction.
 

Static Public Member Functions

Primitives
static MeshObjectcreateMeshFromList (Py::List &list)
 
static MeshObjectcreateSphere (float, int)
 
static MeshObjectcreateEllipsoid (float, float, int)
 
static MeshObjectcreateCylinder (float, float, int, float, int)
 
static MeshObjectcreateCone (float, float, float, int, float, int)
 
static MeshObjectcreateTorus (float, float, int)
 
static MeshObjectcreateCube (float, float, float)
 
static MeshObjectcreateCube (float, float, float, float)
 
- Static Public Member Functions inherited from Base::Persistence
static std::string encodeAttribute (const std::string &)
 Encodes an attribute upon saving.
 

Iterator

typedef std::vector< Segment >::const_iterator const_segment_iterator
 
const_point_iterator points_begin () const
 
const_point_iterator points_end () const
 
const_facet_iterator facets_begin () const
 
const_facet_iterator facets_end () const
 
const_segment_iterator segments_begin () const
 
const_segment_iterator segments_end () const
 

Additional Inherited Members

- Protected Member Functions inherited from Data::ComplexGeoData
Base::Vector3d transformToOutside (const Base::Vector3f &vec) const
 from local to outside
 
Base::Vector3f transformToInside (const Base::Vector3d &vec) const
 from local to inside
 

Member Function Documentation

◆ addMesh() [1/2]

void Mesh::MeshObject::addMesh ( const MeshObject )

Combines two independent mesh objects.

Note
The mesh object we want to add must not overlap or intersect with this mesh object.

◆ addMesh() [2/2]

void Mesh::MeshObject::addMesh ( const MeshCore::MeshKernel )

Combines two independent mesh objects.

Note
The mesh object we want to add must not overlap or intersect with this mesh object.

◆ getElementTypes()

virtual std::vector<const char*> Mesh::MeshObject::getElementTypes ( void  ) const
virtual

Sub type list List of different subelement types its NOT a list of the subelements itself

Implements Data::ComplexGeoData.

◆ getFacesFromSubelement()

virtual void Mesh::MeshObject::getFacesFromSubelement ( const Data::Segment ,
std::vector< Base::Vector3d > &  Points,
std::vector< Base::Vector3d > &  PointNormals,
std::vector< Facet > &  faces 
) const
virtual

Get faces from segment

Reimplemented from Data::ComplexGeoData.

◆ getPointDegree()

unsigned long Mesh::MeshObject::getPointDegree ( const std::vector< unsigned long > &  facets,
std::vector< unsigned long > &  point_degree 
) const

Checks for the given facet indices what will be the degree for each point when these facets are removed from the mesh kernel. The point degree information is stored in point_degree. The return value gives the number of points which will have a degree of zero.

◆ getPoints()

virtual void Mesh::MeshObject::getPoints ( std::vector< Base::Vector3d > &  Points,
std::vector< Base::Vector3d > &  Normals,
float  Accuracy,
uint16_t  flags = 0 
) const
virtual

Get points from object with given accuracy

Reimplemented from Data::ComplexGeoData.

◆ swap()

void Mesh::MeshObject::swap ( MeshCore::MeshKernel Kernel)

Swaps the content of Kernel and the internal mesh kernel.