From 70cba03a1c3f62c5cf6a772ea8dd2c28ee57c5eb Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 27 Sep 2006 11:17:03 +0000 Subject: [PATCH] Implement improvement PAL13394: disk building from circle --- src/BuildGUI/BuildGUI_FaceDlg.cxx | 21 +++++++++--- src/GEOMGUI/GEOM_msg_en.po | 2 +- src/GEOMImpl/GEOMImpl_ShapeDriver.cxx | 49 ++++++++++++++++++++------- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx index 36d8605a9..953c54f8f 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.cxx +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -28,6 +28,7 @@ #include "BuildGUI_FaceDlg.h" #include "GEOMImpl_Types.hxx" +#include "TColStd_MapOfInteger.hxx" #include "SUIT_Session.h" #include "SalomeApp_Application.h" @@ -64,7 +65,7 @@ BuildGUI_FaceDlg::BuildGUI_FaceDlg(GeometryGUI* theGeometryGUI, QWidget* parent, GroupWire = new DlgRef_1Sel1Check_QTD(this, "GroupWire"); GroupWire->GroupBox1->setTitle(tr("GEOM_FACE_FFW")); - GroupWire->TextLabel1->setText(tr("GEOM_WIRES")); + GroupWire->TextLabel1->setText(tr("GEOM_OBJECTS")); GroupWire->CheckButton1->setText(tr("GEOM_FACE_OPT")); GroupWire->PushButton1->setPixmap(image1); @@ -100,7 +101,10 @@ void BuildGUI_FaceDlg::Init() GroupWire->CheckButton1->setChecked(TRUE); - globalSelection( GEOM_WIRE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_EDGE ); + aMap.Add( GEOM_WIRE ); + globalSelection( aMap ); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); @@ -160,7 +164,7 @@ void BuildGUI_FaceDlg::SelectionIntoArgument() if (!myWires.length()) return; if(aNbSel != 1) - aName = tr("%1_wires").arg(aNbSel); + aName = tr("%1_objects").arg(aNbSel); myEditCurrentArgument->setText( aName ); @@ -178,7 +182,11 @@ void BuildGUI_FaceDlg::SetEditCurrentArgument() if (send != GroupWire->PushButton1) return; - globalSelection( GEOM_WIRE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_EDGE ); + aMap.Add( GEOM_WIRE ); + globalSelection( aMap ); + myEditCurrentArgument = GroupWire->LineEdit1; myEditCurrentArgument->setFocus(); @@ -195,7 +203,10 @@ void BuildGUI_FaceDlg::ActivateThisDialog() GEOMBase_Skeleton::ActivateThisDialog(); connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; - globalSelection( GEOM_WIRE ); + TColStd_MapOfInteger aMap; + aMap.Add( GEOM_EDGE ); + aMap.Add( GEOM_WIRE ); + globalSelection( aMap ); } diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index 721eef1bb..57a0ada96 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -903,7 +903,7 @@ msgstr "Create A Face" #: GeometryGUI_FaceDlg.cxx:78 msgid "GEOM_FACE_FFW" -msgstr "Face from a wire" +msgstr "Face from a closed wire and edge" #: GeometryGUI_FaceDlg.cxx:103 msgid "GEOM_FACE_OPT" diff --git a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx index 019ad172b..dc199ffee 100644 --- a/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_ShapeDriver.cxx @@ -170,8 +170,7 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const if (!MW.IsDone()) { Standard_ConstructionError::Raise("Wire construction failed"); } - //W = TopoDS::Wire(aShapeBase); - W = MW; + W = MW; } else { Standard_NullObject::Raise @@ -189,17 +188,30 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const Standard_ConstructionError::Raise("No wires given"); } - // first wire + // first wire or edge Handle(GEOM_Function) aRefWire = Handle(GEOM_Function)::DownCast(aShapes->Value(1)); TopoDS_Shape aWire = aRefWire->GetValue(); - if (aWire.IsNull() || aWire.ShapeType() != TopAbs_WIRE) { - Standard_NullObject::Raise("Shape for face construction is null or not a wire"); + if (aWire.IsNull()) Standard_NullObject::Raise("Argument Shape is null"); + TopoDS_Wire W1; + if(aWire.ShapeType() == TopAbs_WIRE) { + W1 = TopoDS::Wire(aWire); + } + else if(aWire.ShapeType() == TopAbs_EDGE && aWire.Closed()) { + BRepBuilderAPI_MakeWire MW; + MW.Add(TopoDS::Edge(aWire)); + if (!MW.IsDone()) { + Standard_ConstructionError::Raise("Wire construction failed"); + } + W1 = MW; + } + else { + Standard_NullObject::Raise + ("Shape for face construction is neither a wire nor closed edge"); } - TopoDS_Wire W = TopoDS::Wire(aWire); // basic face TopoDS_Shape FFace; - GEOMImpl_Block6Explorer::MakeFace(W, aCI.GetIsPlanar(), FFace); + GEOMImpl_Block6Explorer::MakeFace(W1, aCI.GetIsPlanar(), FFace); if (FFace.IsNull()) { Standard_ConstructionError::Raise("Face construction failed"); } @@ -221,11 +233,24 @@ Standard_Integer GEOMImpl_ShapeDriver::Execute(TFunction_Logbook& log) const Handle(GEOM_Function) aRefWire_i = Handle(GEOM_Function)::DownCast(aShapes->Value(ind)); TopoDS_Shape aWire_i = aRefWire_i->GetValue(); - if (aWire_i.IsNull() || aWire_i.ShapeType() != TopAbs_WIRE) { - Standard_NullObject::Raise("Shape for face construction is null or not a wire"); - } - - FR.Add(TopoDS::Wire(aWire_i)); + if (aWire_i.IsNull()) Standard_NullObject::Raise("Argument Shape is null"); + TopoDS_Wire W_i; + if(aWire_i.ShapeType() == TopAbs_WIRE) { + W_i = TopoDS::Wire(aWire_i); + } + else if(aWire_i.ShapeType() == TopAbs_EDGE && aWire_i.Closed()) { + BRepBuilderAPI_MakeWire MW1; + MW1.Add(TopoDS::Edge(aWire_i)); + if (!MW1.IsDone()) { + Standard_ConstructionError::Raise("Wire construction failed"); + } + W_i = MW1; + } + else { + Standard_NullObject::Raise + ("Shape for face construction is neither a wire nor closed edges"); + } + FR.Add(W_i); } FR.Perform(); -- 2.39.2