Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGExtrusionGeometry.cpp File Reference

#include <memory>
#include <assert.h>
#include "OSGConfig.h"
#include <OSGLog.h>
#include "OSGExtrusionGeometry.h"

Go to the source code of this file.

Namespaces

namespace  osg

Functions

template<class VectorTypeT>
void subdivide (const typename std::vector< VectorTypeT > &dataIn, typename std::vector< VectorTypeT > *dataOut, bool closed)
NodePtr osg::makeExtrusion (const std::vector< Pnt2f > &crossSection, const std::vector< Quaternion > &orientation, const std::vector< Vec2f > &scale, const std::vector< Pnt3f > &spine, Real32 creaseAngle, bool beginCap, bool endCap, bool ccw, bool convex, bool buildNormal, bool buildTexCoord, UInt32 numOfSubdivision)
GeometryPtr osg::makeExtrusionGeo (const std::vector< Pnt2f > &crossSection, const std::vector< Quaternion > &orientation, const std::vector< Vec2f > &scale, const std::vector< Pnt3f > &spine, Real32 creaseAngle, bool beginCap, bool endCap, bool ccw, bool convex, bool buildNormal, bool buildTexCoord, UInt32 numSubdivs)

Variables

static osg::Char8 cvsid_cpp [] = "@(#)$Id: $"
static osg::Char8 cvsid_hpp [] = OSGEXTRUSIONGEOMETRY_HEADER_CVSID
static osg::Char8 cvsid_inl [] = OSGEXTRUSIONGEOMETRY_INLINE_CVSID


Function Documentation

template<class VectorTypeT>
static void subdivide const typename std::vector< VectorTypeT > &  dataIn,
typename std::vector< VectorTypeT > *  dataOut,
bool  closed
 

Definition at line 1762 of file OSGExtrusionGeometry.cpp.

Referenced by osg::ExtrusionSurface::refineCrossSection().

01765 {
01766     typename std::vector<VectorTypeT>::const_iterator inputIt;
01767 
01768     // just copy the data if we can't interpolate
01769     if(dataIn.size() <= 2)
01770     {
01771         // copy and bail out
01772         dataOut->assign(dataIn.begin(), dataIn.end());
01773         return;
01774     }
01775 
01776     // reset vector
01777     dataOut->clear();
01778     dataOut->reserve((2 * dataIn.size()) + 1);
01779 
01780     inputIt = dataIn.begin();
01781     dataOut->push_back(*inputIt);  // copy first vertex
01782     
01783     // If closed apply the 4pt scheme (-1/16, 9/16, 9/16, -1/16) to the first
01784     // point. In order to do this we need to wrap around in the first argument.
01785     if(closed)
01786     {
01787         //dataIn[0] = dataIn[n-1], so we need to subtract one more
01788         dataOut->push_back(apply4PtScheme<VectorTypeT>(dataIn.end() - 2,
01789                                                        inputIt,
01790                                                        inputIt + 1,
01791                                                        inputIt + 2));
01792     }
01793     // Apply 3pt scheme (3/8, 6/8, -1/8) to the first point.
01794     else
01795     {
01796         dataOut->push_back(apply3PtScheme<VectorTypeT>(inputIt,
01797                                                        inputIt + 1,
01798                                                        inputIt + 2));        
01799     }
01800     inputIt++;  // advance to next vertex
01801     
01802     
01803     // if there are more than 3 points available, we can apply the 4 point 
01804     // scheme (-1/16, 9/16, 9/16, -1/16) to all points with the exception 
01805     // of the first and the last point.
01806     if(dataIn.size() > 3)
01807     {
01808         //insert the interpolated points between inputIt and inputIt + 1
01809         for(; (inputIt + 2) != dataIn.end(); ++inputIt)
01810         {
01811             dataOut->push_back(*inputIt);
01812             dataOut->push_back(apply4PtScheme<VectorTypeT>(inputIt - 1,
01813                                                            inputIt,
01814                                                            inputIt + 1,
01815                                                            inputIt + 2));
01816         }
01817     }
01818     
01819     dataOut->push_back(*inputIt);
01820     
01821     // If closed apply the 4pt scheme (-1/16, 9/16, 9/16, -1/16) to the
01822     // points with indices (n-3, n-2, n-1, 1) (equivalent to (n-3,n-2,0,1))
01823     if(closed)
01824     {
01825         dataOut->push_back(apply4PtScheme<VectorTypeT>(dataIn.end() - 3,
01826                                                       dataIn.end() - 2,
01827                                                       dataIn.begin(),
01828                                                       dataIn.begin() + 1));
01829     }
01830     else
01831     {
01832         // Apply 3pt scheme (-1, 6, 3) by reversing the order of the 
01833         // points for the boundary and applying (3, 6, -1) 
01834         dataOut->push_back(apply3PtScheme<VectorTypeT>(dataIn.end() - 1,
01835                                                        dataIn.end() - 2,
01836                                                        dataIn.end() - 3));
01837     }
01838 
01839     // push back last input vertex
01840     dataOut->push_back(dataIn.back());
01841 }


Variable Documentation

osg ::Char8 cvsid_cpp[] = "@(#)$Id: $" [static]
 

Definition at line 1987 of file OSGExtrusionGeometry.cpp.

osg ::Char8 cvsid_hpp[] = OSGEXTRUSIONGEOMETRY_HEADER_CVSID [static]
 

Definition at line 1988 of file OSGExtrusionGeometry.cpp.

osg ::Char8 cvsid_inl[] = OSGEXTRUSIONGEOMETRY_INLINE_CVSID [static]
 

Definition at line 1989 of file OSGExtrusionGeometry.cpp.


Generated on Thu Aug 25 04:12:20 2005 for OpenSG by  doxygen 1.4.3