OCC: interface to open-cascade

Preamble

OCC performs reading of IGES or STEP files with open-cascade. It returns a triangular mesh.

To use the module with the Converter.array interface:

import OCC

To use the module with the CGNS/Python interface:

import OCC.PyTree as OCC

List of functions

– CAD/surface mesh conversion

OCC.convertCAD2Arrays

Convert a CAD (IGES or STEP) file to arrays.

OCC.PyTree.convertCAD2PyTree

Convert a CAD (IGES or STEP) file to pyTree.

Contents

CAD/mesh conversion

OCC.convertCAD2Arrays(fileName, format='fmt_iges', h=0., chordal_err=0., growth_ratio=0., algo=1)

Read a CAD and return arrays.

Parameters:
  • fileName (string) – CAD file name

  • format (string) – file format (‘fmt_iges’ or ‘fmt_step’)

  • h (float) – step size on output mesh. If 0., automatic setting [algo=1,2].

  • chordal_error (float) – max error between CAD and mesh. Result in curvature adaptation. If 0., automatic setting.

  • growth_ratio (float) – max growth ratio between adjacent triangles [algo=1,2].

  • algo (int) – algo=0: mesh with only respect to curvature, algo=1 or algo=2: mesh with regular triangles.

Return type:

a list of TRI arrays

Example of use:

# - convertCAD2Arrays (arrays) -
import Converter as C
import OCC

# IGES avec T3Mesher
A = OCC.convertCAD2Arrays('hammer.iges', format='fmt_iges',
                          h=0., chordal_err=0., growth_ratio=0.8, algo=1)
C.convertArrays2File(A, 'hammer1.plt')

# IGES avec OCC
A = OCC.convertCAD2Arrays('hammer.iges', format='fmt_iges',
                          chordal_err=1, algo=0)
C.convertArrays2File(A, 'hammer2.plt')

# STEP avec T3Mesher
A = OCC.convertCAD2Arrays('as1-oc-214.stp', format='fmt_step',
                          h=0., chordal_err=0., growth_ratio=0.8, algo=1)
C.convertArrays2File(A, 'as1.plt')

# STEP avec OCC
A = OCC.convertCAD2Arrays('as1-oc-214.stp', format='fmt_step',
                          chordal_err=1, algo=0)
C.convertArrays2File(A, 'as2.plt')

OCC.PyTree.convertCAD2PyTree(fileName, format='fmt_iges', h=0., chordal_err=0., growth_ratio=0., algo=1)

Read a CAD and return a zone.

Parameters:
  • fileName (string) – CAD file name

  • format (string) – file format (‘fmt_iges’ or ‘fmt_step’)

  • h (float) – step size on output mesh. If 0., automatic setting [algo=1,2].

  • chordal_error (float) – max error between CAD and mesh. Result in curvature adaptation. If 0., automatic setting.

  • growth_ratio (float) – max growth ratio between adjacent triangles [algo=1,2].

  • algo (int) – algo=0: mesh with only respect to curvature, algo=1 or algo=2: mesh with regular triangles.

Return type:

CGNS pyTree

Example of use:

# - convertIGES2PyTree (PyTree) -
import OCC.PyTree as OCC
import Converter.PyTree as C

t = OCC.convertCAD2PyTree('hammer.iges', h=0., chordal_err=0., algo=1)
C.convertPyTree2File(t, 'out.cgns')