1 // Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // GEOM GEOMGUI : GUI for Geometry component
21 // File : EntityGUI_3DSketcherDlg.cxx
24 #include "EntityGUI_3DSketcherDlg.h"
25 #include "EntityGUI_Widgets.h"
26 #include <SalomeApp_DoubleSpinBox.h>
29 #include <GeometryGUI.h>
30 #include <GEOMImpl_Types.hxx>
31 #include <Precision.hxx>
34 #include <SUIT_Desktop.h>
35 #include <SUIT_Session.h>
36 #include <SUIT_MessageBox.h>
37 #include <SUIT_ResourceMgr.h>
38 #include <SalomeApp_Application.h>
39 #include <LightApp_Application.h>
40 #include <LightApp_SelectionMgr.h>
42 //#include <BRep_Tool.hxx>
43 //#include <TopExp.hxx>
44 //#include <TopExp_Explorer.hxx>
45 //#include <TopoDS_Vertex.hxx>
46 //#include <TopoDS.hxx>
47 #include <TColStd_IndexedMapOfInteger.hxx>
48 //#include <BRepBuilderAPI_Transform.hxx>
49 //#include <BRepBuilderAPI_MakeWire.hxx>
50 #include <BRepBuilderAPI_MakeVertex.hxx>
51 #include <BRepBuilderAPI_MakePolygon.hxx>
52 #include <BRepBuilderAPI_MakeEdge.hxx>
57 Locker( bool& l ) : myLock( l ) { myLock = true; }
58 ~Locker() { myLock = false; }
63 //=================================================================================
64 // class : EntityGUI_3DSketcherDlg()
65 // purpose : Constructs a EntityGUI_3DSketcherDlg which is a child of 'parent', with the
66 // name 'name' and widget flags set to 'f'.
67 // The dialog will by default be modeless, unless you set 'modal' to
68 // TRUE to construct a modal dialog.
69 //=================================================================================
70 EntityGUI_3DSketcherDlg::EntityGUI_3DSketcherDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
71 bool modal, Qt::WindowFlags fl,
72 const double lineWidth )
73 : GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl ),
76 myLineWidth( lineWidth ),
77 myGeometryGUI( theGeometryGUI )
79 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
80 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_UNDO" ) ) );
81 QPixmap image2( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REDO" ) ) );
82 QPixmap image3( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICO_3DSKETCH" ) ) );
84 setWindowTitle( tr( "GEOM_3DSKETCHER_TITLE" ) );
86 /***************************************************************/
88 mainFrame()->GroupConstructors->setTitle( tr( "GEOM_3DSKETCHER" ) );
89 mainFrame()->RadioButton1->setIcon( image3 );;
90 mainFrame()->RadioButton2->close();
91 mainFrame()->RadioButton3->close();
93 GroupType = new DlgRef_3Radio(centralWidget());
94 GroupType->GroupBox1->setTitle(tr("GEOM_COORDINATES_TYPE"));
95 GroupType->RadioButton1->setText(tr("GEOM_SKETCHER_ABS"));
96 GroupType->RadioButton2->setText(tr("GEOM_SKETCHER_REL"));
97 GroupType->RadioButton3->close();
98 myTypeGroup = new QButtonGroup( this );
99 myTypeGroup->addButton( GroupType->RadioButton1, 0 );
100 myTypeGroup->addButton( GroupType->RadioButton2, 1 );
102 Group3Spin = new EntityGUI_3Spin( centralWidget() );
103 Group3Spin->GroupBox1->setTitle( tr( "GEOM_SKETCHER_VALUES" ) );
104 Group3Spin->buttonApply->setText( tr( "GEOM_SKETCHER_APPLY" ) );
105 Group3Spin->buttonUndo->setIcon( image1 );
106 Group3Spin->buttonRedo->setIcon( image2 );
107 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
108 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
109 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) );
111 buttonOk()->setText( tr( "GEOM_BUT_END_SKETCH" ) );
112 buttonApply()->setText( tr( "GEOM_BUT_CLOSE_SKETCH" ) );
114 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
115 layout->setMargin( 0 ); layout->setSpacing( 6 );
116 layout->addWidget( GroupType );
117 layout->addWidget( Group3Spin );
119 setHelpFileName( "create_3dsketcher_page.html" );
127 //=================================================================================
128 // function : ~EntityGUI_3DSketcherDlg()
129 // purpose : Destroys the object and frees any allocated resources
130 //=================================================================================
131 EntityGUI_3DSketcherDlg::~EntityGUI_3DSketcherDlg()
133 myGeomGUI->SetActiveDialogBox( 0 );
136 //=================================================================================
139 //=================================================================================
140 void EntityGUI_3DSketcherDlg::Init()
144 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
146 /* Get setting of step value from file configuration */
147 double step = SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "SettingsGeomStep", 100.0 );
149 /* min, max, step and decimals for spin boxes */
150 initSpinBox( Group3Spin->SpinBox_DX, COORD_MIN, COORD_MAX, step, "length_precision" );
151 initSpinBox( Group3Spin->SpinBox_DY, COORD_MIN, COORD_MAX, step, "length_precision" );
152 initSpinBox( Group3Spin->SpinBox_DZ, COORD_MIN, COORD_MAX, step, "length_precision" );
154 Group3Spin->SpinBox_DX->setValue(0.0);
155 Group3Spin->SpinBox_DY->setValue(0.0);
156 Group3Spin->SpinBox_DZ->setValue(0.0);
158 /* signals and slots connections */
159 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
160 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
162 connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
164 connect( Group3Spin->buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnAddPoint() ) );
165 connect( Group3Spin->buttonUndo, SIGNAL( clicked() ), this, SLOT( ClickOnUndo() ) );
166 connect( Group3Spin->buttonRedo, SIGNAL( clicked() ), this, SLOT( ClickOnRedo() ) ) ;
168 connect( myTypeGroup, SIGNAL( buttonClicked( int ) ), this, SLOT( TypeClicked( int ) ) );
170 connect( Group3Spin->SpinBox_DX, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
171 connect( Group3Spin->SpinBox_DY, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
172 connect( Group3Spin->SpinBox_DZ, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) );
174 connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) );
176 connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) );
177 connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
179 initName( tr( "GEOM_3DSKETCHER" ) );
181 UpdateButtonsState();
182 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
185 //=================================================================================
186 // function : TypeClicked()
187 // purpose : Radio button management
188 //=================================================================================
189 void EntityGUI_3DSketcherDlg::TypeClicked( int mode )
191 if ( mode == myMode ) return;
193 bool blocked = Group3Spin->SpinBox_DX->signalsBlocked();
194 Group3Spin->SpinBox_DX->blockSignals(true);
195 Group3Spin->SpinBox_DY->blockSignals(true);
196 Group3Spin->SpinBox_DZ->blockSignals(true);
197 // Get setting of step value from file configuration
198 XYZ xyz = getLastPoint();
200 Group3Spin->SpinBox_DX->text().toDouble( &okx );
201 Group3Spin->SpinBox_DY->text().toDouble( &oky );
202 Group3Spin->SpinBox_DZ->text().toDouble( &okz );
203 if ( mode == 0 ) { // XY
204 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_X2" ) );
205 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_Y2" ) );
206 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_Z2" ) );
207 if ( okx ) Group3Spin->SpinBox_DX->setValue( xyz.x + Group3Spin->SpinBox_DX->value() );
208 if ( oky ) Group3Spin->SpinBox_DY->setValue( xyz.y + Group3Spin->SpinBox_DY->value() );
209 if ( okz ) Group3Spin->SpinBox_DZ->setValue( xyz.z + Group3Spin->SpinBox_DZ->value() );
210 Group3Spin->buttonApply->setFocus();
213 Group3Spin->TextLabel1->setText( tr( "GEOM_SKETCHER_DX2" ) );
214 Group3Spin->TextLabel2->setText( tr( "GEOM_SKETCHER_DY2" ) );
215 Group3Spin->TextLabel3->setText( tr( "GEOM_SKETCHER_DZ2" ) );
216 if ( okx ) Group3Spin->SpinBox_DX->setValue( Group3Spin->SpinBox_DX->value() - xyz.x );
217 if ( oky ) Group3Spin->SpinBox_DY->setValue( Group3Spin->SpinBox_DY->value() - xyz.y );
218 if ( okz ) Group3Spin->SpinBox_DZ->setValue( Group3Spin->SpinBox_DZ->value() - xyz.z );
219 Group3Spin->buttonApply->setFocus();
221 Group3Spin->SpinBox_DX->blockSignals(blocked);
222 Group3Spin->SpinBox_DY->blockSignals(blocked);
223 Group3Spin->SpinBox_DZ->blockSignals(blocked);
228 //=================================================================================
229 // function : ClickOnAddPoint()
230 // purpose : called when the point coordinates is Applyed
231 //=================================================================================
232 void EntityGUI_3DSketcherDlg::ClickOnAddPoint()
235 if ( !isValid( msg ) ) {
240 myPointsList.append( getCurrentPoint() );
244 Group3Spin->SpinBox_DX->setValue( 0.0 );
245 Group3Spin->SpinBox_DY->setValue( 0.0 );
246 Group3Spin->SpinBox_DZ->setValue( 0.0 );
248 UpdateButtonsState();
249 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
252 //=================================================================================
253 // function : UpdateButtonsState()
255 //=================================================================================
256 void EntityGUI_3DSketcherDlg::UpdateButtonsState()
258 if ( myPointsList.count() == 0 ) GroupType->RadioButton1->click();
259 GroupType->RadioButton2->setEnabled( myPointsList.count() > 0 );
260 Group3Spin->buttonUndo->setEnabled( myPointsList.count() > 0 );
261 Group3Spin->buttonRedo->setEnabled( myRedoList.count() > 0 );
264 //=================================================================================
265 // function : ClickOnUndo()
267 //=================================================================================
268 void EntityGUI_3DSketcherDlg::ClickOnUndo()
270 if (myPointsList.count() > 0) {
271 myRedoList.append( myPointsList.takeLast() );
272 UpdateButtonsState();
273 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
277 //=================================================================================
278 // function : ClickOnRedo()
280 //=================================================================================
281 void EntityGUI_3DSketcherDlg::ClickOnRedo()
283 if ( myRedoList.count() > 0) {
284 myPointsList.append( myRedoList.takeLast() );
285 UpdateButtonsState();
286 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
290 //=================================================================================
291 // function : SelectionIntoArgument()
292 // purpose : Called when selection as changed
293 //=================================================================================
294 void EntityGUI_3DSketcherDlg::SelectionIntoArgument()
296 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
297 SALOME_ListIO aSelList;
298 aSelMgr->selectedObjects(aSelList);
300 int nbSel = aSelList.Extent();
302 GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
303 if ( !CORBA::is_nil(aSelectedObject) ) {
305 if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE)) { // Explore the shape if its a local selection
306 TColStd_IndexedMapOfInteger aMap;
307 aSelMgr->GetIndexes(aSelList.First(), aMap);
308 if (aMap.Extent() == 1)
310 int anIndex = aMap(1);
311 GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations(getStudyId());
312 aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
316 if ( aShape.ShapeType() != TopAbs_VERTEX )
317 isOk = GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_VERTEX);
320 if ( GEOMBase::VertexToPoint( aShape, aPnt ) ) {
321 // set coordinates to the Spin Boxes
326 bool blocked = Group3Spin->SpinBox_DX->signalsBlocked();
327 Group3Spin->SpinBox_DX->blockSignals(true);
328 Group3Spin->SpinBox_DY->blockSignals(true);
329 Group3Spin->SpinBox_DZ->blockSignals(true);
330 if ( GroupType->RadioButton1->isChecked() ) {
331 Group3Spin->SpinBox_DX->setValue( aX );
332 Group3Spin->SpinBox_DY->setValue( aY );
333 Group3Spin->SpinBox_DZ->setValue( aZ );
334 } else if ( GroupType->RadioButton2->isChecked() ) {
335 XYZ xyz = getLastPoint();
336 Group3Spin->SpinBox_DX->setValue( aX - xyz.x );
337 Group3Spin->SpinBox_DY->setValue( aY - xyz.y );
338 Group3Spin->SpinBox_DZ->setValue( aZ - xyz.z );
340 Group3Spin->SpinBox_DX->blockSignals(blocked);
341 Group3Spin->SpinBox_DY->blockSignals(blocked);
342 Group3Spin->SpinBox_DZ->blockSignals(blocked);
347 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
350 //=================================================================================
351 // function : DeactivateActiveDialog()
353 //=================================================================================
354 void EntityGUI_3DSketcherDlg::DeactivateActiveDialog()
358 disconnect( myGeomGUI->getApp()->selectionMgr(), 0, this, 0 );
359 myGeomGUI->SetActiveDialogBox( 0 );
363 //=================================================================================
364 // function : ActivateThisDialog()
366 //=================================================================================
367 void EntityGUI_3DSketcherDlg::ActivateThisDialog()
369 myGeomGUI->EmitSignalDeactivateDialog();
371 myGeomGUI->SetActiveDialogBox( this );
373 connect( myGeomGUI->getApp()->selectionMgr(),
374 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
376 localSelection( GEOM::GEOM_Object::_nil(), TopAbs_VERTEX );
377 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
381 //=================================================================================
382 // function : ValueChangedInSpinBox()
384 //=================================================================================
385 void EntityGUI_3DSketcherDlg::ValueChangedInSpinBox( double newValue )
387 GEOMBase_Helper::displayPreview( true, false, true, true, myLineWidth );
390 //=================================================================================
391 // function : enterEvent()
393 //=================================================================================
394 void EntityGUI_3DSketcherDlg::enterEvent( QEvent* )
396 if ( !mainFrame()->GroupConstructors->isEnabled() )
397 ActivateThisDialog();
400 //=================================================================================
401 // function : createOperation
403 //=================================================================================
404 GEOM::GEOM_IOperations_ptr EntityGUI_3DSketcherDlg::createOperation()
406 return getGeomEngine()->GetICurvesOperations( getStudyId() );
409 //=================================================================================
410 // function : isValid
412 //=================================================================================
413 bool EntityGUI_3DSketcherDlg::isValid( QString& msg )
416 ok = Group3Spin->SpinBox_DX->isValid( msg, !IsPreview() ) && ok;
417 ok = Group3Spin->SpinBox_DY->isValid( msg, !IsPreview() ) && ok;
418 ok = Group3Spin->SpinBox_DZ->isValid( msg, !IsPreview() ) && ok;
422 //=================================================================================
423 // function : execute
425 //=================================================================================
426 bool EntityGUI_3DSketcherDlg::execute( ObjectList& objects )
428 GEOM::ListOfDouble_var aCoordsArray = new GEOM::ListOfDouble;
429 if (!myOK || myPointsList.size() == 0)
430 aCoordsArray->length((myPointsList.size()+1)*3);
432 aCoordsArray->length(myPointsList.size()*3);
434 QStringList aParameters;
437 QList<XYZ>::const_iterator it;
438 for(it = myPointsList.begin(); it != myPointsList.end(); ++it ) {
439 aCoordsArray[i++] = (*it).x;
440 aCoordsArray[i++] = (*it).y;
441 aCoordsArray[i++] = (*it).z;
442 aParameters << (*it).xt;
443 aParameters << (*it).yt;
444 aParameters << (*it).zt;
447 if (!myOK || myPointsList.size() == 0) {
448 XYZ xyz = getCurrentPoint();
449 aCoordsArray[i++] = xyz.x;
450 aCoordsArray[i++] = xyz.y;
451 aCoordsArray[i++] = xyz.z;
452 aParameters << xyz.xt;
453 aParameters << xyz.yt;
454 aParameters << xyz.zt;
457 GEOM::GEOM_ICurvesOperations_var anOper = GEOM::GEOM_ICurvesOperations::_narrow(getOperation());
458 GEOM::GEOM_Object_var anObj = anOper->Make3DSketcher( aCoordsArray );
460 if ( !anObj->_is_nil() ) {
461 if ( !IsPreview() ) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
462 objects.push_back( anObj._retn() );
468 //=================================================================================
469 // function : SetDoubleSpinBoxStep()
470 // purpose : Double spin box management
471 //=================================================================================
472 void EntityGUI_3DSketcherDlg::SetDoubleSpinBoxStep( double step )
474 Group3Spin->SpinBox_DX->setSingleStep(step);
475 Group3Spin->SpinBox_DY->setSingleStep(step);
476 Group3Spin->SpinBox_DZ->setSingleStep(step);
479 //=================================================================================
480 // function : ClickOnOk()
482 //=================================================================================
483 void EntityGUI_3DSketcherDlg::ClickOnOk()
493 //=================================================================================
494 // function : ClickOnApply()
496 //=================================================================================
497 bool EntityGUI_3DSketcherDlg::ClickOnApply()
500 if ( !isValid( msg ) ) {
505 if (myPointsList.count() > 0)
506 myPointsList.append(myPointsList[0]);
517 //=================================================================================
518 // function : getLastPoint()
519 // purpose : return last points from list
520 //=================================================================================
521 EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getLastPoint() const
523 return myPointsList.count() > 0 ? myPointsList.last() : XYZ();
526 //=================================================================================
527 // function : getCurrentPoint()
528 // purpose : returns current points
529 //=================================================================================
530 EntityGUI_3DSketcherDlg::XYZ EntityGUI_3DSketcherDlg::getCurrentPoint() const
534 xyz.x = Group3Spin->SpinBox_DX->value();
535 xyz.y = Group3Spin->SpinBox_DY->value();
536 xyz.z = Group3Spin->SpinBox_DZ->value();
539 xyz = getLastPoint();
540 xyz.x += Group3Spin->SpinBox_DX->value();
541 xyz.y += Group3Spin->SpinBox_DY->value();
542 xyz.z += Group3Spin->SpinBox_DZ->value();
544 xyz.xt = Group3Spin->SpinBox_DX->text();
545 xyz.yt = Group3Spin->SpinBox_DY->text();
546 xyz.zt = Group3Spin->SpinBox_DZ->text();
550 //================================================================
551 // Function : displayPreview
552 // Purpose : Method for displaying preview of resulting shape
553 // Redefined from GEOMBase_Helper.
554 //================================================================
555 void EntityGUI_3DSketcherDlg::displayPreview( GEOM::GEOM_Object_ptr object,
559 const double lineWidth,
560 const int displayMode,
563 // Set color for preview shape
564 getDisplayer()->SetColor( Quantity_NOC_RED );
566 // set width of displayed shape
567 getDisplayer()->SetWidth( (lineWidth == -1)?myLineWidth:lineWidth );
569 // Disable activation of selection
570 getDisplayer()->SetToActivate( activate );
572 // Make a reference to GEOM_Object
573 CORBA::String_var objStr = myGeometryGUI->getApp()->orb()->object_to_string( object );
574 getDisplayer()->SetName( objStr.in() );
576 // Create wire from applied object
577 TopoDS_Shape anApplyedWire, aLastSegment;
578 if ( !createShapes( object, anApplyedWire, aLastSegment ) )
582 SALOME_Prs* aPrs = getDisplayer()->BuildPrs( anApplyedWire );
583 if ( aPrs != 0 && !aPrs->IsNull() )
584 GEOMBase_Helper::displayPreview( aPrs, append, update );
586 getDisplayer()->SetColor( Quantity_NOC_VIOLET );
587 aPrs = getDisplayer()->BuildPrs( aLastSegment );
588 if ( aPrs != 0 && !aPrs->IsNull() )
589 GEOMBase_Helper::displayPreview( aPrs, append, update );
591 getDisplayer()->UnsetName();
593 // Enable activation of displayed objects
594 getDisplayer()->SetToActivate( true );
597 //================================================================
598 // Function : createShapes
599 // Purpose : Create applyed wire, and last segment from entry object
600 //================================================================
601 bool EntityGUI_3DSketcherDlg::createShapes( GEOM::GEOM_Object_ptr /*theObject*/,
602 TopoDS_Shape& theApplyedWire,
603 TopoDS_Shape& theLastSegment )
605 QList<gp_Pnt> points;
606 foreach( XYZ xyz, myPointsList) {
607 gp_Pnt p(xyz.x, xyz.y, xyz.z);
608 if ( points.isEmpty() || points.last().Distance(p) > gp::Resolution())
612 if ( points.count() == 1 ) {
613 // only one point is created
614 BRepBuilderAPI_MakeVertex mkVertex (points.last());
615 theApplyedWire = mkVertex.Shape();
617 else if ( points.count() > 1 ) {
619 BRepBuilderAPI_MakePolygon mkWire;
620 foreach( gp_Pnt p, points )
622 theApplyedWire = mkWire.Shape();
625 XYZ curxyz = getCurrentPoint();
626 gp_Pnt curpnt(curxyz.x, curxyz.y, curxyz.z);
628 if ( points.isEmpty() || points.last().Distance(curpnt) <= gp::Resolution() ) {
629 BRepBuilderAPI_MakeVertex mkVertex (curpnt);
630 theLastSegment = mkVertex.Shape();
633 BRepBuilderAPI_MakeEdge mkEdge(points.last(), curpnt);
634 theLastSegment = mkEdge.Shape();
637 /* VSR: old algorithm does not work properly, see bug 0020899
639 if ( !GEOMBase::GetShape( theObject, aShape ) )
642 if( aShape.ShapeType() != TopAbs_WIRE && aShape.ShapeType() != TopAbs_VERTEX )
645 theApplyedWire = aShape;
649 BRepBuilderAPI_MakeWire aBuilder;
650 TopExp_Explorer edgeExp( aShape, TopAbs_EDGE );
652 TopoDS_Shape anEdge = edgeExp.Current();
654 if ( edgeExp.More() ) // i.e. non-last edge
655 aBuilder.Add( TopoDS::Edge( anEdge ) );
657 theLastSegment = anEdge;
662 if ( aBuilder.IsDone() ) {
663 theApplyedWire = aBuilder.Shape();
665 else if ( !theLastSegment.IsNull() ) {
666 TopExp_Explorer vertexExp( theLastSegment, TopAbs_VERTEX );
667 theApplyedWire = vertexExp.Current();