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-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG3D (Jun 2009) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef _SO_BASE_CONVERTER_PARAMETERS 00026 #define _SO_BASE_CONVERTER_PARAMETERS 00027 00028 #ifdef _MSC_VER 00029 #pragma warning( push ) 00030 #pragma warning(disable:4251) 00031 #endif 00032 00033 #include <Inventor/STL/vector> 00034 #include <Inventor/SbBox.h> 00035 #include <Inventor/SbPList.h> 00036 #include <LDM/compressors/SoDataCompressor.h> 00037 #include <Inventor/helpers/SbFileHelper.h> 00038 00051 class SoConverterParameters { 00052 00053 public: 00054 00055 enum SampleType 00056 { 00060 DECIMATION, 00064 AVERAGE 00065 }; 00066 00067 enum ParametersError 00068 { 00070 PARAM_NO_ERROR = 0, 00072 PARAM_ERROR = -1 00073 }; 00074 00075 00079 SoConverterParameters( ); 00080 00084 virtual ~SoConverterParameters(); 00085 00094 static SoConverterParameters* create( int argc, char** argv ); 00095 00108 static SoConverterParameters* create( const SbStringList& arguments ); 00109 00113 void setVerbose( const bool isVerbose ); 00114 00118 bool isVerbose() const; 00119 00126 void setTileDim( const int tileDim ); 00127 00135 void setTileDim(const SbVec3i32& tileDim); 00136 00140 SbVec3i32 getTileDim() const; 00141 00147 void setHeaderFileName( const SbString& headerFileName ); 00148 00152 SbString getHeaderFileName() const; 00153 00159 void setDataFileName( const SbString& dataFileName ); 00160 00164 SbString getDataSectionFileName() const; 00165 00169 SbString getDataFileName() const; 00170 00178 void setInputFileName( const SbString& inputFileName ); 00179 00183 SbString getInputFileName() const ; 00184 00189 void setInputVolume(SoDataSet* inputVolume); 00190 00194 SoDataSet* getInputVolume() const; 00195 00201 bool setMaxMemory( int maxMemory ); 00202 00206 int getMaxMemory() const; 00207 00214 void setOutputHeaderOnly( bool headerOnly ); 00215 00219 bool getOutputHeaderOnly() const; 00220 00231 bool setOutputDataFormat( const SbString& dataFormat ); 00232 00239 bool setOutputDataFormat( const SoDataSet::DataType& dataType); 00240 00244 SoDataSet::DataType getOutputDataFormat() const; 00245 00252 bool setTargetWordFormat(int wordFormat); 00253 00257 int getTargetWordFormat() const; 00258 00265 bool setInputRangeMinMax( double min, double max ); 00266 00270 void getInputRangeMinMax( double& min, double& max ) const; 00271 00290 bool setCompressionName( const SbString& compressionName ); 00291 00309 void setCompressionLevel (int compressionLevel ); 00310 00318 void setCrcCheck (bool addCrcCheck ); 00319 00323 SbString getCompressionName() const; 00324 00325 /* 00326 * Returns compression level. 00327 */ 00328 int getCompressionLevel() const; 00329 00330 /* 00331 * Returns CRC check setting. 00332 */ 00333 bool isCrcCheckDone () const; 00334 00335 /* 00336 * Returns true if using default compression level. 00337 */ 00338 bool useDefaultCompLvl() const; 00339 00349 bool setLowResAlgorithm( int lowResAlgorithm ); 00350 00354 SampleType getLowResAlgorithm() const; 00355 00360 int getPondCoef() const; 00361 00368 void setUndefinedValue(double undefinedValue); 00369 00373 double getUndefinedValue() const; 00374 00378 int getNbArgs() const; 00379 00383 bool isOutputDataTypeSpecified() const; 00384 00388 bool isInputDataRangeSpecified() const; 00389 00393 void setRGBAMode(const bool flag); 00394 00398 bool isRGBAMode() const; 00399 00412 void enableHistogram(const bool flag); 00413 00417 bool isHistogramEnabled() const; 00418 00422 bool isSavedAsBitSet() const; 00423 00431 void saveAsBitSet( bool flag, double bitsetThreshold = 0); 00432 00436 double getBitSetThreshold() const; 00437 00444 void setBitSetThreshold( double bitsetThreshold ); 00445 00452 void doUpdate ( bool value ); 00453 00457 bool isForUpdate() const; 00458 00462 void setVerticalFlip(bool flag); 00463 00467 bool isVerticalFlip() const; 00468 00469 private: 00470 00471 SbStringList* getArgListAsSbString() const; 00472 00477 bool isForEditing() const; 00478 void setIsForEditing(bool flag); 00479 void setDefaultValue(double value); 00480 double getDefaultValue() const; 00481 bool isTileDimDefault(); 00482 bool isRGBAModeDefault() const; 00483 void setIsFromWriter( bool flag ); 00484 bool isFromWriter() const; 00485 bool recomputeHistogram() const; 00486 void enableRecomputeHistogram(bool flag); 00487 00492 void enableTileMinMax(const bool flag); 00493 00497 bool isTileMinMaxEnabled() const; 00498 00499 private: protected: 00500 00501 bool m_verboseMode; 00502 bool m_outputDataTypeSpecified; 00503 bool m_inputDataRangeSpecified; 00504 bool m_headerOnly; 00505 bool m_crcCheck; 00506 bool m_useDefaultCompLevel; 00507 double m_defaultValue; 00508 bool m_RGBAMode; 00509 00510 int m_memSize; 00511 int m_targetWordFormat; 00512 int m_compressionLevel; 00513 int m_pondCoeff; 00514 int m_nbArgs; 00515 00516 double m_undefValue; 00517 double m_dataRangeInMin; 00518 double m_dataRangeInMax; 00519 00520 SbString m_headerFileName; 00521 SbString m_dataSectionFileName; 00522 SbString m_dataFileName; 00523 SoDataSet* m_inputVolume; 00524 00525 SbString m_inputFileName; //file to convert 00526 SbString m_compressionName; 00527 00528 SampleType m_sampleType; 00529 SoDataSet::DataType m_dataTypeOut; 00530 SbVec3i32 m_tileDim; 00531 00532 // type dependent vars/macros 00533 static const char *m_dataTypeStr[]; 00534 static const char *m_dataTypeXml[]; 00535 00536 void buildOutputFileName(); 00537 bool m_isForEditing; 00538 bool m_isTileDimDefaultValue; 00539 bool m_savedAsBitSet; 00540 bool m_isRGBAModeDefault; 00541 bool m_doHistogram; 00542 bool m_recomputeHistogram; 00543 bool m_doTileMinMax; 00544 double m_bitsetThreshold; 00545 bool m_doUpdate; 00547 bool m_bVerticalFlip; 00548 00549 //instanciate the converterParameters 00550 bool m_bFromWriter; 00551 }; 00552 00553 #ifdef _MSC_VER 00554 #pragma warning( pop ) 00555 #endif 00556 00557 inline bool 00558 SoConverterParameters::isVerbose() const 00559 { 00560 return m_verboseMode; 00561 } 00562 00563 inline void 00564 SoConverterParameters::setVerbose(bool flag) 00565 { 00566 m_verboseMode = flag; 00567 } 00568 00569 inline SbVec3i32 00570 SoConverterParameters::getTileDim() const 00571 { 00572 return m_tileDim; 00573 } 00574 00575 inline void 00576 SoConverterParameters::setHeaderFileName( const SbString& headerFileName ) 00577 { 00578 m_headerFileName = headerFileName; 00579 m_dataFileName.makeEmpty(); 00580 m_dataSectionFileName.makeEmpty(); 00581 buildOutputFileName(); 00582 } 00583 00584 inline SbString 00585 SoConverterParameters::getHeaderFileName() const 00586 { 00587 return m_headerFileName; 00588 } 00589 00590 inline SbString 00591 SoConverterParameters::getDataSectionFileName() const 00592 { 00593 return m_dataSectionFileName; 00594 } 00595 00596 inline void 00597 SoConverterParameters::setDataFileName(const SbString& dataFileName) 00598 { 00599 m_dataFileName = dataFileName; 00600 m_dataSectionFileName = SbFileHelper::getBaseName( m_dataFileName ); 00601 } 00602 00603 inline SbString 00604 SoConverterParameters::getDataFileName() const 00605 { 00606 return m_dataFileName; 00607 } 00608 00609 inline int 00610 SoConverterParameters::getMaxMemory() const 00611 { 00612 return m_memSize; 00613 } 00614 00615 inline bool 00616 SoConverterParameters::getOutputHeaderOnly() const 00617 { 00618 return m_headerOnly; 00619 } 00620 00621 inline void 00622 SoConverterParameters::setOutputHeaderOnly(bool headerOnly) 00623 { 00624 m_headerOnly = headerOnly; 00625 } 00626 00627 inline SoDataSet::DataType 00628 SoConverterParameters::getOutputDataFormat() const 00629 { 00630 return m_dataTypeOut; 00631 } 00632 00633 inline int 00634 SoConverterParameters::getTargetWordFormat() const 00635 { 00636 return m_targetWordFormat; 00637 } 00638 00639 inline SbString 00640 SoConverterParameters::getCompressionName() const 00641 { 00642 return m_compressionName; 00643 } 00644 00645 inline int 00646 SoConverterParameters::getCompressionLevel() const 00647 { 00648 return m_compressionLevel; 00649 } 00650 00651 inline bool 00652 SoConverterParameters::isCrcCheckDone() const 00653 { 00654 return m_crcCheck; 00655 } 00656 00657 inline void 00658 SoConverterParameters::setCrcCheck ( bool addCrcCheck ) 00659 { 00660 m_crcCheck = addCrcCheck; 00661 } 00662 00663 inline void 00664 SoConverterParameters::getInputRangeMinMax(double& min, double& max) const 00665 { 00666 min = m_dataRangeInMin; 00667 max = m_dataRangeInMax; 00668 } 00669 00670 inline SoConverterParameters::SampleType 00671 SoConverterParameters::getLowResAlgorithm() const 00672 { 00673 return m_sampleType; 00674 } 00675 00676 inline double 00677 SoConverterParameters::getUndefinedValue() const 00678 { 00679 return m_undefValue; 00680 } 00681 00682 inline int 00683 SoConverterParameters::getNbArgs() const 00684 { 00685 return m_nbArgs; 00686 } 00687 00688 inline bool 00689 SoConverterParameters::useDefaultCompLvl() const 00690 { 00691 return m_useDefaultCompLevel; 00692 } 00693 00694 inline void 00695 SoConverterParameters::setUndefinedValue(double undefinedValue) 00696 { 00697 m_undefValue = undefinedValue; 00698 } 00699 00700 inline bool 00701 SoConverterParameters::isOutputDataTypeSpecified() const 00702 { 00703 return m_outputDataTypeSpecified; 00704 } 00705 00706 inline void 00707 SoConverterParameters::setInputFileName( const SbString& inputFileName ) 00708 { 00709 m_inputFileName = inputFileName; 00710 00711 buildOutputFileName(); 00712 } 00713 00714 inline SbString 00715 SoConverterParameters::getInputFileName() const 00716 { 00717 return m_inputFileName; 00718 } 00719 00720 inline SoDataSet* 00721 SoConverterParameters::getInputVolume() const 00722 { 00723 return m_inputVolume; 00724 } 00725 00726 inline void 00727 SoConverterParameters::setInputVolume(SoDataSet* inputVolume) 00728 { 00729 m_inputVolume = inputVolume; 00730 } 00731 00732 inline bool 00733 SoConverterParameters::isInputDataRangeSpecified() const 00734 { 00735 return m_inputDataRangeSpecified; 00736 } 00737 00738 inline int 00739 SoConverterParameters::getPondCoef() const 00740 { 00741 return m_pondCoeff; 00742 } 00743 00744 inline bool 00745 SoConverterParameters::isForEditing() const 00746 { 00747 return m_isForEditing; 00748 } 00749 00750 inline void 00751 SoConverterParameters::setDefaultValue(const double value) 00752 { 00753 m_defaultValue = value; 00754 } 00755 00756 inline double 00757 SoConverterParameters::getDefaultValue() const 00758 { 00759 return m_defaultValue; 00760 } 00761 00762 inline bool 00763 SoConverterParameters::isTileDimDefault() 00764 { 00765 return m_isTileDimDefaultValue; 00766 } 00767 00768 inline bool 00769 SoConverterParameters::isSavedAsBitSet() const 00770 { 00771 return m_savedAsBitSet; 00772 } 00773 00774 inline void 00775 SoConverterParameters::saveAsBitSet( bool flag, double bitsetThreshold ) 00776 { 00777 m_savedAsBitSet = flag; 00778 00779 if ( flag ) 00780 m_bitsetThreshold = bitsetThreshold; 00781 } 00782 00783 inline void 00784 SoConverterParameters::setRGBAMode(const bool flag) 00785 { 00786 m_isRGBAModeDefault = false; 00787 m_RGBAMode = flag; 00788 } 00789 00790 inline bool 00791 SoConverterParameters::isRGBAMode() const 00792 { 00793 return m_RGBAMode; 00794 } 00795 00796 inline void 00797 SoConverterParameters::enableHistogram(const bool flag) 00798 { 00799 m_doHistogram = flag; 00800 } 00801 00802 inline bool 00803 SoConverterParameters::isHistogramEnabled() const 00804 { 00805 return m_doHistogram && !isRGBAMode(); 00806 } 00807 00808 inline void 00809 SoConverterParameters::enableRecomputeHistogram(const bool flag) 00810 { 00811 m_recomputeHistogram = flag; 00812 } 00813 00814 inline bool 00815 SoConverterParameters::recomputeHistogram() const 00816 { 00817 return m_recomputeHistogram; 00818 } 00819 00820 inline void 00821 SoConverterParameters::enableTileMinMax(const bool flag) 00822 { 00823 m_doTileMinMax = flag; 00824 } 00825 00826 inline bool 00827 SoConverterParameters::isTileMinMaxEnabled() const 00828 { 00829 return m_doTileMinMax; 00830 } 00831 00832 inline bool 00833 SoConverterParameters::isRGBAModeDefault() const 00834 { 00835 return m_isRGBAModeDefault; 00836 } 00837 00838 inline double 00839 SoConverterParameters::getBitSetThreshold() const 00840 { 00841 return m_bitsetThreshold; 00842 } 00843 00844 inline void 00845 SoConverterParameters::setBitSetThreshold( double bitsetThreshold ) 00846 { 00847 m_bitsetThreshold = bitsetThreshold; 00848 } 00849 00850 inline bool 00851 SoConverterParameters::isFromWriter() const 00852 { 00853 return m_bFromWriter; 00854 } 00855 00856 inline void 00857 SoConverterParameters::setIsFromWriter( bool flag ) 00858 { 00859 m_bFromWriter = flag; 00860 } 00861 00862 inline void 00863 SoConverterParameters::doUpdate ( bool flag ) 00864 { 00865 m_doUpdate = flag; 00866 } 00867 00868 inline bool 00869 SoConverterParameters::isForUpdate() const 00870 { 00871 return m_doUpdate; 00872 } 00873 00874 inline bool 00875 SoConverterParameters::isVerticalFlip() const 00876 { 00877 return m_bVerticalFlip; 00878 } 00879 00880 inline void 00881 SoConverterParameters::setVerticalFlip( bool flag ) 00882 { 00883 m_bVerticalFlip = flag; 00884 } 00885 00886 #endif //_SO_BASE_CONVERTER_ 00887 00888 00889