OFF (.off, .coff)
Background & Context
-
- OFF 3D geometry format.
- Used for storing and exchanging 3D models.
- OFF is an acronym for Object File Format.
- Occasionally called COFF if color information is present.
- Related to NOFF and CNOFF.
- ASCII or binary format.
- Represents a single 2D or 3D object.
- Stores a collection of planar polygons with possibly shared vertices.
- Supports polygon and vertex colors and opacity specifications.
Import & Export
- Import["file.off"] imports an OFF file as a MeshRegion object representing the surface.
- Import["file.off",elem] imports the specified element from an OFF file.
- The import format can be specified with Import["file","OFF"] or Import["file",{"OFF",elem,…}].
- Export["file.off",expr] exports a 3D mesh-based geometric region to a binary OFF file. The expr can be any region that is ConstantRegionQ or a Graphics or Graphics3D object.
- Export["file.off",expr,{opt1->val1,…}] exports expr with the specified options for the file format.
- The export format can be specified with Export["file",expr,"OFF"] or Export["file",expr,{"OFF",opt1->val1,…}].
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data format representation elements:
-
"BinaryFormat" whether the file is a binary or ASCII OFF "VertexData" list of vertex coordinates "PolygonData" the polygon elements in indexed form "VertexColors" colors associated with each vertex "PolygonColors" face color information for each polygon - Geometry representation elements:
-
"BoundaryMeshRegion" boundary mesh representation of the solid "MeshRegion" mesh representation of the surface - Graphics representation elements:
-
"Graphics" 2D OFF file represented as a Graphics object "Graphics3D" 3D geometry represented as a Graphics3D object "GraphicsComplex" OFF file as a GraphicsComplex object "PolygonObjects" list of Polygon primitives given in absolute coordinates
Examples
open all close allBasic Examples (2)
Import a 3D model from OFF as a MeshRegion object:
Import[ "ExampleData/seashell.off"]Summary properties of the model:
Import["ExampleData/seashell.off", "Summary"]Export a 3D model to an OFF file:
Export["model.off", [image], "BinaryFormat" -> False]Print the raw textual contents of the file:
FilePrint[%]Scope (13)
Import (7)
Import works on an ASCII OFF file:
Import["ExampleData/seashell.off"]Import["ExampleData/spikey.off"]Import["http://exampledata.wolfram.com/vase.off"]str = OpenRead["ExampleData/chain.off"]Import[str]Close[str]Import automatically detects OFF files:
Import["http://exampledata.wolfram.com/gear.4"]Import provides access to elements in the OFF file:
Import["ExampleData/seashell.off", "Elements"]Import works on large files:
Import["http://exampledata.wolfram.com/turtle.off"] // MeshCellCount//AbsoluteTimingExport (6)
Export works on 3D graphics:
Export["model.off", [image]]Export["sphere.off", Sphere[]]Export["ball.off", ImplicitRegion[x ^ 2 + y ^ 2 + z ^ 2 ≤ 1, {x, y, z}]]Export["pyramid.off", MeshRegion[{{-1, -1, 0}, {1, -1, 0}, {1, 1, 0}, {-1, 1, 0}, {0, 0, 1}}, Pyramid[{1, 2, 3, 4, 5}]]]Export["model.off", [image]]Export["model.off", [image], "BinaryFormat" -> False]Import Elements (11)
"BinaryFormat" (1)
"BoundaryMeshRegion" (1)
"CoordinateTransform" (1)
"Graphics3D" (1)
Give the Graphics3D object:
Import["ExampleData/chain.off", "Graphics3D"]"GraphicsComplex" (1)
Give the GraphicsComplex object:
Import["ExampleData/chain.off", "GraphicsComplex"]"MeshRegion" (1)
"PolygonColors" (1)
"PolygonData" (1)
"PolygonObjects" (1)
Give the list of Polygon primitives given in absolute coordinates:
Import["ExampleData/chain.off", "PolygonObjects"]"Summary" (1)
Export Options (2)
By default, a binary file is generated when exporting:
Export["model.off", [image]]Print the raw textual contents of the file:
FilePrint[%]Use "BinaryFormat" False to generate an ASCII file:
Export["model.off", [image], {"OFF", "BinaryFormat" -> False}]Print the raw textual contents of the file:
FilePrint[%]History
Introduced in 2007 (6.0) | Updated in 2015 (10.2)