00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2021 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : David Beilloin (Sep 2013) 00022 **=======================================================================*/ 00023 #ifndef _SO_IMAGE_PROCESSING_OUTPUT_H_ 00024 #define _SO_IMAGE_PROCESSING_OUTPUT_H_ 00025 00026 #include <ImageViz/SoImageViz.h> 00027 00028 #include <Inventor/engines/SoEngine.h> 00029 #include <Inventor/errors/SoDebugError.h> 00030 00031 #include <Inventor/fields/SoMFVec2f.h> 00032 #include <Inventor/fields/SoMFVec3f.h> 00033 00034 00035 #ifndef HIDDEN_FROM_DOC 00036 00040 template<class OutputFieldType, class OutputType> 00041 class ImageVizEngineOutputHelper 00042 { 00043 public: 00044 static OutputType getValue(const OutputFieldType *field) 00045 { 00046 return static_cast<OutputType> ( field->getValue() ); 00047 } 00048 }; 00049 00050 #endif// HIDDEN_FROM_DOC 00051 00052 00069 template <typename OutputFieldType, typename OutputType> 00070 class SoImageVizEngineOutput : public SoEngineOutput 00071 { 00072 public: 00073 00075 SoImageVizEngineOutput() 00076 {} 00077 00079 virtual ~SoImageVizEngineOutput() 00080 {} 00081 00083 OutputType getValue() const 00084 { 00085 assert(getContainer()!=NULL); 00086 getContainer()->evaluateWrapper(); 00087 return ImageVizEngineOutputHelper<OutputFieldType, OutputType>::getValue(&m_data); 00088 } 00089 00095 void setValue(OutputType value) 00096 { 00097 m_data.setValue( value ); 00098 } 00099 00100 SoINTERNAL private: 00102 virtual bool updateConnection() 00103 { 00104 if (isEnabled()) 00105 { 00106 SoFieldList connectedFieldList; 00107 int numConnectedField = getForwardConnections(connectedFieldList); 00108 for (int connectionIdx=0;connectionIdx<numConnectedField;++connectionIdx) 00109 { 00110 OutputFieldType* connectedField = dynamic_cast<OutputFieldType*>(connectedFieldList[connectionIdx]); 00111 if ( connectedField ) 00112 { 00113 if ( !connectedField->isReadOnly() ) 00114 connectedField->copyFrom(m_data); 00115 } 00116 #if defined(_DEBUG) 00117 else 00118 SoDebugError::post(OIV_FUNCTION,"Invalid connection Field Type."); 00119 #endif // _DEBUG 00120 } 00121 } 00122 return true; 00123 } 00124 00125 private: 00126 // Store the cached output 00127 OutputFieldType m_data; 00128 00129 friend class SoImageVizEngineOutputPrivateAccessor; 00130 }; 00131 00141 template <typename OutputFieldType, typename OutputType> 00142 class SoImageVizEngineMFieldOutput : public SoEngineOutput 00143 { 00144 public: 00145 00147 SoImageVizEngineMFieldOutput() 00148 {} 00149 00151 virtual ~SoImageVizEngineMFieldOutput() 00152 {} 00153 00155 OutputType getValue() const 00156 { 00157 assert( getContainer() != NULL ); 00158 getContainer()->evaluateWrapper(); 00159 return static_cast< OutputType>( m_data.getValues( 0 ) ); 00160 } 00161 00163 size_t getSize() const 00164 { 00165 assert( getContainer() != NULL ); 00166 getContainer()->evaluateWrapper(); 00167 return m_data.getNum(); 00168 } 00169 00175 void setValue( OutputType value, int size ) 00176 { 00177 m_data.deleteValues( 0 ); 00178 m_data.setValues( 0, size, value ); 00179 } 00180 00181 00182 SoINTERNAL private: 00184 virtual bool updateConnection() 00185 { 00186 if ( isEnabled() ) 00187 { 00188 SoFieldList connectedFieldList; 00189 int numConnectedField = getForwardConnections( connectedFieldList ); 00190 for ( int connectionIdx = 0; connectionIdx < numConnectedField; ++connectionIdx ) 00191 { 00192 OutputFieldType* connectedField = dynamic_cast<OutputFieldType*>( connectedFieldList[connectionIdx] ); 00193 if ( connectedField ) 00194 { 00195 if ( !connectedField->isReadOnly() ) 00196 connectedField->copyFrom( m_data ); 00197 } 00198 #if defined(_DEBUG) 00199 else 00200 SoDebugError::post( __FUNCTION__, "Invalid connection Field Type." ); 00201 #endif // _DEBUG 00202 } 00203 } 00204 return true; 00205 } 00206 00207 private: 00208 // Store the cached output 00209 OutputFieldType m_data; 00210 00211 friend class SoImageVizEngineMFieldOutputPrivateAccessor; 00212 }; 00213 00214 00215 #endif