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)
template<class VectorTypeT>
void subdivide (const typename std::vector< VectorTypeT > &dataIn, typename std::vector< VectorTypeT > *dataOut, UInt32 nTimes, bool close)
Construction functions


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 
) [inline]

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 }

template<class VectorTypeT>
static void subdivide ( const typename std::vector< VectorTypeT > &  dataIn,
typename std::vector< VectorTypeT > *  dataOut,
UInt32  nTimes,
bool  close 
) [inline]

Definition at line 1851 of file OSGExtrusionGeometry.cpp.

01855 {
01856     std::vector<VectorTypeT> in(dataIn), out;
01857     for(UInt32 i = 0; i < nTimes; i++)
01858     {
01859         if(i + 1 < nTimes) // still one round to go
01860         {
01861             out.clear();
01862             out.reserve(2 * (in.size() + 1));
01863             subdivide<VectorTypeT>(in, &out, closed);
01864 
01865             // swap buffers
01866             in.swap(out);
01867         }
01868         else  // final subdivision step
01869         {
01870             dataOut->clear();
01871             dataOut->reserve(2 * (in.size() + 1));
01872 
01873             // subdivide and write result directly into dataOut
01874             subdivide<VectorTypeT>(in, dataOut, closed);
01875         }
01876     }
01877 }


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 Mon Mar 17 12:02:34 2008 for OpenSG by  doxygen 1.5.5