Háló API

From FreeCAD Documentation
Jump to: navigation, search
This page is a translated version of the page Mesh API and the translation is 33% complete.

Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎magyar • ‎italiano • ‎日本語 • ‎română
(November 2018) This information may be incomplete and outdated. For the latest API, see the autogenerated API documentation.


The Mesh objects can be manipulated by adding new facets, deleting facets, importing from an STL file, transforming the mesh and much more. For a complete overview of what can be done see also the Mesh Module documentation. A mesh object cannot be added to an existing document directly. Therefore the document must create an object with a property class that supports meshes. Example:

m = Mesh.Mesh()
... # Manipulate the mesh
d = FreeCAD.activeDocument() # Get a reference to the actie document
f = d.addObject("Mesh::Feature", "Mesh") # Create a mesh feature
f.Mesh = m # Assign the mesh object to the internal property
d.recompute()


Method.png addFacet(Facet)

Description: Adds a facet to the mesh

Returns:

Method.png addFacets(list)

Description: Adds a list of facets to the mesh

Returns:

Method.png addMesh(Mesh)

Description: Combines this mesh with another mesh.

Returns:

Method.png clear( )

Description: Clears the mesh

Returns:

Method.png coarsen( )

Description: Coarsens the mesh

Returns:

Method.png collapseEdge(Edge)

Description: Removes an edge and both facets that share this edge

Returns:

Method.png collapseFacet(Facet)

Description: Removes a facet

Returns:

Method.png collapseFacets(list)

Description: Removes a list of facets

Returns:

Method.png copy( )

Description: Creates a copy of this mesh

Returns: a Mesh object

Method.png countComponents( )

Description: Get the number of topological independent areas

Returns: an integer

Method.png countNonUniformOrientedFacets( )

Description: Get the number of wrong oriented facets

Returns: an integer

Method.png countSegments( )

Description: Get the number of segments which may also be 0

Returns: an integer

Method.png crossSections( )

Description: Get cross-sections of the mesh through several planes

Returns:

Method.png difference(Mesh)

Description: Difference of this and the given mesh object.

Returns:

Method.png fillupHoles( )

Description: Fillup holes

Returns:

Method.png fixDeformations( )

Description: Repair deformed facets

Returns:

Method.png fixDegenerations( )

Description: Remove degenerated facets

Returns:

Method.png fixIndices( )

Description: Repair any invalid indices

Returns:

Method.png fixSelfIntersections( )

Description: Repair self-intersections

Returns:

Method.png flipNormals( )

Description: Flip the mesh normals

Returns:

Method.png foraminate( )

Description: Get a list of facet indices and intersection points

Returns:

Method.png getPlanes( )

Description: Get all planes of the mesh as segment. In the worst case each triangle can be regarded as single plane if none of its neighbors is coplanar.

Returns:

Method.png getSegment(integer)

Description: Get a list of facet indices that describes a segment

Returns:

Method.png getSeparateComponents( )

Description: Returns a list containing the different components (separated areas) of the mesh as separate meshes

Returns: a list

Method.png harmonizeNormals( )

Description: Adjust wrong oriented facets

Returns:

Method.png hasNonManifolds( )

Description: Check if the mesh has non-manifolds

Returns: a boolean

Method.png hasNonUniformOrientedFacets( )

Description: Checks if the mesh has facets with inconsistent orientation

Returns:

Method.png hasSelfIntersections( )

Description: Check if the mesh intersects itself

Returns:

Method.png inner( )

Description: Get the part inside of the intersection

Returns:

Method.png insertVertex(Vertex)

Description: Inserts a vertex into a facet

Returns:

Method.png intersect(Mesh)

Description: Intersection of this and the given mesh object.

Returns:

Method.png isSolid( )

Description: Check if the mesh is a solid

Returns:

Method.png meshFromSegment( )

Description: Create a mesh from segment

Returns:

Method.png nearestFacetOnRay(tuple, tuple)

Description: Get the index and intersection point of the nearest facet to a ray. The first parameter is a tuple of three floats the base point of the ray, the second parameter is ut uple of three floats for the direction. The result is a dictionary with an index and the intersection point or an empty dictionary if there is no intersection.

Returns: a dictionary

Method.png offset(float)

Description: Move the point along their normals

Returns:

Method.png offsetSpecial(float)

Description: Move the point along their normals

Returns:

Method.png optimizeEdges( )

Description: Optimize the edges to get nicer facets

Returns:

Method.png optimizeTopology( )

Description: Optimize the edges to get nicer facets

Returns:

Method.png outer( )

Description: Get the part outside the intersection

Returns:

Method.png printInfo( )

Description: Get detailed information about the mesh

Returns:

Method.png read( )

Description: Read in a mesh object from file.

Returns:

Method.png refine( )

Description: Refine the mesh

Returns:

Method.png removeComponents(integer)

Description: Remove components with less or equal to number of given facets

Returns:

Method.png removeDuplicatedFacets( )

Description: Remove duplicated facets

Returns:

Method.png removeDuplicatedPoints( )

Description: Remove duplicated points

Returns:

Method.png removeFacets(list)

Description: Remove a list of facet indices from the mesh

Returns:

Method.png removeFoldsOnSurface( )

Description: Remove folds on surfaces

Returns:

Method.png removeNonManifolds( )

Description: Remove non-manifolds

Returns:

Method.png rotate( )

Description: Apply a rotation to the mesh

Returns:

Method.png setPoint(int, Vector)

Description: Sets the point at index.

Returns:

Method.png smooth( )

Description: Smooth the mesh

Returns:

Method.png snapVertex( )

Description: Insert a new facet at the border

Returns:

Method.png splitEdge( )

Description: Split edge

Returns:

Method.png splitEdges( )

Description: Split all edges

Returns:

Method.png splitFacet( )

Description: Split facet

Returns:

Method.png swapEdge( )

Description: Swap the common edge with the neighbor

Returns:

Method.png transform( )

Description: Apply a transformation to the mesh

Returns:

Method.png transformToEigen( )

Description: Transform the mesh to its eigenbase

Returns:

Method.png translate(Vector)

Description: Apply a translation to the mesh

Returns:

Method.png unite(Mesh)

Description: Union of this and the given mesh object.

Returns:

Method.png write(string)

Description: Write the mesh object into file.

Returns:

Method.png writeInventor( )

Description: Write the mesh in OpenInventor format to a string.

Returns: a string

Property.png Area

Returns: the area of the mesh object.

Property.png CountFacets

Returns: the number of facets of the mesh object.

Property.png CountPoints

Returns: the number of vertices of the mesh object.

Property.png Facets

Returns: A collection of facets; With this attribute it is possible to get access to the facets of the mesh: for f in mesh.Facets: print f. Facet.Points is a list of coordinate-tupels for the vertices. Facet.PointIndices is a list of indice for the vertices of the facet. WARNING! store Facets in a local variable as it is generated on the fly, each time it is accessed.

Property.png Points

Returns: A collection of the mesh points; With this attribute it is possible to get access to the points of the mesh: for p in mesh.Points: print p.x, p.y, p.z,p.Index.WARNING! store Points in a local variable as it is generated on the fly, each time it is accessed.

Property.png Topology

Returns: the points and face indices as tuple. Topology[0] is a list of all vertices. Each being a tuple of 3 coordinates. Topology[1] is a list of all polygons. Each being a list of vertex indice into Topology[0] WARNING! store Topology in a local variable as it is generated on the fly, each time it is accessed.

Property.png Volume

Returns: the volume of the mesh object.

Property.png BoundBox

Returns: the BoundBox of the object

Property.png Matrix

Returns: the current transformation of the object as matrix

Property.png Placement

Returns: the current transformation of the object as placement