Mesh API/es: Difference between revisions

From FreeCAD Documentation
No edit summary
(Updating to match new version of source page)
Line 1: Line 1:
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:
Los objetos malla pueden ser manipulados añadiendo facetas, eliminando facetas, importando desde un archivo STL, transformando la malla y muchas opciones más. Para una descripción completa de lo que se puede hacer mira también la documentación del [[Mesh Module/es|Módulo de malla]]. Un objeto malla no se puede añadir a un documento existente directamente. Por lo tanto el documento debe crear un objeto con clase apropiada que soporte las mallas. Por ejemplo:


<syntaxhighlight>
m = Mesh.Mesh()
m = Mesh.Mesh()
... # Manipulate the mesh
... # Manipulate the mesh
Line 7: Line 8:
f.Mesh = m # Assign the mesh object to the internal property
f.Mesh = m # Assign the mesh object to the internal property
d.recompute()
d.recompute()
</syntaxhighlight>


{{APIFunction/es|addFacet|Facet|Añade una faceta a la malla| }}
{{APIFunction/es|addFacets|list|Añade una lista de facetas a la malla| }}
{{APIFunction/es|addMesh|Mesh|Combina esta malla con otra malla.| }}
{{APIFunction/es|clear| |Alisa la malla| }}
{{APIFunction/es|coarsen| |Desalisado de malla| }}
{{APIFunction/es|collapseEdge|Edge|Elimina una arista y ambas facetas que compartían esa arista| }}
{{APIFunction/es|collapseFacet|Facet|Elimina una faceta| }}
{{APIFunction/es|collapseFacets|list|Elimina una lista de facetas| }}
{{APIFunction/es|copy| |Crea una copia de esta malla|Un objeto malla}}
{{APIFunction/es|countComponents| |Obtiene el número de áreas topológicamente independientes|Un entero}}
{{APIFunction/es|countNonUniformOrientedFacets| |Obtiene el número de facetas mal orientadas|Un entero}}
{{APIFunction/es|countSegments| |Obtiene el número de segmentos que también podría ser 0|Un entero}}
{{APIFunction/es|crossSections| |Obtiene secciones de cruce de la malla a través de diversos planos| }}
{{APIFunction/es|difference|Mesh|Diferencia de esta y el objeto malla dado.| }}
{{APIFunction/es|fillupHoles| |Rellena agujeros| }}
{{APIFunction/es|fixDeformations| |Repara facetas deformadas| }}
{{APIFunction/es|fixDegenerations| |Elimina facetas degeneradas| }}
{{APIFunction/es|fixIndices| |Repara cualquier índice inválido| }}
{{APIFunction/es|fixSelfIntersections| |Repara auto-intersecciones| }}
{{APIFunction/es|flipNormals| |Invierte las normales de la malla| }}
{{APIFunction/es|foraminate| |Obtiene una lista de índices de facetas y puntos de intersección| }}
{{APIFunction/es|getPlanes| |Obtiene todos los planos de la malla como segmentos. En el peor de los casos cada triángulo se puede considerar un único plano si ninguno de sus vecinos es coplanar.| }}
{{APIFunction/es|getSegment|integer|Obtiene una lista de índices de facetas que describen un segmento| }}
{{APIFunction/es|getSeparateComponents| |Devuelve una lista conteniendo los diferentes componentes (áreas separadas) de la malla como mallas separadas|Una lista}}
{{APIFunction/es|harmonizeNormals| |Ajusta las facetas mal orientadas| }}
{{APIFunction/es|hasNonManifolds| |Comprueba si la malla tiene non-manifolds|Un booleano}}
{{APIFunction/es|hasNonUniformOrientedFacets| |Comprueba si la malla tiene facetas con orientación inconsistente| }}
{{APIFunction/es|hasSelfIntersections| |Comprueba si la malla intersecta consigo misma| }}
{{APIFunction/es|inner| |Obtiene la pieza dentro de la intersección| }}
{{APIFunction/es|insertVertex|Vertex|Inserta un vértice en una faceta| }}
{{APIFunction/es|intersect|Mesh|Intersección de esta y el objeto malla dado.| }}
{{APIFunction/es|isSolid| |Comprueba si la malla es un sólido| }}
{{APIFunction/es|meshFromSegment| |Crea una malla a partir de segmentos| }}
{{APIFunction/es|nearestFacetOnRay|tuple, tuple|Obtiene el índice y punto de intersección de las facetas más cercanas a un rayo. El primer parámetro es una tupla de tres números de coma flotante de un punto base del rayo, el segundo parámetro es una tupla de tres números de coma flotante para la orientación. El resultado es un diccionario con un índice y el punto de intersección o un diccionario vacio si no hay intersección.|Un diccionario}}
{{APIFunction/es|offset|float|Mueve el punto a lo largo de sus normales| }}
{{APIFunction/es|offsetSpecial|float|Mueve el punto a lo largo de su normal| }}
{{APIFunction/es|optimizeEdges| |Optimiza las aristas para conseguir mejores facetas| }}
{{APIFunction/es|optimizeTopology| |Optimiza las aristas para conseguir mejores facetas| }}
{{APIFunction/es|outer| |Obtiene la pieza fuera de la intersección| }}
{{APIFunction/es|printInfo| |Obtiene información detallada de la malla| }}
{{APIFunction/es|read| |Lee un objeto malla desde un archivo.| }}
{{APIFunction/es|refine| |Refina la malla| }}
{{APIFunction/es|removeComponents|integer|Elimina componentes con menos o igual número de facetas dadas| }}
{{APIFunction/es|removeDuplicatedFacets| |Elimina facetas duplicadas| }}
{{APIFunction/es|removeDuplicatedPoints| |Elimina puntos duplicados| }}
{{APIFunction/es|removeFacets|list|Elimina una lista de índices de facetas desde la malla| }}
{{APIFunction/es|removeFoldsOnSurface| |Elimina pliegues en superficies| }}
{{APIFunction/es|removeNonManifolds| |Elimina non-manifolds| }}
{{APIFunction/es|rotate| |Aplica una rotación a la malla| }}
{{APIFunction/es|setPoint|int, Vector|Establece el punto en el índice.| }}
{{APIFunction/es|smooth| |Suaviza la malla| }}
{{APIFunction/es|snapVertex| |Inserta una faceta nueva en el borde| }}
{{APIFunction/es|splitEdge| |Dividir arista| }}
{{APIFunction/es|splitEdges| |Dividir todas las aristas| }}
{{APIFunction/es|splitFacet| |Dividir faceta| }}
{{APIFunction/es|swapEdge| |Cambia la arista común con el vecino| }}
{{APIFunction/es|transform| |Aplica una trasformación a la malla| }}
{{APIFunction/es|transformToEigen| |Transforma la malla en su eigenbase| }}
{{APIFunction/es|translate|Vector|Aplica una translación a la malla| }}
{{APIFunction/es|unite|Mesh|Unión de esta y del objeto malla dado.| }}
{{APIFunction/es|write|string|Escribe el objeto malla en un archivo.| }}
{{APIFunction/es|writeInventor| |Escribe la malla en formato de OpenInventor en una cadena de texto.|Una cadena de texto}}
{{APIProperty/es|Area|El área del objeto malla.}}
{{APIProperty/es|CountFacets|El número de facetas del objeto malla.}}
{{APIProperty/es|CountPoints|El número de vértices del objeto malla.}}
{{APIProperty/es|Facets|Una colección de facetas; Con este atributo es posible tener acceso a las facetas de la malla: for p in mesh.Facets: print p}}
{{APIProperty/es|Points|Una colección de puntos de malla; Con este atributo es posible tener acceso a los puntos de la malla: for p in mesh.Points: print p.x, p.y, p.z}}
{{APIProperty/es|Topology|Los índices de los puntos y caras como tuplas.}}
{{APIProperty/es|Volume|El volumen del objeto malla.}}
{{APIProperty/es|BoundBox|La caja de abarque del objeto}}
{{APIProperty/es|Matrix|La transformación actualdel objeto como matriz}}
{{APIProperty/es|Placement|La transformación actual del objeto como colocación}}


{{APIFunction|addFacet|Facet|Adds a facet to the mesh| }}
{{languages/es | {{en|Mesh_API}} }}
{{APIFunction|addFacets|list|Adds a list of facets to the mesh| }}
{{APIFunction|addMesh|Mesh|Combines this mesh with another mesh.| }}
{{APIFunction|clear| |Clears the mesh| }}
{{APIFunction|coarsen| |Coarsens the mesh| }}
{{APIFunction|collapseEdge|Edge|Removes an edge and both facets that share this edge| }}
{{APIFunction|collapseFacet|Facet|Removes a facet| }}
{{APIFunction|collapseFacets|list|Removes a list of facets| }}
{{APIFunction|copy| |Creates a copy of this mesh|a Mesh object}}
{{APIFunction|countComponents| |Get the number of topological independent areas|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|crossSections| |Get cross-sections of the mesh through several planes| }}
{{APIFunction|difference|Mesh|Difference of this and the given mesh object.| }}
{{APIFunction|fillupHoles| |Fillup holes| }}
{{APIFunction|fixDeformations| |Repair deformed facets| }}
{{APIFunction|fixDegenerations| |Remove degenerated facets| }}
{{APIFunction|fixIndices| |Repair any invalid indices| }}
{{APIFunction|fixSelfIntersections| |Repair self-intersections| }}
{{APIFunction|flipNormals| |Flip the mesh normals| }}
{{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 neighbors is coplanar.| }}
{{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|harmonizeNormals| |Adjust wrong oriented facets| }}
{{APIFunction|hasNonManifolds| |Check if the mesh has non-manifolds|a boolean}}
{{APIFunction|hasNonUniformOrientedFacets| |Checks if the mesh has facets with inconsistent orientation| }}
{{APIFunction|hasSelfIntersections| |Check if the mesh intersects itself| }}
{{APIFunction|inner| |Get the part inside of the intersection| }}
{{APIFunction|insertVertex|Vertex|Inserts a vertex into a facet| }}
{{APIFunction|intersect|Mesh|Intersection of this and the given mesh object.| }}
{{APIFunction|isSolid| |Check if the mesh is a solid| }}
{{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 dictionary}}
{{APIFunction|offset|float|Move the point along their normals| }}
{{APIFunction|offsetSpecial|float|Move the point along their normals| }}
{{APIFunction|optimizeEdges| |Optimize the edges to get nicer facets| }}
{{APIFunction|optimizeTopology| |Optimize the edges to get nicer facets| }}
{{APIFunction|outer| |Get the part outside the intersection| }}
{{APIFunction|printInfo| |Get detailed information about the mesh| }}
{{APIFunction|read| |Read in a mesh object from file.| }}
{{APIFunction|refine| |Refine the mesh| }}
{{APIFunction|removeComponents|integer|Remove components with less or equal to number of given facets| }}
{{APIFunction|removeDuplicatedFacets| |Remove duplicated facets| }}
{{APIFunction|removeDuplicatedPoints| |Remove duplicated points| }}
{{APIFunction|removeFacets|list|Remove a list of facet indices from the mesh| }}
{{APIFunction|removeFoldsOnSurface| |Remove folds on surfaces| }}
{{APIFunction|removeNonManifolds| |Remove non-manifolds| }}
{{APIFunction|rotate| |Apply a rotation to the mesh| }}
{{APIFunction|setPoint|int, Vector|Sets the point at index.| }}
{{APIFunction|smooth| |Smooth the mesh| }}
{{APIFunction|snapVertex| |Insert a new facet at the border| }}
{{APIFunction|splitEdge| |Split edge| }}
{{APIFunction|splitEdges| |Split all edges| }}
{{APIFunction|splitFacet| |Split facet| }}
{{APIFunction|swapEdge| |Swap the common edge with the neighbor| }}
{{APIFunction|transform| |Apply a transformation to the mesh| }}
{{APIFunction|transformToEigen| |Transform the mesh to its eigenbase| }}
{{APIFunction|translate|Vector|Apply a translation to the mesh| }}
{{APIFunction|unite|Mesh|Union of this and the given mesh object.| }}
{{APIFunction|write|string|Write the mesh object into file.| }}
{{APIFunction|writeInventor| |Write the mesh in OpenInventor format to a string.|a string}}
{{APIProperty|Area|the area of the mesh object.}}
{{APIProperty|CountFacets|the number of facets of the mesh object.}}
{{APIProperty|CountPoints|the number of vertices of the mesh object.}}
{{APIProperty|Facets|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}}
{{APIProperty|Points|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}}
{{APIProperty|Topology|the points and face indices as tuple.}}
{{APIProperty|Volume|the volume of the mesh object.}}
{{APIProperty|BoundBox|the BoundBox of the object}}
{{APIProperty|Matrix|the current transformation of the object as matrix}}
{{APIProperty|Placement|the current transformation of the object as placement}}



[[Category:API/es]]
[[Category:API]]

{{clear}}
<languages/>

Revision as of 11:37, 6 December 2014

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