Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SoSTLFileKit.h
1#ifndef COIN_SOSTLFILEKIT_H
2#define COIN_SOSTLFILEKIT_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#include <Inventor/SbBasic.h>
37
38#include <Inventor/fields/SoSFString.h>
39#include <Inventor/fields/SoSFBool.h>
40#include <Inventor/fields/SoSFEnum.h>
41
42#include <Inventor/annex/ForeignFiles/SoForeignFileKit.h>
43
44class SbVec3f;
47class SoSTLFileKitP;
48
49class COIN_DLL_API SoSTLFileKit : public SoForeignFileKit {
51
52 SO_KIT_HEADER(SoSTLFileKit);
53 SO_KIT_CATALOG_ENTRY_HEADER(shapehints);
54 SO_KIT_CATALOG_ENTRY_HEADER(texture);
55 SO_KIT_CATALOG_ENTRY_HEADER(normalbinding);
56 SO_KIT_CATALOG_ENTRY_HEADER(normals);
57 SO_KIT_CATALOG_ENTRY_HEADER(materialbinding);
58 SO_KIT_CATALOG_ENTRY_HEADER(material);
59 SO_KIT_CATALOG_ENTRY_HEADER(coordinates);
60 SO_KIT_CATALOG_ENTRY_HEADER(facets);
61
62public:
63 static void initClass(void);
64 SoSTLFileKit(void);
65
66 enum Colorization { GREY, MATERIALISE, TNO_VISICAM };
67
68 SoSFString info;
69 SoSFBool binary;
70 SoSFEnum colorization;
71
72 static SbBool identify(const char * filename);
73 virtual SbBool canReadFile(const char * filename = NULL) const;
74 virtual SbBool readFile(const char * filename);
75
76 virtual SbBool canWriteFile(const char * filename = NULL) const;
77 virtual SbBool writeFile(const char * filename);
78
79
80 SbBool canReadScene(void) const;
81 SbBool readScene(SoNode * scene);
82 virtual SoSeparator *convert();
83
84protected:
85 virtual ~SoSTLFileKit(void);
86
87 void reset(void);
88 SbBool addFacet(const SbVec3f & v1, const SbVec3f & v2, const SbVec3f & v3,
89 const SbVec3f & normal);
90 void organizeModel(void);
91
92private:
93 SoSTLFileKitP * pimpl;
94
95 static void add_facet_cb(void * closure, SoCallbackAction * action, const SoPrimitiveVertex * v1, const SoPrimitiveVertex * v2, const SoPrimitiveVertex * v3);
96 static void put_facet_cb(void * closure, SoCallbackAction * action, const SoPrimitiveVertex * v1, const SoPrimitiveVertex * v2, const SoPrimitiveVertex * v3);
97
98}; // SoSTLFileKit
99
100#endif // !COIN_SOSTLFILEKIT_H
The SbVec3f class is a 3 dimensional vector with floating point coordinates.
Definition SbVec3f.h:51
The SoCallbackAction class invokes callbacks at specific nodes.
Definition SoCallbackAction.h:80
Abstract base class for foreign file format support in Coin.
Definition SoForeignFileKit.h:45
virtual class SoSeparator * convert()=0
static void initClass(void)
Definition SoForeignFileKit.cpp:125
virtual SbBool readFile(const char *filename)
Definition SoForeignFileKit.cpp:334
virtual SbBool writeFile(const char *filename)
Definition SoForeignFileKit.cpp:354
virtual SbBool canWriteFile(const char *filename=NULL) const
Definition SoForeignFileKit.cpp:343
virtual SbBool canReadFile(const char *filename=NULL) const
Definition SoForeignFileKit.cpp:323
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:56
The SoPrimitiveVertex class represents a single vertex of a generated primitive.
Definition SoPrimitiveVertex.h:43
The SoSFBool class is a container for an SbBool value.
Definition SoSFBool.h:39
The SoSFEnum class is a container for an enum value.
Definition SoSFEnum.h:40
The SoSFString class is a container for an SbString.
Definition SoSFString.h:40
SoSTLFileKit is a class for using STL files with Coin.
Definition SoSTLFileKit.h:49
The SoSeparator class is a state-preserving group node.
Definition SoSeparator.h:44