MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoCSO/CSOProcessor/CSOIsoProcessor/CSOIsoProcessor.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00005 
00010 //----------------------------------------------------------------------------------
00011 
00012 #ifndef __CSOIsoProcessor_H
00013 #define __CSOIsoProcessor_H
00014 
00015 
00016 #include "SoCSOSystem.h"
00017 #include "CSOProcessor/CSOProcessor.h"
00018 
00019 #include <CSOTools/CSOMarchingSquares.h>
00020 #include <mlPlaneField.h>
00021 
00022 
00023 ML_START_NAMESPACE
00024 
00025 
00027 
00029 enum CSOIsoStartCondition {
00030   START_ALWAYS                    = 0, 
00031   START_HIT_LOWER_ISO_VALUE       = 1, 
00032   START_HIT_GREATER_ISO_VALUE     = 2  
00033 };
00034 
00036 
00037 static const char* SUB_TYPE_ISO_FIXED_SINGLE       = "SUB_TYPE_ISO_FIXED_SINGLE";   
00038 static const char* SUB_TYPE_ISO_INTERACTIVE_SINGLE = "SUB_TYPE_INTERACTIVE_SINGLE"; 
00039 static const char* SUB_TYPE_ISO_FIXED_ALL          = "SUB_TYPE_ISO_FIXED_ALL";      
00040 static const char* SUB_TYPE_ISO_INTERACTIVE_ALL    = "SUB_TYPE_INTERACTIVE_ALL";    
00041 
00043 
00046 class SOCSO_EXPORT CSOIsoProcessor : public CSOProcessor
00047 {
00048 
00049 public:
00050 
00052   CSOIsoProcessor();
00053 
00055   virtual void handleNotification(Field *field);
00056 
00060   virtual bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos);
00061 
00064   virtual bool needsMemoryImage();
00065 
00067   virtual void setMemoryImage(float* imageData, int sizex, int sizey, int voxelPosZ,  
00068                               const Matrix4& voxelToWorldMatrix, const Matrix4& worldToVoxelMatrix, 
00069                               View2DSliceList* slicelist);
00070 
00072   bool isCurrentlyGenerating();
00074   bool isCurrentlyEditing();
00075 
00077   virtual void resetInteractionState();
00078 
00080   virtual void triggerSetMouseCursor(SoView2D* view2d, bool shouldSetMouseCursor);
00081 
00083   virtual void activateAttachments();
00084   
00085   
00086 protected:
00087 
00089   virtual ~CSOIsoProcessor();
00090 
00091 private:
00092 
00093   /* FIELDS */
00094 
00099   PlaneField* _planeFld;
00103   IntField*   _currentSliceFld;
00110   IntField*   _currentLayoutFld;
00112   StringField* _currentLayoutStringFld;
00114   BoolField*  _useInputImageFld;
00116   BoolField* _shouldInterpolateFld;    
00118   BoolField* _useIsovalueFld;
00120   BoolField* _findAllContoursFld;
00122   FloatField* _isoValueFld;
00124   BoolField* _shouldUpdateStartPosFld;
00125   
00132   EnumField*  _startConditionFld;
00133 
00138   EnumField*  _smoothingModeFld;
00139 
00140 
00141   /* STATE VARIABLES */    
00142 
00144   CSOList* _csoList;
00145 
00147   View2DSliceList* _slicelist;
00148 
00150   float _currentHitXPos;
00152   float _currentHitYPos;
00154   float _currentHitZPos;
00156   float _storedHitXPos;
00158   float _storedHitYPos;
00160   float _storedHitZPos;
00162   int _timePoint;
00163 
00165   bool  _bUseInputImage;
00168   bool  _bUseIsoValue;
00171   bool  _bUpdateStartPos;
00173   float _isoValue;
00175   bool  _bInterpolate;
00178   bool  _bFindAllContours;
00179 
00181   CSO* _currentlyActiveCSO;
00182 
00184   bool _isGeneratingCSO;
00185 
00189   float _currentIsoValue;
00190 
00192   float* _imageSlice;
00194   int _imageSizeX;
00196   int _imageSizeY;    
00198   int _lastCurrentZ;
00199 
00201   Matrix4 _worldToVoxelMatrix;
00202 
00204   float* _view2DImg;
00206   Matrix4 _view2DWorldToVoxelMatrix;
00208   Matrix4 _optionalWorldToVoxelMatrix;
00213   TSubImage<float>  _inOptionalImg;
00215   bool            _optionalImgIsValid;
00217   PagedImage* _pImg;
00219   CSOMarchingSquares _marchingSquares;
00224   std::vector<CSOMarchingSquaresCell::vecPoint2D> _vecPositions;
00225 
00226 
00227   /* METHODS */
00228 
00230   void _setInternalStateVariables();  
00234   float _getImageValueAt(int posx, int posy);
00237   bool  _shouldCreateContour(float isovalue);
00239   bool _findIsoContour(float isoValue);
00241   void _mapVoxelToWorld(SbVec3f voxel, SbVec3f& world);
00243   void _mapVoxelToWorld(Vector3 voxel, Vector3& world);
00246   bool _fillCSO(CSO* cso, CSOMarchingSquaresCell::vecPoint2D& positions, float posZ);
00248   CSO* _addAndInitCSO();
00249 
00251   void _setInputImageSlice();
00252 
00253 
00254   ML_MODULE_CLASS_HEADER(CSOIsoProcessor);
00255 };
00256 
00258 
00259 
00260 ML_END_NAMESPACE
00261 
00262 #endif // __CSOIsoProcessor_H