| 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.2 $ |
| 44 | | |
| 45 | | Classes: |
| 46 | | SoGroup |
| 47 | | |
| 48 | | Author(s) : Paul S. Strauss, Nick Thompson |
| 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/misc/SoChildList.h>cxx . . $ `<file>/lib/database/include/Inventor/misc/SoChildList.h`/ |
| 56 | #include <Inventor/SoDB.h>cxx . . $ `<file>/lib/database/include/Inventor/SoDB.h`/ |
| 57 | #include <Inventor/SoInput.h>cxx . . $ `<file>/lib/database/include/Inventor/SoInput.h`/ |
| 58 | #include <Inventor/SoOutput.h>cxx . . $ `<file>/lib/database/include/Inventor/SoOutput.h`/ |
| 59 | #include <Inventor/actions/SoActions.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoActions.h`/ |
| 60 | #include <Inventor/errors/SoDebugError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoDebugError.h`/ |
| 61 | #include <Inventor/errors/SoReadError.h>cxx . . $ `<file>/lib/database/include/Inventor/errors/SoReadError.h`/ |
| 62 | #include <Inventor/fields/SoFieldData.h>cxx . . $ `<file>/lib/database/include/Inventor/fields/SoFieldData.h`/ |
| 63 | #include <Inventor/nodes/SoGroup.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoGroup.h`/ |
| 64 | #include <Inventor/elements/SoCacheElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoCacheElement.h`/ |
| 65 | |
| 66 | SO_NODE_SOURCEcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:241:9`!(SoGroup); |
| 67 | |
| 68 | //////////////////////////////////////////////////////////////////////// |
| 69 | // |
| 70 | // Description: |
| 71 | // Default constructor |
| 72 | // |
| 73 | // Use: public |
| 74 | |
| 75 | SoGroupcxx . . $ SoGroup#::SoGroupcxx . . $ SoGroup#SoGroup(49f6e7a06ebc5aa8).() |
| 76 | // |
| 77 | //////////////////////////////////////////////////////////////////////// |
| 78 | { |
| 79 | childrencxx . . $ SoGroup#children. = new SoChildListcxx . . $ SoChildList#(this); |
| 80 | SO_NODE_CONSTRUCTORcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:309:9`!(SoGroup); |
| 81 | isBuiltIncxx . . $ SoFieldContainer#isBuiltIn. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 82 | } |
| 83 | |
| 84 | //////////////////////////////////////////////////////////////////////// |
| 85 | // |
| 86 | // Description: |
| 87 | // Constructor that takes approximate number of children. |
| 88 | // |
| 89 | // Use: public |
| 90 | |
| 91 | SoGroupcxx . . $ SoGroup#::SoGroupcxx . . $ SoGroup#SoGroup(d4f767463ce0a6b3).(int nChildren) |
| 92 | // |
| 93 | //////////////////////////////////////////////////////////////////////// |
| 94 | { |
| 95 | childrencxx . . $ SoGroup#children. = new SoChildListcxx . . $ SoChildList#(this, nChildren); |
| 96 | SO_NODE_CONSTRUCTORcxx . . $ `lib/database/include/Inventor/nodes/SoSubNode.h:309:9`!(SoGroup); |
| 97 | isBuiltIncxx . . $ SoFieldContainer#isBuiltIn. = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 98 | } |
| 99 | |
| 100 | //////////////////////////////////////////////////////////////////////// |
| 101 | // |
| 102 | // Description: |
| 103 | // Destructor. |
| 104 | // |
| 105 | // Use: private |
| 106 | |
| 107 | SoGroupcxx . . $ SoGroup#::~cxx . . $ SoGroup#`~SoGroup`(49f6e7a06ebc5aa8).SoGroupcxx . . $ SoGroup#() |
| 108 | // |
| 109 | //////////////////////////////////////////////////////////////////////// |
| 110 | { |
| 111 | delete childrencxx . . $ SoGroup#children.; |
| 112 | } |
| 113 | |
| 114 | //////////////////////////////////////////////////////////////////////// |
| 115 | // |
| 116 | // Description: |
| 117 | // This adds a child as the last one in the group. |
| 118 | // |
| 119 | // Use: public |
| 120 | |
| 121 | void |
| 122 | SoGroupcxx . . $ SoGroup#::addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(SoNodecxx . . $ SoNode# *child) |
| 123 | // |
| 124 | //////////////////////////////////////////////////////////////////////// |
| 125 | { |
| 126 | #ifdef DEBUG |
| 127 | if (child == NULL) { |
| 128 | SoDebugError::post("SoGroup::addChild", "NULL child node"); |
| 129 | return; |
| 130 | } |
| 131 | #endif /* DEBUG */ |
| 132 | |
| 133 | childrencxx . . $ SoGroup#children.->appendcxx . . $ SoChildList#append(da6c7544ccee32bd).(child); |
| 134 | } |
| 135 | |
| 136 | //////////////////////////////////////////////////////////////////////// |
| 137 | // |
| 138 | // Description: |
| 139 | // This inserts a child into a group so that it will have the given |
| 140 | // index. |
| 141 | // |
| 142 | // Use: public |
| 143 | |
| 144 | void |
| 145 | SoGroupcxx . . $ SoGroup#::insertChildcxx . . $ SoGroup#insertChild(de18c6a3dadfdca6).(SoNodecxx . . $ SoNode# *child, int newChildIndex) |
| 146 | // |
| 147 | //////////////////////////////////////////////////////////////////////// |
| 148 | { |
| 149 | #ifdef DEBUG |
| 150 | if (child == NULL) { |
| 151 | SoDebugError::post("SoGroup::insertChild", "NULL child node"); |
| 152 | return; |
| 153 | } |
| 154 | |
| 155 | // Make sure index is reasonable |
| 156 | if (newChildIndex < 0 || newChildIndex > getNumChildren()) { |
| 157 | SoDebugError::post("SoGroup::insertChild", |
| 158 | "Index %d is out of range %d - %d", |
| 159 | newChildIndex, 0, getNumChildren()); |
| 160 | return; |
| 161 | } |
| 162 | #endif /* DEBUG */ |
| 163 | |
| 164 | // See if adding at end |
| 165 | if (newChildIndex >= getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).()) |
| 166 | childrencxx . . $ SoGroup#children.->appendcxx . . $ SoChildList#append(da6c7544ccee32bd).(child); |
| 167 | |
| 168 | else |
| 169 | childrencxx . . $ SoGroup#children.->insertcxx . . $ SoChildList#insert(de18c6a3dadfdca6).(child, newChildIndex); |
| 170 | } |
| 171 | |
| 172 | //////////////////////////////////////////////////////////////////////// |
| 173 | // |
| 174 | // Description: |
| 175 | // Returns child with the given index |
| 176 | // |
| 177 | // Use: public |
| 178 | |
| 179 | SoNodecxx . . $ SoNode# * |
| 180 | SoGroupcxx . . $ SoGroup#::getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(int index) const |
| 181 | // |
| 182 | //////////////////////////////////////////////////////////////////////// |
| 183 | { |
| 184 | return(*childrencxx . . $ SoGroup#children.)[cxx . . $ SoNodeList#`operator[]`(fd675789997d09c2).index]; |
| 185 | } |
| 186 | |
| 187 | //////////////////////////////////////////////////////////////////////// |
| 188 | // |
| 189 | // Description: |
| 190 | // Returns number of children |
| 191 | // |
| 192 | // Use: public |
| 193 | |
| 194 | int |
| 195 | SoGroupcxx . . $ SoGroup#::getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() const |
| 196 | // |
| 197 | //////////////////////////////////////////////////////////////////////// |
| 198 | { |
| 199 | return childrencxx . . $ SoGroup#children.->getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); |
| 200 | } |
| 201 | |
| 202 | //////////////////////////////////////////////////////////////////////// |
| 203 | // |
| 204 | // Description: |
| 205 | // Returns the first index (starting with 0) of a child that |
| 206 | // matches the given node pointer, or -1 if no such child is found. |
| 207 | // |
| 208 | // Use: public |
| 209 | |
| 210 | int |
| 211 | SoGroupcxx . . $ SoGroup#::findChildcxx . . $ SoGroup#findChild(25d228eba4c5059a).(const SoNodecxx . . $ SoNode# *child) const |
| 212 | // |
| 213 | //////////////////////////////////////////////////////////////////////// |
| 214 | { |
| 215 | int i, num; |
| 216 | |
| 217 | num = getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).(); |
| 218 | |
| 219 | for (i = 0; i < num; i++) |
| 220 | if (getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i) == child) return(i); |
| 221 | |
| 222 | return(-1); |
| 223 | } |
| 224 | |
| 225 | //////////////////////////////////////////////////////////////////////// |
| 226 | // |
| 227 | // Description: |
| 228 | // Removes the child with the given index from the group. |
| 229 | // |
| 230 | // Use: public |
| 231 | |
| 232 | void |
| 233 | SoGroupcxx . . $ SoGroup#::removeChildcxx . . $ SoGroup#removeChild(d4f767463ce0a6b3).(int index) |
| 234 | // |
| 235 | //////////////////////////////////////////////////////////////////////// |
| 236 | { |
| 237 | #ifdef DEBUG |
| 238 | if (index < 0 || index >= getNumChildren()) { |
| 239 | SoDebugError::post("SoGroup::removeChild", |
| 240 | "Index %d is out of range %d - %d", |
| 241 | index, 0, getNumChildren() - 1); |
| 242 | return; |
| 243 | } |
| 244 | #endif /* DEBUG */ |
| 245 | |
| 246 | // Play it safe anyway... |
| 247 | if (index >= 0) { |
| 248 | childrencxx . . $ SoGroup#children.->removecxx . . $ SoChildList#remove(d4f767463ce0a6b3).(index); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | //////////////////////////////////////////////////////////////////////// |
| 253 | // |
| 254 | // Description: |
| 255 | // Removes all children from the group. |
| 256 | // |
| 257 | // Use: public |
| 258 | |
| 259 | void |
| 260 | SoGroupcxx . . $ SoGroup#::removeAllChildrencxx . . $ SoGroup#removeAllChildren(49f6e7a06ebc5aa8).() |
| 261 | // |
| 262 | //////////////////////////////////////////////////////////////////////// |
| 263 | { |
| 264 | childrencxx . . $ SoGroup#children.->truncatecxx . . $ SoChildList#truncate(d4f767463ce0a6b3).(0); |
| 265 | } |
| 266 | |
| 267 | //////////////////////////////////////////////////////////////////////// |
| 268 | // |
| 269 | // Description: |
| 270 | // Replaces child with given index with new child. |
| 271 | // |
| 272 | // Use: public |
| 273 | |
| 274 | void |
| 275 | SoGroupcxx . . $ SoGroup#::replaceChildcxx . . $ SoGroup#replaceChild(e27134e6ee27ace4).(int index, SoNodecxx . . $ SoNode# *newChild) |
| 276 | // |
| 277 | //////////////////////////////////////////////////////////////////////// |
| 278 | { |
| 279 | #ifdef DEBUG |
| 280 | if (index < 0 || index >= getNumChildren()) { |
| 281 | SoDebugError::post("SoGroup::replaceChild", |
| 282 | "Index %d is out of range %d - %d", |
| 283 | index, 0, getNumChildren() - 1); |
| 284 | return; |
| 285 | } |
| 286 | #endif /* DEBUG */ |
| 287 | |
| 288 | // Play it safe anyway... |
| 289 | if (index >= 0) |
| 290 | childrencxx . . $ SoGroup#children.->setcxx . . $ SoChildList#set(e27134e6ee27ace4).(index, newChild); |
| 291 | } |
| 292 | |
| 293 | //////////////////////////////////////////////////////////////////////// |
| 294 | // |
| 295 | // Description: |
| 296 | // Returns pointer to children. |
| 297 | // |
| 298 | // Use: internal |
| 299 | |
| 300 | SoChildListcxx . . $ SoChildList# * |
| 301 | SoGroupcxx . . $ SoGroup#::getChildrencxx . . $ SoGroup#getChildren(ab7c10c4b6f38fa1).() const |
| 302 | // |
| 303 | //////////////////////////////////////////////////////////////////////// |
| 304 | { |
| 305 | return childrencxx . . $ SoGroup#children.; |
| 306 | } |
| 307 | |
| 308 | //////////////////////////////////////////////////////////////////////// |
| 309 | // |
| 310 | // Description: |
| 311 | // Reads stuff into instance of SoGroup. Returns FALSE on error. |
| 312 | // This also deals with field data (if any), so this method should |
| 313 | // be useful for most subclasses of SoGroup as well. |
| 314 | // |
| 315 | // Use: protected |
| 316 | |
| 317 | SbBoolcxx . . $ SbBool# |
| 318 | SoGroupcxx . . $ SoGroup#::readInstancecxx . . $ SoGroup#readInstance(9e4ba99a4b4184f8).(SoInputcxx . . $ SoInput# *in, unsigned short flags) |
| 319 | // |
| 320 | //////////////////////////////////////////////////////////////////////// |
| 321 | { |
| 322 | SbBoolcxx . . $ SbBool# readOK = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 323 | |
| 324 | // First, turn off notification for this node |
| 325 | SbBoolcxx . . $ SbBool# saveNotify = enableNotifycxx . . $ SoFieldContainer#enableNotify(7864480464b09eea).(FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 326 | |
| 327 | // Read field info. We can't just call |
| 328 | // SoFieldContainer::readInstance() to read the fields here |
| 329 | // because we need to tell the SoFieldData that it's ok if a name |
| 330 | // is found that is not a valid field name - it could be the name |
| 331 | // of a child node. |
| 332 | SbBoolcxx . . $ SbBool# notBuiltIn; // Not used |
| 333 | readOK = getFieldDatacxx . . $ SoGroup#getFieldData(56e90abbfb485471).()->readcxx . . $ SoFieldData#read(cc8228a617223129).(in, this, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!, notBuiltIn); |
| 334 | if (!readOK) return readOK; |
| 335 | |
| 336 | // If binary BUT was written without children (which can happen |
| 337 | // if it was read as an unknown node and then written out in |
| 338 | // binary), don't try to read children: |
| 339 | if (!in->isBinarycxx . . $ SoInput#isBinary(b126dc7c1de90089).() || (flags & IS_GROUPcxx . . $ SoBase#IS_GROUP.)) |
| 340 | readOK = readChildrencxx . . $ SoGroup#readChildren(cfb31f743f00c8ca).(in); |
| 341 | |
| 342 | // Re-enable notification |
| 343 | enableNotifycxx . . $ SoFieldContainer#enableNotify(7864480464b09eea).(saveNotify); |
| 344 | |
| 345 | return readOK; |
| 346 | } |
| 347 | |
| 348 | //////////////////////////////////////////////////////////////////////// |
| 349 | // |
| 350 | // Description: |
| 351 | // Reads children into instance of SoGroup. Returns FALSE on error. |
| 352 | // |
| 353 | // Use: protected |
| 354 | |
| 355 | SbBoolcxx . . $ SbBool# |
| 356 | SoGroupcxx . . $ SoGroup#::readChildrencxx . . $ SoGroup#readChildren(cfb31f743f00c8ca).(SoInputcxx . . $ SoInput# *in) |
| 357 | // |
| 358 | //////////////////////////////////////////////////////////////////////// |
| 359 | { |
| 360 | SoBasecxx . . $ SoBase# *base; |
| 361 | SbBoolcxx . . $ SbBool# ret = TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!; |
| 362 | |
| 363 | // If reading binary, read number of children first |
| 364 | if (in->isBinarycxx . . $ SoInput#isBinary(b126dc7c1de90089).()) { |
| 365 | |
| 366 | int numToRead, i; |
| 367 | |
| 368 | if (!in->readcxx . . $ SoInput#read(795be11dee30bb15).(numToRead)) |
| 369 | ret = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 370 | |
| 371 | else { |
| 372 | for (i = 0; i < numToRead; i++) { |
| 373 | |
| 374 | if (SoBasecxx . . $ SoBase#::readcxx . . $ SoBase#read(56c2a128ec952e80).(in, base, SoNodecxx . . $ SoNode#::getClassTypeIdcxx . . $ SoNode#getClassTypeId(c00c150378d2b968).()) && |
| 375 | base != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 376 | addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).((SoNodecxx . . $ SoNode# *) base); |
| 377 | |
| 378 | // Running out of children is now an error, since the |
| 379 | // number of children in the file must be exact |
| 380 | else { |
| 381 | ret = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 382 | break; |
| 383 | } |
| 384 | } |
| 385 | // If we are reading a 1.0 file, read the GROUP_END_MARKER |
| 386 | if (ret && in->getIVVersioncxx . . $ SoInput#getIVVersion(9b8c9e39889c762c).() == 1.0f) { |
| 387 | const int GROUP_END_MARKER = -1; |
| 388 | int marker; |
| 389 | |
| 390 | // Read end marker if it is there. If not, some sort of |
| 391 | // error occurred. |
| 392 | if (! in->readcxx . . $ SoInput#read(795be11dee30bb15).(marker) || marker != GROUP_END_MARKER) |
| 393 | ret = FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!; |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | // ASCII: Read children until none left. Deal with children |
| 399 | // causing errors by adding them as is. |
| 400 | else { |
| 401 | while (TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!) { |
| 402 | ret = SoBasecxx . . $ SoBase#::readcxx . . $ SoBase#read(56c2a128ec952e80).(in, base, SoNodecxx . . $ SoNode#::getClassTypeIdcxx . . $ SoNode#getClassTypeId(c00c150378d2b968).()) && ret; |
| 403 | |
| 404 | // Add child, even if error occurred, unless there is no |
| 405 | // child to add. |
| 406 | if (base != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) |
| 407 | addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).((SoNodecxx . . $ SoNode# *) base); |
| 408 | |
| 409 | // Stop when we run out of valid children |
| 410 | else |
| 411 | break; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | return ret; |
| 416 | } |
| 417 | |
| 418 | //////////////////////////////////////////////////////////////////////// |
| 419 | // |
| 420 | // Description: |
| 421 | // Implements typical traversal. |
| 422 | // |
| 423 | // Use: extender |
| 424 | |
| 425 | void |
| 426 | SoGroupcxx . . $ SoGroup#::doActioncxx . . $ SoGroup#doAction(967167263c8a77b7).(SoActioncxx . . $ SoAction# *action) |
| 427 | // |
| 428 | //////////////////////////////////////////////////////////////////////// |
| 429 | { |
| 430 | int numIndices; |
| 431 | const int *indices; |
| 432 | |
| 433 | if (action->getPathCodecxx . . $ SoAction#getPathCode(8bed7858e06375c9).(numIndices, indices) == SoActioncxx . . $ SoAction#::IN_PATHcxx . . $ SoAction#IN_PATH.) |
| 434 | childrencxx . . $ SoGroup#children.->traversecxx . . $ SoChildList#traverse(8167277d18ca88ca).(action, 0, indices[numIndices - 1]); |
| 435 | |
| 436 | else |
| 437 | childrencxx . . $ SoGroup#children.->traversecxx . . $ SoChildList#traverse(967167263c8a77b7).(action); |
| 438 | } |
| 439 | |
| 440 | //////////////////////////////////////////////////////////////////////// |
| 441 | // |
| 442 | // Description: |
| 443 | // Does the callback action |
| 444 | // |
| 445 | // Use: extender |
| 446 | |
| 447 | void |
| 448 | SoGroupcxx . . $ SoGroup#::callbackcxx . . $ SoGroup#callback(425635c2081b81c8).(SoCallbackActioncxx . . $ SoCallbackAction# *action) |
| 449 | // |
| 450 | //////////////////////////////////////////////////////////////////////// |
| 451 | { |
| 452 | SoGroupcxx . . $ SoGroup#::doActioncxx . . $ SoGroup#doAction(967167263c8a77b7).(action); |
| 453 | } |
| 454 | |
| 455 | //////////////////////////////////////////////////////////////////////// |
| 456 | // |
| 457 | // Description: |
| 458 | // Does the GL render action |
| 459 | // |
| 460 | // Use: extender |
| 461 | |
| 462 | void |
| 463 | SoGroupcxx . . $ SoGroup#::GLRendercxx . . $ SoGroup#GLRender(5c806c737f468e18).(SoGLRenderActioncxx . . $ SoGLRenderAction# *action) |
| 464 | |
| 465 | //////////////////////////////////////////////////////////////////////// |
| 466 | { |
| 467 | int numIndices; |
| 468 | const int *indices; |
| 469 | SoActioncxx . . $ SoAction#::PathCodecxx . . $ SoAction#PathCode# pc = action->getPathCodecxx . . $ SoAction#getPathCode(8bed7858e06375c9).(numIndices, indices); |
| 470 | |
| 471 | // Perform fast-path GLRender traversal: |
| 472 | if (pc != SoActioncxx . . $ SoAction#::IN_PATHcxx . . $ SoAction#IN_PATH.) { |
| 473 | action->pushCurPathcxx . . $ SoAction#pushCurPath(49f6e7a06ebc5aa8).(); |
| 474 | for (int i = 0; i < childrencxx . . $ SoGroup#children.->getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); i++) { |
| 475 | |
| 476 | action->popPushCurPathcxx . . $ SoAction#popPushCurPath(d4f767463ce0a6b3).(i); |
| 477 | if (! action->abortNowcxx . . $ SoGLRenderAction#abortNow(b126dc7c1de90089).()) |
| 478 | ((SoNodecxx . . $ SoNode#*)(childrencxx . . $ SoGroup#children.->getcxx . . $ SbPList#get(9b392d13998dd55f).(i)))->GLRendercxx . . $ SoNode#GLRender(5c806c737f468e18).(action); |
| 479 | else |
| 480 | SoCacheElementcxx . . $ SoCacheElement#::invalidatecxx . . $ SoCacheElement#invalidate(10e5c4d2a7f63e3e).(action->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).()); |
| 481 | |
| 482 | // Stop if action has reached termination condition. (For |
| 483 | // example, search has found what it was looking for, or event |
| 484 | // was handled.) |
| 485 | if (action->hasTerminatedcxx . . $ SoAction#hasTerminated(455f465bc33b4cdf).()) |
| 486 | break; |
| 487 | } |
| 488 | action->popCurPathcxx . . $ SoAction#popCurPath(49f6e7a06ebc5aa8).(); |
| 489 | } |
| 490 | |
| 491 | else { |
| 492 | |
| 493 | // This is the same as SoChildList::traverse(), except that it |
| 494 | // checks render abort for each child |
| 495 | |
| 496 | int lastChild = indices[numIndices - 1]; |
| 497 | for (int i = 0; i <= lastChild; i++) { |
| 498 | |
| 499 | SoNodecxx . . $ SoNode# *child = (SoNodecxx . . $ SoNode# *) childrencxx . . $ SoGroup#children.->getcxx . . $ SbPList#get(9b392d13998dd55f).(i); |
| 500 | |
| 501 | if (pc == SoActioncxx . . $ SoAction#::OFF_PATHcxx . . $ SoAction#OFF_PATH. && ! child->affectsStatecxx . . $ SoNode#affectsState(455f465bc33b4cdf).()) |
| 502 | continue; |
| 503 | |
| 504 | action->pushCurPathcxx . . $ SoAction#pushCurPath(d4f767463ce0a6b3).(i); |
| 505 | if (action->getCurPathCodecxx . . $ SoAction#getCurPathCode(642470b03220c9ca).() != SoActioncxx . . $ SoAction#::OFF_PATHcxx . . $ SoAction#OFF_PATH. || |
| 506 | child->affectsStatecxx . . $ SoNode#affectsState(455f465bc33b4cdf).()) { |
| 507 | |
| 508 | if (! action->abortNowcxx . . $ SoGLRenderAction#abortNow(b126dc7c1de90089).()) |
| 509 | child->GLRendercxx . . $ SoNode#GLRender(5c806c737f468e18).(action); |
| 510 | else |
| 511 | SoCacheElementcxx . . $ SoCacheElement#::invalidatecxx . . $ SoCacheElement#invalidate(10e5c4d2a7f63e3e).(action->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).()); |
| 512 | } |
| 513 | |
| 514 | action->popCurPathcxx . . $ SoAction#popCurPath(bd6e9aa4a69af45e).(pc); |
| 515 | |
| 516 | if (action->hasTerminatedcxx . . $ SoAction#hasTerminated(455f465bc33b4cdf).()) |
| 517 | break; |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | //////////////////////////////////////////////////////////////////////// |
| 523 | // |
| 524 | // Description: |
| 525 | // Does the get bounding box action. This takes care of averaging |
| 526 | // the centers of all children to get a combined center. |
| 527 | // |
| 528 | // Use: extender |
| 529 | |
| 530 | void |
| 531 | SoGroupcxx . . $ SoGroup#::getBoundingBoxcxx . . $ SoGroup#getBoundingBox(dd7d7d7c2dd56aae).(SoGetBoundingBoxActioncxx . . $ SoGetBoundingBoxAction# *action) |
| 532 | // |
| 533 | //////////////////////////////////////////////////////////////////////// |
| 534 | { |
| 535 | SbVec3fcxx . . $ SbVec3f# totalCentercxx . . $ SbVec3f#SbVec3f(bd1040fe176e0786).(0,0,0); |
| 536 | int numCenters = 0; |
| 537 | int numIndices; |
| 538 | const int *indices; |
| 539 | int lastChild; |
| 540 | |
| 541 | if (action->getPathCodecxx . . $ SoAction#getPathCode(8bed7858e06375c9).(numIndices, indices) == SoActioncxx . . $ SoAction#::IN_PATHcxx . . $ SoAction#IN_PATH.) |
| 542 | lastChild = indices[numIndices - 1]; |
| 543 | else |
| 544 | lastChild = getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() - 1; |
| 545 | |
| 546 | for (int i = 0; i <= lastChild; i++) { |
| 547 | childrencxx . . $ SoGroup#children.->traversecxx . . $ SoChildList#traverse(8167277d18ca88ca).(action, i, i); |
| 548 | if (action->isCenterSetcxx . . $ SoGetBoundingBoxAction#isCenterSet(455f465bc33b4cdf).()) { |
| 549 | totalCenter +=cxx . . $ SbVec3f#`operator+=`(13422326b1abca17). action->getCentercxx . . $ SoGetBoundingBoxAction#getCenter(b5c384c15c94bb12).(); |
| 550 | numCenters++; |
| 551 | action->resetCentercxx . . $ SoGetBoundingBoxAction#resetCenter(49f6e7a06ebc5aa8).(); |
| 552 | } |
| 553 | } |
| 554 | // Now, set the center to be the average. Don't re-transform the |
| 555 | // average, which should already be transformed. |
| 556 | if (numCenters != 0) |
| 557 | action->setCentercxx . . $ SoGetBoundingBoxAction#setCenter(53e9a146b1159747).(totalCenter /cxx . . $ `operator/`(8301011090c64e0f). numCenters, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!); |
| 558 | } |
| 559 | |
| 560 | //////////////////////////////////////////////////////////////////////// |
| 561 | // |
| 562 | // Description: |
| 563 | // Does the handle event thing |
| 564 | // |
| 565 | // Use: extender |
| 566 | |
| 567 | void |
| 568 | SoGroupcxx . . $ SoGroup#::handleEventcxx . . $ SoGroup#handleEvent(89f4d17049d836a3).(SoHandleEventActioncxx . . $ SoHandleEventAction# *action) |
| 569 | // |
| 570 | //////////////////////////////////////////////////////////////////////// |
| 571 | { |
| 572 | SoGroupcxx . . $ SoGroup#::doActioncxx . . $ SoGroup#doAction(967167263c8a77b7).(action); |
| 573 | } |
| 574 | |
| 575 | //////////////////////////////////////////////////////////////////////// |
| 576 | // |
| 577 | // Description: |
| 578 | // Pick. |
| 579 | // |
| 580 | // Use: extender |
| 581 | |
| 582 | void |
| 583 | SoGroupcxx . . $ SoGroup#::pickcxx . . $ SoGroup#pick(7b4c6871cb3411ea).(SoPickActioncxx . . $ SoPickAction# *action) |
| 584 | // |
| 585 | //////////////////////////////////////////////////////////////////////// |
| 586 | { |
| 587 | SoGroupcxx . . $ SoGroup#::doActioncxx . . $ SoGroup#doAction(967167263c8a77b7).(action); |
| 588 | } |
| 589 | |
| 590 | //////////////////////////////////////////////////////////////////////// |
| 591 | // |
| 592 | // Description: |
| 593 | // Does search... |
| 594 | // |
| 595 | // Use: extender |
| 596 | |
| 597 | void |
| 598 | SoGroupcxx . . $ SoGroup#::searchcxx . . $ SoGroup#search(ecd330ee9b1f803b).(SoSearchActioncxx . . $ SoSearchAction# *action) |
| 599 | // |
| 600 | //////////////////////////////////////////////////////////////////////// |
| 601 | { |
| 602 | // First see if the caller is searching for this node |
| 603 | SoNodecxx . . $ SoNode#::searchcxx . . $ SoNode#search(ecd330ee9b1f803b).(action); |
| 604 | |
| 605 | // Then recurse on children if not already found |
| 606 | if (! action->isFoundcxx . . $ SoSearchAction#isFound(455f465bc33b4cdf).()) |
| 607 | SoGroupcxx . . $ SoGroup#::doActioncxx . . $ SoGroup#doAction(967167263c8a77b7).(action); |
| 608 | } |
| 609 | |
| 610 | //////////////////////////////////////////////////////////////////////// |
| 611 | // |
| 612 | // Description: |
| 613 | // Implements get matrix action. |
| 614 | // |
| 615 | // Use: extender |
| 616 | |
| 617 | void |
| 618 | SoGroupcxx . . $ SoGroup#::getMatrixcxx . . $ SoGroup#getMatrix(b69d845234b7e6ee).(SoGetMatrixActioncxx . . $ SoGetMatrixAction# *action) |
| 619 | // |
| 620 | //////////////////////////////////////////////////////////////////////// |
| 621 | { |
| 622 | int numIndices; |
| 623 | const int *indices; |
| 624 | |
| 625 | // Only need to compute matrix if group is a node in middle of |
| 626 | // current path chain or is off path chain (since the only way |
| 627 | // this could be called if it is off the chain is if the group is |
| 628 | // under a group that affects the chain). |
| 629 | |
| 630 | switch (action->getPathCodecxx . . $ SoAction#getPathCode(8bed7858e06375c9).(numIndices, indices)) { |
| 631 | |
| 632 | case SoActioncxx . . $ SoAction#::NO_PATHcxx . . $ SoAction#NO_PATH.: |
| 633 | break; |
| 634 | |
| 635 | case SoActioncxx . . $ SoAction#::IN_PATHcxx . . $ SoAction#IN_PATH.: |
| 636 | childrencxx . . $ SoGroup#children.->traversecxx . . $ SoChildList#traverse(8167277d18ca88ca).(action, 0, indices[numIndices - 1]); |
| 637 | break; |
| 638 | |
| 639 | case SoActioncxx . . $ SoAction#::BELOW_PATHcxx . . $ SoAction#BELOW_PATH.: |
| 640 | break; |
| 641 | |
| 642 | case SoActioncxx . . $ SoAction#::OFF_PATHcxx . . $ SoAction#OFF_PATH.: |
| 643 | childrencxx . . $ SoGroup#children.->traversecxx . . $ SoChildList#traverse(967167263c8a77b7).(action); |
| 644 | break; |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | //////////////////////////////////////////////////////////////////////// |
| 649 | // |
| 650 | // Description: |
| 651 | // Implements write action. |
| 652 | // |
| 653 | // Use: extender |
| 654 | |
| 655 | void |
| 656 | SoGroupcxx . . $ SoGroup#::writecxx . . $ SoGroup#write(a375a81bffae2638).(SoWriteActioncxx . . $ SoWriteAction# *action) |
| 657 | |
| 658 | // |
| 659 | //////////////////////////////////////////////////////////////////////// |
| 660 | { |
| 661 | |
| 662 | SoOutputcxx . . $ SoOutput# *out = action->getOutputcxx . . $ SoWriteAction#getOutput(daf9692406936d14).(); |
| 663 | |
| 664 | // In write-reference counting phase |
| 665 | if (out->getStagecxx . . $ SoOutput#getStage(951fc68f69ba3c5a).() == SoOutputcxx . . $ SoOutput#::COUNT_REFScxx . . $ SoOutput#COUNT_REFS.) { |
| 666 | |
| 667 | // Increment our write reference count |
| 668 | addWriteReferencecxx . . $ SoFieldContainer#addWriteReference(ef4b98cc8eef533a).(out); |
| 669 | |
| 670 | // If this is the first reference (i.e., we don't now have |
| 671 | // multiple references), also count the appropriate children |
| 672 | if (! hasMultipleWriteRefscxx . . $ SoBase#hasMultipleWriteRefs(455f465bc33b4cdf).()) |
| 673 | SoGroupcxx . . $ SoGroup#::doActioncxx . . $ SoGroup#doAction(967167263c8a77b7).(action); |
| 674 | } |
| 675 | |
| 676 | // In writing phase, we have to do some more work |
| 677 | else if (! writeHeadercxx . . $ SoBase#writeHeader(9b3bdbd0ec77c6f4).(out, TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!, FALSEcxx . . $ `lib/database/include/Inventor/SbBasic.h:79:12`!)) { |
| 678 | |
| 679 | // Write fields |
| 680 | const SoFieldDatacxx . . $ SoFieldData# *fieldData = getFieldDatacxx . . $ SoGroup#getFieldData(56e90abbfb485471).(); |
| 681 | fieldData->writecxx . . $ SoFieldData#write(3c9bfc134c31f96e).(out, this); |
| 682 | |
| 683 | // See which children to traverse |
| 684 | int i, lastChild, numIndices; |
| 685 | const int *indices; |
| 686 | if (action->getPathCodecxx . . $ SoAction#getPathCode(8bed7858e06375c9).(numIndices, indices) == SoActioncxx . . $ SoAction#::IN_PATHcxx . . $ SoAction#IN_PATH.) |
| 687 | lastChild = indices[numIndices - 1]; |
| 688 | else |
| 689 | lastChild = getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() - 1; |
| 690 | |
| 691 | int numChildren = 0; |
| 692 | for (i = 0; i <= lastChild; i++) |
| 693 | if (getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i)->shouldWritecxx . . $ SoBase#shouldWrite(b126dc7c1de90089).() > 0) |
| 694 | numChildren++; |
| 695 | |
| 696 | // If writing binary format, write out number of children |
| 697 | // that are going to be written |
| 698 | if (out->isBinarycxx . . $ SoOutput#isBinary(455f465bc33b4cdf).()) |
| 699 | out->writecxx . . $ SoOutput#write(d4f767463ce0a6b3).(numChildren); |
| 700 | |
| 701 | // In the writing stage, we can't use standard traversal, |
| 702 | // because if we are writing out one path of a path list, we |
| 703 | // might need to write out children that are not relevant to |
| 704 | // the current path (but are relevant to another path in the |
| 705 | // list). Therefore, we implement a different traversal that |
| 706 | // writes out each child that is referenced. |
| 707 | for (i = 0; i <= lastChild; i++) |
| 708 | if (getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i)->shouldWritecxx . . $ SoBase#shouldWrite(b126dc7c1de90089).()) |
| 709 | childrencxx . . $ SoGroup#children.->traversecxx . . $ SoChildList#traverse(26b22d80ec04e930).(action, i); |
| 710 | |
| 711 | // Write post-children stuff |
| 712 | writeFootercxx . . $ SoBase#writeFooter(58762e0f79576b7c).(out); |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | //////////////////////////////////////////////////////////////////////// |
| 717 | // |
| 718 | // Description: |
| 719 | // Copies the contents of the given node into this instance. |
| 720 | // |
| 721 | // Use: protected, virtual |
| 722 | |
| 723 | void |
| 724 | SoGroupcxx . . $ SoGroup#::copyContentscxx . . $ SoGroup#copyContents(502fcadd2953076).(const SoFieldContainercxx . . $ SoFieldContainer# *fromFC, SbBoolcxx . . $ SbBool# copyConnections) |
| 725 | // |
| 726 | //////////////////////////////////////////////////////////////////////// |
| 727 | { |
| 728 | // Copy the usual stuff |
| 729 | SoNodecxx . . $ SoNode#::copyContentscxx . . $ SoNode#copyContents(502fcadd2953076).(fromFC, copyConnections); |
| 730 | |
| 731 | // Copy the kids |
| 732 | const SoGroupcxx . . $ SoGroup# *fromGroup = (const SoGroupcxx . . $ SoGroup# *) fromFC; |
| 733 | for (int i = 0; i < fromGroup->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).(); i++) { |
| 734 | |
| 735 | // If this node is being copied, it must be "inside" (see |
| 736 | // SoNode::copy() for details.) Therefore, all of its children |
| 737 | // must be inside, as well. |
| 738 | SoNodecxx . . $ SoNode# *fromKid = fromGroup->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i); |
| 739 | SoNodecxx . . $ SoNode# *kidCopy = (SoNodecxx . . $ SoNode# *) findCopycxx . . $ SoFieldContainer#findCopy(764c84fe9fa40e97).(fromKid, copyConnections); |
| 740 | |
| 741 | #ifdef DEBUG |
| 742 | if (kidCopy == NULL) |
| 743 | SoDebugError::post("(internal) SoGroup::copyContents", |
| 744 | "Child %d has not been copied yet", i); |
| 745 | #endif /* DEBUG */ |
| 746 | |
| 747 | addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(kidCopy); |
| 748 | } |
| 749 | } |