| 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 $ |
| 44 |
| |
| 45 |
| Classes: |
| 46 |
| SoProfileElement class. |
| 47 |
| |
| 48 |
| Author(s) : Paul S. Strauss, Nick Thompson, Thad Beier, |
| 49 |
| Dave Immel |
| 50 |
| |
| 51 |
______________ S I L I C O N G R A P H I C S I N C . ____________ |
| 52 |
_______________________________________________________________________ |
| 53 |
*/ |
| 54 |
|
| 55 |
#ifdef DEBUG |
| 56 |
#include <assert.h> |
| 57 |
#endif |
| 58 |
|
| 59 |
#include <Inventor/elements/SoProfileElement.h> |
| 60 |
#include <Inventor/nodes/SoProfile.h> |
| 61 |
|
| 62 |
SO_ELEMENT_SOURCE(SoProfileElement); |
| 63 |
|
| 64 |
//////////////////////////////////////////////////////////////////////// |
| 65 |
// |
| 66 |
// Description: |
| 67 |
// Destructor. |
| 68 |
// |
| 69 |
// Use: public |
| 70 |
|
| 71 |
SoProfileElement::~SoProfileElement() |
| 72 |
// |
| 73 |
//////////////////////////////////////////////////////////////////////// |
| 74 |
{ |
| 75 |
} |
| 76 |
|
| 77 |
//////////////////////////////////////////////////////////////////////// |
| 78 |
// |
| 79 |
// Description: |
| 80 |
// Initializes element. |
| 81 |
// |
| 82 |
// Use: public |
| 83 |
|
| 84 |
void |
| 85 |
SoProfileElement::init(SoState *) |
| 86 |
// |
| 87 |
//////////////////////////////////////////////////////////////////////// |
| 88 |
{ |
| 89 |
profiles.truncate(0); |
| 90 |
} |
| 91 |
|
| 92 |
//////////////////////////////////////////////////////////////////////// |
| 93 |
// |
| 94 |
// Description: |
| 95 |
// Adds the given profile to the list of profiles |
| 96 |
// |
| 97 |
// Use: public |
| 98 |
|
| 99 |
void |
| 100 |
SoProfileElement::add(SoState *state, SoProfile *profile) |
| 101 |
// |
| 102 |
//////////////////////////////////////////////////////////////////////// |
| 103 |
{ |
| 104 |
SoProfileElement *elt; |
| 105 |
|
| 106 |
elt = (SoProfileElement *) getElement(state, classStackIndex); |
| 107 |
|
| 108 |
if (elt != NULL && profile != NULL) { |
| 109 |
|
| 110 |
// append the given profile node to the list of profiles in the |
| 111 |
// element. If the directive on the profile is START_FIRST, |
| 112 |
// truncate the profile list before adding this one. |
| 113 |
if (profile->linkage.getValue() == START_FIRST) { |
| 114 |
elt->profiles.truncate(0); |
| 115 |
elt->clearNodeIds(); |
| 116 |
} |
| 117 |
elt->profiles.append(profile); |
| 118 |
elt->addNodeId(profile); |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
//////////////////////////////////////////////////////////////////////// |
| 123 |
// |
| 124 |
// Description: |
| 125 |
// Returns the current profile node |
| 126 |
// |
| 127 |
// Use: public |
| 128 |
|
| 129 |
const SoNodeList & |
| 130 |
SoProfileElement::get(SoState *state) |
| 131 |
// |
| 132 |
//////////////////////////////////////////////////////////////////////// |
| 133 |
{ |
| 134 |
const SoProfileElement *elt; |
| 135 |
elt = (const SoProfileElement *) |
| 136 |
getConstElement(state, classStackIndex); |
| 137 |
|
| 138 |
return elt->profiles; |
| 139 |
} |
| 140 |
|
| 141 |
//////////////////////////////////////////////////////////////////////// |
| 142 |
// |
| 143 |
// Description: |
| 144 |
// Override push to copy the existing profiles from the previous |
| 145 |
// set. |
| 146 |
// |
| 147 |
// Use: public |
| 148 |
|
| 149 |
void |
| 150 |
SoProfileElement::push(SoState *) |
| 151 |
// |
| 152 |
//////////////////////////////////////////////////////////////////////// |
| 153 |
{ |
| 154 |
SoProfileElement *elt; |
| 155 |
elt = (SoProfileElement *) getNextInStack(); |
| 156 |
|
| 157 |
// Rely on SoNodeList::operator = to do the right thing... |
| 158 |
profiles = elt->profiles; |
| 159 |
nodeIds = elt->nodeIds; |
| 160 |
} |
| 161 |
|
| 162 |
//////////////////////////////////////////////////////////////////////// |
| 163 |
// |
| 164 |
// Description: |
| 165 |
// Prints contents of element for debugging. |
| 166 |
// |
| 167 |
// Use: public |
| 168 |
// |
| 169 |
//////////////////////////////////////////////////////////////////////// |
| 170 |
|
| 171 |
#ifdef DEBUG |
| 172 |
void |
| 173 |
SoProfileElement::print(FILE *fp) const |
| 174 |
{ |
| 175 |
SoAccumulatedElement::print(fp); |
| 176 |
} |
| 177 |
#else /* DEBUG */ |
| 178 |
void |
| 179 |
SoProfileElement::print(FILE *) const |
| 180 |
{ |
| 181 |
} |
| 182 |
#endif /* DEBUG */ |