VR-Forces 4.0.4 Class Documentation
include/gdb/ssAnyIntersectionsFunctor.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 ** Copyright (c) 2005 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 *********************************************************************/
00005 /*********************************************************************
00006 ** $RCSfile: ssAnyIntersectionsFunctor.h,v $ $Revision: 1.4 $ $State: Exp $
00007 *********************************************************************/
00008 #ifndef ssAnyIntersectionFunctor_H_
00009 #define ssAnyIntersectionFunctor_H_
00010 
00011 #include <vlutil/vlConfig.h> 
00012 #include "geometry/spatialSubdivision.h"
00013 #include "geometry/ssFunctor.h"
00014 
00015 #include "geometry/chrdIntRec.h"
00016 #include "gdb/gdbNode.h"
00017 #include <assert.h>
00018 
00019 //
00020 // A functor intended for use with the spatial subdivision set of classes.  It's 
00021 // primary usage is to intersect the first parameter into the second.  
00022 // 
00023 // Expected usage:
00024 // When passed to the intersection objects intersection functions, this functor 
00025 // intersects the first item into the second one.  Used primarily for intersecting the
00026 // different spatial sorted elements into their appropriate spatial subdivisions.
00027 // For an example, see the gdbNode intersecter class.
00028 // 
00029 template <typename TypeToIntersect, typename Container>
00030 class DtSsAnyIntersectionFunctor : public DtSsFunctor<TypeToIntersect, Container>
00031 {
00032 public:
00033    // Constructor
00034    DtSsAnyIntersectionFunctor();
00035 
00036    // Destructor
00037    virtual ~DtSsAnyIntersectionFunctor();
00038 
00039 private:
00040    // not implemented
00041    DtSsAnyIntersectionFunctor(const DtSsAnyIntersectionFunctor& original);   
00042    DtSsAnyIntersectionFunctor& operator=(const DtSsAnyIntersectionFunctor& original);
00043 
00044 public:
00045    // Function operator - when applied intersects the first element with the
00046    // second element.
00047    // @param itemToIntersect The item to intersect into the second parameter.
00048    // @param container The container of elements into which to intersect the first
00049    // parameter.
00050    //
00051    // @returns Always returns false as it is never done processing - it can
00052    // always continue intersecting elements.
00053    virtual bool operator()(TypeToIntersect& itemToIntersect, Container& container);
00054 
00055    virtual DtChordIntersectionRecord* intersectionRecord() const;
00056 
00057    virtual void setIntersectionRecord(DtChordIntersectionRecord* newIntersectionRecord);
00058 
00059    virtual DtGdbNode::DtIntersectRecordType intersectionRecordType() const;
00060 
00061    virtual void setIntersectionRecordType(
00062       DtGdbNode::DtIntersectRecordType& newIntersectionRecordType);
00063 
00064 
00065 private:
00066 
00067    DtChordIntersectionRecord*        myIntersectionRecord;
00068    DtGdbNode::DtIntersectRecordType myIntersectionRecordType;
00069 };
00070 
00071 
00072 //------------------------------------------------------
00073 //  INLINE METHODS
00074 //------------------------------------------------------
00075 template <typename TypeToIntersect, typename Container>
00076 DtSsAnyIntersectionFunctor<TypeToIntersect, Container>::DtSsAnyIntersectionFunctor()
00077 : DtSsFunctor<TypeToIntersect, Container>()
00078 , myIntersectionRecord(0)
00079 , myIntersectionRecordType(DtGdbNode::IRT_IPOINT)
00080 {
00081 }
00082 
00083 
00084 template <typename TypeToIntersect, typename Container>
00085 DtSsAnyIntersectionFunctor<TypeToIntersect, Container>::~DtSsAnyIntersectionFunctor()
00086 {
00087 }
00088 
00089 template <typename TypeToIntersect, typename Container>
00090 bool DtSsAnyIntersectionFunctor<TypeToIntersect, Container>::operator()
00091    (TypeToIntersect& itemToIntersect, Container& containerToIntersect) 
00092 {
00093    bool retVal = false;
00094    
00095    assert(myIntersectionRecord != 0);
00096 
00097    typename Container::iterator iter = containerToIntersect.begin();
00098    typename Container::iterator endIter = containerToIntersect.end();
00099    for (; iter != endIter, !retVal; ++iter)
00100    {
00101       if ((*iter)->intersect(itemToIntersect, *myIntersectionRecord, myIntersectionRecordType))
00102       {
00103          assert(myIntersectionRecord->intersectionFound());
00104          retVal = true;
00105       }
00106    }
00107 
00108    return retVal;
00109 }
00110 
00111 
00112 template <typename TypeToIntersect, typename Container>
00113 DtChordIntersectionRecord* 
00114 DtSsAnyIntersectionFunctor<TypeToIntersect, Container>::intersectionRecord() const
00115 {
00116    return myIntersectionRecord;
00117 }
00118 
00119 
00120 template <typename TypeToIntersect, typename Container>
00121 void DtSsAnyIntersectionFunctor<TypeToIntersect, Container>::
00122 setIntersectionRecord(DtChordIntersectionRecord* newIntersectionRecord)
00123 {
00124    assert(newIntersectionRecord != 0);
00125    myIntersectionRecord = newIntersectionRecord;
00126 }
00127 
00128 
00129 template <typename TypeToIntersect, typename Container>
00130 DtGdbNode::DtIntersectRecordType 
00131 DtSsAnyIntersectionFunctor<TypeToIntersect, Container>::intersectionRecordType() const
00132 {
00133    return myIntersectionRecordType;
00134 }
00135 
00136 template <typename TypeToIntersect, typename Container>
00137 void DtSsAnyIntersectionFunctor<TypeToIntersect, Container>::
00138 setIntersectionRecordType(DtGdbNode::DtIntersectRecordType& newIntersectionRecordType) 
00139 {  
00140    myIntersectionRecordType = newIntersectionRecordType;
00141 }
00142 
00143 #endif
00144 
00145 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)