Debian Codegraph @

lib/database/src/so/upgraders/SoV1ShapeHints.c++

raw
1 /*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37 /*
38 * Copyright (C) 1990,91,92 Silicon Graphics, Inc.
39 *
40 _______________________________________________________________________
41 ______________ S I L I C O N G R A P H I C S I N C . ____________
42 |
43 | $Revision: 1.1.1.1 $
44 |
45 | Classes:
46 | SoV1ShapeHints
47 |
48 | Author(s) : Gavin Bell
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54 #include "SoV1ShapeHints.h"
55 #include <Inventor/nodes/SoShapeHints.h>
56
57 SO_NODE_SOURCE(SoV1ShapeHints);
58
59 ////////////////////////////////////////////////////////////////////////
60 //
61 // Description:
62 // Default constructor
63 //
64 // Use: public
65
66 SoV1ShapeHints::SoV1ShapeHints()
67 //
68 ////////////////////////////////////////////////////////////////////////
69 {
70 SO_NODE_CONSTRUCTOR(SoV1ShapeHints);
71
72 SO_NODE_ADD_FIELD(hints, (SURFACE | UNORDERED | CONCAVE));
73 SO_NODE_ADD_FIELD(creaseAngle, (0.0));
74
75 // Set up static info for enumerated type field
76 SO_NODE_DEFINE_ENUM_VALUE(Hint, SOLID);
77 SO_NODE_DEFINE_ENUM_VALUE(Hint, ORDERED);
78 SO_NODE_DEFINE_ENUM_VALUE(Hint, CONVEX);
79 SO_NODE_DEFINE_ENUM_VALUE(Hint, SURFACE);
80 SO_NODE_DEFINE_ENUM_VALUE(Hint, UNORDERED);
81 SO_NODE_DEFINE_ENUM_VALUE(Hint, CONCAVE);
82
83 // Set up info in enumerated type field
84 SO_NODE_SET_SF_ENUM_TYPE(hints, Hint);
85 }
86
87 ////////////////////////////////////////////////////////////////////////
88 //
89 // Description:
90 // Destructor.
91 //
92 // Use: private
93
94 SoV1ShapeHints::~SoV1ShapeHints()
95 //
96 ////////////////////////////////////////////////////////////////////////
97 {
98 }
99
100 ////////////////////////////////////////////////////////////////////////
101 //
102 // Description:
103 // Create a version 2.0 SoShapeHints.
104 //
105 // Use: private
106
107 SoNode *
108 SoV1ShapeHints::createNewNode()
109 //
110 ////////////////////////////////////////////////////////////////////////
111 {
112 SoShapeHints *result = SO_UPGRADER_CREATE_NEW(SoShapeHints);
113
114 // Convert from old enums to new fields
115 if (! hints.isDefault()) {
116 Hint h = (Hint) hints.getValue();
117
118 if (h & SOLID)
119 result->shapeType = SoShapeHints::SOLID;
120 if (h & ORDERED)
121 result->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
122
123 // Since CONVEX is the default in 2.0, we just have to turn it
124 // off when it's not specified
125 if (! (h & CONVEX))
126 result->faceType = SoShapeHints::UNKNOWN_FACE_TYPE;
127
128 if (hints.isIgnored()) {
129 result->shapeType.setIgnored(TRUE);
130 result->vertexOrdering.setIgnored(TRUE);
131 result->faceType.setIgnored(TRUE);
132 }
133 }
134
135 SO_UPGRADER_COPY_FIELD(creaseAngle, result);
136
137 return result;
138 }
139