rnc: return a compound instead of wires

This commit is contained in:
gdd 2011-09-14 12:03:00 +00:00
parent cedb03e2fb
commit 80fcb4b456

View File

@ -516,10 +516,10 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const QPoint& theEndPnt)
//================================================================================= //=================================================================================
GEOM::GEOM_IOperations_ptr EntityGUI_FeatureDetectorDlg::createOperation() GEOM::GEOM_IOperations_ptr EntityGUI_FeatureDetectorDlg::createOperation()
{ {
if (myConstructorId == CORNERS) // if (myConstructorId == CORNERS)
return myGeomGUI->GetGeomGen()->GetIShapesOperations( getStudyId() ); return myGeomGUI->GetGeomGen()->GetIShapesOperations( getStudyId() );
else // else
return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() ); // return myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
} }
//================================================================================= //=================================================================================
@ -529,6 +529,7 @@ GEOM::GEOM_IOperations_ptr EntityGUI_FeatureDetectorDlg::createOperation()
bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects ) bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
{ {
MESSAGE("EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )") MESSAGE("EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )")
bool res = false; bool res = false;
SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow(); SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort(); OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
@ -580,6 +581,9 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
QRect aRect = QRect(myStartPnt, myEndPnt); 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 (myConstructorId == CORNERS)
{ {
if( !aRect.isEmpty() ) if( !aRect.isEmpty() )
@ -593,9 +597,6 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
int cornerCount = aDetector->GetCornerCount(); int cornerCount = aDetector->GetCornerCount();
// Build the geom objects associated to the detected corners and returned by execute // 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() );
if( !aBasicOperations->_is_nil() && !aShapesOperations->_is_nil() ) if( !aBasicOperations->_is_nil() && !aShapesOperations->_is_nil() )
{ {
GEOM::GEOM_Object_var aGeomCorner; GEOM::GEOM_Object_var aGeomCorner;
@ -642,8 +643,8 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
aDetector->SetROI( aRect ); aDetector->SetROI( aRect );
} }
GEOM::GEOM_IBasicOperations_var aBasicOperations = myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() ); GEOM::GEOM_ICurvesOperations_var aCurveOperations = myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
GEOM::GEOM_ICurvesOperations_var aCurveOperations = GEOM::GEOM_ICurvesOperations::_narrow( getOperation() ); // GEOM::GEOM_ICurvesOperations::_narrow( getOperation() );
aDetector->ComputeContours(); aDetector->ComputeContours();
std::vector< std::vector<cv::Point> > contours = aDetector->GetContours(); std::vector< std::vector<cv::Point> > contours = aDetector->GetContours();
@ -651,6 +652,11 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
std::vector< cv::Point > contour; std::vector< cv::Point > contour;
int idx = 0; 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] ) for( ; idx >= 0; idx = hierarchy[idx][0] )
{ {
contour = contours[idx]; contour = contours[idx];
@ -659,6 +665,7 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
GEOM::ListOfGO_var geomContourPnts = new GEOM::ListOfGO(); GEOM::ListOfGO_var geomContourPnts = new GEOM::ListOfGO();
geomContourPnts->length( contour.size() ); geomContourPnts->length( contour.size() );
std::cout<<"repere1"<<std::endl;
int j = 0; int j = 0;
for ( it=contour.begin() ; it < contour.end(); it++ ) for ( it=contour.begin() ; it < contour.end(); it++ )
{ {
@ -676,13 +683,25 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
geomContourPnts[j] = aGeomContourPnt; geomContourPnts[j] = aGeomContourPnt;
j++; j++;
} }
std::cout<<"repere2"<<std::endl;
GEOM::GEOM_Object_var aWire = aCurveOperations->MakePolyline(geomContourPnts.in(), false); GEOM::GEOM_Object_var aWire = aCurveOperations->MakePolyline(geomContourPnts.in(), false);
// GEOM::GEOM_Object_var aWire = aCurveOperations->MakeSplineInterpolation(geomContourPnts.in(), false, true); // GEOM::GEOM_Object_var aWire = aCurveOperations->MakeSplineInterpolation(geomContourPnts.in(), false, true);
std::cout<<"repere3"<<std::endl;
if ( !aWire->_is_nil() ) if ( !aWire->_is_nil() )
{ {
objects.push_back( aWire._retn() ); geomContours->length(contourCount + 1);
geomContours[contourCount] = aWire;
contourCount++;
// objects.push_back( aWire._retn() );
} }
} }
std::cout<<"repere4, contourCount = "<<contourCount<<std::endl;
GEOM::GEOM_Object_var aContoursCompound = aShapesOperations->MakeCompound(geomContours);
std::cout<<"repere5"<<std::endl;
if ( !aContoursCompound->_is_nil() )
{
objects.push_back( aContoursCompound._retn() );
}
res=true; res=true;
} }