1 #ifndef STL_STEEL_H
2 #define STL_STEEL_H
3 
4 /**************************************************************************\
5  * Copyright (c) Kongsberg Oil & Gas Technologies AS
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met:
11  *
12  * Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * Neither the name of the copyright holder nor the names of its
20  * contributors may be used to endorse or promote products derived from
21  * this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 \**************************************************************************/
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /* __cplusplus */
39 
40 /* ********************************************************************** */
41 
42 #define  STL_STEEL_MAJOR           (0)
43 #define  STL_STEEL_MINOR           (5)
44 #define  STL_STEEL_MICRO           (0)
45 #define  STL_STEEL_ABI_VERSION     (0)
46 #define  STL_STEEL_ABI_REVISION    (0)
47 #define  STL_STEEL_ABI_AGE         (0)
48 
49 #define  STL_ERROR                (-1)
50 #define  STL_OK                    (0)
51 #define  STL_BEGIN                 (1)
52 #define  STL_INIT_INFO             (2)
53 #define  STL_FACET                 (3)
54 #define  STL_EXIT_INFO             (4)
55 #define  STL_END                   (5)
56 
57 #define  STL_BINARY             (0x01)
58 /* binary file color extensions (mutually exclusive): */
59 #define  STL_COLOR_MATERIALISE  (0x02)
60 #define  STL_COLOR_TNO_VISICAM  (0x04)
61 
62 #define  STL_NO_COLOR     (0xffffffff)
63 
64 typedef  float                stl_real;
65 typedef  struct stl_facet_s   stl_facet;
66 typedef  struct stl_reader_s  stl_reader;
67 typedef  struct stl_writer_s  stl_writer;
68 
69 int           stl_steel_major(void);
70 int           stl_steel_minor(void);
71 int           stl_steel_micro(void);
72 int           stl_steel_abi_version(void);
73 int           stl_steel_abi_revision(void);
74 int           stl_steel_abi_age(void);
75 int           stl_steel_abi_supported(int version, int revision);
76 
77 stl_facet *   stl_facet_create_uninitialized(void);
78 stl_facet *   stl_facet_create(void);
79 stl_facet *   stl_facet_clone(stl_facet * facet);
80 void          stl_facet_copy(stl_facet * source, stl_facet * target);
81 void          stl_facet_destroy(stl_facet * facet);
82 void          stl_facet_set_normal(stl_facet * facet, stl_real x, stl_real y, stl_real z);
83 void          stl_facet_get_normal(stl_facet * facet, stl_real * x, stl_real * y, stl_real * z);
84 void          stl_facet_set_vertex1(stl_facet * facet, stl_real x, stl_real y, stl_real z);
85 void          stl_facet_get_vertex1(stl_facet * facet, stl_real * x, stl_real * y, stl_real * z);
86 void          stl_facet_set_vertex2(stl_facet * facet, stl_real x, stl_real y, stl_real z);
87 void          stl_facet_get_vertex2(stl_facet * facet, stl_real * x, stl_real * y, stl_real * z);
88 void          stl_facet_set_vertex3(stl_facet * facet, stl_real x, stl_real y, stl_real z);
89 void          stl_facet_get_vertex3(stl_facet * facet, stl_real * x, stl_real * y, stl_real * z);
90 void          stl_facet_set_padding(stl_facet * facet, unsigned int padding);
91 unsigned int  stl_facet_get_padding(stl_facet * facet);
92 void          stl_facet_set_color(stl_facet * facet, unsigned int rgb);
93 unsigned int  stl_facet_get_color(stl_facet * facet);
94 
95 stl_reader *  stl_reader_create(const char * filename);
96 void          stl_reader_destroy(stl_reader * reader);
97 unsigned int  stl_reader_flags(stl_reader * reader);
98 int           stl_reader_peek(stl_reader * reader);
99 const char *  stl_reader_get_info(stl_reader * reader);
100 stl_facet *   stl_reader_get_facet(stl_reader * reader);
101 void          stl_reader_fill_facet(stl_reader * reader, stl_facet * facet);
102 const char *  stl_reader_get_error(stl_reader * reader);
103 int           stl_reader_get_line_number(stl_reader * reader);
104 
105 /* not really implemented yet */
106 stl_writer *  stl_writer_create(const char * filename, unsigned int flags);
107 int           stl_writer_destroy(stl_writer * writer);
108 unsigned int  stl_writer_get_flags(stl_writer * writer);
109 int           stl_writer_set_info(stl_writer * writer, const char * info);
110 void          stl_writer_set_facet(stl_writer * writer, stl_facet * facet);
111 stl_facet *   stl_writer_get_facet(stl_writer * writer);
112 int           stl_writer_put_facet(stl_writer * writer, stl_facet * facet);
113 const char *  stl_writer_get_error(stl_writer * writer);
114 
115 /* ********************************************************************** */
116 
117 #ifdef __cplusplus
118 } /* extern "C" */
119 #endif /* __cplusplus */
120 
121 #endif /* STL_STEEL_H */
122