1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File : EntityGUI_SketcherDlg.cxx
25 // Author : Renaud NEDELEC, Open CASCADE S.A.S.
27 #include "EntityGUI_FeatureDetectorDlg.h"
29 #include <OCCViewer_ViewWindow.h>
30 #include <OCCViewer_ViewManager.h>
32 #include <SOCC_ViewModel.h>
35 #include <GeometryGUI.h>
36 #include <EntityGUI.h>
38 #include <GEOM_Object.hxx>
40 #include <SUIT_Desktop.h>
41 #include <SUIT_ResourceMgr.h>
42 #include <SUIT_Session.h>
43 #include <SUIT_ViewWindow.h>
44 #include <SalomeApp_Application.h>
45 #include <LightApp_Application.h>
46 #include <LightApp_SelectionMgr.h>
48 #include <SALOME_ListIteratorOfListIO.hxx>
50 #include <SalomeApp_Study.h>
52 #include <utilities.h>
55 #include <TopoDS_Shape.hxx>
56 #include <TopoDS_Wire.hxx>
58 #include <BRepBuilderAPI_MakeVertex.hxx>
59 #include <BRepBuilderAPI_MakeFace.hxx>
60 #include <BRepBuilderAPI_MakePolygon.hxx>
61 #include <BRepBuilderAPI_Transform.hxx>
63 #include <AIS_TexturedShape.hxx>
64 #include <TCollection_AsciiString.hxx>
65 #include <StdSelect_DisplayMode.hxx>
67 #include <Graphic3d_MaterialAspect.hxx>
69 #include <Precision.hxx>
74 #include <boost/utility.hpp>
97 //=================================================================================
98 // class : EntityGUI_FeatureDetectorDlg()
99 // purpose : Constructs a EntityGUI_FeatureDetectorDlg which is a child of 'parent', with the
100 // name 'name' and widget flags set to 'f'.
101 // The dialog will by default be modeless, unless you set 'modal' to
102 // TRUE to construct a modal dialog.
103 //=================================================================================
104 EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
105 bool modal, Qt::WindowFlags fl)
106 : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
108 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("OCCViewer", tr("ICON_OCCVIEWER_VIEW_DUMP")));
109 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
111 setWindowTitle(tr("GEOM_DETECT_TITLE"));
113 /***************************************************************/
115 mainFrame()->GroupConstructors->setTitle(tr("GEOM_FEATURES"));
116 mainFrame()->RadioButton1->setText(tr("GEOM_CONTOURS"));
117 mainFrame()->RadioButton2->setText(tr("GEOM_CORNERS"));
118 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
119 mainFrame()->RadioButton3->close();
121 // myViewGroup = new DlgRef_3Radio(centralWidget());
122 // myViewGroup->GroupBox1->setTitle(tr("GEOM_VIEW"));
123 // myViewGroup->RadioButton1->setText(tr( "GEOM_TOP" ));
124 // myViewGroup->RadioButton2->setText(tr( "GEOM_FRONT"));
125 // myViewGroup->RadioButton3->setText(tr( "GEOM_LEFT" ));
126 // myViewButtonGroup = new QButtonGroup( this );
127 // myViewButtonGroup->addButton( myViewGroup->RadioButton1, XY ); // Top view
128 // myViewButtonGroup->addButton( myViewGroup->RadioButton2, YZ ); // Front View
129 // myViewButtonGroup->addButton( myViewGroup->RadioButton3, XZ ); // Left View
131 // myViewGroup->hide();
133 mySelectionGroup = new QGroupBox(tr("GEOM_DETECT"), centralWidget());
134 QGridLayout* mySelectGrpLayout = new QGridLayout(mySelectionGroup);
135 myPushButton = new QPushButton(mySelectionGroup);
136 myPushButton->setIcon(image0);
137 myPushButton->setCheckable(true);
139 mySelButton = new QPushButton(mySelectionGroup);
140 mySelButton->setIcon(image1);
141 myLineEdit = new QLineEdit(mySelectionGroup);
143 mySnapshotLabel = new QLabel(mySelectionGroup);
144 QFrame* myImgSampleFrame = new QFrame(mySelectionGroup);
145 // myImgSampleFrame->setFrameRect(QRect(0,0,10,10));
146 myImgSampleFrame->setFrameStyle(QFrame::Box);
147 QLabel* myPictureLabel = new QLabel(tr( "GEOM_PICTURE" ),mySelectionGroup);
148 mySelectGrpLayout->addWidget(myPictureLabel, 0, 0);
149 mySelectGrpLayout->addWidget(mySelButton, 0, 1);
150 mySelectGrpLayout->addWidget(myLineEdit, 0, 2);// 1, 2);
152 mySelectGrpLayout->addWidget(mySnapshotLabel, 1, 0);
153 mySelectGrpLayout->addWidget(myPushButton, 1, 1);
154 mySelectGrpLayout->addWidget(myImgSampleFrame, 1, 2);
155 // mySelectGrpLayout->setColumnStretch(3, 1);
157 QGridLayout* myFrameLayout = new QGridLayout(myImgSampleFrame);
158 myImgSampleLabel = new QLabel(myImgSampleFrame);
159 myFrameLayout->addWidget(myImgSampleLabel, 0, 0);
161 myOutputGroup = new DlgRef_3Radio(centralWidget());
162 myOutputGroup->GroupBox1->setTitle(tr("GEOM_DETECT_OUTPUT"));
163 myOutputGroup->RadioButton2->setText(tr( "GEOM_POLYLINE" ));
164 myOutputGroup->RadioButton1->setText(tr( "GEOM_SPLINE"));
165 myOutputGroup->RadioButton3->hide();
167 // myOutputGroup->hide(); //caché pour la demo
169 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
170 layout->setMargin(0); layout->setSpacing(6);
171 // layout->addWidget( myViewGroup);
172 layout->addWidget( mySelectionGroup);
173 layout->addWidget( myOutputGroup);
175 // mainFrame()->GroupBoxName->hide();
177 // Build an instance of detection used to perform image processing operations
178 aDetector = new ShapeRec_FeatureDetector();
184 //=================================================================================
185 // function : ~EntityGUI_FeatureDetectorDlg()
186 // purpose : Destroys the object and frees any allocated resources
187 //=================================================================================
188 EntityGUI_FeatureDetectorDlg::~EntityGUI_FeatureDetectorDlg()
193 //=================================================================================
196 //=================================================================================
197 void EntityGUI_FeatureDetectorDlg::Init()
199 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
200 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
201 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
203 connect( this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));
205 connect( myPushButton, SIGNAL( toggled( bool ) ), this, SLOT( onButtonToggled( bool ) ) );
206 connect( mySelButton, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
208 // connect( myViewButtonGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( onViewClicked( int ) ) );
210 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),this, SLOT( SelectionIntoArgument() ) );
214 mySelButton->click();
215 mySelButton->setDown(true);
217 // SetEditCurrentArgument();
218 SelectionIntoArgument();
220 initName(tr("GEOM_CONTOURS"));
223 // myViewGroup->RadioButton1->setChecked(true);
224 myOutputGroup->RadioButton1->setChecked(true);
226 gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
227 gp_Dir aDirZ = gp_Dir(0, 0, 1);
228 gp_Dir aDirX = gp_Dir(1, 0, 0);
230 aGlobalCS = gp_Ax3(aOrigin, aDirZ, aDirX);
232 myStartPnt = gp_Pnt(0,0,0);
233 myEndPnt = myStartPnt;
235 myGeomGUI->SetWorkingPlane( aGlobalCS );
236 myGeomGUI->ActiveWorkingPlane();
238 ConstructorsClicked(myConstructorId);
241 //=================================================================================
242 // function : SetEditCurrentArgument()
244 //=================================================================================
245 void EntityGUI_FeatureDetectorDlg::SetEditCurrentArgument()
247 QPushButton* send = (QPushButton*)sender();
248 if ( send == mySelButton ) {
249 myEditCurrentArgument = myLineEdit;
250 myLineEdit->setEnabled(true);
253 myLineEdit->setEnabled(false);
257 //=================================================================================
258 // function : SelectionIntoArgument()
259 // purpose : Called when selection as changed or other case
260 //=================================================================================
261 void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
264 SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
265 std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
266 SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
268 if (!myEditCurrentArgument->isEnabled())
271 myEditCurrentArgument->setText( "" );
273 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
274 SALOME_ListIO aSelList;
275 aSelMgr->selectedObjects(aSelList);
276 SALOME_ListIteratorOfListIO anIt( aSelList );
278 for( ; anIt.More(); anIt.Next() )
279 if( !anIt.Value().IsNull() )
281 myFaceEntry = anIt.Value()->getEntry();
284 if (aSelList.Extent() != 1) {
285 if (myEditCurrentArgument == myLineEdit)
290 TopAbs_ShapeEnum aNeedType = TopAbs_FACE ;
291 GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
293 if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
294 QString aName = GEOMBase::GetName( aSelectedObject.get() );
295 myEditCurrentArgument->setText( aName );
297 if ( myEditCurrentArgument == myLineEdit ) {
298 myFace = aSelectedObject;
299 AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString());
300 if (AISit == soccViewer->entry2aisobjects.end())
303 Handle(AIS_InteractiveObject) myAIS = (*AISit).second[0];
304 Handle(GEOM_AISShape) myAISShape;
305 if( myAIS->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
306 myAISShape = Handle(GEOM_AISShape)::DownCast( myAIS );
311 std::string theImgFileName = myAISShape->TextureFile();
312 if ( theImgFileName == "" )
315 aDetector->SetPath( theImgFileName );
321 //=================================================================================
322 // function : acceptMouseEvent()
324 //=================================================================================
325 bool EntityGUI_FeatureDetectorDlg::acceptMouseEvent() const
327 return myPushButton->isChecked();
330 //=======================================================================
331 // function : ClickOnOk()
333 //=======================================================================
334 void EntityGUI_FeatureDetectorDlg::ClickOnOk()
336 setIsApplyAndClose( true );
341 //=================================================================================
342 // function : ClickOnApply()
344 //=================================================================================
345 bool EntityGUI_FeatureDetectorDlg::ClickOnApply()
351 ConstructorsClicked(getConstructorId());
355 //=================================================================================
356 // function : onConstructorClicked(int)
358 //=================================================================================
359 void EntityGUI_FeatureDetectorDlg::ConstructorsClicked(int id)
361 MESSAGE("Constructor id ="<<id)
362 myConstructorId = id;
366 // myViewGroup->show();
367 // mySelectionGroup->show();
368 myOutputGroup->hide();
369 mySnapshotLabel->setText(tr("GEOM_DETECT_ZONE"));
370 initName(tr("GEOM_CORNERS"));
373 // myViewGroup->hide();
374 // mySelectionGroup->hide();
375 // mySelectionGroup->show();
376 myOutputGroup->show();
377 mySnapshotLabel->setText(tr("GEOM_COLOR_FILTER"));
378 initName(tr("GEOM_CONTOURS"));
381 // myViewGroup->hide();
382 // mySelectionGroup->hide();
383 // mySelectionGroup->show();
384 myOutputGroup->hide();
385 mySnapshotLabel->setText(tr(""));
386 initName(tr("GEOM_LINES"));
391 // //=================================================================================
392 // // function : onViewClicked()
394 // //=================================================================================
395 // void EntityGUI_FeatureDetectorDlg::onViewClicked(int id)
397 // gp_Pnt aOrigin = gp_Pnt(0, 0, 0);
404 // aDirZ = gp_Dir(0, 0, 1);
405 // aDirX = gp_Dir(1, 0, 0);
408 // aDirZ = gp_Dir(1, 0, 0);
409 // aDirX = gp_Dir(0, 1, 0);
412 // aDirZ = gp_Dir(0, -1, 0);
413 // aDirX = gp_Dir(1, 0 , 0);
417 // myWPlane = gp_Ax3(aOrigin, aDirZ, aDirX);
418 // myGeomGUI->SetWorkingPlane( myWPlane );
419 // myGeomGUI->ActiveWorkingPlane();
423 //=================================================================================
424 // function : onButtonToggled()
426 //=================================================================================
427 void EntityGUI_FeatureDetectorDlg::onButtonToggled( bool checked)
431 myStartPnt = gp_Pnt(0,0,0);
432 myEndPnt = myStartPnt;
433 myLineEdit->setEnabled(true);
437 myLineEdit->setEnabled(false);
441 //=================================================================================
442 // function : setStartPnt( const QPoint& )
444 //=================================================================================
445 void EntityGUI_FeatureDetectorDlg::setStartPnt(const gp_Pnt& theStartPnt)
447 myStartPnt = theStartPnt;
448 MESSAGE("myStartPnt = ("<<theStartPnt.X()<<", "<<theStartPnt.Y()<<")")
451 //=================================================================================
452 // function : setEndPnt( const QPoint& )
454 //=================================================================================
455 void EntityGUI_FeatureDetectorDlg::setEndPnt(const gp_Pnt& theEndPnt)
457 myEndPnt = theEndPnt;
458 MESSAGE("myEndPnt = ("<<theEndPnt.X()<<", "<<theEndPnt.Y()<<")")
462 //=================================================================================
463 // function : showImageSample()
465 //=================================================================================
466 void EntityGUI_FeatureDetectorDlg::showImageSample()
468 int height = aDetector->GetImgHeight();
469 int width = aDetector->GetImgWidth();
471 // Operations to display the corners properly in the 3D scene
472 double pictureLeft = -0.5 * width; // X coordinate of the top left corner of the background image in the view
473 double pictureTop = 0.5 * height; // Y coordinate of both top corners
475 // Set detection rectangle in the background image coordinates system
476 QPoint topLeft = QPoint(myStartPnt.X() - pictureLeft, pictureTop - myStartPnt.Y());
477 QPoint bottomRight = QPoint(myEndPnt.X() - pictureLeft, pictureTop - myEndPnt.Y());
478 QRect aRect = QRect(topLeft, bottomRight);
480 if( !aRect.isEmpty() && aRect.width() > 1 )
482 aDetector->SetROI( aRect );
483 std::string samplePicturePath = aDetector->CroppImage();
484 MESSAGE("samplePicturePath = "<<samplePicturePath)
485 QPixmap pixmap(QString(samplePicturePath.c_str()));
486 myImgSampleLabel->setPixmap(pixmap);
487 myImgSampleLabel->setMask(pixmap.mask());
493 //=================================================================================
494 // function : createOperation
496 //=================================================================================
497 GEOM::GEOM_IOperations_ptr EntityGUI_FeatureDetectorDlg::createOperation()
499 return myGeomGUI->GetGeomGen()->GetIShapesOperations( getStudyId() );
502 //=================================================================================
503 // function : execute()
505 //=================================================================================
506 bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
510 // SUIT_ViewWindow* theViewWindow = getDesktop()->activeWindow();
511 // std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator AISit;
512 // SOCC_Viewer* soccViewer = (SOCC_Viewer*)(theViewWindow->getViewManager()->getViewModel());
514 // AISit = soccViewer->entry2aisobjects.find(myFaceEntry.toStdString());
515 // if (AISit == soccViewer->entry2aisobjects.end())
518 // Handle(AIS_InteractiveObject) myAIS = (*AISit).second[0];
519 // Handle(GEOM_AISShape) myAISShape;
520 // if( myAIS->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) {
521 // myAISShape = Handle(GEOM_AISShape)::DownCast( myAIS );
526 // std::string theImgFileName = myAISShape->TextureFile();
528 // if ( theImgFileName == "" )
531 // aDetector->SetPath( theImgFileName );
533 int height = aDetector->GetImgHeight();
534 int width = aDetector->GetImgWidth();
536 // Operations to display the corners properly in the 3D scene
537 double pictureLeft = -0.5 * width; // X coordinate of the top left corner of the background image in the view
538 double pictureTop = 0.5 * height; // Y coordinate of both top corners
540 // Set detection rectangle in the background image coordinates system
541 QPoint topLeft = QPoint(myStartPnt.X() - pictureLeft, pictureTop - myStartPnt.Y());
542 QPoint bottomRight = QPoint(myEndPnt.X() - pictureLeft, pictureTop - myEndPnt.Y());
543 QRect aRect = QRect(topLeft, bottomRight);
545 GEOM::GEOM_IBasicOperations_var aBasicOperations = myGeomGUI->GetGeomGen()->GetIBasicOperations( getStudyId() );
546 GEOM::GEOM_IShapesOperations_var aShapesOperations = GEOM::GEOM_IShapesOperations::_narrow( getOperation() );
548 if (myConstructorId == CORNERS)
550 if( !aRect.isEmpty() )
552 aDetector->SetROI( aRect );
553 pictureLeft = myStartPnt.X();
554 pictureTop = myStartPnt.Y();
556 aDetector->ComputeCorners();
557 CvPoint2D32f* corners = aDetector->GetCorners();
558 int cornerCount = aDetector->GetCornerCount();
561 // Build the geom objects associated to the detected corners and returned by execute
562 if( !aBasicOperations->_is_nil() && !aShapesOperations->_is_nil() )
564 GEOM::GEOM_Object_var aGeomCorner;
565 GEOM::ListOfGO_var geomCorners = new GEOM::ListOfGO();
566 geomCorners->length( cornerCount );
567 for (i = 0; i < cornerCount; i++)
569 double x = pictureLeft + corners[i].x;
570 double y = pictureTop - corners[i].y;
573 aGeomCorner = aBasicOperations->MakePointXYZ( x,y,z );
575 geomCorners[i] = aGeomCorner;
577 GEOM::GEOM_Object_var aCompound = aShapesOperations->MakeCompound(geomCorners);
578 if ( !aCompound->_is_nil() )
581 SALOMEDS::Color aColor;
586 aCompound->SetColor(aColor);
587 aCompound->SetMarkerStd(GEOM::MT_POINT,GEOM::MS_30);
588 objects.push_back( aCompound._retn() );
593 else if (myConstructorId == CONTOURS)
595 int method = 0 ; //CANNY
596 if( !aRect.isEmpty() && aRect.width() > 1 )
598 aDetector->SetROI( aRect );
599 method = 1 ; //COLORFILTER
602 GEOM::GEOM_ICurvesOperations_var aCurveOperations = myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
604 aDetector->ComputeContours( method );
605 std::vector< std::vector<cv::Point> > contours = aDetector->GetContours();
606 std::vector<cv::Vec4i> hierarchy = aDetector->GetContoursHierarchy();
608 std::vector< cv::Point > contour;
611 GEOM::ListOfGO_var geomContours = new GEOM::ListOfGO();
612 int contourCount = 0;
616 MESSAGE("hierarchy.size() =" << hierarchy.size())
617 for( ; idx >= 0; idx = hierarchy[idx][0])
619 // for(int count=0, child=idx; child>=0, count<1; child=hierarchy[idx][2], count++)
621 // contour = contours[child];
622 contour = contours[idx];
623 std::vector< cv::Point >::iterator it;
624 std::vector< cv::Point >::iterator it_previous;
625 std::vector< cv::Point >::iterator it_next;
626 GEOM::GEOM_Object_var aGeomContourPnt;
627 GEOM::ListOfGO_var geomContourPnts = new GEOM::ListOfGO();
629 geomContourPnts->length( contour.size() );
632 std::set< std::vector<int> > existing_points;
633 std::pair< std::set< std::vector<int> >::iterator,bool > pnt_it;
634 for ( it=contour.begin() ; it < contour.end(); it++ )
636 int pnt_array[] = {it->x,it->y};
637 std::vector<int> pnt (pnt_array, pnt_array + sizeof(pnt_array) / sizeof(int) );
639 pnt_it=existing_points.insert(pnt);
640 if (pnt_it.second == true) // To avoid double points in the contours
643 if (it!=contour.begin()) // From the second point on perform some checking to avoid loops in the contours we build
645 it_previous = boost::prior(it);
646 it_next = boost::next(it);
648 double u_v_scalar_product = (it->x - it_previous->x) * (it_next->x - it->x) +
649 (it->y - it_previous->y) * (it_next->y - it->y);
650 if (u_v_scalar_product < 0)
652 double u_v_det = (it->x - it_previous->x) * (it_next->y - it->y) -
653 (it->y - it_previous->y) * (it_next->x - it->x);
655 double norme_u = sqrt ( (it->x - it_previous->x)*(it->x - it_previous->x) +
656 (it->y - it_previous->y)*(it->y - it_previous->y) );
658 double norme_v = sqrt ( (it->x - it_next->x)*(it->x - it_next->x) +
659 (it->y - it_next->y)*(it->y - it_next->y) );
661 double u_v_sinus = u_v_det / (norme_u * norme_v);
663 if (fabs(u_v_sinus) < Precision::Confusion())
669 double x = -0.5 *width + it->x;
670 double y = 0.5 *height - it->y;
674 aGeomContourPnt = aBasicOperations->MakePointXYZ( x,y,z );
675 geomContourPnts->length( j+1 );
676 geomContourPnts[j] = aGeomContourPnt;
682 GEOM::GEOM_Object_var aWire;
683 if(myOutputGroup->RadioButton2->isChecked())
685 aWire = aCurveOperations->MakePolyline(geomContourPnts.in(), false);
687 else if(myOutputGroup->RadioButton1->isChecked())
689 aWire = aCurveOperations->MakeSplineInterpolation(geomContourPnts.in(), /*closed =*/ false, /*reordering =*/ false);
694 if ( !aWire->_is_nil() )
696 geomContours->length(contourCount + 1);
697 geomContours[contourCount] = aWire;
702 GEOM::GEOM_Object_var aContoursCompound = aShapesOperations->MakeCompound(geomContours);
703 if ( !aContoursCompound->_is_nil() )
705 objects.push_back( aContoursCompound._retn() );
710 else if(myConstructorId ==LINES)
712 aDetector->ComputeLines();
713 std::vector<cv::Vec4i> lines = aDetector->GetLines();
714 GEOM::GEOM_Object_var Pnt1;
715 GEOM::GEOM_Object_var Pnt2;
716 GEOM::GEOM_Object_var aLine;
718 GEOM::ListOfGO_var geomLines = new GEOM::ListOfGO();
720 for( int i = 0; i < lines.size(); i++ )
722 Pnt1 = aBasicOperations->MakePointXYZ( -0.5 *width + lines[i][0], 0.5 *height - lines[i][1], 0 );
723 Pnt2 = aBasicOperations->MakePointXYZ( -0.5 *width + lines[i][2], 0.5 *height - lines[i][3], 0 );
724 aLine = aBasicOperations->MakeLineTwoPnt( Pnt1, Pnt2 );
725 if ( !aLine->_is_nil() )
727 geomLines->length(linesCount + 1);
728 geomLines[linesCount] = aLine;
732 GEOM::GEOM_Object_var aLinesCompound = aShapesOperations->MakeCompound(geomLines);
733 if ( !aLinesCompound->_is_nil() )
735 objects.push_back( aLinesCompound._retn() );