From: dcq Date: Mon, 22 Mar 2004 17:02:07 +0000 (+0000) Subject: DCQ : Add Multi-Wire for MakeFace X-Git-Tag: V1_4_1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4c60078497bbd9acbd3f1dfe172437162a1ccb8b;p=modules%2Fgeom.git DCQ : Add Multi-Wire for MakeFace --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 018f7f6a9..9b085c403 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -101,6 +101,9 @@ module GEOM GEOM_Shape MakePlacedBox(in double x1, in double y1, in double z1, in double delta1, in double delta2, in double delta3) raises (SALOME::SALOME_Exception) ; + GEOM_Shape MakePanel(in GEOM_Shape shape, + in short directiontype, + in double delta) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeGlueFaces(in GEOM_Shape shape, in double tol3d) raises (SALOME::SALOME_Exception) ; @@ -234,8 +237,10 @@ module GEOM in PointStruct pstruct2) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeWire (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; GEOM_Shape MakeCompound (in ListOfIOR ListShape) raises (SALOME::SALOME_Exception) ; - GEOM_Shape MakeFace (in ListOfIOR ListShape, - in boolean wantplanarface ) raises (SALOME::SALOME_Exception) ; + GEOM_Shape MakeFace (in GEOM_Shape shapeWire, + 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 224b541a9..1460732e7 100644 --- a/src/BuildGUI/BuildGUI.cxx +++ b/src/BuildGUI/BuildGUI.cxx @@ -168,7 +168,7 @@ void BuildGUI::MakeFaceAndDisplay(GEOM::GEOM_Gen::ListOfIOR& listShapesIOR, const Standard_Boolean wantPlanar) { try { - GEOM::GEOM_Shape_var result = myGeom->MakeFace(listShapesIOR, 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/GEOM/GEOM_Gen_i.cc b/src/GEOM/GEOM_Gen_i.cc index c5b9bf2a7..4bf747c5a 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 @@ -3638,6 +3639,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..6d74fa198 100644 --- a/src/GEOM/GEOM_Gen_i.hh +++ b/src/GEOM/GEOM_Gen_i.hh @@ -388,7 +388,6 @@ class GEOM_Gen_i: public POA_GEOM::GEOM_Gen, GEOM::GEOM_Shape_ptr MakePlacedBox(CORBA::Double x1, CORBA::Double y1, CORBA::Double z1, CORBA::Double delta1, CORBA::Double delta2, CORBA::Double delta3) throw (SALOME::SALOME_Exception) ; - GEOM::GEOM_Shape_ptr MakePanel(GEOM::GEOM_Shape_ptr shape, CORBA::Short directiontype, CORBA::Double delta) @@ -586,6 +585,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/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 4cfc0184f..4746e7d62 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -240,6 +240,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)