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 00459 #if 1 SoDEPRECATED 00465 bool setBorder( const int border = 0 ); 00466 SoDEPRECATED 00471 int getBorder() const 00472 { return 0; } 00473 00474 #endif 00476 private: 00477 00478 SbStringList* getArgListAsSbString() const; 00479 00484 bool isForEditing() const; 00485 void setIsForEditing(bool flag); 00486 void setDefaultValue(double value); 00487 double getDefaultValue() const; 00488 bool isTileDimDefault(); 00489 bool isRGBAModeDefault() const; 00490 void setIsFromWriter( bool flag ); 00491 bool isFromWriter() const; 00492 void setVerticalFlip(bool flag); 00493 bool isVerticalFlip() const; 00494 bool recomputeHistogram() const; 00495 void enableRecomputeHistogram(bool flag); 00496 00501 void enableTileMinMax(const bool flag); 00502 00506 bool isTileMinMaxEnabled() const; 00507 00508 private: protected: 00509 00510 bool m_verboseMode; 00511 bool m_outputDataTypeSpecified; 00512 bool m_inputDataRangeSpecified; 00513 bool m_headerOnly; 00514 bool m_crcCheck; 00515 bool m_useDefaultCompLevel; 00516 double m_defaultValue; 00517 bool m_RGBAMode; 00518 00519 int m_memSize; 00520 int m_currentWordFormat; 00521 int m_targetWordFormat; 00522 int m_compressionLevel; 00523 int m_pondCoeff; 00524 int m_nbArgs; 00525 00526 double m_undefValue; 00527 double m_dataRangeInMin; 00528 double m_dataRangeInMax; 00529 00530 SbString m_headerFileName; 00531 SbString m_dataSectionFileName; 00532 SbString m_dataFileName; 00533 SoDataSet* m_inputVolume; 00534 00535 SbString m_inputFileName; //file to convert 00536 SbString m_fileExt; 00537 SbString m_compressionName; 00538 00539 SampleType m_sampleType; 00540 SoDataSet::DataType m_dataTypeOut; 00541 SbVec3i32 m_tileDim; 00542 00543 SbStringList m_argListAsSbString; 00544 00545 // type dependent vars/macros 00546 static const char *m_dataTypeStr[]; 00547 static const char *m_dataTypeXml[]; 00548 00549 void buildOutputFileName(); 00550 bool m_isForEditing; 00551 bool m_isTileDimDefaultValue; 00552 bool m_savedAsBitSet; 00553 bool m_isRGBAModeDefault; 00554 bool m_doHistogram; 00555 bool m_recomputeHistogram; 00556 bool m_doTileMinMax; 00557 double m_bitsetThreshold; 00558 bool m_doUpdate; 00559 bool m_bVerticalFlip; 00560 00561 // Who instanciate the converterParameters 00562 bool m_bFromWriter; 00563 }; 00564 00565 #ifdef _MSC_VER 00566 #pragma warning( pop ) 00567 #endif 00568 00569 inline bool 00570 SoConverterParameters::isVerbose() const 00571 { 00572 return m_verboseMode; 00573 } 00574 00575 inline void 00576 SoConverterParameters::setVerbose(bool flag) 00577 { 00578 m_verboseMode = flag; 00579 } 00580 00581 inline SbVec3i32 00582 SoConverterParameters::getTileDim() const 00583 { 00584 return m_tileDim; 00585 } 00586 00587 inline void 00588 SoConverterParameters::setHeaderFileName( const SbString& headerFileName ) 00589 { 00590 m_headerFileName = headerFileName; 00591 m_dataFileName.makeEmpty(); 00592 m_dataSectionFileName.makeEmpty(); 00593 buildOutputFileName(); 00594 } 00595 00596 inline SbString 00597 SoConverterParameters::getHeaderFileName() const 00598 { 00599 return m_headerFileName; 00600 } 00601 00602 inline SbString 00603 SoConverterParameters::getDataSectionFileName() const 00604 { 00605 return m_dataSectionFileName; 00606 } 00607 00608 inline void 00609 SoConverterParameters::setDataFileName(const SbString& dataFileName) 00610 { 00611 m_dataFileName = dataFileName; 00612 m_dataSectionFileName = SbFileHelper::getBaseName( m_dataFileName ); 00613 } 00614 00615 inline SbString 00616 SoConverterParameters::getDataFileName() const 00617 { 00618 return m_dataFileName; 00619 } 00620 00621 inline int 00622 SoConverterParameters::getMaxMemory() const 00623 { 00624 return m_memSize; 00625 } 00626 00627 inline bool 00628 SoConverterParameters::getOutputHeaderOnly() const 00629 { 00630 return m_headerOnly; 00631 } 00632 00633 inline void 00634 SoConverterParameters::setOutputHeaderOnly(bool headerOnly) 00635 { 00636 m_headerOnly = headerOnly; 00637 } 00638 00639 inline SoDataSet::DataType 00640 SoConverterParameters::getOutputDataFormat() const 00641 { 00642 return m_dataTypeOut; 00643 } 00644 00645 inline int 00646 SoConverterParameters::getTargetWordFormat() const 00647 { 00648 return m_targetWordFormat; 00649 } 00650 00651 inline SbString 00652 SoConverterParameters::getCompressionName() const 00653 { 00654 return m_compressionName; 00655 } 00656 00657 inline int 00658 SoConverterParameters::getCompressionLevel() const 00659 { 00660 return m_compressionLevel; 00661 } 00662 00663 inline bool 00664 SoConverterParameters::isCrcCheckDone() const 00665 { 00666 return m_crcCheck; 00667 } 00668 00669 inline void 00670 SoConverterParameters::setCrcCheck ( bool addCrcCheck ) 00671 { 00672 m_crcCheck = addCrcCheck; 00673 } 00674 00675 inline void 00676 SoConverterParameters::getInputRangeMinMax(double& min, double& max) const 00677 { 00678 min = m_dataRangeInMin; 00679 max = m_dataRangeInMax; 00680 } 00681 00682 inline SoConverterParameters::SampleType 00683 SoConverterParameters::getLowResAlgorithm() const 00684 { 00685 return m_sampleType; 00686 } 00687 00688 inline double 00689 SoConverterParameters::getUndefinedValue() const 00690 { 00691 return m_undefValue; 00692 } 00693 00694 inline int 00695 SoConverterParameters::getNbArgs() const 00696 { 00697 return m_nbArgs; 00698 } 00699 00700 inline bool 00701 SoConverterParameters::useDefaultCompLvl() const 00702 { 00703 return m_useDefaultCompLevel; 00704 } 00705 00706 inline void 00707 SoConverterParameters::setUndefinedValue(double undefinedValue) 00708 { 00709 m_undefValue = undefinedValue; 00710 } 00711 00712 inline bool 00713 SoConverterParameters::isOutputDataTypeSpecified() const 00714 { 00715 return m_outputDataTypeSpecified; 00716 } 00717 00718 inline void 00719 SoConverterParameters::setInputFileName( const SbString& inputFileName ) 00720 { 00721 m_inputFileName = inputFileName; 00722 00723 buildOutputFileName(); 00724 } 00725 00726 inline SbString 00727 SoConverterParameters::getInputFileName() const 00728 { 00729 return m_inputFileName; 00730 } 00731 00732 inline SoDataSet* 00733 SoConverterParameters::getInputVolume() const 00734 { 00735 return m_inputVolume; 00736 } 00737 00738 inline void 00739 SoConverterParameters::setInputVolume(SoDataSet* inputVolume) 00740 { 00741 m_inputVolume = inputVolume; 00742 } 00743 00744 inline bool 00745 SoConverterParameters::isInputDataRangeSpecified() const 00746 { 00747 return m_inputDataRangeSpecified; 00748 } 00749 00750 inline int 00751 SoConverterParameters::getPondCoef() const 00752 { 00753 return m_pondCoeff; 00754 } 00755 00756 inline bool 00757 SoConverterParameters::isForEditing() const 00758 { 00759 return m_isForEditing; 00760 } 00761 00762 inline void 00763 SoConverterParameters::setDefaultValue(const double value) 00764 { 00765 m_defaultValue = value; 00766 } 00767 00768 inline double 00769 SoConverterParameters::getDefaultValue() const 00770 { 00771 return m_defaultValue; 00772 } 00773 00774 inline bool 00775 SoConverterParameters::isTileDimDefault() 00776 { 00777 return m_isTileDimDefaultValue; 00778 } 00779 00780 inline bool 00781 SoConverterParameters::isSavedAsBitSet() const 00782 { 00783 return m_savedAsBitSet; 00784 } 00785 00786 inline void 00787 SoConverterParameters::saveAsBitSet( bool flag, double bitsetThreshold ) 00788 { 00789 m_savedAsBitSet = flag; 00790 00791 if ( flag ) 00792 m_bitsetThreshold = bitsetThreshold; 00793 } 00794 00795 inline void 00796 SoConverterParameters::setRGBAMode(const bool flag) 00797 { 00798 m_isRGBAModeDefault = false; 00799 m_RGBAMode = flag; 00800 } 00801 00802 inline bool 00803 SoConverterParameters::isRGBAMode() const 00804 { 00805 return m_RGBAMode; 00806 } 00807 00808 inline void 00809 SoConverterParameters::enableHistogram(const bool flag) 00810 { 00811 m_doHistogram = flag; 00812 } 00813 00814 inline bool 00815 SoConverterParameters::isHistogramEnabled() const 00816 { 00817 return m_doHistogram && !isRGBAMode(); 00818 } 00819 00820 inline void 00821 SoConverterParameters::enableRecomputeHistogram(const bool flag) 00822 { 00823 m_recomputeHistogram = flag; 00824 } 00825 00826 inline bool 00827 SoConverterParameters::recomputeHistogram() const 00828 { 00829 return m_recomputeHistogram; 00830 } 00831 00832 inline void 00833 SoConverterParameters::enableTileMinMax(const bool flag) 00834 { 00835 m_doTileMinMax = flag; 00836 } 00837 00838 inline bool 00839 SoConverterParameters::isTileMinMaxEnabled() const 00840 { 00841 return m_doTileMinMax; 00842 } 00843 00844 inline bool 00845 SoConverterParameters::isRGBAModeDefault() const 00846 { 00847 return m_isRGBAModeDefault; 00848 } 00849 00850 inline double 00851 SoConverterParameters::getBitSetThreshold() const 00852 { 00853 return m_bitsetThreshold; 00854 } 00855 00856 inline void 00857 SoConverterParameters::setBitSetThreshold( double bitsetThreshold ) 00858 { 00859 m_bitsetThreshold = bitsetThreshold; 00860 } 00861 00862 inline bool 00863 SoConverterParameters::isFromWriter() const 00864 { 00865 return m_bFromWriter; 00866 } 00867 00868 inline void 00869 SoConverterParameters::setIsFromWriter( bool flag ) 00870 { 00871 m_bFromWriter = flag; 00872 } 00873 00874 inline void 00875 SoConverterParameters::doUpdate ( bool flag ) 00876 { 00877 m_doUpdate = flag; 00878 } 00879 00880 inline bool 00881 SoConverterParameters::isForUpdate() const 00882 { 00883 return m_doUpdate; 00884 } 00885 00886 inline bool 00887 SoConverterParameters::isVerticalFlip() const 00888 { 00889 return m_bVerticalFlip; 00890 } 00891 00892 inline void 00893 SoConverterParameters::setVerticalFlip( bool flag ) 00894 { 00895 m_bVerticalFlip = flag; 00896 } 00897 00898 #endif //_SO_BASE_CONVERTER_ 00899 00900 00901