00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef _SB_PROJECTION_
00025 #define _SB_PROJECTION_
00026 
00027 #include <Inventor/SbLinear.h>
00028 #include <Inventor/SbString.h> 
00029 
00030 #include <Inventor/STL/vector> 
00031 
00032 #if defined(_WIN32)
00033 #pragma warning( push )
00034 #pragma warning( disable: 4251 ) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
00035 #endif
00036 
00037 #define NUM_MAX_PARAMS 256
00038 #define MAX_PARAM_LENGTH 256
00039 
00040 class SoProjection;
00041 
00096 class  SbProjection
00097 {
00098 
00099 public:
00100 
00104   SbProjection();
00105 
00109   SbProjection(SoProjection *node);
00110 
00114   SbProjection(const SbProjection &proj);
00115 
00119   virtual ~SbProjection();
00120 
00124   virtual void init(){}
00125 
00129   virtual void exit(){}
00130  
00134   virtual void inverse(SbVec3f &point);
00135 
00146   virtual bool getProjectedBoundingBox(SbBox3f& bbox);
00147 
00152   void project(SbVec3f &point);
00153 
00158   void project( int numPoints, float *points);
00159 
00165   void project(int32_t numCoords, const SbVec3f *coords, SbVec3f *projectedCoords);
00166 
00170   inline SoProjection *getProjectionNode() const
00171   {return m_projection;}
00172 
00176   virtual void setParameter( int parameterId, const SbString ¶meterString );
00177 
00181   virtual void setParameter( int parameterId, const float ¶meterFloat );
00182 
00186   void setNumStringParameters( int numParameters );
00187 
00191   void setNumFloatParameters( int numParameters );
00192 
00196   int getNumStringParameters() const;
00197 
00201   int getNumFloatParameters() const;
00202 
00207   SbBool getParameter( int pos, SbString& parameter ) const;
00208 
00214   SbBool getParameter( int pos, float& parameter ) const;
00215 
00216 SoEXTENDER_Documented private:
00220   virtual void apply(SbVec3f &point);
00221 
00225   virtual void applyPreProjection( SbVec3f &point );
00226 
00230   virtual void applyPostProjection( SbVec3f &point );
00231 
00232 private:
00233 
00238   virtual void internalSetParameter( int parameterId, const SbString ¶meterString, SbBool notifyNode = TRUE, SbBool callInit = TRUE);
00239 
00244   virtual void internalSetParameter( int parameterId, const float ¶meterString, SbBool notifyNode = TRUE, SbBool callInit = TRUE);
00245 
00250   virtual void internalSetParameterIn( int parameterId, const SbString ¶meterString, SbBool notifyNode = TRUE, SbBool callInit = TRUE);
00251 
00252   
00253   void copyParams();
00254 
00255 private:
00256 
00257   
00258   void initParameters();
00259 
00260   
00261   void afterSettingParameters( SbBool notifyNode, SbBool callInit );
00262 
00263   
00264   char *m_stringParameters[NUM_MAX_PARAMS];
00265 
00266   
00267   int m_numStringParams;
00268 
00269   
00270   char *m_stringParametersIn[NUM_MAX_PARAMS];
00271 
00272   
00273   int m_numStringParamsIn;
00274 
00275   
00276   std::vector< float > m_floatParameters;
00277 
00278   
00279   void applyMatrix(SbVec3f &point);
00280 
00281   static const double deg2rad;
00282   static const double rad2deg;
00283 
00284 private:
00286   SoProjection *m_projection;
00287 };
00288 
00289 
00290 inline void SbProjection::apply(SbVec3f &)
00291 {}
00292 
00293 inline void SbProjection::inverse(SbVec3f &)
00294 {}
00295 
00296 inline void SbProjection::applyPreProjection( SbVec3f &)
00297 {}
00298 
00299 inline void SbProjection::applyPostProjection( SbVec3f &)
00300 {}
00301 
00302 inline bool SbProjection::getProjectedBoundingBox(SbBox3f& ) 
00303 { return false; }
00304 
00305 #if defined(_WIN32)
00306 #pragma warning( pop )
00307 #endif
00308 
00309 #endif 
00310 
00311 
00312