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

OSGStripeGraphOp.cpp

Go to the documentation of this file.
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  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 
00040 /***************************************************************************\
00041 *                             Includes                                    *
00042 \***************************************************************************/
00043 
00044 #include <OSGStripeGraphOp.h>
00045 #include <OSGGeoFunctions.h>
00046 
00047 OSG_USING_NAMESPACE
00048 
00049 /***************************************************************************\
00050  *                            Description                                  *
00051 \***************************************************************************/
00052 
00060 /***************************************************************************\
00061  *                           Instance methods                              *
00062 \***************************************************************************/
00063 
00064 /*-------------------------------------------------------------------------*\
00065  -  public                                                                 -
00066 \*-------------------------------------------------------------------------*/
00067 
00068 
00069 /*------------- constructors & destructors --------------------------------*/
00070 
00071 StripeGraphOp::StripeGraphOp(const char* name): 
00072     SingleTypeGraphOpGeo(name),
00073     _force(false),
00074     _stitch(false)
00075 {
00076 }
00077 
00078 StripeGraphOp::~StripeGraphOp(void)
00079 {
00080 }
00081 
00082 GraphOp *StripeGraphOp::create()
00083 {
00084     StripeGraphOp *inst = new StripeGraphOp();
00085     return inst;
00086 }
00087 
00088 void StripeGraphOp::setParams(const std::string params)
00089 {
00090     ParamSet ps(params);   
00091     
00092     ps("force",  _force);
00093     ps("stitch",  _stitch);
00094     
00095     std::string out = ps.getUnusedParams();
00096     if(out.length())
00097     {
00098         FWARNING(("StripeGraphOp doesn't have parameters '%s'\n.",
00099                 out.c_str()));
00100     }
00101 }
00102 
00103 std::string StripeGraphOp::usage(void)
00104 {
00105     return 
00106     "Stripe: Stripe Geometries\n"
00107     "Params: name (type, default)\n"
00108     "  force  (bool, false): force striping even if already striped\n"
00109     "  stitch (bool, false): stitch strips using degenerate triangles\n";
00110 }
00111 
00112 bool StripeGraphOp::travNodeEnter(NodePtr node)
00113 {
00114     GeometryPtr geo = GeometryPtr::dcast(node->getCore());
00115 
00116     if(geo != NullFC)
00117     {
00118         // Check if it's striped already
00119         if (!_force)
00120         {
00121             GeoPTypesPtr t = geo->getTypes();
00122             
00123             for(UInt32 i = 0; i < t->size(); ++i)
00124             {
00125                 if(t->getValue(i) == GL_TRIANGLE_STRIP)
00126                 {
00127                     return true;
00128                 }
00129             }
00130         }
00131         createSharedIndex(geo);
00132         createOptimizedPrimitives(geo, 1, true, true, 16, false, _stitch);
00133     }
00134     
00135     return true;
00136 }
00137 
00138 bool StripeGraphOp::travNodeLeave(NodePtr)
00139 {
00140     return true;
00141 }
00142 
00143 /*-------------------------------------------------------------------------*\
00144  -  protected                                                              -
00145 \*-------------------------------------------------------------------------*/

Generated on Thu Aug 25 04:11:06 2005 for OpenSG by  doxygen 1.4.3