Debian Codegraph @

lib/nodekits/src/upgraders/SoV1BaseKit.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 /*
38 * Copyright (C) 1990,91 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 | SoV1BaseKit
47 |
48 | Author(s) : Paul Isaacs and Thad Beier
49 |
50 ______________ S I L I C O N G R A P H I C S I N C . ____________
51 _______________________________________________________________________
52 */
53
54
55 #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/
56 #include <Inventor/SoPath.h>cxx . . $ `<file>/lib/database/include/Inventor/SoPath.h`/
57 #include <Inventor/nodes/SoLabel.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoLabel.h`/
58 #include <Inventor/nodes/SoGroup.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoGroup.h`/
59 #include <Inventor/nodes/SoSwitch.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSwitch.h`/
60 #include <Inventor/nodekits/SoNodeKitListPart.h>cxx . . $ `<file>/lib/nodekits/include/Inventor/nodekits/SoNodeKitListPart.h`/
61
62 #include <Inventor/misc/upgraders/SoV1BaseKit.h>cxx . . $ `<file>/lib/nodekits/include/Inventor/misc/upgraders/SoV1BaseKit.h`/
63 #include <Inventor/nodekits/SoBaseKit.h>cxx . . $ `<file>/lib/nodekits/include/Inventor/nodekits/SoBaseKit.h`/
64 #include <Inventor/errors/SoDebugError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoDebugError.h`/
65
66
67 // Defines for printing out file data for nodekits
68 #define SO_V1_BASEKIT_FILEDATA_HEADERcxx . . $ `lib/nodekits/src/upgraders/SoV1BaseKit.c++:68:9`! "partName/childNum pairs [ "
69 #define SO_V1_BASEKIT_FILEDATA_FOOTERcxx . . $ `lib/nodekits/src/upgraders/SoV1BaseKit.c++:69:9`! "]"
70
71 // Define the required type id and name inquiry methods
72 SO_NODE_SOURCEcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:241:9`!(SoV1BaseKit);
73
74 // Define the required catalog inquiry methods
75 SO_V1_SUBKIT_CATALOG_VARScxx . . $ `lib/nodekits/include/Inventor/misc/upgraders/SoV1SubKit.h:112:9`!(SoV1BaseKit);
76 SO_V1_SUBKIT_CATALOG_METHODScxx . . $ `lib/nodekits/include/Inventor/misc/upgraders/SoV1SubKit.h:120:9`!(SoV1BaseKit);
77
78
79 ////////////////////////////////////////////////////////////////////////
80 //
81 // Description:
82 // Constructor
83 //
84 // Use: public
85
86 SoV1BaseKitcxx . . $ SoV1BaseKit#::SoV1BaseKitcxx . . $ SoV1BaseKit#SoV1BaseKit(49f6e7a06ebc5aa8).()
87 //
88 ////////////////////////////////////////////////////////////////////////
89 {
90 SO_NODE_CONSTRUCTORcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:309:9`!(SoV1BaseKit);
91
92 if (SO_NODE_IS_FIRST_INSTANCEcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:326:9`!() ) {
93
94 // Initialize children catalog and add entries to it
95 // NOTE: for all classes other than the SoV1BaseKit class, the
96 // macro SO_V1_SUBKIT_INHERIT_CATALOG is used.
97 // the nodekitCatalog is made from scratch ONLY in the SoV1BaseKit class
98 nodekitCatalogcxx . . $ SoV1BaseKit#nodekitCatalog. = new SoV1NodekitCatalogcxx . . $ SoV1NodekitCatalog#();
99 SO_V1_SUBKIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/misc/upgraders/SoV1SubKit.h:193:9`!("this",SoV1BaseKit, "", "", FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!);
100 SO_V1_SUBKIT_ADD_CATALOG_ENTRYcxx . . $ `lib/nodekits/include/Inventor/misc/upgraders/SoV1SubKit.h:193:9`!("label",SoLabel, "this", "", TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`! );
101 }
102
103 if ( getNodekitCatalogcxx . . $ SoV1BaseKit#getNodekitCatalog(84f18d8e1dffd288).() != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! )
104 nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList. = new SoV1NodekitPartscxx . . $ SoV1NodekitParts#( this );
105 }
106
107 ////////////////////////////////////////////////////////////////////////
108 //
109 // Description:
110 // Destructor (necessary since inline destructor is too complex)
111 //
112 // Use: public
113
114 SoV1BaseKitcxx . . $ SoV1BaseKit#::~cxx . . $ SoV1BaseKit#`~SoV1BaseKit`(49f6e7a06ebc5aa8).SoV1BaseKitcxx . . $ SoV1BaseKit#()
115 //
116 ////////////////////////////////////////////////////////////////////////
117 {
118 delete nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.;
119 }
120
121 ////////////////////////////////////////////////////////////////////////
122 //
123 // Description:
124 // Return the part with the given name
125 //
126 // Use: protected
127
128 SoNodecxx . . $ SoNode# *
129 SoV1BaseKitcxx . . $ SoV1BaseKit#::getAnyPartcxx . . $ SoV1BaseKit#getAnyPart(950bf2ec3cc02a4e).( const SbNamecxx . . $ SbName# &partName, const SoTypecxx . . $ SoType# &partType,
130 SbBoolcxx . . $ SbBool# makeIfNeeded, SbBoolcxx . . $ SbBool# leafCheck,
131 SbBoolcxx . . $ SbBool# publicCheck, SoPathcxx . . $ SoPath# * /* inheritancePath */ )
132 //
133 ////////////////////////////////////////////////////////////////////////
134 {
135 SoNodecxx . . $ SoNode# *theNode = nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.->getAnyPartcxx . . $ SoV1NodekitParts#getAnyPart(e7d7a7aae96def2f).( partName, makeIfNeeded,
136 leafCheck, publicCheck );
137
138 // check that the node we are giving back is derived from
139 // partType, so that it is safe for the recipient of 'theNode'
140 // to treat it as being of that type
141 if ( theNode != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!
142 && !theNode->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( partType )) {
143 #ifdef DEBUG
144 SoDebugError::post("SoV1BaseKit::getAnyPart",
145 "the node you asked for, %s, is not of the type you asked for",
146 partName.getString() );
147 #endif
148 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
149 }
150 return theNode;
151 }
152
153 ////////////////////////////////////////////////////////////////////////
154 //
155 // Description:
156 // Return the part with the given name
157 //
158 // Use: public
159
160 SoNodecxx . . $ SoNode# *
161 SoV1BaseKitcxx . . $ SoV1BaseKit#::getPartcxx . . $ SoV1BaseKit#getPart(528a98bf4c45b430).( const SbNamecxx . . $ SbName# &partName, const SoTypecxx . . $ SoType# &partType,
162 SbBoolcxx . . $ SbBool# makeIfNeeded,
163 SoPathcxx . . $ SoPath# *inheritancePath )
164 //
165 ////////////////////////////////////////////////////////////////////////
166 {
167 // the fourth argument, leafCheck and publicCheck are TRUE, because we
168 // don't ordinarily return parts unless they are public leaves.
169 return ( getAnyPartcxx . . $ SoV1BaseKit#getAnyPart(950bf2ec3cc02a4e).( partName, partType, makeIfNeeded, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!,
170 inheritancePath ) );
171 }
172
173 ////////////////////////////////////////////////////////////////////////
174 //
175 // Description:
176 // Return the part with the given name
177 //
178 // Use: protected
179
180 SbBoolcxx . . $ SbBool#
181 SoV1BaseKitcxx . . $ SoV1BaseKit#::setAnyPartcxx . . $ SoV1BaseKit#setAnyPart(9a61422242ad1ac7).( const SbNamecxx . . $ SbName# &partName, SoNodecxx . . $ SoNode# *from, SbBoolcxx . . $ SbBool# anyPart )
182 //
183 ////////////////////////////////////////////////////////////////////////
184 {
185 if ( from )
186 from->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
187 SbBoolcxx . . $ SbBool# answer = nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.->setAnyPartcxx . . $ SoV1NodekitParts#setAnyPart(9a61422242ad1ac7).( partName, from, anyPart );
188 if ( from )
189 from->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
190 return answer;
191 }
192
193 ////////////////////////////////////////////////////////////////////////
194 //
195 // Description:
196 // Check to see if the given node is derived from any of the typeIds
197 // in the given typeList
198 //
199 // Use: public
200
201 SbBoolcxx . . $ SbBool#
202 SoV1BaseKitcxx . . $ SoV1BaseKit#::childOkInListcxx . . $ SoV1BaseKit#childOkInList(616513e1c8a35264).(const SoNodecxx . . $ SoNode# *child,
203 const SbPListcxx . . $ SbPList# &listToCheck ) const
204 //
205 ////////////////////////////////////////////////////////////////////////
206 {
207 for( int i = 0; i < listToCheck.getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++ ) {
208 if ( child->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( *((SoTypecxx . . $ SoType# *) listToCheck[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).i] ) ) )
209 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
210 }
211
212 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
213 }
214
215 #define COMMENT_CHARcxx . . $ `lib/nodekits/src/upgraders/SoV1BaseKit.c++:215:9`! '#'
216
217
218 ////////////////////////////////////////////////////////////////////////
219 //
220 // Description:
221 // Creates the nodekitPartsList list.
222 // Should be called once during the constructor for each instance.
223 //
224 //
225 //
226 // Use: protected
227
228 void
229 SoV1BaseKitcxx . . $ SoV1BaseKit#::createNodekitPartsListcxx . . $ SoV1BaseKit#createNodekitPartsList(49f6e7a06ebc5aa8).()
230 //
231 ////////////////////////////////////////////////////////////////////////
232 {
233 if ( getNodekitCatalogcxx . . $ SoV1BaseKit#getNodekitCatalog(84f18d8e1dffd288).() != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ) {
234 SoV1NodekitPartscxx . . $ SoV1NodekitParts# *oldParts = nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.;
235 nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList. = new SoV1NodekitPartscxx . . $ SoV1NodekitParts#( this, oldParts );
236 if (oldParts)
237 delete oldParts;
238 }
239 }
240
241 ////////////////////////////////////////////////////////////////////////
242 //
243 // Description:
244 // Interprets the customData string and checks the structure of the given
245 // node based on those contents.
246 //
247 // Use: private
248
249 void
250 SoV1BaseKitcxx . . $ SoV1BaseKit#::interpretCustomDatacxx . . $ SoV1BaseKit#interpretCustomData(b2cc2bc79e6de27a).(SoV1CustomNodecxx . . $ SoV1CustomNode# *inst, // Node to interpret for
251 int index ) const // Index into the customData
252 // field for finding the
253 // string to interpret.
254 //
255 ////////////////////////////////////////////////////////////////////////
256 {
257 #ifdef DEBUG
258 if ( !inst->isOfType( SoV1BaseKit::getClassTypeId() )) {
259 SoDebugError::post("SoV1BaseKit::interpretCustomData",
260 "Given node is not a nodekit.");
261 return;
262 }
263 #endif
264
265 // get the catalog and parts list
266 SoV1BaseKitcxx . . $ SoV1BaseKit# *theKit = (SoV1BaseKitcxx . . $ SoV1BaseKit# *) inst;
267
268 // only do this if 'index' is for the class SoV1BaseKit...
269 if ( theKit->classNamecxx . . $ SoV1CustomNode#className..getNumcxx . . $ SoMField#getNum(455f465bc33b4cdf).() <= index ||
270 theKit->classNamecxx . . $ SoV1CustomNode#className.[cxx . . $ SoMFName#`operator[]`(e603ed4d11f0a676).index] !=cxx . . $ `operator!=`(1deca42c6f82b65f). "BaseKit" )
271 return;
272
273 SoV1NodekitPartscxx . . $ SoV1NodekitParts# *nkp = theKit->nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.;
274 const SoV1NodekitCatalogcxx . . $ SoV1NodekitCatalog# *theCat = theKit->getNodekitCatalogcxx . . $ SoV1BaseKit#getNodekitCatalog(84f18d8e1dffd288).();
275
276 #ifdef DEBUG
277 // make sure that 'inst' is listed as the part 'this' in its own
278 // nodekitPartsList list.
279 if ( inst != nkp->nodeList[0] ) {
280 SoDebugError::post("SoV1BaseKit::interpretCustomData",
281 "Given node is not listed in its own partlist!");
282 return;
283 }
284 #endif
285
286 // O.K., we're going to do something a little tricky here. You see, some
287 // of the constructors for nodekits build parts automatically. For example,
288 // an SoV1ConeKit constructor creates a new SoCone and then calls
289 // setPart( "cone", newlyMadeSoCone );
290 // Now, reading in a nodekit follows the following algorithm:
291 // [1] create a new kit
292 // [2] read the kit's fields and children
293 // [3] come into this routine and check the node's structural integrity,
294 // based on the information you find in the field 'customData'
295 // The problem is that steps [1] and [2] can create duplicate children.
296 // Clearly, we want to keep the children described in the file, which
297 // are created/read during step [2] and enumerated in the 'customData'
298 // field.
299 // Hence, the tricky part:
300 // If 'customData' is empty, then keep the default parts made by
301 // the constructor.
302 // If 'customData' is not empty, then we want to get rid of the
303 // parts made in the constructor. These parts will all be registered
304 // in the partsList. So get rid of everything in the partsList (except
305 // for 'this' of course).
306 if ( !inst->customDatacxx . . $ SoV1CustomNode#customData..isDefaultcxx . . $ SoField#isDefault(455f465bc33b4cdf).() &&
307 (inst->customDatacxx . . $ SoV1CustomNode#customData.[cxx . . $ SoMFString#`operator[]`(1f64d4776649c045).(int) index] !=cxx . . $ `operator!=`(7399b355b639fe1). "") ) {
308 SbNamecxx . . $ SbName# entryNamecxx . . $ SbName#SbName(49f6e7a06ebc5aa8).;
309 for ( int entryNum = nkp->numEntriescxx . . $ SoV1NodekitParts#numEntries. - 1; entryNum > 0; entryNum-- ) {
310 // Work backwards through the parts list. Then we will be
311 // sure to delete children before their parents.
312 // Also, don't get rid of entry 0, since that is 'this'.
313 if ( nkp->nodeListcxx . . $ SoV1NodekitParts#nodeList.[entryNum] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ) {
314 entryName =cxx . . $ SbName#`operator=`(8da52b6fc1e0f7c6). theCat->getNamecxx . . $ SoV1NodekitCatalog#getName(e603ed4d11f0a676).( entryNum );
315 nkp->setAnyPartcxx . . $ SoV1NodekitParts#setAnyPart(9a61422242ad1ac7).(entryName, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`! );
316 }
317 }
318 }
319 // end of tricky part.
320
321 // Get a destroyable copy of the customData string.(strtok will corrupt it).
322 char *fData = strdup( inst->customDatacxx . . $ SoV1CustomNode#customData.[cxx . . $ SoMFString#`operator[]`(1f64d4776649c045).(int) index].getStringcxx . . $ SbString#getString(a9f41ea0e82d88cf).());
323 // to begin, advance fData to after the HEADER
324 fData += strlen( SO_V1_BASEKIT_FILEDATA_HEADERcxx . . $ `lib/nodekits/src/upgraders/SoV1BaseKit.c++:68:9`! );
325
326 char *newPartName, *newChildNumString;
327 int newChildNum, partNum, parentPartNum;
328 SoGroupcxx . . $ SoGroup# *parentNode;
329 SoNodecxx . . $ SoNode# *childNode;
330 SbBoolcxx . . $ SbBool# isOk;
331
332 newPartName = strtok( fData, " \n"); // first string
333 newChildNumString = strtok( NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, " \n"); // second string
334
335 // as long as we can keep reading in name/number pairs, continue...
336 while ( newPartName && newChildNumString ) {
337
338 isOk = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
339
340 // for each partName/childNumber pair, find the part,
341 // find that part's parent, and set the properly numbered child
342 // of that parent to be 'partName'
343 sscanf( newChildNumString, "%d", &newChildNum );
344
345 // find and check the partNum for this part
346 partNum = theCat->getPartNumbercxx . . $ SoV1NodekitCatalog#getPartNumber(27e5f5d7f6cb8473).( newPartNamecxx . . $ SbName#SbName(85c52e162fed56f9). );
347 if ( partNum == SO_V1_CATALOG_NAME_NOT_FOUNDcxx . . $ `lib/nodekits/include/Inventor/misc/upgraders/SoV1NodekitCatalog.h:65:9`! ) {
348 #ifdef DEBUG
349 SoDebugError::postWarning("SoV1BaseKit::interpretCustomData",
350 "node type %s wont recognize the part named %s",
351 inst->getTypeId().getName().getString(), newPartName );
352 #endif
353 isOk = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
354 }
355
356 // find and check the parentPartNum
357 if ( isOk ) {
358 parentPartNum = theCat->getParentPartNumbercxx . . $ SoV1NodekitCatalog#getParentPartNumber(27e5f5d7f6cb8473).( newPartNamecxx . . $ SbName#SbName(85c52e162fed56f9). );
359 if ( parentPartNum == SO_V1_CATALOG_NAME_NOT_FOUNDcxx . . $ `lib/nodekits/include/Inventor/misc/upgraders/SoV1NodekitCatalog.h:65:9`! ) {
360 #ifdef DEBUG
361 SoDebugError::postWarning("SoV1BaseKit::interpretCustomData",
362 "node type %s has no parent part for part named %s",
363 inst->getTypeId().getName().getString(), newPartName );
364 #endif
365 isOk = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
366 }
367 }
368
369 // make sure parent is already in the parts list!
370 if ( isOk ) {
371 if (nkp->nodeListcxx . . $ SoV1NodekitParts#nodeList.[parentPartNum] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
372 #ifdef DEBUG
373 SoDebugError::post("SoV1BaseKit::interpretCustomData",
374 "parent of node %s is not an existing node yet.",
375 newPartName );
376 #endif
377 isOk = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
378 }
379 }
380
381 // make sure parent has enough children to get the one specified
382 if ( isOk ) {
383 parentNode = (SoGroupcxx . . $ SoGroup# *) nkp->nodeListcxx . . $ SoV1NodekitParts#nodeList.[parentPartNum];
384 if ( !parentNode ||
385 newChildNum >= parentNode->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() ) {
386 #ifdef DEBUG
387 SoDebugError::post("SoV1BaseKit::interpretCustomData",
388 "parent of node %s only has %d children, but you are asking for child number %d", newPartName, parentNode->getNumChildren(), newChildNum );
389 #endif
390 isOk = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
391 }
392 }
393
394 // make sure child is of type given by the template
395 if ( isOk ) {
396 childNode = parentNode->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).( newChildNum );
397 if ( !childNode ||
398 !childNode->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( theCat->getTypecxx . . $ SoV1NodekitCatalog#getType(75a08c2672826769).( partNum ) ) ) {
399 #ifdef DEBUG
400 SoDebugError::post("SoV1BaseKit::interpretCustomData",
401 "given part not of correct type");
402 #endif
403 isOk = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
404 }
405 }
406
407 // make sure the spot isnt already taken...
408 if ( isOk ) {
409 if ( nkp->nodeListcxx . . $ SoV1NodekitParts#nodeList.[partNum] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! ) {
410 #ifdef DEBUG
411 SoDebugError::post("SoV1BaseKit::interpretCustomData",
412 " given part %s already in parts list", newPartName );
413 #endif
414 isOk = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
415 }
416 }
417
418 if ( isOk && theCat->isListcxx . . $ SoV1NodekitCatalog#isList(7ccb52b1bfe01045).( partNum ) ) {
419 const SbPListcxx . . $ SbPList# listTypes = theCatcxx . . $ SbPList#SbPList(77684fc585f5010a).->getListItemTypescxx . . $ SoV1NodekitCatalog#getListItemTypes(149b507b5392266b).( partNum );
420 SoTypecxx . . $ SoType# *babyType;
421 SoNodecxx . . $ SoNode# *theBaby;
422 SoGroupcxx . . $ SoGroup# *grp = (SoGroupcxx . . $ SoGroup# *) childNode;
423
424 for (int babyNum = 0;
425 (babyNum < grp->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).()) && (isOk == TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
426 babyNum++ ) {
427
428 theBaby = grp->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).( babyNum );
429 SbBoolcxx . . $ SbBool# foundBaby = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
430
431 for ( int j = 0;
432 (j < listTypes.getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).()) && (foundBaby == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); j++ ) {
433 babyType = (SoTypecxx . . $ SoType# *) listTypes[cxx . . $ SbPList#`operator[]`(5f9a4f363ac2f591).j];
434
435 if ( theBaby->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( *babyType ) )
436 foundBaby = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
437 }
438 if ( foundBaby == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! ) {
439 #ifdef DEBUG
440 SoDebugError::post("SoV1BaseKit::interpretCustomData",
441 " part %s is list, but children chosen node are not of the list item type", newPartName );
442 #endif
443 isOk = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
444 }
445 }
446 }
447
448 // passed every test! set that part...
449 if ( isOk ) {
450 nkp->nodeListcxx . . $ SoV1NodekitParts#nodeList.[ partNum ] = childNode;
451 }
452
453 newPartName = strtok( NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, " \n"); // first string
454 newChildNumString = strtok( NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, " \n"); // second string
455 }
456 }
457
458 ////////////////////////////////////////////////////////////////////////
459 //
460 // Description:
461 // Create the V2.0 node to replace this node
462 //
463 // Use: public
464
465 SoNodecxx . . $ SoNode# *
466 SoV1BaseKitcxx . . $ SoV1BaseKit#::createNewNodecxx . . $ SoV1BaseKit#createNewNode(37b0c20759e6fed3).()
467 //
468 ////////////////////////////////////////////////////////////////////////
469 {
470 return new SoBaseKitcxx . . $ SoBaseKit#SoBaseKit(49f6e7a06ebc5aa8).;
471 }
472
473 ////////////////////////////////////////////////////////////////////////
474 //
475 // Description:
476 // Virtual method to setUp the new node.
477 //
478 // Use: public
479
480 void
481 SoV1BaseKitcxx . . $ SoV1BaseKit#::setUpNewNodecxx . . $ SoV1BaseKit#setUpNewNode(da6c7544ccee32bd).(SoNodecxx . . $ SoNode# *newNode)
482 //
483 ////////////////////////////////////////////////////////////////////////
484 {
485 const SoV1NodekitCatalogcxx . . $ SoV1NodekitCatalog# *cat = getNodekitCatalogcxx . . $ SoV1BaseKit#getNodekitCatalog(84f18d8e1dffd288).();
486
487 SoBaseKitcxx . . $ SoBaseKit# *newKit = (SoBaseKitcxx . . $ SoBaseKit# *) newNode;
488
489 // We're going to be undoing some parent child connecions.
490 // So, just to be safe, ref every non-NULL node in the parts list,
491 // and unref them at the end...
492 int i;
493 for( i = 1; i < cat->getNumEntriescxx . . $ SoV1NodekitCatalog#getNumEntries(455f465bc33b4cdf).(); i++ ) {
494 SoNodecxx . . $ SoNode# *thePart = nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.->nodeListcxx . . $ SoV1NodekitParts#nodeList.[i];
495 if (thePart != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
496 thePart->refcxx . . $ SoBase#ref(83f5f38750778ac8).();
497 }
498
499 // Loop through all parts in the parts list.
500 // Start at 1, since part 0 in the list is 'this'
501 for( i = 1; i < cat->getNumEntriescxx . . $ SoV1NodekitCatalog#getNumEntries(455f465bc33b4cdf).(); i++ ) {
502
503 SoNodecxx . . $ SoNode# *thePart = nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.->nodeListcxx . . $ SoV1NodekitParts#nodeList.[i];
504 const SbNamecxx . . $ SbName# &theName = cat->getNamecxx . . $ SoV1NodekitCatalog#getName(e603ed4d11f0a676).( i );
505
506 // If the part is not a leaf part, (and also is non-NULL)
507 // then remove any children it may have.
508 // Why? Well, at this point, we've got all the node pointers
509 // established in the parts list, so we won't lose track of them.
510 // When we call set part in the new node, it will establish the
511 // correct locations for each part in the new kit. But we don't
512 // want to keep the old parent-child relationships that we read from
513 // file.
514 if ( thePart != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && !cat->isLeafcxx . . $ SoV1NodekitCatalog#isLeaf(7ccb52b1bfe01045).(i)) {
515 if (thePart->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( SoGroupcxx . . $ SoGroup#::getClassTypeIdcxx . . $ SoGroup#getClassTypeId(c00c150378d2b968).() )) {
516 SoGroupcxx . . $ SoGroup# *grp = (SoGroupcxx . . $ SoGroup# *) thePart;
517 while ( grp->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() > 0 ) {
518 grp->removeChildcxx . . $ SoGroup#removeChild(d4f767463ce0a6b3).(0);
519 }
520 }
521 }
522
523
524 // Attempt to just call setPart with the entry in the list...
525 if ( !tryToSetPartInNewNodecxx . . $ SoV1BaseKit#tryToSetPartInNewNode(e0744854fea54a6a).( newKit, thePart, theName ) ) {
526
527 // Okay, we couldn't just set the part.
528 // Try to do some of the special case stuff.
529 if ( !dealWithUpgradedPartcxx . . $ SoV1BaseKit#dealWithUpgradedPart(e0744854fea54a6a).( newKit, thePart, theName )) {
530 #ifdef DEBUG
531 SoDebugError::post("SoV1BaseKit::setUpNewNode",
532 "Dont know what to do with part named %s. The node is going to be ignored and lost.", theName.getString() );
533 #endif
534 }
535 }
536 }
537
538 // Unref the parts we ref'ed
539 for( i = 1; i < cat->getNumEntriescxx . . $ SoV1NodekitCatalog#getNumEntries(455f465bc33b4cdf).(); i++ ) {
540 SoNodecxx . . $ SoNode# *thePart = nodekitPartsListcxx . . $ SoV1BaseKit#nodekitPartsList.->nodeListcxx . . $ SoV1NodekitParts#nodeList.[i];
541 if (thePart != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!)
542 thePart->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).();
543 }
544
545 }
546
547
548 ////////////////////////////////////////////////////////////////////////
549 //
550 // Description:
551 // Attempt to set the given part in the new node.
552 // This will succeed if the partName exists in the newNode's catalog and
553 // the node that we are attempting to use for that part is of a legal type.
554 //
555 // Use: protected
556 //
557 SbBoolcxx . . $ SbBool#
558 SoV1BaseKitcxx . . $ SoV1BaseKit#::tryToSetPartInNewNodecxx . . $ SoV1BaseKit#tryToSetPartInNewNode(e0744854fea54a6a).( SoBaseKitcxx . . $ SoBaseKit# *newNode,
559 SoNodecxx . . $ SoNode# *newPart, const SbNamecxx . . $ SbName# &newPartName )
560 //
561 ////////////////////////////////////////////////////////////////////////
562 {
563 const SoNodekitCatalogcxx . . $ SoNodekitCatalog# *cat = newNode->getNodekitCatalogcxx . . $ SoBaseKit#getNodekitCatalog(dcbb24eea8408bf4).();
564
565 // Does newNode's catalog contain an entry called 'newPartName'?
566 int partNumber = cat->getPartNumbercxx . . $ SoNodekitCatalog#getPartNumber(27e5f5d7f6cb8473).( newPartName );
567 if ( partNumber == SO_CATALOG_NAME_NOT_FOUNDcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoNodekitCatalog.h:66:9`! ) {
568 if ( newPart != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! )
569 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
570 else
571 // Everythings okay, really, if the part we were going to give it
572 // was just NULL anyway.
573 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
574 }
575
576 // Is newPart either NULL or derived from the class given in newNode's
577 // catalog for 'newPartName'
578 const SoTypecxx . . $ SoType# &partType = cat->getTypecxx . . $ SoNodekitCatalog#getType(eb1adc4f4b160d08).( partNumber );
579 if ( newPart != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`! && newPart->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( partType ) == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! )
580 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
581
582 // If we got here, we can call setAnyPart!
583 newNode->setAnyPartcxx . . $ SoBaseKit#setAnyPart(9a61422242ad1ac7).( newPartName, newPart );
584 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
585 }
586
587 ////////////////////////////////////////////////////////////////////////
588 //
589 // Description:
590 // A virtual function that allows classes to treat parts that fail the
591 // tests of 'tryToSetPartInNewNode'
592 //
593 // For SoV1BaseKit, this means dealing with the part 'label' and
594 // dealing with any part that is a list part.
595 //
596 // Subclasses will have to do special work if, for example, a part name
597 // or part type has been changed or if a part has been removed.
598 //
599 // Use: public
600 //
601 SbBoolcxx . . $ SbBool#
602 SoV1BaseKitcxx . . $ SoV1BaseKit#::dealWithUpgradedPartcxx . . $ SoV1BaseKit#dealWithUpgradedPart(e0744854fea54a6a).( SoBaseKitcxx . . $ SoBaseKit# *newNode, SoNodecxx . . $ SoNode# *newPart,
603 const SbNamecxx . . $ SbName# &newPartName )
604 //
605 ////////////////////////////////////////////////////////////////////////
606 {
607 // If the part name is "label", let's just name the newKit
608 // "label", since the label part no longer exists and most likely
609 // this is the appropriate functionality.
610 if ( newPartName ==cxx . . $ `operator==`(1deca42c6f82b65f). "label" ) {
611 if ( !newPart->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( SoLabelcxx . . $ SoLabel#::getClassTypeIdcxx . . $ SoLabel#getClassTypeId(c00c150378d2b968).() ) )
612 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
613
614 SoLabelcxx . . $ SoLabel# *lbl = (SoLabelcxx . . $ SoLabel# *) newPart;
615 newNode->setNamecxx . . $ SoBase#setName(78e67776a82c5be1).(lbl->labelcxx . . $ SoLabel#label..getValuecxx . . $ SoSFName#getValue(96f83ea34e3884f5).());
616 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
617 }
618
619 // If the part doesn't exist in the catalog, there is nothing more
620 // we can do just here.
621 const SoNodekitCatalogcxx . . $ SoNodekitCatalog# *cat = newNode->getNodekitCatalogcxx . . $ SoBaseKit#getNodekitCatalog(dcbb24eea8408bf4).();
622 int partNumber = cat->getPartNumbercxx . . $ SoNodekitCatalog#getPartNumber(27e5f5d7f6cb8473).( newPartName );
623 if ( partNumber == SO_CATALOG_NAME_NOT_FOUNDcxx . . $ `lib/nodekits/include/Inventor/nodekits/SoNodekitCatalog.h:66:9`! )
624 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
625
626 // If the part was a list part, we've got more work to do...
627 if ( cat->isListcxx . . $ SoNodekitCatalog#isList(7ccb52b1bfe01045).( partNumber ) ) {
628 // Old lists used to be just some subclass of group with children
629 // stuck underneath.
630 // New lists are of type SoNodeKitListPart. Within this part is
631 // a container node, and below it are children of a given type.
632
633 // First, get a list from the new node.
634 SoNodeKitListPartcxx . . $ SoNodeKitListPart# *newList
635 = (SoNodeKitListPartcxx . . $ SoNodeKitListPart# *) newNode->getAnyPartcxx . . $ SoBaseKit#getAnyPart(e7d7a7aae96def2f).( newPartName, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!);
636
637 // For each child of the old list, try to set it as a child
638 // in the new list.
639 #ifdef DEBUG
640 if ( !newPart->isOfType( SoGroup::getClassTypeId() ) ) {
641 SoDebugError::post("SoV1BaseKit::dealWithUpgradedPart",
642 "the node for part %s in the old node isn't subclassed from SoGroup", newPartName.getString() );
643 return FALSE;
644 }
645 #endif
646 // Check if all the children of oldList are legal children for newList
647 SoGroupcxx . . $ SoGroup# *oldList = (SoGroupcxx . . $ SoGroup# *) newPart;
648 SbBoolcxx . . $ SbBool# allOkay = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
649 int i;
650 for ( i = 0; i < oldList->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).(); i++ ) {
651 SoNodecxx . . $ SoNode# *kid = oldList->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i);
652 if ( newList->isChildPermittedcxx . . $ SoNodeKitListPart#isChildPermitted(25d228eba4c5059a).( kid ) == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`! )
653 allOkay = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
654 }
655
656 // If the children aren't ALL okay, then don't set any. Just return
657 // FALSE and hope that a subclass will be able to deal with them.
658 if (allOkay == FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!)
659 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!;
660
661 // Move all the children from oldList to newList...
662 for ( i = 0; i < oldList->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).(); i++ ) {
663 SoNodecxx . . $ SoNode# *kid = oldList->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i);
664 newList->addChildcxx . . $ SoNodeKitListPart#addChild(da6c7544ccee32bd).( kid );
665 }
666 while( oldList->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() > 0 )
667 oldList->removeChildcxx . . $ SoGroup#removeChild(d4f767463ce0a6b3).(0);
668
669 // If the listContainer type is an SoSwitch, then copy the
670 // whichChild value into the new list.
671 if ( oldList->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).( SoSwitchcxx . . $ SoSwitch#::getClassTypeIdcxx . . $ SoSwitch#getClassTypeId(c00c150378d2b968).() )
672 && newList->getContainerTypecxx . . $ SoNodeKitListPart#getContainerType(70775439ff16cb15).().isDerivedFromcxx . . $ SoType#isDerivedFrom(1fd66475a268b64e).(
673 SoSwitchcxx . . $ SoSwitch#::getClassTypeIdcxx . . $ SoSwitch#getClassTypeId(c00c150378d2b968).())) {
674 SoSwitchcxx . . $ SoSwitch# *sw = (SoSwitchcxx . . $ SoSwitch# *) oldList;
675 // Send a string that says "whichChild x" to newList...
676 char myBuf[200];
677 sprintf( myBuf, "whichChild %d", sw->whichChildcxx . . $ SoSwitch#whichChild..getValuecxx . . $ SoSFInt32#getValue(455f465bc33b4cdf).() );
678 newList->containerSetcxx . . $ SoNodeKitListPart#containerSet(85c52e162fed56f9).( myBuf );
679 }
680 return TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!;
681 }
682
683 return FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; // don't know how to do anything yet...
684 }