From 114f1b365123d9942c7b8c5e641694c3da09c11f Mon Sep 17 00:00:00 2001 From: isn Date: Thu, 8 Sep 2016 18:07:13 +0300 Subject: [PATCH] multi bath + calc case test --- src/HYDROData/HYDROData_Bathymetry.cxx | 17 +- src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx | 77 +- src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h | 9 + src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx | 199 ++- src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h | 2 + src/HYDROGUI/resources/HYDROGUI_msg_en.ts | 17 +- src/HYDRO_tests/CMakeLists.txt | 3 + src/HYDRO_tests/reference_data/CMakeLists.txt | 8 + src/HYDRO_tests/reference_data/cc_int_w_1.png | Bin 0 -> 3997 bytes src/HYDRO_tests/reference_data/cc_int_w_2.png | Bin 0 -> 4119 bytes src/HYDRO_tests/reference_data/cc_int_w_3.png | Bin 0 -> 4196 bytes src/HYDRO_tests/reference_data/p1.brep | 42 + src/HYDRO_tests/reference_data/p2.brep | 42 + src/HYDRO_tests/reference_data/p3.brep | 42 + src/HYDRO_tests/reference_data/r2.brep | 1190 +++++++++++++++++ src/HYDRO_tests/test_HYDROData_CalcCase.cxx | 104 ++ src/HYDRO_tests/test_HYDROData_CalcCase.h | 43 + .../test_HYDROData_LandCoverMap.cxx | 21 - src/HYDRO_tests/test_HYDROData_LandCoverMap.h | 2 - 19 files changed, 1723 insertions(+), 95 deletions(-) create mode 100644 src/HYDRO_tests/reference_data/cc_int_w_1.png create mode 100644 src/HYDRO_tests/reference_data/cc_int_w_2.png create mode 100644 src/HYDRO_tests/reference_data/cc_int_w_3.png create mode 100644 src/HYDRO_tests/reference_data/p1.brep create mode 100644 src/HYDRO_tests/reference_data/p2.brep create mode 100644 src/HYDRO_tests/reference_data/p3.brep create mode 100644 src/HYDRO_tests/reference_data/r2.brep create mode 100644 src/HYDRO_tests/test_HYDROData_CalcCase.cxx create mode 100644 src/HYDRO_tests/test_HYDROData_CalcCase.h diff --git a/src/HYDROData/HYDROData_Bathymetry.cxx b/src/HYDROData/HYDROData_Bathymetry.cxx index b5a50b1b..9cb013af 100644 --- a/src/HYDROData/HYDROData_Bathymetry.cxx +++ b/src/HYDROData/HYDROData_Bathymetry.cxx @@ -489,6 +489,16 @@ QStringList HYDROData_Bathymetry::GetFilePaths() const } } } + else //backward compatibility + { + TDF_Label anOldLabel = myLab.FindChild( DataTag_FilePath, false ); + if ( !anOldLabel.IsNull() ) + { + Handle(TDataStd_AsciiString) anAsciiStr; + if ( anOldLabel.FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) ) + aResL << QString(anAsciiStr->Get().ToCString()); + } + } return aResL; } @@ -555,9 +565,12 @@ bool HYDROData_Bathymetry::ImportFromFiles( const QStringList& theFileNames ) // Try to import the file if ( aFileSuf == "xyz" ) - Stat = Stat || importFromXYZFile( aFile, aPoints ); + Stat = importFromXYZFile( aFile, aPoints ); else if ( aFileSuf == "asc" ) - Stat = Stat || importFromASCFile( aFile, aPoints ); + Stat = importFromASCFile( aFile, aPoints ); + + if (!Stat) + continue; //ignore this points // Close the file aFile.close(); diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx index e4b67cab..68cdbead 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.cxx @@ -33,7 +33,6 @@ #include #include -//TODO add new checkbox ('FUSE INTO THE ONE')!!! HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle ) : HYDROGUI_InputPanel( theModule, theTitle ) { @@ -45,21 +44,25 @@ HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* the QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup ); myFileNames = new QListWidget( myFileNameGroup ); - myFileNames->viewport()->setAttribute( Qt::WA_TransparentForMouseEvents ); - //myFileNames->setFocusPolicy(Qt::FocusPolicy::NoFocus); //TODO - //myFileNames->setReadOnly( true ); + //myFileNames->viewport()->setAttribute( Qt::WA_TransparentForMouseEvents ); + //myFileNames->setFocusPolicy(Qt::FocusPolicy::NoFocus); QPushButton* aBrowseBtn = new QPushButton( myFileNameGroup ); - // aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); aBrowseBtn->setText("Load files(s)"); aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) ); QBoxLayout* aFileNameLayout = new QVBoxLayout( myFileNameGroup ); + + myFuseIntoOne = new QCheckBox(); + myFuseIntoOne->setText("Import as one bathemetry object (fuse the geometry data)"); + myFuseIntoOne->setEnabled( false ); + aFileNameLayout->setMargin( 5 ); aFileNameLayout->setSpacing( 5 ); aFileNameLayout->addWidget( aFileNameLabel ); aFileNameLayout->addWidget( aBrowseBtn ); aFileNameLayout->addWidget( myFileNames ); + aFileNameLayout->addWidget( myFuseIntoOne ); // Bathymetry name myObjectNameGroup = new QGroupBox( tr( "BATHYMETRY_NAME" ) ); @@ -83,6 +86,7 @@ HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* the addStretch(); connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); + connect( myFuseIntoOne, SIGNAL( stateChanged(int) ), this, SLOT( onStateChanged(int) ) ); } HYDROGUI_ImportBathymetryDlg::~HYDROGUI_ImportBathymetryDlg() @@ -94,12 +98,16 @@ void HYDROGUI_ImportBathymetryDlg::reset() myFileNames->clear(); myObjectName->clear(); myObjectNameGroup->setEnabled( false ); + myFuseIntoOne->setEnabled( false ); } void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName ) { myObjectName->setText( theName ); - myObjectNameGroup->setEnabled( !theName.isEmpty() || !myFileNames->count() ); + bool ObjNameState = myObjectName->isEnabled(); + myObjectNameGroup->setEnabled( !theName.isEmpty() || myFileNames->count() > 0 ); + myObjectName->setEnabled(ObjNameState); + myFuseIntoOne->setEnabled( myFileNames->count() > 1 ); } QString HYDROGUI_ImportBathymetryDlg::getObjectName() const @@ -109,11 +117,25 @@ QString HYDROGUI_ImportBathymetryDlg::getObjectName() const void HYDROGUI_ImportBathymetryDlg::setFileNames( const QStringList& theFileNames ) { - + myFileNames->clear(); myFileNames->addItems( theFileNames ); - if ( !myObjectNameGroup->isEnabled() ) - myObjectNameGroup->setEnabled( !theFileNames.isEmpty() ); + if (myFuseIntoOne->isChecked() || theFileNames.count() == 1 ) + { + myObjectNameGroup->setEnabled( true ); + myObjectName->setEnabled( true ); + } + else + { + myObjectNameGroup->setEnabled( false ); + myObjectName->setEnabled( false ); + } + // + if (theFileNames.count() == 1) + myFuseIntoOne->setEnabled( false ); + else if (theFileNames.count() > 1) + myFuseIntoOne->setEnabled( true ); + } QStringList HYDROGUI_ImportBathymetryDlg::getFileNames() const @@ -137,6 +159,26 @@ bool HYDROGUI_ImportBathymetryDlg::isInvertAltitudes() const return myInvertAltitudes->isChecked(); } +void HYDROGUI_ImportBathymetryDlg::setFuseIntoOneOptionChecked( bool isFIO ) +{ + myFuseIntoOne->setChecked( isFIO ); +} + +bool HYDROGUI_ImportBathymetryDlg::isFuseIntoOneOptionChecked() const +{ + return myFuseIntoOne->isChecked(); +} + +void HYDROGUI_ImportBathymetryDlg::setFuseIntoOneOptionEnabled(bool enabled) +{ + myFuseIntoOne->setEnabled(enabled); +} + +bool HYDROGUI_ImportBathymetryDlg::isFuseIntoOneOptionEnabled() const +{ + return myFuseIntoOne->isEnabled(); +} + void HYDROGUI_ImportBathymetryDlg::onBrowse() { QString aFilter( tr( "BATHYMETRY_FILTER" ) ); @@ -149,6 +191,21 @@ void HYDROGUI_ImportBathymetryDlg::onBrowse() } } - +void HYDROGUI_ImportBathymetryDlg::onStateChanged (int state) +{ + if (getFileNames().count() > 1) + { + if (state == Qt::Checked) + { + myObjectName->setEnabled(true); + myObjectNameGroup->setEnabled(true); + } + else if (state == Qt::Unchecked) + { + myObjectName->setEnabled(false); + myObjectNameGroup->setEnabled(false); + } + } +} diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h index 210c5e9d..438bddb4 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryDlg.h @@ -48,11 +48,18 @@ public: void setInvertAltitudes( const bool theIsInvert ); bool isInvertAltitudes() const; + void setFuseIntoOneOptionChecked( bool isFIO ); + bool isFuseIntoOneOptionChecked() const; + void setFuseIntoOneOptionEnabled(bool enabled); + bool isFuseIntoOneOptionEnabled() const; + + signals: void FileSelected( const QStringList& theFileName ); protected slots: void onBrowse(); + void onStateChanged (int state); private: QGroupBox* myFileNameGroup; @@ -60,6 +67,8 @@ private: QCheckBox* myInvertAltitudes; + QCheckBox* myFuseIntoOne; + QGroupBox* myObjectNameGroup; QLineEdit* myObjectName; }; diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx index ca048674..02ea51ac 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx @@ -34,6 +34,10 @@ #include #include +#include +#include +#include + HYDROGUI_ImportBathymetryOp::HYDROGUI_ImportBathymetryOp( HYDROGUI_Module* theModule, const bool theIsEdit ) @@ -68,9 +72,12 @@ void HYDROGUI_ImportBathymetryOp::startOperation() QStringList aFileNames = myEditedObject->GetFilePaths(); bool anIsAltitudesInverted = myEditedObject->IsAltitudesInverted(); + aPanel->setFuseIntoOneOptionChecked( true ); + aPanel->setObjectName( aName ); aPanel->setFileNames( aFileNames ); aPanel->setInvertAltitudes( anIsAltitudesInverted ); + aPanel->setFuseIntoOneOptionEnabled( false ); } } } @@ -110,72 +117,151 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags, return false; } - QStringList aFileNames = aPanel->getFileNames(); //TODO simplified ?? - - bool anIsInvertAltitudes = aPanel->isInvertAltitudes(); + QStringList aFileNames = aPanel->getFileNames(); + + QStringList DummyFileList; + foreach (QString str, aFileNames) + DummyFileList << str.simplified(); + + aFileNames = DummyFileList; + DummyFileList.clear(); if ( aFileNames.isEmpty() ) { - theErrorMsg = tr( "INCORRECT_FILE_NAME" ); + theErrorMsg = tr( "EMPTY_FILENAMES" ); return false; } - QStringList DummyFileList; + QString inexistWarn; + foreach (QString aFileName, aFileNames ) { QFileInfo aFileInfo( aFileName ); if ( !aFileInfo.exists() || !aFileInfo.isReadable() ) { - theErrorMsg = tr( "FILE_NOT_EXISTS_OR_CANT_BE_READ" ).arg( aFileName ); + inexistWarn += "\n" + aFileName; continue; } DummyFileList << aFileName; } + if (!inexistWarn.isNull()) + SUIT_MessageBox::warning( module()->getApp()->desktop(), + tr( "BATHEMETRY_IMPORT_WARNING" ), "Can't read the next files:" + inexistWarn ); + aFileNames = DummyFileList; - if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anObjectName ) ) + bool isFuseIntoOneOption = aPanel->isFuseIntoOneOptionChecked(); + bool anIsInvertAltitudes = aPanel->isInvertAltitudes(); + + QString replacemWarn; + QString UnreadFilesWarn; + + if ( myIsEdit ) { - // check that there are no other objects with the same name in the document - Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), anObjectName ); - if( !anObject.IsNull() ) - { - theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anObjectName ); + //edit already existing bath + if (myEditedObject.IsNull()) return false; + QStringList anOldFileNames = myEditedObject->GetFilePaths(); + bool anIsInvertAltitudes = aPanel->isInvertAltitudes(); + myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false ); + if ( aFileNames.toSet() != anOldFileNames.toSet() ) + { + myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false ); + if ( !myEditedObject->ImportFromFiles( aFileNames ) ) + { + theErrorMsg = tr( "BAD_IMPORTED_BATHYMETRY_FILE" ).arg( aFileNames.join("\n") ); + return false; + } } - } + else if ( anIsInvertAltitudes != myEditedObject->IsAltitudesInverted() ) + myEditedObject->SetAltitudesInverted( anIsInvertAltitudes ); - Handle(HYDROData_Bathymetry) aBathymetryObj; - if ( myIsEdit ) - { - aBathymetryObj = myEditedObject; + QString aNewObjName; + if (CheckNameExistingBathy(anObjectName, aNewObjName)) + { + myEditedObject->SetName( aNewObjName ); + replacemWarn += "\n'" + anObjectName + "' => '" + aNewObjName + "'"; + } + else + myEditedObject->SetName( anObjectName ); + myEditedObject->Update(); } else { - aBathymetryObj = - Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) ); - } - if ( aBathymetryObj.IsNull() ) - return false; - - QStringList anOldFileName = aBathymetryObj->GetFilePaths(); - if ( aFileNames != anOldFileName ) - { - aBathymetryObj->SetAltitudesInverted( anIsInvertAltitudes, false ); - if ( !aBathymetryObj->ImportFromFiles( aFileNames ) ) + //create the new one + if (isFuseIntoOneOption) { - theErrorMsg = tr( "BAD_IMPORTED_BATHYMETRY_FILE" ).arg( aFileNames.join("\n") ); - return false; + Handle(HYDROData_Bathymetry) aBathymetryObj = Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) ); + if ( aBathymetryObj.IsNull() ) + return false; + aBathymetryObj->SetAltitudesInverted( anIsInvertAltitudes, false ); + if ( !aBathymetryObj->ImportFromFiles( aFileNames ) ) + { + theErrorMsg = tr( "BAD_IMPORTED_BATHYMETRY_FILE" ).arg( aFileNames.join("\n") ); + return false; + } + + QString aNewObjName; + if (CheckNameExistingBathy(anObjectName, aNewObjName)) + { + aBathymetryObj->SetName( aNewObjName ); + replacemWarn += "\n'" + anObjectName + "' => '" + aNewObjName + "'"; + } + else + aBathymetryObj->SetName( anObjectName ); + + aBathymetryObj->SetName( anObjectName ); + aBathymetryObj->Update(); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aBathymetryObj ); + theBrowseObjectsEntries.append( anEntry ); + } + else //myedit off + non-fuse => import separate files + { + bool AtLeastOneWasImported = false; + foreach (QString filename, aFileNames) + { + Handle(HYDROData_Bathymetry) aBathymetryObj = Handle(HYDROData_Bathymetry)::DownCast( doc()->CreateObject( KIND_BATHYMETRY ) ); + if ( aBathymetryObj.IsNull() ) + continue; + aBathymetryObj->SetAltitudesInverted( anIsInvertAltitudes, false ); + if ( !aBathymetryObj->ImportFromFiles( QStringList(filename) ) ) + { + UnreadFilesWarn += "\n" + filename; + continue; + } + + QString anObjectName = QFileInfo( filename ).baseName(); + QString aNewObjName; + if (CheckNameExistingBathy(anObjectName, aNewObjName)) + { + aBathymetryObj->SetName( aNewObjName ); + replacemWarn += "\n'" + anObjectName + "' => '" + aNewObjName + "'"; + } + else + aBathymetryObj->SetName( anObjectName ); + + AtLeastOneWasImported = true; + aBathymetryObj->Update(); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aBathymetryObj ); + theBrowseObjectsEntries.append( anEntry ); + } + if (!AtLeastOneWasImported) + { + theErrorMsg = tr( "BAD_IMPORTED_BATHYMETRY_FILES" ).arg( aFileNames.join("\n") ); + return false; + } } } - else if ( anIsInvertAltitudes != aBathymetryObj->IsAltitudesInverted() ) - { - aBathymetryObj->SetAltitudesInverted( anIsInvertAltitudes ); - } - aBathymetryObj->SetName( anObjectName ); + if (!UnreadFilesWarn.isNull()) + SUIT_MessageBox::warning( module()->getApp()->desktop(), + tr( "BATHEMETRY_IMPORT_WARNING" ), "The next files cannot be imported:" + UnreadFilesWarn ); + - aBathymetryObj->Update(); + if (!replacemWarn.isNull()) + SUIT_MessageBox::warning( module()->getApp()->desktop(), + tr( "BATHEMETRY_IMPORT_WARNING" ), "The next objects names are already exist in the document; so the new objects was renamed:" + replacemWarn ); // Activate VTK viewer and show the bathymetry SUIT_ViewManager* aVTKMgr = 0; @@ -193,26 +279,8 @@ bool HYDROGUI_ImportBathymetryOp::processApply( int& theUpdateFlags, } } - /* - // If there is no VTK viewer yet then create a new one - if ( !aVTKMgr ) - { - aVTKMgr = module()->getApp()->createViewManager( SVTK_Viewer::Type() ); - } - // Set the bathymetry visible in the VTK viewer - if ( aVTKMgr ) - { - module()->setObjectVisible( (size_t)aVTKMgr->getViewModel(), aBathymetryObj, true ); - }*/ - theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | - UF_VTKViewer | UF_VTK_Forced; - - if( !myIsEdit ) - { - QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aBathymetryObj ); - theBrowseObjectsEntries.append( anEntry ); - } + UF_VTKViewer | UF_VTK_Forced; return true; } @@ -224,11 +292,17 @@ void HYDROGUI_ImportBathymetryOp::onFileSelected() if ( !aPanel ) return; + QStringList aFileNames = aPanel->getFileNames(); + if ( !aPanel->isFuseIntoOneOptionEnabled() ) + aPanel->setFuseIntoOneOptionEnabled( !myIsEdit && aFileNames.count() > 1 ); + QString anObjectName = aPanel->getObjectName().simplified(); if ( anObjectName.isEmpty() ) { - anObjectName = aPanel->getFileNames().join("\n"); //TODO temp - if ( !anObjectName.isEmpty() ) { + if (aFileNames.count() == 1) + { + anObjectName = aFileNames[0]; + if ( !anObjectName.isEmpty() ) anObjectName = QFileInfo( anObjectName ).baseName(); } @@ -239,5 +313,16 @@ void HYDROGUI_ImportBathymetryOp::onFileSelected() } } +bool HYDROGUI_ImportBathymetryOp::CheckNameExistingBathy(const QString& InpName, QString& OutputName) +{ + Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), InpName ); + if (anObject.IsNull()) + return false; + else + { + OutputName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_BATHYMETRY_NAME" ) ); + return true; + } +} diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h index fe214c34..57a7e95d 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.h @@ -42,6 +42,8 @@ protected: virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg, QStringList& theBrowseObjectsEntries ); + bool CheckNameExistingBathy(const QString& InpName, QString& OutputName); + protected slots: void onFileSelected(); diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 7b3a26b1..52583d87 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -141,9 +141,14 @@ does not exist or you have not enough permissions to open it. The object name must not be an empty string value. - INCORRECT_FILE_NAME - The file name must not be an empty string value. + EMPTY_FILENAMES + Files list is empty + + BATHEMETRY_IMPORT_WARNING + Imort of bahemetry - warning + + INSUFFICIENT_INPUT_DATA Insufficient input data @@ -619,7 +624,13 @@ Do you want to continue? '%1' file cannot be correctly imported for a Bathymetry definition. - + + BAD_IMPORTED_BATHYMETRY_FILES + '%1' +All files cannot be correctly imported for a Bathymetry definition. + + + HYDROGUI_ImportImageDlg diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index 8ff5e1c0..064f9e83 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -19,6 +19,8 @@ set(PROJECT_HEADERS test_HYDROGUI_ListModel.h test_HYDROGUI_Shape.h test_HYDROGUI_LandCoverMapDlg.h + test_HYDROData_CalcCase.h + test_Dependencies.h TestShape.h @@ -44,6 +46,7 @@ set(PROJECT_SOURCES test_HYDROGUI_ListModel.cxx test_HYDROGUI_Shape.cxx test_HYDROGUI_LandCoverMapDlg.cxx + test_HYDROData_CalcCase.cxx test_Dependencies.cxx TestShape.cxx diff --git a/src/HYDRO_tests/reference_data/CMakeLists.txt b/src/HYDRO_tests/reference_data/CMakeLists.txt index e1b18f95..891597b4 100644 --- a/src/HYDRO_tests/reference_data/CMakeLists.txt +++ b/src/HYDRO_tests/reference_data/CMakeLists.txt @@ -102,6 +102,14 @@ SET(REFERENCE_DATA t1.dbf test_LCM.dbf test.telemac + r2.brep + p1.brep + p2.brep + p3.brep + cc_int_w_1.png + cc_int_w_2.png + cc_int_w_3.png + ) # Application tests diff --git a/src/HYDRO_tests/reference_data/cc_int_w_1.png b/src/HYDRO_tests/reference_data/cc_int_w_1.png new file mode 100644 index 0000000000000000000000000000000000000000..4762944546f90db3a6ef176a51d36007add21041 GIT binary patch literal 3997 zcmeHIdpMM78^7O~iE*AmC5OB-pd+J@a6-k78kgV73Q!giu1hjQ+1n%XI=v`Hc* zJA71V%3)DrS8dA1N+>erkW+GqO$y)R`mXP<@6Yf0{@H8q>w4dLpXa^r`}cc(@9&xC zB;RGDnzF7k0H|$p;<*D*aR7=JT>;Ic9}B-g-gQrQw%5B+vF4RFC!5r$@6d@+ex|uw|=_D(iCE)r?2&1*J|M3vX{o ziBR&*KH$NdU=LpVK_om}{b7UGp3>v=x2B^Dj4Dp1iujB26C(o(OK)X9J^qAS@jh&} zZ|+a)hPn6U>EYWN-q*ji>WiDPIpRu3bpDRN75Hl@P~9JMAOsxO+9m{<%V(ZG&4}}( z0`HN^T3s2R(_=pYp!!>)iE^EdkvlsENbP9s=`Md!Hctcisf)FiFf@CdCxF;#E!*hm zOjOb|p!u=ZfvsYixoQoSXpQRf5hX(yI|}ytl)CbM!Lni~3goTqC^l0CJ~CDUCwKIm z*bA~aXDN+445KLw9jLX>gPuK|hHu$4QXtVLi#bycK4M5#IZI(^U=+|$T1ZZ>nm)Eo z4AnpJl!>n>G%z)BCo7WVx<`5)m+!$C&m<58E$hLA5zeW97*;rYFw($B7xg+$yyM=*bzl zSFCMae?E*KvEi!S&0HJ^&4jY@((hd+Loz)~Oy67>{NVq3Ya#=1)3py2YE7R_(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qGzla_qbC_R<6GRR_Bt{9YC!pZ#@WVxqG0@W^a*`zH!Y`%m;&$T9+sg?_F2qEiu| z@y52?wreE3@v9KBwXaE*&uhnp3WOAz=KvsZvIo$xD-vn()_|lO?xJhWk0ug}DE@;&G zuj$m1lF{GCGLA&QZ_e=99a7|7vVU^C_px2ok-1q5&%*HDN9QkmQ|MbB^Eh>tJmcSL zpEg)`=w1IGKglnprA-B$A3~y>9gq)cJo!9SKhoFv;YCnUd}ZMzsu~~fXy15R|Ks>& zo7l_Of@}bU2?Yi<6&B%r_ih`Gw3m&jSbo>>^UhZ9b%)=5{-dX-M+0&2DSMZHdr!k` zLE$9&Y7(?I#hKWdnzzFid!Fd;^?&(|Uwovzxw%;*!%GD~QriL1-AR^J^5%-N?_Pc# z+uwLKX=?$JmnY;BE|;vvp5?Y!N00Zs8E!8tDvuawI-KFH1rQ~;KBqczYN6S5c!=N6 zp|3*?hJs&KOg;@j;o;#i*H#kL>MD;JD(H^9fgHo@o5IE2$Li|rW@ literal 0 HcmV?d00001 diff --git a/src/HYDRO_tests/reference_data/cc_int_w_2.png b/src/HYDRO_tests/reference_data/cc_int_w_2.png new file mode 100644 index 0000000000000000000000000000000000000000..70ef70e65d69c20d7d48b13213470f701c3f055f GIT binary patch literal 4119 zcmeHJ`8$+-7e6zGxh0IHL}={EL|H0JW}2jt$MRMWB9ykFg~~qRPL!f3Eu!QRDo;Y8 zcx$>mzJLh}O=bZVRbDwjccC_CpIZtUG z07%-ftTqFPPyvW8m>7~I2S)m#2k9u&W-Er)F>H4X`YrCq+IAE`>Z$M|T+)+T3?N-> zW3_H;@HJkW`)y@s0(s;?%c2KfT*oM-+ev4_uxbU}a&2QQWU2RUFP5tpO-mtBy&$Hr zDC)IEjHS2LI<~==zepESlqhO>(#&KA#q()8Ra~og{g%EhP0i+(QM@vnp_*4iFRvcm z8%|%^T2@wU#QA7?be2zlAV)+Y{aU{m`2S*HMX|>lb5N7t@PxW4iZeP1_+iu2(UhzdizE#4pJ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kWsTQK`QswD-L5*y_|7-{Kw#*;p-mlmczB1>9=9{bHCHu*=E2yNY1CdNy^G`n ze4Zr&Zee%-Yl(^+g`FE%ARo}*Dkp}Q+Hn#)@0YALjpPL6X5LPuQy`Cc{M4$~n~m$1 z$N?*+@<~R4eDO#P8O&&boqt#|QUCk3elhSL2HXwJ&G{4EFRny9nB*848KwBPJ{o;j z9>yo4}R=Xpj-O)a-D;Q+Xc~C-%*!f7bogCsBZ7ykA|lE(Ed;|6WiHU zeReKn^3y5$x6iQ#LoE;XH8f`Z_^E4qMPD#jd0ZqVr5&}gG?8=4ruWPG!cYYLO}?Q> z1s|d?(48G>H(c3X#;KV6uq&R|dVkN0o9}Zy=eqdA6>~$WYdPT`CxkKmv;5uXd@8Vw z>l-J+k?gR^n668iWEq!}H#*RP+MB-1kM2c1w!-E|)vw4%8+=|)hpn>N0sqr39mzl}p zo>YGG7KgRp9Nk;c__+M;gY4bKfcW%mb;_fu0;*p+G@@`{d!cgNWSIF3OBo*Uf)CacLO7$0Iede0&FY5)}&w05D z*DS-PKi;q4{SbtYTIV|7oiN(hkQz2SG+h7cm8E;28=6o4O2yK(at;T|$0|i`ctm`C zxw@k{pu<@|qSPqfVyttu*a^>zQ|@J-1HT6wM15|Prq7>Sc4p+;)Kq)#T!r9!OT}Ly z<6mzqiI^E}XsE9jXhc!Ysji*Q$#Hua-t+Xd-2NNK#_BwsCkjw(zfU;LozHIj7}}~d zn8u{$<)-yt$53M!}1$~i_Z6;HhMQJ-~5mG*15;zEz!{(-$S37Z;&b1 k@&Bhj|JNG^rWQ3PqVkDtWO75|rV!m`gT2)~=8njJ1N?G!>;M1& literal 0 HcmV?d00001 diff --git a/src/HYDRO_tests/reference_data/cc_int_w_3.png b/src/HYDRO_tests/reference_data/cc_int_w_3.png new file mode 100644 index 0000000000000000000000000000000000000000..cdeffb4a98fa91beaa5c00accb4024af3aacce70 GIT binary patch literal 4196 zcmeHK`#)6M8(w?HW#njPC{C%FpN_E_(A!RBeDp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#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +const QString REF_DATA_PATH = qgetenv( "HYDRO_ROOT_DIR" ) + "/bin/salome/test"; + + +void test_HYDROData_CalcCase::test_add_int_wires() +{ + { + TopoDS_Shape out; + TopTools_ListOfShape Wires; + + BRep_Builder B; + TopoDS_Shape InF; + TopoDS_Shape InP; + BRepTools::Read(InP, (REF_DATA_PATH + "/p1.brep").toStdString().c_str(), B); + BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B); + Wires.Append(InP); + + TopTools_ListOfShape OutSh; + HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh); + CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent()); + TopoDS_Compound cmp; + B.MakeCompound(cmp); + B.Add(cmp, OutSh.First()); + B.Add(cmp, OutSh.Last()); + TestViewer::show( cmp, AIS_Shaded, true, "cc_int_w_1" ); + //CPPUNIT_ASSERT_IMAGES + } + + { + TopoDS_Shape out; + TopTools_ListOfShape Wires; + + BRep_Builder B; + TopoDS_Shape InF; + TopoDS_Shape InP; + BRepTools::Read(InP, (REF_DATA_PATH + "/p2.brep").toStdString().c_str(), B); + BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B); + Wires.Append(InP); + + TopTools_ListOfShape OutSh; + HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh); + CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent()); + TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" ); + //CPPUNIT_ASSERT_IMAGES + } + + { + TopoDS_Shape out; + TopTools_ListOfShape Wires; + + BRep_Builder B; + TopoDS_Shape InF; + TopoDS_Shape InP; + BRepTools::Read(InP, (REF_DATA_PATH + "/p3.brep").toStdString().c_str(), B); + BRepTools::Read(InF, (REF_DATA_PATH + "/r2.brep").toStdString().c_str(), B); + Wires.Append(InP); + + TopTools_ListOfShape OutSh; + HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh); + CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent()); + TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3" ); + CPPUNIT_ASSERT_IMAGES + } + +} + + + diff --git a/src/HYDRO_tests/test_HYDROData_CalcCase.h b/src/HYDRO_tests/test_HYDROData_CalcCase.h new file mode 100644 index 00000000..c4dbda7f --- /dev/null +++ b/src/HYDRO_tests/test_HYDROData_CalcCase.h @@ -0,0 +1,43 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifdef WIN32 + #pragma warning( disable: 4251 ) +#endif + +#include +#define SHP_TESTS + +class test_HYDROData_CalcCase : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( test_HYDROData_CalcCase ); + CPPUNIT_TEST( test_add_int_wires ); + + CPPUNIT_TEST_SUITE_END(); + +public: + void test_add_int_wires(); + +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_CalcCase ); +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( test_HYDROData_CalcCase, "HYDROData_CalcCase" ); + +#ifdef WIN32 + #pragma warning( default: 4251 ) +#endif diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx index a66ae5ef..3656a9aa 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.cxx @@ -1278,24 +1278,3 @@ void test_HYDROData_LandCoverMap::test_shp_clc_classification_check() } -void test_HYDROData_LandCoverMap::test_add_int_edges_1() -{ - TopoDS_Shape out; - TopTools_ListOfShape Wires; - - BRep_Builder B; - TopoDS_Shape InF; - TopoDS_Shape InP; - BRepTools::Read(InP, "d:/p2.brep", B); //TODO - BRepTools::Read(InF, "d:/r2.brep", B); - Wires.Append(InP); - - TopTools_ListOfShape OutSh; - HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh); - TopTools_ListIteratorOfListOfShape it(OutSh); - for (;it.More();it.Next()) - { - TopoDS_Shape Sh = it.Value(); - } -} - diff --git a/src/HYDRO_tests/test_HYDROData_LandCoverMap.h b/src/HYDRO_tests/test_HYDROData_LandCoverMap.h index cdf06fa3..c473c4a1 100644 --- a/src/HYDRO_tests/test_HYDROData_LandCoverMap.h +++ b/src/HYDRO_tests/test_HYDROData_LandCoverMap.h @@ -52,7 +52,6 @@ class test_HYDROData_LandCoverMap : public CppUnit::TestFixture CPPUNIT_TEST( test_shp_loop_back ); CPPUNIT_TEST( test_shp_clc_classification_perf ); CPPUNIT_TEST( test_shp_clc_classification_check ); - CPPUNIT_TEST( test_add_int_edges_1 ); #endif CPPUNIT_TEST_SUITE_END(); @@ -82,7 +81,6 @@ public: void test_copy(); void test_shp_clc_classification_perf(); void test_shp_clc_classification_check(); - void test_add_int_edges_1(); }; CPPUNIT_TEST_SUITE_REGISTRATION( test_HYDROData_LandCoverMap ); -- 2.39.2