From: dcq Date: Thu, 8 Apr 2004 08:14:25 +0000 (+0000) Subject: DCQ : Add MakeFaces Method X-Git-Tag: Base_Ecole_Ete~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bc58667418bee31643f4656c638889d5dd1e0034;p=modules%2Fgeom.git DCQ : Add MakeFaces Method --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 12eff04d7..9b085c403 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -238,7 +238,9 @@ module GEOM GEOM_Shape MakeWire (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeCompound (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeFace (in GEOM_Shape shapeWire, - in boolean wantplanarface ) raises (SALOME::SALOME_Exception) ; + in boolean wantplanarface) raises (SALOME::SALOME_Exception) ; + GEOM_Shape MakeFaces (in ListOfIOR ListShape, + in boolean wantplanarface) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeShell (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeSolid (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; diff --git a/src/BuildGUI/BuildGUI.cxx b/src/BuildGUI/BuildGUI.cxx index 4d404afc2..1460732e7 100644 --- a/src/BuildGUI/BuildGUI.cxx +++ b/src/BuildGUI/BuildGUI.cxx @@ -164,10 +164,11 @@ void BuildGUI::MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR) // function : MakeFaceAndDisplay() // purpose : //===================================================================================== -void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar) +void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const Standard_Boolean wantPlanar) { try { - GEOM::GEOM_Shape_var result = myGeom->MakeFace(aWire, wantPlanar); + GEOM::GEOM_Shape_var result = myGeom->MakeFaces(listShapesIOR, wantPlanar); if(result->_is_nil()) { QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE")); return; diff --git a/src/BuildGUI/BuildGUI.h b/src/BuildGUI/BuildGUI.h index c8672d5ac..7d50e6967 100644 --- a/src/BuildGUI/BuildGUI.h +++ b/src/BuildGUI/BuildGUI.h @@ -48,7 +48,8 @@ public : void MakeLinearEdgeAndDisplay(const gp_Pnt P1, const gp_Pnt P2); void MakeWireAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); - void MakeFaceAndDisplay(GEOM::GEOM_Shape_ptr aWire, const Standard_Boolean wantPlanar); + void MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, + const Standard_Boolean wantPlanar); void MakeShellAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); void MakeSolidAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); void MakeCompoundAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR); diff --git a/src/BuildGUI/BuildGUI_FaceDlg.cxx b/src/BuildGUI/BuildGUI_FaceDlg.cxx index 340519af3..197231414 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.cxx +++ b/src/BuildGUI/BuildGUI_FaceDlg.cxx @@ -52,7 +52,7 @@ BuildGUI_FaceDlg::BuildGUI_FaceDlg(QWidget* parent, const char* name, BuildGUI* GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints"); GroupPoints->GroupBox1->setTitle(tr("GEOM_FACE_FFW")); - GroupPoints->TextLabel1->setText(tr("GEOM_WIRE")); + GroupPoints->TextLabel1->setText(tr("GEOM_WIRES")); GroupPoints->CheckButton1->setText(tr("GEOM_FACE_OPT")); GroupPoints->PushButton1->setPixmap(image1); @@ -85,7 +85,7 @@ void BuildGUI_FaceDlg::Init() myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->CheckButton1->setChecked(TRUE); - myOkShape = false; + myOkListShapes = false; myWireFilter = new GEOM_ShapeTypeFilter(TopAbs_WIRE, myGeom); mySelection->AddFilter(myWireFilter); /* first filter used */ @@ -124,8 +124,8 @@ void BuildGUI_FaceDlg::ClickOnOk() void BuildGUI_FaceDlg::ClickOnApply() { QAD_Application::getDesktop()->putInfo(tr("")); - if(myOkShape) - myBuildGUI->MakeFaceAndDisplay(myGeomShape, GroupPoints->CheckButton1->isChecked()); + if(myOkListShapes) + myBuildGUI->MakeFaceAndDisplay(myListShapes, GroupPoints->CheckButton1->isChecked()); return; } @@ -139,24 +139,17 @@ void BuildGUI_FaceDlg::SelectionIntoArgument() myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ - myOkShape = false; + myOkListShapes = false; int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); - if(nbSel != 1) { - return; - } - - // nbSel == 1! - Standard_Boolean testResult; - Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); - if(!myGeomBase->GetTopoFromSelection(mySelection, myShape)) - return; - - myGeomShape = myGeomBase->ConvertIOinGEOMShape(IO, testResult); - if(!testResult) + if(nbSel == 0) return; + if(nbSel != 1) + aString = tr("%1_objects").arg(nbSel); + myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); + myEditCurrentArgument->setText(aString); - myOkShape = true; + myOkListShapes = true; /* no simulation */ return; } @@ -176,23 +169,6 @@ void BuildGUI_FaceDlg::SetEditCurrentArgument() } -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void BuildGUI_FaceDlg::LineEditReturnPressed() -{ - QLineEdit* send = (QLineEdit*)sender(); - if(send == GroupPoints->LineEdit1) - myEditCurrentArgument = GroupPoints->LineEdit1; - else - return; - - GEOMBase_Skeleton::LineEditReturnPressed(); - return; -} - - //================================================================================= // function : ActivateThisDialog() // purpose : diff --git a/src/BuildGUI/BuildGUI_FaceDlg.h b/src/BuildGUI/BuildGUI_FaceDlg.h index 43fd93b40..86ce40a13 100644 --- a/src/BuildGUI/BuildGUI_FaceDlg.h +++ b/src/BuildGUI/BuildGUI_FaceDlg.h @@ -57,9 +57,8 @@ private: /* Filter selection */ Handle(GEOM_ShapeTypeFilter) myWireFilter; - TopoDS_Shape myShape; /* topology used to fuse */ - GEOM::GEOM_Shape_var myGeomShape; /* is myShape */ - bool myOkShape; /* to check when arguments is defined */ + GEOM::GEOM_Gen::ListOfIOR myListShapes; + bool myOkListShapes; /* to check when arguments is defined */ DlgRef_1Sel1Check_QTD* GroupPoints; @@ -67,7 +66,6 @@ private slots: void ClickOnOk(); void ClickOnApply(); void ActivateThisDialog(); - void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); diff --git a/src/GEOM/GEOM_Gen_i.cc b/src/GEOM/GEOM_Gen_i.cc index 7b8d5558c..2463789da 100644 --- a/src/GEOM/GEOM_Gen_i.cc +++ b/src/GEOM/GEOM_Gen_i.cc @@ -63,6 +63,7 @@ using namespace std; #else #include #endif +#include #include #include #include @@ -3684,6 +3685,69 @@ GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFace( GEOM::GEOM_Shape_ptr wire, } +//================================================================================= +// function : MakeFaces() +// purpose : +//================================================================================= +GEOM::GEOM_Shape_ptr GEOM_Gen_i::MakeFaces(const GEOM::GEOM_Gen::ListOfIOR& ListShapes, + CORBA::Boolean wantplanarface) + throw (SALOME::SALOME_Exception) +{ + GEOM::GEOM_Shape_var result; + + try { + GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[0]); + TopoDS_Shape Shape = GetTopoShape(aShape); + if(Shape.IsNull() || Shape.ShapeType() != TopAbs_WIRE) { + THROW_SALOME_CORBA_EXCEPTION("Shell aborted : null shape during operation", SALOME::BAD_PARAM); + } + TopoDS_Wire W = TopoDS::Wire(Shape); + TopoDS_Shape FFace = BRepBuilderAPI_MakeFace(W, wantplanarface).Shape(); + if(!FFace.IsNull()) { + if(ListShapes.length() == 1) { + result = CreateObject(FFace); + InsertInLabelMoreArguments(FFace, result, ListShapes, myCurrentOCAFDoc); + } + else if(ListShapes.length() >= 2) { + TopoDS_Compound C; + BRep_Builder aBuilder; + aBuilder.MakeCompound(C); + BRepAlgo_FaceRestrictor FR; + + TopAbs_Orientation OriF = FFace.Orientation(); + TopoDS_Shape aLocalS = FFace.Oriented(TopAbs_FORWARD); + FR.Init(TopoDS::Face(aLocalS), Standard_False, Standard_True); + + for(unsigned int i = 0; i < ListShapes.length(); i++) { + GEOM::GEOM_Shape_var aShape = GetIORFromString(ListShapes[i]); + TopoDS_Shape Shape = GetTopoShape(aShape); + if(Shape.IsNull()) { + THROW_SALOME_CORBA_EXCEPTION("Shell aborted : null shape during operation", SALOME::BAD_PARAM); + } + FR.Add(TopoDS::Wire(Shape)); + } + + FR.Perform(); + + if(FR.IsDone()) { + for(; FR.More(); FR.Next()) + aBuilder.Add(C, FR.Current().Oriented(OriF)); + result = CreateObject(C); + InsertInLabelMoreArguments(C, result, ListShapes, myCurrentOCAFDoc); + } + } + } + else { + THROW_SALOME_CORBA_EXCEPTION("Null result in GEOM_Gen_i::MakeFace", SALOME::BAD_PARAM); + } + } + catch (Standard_Failure) { + THROW_SALOME_CORBA_EXCEPTION("Exception catched in GEOM_Gen_i::MakeFace", SALOME::BAD_PARAM); + } + return result; +} + + //================================================================================= // function : MakeShell() // purpose : Make a compound from a list containing one or more shapes diff --git a/src/GEOM/GEOM_Gen_i.hh b/src/GEOM/GEOM_Gen_i.hh index 753e98e89..400537339 100644 --- a/src/GEOM/GEOM_Gen_i.hh +++ b/src/GEOM/GEOM_Gen_i.hh @@ -586,6 +586,9 @@ class GEOM_Gen_i: public POA_GEOM::GEOM_Gen, throw (SALOME::SALOME_Exception) ; GEOM::GEOM_Shape_ptr MakeFace (GEOM::GEOM_Shape_ptr wire, CORBA::Boolean wantplanarface) throw (SALOME::SALOME_Exception) ; + GEOM::GEOM_Shape_ptr MakeFaces (const GEOM::GEOM_Gen::ListOfIOR& ListShapes, + CORBA::Boolean wantplanarface) + throw (SALOME::SALOME_Exception) ; GEOM::GEOM_Shape_ptr MakeShell (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) throw (SALOME::SALOME_Exception) ; GEOM::GEOM_Shape_ptr MakeSolid (const GEOM::GEOM_Gen::ListOfIOR& ListShapes) diff --git a/src/GEOMContext/GEOM_msg_en.po b/src/GEOMContext/GEOM_msg_en.po index 167a8b7e0..34834bc66 100644 --- a/src/GEOMContext/GEOM_msg_en.po +++ b/src/GEOMContext/GEOM_msg_en.po @@ -662,6 +662,10 @@ msgstr "Vertex" msgid "GEOM_WIRE" msgstr "Wire" +#Wire(s) +msgid "GEOM_WIRES" +msgstr "Wire(s)" + #Parameter msgid "GEOM_PARAMETER" msgstr "Parameter :" diff --git a/src/GEOMContext/GEOM_msg_fr.po b/src/GEOMContext/GEOM_msg_fr.po index f502017f4..9bde4dfce 100644 --- a/src/GEOMContext/GEOM_msg_fr.po +++ b/src/GEOMContext/GEOM_msg_fr.po @@ -635,6 +635,10 @@ msgstr "Vertex" #Wire msgid "GEOM_WIRE" msgstr "Wire" + +#Wire(s) +msgid "GEOM_WIRES" +msgstr "Wire(s)" #Parameter msgid "GEOM_PARAMETER" diff --git a/src/GEOM_SWIG/batchmode_geompy.py b/src/GEOM_SWIG/batchmode_geompy.py index 4bb742a89..949050b04 100644 --- a/src/GEOM_SWIG/batchmode_geompy.py +++ b/src/GEOM_SWIG/batchmode_geompy.py @@ -152,6 +152,12 @@ def MakeCircle(p1,d1,radius): anObj._set_Name(ior) return anObj +def MakeEllipse(p1,d1,radiusMaj,radiusMin): + anObj = geom.MakeEllipse(p1,d1,radiusMaj, radiusMin) + ior = orb.object_to_string(anObj) + anObj._set_Name(ior) + return anObj + def MakePlane(p1,d1,trimsize): anObj = geom.MakePlane(p1,d1,trimsize) ior = orb.object_to_string(anObj) @@ -214,6 +220,12 @@ def MakeFace(aShapeWire,WantPlanarFace): anObj._set_Name(ior) return anObj +def MakeFaces(ListShape,WantPlanarFace): + anObj = geom.MakeFaces(ListShape,WantPlanarFace) + ior = orb.object_to_string(anObj) + anObj._set_Name(ior) + return anObj + def MakeCompound(ListShape): anObj = geom.MakeCompound(ListShape) ior = orb.object_to_string(anObj) @@ -356,10 +368,11 @@ def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], return anObj def SuppressFaces(aShape,ListOfId): - anObj = geom.SuppressFaces(aShape,ListOfId) - ior = orb.object_to_string(anObj) - anObj._set_Name(ior) - return anObj + ListObj = geom.SuppressFaces(aShape,ListOfId) + for anObj in ListObj : + ior = orb.object_to_string(anObj) + anObj._set_Name(ior) + return ListObj def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace): anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace) diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 4cfc0184f..39d97e939 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -178,6 +178,12 @@ def MakeCircle(p1,d1,radius): anObj._set_Name(ior) return anObj +def MakeEllipse(p1,d1,radiusMaj,radiusMin): + anObj = geom.MakeEllipse(p1,d1,radiusMaj, radiusMin) + ior = orb.object_to_string(anObj) + anObj._set_Name(ior) + return anObj + def MakePlane(p1,d1,trimsize): anObj = geom.MakePlane(p1,d1,trimsize) ior = salome.orb.object_to_string(anObj) @@ -240,6 +246,12 @@ def MakeFace(aShapeWire,WantPlanarFace): anObj._set_Name(ior) return anObj +def MakeFaces(ListShape,WantPlanarFace): + anObj = geom.MakeFaces(ListShape,WantPlanarFace) + ior = salome.orb.object_to_string(anObj) + anObj._set_Name(ior) + return anObj + def MakeCompound(ListShape): anObj = geom.MakeCompound(ListShape) ior = salome.orb.object_to_string(anObj) @@ -382,10 +394,11 @@ def Partition(ListShapes, ListTools=[], ListKeepInside=[], ListRemoveInside=[], return anObj def SuppressFaces(aShape,ListOfId): - anObj = geom.SuppressFaces(aShape,ListOfId) - ior = salome.orb.object_to_string(anObj) - anObj._set_Name(ior) - return anObj + ListObj = geom.SuppressFaces(aShape,ListOfId) + for anObj in ListObj : + ior = salome.orb.object_to_string(anObj) + anObj._set_Name(ior) + return ListObj def SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace): anObj = geom.SuppressHole(aShape,ListOfFace,ListOfWire,ListOfEndFace)