File: index.html

package info (click to toggle)
openctm 1.0.3%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,692 kB
  • sloc: ansic: 9,241; cpp: 5,199; python: 735; makefile: 30
file content (93 lines) | stat: -rw-r--r-- 8,234 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>OpenCTM: OpenCTM API Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li class="current"><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>OpenCTM API Reference</h1><h3>1.0.3 </h3><h2><a class="anchor" id="intro_sec">
Introduction</a></h2>
<p>OpenCTM is an open file format for storing compressed triangle meshes. In order to easily read and write OpenCTM files (usually suffixed .ctm) an API (Application Program Interface) is provided that can easily be used from most modern programming languages.</p>
<p>The OpenCTM functionality itself is written in highly portable standard C (C99).</p>
<h2><a class="anchor" id="usage_sec">
Usage</a></h2>
<p>For information about how to use the OpenCTM API, see <a class="el" href="openctm_8h.html">openctm.h</a>.</p>
<p>For information about the C++ wrapper classes, see <a class="el" href="classCTMimporter.html" title="OpenCTM importer class.">CTMimporter</a> and <a class="el" href="classCTMexporter.html" title="OpenCTM exporter class.">CTMexporter</a>.</p>
<h2><a class="anchor" id="example_sec">
Example usage</a></h2>
<h3><a class="anchor" id="example_load_sec">
Loading a CTM file</a></h3>
<p>Here is a simple example of loading a CTM file:</p>
<div class="fragment"><pre class="fragment">   <a class="code" href="openctm_8h.html#a7062b4f48dc6d1b736ac93955acf3888" title="OpenCTM context handle.">CTMcontext</a> context;
   <a class="code" href="openctm_8h.html#ac5ea1beb64d415c241f2abf35eeb6c48" title="Unsigned integer (32 bits wide).">CTMuint</a>    vertCount, triCount, * indices;
   <a class="code" href="openctm_8h.html#af8b7eeaefac4d6ad39d11c3f7be8afa2" title="Single precision floating point type (IEEE 754 32 bits wide).">CTMfloat</a>   * vertices;

   <span class="comment">// Create a new context</span>
   context = <a class="code" href="openctm_8h.html#a3ca20da713005b0c6afb9b5f21640837" title="Create a new OpenCTM context.">ctmNewContext</a>(<a class="code" href="openctm_8h.html#a0f5efe622ac5146c4505d49860ce5625a98b76ddee5519228fb8864e7929e5f00" title="The OpenCTM context will be used for importing data.">CTM_IMPORT</a>);

   <span class="comment">// Load the OpenCTM file</span>
   <a class="code" href="openctm_8h.html#a99a57706d438c5654adbc9646058dc01" title="Load an OpenCTM format file into the context.">ctmLoad</a>(context, <span class="stringliteral">&quot;mymesh.ctm&quot;</span>);
   <span class="keywordflow">if</span>(<a class="code" href="openctm_8h.html#a2bbaed33a6809affc4a61469f6676bdf" title="Returns the latest error.">ctmGetError</a>(context) == <a class="code" href="openctm_8h.html#a0f5efe622ac5146c4505d49860ce5625abf60b318c307c84b240d374d07ff6bf5" title="No error has occured (everything is OK).">CTM_NONE</a>)
   {
     <span class="comment">// Access the mesh data</span>
     vertCount = <a class="code" href="openctm_8h.html#a4012ac28aa780819e40ee118d7c6578e" title="Get information about an OpenCTM context.">ctmGetInteger</a>(context, <a class="code" href="openctm_8h.html#a0f5efe622ac5146c4505d49860ce5625af7d1a8887b82dc448f9d774e8874d98a" title="Number of vertices in the mesh (integer).">CTM_VERTEX_COUNT</a>);
     vertices = <a class="code" href="openctm_8h.html#abdfcfede5d37c75e78cae989dc71e248" title="Get a floating point array from an OpenCTM context.">ctmGetFloatArray</a>(context, <a class="code" href="openctm_8h.html#a0f5efe622ac5146c4505d49860ce5625af7e80243674806368e9e29e9e2bf8d55" title="Vertex point coordinates (float array).">CTM_VERTICES</a>);
     triCount = <a class="code" href="openctm_8h.html#a4012ac28aa780819e40ee118d7c6578e" title="Get information about an OpenCTM context.">ctmGetInteger</a>(context, <a class="code" href="openctm_8h.html#a0f5efe622ac5146c4505d49860ce5625a6d97b09d2d5da53c7c3bad5c5f30e51d" title="Number of triangles in the mesh (integer).">CTM_TRIANGLE_COUNT</a>);
     indices = <a class="code" href="openctm_8h.html#ae202716acce7a97668654052dc4d0bef" title="Get an integer array from an OpenCTM context.">ctmGetIntegerArray</a>(context, <a class="code" href="openctm_8h.html#a0f5efe622ac5146c4505d49860ce5625aa7ec8fe7061e8a336530ee0448073206" title="Triangle indices (integer array).">CTM_INDICES</a>);

     <span class="comment">// Deal with the mesh (e.g. transcode it to our internal representation)</span>
     <span class="comment">// ...</span>
   }

   <span class="comment">// Free the context</span>
   <a class="code" href="openctm_8h.html#aeb16fd3054a19415be90de4968b21a3a" title="Free an OpenCTM context.">ctmFreeContext</a>(context);
</pre></div><h3><a class="anchor" id="example_create_sec">
Creating a CTM file</a></h3>
<p>Here is a simple example of creating a CTM file:</p>
<div class="fragment"><pre class="fragment">   <a class="code" href="openctm_8h.html#a7062b4f48dc6d1b736ac93955acf3888" title="OpenCTM context handle.">CTMcontext</a> context;
   <a class="code" href="openctm_8h.html#ac5ea1beb64d415c241f2abf35eeb6c48" title="Unsigned integer (32 bits wide).">CTMuint</a>    vertCount, triCount, * indices;
   <a class="code" href="openctm_8h.html#af8b7eeaefac4d6ad39d11c3f7be8afa2" title="Single precision floating point type (IEEE 754 32 bits wide).">CTMfloat</a>   * vertices;

   <span class="comment">// Create our mesh in memory</span>
   vertCount = 100;
   triCount = 120;
   vertices = (<a class="code" href="openctm_8h.html#af8b7eeaefac4d6ad39d11c3f7be8afa2" title="Single precision floating point type (IEEE 754 32 bits wide).">CTMfloat</a> *) malloc(3 * <span class="keyword">sizeof</span>(<a class="code" href="openctm_8h.html#af8b7eeaefac4d6ad39d11c3f7be8afa2" title="Single precision floating point type (IEEE 754 32 bits wide).">CTMfloat</a>) * vertCount);
   indices = (<a class="code" href="openctm_8h.html#ac5ea1beb64d415c241f2abf35eeb6c48" title="Unsigned integer (32 bits wide).">CTMuint</a> *) malloc(3 * <span class="keyword">sizeof</span>(<a class="code" href="openctm_8h.html#ac5ea1beb64d415c241f2abf35eeb6c48" title="Unsigned integer (32 bits wide).">CTMuint</a>) * triCount);
   <span class="comment">// ...</span>

   <span class="comment">// Create a new context</span>
   context = <a class="code" href="openctm_8h.html#a3ca20da713005b0c6afb9b5f21640837" title="Create a new OpenCTM context.">ctmNewContext</a>(<a class="code" href="openctm_8h.html#a0f5efe622ac5146c4505d49860ce5625a4d156b19083ce49d4b8a6da287d6f5d3" title="The OpenCTM context will be used for exporting data.">CTM_EXPORT</a>);

   <span class="comment">// Define our mesh representation to OpenCTM (store references to it in</span>
   <span class="comment">// the context)</span>
   <a class="code" href="openctm_8h.html#a1cb648e89121ae67f5a8b9e5a8f41c4d" title="Define a triangle mesh.">ctmDefineMesh</a>(context, vertices, vertCount, indices, triCount, NULL);

   <span class="comment">// Save the OpenCTM file</span>
   <a class="code" href="openctm_8h.html#acde994008b0b3321bad9f3bbfacb12db" title="Save an OpenCTM format file.">ctmSave</a>(context, <span class="stringliteral">&quot;mymesh.ctm&quot;</span>);

   <span class="comment">// Free the context</span>
   <a class="code" href="openctm_8h.html#aeb16fd3054a19415be90de4968b21a3a" title="Free an OpenCTM context.">ctmFreeContext</a>(context);

   <span class="comment">// Free our mesh</span>
   free(indices);
   free(vertices);
</pre></div> </div>
<div style="padding: 1em 1em 0.5em 1em; margin: 2em 0 0 0; border-top: 1px solid #84b0c7; color: #808080; text-align: center;">
  <p>Copyright &copy; 2009-2010 Marcus Geelnard &mdash;
  <a href="http://openctm.sourceforge.net" title="OpenCTM home page">openctm.sourceforge.net</a></p>
</div>
</body>
</html>