]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
DCQ : Add MakeFaces Method
authordcq <dcq@opencascade.com>
Thu, 8 Apr 2004 08:14:25 +0000 (08:14 +0000)
committerdcq <dcq@opencascade.com>
Thu, 8 Apr 2004 08:14:25 +0000 (08:14 +0000)
idl/GEOM_Gen.idl
src/BuildGUI/BuildGUI.cxx
src/BuildGUI/BuildGUI.h
src/BuildGUI/BuildGUI_FaceDlg.cxx
src/BuildGUI/BuildGUI_FaceDlg.h
src/GEOM/GEOM_Gen_i.cc
src/GEOM/GEOM_Gen_i.hh
src/GEOMContext/GEOM_msg_en.po
src/GEOMContext/GEOM_msg_fr.po
src/GEOM_SWIG/batchmode_geompy.py
src/GEOM_SWIG/geompy.py

index 12eff04d74989db663f71297408a9032e17b803f..9b085c4038f5d012bc4a10dd5036aae625aa78e6 100644 (file)
@@ -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) ;
 
index 4d404afc2cec2e1c4ba400849e835d359b444b34..1460732e7c0ac984899a7fe6e1bb2b64e58d22de 100644 (file)
@@ -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;
index c8672d5acf301b6262a4e0d76b4ae800ce404d86..7d50e69676aa51b3fa7f78322b0059c9d9cb1ec6 100644 (file)
@@ -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);
index 340519af3269ebc13c96755cc0554faafeb3bd59..19723141452493df16cd84dcf6f89296eec7c93c 100644 (file)
@@ -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  :
index 43fd93b40b34cbf661dcb53d754070dc82b0176d..86ce40a1381c3ab0bd714dfac244bea0aa912dbd 100644 (file)
@@ -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();
 
index 7b8d5558c30776c59eea663e6879e6099135ff68..2463789daa2b80f6b8763ab17aaba6543a9faefc 100644 (file)
@@ -63,6 +63,7 @@ using namespace std;
 #else
 #include <BRepAlgoAPI.hxx>
 #endif
+#include <BRepAlgo_FaceRestrictor.hxx>
 #include <BRepAdaptor_Surface.hxx>
 #include <BRepBuilderAPI_Copy.hxx>
 #include <BRepAlgoAPI_Common.hxx>
@@ -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
index 753e98e8902f268f6aa4b79e1cd2a8595067507e..400537339fd62bb6a92182b3086ed1c416a54549 100644 (file)
@@ -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)
index 167a8b7e06f5e1bb9ad3e9ea4fcbd69da07abbf1..34834bc660abe320038e8384dd6b452b4a9ef109 100644 (file)
@@ -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 :"
index f502017f4c8a460ac28493b7cce161ad223d3c7e..9bde4dfce7ef38ef9f6052e8901af9c53ccff4ef 100644 (file)
@@ -635,6 +635,10 @@ msgstr "Vertex"
 #Wire
 msgid "GEOM_WIRE"
 msgstr "Wire"
+
+#Wire(s)
+msgid "GEOM_WIRES"
+msgstr "Wire(s)"
        
 #Parameter
 msgid "GEOM_PARAMETER"
index 4bb742a89b03e65578fd8d0ee18313e3508cd679..949050b04c5dd58dc3d57159c0eb9b33fbeeb7ac 100644 (file)
@@ -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)
index 4cfc0184f72b0d93033a525f43a944d1bab46dfa..39d97e9392f37261f07902bea5a75dd643ab3b06 100644 (file)
@@ -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)