| 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 | #define DEBUG_WRITEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:37:9`! 0 |
| 38 | |
| 39 | #include <Inventor/actions/SoSearchAction.h>cxx . . $ `<file>/lib/database/include/Inventor/actions/SoSearchAction.h`/ |
| 40 | #include <Inventor/elements/SoLazyElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoLazyElement.h`/ |
| 41 | #include <Inventor/elements/SoTextureImageElement.h>cxx . . $ `<file>/lib/database/include/Inventor/elements/SoTextureImageElement.h`/ |
| 42 | #include <Inventor/nodes/SoMaterial.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoMaterial.h`/ |
| 43 | #include <Inventor/nodes/SoSeparator.h>cxx . . $ `<file>/lib/database/include/Inventor/nodes/SoSeparator.h`/ |
| 44 | |
| 45 | #include "IfAssert.h"cxx . . $ `<file>/apps/tools/ivfix/IfAssert.h`/ |
| 46 | #include "IfBuilder.h"cxx . . $ `<file>/apps/tools/ivfix/IfBuilder.h`/ |
| 47 | #include "IfCondenser.h"cxx . . $ `<file>/apps/tools/ivfix/IfCondenser.h`/ |
| 48 | #include "IfFlattener.h"cxx . . $ `<file>/apps/tools/ivfix/IfFlattener.h`/ |
| 49 | #include "IfHolder.h"cxx . . $ `<file>/apps/tools/ivfix/IfHolder.h`/ |
| 50 | #include "IfReporter.h"cxx . . $ `<file>/apps/tools/ivfix/IfReporter.h`/ |
| 51 | #include "IfShape.h"cxx . . $ `<file>/apps/tools/ivfix/IfShape.h`/ |
| 52 | #include "IfStripper.h"cxx . . $ `<file>/apps/tools/ivfix/IfStripper.h`/ |
| 53 | |
| 54 | // All roots at Level 5 have this name so we can find them easily: |
| 55 | #define LEVEL_5_ROOT_NAMEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:55:9`! "__level5Root" |
| 56 | |
| 57 | #if DEBUG_WRITEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:37:9`! |
| 58 | #include <Inventor/actions/SoWriteAction.h> |
| 59 | #endif |
| 60 | |
| 61 | ///////////////////////////////////////////////////////////////////////////// |
| 62 | // |
| 63 | // Constructor. |
| 64 | // |
| 65 | ///////////////////////////////////////////////////////////////////////////// |
| 66 | |
| 67 | IfBuildercxx . . $ IfBuilder#::IfBuildercxx . . $ IfBuilder#IfBuilder(49f6e7a06ebc5aa8).() |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | ///////////////////////////////////////////////////////////////////////////// |
| 72 | // |
| 73 | // Destructor. |
| 74 | // |
| 75 | ///////////////////////////////////////////////////////////////////////////// |
| 76 | |
| 77 | IfBuildercxx . . $ IfBuilder#::~cxx . . $ IfBuilder#`~IfBuilder`(49f6e7a06ebc5aa8).IfBuildercxx . . $ IfBuilder#() |
| 78 | { |
| 79 | } |
| 80 | |
| 81 | ///////////////////////////////////////////////////////////////////////////// |
| 82 | // |
| 83 | // This takes a sorted IfShapeList and builds a minimal scene graph that |
| 84 | // represents it. |
| 85 | // |
| 86 | ///////////////////////////////////////////////////////////////////////////// |
| 87 | |
| 88 | SoNodecxx . . $ SoNode# * |
| 89 | IfBuildercxx . . $ IfBuilder#::buildcxx . . $ IfBuilder#build(69168a290fdce18b).(const IfShapeListcxx . . $ IfShapeList# &shapeList, SbBoolcxx . . $ SbBool# _doStrips, SbBoolcxx . . $ SbBool# _doVP, |
| 90 | SbBoolcxx . . $ SbBool# _doAnyNormals, SbBoolcxx . . $ SbBool# _doAnyTexCoords) |
| 91 | { |
| 92 | doStripscxx . . $ IfBuilder#doStrips. = _doStrips; |
| 93 | doVPcxx . . $ IfBuilder#doVP. = _doVP; |
| 94 | doAnyNormalscxx . . $ IfBuilder#doAnyNormals. = _doAnyNormals; |
| 95 | doAnyTexCoordscxx . . $ IfBuilder#doAnyTexCoords. = _doAnyTexCoords; |
| 96 | |
| 97 | ////////////////////////////////////////////////////////////////// |
| 98 | // |
| 99 | // We are going to build a 5-level scene graph. The top level (0) |
| 100 | // is just a root node. Levels 1-5 are separators under which |
| 101 | // nodes of the corresponding levels are stored, as well as the |
| 102 | // lower-level root separators. These nodes are stored only when |
| 103 | // they differ between shapes. |
| 104 | // |
| 105 | // When we are done, we will prune out any unnecessary separators |
| 106 | // at levels that do not contain differences. |
| 107 | // |
| 108 | |
| 109 | // Build the top-level root |
| 110 | rootscxx . . $ IfBuilder#roots.[0] = new SoSeparatorcxx . . $ SoSeparator#SoSeparator(49f6e7a06ebc5aa8).; |
| 111 | rootscxx . . $ IfBuilder#roots.[0]->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 112 | |
| 113 | // Build the other 5 roots |
| 114 | IfShapecxx . . $ IfShape# *shape = shapeList[cxx . . $ IfShapeList#`operator[]`(85d3550b3884708d).0]; |
| 115 | buildRootscxx . . $ IfBuilder#buildRoots(fff99ec978ee0015).(1, shape); |
| 116 | |
| 117 | // Run through the sorted list of shapes. Every time we hit a |
| 118 | // shape that differs from the previous shape at Level 1, 2, 3, or |
| 119 | // 4, we create a new root at the appropriate level and add the |
| 120 | // nodes at that level to it. |
| 121 | |
| 122 | for (int i = 1; i < shapeList.getLengthcxx . . $ IfShapeList#getLength(455f465bc33b4cdf).(); i++) { |
| 123 | |
| 124 | IfShapecxx . . $ IfShape# *shape = shapeList[cxx . . $ IfShapeList#`operator[]`(85d3550b3884708d).i]; |
| 125 | |
| 126 | // Skip over a shape that is the same as the previous one (as |
| 127 | // a result of merging) |
| 128 | if (shape == shapeList[cxx . . $ IfShapeList#`operator[]`(85d3550b3884708d).i - 1]) |
| 129 | continue; |
| 130 | |
| 131 | ASSERTcxx . . $ `apps/tools/ivfix/IfAssert.h:54:9`!(shape->differenceLevel >= 0 && shape->differenceLevel <= 5); |
| 132 | |
| 133 | if (shape->differenceLevelcxx . . $ IfShape#differenceLevel. > 0) |
| 134 | buildRootscxx . . $ IfBuilder#buildRoots(fff99ec978ee0015).(shape->differenceLevelcxx . . $ IfShape#differenceLevel., shape); |
| 135 | |
| 136 | // Always add the appropriate nodes for Level 5 |
| 137 | else |
| 138 | shape->addNodesForLevelcxx . . $ IfShape#addNodesForLevel(7b63667c02f19e96).(rootscxx . . $ IfBuilder#roots.[5], 5); |
| 139 | |
| 140 | // We are done with the nodes in this shape, so unref them to |
| 141 | // see if we can free up some memory |
| 142 | shape->clearNodescxx . . $ IfShape#clearNodes(49f6e7a06ebc5aa8).(); |
| 143 | } |
| 144 | |
| 145 | #if DEBUG_WRITEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:37:9`! |
| 146 | { |
| 147 | SoWriteAction wa; |
| 148 | wa.getOutput()->openFile("PREFLATTEN.iv"); |
| 149 | wa.apply(roots[0]); |
| 150 | } |
| 151 | #endif |
| 152 | |
| 153 | // Now replace all level-5 roots with the result of flattening, |
| 154 | // condensing, and so forth |
| 155 | replaceLevel5cxx . . $ IfBuilder#replaceLevel5(49f6e7a06ebc5aa8).(); |
| 156 | |
| 157 | #if DEBUG_WRITEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:37:9`! |
| 158 | { |
| 159 | SoWriteAction wa; |
| 160 | wa.getOutput()->openFile("PREREMOVE.iv"); |
| 161 | wa.apply(roots[0]); |
| 162 | } |
| 163 | #endif |
| 164 | |
| 165 | // Now remove any separators that have only one child |
| 166 | removeUnnecessarySeparatorscxx . . $ IfBuilder#removeUnnecessarySeparators(6550c07fb03417b6).(rootscxx . . $ IfBuilder#roots.[0], 0); |
| 167 | |
| 168 | // Get rid of the top separator if it has only one child |
| 169 | while (rootscxx . . $ IfBuilder#roots.[0]->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() == 1) { |
| 170 | SoSeparatorcxx . . $ SoSeparator# *newRoot = (SoSeparatorcxx . . $ SoSeparator# *) rootscxx . . $ IfBuilder#roots.[0]->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(0); |
| 171 | newRoot->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 172 | rootscxx . . $ IfBuilder#roots.[0]->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).(); |
| 173 | rootscxx . . $ IfBuilder#roots.[0] = newRoot; |
| 174 | |
| 175 | // If the new top root isn't really a separator, stop. (It |
| 176 | // might be a derived class.) |
| 177 | if (rootscxx . . $ IfBuilder#roots.[0]->getTypeIdcxx . . $ SoSeparator#getTypeId(70775439ff16cb15).() !=cxx . . $ SoType#`operator!=`(1fd66475a268b64e). SoSeparatorcxx . . $ SoSeparator#::getClassTypeIdcxx . . $ SoSeparator#getClassTypeId(c00c150378d2b968).()) |
| 178 | break; |
| 179 | } |
| 180 | |
| 181 | #if DEBUG_WRITEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:37:9`! |
| 182 | { |
| 183 | SoWriteAction wa; |
| 184 | wa.getOutput()->openFile("POSTREMOVE.iv"); |
| 185 | wa.apply(roots[0]); |
| 186 | } |
| 187 | #endif |
| 188 | |
| 189 | rootscxx . . $ IfBuilder#roots.[0]->unrefNoDeletecxx . . $ SoBase#unrefNoDelete(83f5f38750778ac8).(); |
| 190 | return rootscxx . . $ IfBuilder#roots.[0]; |
| 191 | } |
| 192 | |
| 193 | ///////////////////////////////////////////////////////////////////////////// |
| 194 | // |
| 195 | // Builds the roots from the given level down. |
| 196 | // |
| 197 | ///////////////////////////////////////////////////////////////////////////// |
| 198 | |
| 199 | void |
| 200 | IfBuildercxx . . $ IfBuilder#::buildRootscxx . . $ IfBuilder#buildRoots(fff99ec978ee0015).(int startLevel, IfShapecxx . . $ IfShape# *shape) |
| 201 | { |
| 202 | ASSERTcxx . . $ `apps/tools/ivfix/IfAssert.h:54:9`!(startLevel > 0 && startLevel <= 5); |
| 203 | |
| 204 | for (int level = startLevel; level <= 5; level++) { |
| 205 | |
| 206 | rootscxx . . $ IfBuilder#roots.[level] = new SoSeparatorcxx . . $ SoSeparator#SoSeparator(49f6e7a06ebc5aa8).; |
| 207 | rootscxx . . $ IfBuilder#roots.[level-1]->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(rootscxx . . $ IfBuilder#roots.[level]); |
| 208 | |
| 209 | // Add the appropriate nodes for the level |
| 210 | shape->addNodesForLevelcxx . . $ IfShape#addNodesForLevel(7b63667c02f19e96).(rootscxx . . $ IfBuilder#roots.[level], level); |
| 211 | } |
| 212 | |
| 213 | // Every time this is called, a new Level 5 root is built. Name it |
| 214 | // so we can find all of them easily later on, unless we really |
| 215 | // don't want to flatten it because the IfShape says so. |
| 216 | if (! shape->dontFlattencxx . . $ IfShape#dontFlatten.) |
| 217 | rootscxx . . $ IfBuilder#roots.[5]->setNamecxx . . $ SoBase#setName(78e67776a82c5be1).(LEVEL_5_ROOT_NAMEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:55:9`!); |
| 218 | } |
| 219 | |
| 220 | ///////////////////////////////////////////////////////////////////////////// |
| 221 | // |
| 222 | // Replaces all level-5 roots with the result of flattening. |
| 223 | // |
| 224 | ///////////////////////////////////////////////////////////////////////////// |
| 225 | |
| 226 | void |
| 227 | IfBuildercxx . . $ IfBuilder#::replaceLevel5cxx . . $ IfBuilder#replaceLevel5(49f6e7a06ebc5aa8).() |
| 228 | { |
| 229 | // Find all paths to the roots with the Level 5 name |
| 230 | SoSearchActioncxx . . $ SoSearchAction# sacxx . . $ SoSearchAction#SoSearchAction(49f6e7a06ebc5aa8).; |
| 231 | sa.setNamecxx . . $ SoSearchAction#setName(78e67776a82c5be1).(LEVEL_5_ROOT_NAMEcxx . . $ `apps/tools/ivfix/IfBuilder.c++:55:9`!); |
| 232 | sa.setInterestcxx . . $ SoSearchAction#setInterest(b27440939ca13a5b).(SoSearchActioncxx . . $ SoSearchAction#::ALLcxx . . $ SoSearchAction#ALL.); |
| 233 | sa.applycxx . . $ SoAction#apply(da6c7544ccee32bd).(rootscxx . . $ IfBuilder#roots.[0]); |
| 234 | |
| 235 | // There may not be any, depending on the shape types we found |
| 236 | int numSubGraphs = sa.getPathscxx . . $ SoSearchAction#getPaths(e5198181f61c9f38).().getLengthcxx . . $ SbPList#getLength(455f465bc33b4cdf).(); |
| 237 | |
| 238 | for (int i = 0; i < numSubGraphs; i++) { |
| 239 | |
| 240 | IfReportercxx . . $ IfReporter#::reportIndexcxx . . $ IfReporter#reportIndex(7b85637613228108).("Doing subgraph", i, numSubGraphs); |
| 241 | |
| 242 | const SoPathcxx . . $ SoPath# *path = sa.getPathscxx . . $ SoSearchAction#getPaths(e5198181f61c9f38).()[cxx . . $ SoPathList#`operator[]`(81b2b9099fcfac9c).i]; |
| 243 | SoNodecxx . . $ SoNode# *level5Root = path->getTailcxx . . $ SoPath#getTail(b794963b450d51b3).(); |
| 244 | ASSERTcxx . . $ `apps/tools/ivfix/IfAssert.h:54:9`!(path->getLength() > 1); |
| 245 | ASSERTcxx . . $ `apps/tools/ivfix/IfAssert.h:54:9`!(level5Root->getTypeId() == SoSeparator::getClassTypeId()); |
| 246 | |
| 247 | // Traverse the path with a callback action to determine if |
| 248 | // normals and texture coordinates are required |
| 249 | SbBoolcxx . . $ SbBool# doNormals, doTexCoords; |
| 250 | getFlagscxx . . $ IfBuilder#getFlags(bd8db4700868b7be).((SoPathcxx . . $ SoPath# *) path, doNormals, doTexCoords); |
| 251 | |
| 252 | // Replace the level 5 root with the result of flattening its |
| 253 | // subgraph |
| 254 | SoNodecxx . . $ SoNode# *flatRoot = flattencxx . . $ IfBuilder#flatten(4707986c6b1039e1).(path, |
| 255 | doAnyNormalscxx . . $ IfBuilder#doAnyNormals. && doNormals, |
| 256 | doAnyTexCoordscxx . . $ IfBuilder#doAnyTexCoords. && doTexCoords); |
| 257 | SoSeparatorcxx . . $ SoSeparator# *parent = (SoSeparatorcxx . . $ SoSeparator# *) path->getNodeFromTailcxx . . $ SoPath#getNodeFromTail(fd675789997d09c2).(1); |
| 258 | ASSERTcxx . . $ `apps/tools/ivfix/IfAssert.h:54:9`!(parent->getTypeId() == SoSeparator::getClassTypeId()); |
| 259 | parent->replaceChildcxx . . $ SoGroup#replaceChild(c33fb305120b01c8).(level5Root, flatRoot); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | ///////////////////////////////////////////////////////////////////////////// |
| 264 | // |
| 265 | // Traverses the given path with a callback action to determine if |
| 266 | // normals and texture coordinates are required for shapes in it. |
| 267 | // |
| 268 | ///////////////////////////////////////////////////////////////////////////// |
| 269 | |
| 270 | void |
| 271 | IfBuildercxx . . $ IfBuilder#::getFlagscxx . . $ IfBuilder#getFlags(bd8db4700868b7be).(SoPathcxx . . $ SoPath# *path, SbBoolcxx . . $ SbBool# &doNormals, SbBoolcxx . . $ SbBool# &doTexCoords) |
| 272 | { |
| 273 | // The callback will store the flag values in this array, which we |
| 274 | // pass in as user data |
| 275 | SbBoolcxx . . $ SbBool# flags[2]; |
| 276 | |
| 277 | SoCallbackActioncxx . . $ SoCallbackAction# cacxx . . $ SoCallbackAction#SoCallbackAction(49f6e7a06ebc5aa8).; |
| 278 | ca.addPreTailCallbackcxx . . $ SoCallbackAction#addPreTailCallback(44a3ba4006a23a06).(flagCBcxx . . $ IfBuilder#flagCB(6eea413111466577)., flags); |
| 279 | ca.applycxx . . $ SoAction#apply(eed4dbbaf0eca0f1).(path); |
| 280 | |
| 281 | // Access the stored flags |
| 282 | doNormals = flags[0]; |
| 283 | doTexCoords = flags[1]; |
| 284 | } |
| 285 | |
| 286 | ///////////////////////////////////////////////////////////////////////////// |
| 287 | // |
| 288 | // This is called through the callback. |
| 289 | // |
| 290 | ///////////////////////////////////////////////////////////////////////////// |
| 291 | |
| 292 | void |
| 293 | IfBuildercxx . . $ IfBuilder#::setFlagscxx . . $ IfBuilder#setFlags(1a3c565e6bf43e7f).(SoCallbackActioncxx . . $ SoCallbackAction# *cba, SbBoolcxx . . $ SbBool# *flags) |
| 294 | { |
| 295 | // Do normals only if lighting is on |
| 296 | flags[0] = (SoLazyElementcxx . . $ SoLazyElement#::getLightModelcxx . . $ SoLazyElement#getLightModel(fec557bbb5044c9b).(cba->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).()) == |
| 297 | SoLazyElementcxx . . $ SoLazyElement#::PHONGcxx . . $ SoLazyElement#PHONG.); |
| 298 | |
| 299 | // Do texture coordinates only if there is a texture |
| 300 | SbVec2scxx . . $ SbVec2s# scxx . . $ SbVec2s#SbVec2s(49f6e7a06ebc5aa8).; |
| 301 | int nc, wrapS, wrapT, model; |
| 302 | SbColorcxx . . $ SbColor# blendColorcxx . . $ SbColor#SbColor(49f6e7a06ebc5aa8).; |
| 303 | flags[1] = (SoTextureImageElementcxx . . $ SoTextureImageElement#::getcxx . . $ SoTextureImageElement#get(461dc020ceac1ded).(cba->getStatecxx . . $ SoAction#getState(5c8eb8fe6550a03).(), s, nc, |
| 304 | wrapS, wrapT, |
| 305 | model, blendColor) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 306 | } |
| 307 | |
| 308 | ///////////////////////////////////////////////////////////////////////////// |
| 309 | // |
| 310 | // Flattens the subgraph at the tail of the given path, returning |
| 311 | // the resulting graph. |
| 312 | // |
| 313 | ///////////////////////////////////////////////////////////////////////////// |
| 314 | |
| 315 | SoNodecxx . . $ SoNode# * |
| 316 | IfBuildercxx . . $ IfBuilder#::flattencxx . . $ IfBuilder#flatten(4707986c6b1039e1).(const SoPathcxx . . $ SoPath# *path, SbBoolcxx . . $ SbBool# doNormals, SbBoolcxx . . $ SbBool# doTexCoords) |
| 317 | { |
| 318 | // Copy all properties from higher in the path to this root, just |
| 319 | // in case the subgraph at the tail needs them. Specifically, |
| 320 | // SoShapeHints nodes that are higher up will affect the triangle |
| 321 | // generation, so we need to make sure they are included. |
| 322 | SoSeparatorcxx . . $ SoSeparator# *root = collectObjectcxx . . $ IfBuilder#collectObject(3eccb87d01cfbfd7).(path); |
| 323 | root->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 324 | |
| 325 | // Create a IfHolder to hold everything |
| 326 | IfHoldercxx . . $ IfHolder# *holder = new IfHoldercxx . . $ IfHolder#IfHolder(3a44c4d05320ac8).(root, doStripscxx . . $ IfBuilder#doStrips., doNormals, doTexCoords); |
| 327 | root->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).(); |
| 328 | |
| 329 | // Flatten to produce triangles |
| 330 | |
| 331 | IfReportercxx . . $ IfReporter#::startReportcxx . . $ IfReporter#startReport(34d26762b42c433a).(" Flattening", TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 332 | IfFlattenercxx . . $ IfFlattener# *flattener = new IfFlattenercxx . . $ IfFlattener#; |
| 333 | flattener->flattencxx . . $ IfFlattener#flatten(405e200fcf6cafee).(holder); |
| 334 | delete flattener; |
| 335 | IfReportercxx . . $ IfReporter#::finishReportcxx . . $ IfReporter#finishReport(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 336 | |
| 337 | IfReportercxx . . $ IfReporter#::reportHoldercxx . . $ IfReporter#reportHolder(141f167c65d50288).(" After flattening", holder); |
| 338 | |
| 339 | // Condense the result |
| 340 | IfReportercxx . . $ IfReporter#::startReportcxx . . $ IfReporter#startReport(34d26762b42c433a).(" Condensing", TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 341 | IfCondensercxx . . $ IfCondenser# *condenser = new IfCondensercxx . . $ IfCondenser#; |
| 342 | condenser->condensecxx . . $ IfCondenser#condense(405e200fcf6cafee).(holder); |
| 343 | delete condenser; |
| 344 | IfReportercxx . . $ IfReporter#::finishReportcxx . . $ IfReporter#finishReport(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 345 | |
| 346 | IfReportercxx . . $ IfReporter#::reportHoldercxx . . $ IfReporter#reportHolder(141f167c65d50288).(" After condensing", holder); |
| 347 | |
| 348 | if (doStripscxx . . $ IfBuilder#doStrips.) { |
| 349 | // Produce better triangle strips |
| 350 | IfReportercxx . . $ IfReporter#::startReportcxx . . $ IfReporter#startReport(34d26762b42c433a).(" Stripping ", TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 351 | IfStrippercxx . . $ IfStripper# *stripper = new IfStrippercxx . . $ IfStripper#; |
| 352 | stripper->stripcxx . . $ IfStripper#strip(405e200fcf6cafee).(holder); |
| 353 | delete stripper; |
| 354 | IfReportercxx . . $ IfReporter#::finishReportcxx . . $ IfReporter#finishReport(d4f767463ce0a6b3).(TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!); |
| 355 | |
| 356 | IfReportercxx . . $ IfReporter#::reportHoldercxx . . $ IfReporter#reportHolder(141f167c65d50288).(" After stripping ", holder); |
| 357 | } |
| 358 | |
| 359 | if (doVPcxx . . $ IfBuilder#doVP.) { |
| 360 | // Find the last material in the object |
| 361 | int i; |
| 362 | for (i = root->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() - 1; i >= 0; i--) { |
| 363 | if (root->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i)->isOfTypecxx . . $ SoBase#isOfType(1fd66475a268b64e).(SoMaterialcxx . . $ SoMaterial#::getClassTypeIdcxx . . $ SoMaterial#getClassTypeId(c00c150378d2b968).())) |
| 364 | break; |
| 365 | } |
| 366 | SoMaterialcxx . . $ SoMaterial# *mtl = (i >= 0 ? (SoMaterialcxx . . $ SoMaterial# *) root->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i) : NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 367 | holder->convertToVertexPropertycxx . . $ IfHolder#convertToVertexProperty(abe752e5f4ec62b8).(mtl); |
| 368 | } |
| 369 | |
| 370 | SoNodecxx . . $ SoNode# *result = holder->rootcxx . . $ IfHolder#root.; |
| 371 | result->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 372 | delete holder; |
| 373 | result->unrefNoDeletecxx . . $ SoBase#unrefNoDelete(83f5f38750778ac8).(); |
| 374 | |
| 375 | return result; |
| 376 | } |
| 377 | |
| 378 | ///////////////////////////////////////////////////////////////////////////// |
| 379 | // |
| 380 | // Collects all properties along the given path (above the tail) |
| 381 | // and returns a separator-rooted graph that contains all of them |
| 382 | // and the tail of the path. |
| 383 | // |
| 384 | ///////////////////////////////////////////////////////////////////////////// |
| 385 | |
| 386 | SoSeparatorcxx . . $ SoSeparator# * |
| 387 | IfBuildercxx . . $ IfBuilder#::collectObjectcxx . . $ IfBuilder#collectObject(3eccb87d01cfbfd7).(const SoPathcxx . . $ SoPath# *path) |
| 388 | { |
| 389 | // Create a separator to hold everything |
| 390 | SoSeparatorcxx . . $ SoSeparator# *root = new SoSeparatorcxx . . $ SoSeparator#SoSeparator(49f6e7a06ebc5aa8).; |
| 391 | root->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 392 | |
| 393 | // Traverse all nodes along the path. They should all be separators. |
| 394 | int numAboveTail = path->getLengthcxx . . $ SoPath#getLength(455f465bc33b4cdf).() - 1; |
| 395 | for (int i = 0; i < numAboveTail; i++) { |
| 396 | ASSERTcxx . . $ `apps/tools/ivfix/IfAssert.h:54:9`!(path->getNode(i)->isOfType(SoSeparator::getClassTypeId())); |
| 397 | |
| 398 | SoSeparatorcxx . . $ SoSeparator# *sep = (SoSeparatorcxx . . $ SoSeparator# *) path->getNodecxx . . $ SoPath#getNode(fd675789997d09c2).(i); |
| 399 | |
| 400 | int nextIndexInPath = path->getIndexcxx . . $ SoPath#getIndex(7ccb52b1bfe01045).(i+1); |
| 401 | |
| 402 | for (int j = 0; j < nextIndexInPath; j++) { |
| 403 | SoNodecxx . . $ SoNode# *node = sep->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(j); |
| 404 | if (node->affectsStatecxx . . $ SoNode#affectsState(455f465bc33b4cdf).()) |
| 405 | root->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(node); |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | root->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(path->getTailcxx . . $ SoPath#getTail(b794963b450d51b3).()); |
| 410 | |
| 411 | root->unrefNoDeletecxx . . $ SoBase#unrefNoDelete(83f5f38750778ac8).(); |
| 412 | return root; |
| 413 | } |
| 414 | |
| 415 | ///////////////////////////////////////////////////////////////////////////// |
| 416 | // |
| 417 | // Recursive procedure that removes any separators that have only one |
| 418 | // child. |
| 419 | // |
| 420 | ///////////////////////////////////////////////////////////////////////////// |
| 421 | |
| 422 | void |
| 423 | IfBuildercxx . . $ IfBuilder#::removeUnnecessarySeparatorscxx . . $ IfBuilder#removeUnnecessarySeparators(6550c07fb03417b6).(SoSeparatorcxx . . $ SoSeparator# *root, int level) |
| 424 | { |
| 425 | // If the last child is a separator, move its children here and |
| 426 | // remove it. |
| 427 | |
| 428 | int curLevel = level; |
| 429 | while (TRUEcxx . . $ `lib/database/include/Inventor/SbBasic.h:80:12`!) { |
| 430 | |
| 431 | SoNodecxx . . $ SoNode# *lastKid = root->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(root->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() - 1); |
| 432 | |
| 433 | if (lastKid->getTypeIdcxx . . $ SoBase#getTypeId(70775439ff16cb15).() ==cxx . . $ SoType#`operator==`(1fd66475a268b64e). SoSeparatorcxx . . $ SoSeparator#::getClassTypeIdcxx . . $ SoSeparator#getClassTypeId(c00c150378d2b968).()) { |
| 434 | |
| 435 | // A Level 2 separator should NOT be removed unless there |
| 436 | // is no camera under its Level 1 separator. This keeps |
| 437 | // caching ok under the camera. |
| 438 | if (curLevel == 1 && root->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() > 1) |
| 439 | break; |
| 440 | |
| 441 | SoSeparatorcxx . . $ SoSeparator# *kidSep = (SoSeparatorcxx . . $ SoSeparator# *) lastKid; |
| 442 | |
| 443 | // Remove the kid from the root |
| 444 | kidSep->refcxx . . $ SoBase#ref(83f5f38750778ac8).(); |
| 445 | root->removeChildcxx . . $ SoGroup#removeChild(d4f767463ce0a6b3).(root->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).() - 1); |
| 446 | |
| 447 | // Move the children |
| 448 | for (int i = 0; i < kidSep->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).(); i++) |
| 449 | root->addChildcxx . . $ SoGroup#addChild(da6c7544ccee32bd).(kidSep->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i)); |
| 450 | |
| 451 | kidSep->unrefcxx . . $ SoBase#unref(83f5f38750778ac8).(); |
| 452 | } |
| 453 | else |
| 454 | break; |
| 455 | |
| 456 | curLevel++; |
| 457 | } |
| 458 | |
| 459 | // Recurse on the children |
| 460 | for (int i = 0; i < root->getNumChildrencxx . . $ SoGroup#getNumChildren(455f465bc33b4cdf).(); i++) { |
| 461 | SoNodecxx . . $ SoNode# *kid = root->getChildcxx . . $ SoGroup#getChild(fd675789997d09c2).(i); |
| 462 | if (kid->getTypeIdcxx . . $ SoBase#getTypeId(70775439ff16cb15).() ==cxx . . $ SoType#`operator==`(1fd66475a268b64e). SoSeparatorcxx . . $ SoSeparator#::getClassTypeIdcxx . . $ SoSeparator#getClassTypeId(c00c150378d2b968).()) |
| 463 | removeUnnecessarySeparatorscxx . . $ IfBuilder#removeUnnecessarySeparators(6550c07fb03417b6).((SoSeparatorcxx . . $ SoSeparator# *) kid, level + 1); |
| 464 | } |
| 465 | } |