Mesh Oriented datABase
(version 5.5.1)
An array-based unstructured mesh library
WriteSTL.hpp
Go to the documentation of this file.
1
/**
2
* MOAB, a Mesh-Oriented datABase, is a software component for creating,
3
* storing and accessing finite element mesh data.
4
*
5
* Copyright 2004 Sandia Corporation. Under the terms of Contract
6
* DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7
* retains certain rights in this software.
8
*
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
13
*
14
*/
15
16
#ifndef WRITE_STL_HPP
17
#define WRITE_STL_HPP
18
19
#include "
moab/CartVect.hpp
"
20
#include "
moab/Forward.hpp
"
21
#include "
moab/WriterIface.hpp
"
22
23
#include <cstdio>
24
25
namespace
moab
26
{
27
28
class
WriteUtilIface;
29
30
/**
31
* \brief ASCII and Binary Stereo Lithography File writers.
32
* \author Jason Kraftcheck
33
*
34
* This writer will write only the MBTRI elements in the mesh. It
35
* will not decompose other 2-D elements into triangles, nor will
36
* it skin the mesh or do any other high-level operation to generate
37
* triangles from 3-D elements.
38
*
39
* Binary files will be written with a little-endian byte order by
40
* default. The byte order can be controlled with writer options.
41
*/
42
class
WriteSTL
:
public
WriterIface
43
{
44
45
public
:
46
//! factory method forSTL writer
47
static
WriterIface
*
factory
(
Interface
* );
48
49
//! Constructor
50
WriteSTL
(
Interface
* impl );
51
52
//! Destructor
53
virtual
~WriteSTL
();
54
55
//! writes out a file
56
ErrorCode
write_file
(
const
char
* file_name,
57
const
bool
overwrite,
58
const
FileOptions
& opts,
59
const
EntityHandle
* output_list,
60
const
int
num_sets,
61
const
std::vector< std::string >& qa_list,
62
const
Tag
* tag_list = NULL,
63
int
num_tags = 0,
64
int
export_dimension = 3 );
65
66
protected
:
67
enum
ByteOrder
68
{
69
STL_BIG_ENDIAN
,
70
STL_LITTLE_ENDIAN
,
71
STL_UNKNOWN_BYTE_ORDER
72
};
73
74
//! Write list of triangles to an STL file.
75
ErrorCode
ascii_write_triangles
( FILE* file,
const
char
header[81],
const
Range
& triangles,
int
precision );
76
//! Write list of triangles to an STL file.
77
ErrorCode
binary_write_triangles
( FILE* file,
const
char
header[81],
ByteOrder
byte_order,
const
Range
& triangles );
78
79
//! Given an array of vertex coordinates for a triangle,
80
//! pass back individual point coordinates as floats and
81
//! calculate triangle normal.
82
ErrorCode
get_triangle_data
(
const
double
vtx_coords[9],
float
v1[3],
float
v2[3],
float
v3[3],
float
n[3] );
83
84
ErrorCode
get_triangle_data
(
const
double
vtx_coords[9],
CartVect
& v1,
CartVect
& v2,
CartVect
& v3,
CartVect
& n );
85
86
//! interface instance
87
Interface
*
mbImpl
;
88
WriteUtilIface
*
mWriteIface
;
89
90
private
:
91
//! Construct 80-byte, null-terminated description string from
92
//! qa_list. Unused space in header will be null-char padded.
93
ErrorCode
make_header
(
char
header[81],
const
std::vector< std::string >& qa_list );
94
95
//! Get triangles to write from input array of entity sets. If
96
//! no sets, gets all triangles.
97
ErrorCode
get_triangles
(
const
EntityHandle
* set_array,
int
set_array_length,
Range
& triangles );
98
99
//! Open a file, respecting passed overwrite value and
100
//! subclass-specified value for need_binary_io().
101
FILE*
open_file
(
const
char
* name,
bool
overwrite,
bool
binary );
102
};
103
104
}
// namespace moab
105
106
#endif
src
io
WriteSTL.hpp
Generated on Sat Dec 21 2024 02:03:58 for Mesh Oriented datABase by
1.9.1.