Mesh API: Difference between revisions

From FreeCAD Documentation
mNo edit summary
mNo edit summary
Line 17: Line 17:
{{APIFunction|collapseFacets|list|Removes a list of facets| }}
{{APIFunction|collapseFacets|list|Removes a list of facets| }}
{{APIFunction|copy| |Creates a copy of this mesh|a Mesh object}}
{{APIFunction|copy| |Creates a copy of this mesh|a Mesh object}}
{{APIFunction|countComponents| |Get the number of topologic independent areas|an integer}}
{{APIFunction|countComponents| |Get the number of topological independent areas|an integer}}
{{APIFunction|countNonUniformOrientedFacets| |Get the number of wrong oriented facets|an integer}}
{{APIFunction|countNonUniformOrientedFacets| |Get the number of wrong oriented facets|an integer}}
{{APIFunction|countSegments| |Get the number of segments which may also be 0|an integer}}
{{APIFunction|countSegments| |Get the number of segments which may also be 0|an integer}}
Line 29: Line 29:
{{APIFunction|flipNormals| |Flip the mesh normals| }}
{{APIFunction|flipNormals| |Flip the mesh normals| }}
{{APIFunction|foraminate| |Get a list of facet indices and intersection points| }}
{{APIFunction|foraminate| |Get a list of facet indices and intersection points| }}
{{APIFunction|getPlanes| |Get all planes of the mesh as segment. In the worst case each triangle can be regarded as single plane if none of its neighours is coplanar.| }}
{{APIFunction|getPlanes| |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.| }}
{{APIFunction|getSegment|integer|Get a list of facet indices that describes a segment| }}
{{APIFunction|getSegment|integer|Get a list of facet indices that describes a segment| }}
{{APIFunction|getSeparateComponents| |Returns a list containing the different components (separated areas) of the mesh as separate meshes|a list}}
{{APIFunction|getSeparateComponents| |Returns a list containing the different components (separated areas) of the mesh as separate meshes|a list}}
Line 41: Line 41:
{{APIFunction|isSolid| |Check if the mesh is a solid| }}
{{APIFunction|isSolid| |Check if the mesh is a solid| }}
{{APIFunction|meshFromSegment| |Create a mesh from segment| }}
{{APIFunction|meshFromSegment| |Create a mesh from segment| }}
{{APIFunction|nearestFacetOnRay|tuple, tuple|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.|a dictionnary}}
{{APIFunction|nearestFacetOnRay|tuple, tuple|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.|a dictionary}}
{{APIFunction|offset|float|Move the point along their normals| }}
{{APIFunction|offset|float|Move the point along their normals| }}
{{APIFunction|offsetSpecial|float|Move the point along their normals| }}
{{APIFunction|offsetSpecial|float|Move the point along their normals| }}
Line 63: Line 63:
{{APIFunction|splitEdges| |Split all edges| }}
{{APIFunction|splitEdges| |Split all edges| }}
{{APIFunction|splitFacet| |Split facet| }}
{{APIFunction|splitFacet| |Split facet| }}
{{APIFunction|swapEdge| |Swap the common edge with the neighbour| }}
{{APIFunction|swapEdge| |Swap the common edge with the neighbor| }}
{{APIFunction|transform| |Apply a transformation to the mesh| }}
{{APIFunction|transform| |Apply a transformation to the mesh| }}
{{APIFunction|transformToEigen| |Transform the mesh to its eigenbase| }}
{{APIFunction|transformToEigen| |Transform the mesh to its eigenbase| }}

Revision as of 06:55, 14 January 2013

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()
addFacet(Facet)

Description: Adds a facet to the mesh

Returns:

addFacets(list)

Description: Adds a list of facets to the mesh

Returns:

addMesh(Mesh)

Description: Combines this mesh with another mesh.

Returns:

clear( )

Description: Clears the mesh

Returns:

coarsen( )

Description: Coarsens the mesh

Returns:

collapseEdge(Edge)

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

Returns:

collapseFacet(Facet)

Description: Removes a facet

Returns:

collapseFacets(list)

Description: Removes a list of facets

Returns:

copy( )

Description: Creates a copy of this mesh

Returns: a Mesh object

countComponents( )

Description: Get the number of topological independent areas

Returns: an integer

countNonUniformOrientedFacets( )

Description: Get the number of wrong oriented facets

Returns: an integer

countSegments( )

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

Returns: an integer

crossSections( )

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

Returns:

difference(Mesh)

Description: Difference of this and the given mesh object.

Returns:

fillupHoles( )

Description: Fillup holes

Returns:

fixDeformations( )

Description: Repair deformed facets

Returns:

fixDegenerations( )

Description: Remove degenerated facets

Returns:

fixIndices( )

Description: Repair any invalid indices

Returns:

fixSelfIntersections( )

Description: Repair self-intersections

Returns:

flipNormals( )

Description: Flip the mesh normals

Returns:

foraminate( )

Description: Get a list of facet indices and intersection points

Returns:

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:

getSegment(integer)

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

Returns:

getSeparateComponents( )

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

Returns: a list

harmonizeNormals( )

Description: Adjust wrong oriented facets

Returns:

hasNonManifolds( )

Description: Check if the mesh has non-manifolds

Returns: a boolean

hasNonUniformOrientedFacets( )

Description: Checks if the mesh has facets with inconsistent orientation

Returns:

hasSelfIntersections( )

Description: Check if the mesh intersects itself

Returns:

inner( )

Description: Get the part inside of the intersection

Returns:

insertVertex(Vertex)

Description: Inserts a vertex into a facet

Returns:

intersect(Mesh)

Description: Intersection of this and the given mesh object.

Returns:

isSolid( )

Description: Check if the mesh is a solid

Returns:

meshFromSegment( )

Description: Create a mesh from segment

Returns:

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

offset(float)

Description: Move the point along their normals

Returns:

offsetSpecial(float)

Description: Move the point along their normals

Returns:

optimizeEdges( )

Description: Optimize the edges to get nicer facets

Returns:

optimizeTopology( )

Description: Optimize the edges to get nicer facets

Returns:

outer( )

Description: Get the part outside the intersection

Returns:

printInfo( )

Description: Get detailed information about the mesh

Returns:

read( )

Description: Read in a mesh object from file.

Returns:

refine( )

Description: Refine the mesh

Returns:

removeComponents(integer)

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

Returns:

removeDuplicatedFacets( )

Description: Remove duplicated facets

Returns:

removeDuplicatedPoints( )

Description: Remove duplicated points

Returns:

removeFacets(list)

Description: Remove a list of facet indices from the mesh

Returns:

removeFoldsOnSurface( )

Description: Remove folds on surfaces

Returns:

removeNonManifolds( )

Description: Remove non-manifolds

Returns:

rotate( )

Description: Apply a rotation to the mesh

Returns:

setPoint(int, Vector)

Description: Sets the point at index.

Returns:

smooth( )

Description: Smooth the mesh

Returns:

snapVertex( )

Description: Insert a new facet at the border

Returns:

splitEdge( )

Description: Split edge

Returns:

splitEdges( )

Description: Split all edges

Returns:

splitFacet( )

Description: Split facet

Returns:

swapEdge( )

Description: Swap the common edge with the neighbor

Returns:

transform( )

Description: Apply a transformation to the mesh

Returns:

transformToEigen( )

Description: Transform the mesh to its eigenbase

Returns:

translate(Vector)

Description: Apply a translation to the mesh

Returns:

unite(Mesh)

Description: Union of this and the given mesh object.

Returns:

write(string)

Description: Write the mesh object into file.

Returns:

writeInventor( )

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

Returns: a string

Area

Returns: the area of the mesh object.

CountFacets

Returns: the number of facets of the mesh object.

CountPoints

Returns: the number of vertices of the mesh object.

Facets

Returns: A collection of facets; With this attribute it is possible to get access to the facets of the mesh: for p in mesh.Facets: print p

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

Topology

Returns: the points and face indices as tuple.

Volume

Returns: the volume of the mesh object.

BoundBox

Returns: the BoundBox of the object

Matrix

Returns: the current transformation of the object as matrix

Placement

Returns: the current transformation of the object as placement

Available translations of this page: