From 80fcb4b456c8a0063fcb89922defae74e5b17f34 Mon Sep 17 00:00:00 2001 From: gdd Date: Wed, 14 Sep 2011 12:03:00 +0000 Subject: [PATCH] rnc: return a compound instead of wires --- .../EntityGUI_FeatureDetectorDlg.cxx | 39 ++++++++++++++----- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx index 952b069ef..80c89e610 100644 --- a/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx +++ b/src/EntityGUI/EntityGUI_FeatureDetectorDlg.cxx @@ -516,10 +516,10 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const QPoint& theEndPnt) //================================================================================= GEOM::GEOM_IOperations_ptr EntityGUI_FeatureDetectorDlg::createOperation() { - if (myConstructorId == CORNERS) +// if (myConstructorId == CORNERS) return myGeomGUI->GetGeomGen()->GetIShapesOperations( getStudyId() ); - else - return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); +// else +// return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); } //================================================================================= @@ -529,6 +529,7 @@ GEOM::GEOM_IOperations_ptr EntityGUI_FeatureDetectorDlg::createOperation() bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) { MESSAGE("EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )") + bool res = false; SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow(); OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); @@ -580,6 +581,9 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) QRect aRect = QRect(myStartPnt, myEndPnt); + + GEOM::GEOM_IBasicOperations_var aBasicOperations = myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() ); + GEOM::GEOM_IShapesOperations_var aShapesOperations = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); if (myConstructorId == CORNERS) { if( !aRect.isEmpty() ) @@ -592,10 +596,7 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) CvPoint2D32f* corners = aDetector->GetCorners(); int cornerCount = aDetector->GetCornerCount(); - // Build the geom objects associated to the detected corners and returned by execute - GEOM::GEOM_IBasicOperations_var aBasicOperations = myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() ); - GEOM::GEOM_IShapesOperations_var aShapesOperations = GEOM::GEOM_IShapesOperations::_narrow( getOperation() ); - + // Build the geom objects associated to the detected corners and returned by execute if( !aBasicOperations->_is_nil() && !aShapesOperations->_is_nil() ) { GEOM::GEOM_Object_var aGeomCorner; @@ -642,8 +643,8 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) aDetector->SetROI( aRect ); } - GEOM::GEOM_IBasicOperations_var aBasicOperations = myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() ); - GEOM::GEOM_ICurvesOperations_var aCurveOperations = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); + GEOM::GEOM_ICurvesOperations_var aCurveOperations = myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); +// GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); aDetector->ComputeContours(); std::vector< std::vector > contours = aDetector->GetContours(); @@ -651,6 +652,11 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) std::vector< cv::Point > contour; int idx = 0; + + GEOM::ListOfGO_var geomContours = new GEOM::ListOfGO(); + int contourCount = 0; + + MESSAGE("hierarchy.size() =" << hierarchy.size()) for( ; idx >= 0; idx = hierarchy[idx][0] ) { contour = contours[idx]; @@ -659,6 +665,7 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) GEOM::ListOfGO_var geomContourPnts = new GEOM::ListOfGO(); geomContourPnts->length( contour.size() ); + std::cout<<"repere1"<MakePolyline(geomContourPnts.in(), false); // GEOM::GEOM_Object_var aWire = aCurveOperations->MakeSplineInterpolation(geomContourPnts.in(), false, true); + std::cout<<"repere3"<_is_nil() ) { - objects.push_back( aWire._retn() ); + geomContours->length(contourCount + 1); + geomContours[contourCount] = aWire; + contourCount++; +// objects.push_back( aWire._retn() ); } } + std::cout<<"repere4, contourCount = "<MakeCompound(geomContours); + std::cout<<"repere5"<_is_nil() ) + { + objects.push_back( aContoursCompound._retn() ); + } res=true; } -- 2.39.2