Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
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 
43 
44 class SbVec3f;
45 class SoCallbackAction;
46 class SoPrimitiveVertex;
47 class SoSTLFileKitP;
48 
49 class 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 
62 public:
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 
84 protected:
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 
92 private:
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 SoBaseKit class is the toplevel superclass for nodekits.
Definition: SoBaseKit.h:66
Abstract base class for foreign file format support in Coin.
Definition: SoForeignFileKit.h:45
The SoPrimitiveVertex class represents a single vertex of a generated primitive.
Definition: SoPrimitiveVertex.h:43
virtual SbBool readFile(const char *filename)
Definition: SoForeignFileKit.cpp:332
The SoSFString class is a container for an SbString.
Definition: SoSFString.h:40
virtual SbBool writeFile(const char *filename)
Definition: SoForeignFileKit.cpp:352
The SoNode class is the base class for nodes used in scene graphs.
Definition: SoNode.h:56
The SoSFEnum class is a container for an enum value.
Definition: SoSFEnum.h:40
SoSTLFileKit is a class for using STL files with Coin.
Definition: SoSTLFileKit.h:49
The SoSFBool class is a container for an SbBool value.
Definition: SoSFBool.h:39
virtual SbBool canReadFile(const char *filename=NULL) const
Definition: SoForeignFileKit.cpp:321
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
The SoSeparator class is a state-preserving group node.
Definition: SoSeparator.h:44
virtual class SoSeparator * convert()=0
virtual SbBool canWriteFile(const char *filename=NULL) const
Definition: SoForeignFileKit.cpp:341