00001 /*---------------------------------------------------------------------------*\ 00002 * OpenSG * 00003 * * 00004 * * 00005 * Copyright(C) 2000-2002 by the OpenSG Forum * 00006 * * 00007 * www.opensg.org * 00008 * * 00009 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de * 00010 * * 00011 \*---------------------------------------------------------------------------*/ 00012 /*---------------------------------------------------------------------------*\ 00013 * License * 00014 * * 00015 * * 00016 * This library is free software; you can redistribute it and/or modify it * 00017 * under the terms of the GNU Library General Public License as published * 00018 * by the Free Software Foundation, version 2. * 00019 * * 00020 * This library is distributed in the hope that it will be useful, but * 00021 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00023 * Library General Public License for more details. * 00024 * * 00025 * You should have received a copy of the GNU Library General Public * 00026 * License along with this library; if not, write to the Free Software * 00027 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00028 * * 00029 * * 00030 \*---------------------------------------------------------------------------*/ 00031 /*---------------------------------------------------------------------------*\ 00032 * Changes * 00033 * * 00034 * * 00035 * * 00036 * * 00037 * * 00038 * * 00039 \*---------------------------------------------------------------------------*/ 00040 00041 #include <stdlib.h> 00042 #include <stdio.h> 00043 00044 #include "OSGConfig.h" 00045 00046 #include "OSGGeometry.h" 00047 00048 OSG_BEGIN_NAMESPACE 00049 00050 inline 00051 Int32 EdgeIterator::getIndex(void) const 00052 { 00053 return _edgeIndex; 00054 } 00055 00056 00061 inline 00062 UInt32 EdgeIterator::getLength(void) const 00063 { 00064 if ( getType() == GL_LINES ) 00065 return 2; 00066 else 00067 return Inherited::getLength(); 00068 } 00069 00070 00071 // Why isn't the following list of methods not implemented via macros like: 00072 // 00073 // #define getPROPERTYIndex(PROPERTY) 00074 // inline 00075 // Int32 EdgeIterator::get ## PROPERTY ## Index(Int32 which) const 00076 // { 00077 // if ( getType() == GL_LINES ) 00078 // return Inherited::get ## PROPERTY ## Index(_edgePntIndex[which]); 00079 // else 00080 // return Inherited::get ## PROPERTY ## Index(which); 00081 // } 00082 // 00083 // #define getPROPERTY(PROPERTY,PROPERTY_TYPE) 00084 // inline 00085 // PROPERTY_TYPE EdgeIterator::get ## PROPERTY ## (Int32 which) const 00086 // { 00087 // Int32 ind = get ## PROPERTY ## Index(which); 00088 // 00089 // return getGeometry()->get ## PROPERTY ## s()->getValue(ind); 00090 // } 00091 // 00092 // getPROPERTYIndex(Position) 00093 // getPROPERTY( Position,Pnt3f) 00094 // 00095 // It won't Work this way unfortunately since the TexCoordsIndex breaks 00096 // an implicit naming convention: "TexCoords3" and "TexCoordsIndex3" instead of 00097 // "TexCoords3" and "TexCoords3Index" :-/ 00098 00099 00100 inline 00101 Int32 EdgeIterator::getPositionIndex(Int32 which) const 00102 { 00103 if ( getType() == GL_LINES ) 00104 return Inherited::getPositionIndex(_edgePntIndex[which]); 00105 else 00106 return Inherited::getPositionIndex(which); 00107 } 00108 00109 inline 00110 Pnt3f EdgeIterator::getPosition(Int32 which) const 00111 { 00112 Int32 ind = getPositionIndex(which); 00113 00114 return getGeometry()->getPositions()->getValue(ind); 00115 } 00116 00117 inline 00118 Int32 EdgeIterator::getNormalIndex(Int32 which) const 00119 { 00120 if ( getType() == GL_LINES ) 00121 return Inherited::getNormalIndex(_edgePntIndex[which]); 00122 else 00123 return Inherited::getNormalIndex(which); 00124 } 00125 00126 inline 00127 Vec3f EdgeIterator::getNormal(Int32 which) const 00128 { 00129 Int32 ind = getNormalIndex(which); 00130 00131 return getGeometry()->getNormals()->getValue(ind); 00132 } 00133 00134 inline 00135 Int32 EdgeIterator::getColorIndex(Int32 which) const 00136 { 00137 if ( getType() == GL_LINES ) 00138 return Inherited::getColorIndex(_edgePntIndex[which]); 00139 else 00140 return Inherited::getColorIndex(which); 00141 } 00142 00143 inline 00144 Color3f EdgeIterator::getColor(Int32 which) const 00145 { 00146 Int32 ind = getColorIndex(which); 00147 00148 return getGeometry()->getColors()->getValue(ind); 00149 } 00150 00151 inline 00152 Int32 EdgeIterator::getSecondaryColorIndex(Int32 which) const 00153 { 00154 if ( getType() == GL_LINES ) 00155 return Inherited::getSecondaryColorIndex(_edgePntIndex[which]); 00156 else 00157 return Inherited::getSecondaryColorIndex(which); 00158 } 00159 00160 inline 00161 Color3f EdgeIterator::getSecondaryColor(Int32 which) const 00162 { 00163 Int32 ind = getSecondaryColorIndex(which); 00164 00165 return getGeometry()->getSecondaryColors()->getValue(ind); 00166 } 00167 00168 inline 00169 Int32 EdgeIterator::getTexCoordsIndex(Int32 which) const 00170 { 00171 if ( getType() == GL_LINES ) 00172 return Inherited::getTexCoordsIndex(_edgePntIndex[which]); 00173 else 00174 return Inherited::getTexCoordsIndex(which); 00175 } 00176 00177 inline 00178 Vec2f EdgeIterator::getTexCoords(Int32 which) const 00179 { 00180 Int32 ind = getTexCoordsIndex(which); 00181 00182 return getGeometry()->getTexCoords()->getValue(ind); 00183 } 00184 00185 00186 inline 00187 Int32 EdgeIterator::getTexCoordsIndex1(Int32 which) const 00188 { 00189 if ( getType() == GL_LINES ) 00190 return Inherited::getTexCoordsIndex1(_edgePntIndex[which]); 00191 else 00192 return Inherited::getTexCoordsIndex1(which); 00193 } 00194 00195 inline 00196 Vec2f EdgeIterator::getTexCoords1(Int32 which) const 00197 { 00198 Int32 ind = getTexCoordsIndex1(which); 00199 00200 return getGeometry()->getTexCoords1()->getValue(ind); 00201 } 00202 00203 inline 00204 Int32 EdgeIterator::getTexCoordsIndex2(Int32 which) const 00205 { 00206 if ( getType() == GL_LINES ) 00207 return Inherited::getTexCoordsIndex2(_edgePntIndex[which]); 00208 else 00209 return Inherited::getTexCoordsIndex2(which); 00210 } 00211 00212 inline 00213 Vec2f EdgeIterator::getTexCoords2(Int32 which) const 00214 { 00215 Int32 ind = getTexCoordsIndex2(which); 00216 00217 return getGeometry()->getTexCoords2()->getValue(ind); 00218 } 00219 00220 inline 00221 Int32 EdgeIterator::getTexCoordsIndex3(Int32 which) const 00222 { 00223 if ( getType() == GL_LINES ) 00224 return Inherited::getTexCoordsIndex3(_edgePntIndex[which]); 00225 else 00226 return Inherited::getTexCoordsIndex3(which); 00227 } 00228 00229 inline 00230 Vec2f EdgeIterator::getTexCoords3(Int32 which) const 00231 { 00232 Int32 ind = getTexCoordsIndex3(which); 00233 00234 return getGeometry()->getTexCoords3()->getValue(ind); 00235 } 00236 00237 inline 00238 Int32 EdgeIterator::getIndexIndex(Int32 which) const 00239 { 00240 if ( getType() == GL_LINES ) 00241 return Inherited::getIndexIndex(_edgePntIndex[which]); 00242 else 00243 return Inherited::getIndexIndex(which); 00244 } 00245 00246 OSG_END_NAMESPACE
1.4.3