00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #include <Inventor/misc/SoChildList.h>
00031 #include <Inventor/nodes/SoShape.h>
00032 #include <Inventor/nodekits/SoShapeKit.h>
00033
00034 #include "SoComplexShape.h"
00035
00036 #include <Inventor/actions/SoCallbackAction.h>
00037 #include <Inventor/actions/SoGetBoundingBoxAction.h>
00038 #include <Inventor/actions/SoPickAction.h>
00039 #include <Inventor/actions/SoGLRenderAction.h>
00040 #include <Inventor/actions/SoHandleEventAction.h>
00041 #include <Inventor/actions/SoGetMatrixAction.h>
00042
00043 SO_NODE_ABSTRACT_SOURCE(SoComplexShape);
00044
00045
00051 void
00052 SoComplexShape::initClass()
00053 {
00054
00055 SO_NODE_INIT_ABSTRACT_CLASS(SoComplexShape, SoNode, "SoNode");
00056
00057 }
00058
00062 SoComplexShape::SoComplexShape()
00063 {
00064 SO_NODE_CONSTRUCTOR(SoComplexShape);
00065 }
00066
00067
00071 SoComplexShape::~SoComplexShape()
00072 {
00073 }
00074
00078 SoChildList *SoComplexShape::getChildren() const
00079 {
00080 return children;
00081 }
00082
00083
00087 void
00088 SoComplexShape::GLRender(SoGLRenderAction *action)
00089 {
00090 SoComplexShape::doAction(action);
00091 }
00092
00096 void
00097 SoComplexShape::callback(SoCallbackAction *action)
00098 {
00099 SoComplexShape::doAction(action);
00100 }
00101
00106 void
00107 SoComplexShape::getBoundingBox(SoGetBoundingBoxAction *action)
00108 {
00109 SoComplexShape::doAction(action);
00110 }
00111
00115 void
00116 SoComplexShape::handleEvent(SoHandleEventAction *action)
00117 {
00118 SoComplexShape::doAction(action);
00119 }
00120
00124 void
00125 SoComplexShape::pick(SoPickAction *action)
00126 {
00127 SoComplexShape::doAction(action);
00128 }
00129
00139 void
00140 SoComplexShape::getMatrix(SoGetMatrixAction *action)
00141 {
00142 int numIndices;
00143 const int *indices;
00144
00145
00146
00147
00148 switch (action->getPathCode(numIndices, indices)) {
00149
00150 case SoAction::NO_PATH:
00151 case SoAction::BELOW_PATH:
00152
00153 break;
00154
00155 case SoAction::OFF_PATH:
00156 case SoAction::IN_PATH:
00157
00158
00159 SoComplexShape::doAction(action);
00160 break;
00161 }
00162 }
00163
00164
00168 void
00169 SoComplexShape::doAction(SoAction *action)
00170 {
00171
00172 if (children->getLength() == 0) generateChildren();
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197 int numIndices;
00198 const int *indices;
00199
00200
00201
00202 int lastChildIndex;
00203
00204
00205
00206
00207 if (action->getPathCode(numIndices, indices) ==
00208 SoAction::IN_PATH)
00209 lastChildIndex = indices[numIndices - 1];
00210
00211
00212 else
00213 lastChildIndex = children->getLength() - 1;
00214
00215
00216
00217
00218
00219
00220 if (action->isOfType(
00221 SoGetBoundingBoxAction::getClassTypeId())) {
00222 SoGetBoundingBoxAction *bba =
00223 (SoGetBoundingBoxAction *) action;
00224 SbVec3f totalCenter(0.0, 0.0, 0.0);
00225 int numCenters = 0;
00226
00227 for (int i = 0; i <= lastChildIndex; i++) {
00228 children->traverse(bba, i);
00229
00230
00231
00232 if (bba->isCenterSet()) {
00233 totalCenter += bba->getCenter();
00234 numCenters++;
00235 bba->resetCenter();
00236 }
00237 }
00238
00239
00240
00241 if (numCenters != 0)
00242 bba->setCenter(totalCenter / (float)numCenters, FALSE);
00243 }
00244
00245
00246 else
00247 for (int i = 0; i <= lastChildIndex; i++)
00248 children->traverse(action, i);
00249 }
00250
00251
00255 void SoComplexShape::copyContents(const SoFieldContainer *FC,
00256 SbBool copyConnection)
00257 {
00258 SoNode::copyContents(FC, copyConnection);
00259 children = ((SoComplexShape *)FC)->children;
00260 }
00261
00262