From 28bd174c0d97b0ab08445fbfe3be6fd93cca0950 Mon Sep 17 00:00:00 2001 From: gdd Date: Fri, 7 Oct 2011 09:56:54 +0000 Subject: [PATCH] rnc : Finished a first demo prototype A textured shape can now be selected in the FeatureDetection dialog and the associated texture is used to detect contours and corners. --- resources/GEOM_en.xml | 1 + .../EntityGUI_FeatureDetectorDlg.cxx | 42 ++++++++++++++++--- src/EntityGUI/EntityGUI_FeatureDetectorDlg.h | 1 + 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/resources/GEOM_en.xml b/resources/GEOM_en.xml index d664cfd5b..033ccbd86 100644 --- a/resources/GEOM_en.xml +++ b/resources/GEOM_en.xml @@ -293,6 +293,7 @@ + diff --git a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx index a499cf8d6..bf9346bcb 100644 --- a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx +++ b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx @@ -32,6 +32,8 @@ #include #include +#include + #include #include #include @@ -46,6 +48,8 @@ #include #include +#include + #include #include @@ -357,6 +361,12 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument() LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); SALOME_ListIO aSelList; aSelMgr->selectedObjects(aSelList); + SALOME_ListIteratorOfListIO anIt( aSelList ); + for( ; anIt.More(); anIt.Next() ) + if( !anIt.Value().IsNull() ) + { + myFaceEntry = anIt.Value()->getEntry(); + } if (aSelList.Extent() != 1) { if (myEditCurrentArgument == myLineEdit) @@ -558,7 +568,27 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) bool res = false; SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow(); OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); - QString theImgFileName = vp->backgroundImageFilename(); +// QString theImgFileName = vp->backgroundImageFilename(); + + MESSAGE("myFaceEntry = "<< myFaceEntry.toStdString()); + std::map< std::string , std::vector >::iterator AISit; + SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel()); + + MESSAGE("repere1") + AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString()); + if (AISit == soccViewer->entry2aisobjects.end()) + return res; + + Handle(AIS_InteractiveObject) myAIS = (*AISit).second[0]; + Handle(GEOM_AISShape) myAISShape; + if( myAIS->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) { + myAISShape = Handle(GEOM_AISShape)::DownCast( myAIS ); + } + else + return res; + + QString theImgFileName = QString::fromStdString( myAISShape->TextureFile() ); + if ( theImgFileName.isEmpty() ) return res; @@ -637,9 +667,9 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) // double z = aCornerPnt.Z(); // When using the new way with textures on shapes we just have to do the following - double x = corners[i].x; - double y = height - corners[i].y; - double z = 0; + double x = -0.5*width + corners[i].x; + double y = 0.5*height - corners[i].y; + double z = 0; aGeomCorner = aBasicOperations->MakePointXYZ( x,y,z ); @@ -708,8 +738,8 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) // if (pnt_it.second == true) // { // MESSAGE("point absent du contour insere") - double x = it->x; - double y = height - it->y; + double x = -0.5*width + it->x; + double y = 0.5 *height - it->y; double z = 0; aGeomContourPnt = aBasicOperations->MakePointXYZ( x,y,z ); geomContourPnts[j] = aGeomContourPnt; diff --git a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.h b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.h index b9c371a5a..949d237f1 100644 --- a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.h +++ b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.h @@ -71,6 +71,7 @@ private slots: private: GEOM::GeomObjPtr myFace; + QString myFaceEntry; int myConstructorId; -- 2.39.2