MeVisLabToolboxReference
MeVisLab/Standard/Sources/Inventor/SoCSO/CSOProcessor/CSOLiveWireProcessor/CSOLiveWireProcessor.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00005 
00010 //----------------------------------------------------------------------------------
00011 
00012 #ifndef __CSOLiveWireProcessor_H
00013 #define __CSOLiveWireProcessor_H
00014 
00015 
00016 #include "SoCSOSystem.h"
00017 #include "CSOProcessor/CSOProcessor.h"
00018 #include <mlPlaneField.h>
00019 
00020 #include "CSOLiveWireGraph.h"
00021 
00022 
00023 ML_START_NAMESPACE
00024 
00026 
00028 enum CSOLiveWireFinishingMode {
00029   CSO_LIVE_WIRE_FINISH_ON_DOUBLE_CLICK = 0, 
00030   CSO_LIVE_WIRE_FINISH_ON_DISTANCE     = 1  
00031 };
00032 
00034 
00036 enum SliceErrorHandlingMode {
00037   CSO_SLICE_ERROR_HANDLING_REMOVE_CSO            = 0, 
00038   CSO_SLICE_ERROR_HANDLING_REMOVE_LAST_SEEDPOINT = 1, 
00039   CSO_SLICE_ERROR_HANDLING_PRINT_WARNING         = 2  
00040 };
00041 
00043 
00046 class SOCSO_EXPORT CSOLiveWireProcessor : public CSOProcessor
00047 {
00048   
00049 public:
00050 
00052   CSOLiveWireProcessor();
00053 
00056   virtual bool process(CSOEvalEventView2DInfos view2DInfos, CSOEvalEventCSOInfos csoInfos);
00057  
00060   virtual bool needsMemoryImage();
00061 
00063   virtual void setMemoryImage(float* imageData, int sizex, int sizey, int voxelPosZ,  
00064                               const Matrix4& voxelToWorldMatrix, const Matrix4& worldToVoxelMatrix, 
00065                               View2DSliceList* slicelist);
00066 
00068   virtual bool isCurrentlyGenerating();
00070   virtual bool isCurrentlyEditing();
00072   virtual bool couldCloseCSO();
00074   virtual void resetInteractionState();
00076   virtual void triggerSetMouseCursor(SoView2D* view2d, bool shouldSetMouseCursor);
00077     
00078   
00079 protected:
00080 
00082   virtual ~CSOLiveWireProcessor();
00084   virtual void activateAttachments();
00086   virtual void handleNotification(Field* field);
00087 
00088 private:
00089 
00090   /* FIELDS */
00091 
00096   PlaneField* _planeFld;
00100   IntField*   _currentSliceFld;
00107   IntField*   _currentLayoutFld;
00109   StringField* _currentLayoutStringFld;
00111   BoolField*  _useInputImageFld;
00113   BoolField*  _useInputImageCostsFld;
00115   EnumField* _finishingModeFld;
00118   IntField* _draggingToleranceFld;
00120   BoolField* _useFinishingDistanceFld;
00124   FloatField* _finishingDistanceFld;
00127   BoolField* _generateClosedCSOFld;
00133   EnumField* _multipleSliceCSOErrorHandlingModeFld;
00136   BoolField* _isCurrentlyGeneratingFld;
00141   EnumField*  _smoothingModeFld;
00143   IntField* _smoothingAmountFld;
00144 
00146   EnumField* _neighborhoodModeFld;
00147 
00149   BoolField* _usePathCostThresholdFld;
00151   FloatField* _pathCostThresholdFld;
00152 
00153 
00154   FloatField* _weightGradientFld;
00156   FloatField* _weightLaplacianFld;
00158   FloatField* _weightDirectionalFld;
00159 
00160   /* MEMBER VARIABLES */
00161 
00163   CSOLiveWireGraph* _liveWireGraph;
00164 
00166   CSOList* _csoList;
00167 
00169   float _currentHitXPos;
00171   float _currentHitYPos;
00173   float _currentHitZPos;
00175   float _lastRecentHitXPos;
00177   float _lastRecentHitYPos;
00179   float _lastRecentHitZPos;
00181   float _startHitXPos;
00183   float _startHitYPos;
00185   float _startHitZPos;
00186 
00188   int _timePoint;
00189 
00191   CSO* _currentlyActiveCSO;
00193   CSOSeedPoint* _currentlyActiveSeedPoint;
00195   CSOPathPoints* _currentlyActivePathPoints;
00196 
00201   std::vector<Vector3>_draggedPositions;
00202 
00204   View2DSliceList* _slicelist;
00205 
00207   SoView2D* _lastCurrentView2D;
00208 
00210   int _lastCurrentZ;
00211 
00213   bool _isMovingSeedPoint;
00215   bool _isGeneratingCSO;
00217   bool _isDrawingInMotion;
00219   bool _couldCloseCurrentCSO;
00220 
00222   bool _bUseInputImage;
00223 
00226   bool _bUseInputCosts;
00227 
00229   float* _imageSlice;
00231   unsigned int _imageSizeX;
00233   unsigned int _imageSizeY;
00235   Matrix4 _worldToVoxelMatrix;
00236 
00238   float* _view2DImg;
00240   Matrix4 _view2DWorldToVoxelMatrix;
00242   Matrix4 _optionalWorldToVoxelMatrix;
00243   
00248   TSubImage<float>  _inOptionalImg;
00250   bool            _optionalImgIsValid;
00252   PagedImage* _pImg;
00253 
00255   SbVec3f _sliceNormal0;
00257   SbVec3f _sliceNormal1;
00259   SbVec3f _sliceNormal2;
00260 
00261 
00262   /* METHODS */
00263 
00267   void _removeSeedPointFromMiddle();
00268 
00270   CSO* _addAndInitCSO();
00272   void _interpolate(CSO* cso, CSOPathPoints* pPoints);
00274   void _setInputImageSlice();
00276   bool _couldCloseByDistance(const Vector3& currPos, View2DSliceList* slicelist);
00278   bool _isInsideImage(VoxelPos pos);
00281   void _findLiveWirePathsAroundActiveSeedPoint(const Vector3& currentHitPoint);
00284   void _transformWorldToVoxel(const Vector3& worldPos, Vector3& voxelPos);
00287   void _transformVoxelToWorld(const Vector3& voxelPos, Vector3& worldPos);
00291   void _fillPoints(CSOPathPoints* pathPoints, const std::vector<VoxelPos>& positions);
00294   bool _isWithinRangeDistance(const Vector3& startPos, const Vector3& endPos, float rangeDistance, View2DSliceList* slicelist) const;
00295 
00296   ML_MODULE_CLASS_HEADER(CSOLiveWireProcessor);
00297 };
00298 
00300 
00301 
00302 ML_END_NAMESPACE
00303 
00304 
00305 #endif //__CSOLiveWireProcessor_H
00306