Debian Codegraph @

apps/tools/ivfix/IfHolder.c++

raw symbols SCIP
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 #include <Inventor/nodes/SoCoordinate3.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoCoordinate3.h`/
38 #include <Inventor/nodes/SoIndexedFaceSet.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoIndexedFaceSet.h`/
39 #include <Inventor/nodes/SoIndexedShape.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoIndexedShape.h`/
40 #include <Inventor/nodes/SoIndexedTriangleStripSet.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoIndexedTriangleStripSet.h`/
41 #include <Inventor/nodes/SoMaterial.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoMaterial.h`/
42 #include <Inventor/nodes/SoMaterialBinding.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoMaterialBinding.h`/
43 #include <Inventor/nodes/SoNormal.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoNormal.h`/
44 #include <Inventor/nodes/SoNormalBinding.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoNormalBinding.h`/
45 #include <Inventor/nodes/SoSeparator.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSeparator.h`/
46 #include <Inventor/nodes/SoTextureCoordinate2.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoTextureCoordinate2.h`/
47 #include <Inventor/nodes/SoTextureCoordinateBinding.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoTextureCoordinateBinding.h`/
48
49 #include "IfHolder.h"cxx . . $ `<file>/apps/tools/ivfix/IfHolder.h`/
50
51 /////////////////////////////////////////////////////////////////////////////
52 //
53 // Constructor.
54 //
55 /////////////////////////////////////////////////////////////////////////////
56
57 IfHoldercxx . . $ IfHolder#::IfHoldercxx . . $ IfHolder#IfHolder(3a44c4d05320ac8).(SoNodecxx . . $ SoNode# *graphRoot, SbBoolcxx . . $ SbBool# _doStrips,
58 SbBoolcxx . . $ SbBool# _doNormals, SbBoolcxx . . $ SbBool# _doTexCoords)
59 {
60 origRootcxx . . $ IfHolder#origRoot. = graphRoot;
61 origRootcxx . . $ IfHolder#origRoot.->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
62
63 doStripscxx . . $ IfHolder#doStrips. = _doStrips;
64 doNormalscxx . . $ IfHolder#doNormals. = _doNormals;
65 doTexCoordscxx . . $ IfHolder#doTexCoords. = _doTexCoords;
66
67 rootcxx . . $ IfHolder#root. = new SoSeparatorcxx . . $ SoSeparator#SoSeparator(d4f767463ce0a6b3).(7);
68 rootcxx . . $ IfHolder#root.->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
69
70 coordscxx . . $ IfHolder#coords. = new SoCoordinate3cxx . . $ SoCoordinate3#;
71 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(coordscxx . . $ IfHolder#coords.);
72
73 materialBindingcxx . . $ IfHolder#materialBinding. = new SoMaterialBindingcxx . . $ SoMaterialBinding#;
74 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(materialBindingcxx . . $ IfHolder#materialBinding.);
75
76 if (doNormalscxx . . $ IfHolder#doNormals.) {
77 normalscxx . . $ IfHolder#normals. = new SoNormalcxx . . $ SoNormal#;
78 normalBindingcxx . . $ IfHolder#normalBinding. = new SoNormalBindingcxx . . $ SoNormalBinding#;
79 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(normalscxx . . $ IfHolder#normals.);
80 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(normalBindingcxx . . $ IfHolder#normalBinding.);
81 }
82 else {
83 normalscxx . . $ IfHolder#normals. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
84 normalBindingcxx . . $ IfHolder#normalBinding. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
85 }
86
87 if (doTexCoordscxx . . $ IfHolder#doTexCoords.) {
88 texCoordscxx . . $ IfHolder#texCoords. = new SoTextureCoordinate2cxx . . $ SoTextureCoordinate2#;
89 texCoordBindingcxx . . $ IfHolder#texCoordBinding. = new SoTextureCoordinateBindingcxx . . $ SoTextureCoordinateBinding#;
90 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(texCoordscxx . . $ IfHolder#texCoords.);
91 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(texCoordBindingcxx . . $ IfHolder#texCoordBinding.);
92 }
93 else {
94 texCoordscxx . . $ IfHolder#texCoords. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
95 texCoordBindingcxx . . $ IfHolder#texCoordBinding. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
96 }
97
98 if (doStripscxx . . $ IfHolder#doStrips.) {
99 stripSetcxx . . $ IfHolder#stripSet. = new SoIndexedTriangleStripSetcxx . . $ SoIndexedTriangleStripSet#;
100 faceSetcxx . . $ IfHolder#faceSet. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
101 triSetcxx . . $ IfHolder#triSet. = stripSetcxx . . $ IfHolder#stripSet.;
102 }
103 else {
104 stripSetcxx . . $ IfHolder#stripSet. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
105 faceSetcxx . . $ IfHolder#faceSet. = new SoIndexedFaceSetcxx . . $ SoIndexedFaceSet#;
106 triSetcxx . . $ IfHolder#triSet. = faceSetcxx . . $ IfHolder#faceSet.;
107 }
108
109 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(triSetcxx . . $ IfHolder#triSet.);
110 }
111
112 /////////////////////////////////////////////////////////////////////////////
113 //
114 // Destructor.
115 //
116 /////////////////////////////////////////////////////////////////////////////
117
118 IfHoldercxx . . $ IfHolder#::~cxx . . $ IfHolder#`~IfHolder`(49f6e7a06ebc5aa8).IfHoldercxx . . $ IfHolder#()
119 {
120 origRootcxx . . $ IfHolder#origRoot.->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
121 rootcxx . . $ IfHolder#root.->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
122 }
123
124 /////////////////////////////////////////////////////////////////////////////
125 //
126 // Converts the scene graph to use an SoVertexProperty node for
127 // the properties. The given material is used in case the
128 // materials need to be copied into the SoVertexProperty node.
129 //
130 /////////////////////////////////////////////////////////////////////////////
131
132 void
133 IfHoldercxx . . $ IfHolder#::convertToVertexPropertycxx . . $ IfHolder#convertToVertexProperty(abe752e5f4ec62b8).(SoMaterialcxx . . $ SoMaterial# *mtl)
134 {
135 // Create a new SoVertexProperty node
136 SoVertexPropertycxx . . $ SoVertexProperty# *vp = new SoVertexPropertycxx . . $ SoVertexProperty#;
137 vp->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
138
139 // Copy the field values from the property nodes
140 vp->vertexcxx . . $ SoVertexProperty#vertex. =cxx . . $ SoMFVec3f#`operator=`(81a0782a29c21fa3). coordscxx . . $ IfHolder#coords.->pointcxx . . $ SoCoordinate3#point.;
141 if (doNormalscxx . . $ IfHolder#doNormals.) {
142 vp->normalcxx . . $ SoVertexProperty#normal. =cxx . . $ SoMFVec3f#`operator=`(81a0782a29c21fa3). normalscxx . . $ IfHolder#normals.->vectorcxx . . $ SoNormal#vector.;
143 vp->normalBindingcxx . . $ SoVertexProperty#normalBinding. =cxx . . $ SoSFEnum#`operator=`(a916ead64264dedc). normalBindingcxx . . $ IfHolder#normalBinding.->valuecxx . . $ SoNormalBinding#value.;
144 }
145 if (doTexCoordscxx . . $ IfHolder#doTexCoords.)
146 vp->texCoordcxx . . $ SoVertexProperty#texCoord. =cxx . . $ SoMFVec2f#`operator=`(e4fb6662fa2ca8df). texCoordscxx . . $ IfHolder#texCoords.->pointcxx . . $ SoTextureCoordinate2#point.;
147 vp->materialBindingcxx . . $ SoVertexProperty#materialBinding. =cxx . . $ SoSFEnum#`operator=`(a916ead64264dedc). materialBindingcxx . . $ IfHolder#materialBinding.->valuecxx . . $ SoMaterialBinding#value.;
148
149 // Copy the materials only if there are materials and they are not overall
150 if (mtl != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! &&
151 materialBindingcxx . . $ IfHolder#materialBinding.->valuecxx . . $ SoMaterialBinding#value..getValuecxx . . $ SoSFEnum#getValue(455f465bc33b4cdf).() != SoMaterialBindingcxx . . $ SoMaterialBinding#::OVERALLcxx . . $ SoMaterialBinding#OVERALL.) {
152
153 // Need to pack the diffuse colors and transparency values
154 // into the orderedRGBA field
155 int num = mtl->diffuseColorcxx . . $ SoMaterial#diffuseColor..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).();
156 int numT = mtl->transparencycxx . . $ SoMaterial#transparency..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).();
157 vp->orderedRGBAcxx . . $ SoVertexProperty#orderedRGBA..setNumcxx . . $ SoMField#setNum(d4f767463ce0a6b3).(num);
158 uint32_tcxx . . $ uint32_t# *rgba = vp->orderedRGBAcxx . . $ SoVertexProperty#orderedRGBA..startEditingcxx . . $ SoMFUInt32#startEditing(ac695d451f96e4aa).();
159 const SbColorcxx . . $ SbColor# *d = mtl->diffuseColorcxx . . $ SoMaterial#diffuseColor..getValuescxx . . $ SoMFColor#getValues(9dd468d3f2917510).(0);
160 const float *t = mtl->transparencycxx . . $ SoMaterial#transparency..getValuescxx . . $ SoMFFloat#getValues(bab6c6b0b673bcf).(0);
161 for (int i = 0; i < num; i++)
162 rgba[i] = d[i].getPackedValuecxx . . $ SbColor#getPackedValue(b4a4f3d4caa63b62).(numT == 1 ? t[0] : t[i]);
163 vp->orderedRGBAcxx . . $ SoVertexProperty#orderedRGBA..finishEditingcxx . . $ SoMFUInt32#finishEditing(49f6e7a06ebc5aa8).();
164 }
165
166 // Store the SoVertexProperty node in the shape
167 triSetcxx . . $ IfHolder#triSet.->vertexPropertycxx . . $ SoVertexShape#vertexProperty. =cxx . . $ SoSFNode#`operator=`(4a10d168dc65ab48). vp;
168 vp->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
169
170 // Remove the old property nodes from the graph, leaving just the
171 // shape
172 triSetcxx . . $ IfHolder#triSet.->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
173 rootcxx . . $ IfHolder#root.->removeAllChildrencxx . . $ SoGroup#removeAllChildren(49f6e7a06ebc5aa8).();
174 rootcxx . . $ IfHolder#root.->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(triSetcxx . . $ IfHolder#triSet.);
175 triSetcxx . . $ IfHolder#triSet.->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
176 }