diff --git a/doc/salome/examples/complex_objs_ex03.py b/doc/salome/examples/complex_objs_ex03.py index 35ccf0857..0c56c81e8 100644 --- a/doc/salome/examples/complex_objs_ex03.py +++ b/doc/salome/examples/complex_objs_ex03.py @@ -20,14 +20,12 @@ p3 = geompy.MakeVertex( -30., -30., 10.) # create an arc from three points arc = geompy.MakeArc(p1, p2, p3) -ShapeListCompound = [] -i = 0 -while i <= 3 : +ContoursList = [] +for i in range(4): S = geompy.MakeTranslation(arc, i * 50., 0., 0.) - ShapeListCompound.append(S) - i = i + 1 + ContoursList.append(S) -compound = geompy.MakeCompound(ShapeListCompound) +compound = geompy.MakeCompound(ContoursList) # create a filling filling = geompy.MakeFilling(compound, mindeg, maxdeg, tol3d, tol2d, nbiter) diff --git a/doc/salome/gui/GEOM/images/filling.png b/doc/salome/gui/GEOM/images/filling.png old mode 100755 new mode 100644 index 2efb1c8ea..9235f7a95 Binary files a/doc/salome/gui/GEOM/images/filling.png and b/doc/salome/gui/GEOM/images/filling.png differ diff --git a/doc/salome/gui/GEOM/input/creating_filling.doc b/doc/salome/gui/GEOM/input/creating_filling.doc index 874cac94b..5050ed8a1 100644 --- a/doc/salome/gui/GEOM/input/creating_filling.doc +++ b/doc/salome/gui/GEOM/input/creating_filling.doc @@ -6,19 +6,18 @@ To generate a \b Filling in the Main Menu select New Entity - > Genera To create a curvilinear face from several edges you need to define the following parameters: -\n Input Compound - the list of edges/wires used for creation -of the surface. To prepare for the filling each wire of the compound -is converted to an edge created on a BSpline curve built using curves -from all edges of the wire. +\n Input Contours - the list of edges/wires to use for creation +of the surface. You can select either several edges/wires or a +compound of them. To prepare for the filling, each input wire +is converted into a single BSpline curve by concatenating its edges. \n \b Minimum and Maximum Degree of equation of the resulting -BSpline or Besier curves describing the surface; +BSpline or Besier curves describing the surface. \n \b Tolerance for \b 2D and for \b 3D - minimum distance between the -created surface and the reference edge; +created surface and the input contours. \n Number of Iterations - defines the maximum number of iterations. The iterations are repeated until the required tolerance is reached. So, a greater number of iterations allows producing a better surface. \n Method - Kind of method to perform filling operation -
  1. Default - the standard behaviour.
  2. Use edges orientation - the edges orientation is used: if an edge is @@ -28,7 +27,7 @@ algorithm.
  3. minimize the sum of distances between ends points of edges.
-\n Approximation - if checked, BSpline curves are generated in +Approximation - if checked, BSpline curves are generated in the process of surface construction (using GeomAPI_PointsToBSplineSurface functionality). By default the surface is created using Besier curves. The usage of Approximation @@ -36,11 +35,11 @@ slows the algorithm, but allows building the surface for complex cases. \n The \b Result of the operation will be a GEOM_Object (face). -\n TUI Command: geompy.MakeFilling(Edges, MinDegree, MaxDegree, Tol2D, Tol3D, NbIter) -\n Arguments: Name + 1 List of edges + 7 Parameters -(Min. degree, Max. degree, Number of iterations, 2D tolerance, 3D -tolerance, Number of iterations, Method, Approximation). -\n Advanced options \ref preview_anchor "Preview" +\n TUI Command: geompy.MakeFilling(Contours, MinDegree, MaxDegree, Tol2D, Tol3D, NbIter)
+Arguments: List/compound of edges/wires + 7 Parameters +(Min. degree, Max. degree, 2D tolerance, 3D tolerance, Number of +iterations, Method, Approximation). +\n Advanced options: \ref preview_anchor "Preview" \image html filling.png @@ -50,7 +49,7 @@ tolerance, Number of iterations, Method, Approximation). \image html fillingsn.png "Resulting surface" -Our TUI Scripts provide you with useful examples of creation of +Sample TUI Scripts provide you with useful examples of creation of \ref tui_creation_filling "Complex Geometric Objects". */ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index b9cfadd17..e4bb0840b 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1682,18 +1682,18 @@ module GEOM in double theAngle); /*! - * \brief Create a filling from the given compound of contours. - * \param theShape Initial shape on which to perform the feature. - * \param theMinDeg a minimal degree of BSpline surface to create - * \param theMaxDeg a maximal degree of BSpline surface to create - * \param theTol2D a 2d tolerance to be reached - * \param theTol3D a 3d tolerance to be reached - * \param theNbIter a number of iteration of approximation algorithm + * \brief Create a face from a given set of contours. + * \param theContours either a list or a compound of edges/wires. + * \param theMinDeg a minimal degree of BSpline surface to create. + * \param theMaxDeg a maximal degree of BSpline surface to create. + * \param theTol2D a 2d tolerance to be reached. + * \param theTol3D a 3d tolerance to be reached. + * \param theNbIter a number of iteration of approximation algorithm. * \param theMethod Kind of method to perform filling operation. - * \param theApprox Boolean indicating if result should be approximated - * \return New GEOM_Object, containing the created filling surface. + * \param theApprox Boolean indicating if result should be approximated. + * \return New GEOM_Object (face), containing the created filling surface. */ - GEOM_Object MakeFilling (in GEOM_Object theShape, + GEOM_Object MakeFilling (in ListOfGO theContours, in long theMinDeg, in long theMaxDeg, in double theTol2D, in double theTol3D, in long theNbIter, diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 60757aabf..d9ed8d59b 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -790,7 +790,7 @@ Please, select face, shell or solid and try again GEOM_FILLING_COMPOUND - Input compound + Input contours GEOM_FILLING_MAX_DEG diff --git a/src/GEOMGUI/GeometryGUI.h b/src/GEOMGUI/GeometryGUI.h index 5dde1ed7f..f4fb8a393 100644 --- a/src/GEOMGUI/GeometryGUI.h +++ b/src/GEOMGUI/GeometryGUI.h @@ -145,8 +145,8 @@ public: virtual bool isDraggable( const SUIT_DataObject* what ) const; virtual bool isDropAccepted( const SUIT_DataObject* where ) const; virtual void dropObjects( const DataObjectList& what, - SUIT_DataObject* where, - const int row, Qt::DropAction action ); + SUIT_DataObject* where, + const int row, Qt::DropAction action ); public slots: virtual bool deactivateModule( SUIT_Study* ); diff --git a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx index 9dc5092bd..51d554ea7 100644 --- a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx @@ -30,44 +30,43 @@ #include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include -#include -#include -#include -#include -#include +#include +#include +#include #include #include +#include #include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - #include //======================================================================= @@ -101,19 +100,9 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const if (aFunction->GetType() != BASIC_FILLING) return 0; GEOMImpl_IFilling IF (aFunction); - Handle(GEOM_Function) aShapeFunction = IF.GetShape(); - if (aShapeFunction.IsNull()) return 0; - - TopoDS_Shape aShape; - BRepBuilderAPI_Copy Copy (aShapeFunction->GetValue()); - if (Copy.IsDone()) - aShape = Copy.Shape(); - - if (aShape.IsNull() || aShape.ShapeType() != TopAbs_COMPOUND) return 0; - - Standard_Integer mindeg = IF.GetMinDeg(); - Standard_Integer maxdeg = IF.GetMaxDeg(); - Standard_Real tol3d = IF.GetTol3D(); + Standard_Integer mindeg = IF.GetMinDeg(); + Standard_Integer maxdeg = IF.GetMaxDeg(); + Standard_Real tol3d = IF.GetTol3D(); Standard_Boolean isApprox = IF.GetApprox(); if (mindeg > maxdeg) { @@ -130,32 +119,56 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const BRep_Builder B; B.MakeCompound(aComp); + // input is either a list or compound of contours + TopTools_SequenceOfShape contours; + Handle(TColStd_HSequenceOfTransient) aShapeFunctions = IF.GetShapes(); + if ( aShapeFunctions.IsNull() || aShapeFunctions->IsEmpty() ) return 0; + for ( int i = 1; i <= aShapeFunctions->Length(); ++i ) + { + Handle(GEOM_Function) fun = Handle(GEOM_Function)::DownCast( aShapeFunctions->Value( i )); + if ( fun.IsNull() ) return 0; + TopoDS_Shape s = fun->GetValue(); + if ( s.IsNull() ) return 0; + BRepBuilderAPI_Copy Copy (s); + if ( Copy.IsDone() ) + contours.Append( Copy.Shape() ); + } + // 1. Convert argument wires, if any, into BSpline edges - TopoDS_Iterator It (aShape); - for (; It.More(); It.Next()) { - Scurrent = It.Value(); + for ( int i = 1; i <= contours.Length(); ++i ) + { + Scurrent = contours.Value( i ); if (Scurrent.ShapeType() != TopAbs_EDGE) { - TopoDS_Edge NewEdge; + if (Scurrent.ShapeType() == TopAbs_WIRE) { const TopoDS_Wire& CurWire = TopoDS::Wire(Scurrent); - NewEdge = BRepAlgo::ConcatenateWireC0(CurWire); + TopoDS_Edge NewEdge = BRepAlgo::ConcatenateWireC0(CurWire); + if (NewEdge.IsNull()) + Standard_ConstructionError::Raise("Failed to join several edges into one"); + Scurrent = NewEdge; } - if (NewEdge.IsNull()) { - Standard_ConstructionError::Raise("The argument compound must contain only edges"); + else if (Scurrent.ShapeType() == TopAbs_COMPOUND) + { + for ( TopoDS_Iterator It( Scurrent ); It.More(); It.Next() ) + contours.Append( It.Value() ); + continue; + } + else + { + Standard_ConstructionError::Raise("Input must contain only edges or/and wires"); } - Scurrent = NewEdge; } B.Add(aComp,Scurrent); } - aShape = aComp; + TopoDS_Shape aShape = aComp; // 2. The surface construction if (!isApprox) { // make filling as in old version of SALOME (before 4.1.1) - Standard_Real tol2d = IF.GetTol2D(); - Standard_Integer nbiter = IF.GetNbIter(); + Standard_Real tol2d = IF.GetTol2D(); + Standard_Integer nbiter = IF.GetNbIter(); Standard_Integer aMethod = IF.GetMethod(); GeomFill_SectionGenerator Section; @@ -324,7 +337,7 @@ GetCreationInformation(std::string& theOperationName, switch ( aType ) { case BASIC_FILLING: { - AddParam( theParams, "Input compound", aCI.GetShape() ); + AddParam( theParams, "Input compound", aCI.GetShapes() ); AddParam( theParams, "Method", aCI.GetMethod() ); const char* method[3] = { "Standard", "Use edges orientation", "Correct edges orientation" }; diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 27c366d8e..7483e2263 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -626,8 +626,8 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRH (Handle(GEO */ //============================================================================= Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, double theH, double theA) + Handle(GEOM_Object) theVec, + double theR, double theH, double theA) { SetErrorCode(KO); @@ -1615,15 +1615,19 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways * MakeFilling */ //============================================================================= -Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling - (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, - double theTol2D, double theTol3D, int theNbIter, - int theMethod, bool isApprox) +Handle(GEOM_Object) +GEOMImpl_I3DPrimOperations::MakeFilling (std::list< Handle(GEOM_Object)> & theContours, + int theMinDeg, int theMaxDeg, + double theTol2D, double theTol3D, int theNbIter, + int theMethod, bool isApprox) { SetErrorCode(KO); - if (theShape.IsNull()) return NULL; - + Handle(TColStd_HSequenceOfTransient) contours = GEOM_Object::GetLastFunctions( theContours ); + if ( contours.IsNull() || contours->IsEmpty() ) { + SetErrorCode("NULL argument shape"); + return NULL; + } //Add a new Filling object Handle(GEOM_Object) aFilling = GetEngine()->AddObject(GetDocID(), GEOM_FILLING); @@ -1635,12 +1639,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling if (aFunction->GetDriverGUID() != GEOMImpl_FillingDriver::GetID()) return NULL; GEOMImpl_IFilling aFI (aFunction); - - Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); - - if (aRefShape.IsNull()) return NULL; - - aFI.SetShape(aRefShape); + aFI.SetShapes(contours); aFI.SetMinDeg(theMinDeg); aFI.SetMaxDeg(theMaxDeg); aFI.SetTol2D(theTol2D); @@ -1668,17 +1667,17 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling //Make a Python command GEOM::TPythonDump pd (aFunction); - pd << aFilling << " = geompy.MakeFilling(" << theShape ; + pd << aFilling << " = geompy.MakeFilling(" << theContours ; if ( theMinDeg != 2 ) pd << ", theMinDeg=" << theMinDeg ; if ( theMaxDeg != 5 ) pd << ", theMaxDeg=" << theMaxDeg ; if ( fabs(theTol2D-0.0001) > Precision::Confusion() ) - pd << ", theTol2D=" << theTol2D ; + { pd << ", theTol2D=" << theTol2D ; } if ( fabs(theTol3D-0.0001) > Precision::Confusion() ) - pd << ", theTol3D=" << theTol3D ; + { pd << ", theTol3D=" << theTol3D ; } if ( theNbIter != 0 ) pd << ", theNbIter=" << theNbIter ; if ( theMethod==1 ) pd << ", theMethod=GEOM.FOM_UseOri"; else if( theMethod==2 ) pd << ", theMethod=GEOM.FOM_AutoCorrect"; - if(isApprox) pd << ", isApprox=" << isApprox ; + if ( isApprox ) pd << ", isApprox=" << isApprox ; pd << ")"; SetErrorCode(OK); diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index de227452e..c7f427b39 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -50,17 +50,17 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeDiskR (double theR, int theOrientation); Standard_EXPORT Handle(GEOM_Object) MakeCylinderRH (double theR, double theH); Standard_EXPORT Handle(GEOM_Object) MakeCylinderPntVecRH (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, double theH); + Handle(GEOM_Object) theVec, + double theR, double theH); Standard_EXPORT Handle(GEOM_Object) MakeCylinderRHA (double theR, double theH, double theA); Standard_EXPORT Handle(GEOM_Object) MakeCylinderPntVecRHA (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR, double theH, double theA); + Handle(GEOM_Object) theVec, + double theR, double theH, double theA); Standard_EXPORT Handle(GEOM_Object) MakeConeR1R2H (double theR1, double theR2, double theH); Standard_EXPORT Handle(GEOM_Object) MakeConePntVecR1R2H (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theR1, double theR2, double theH); + Handle(GEOM_Object) theVec, + double theR1, double theR2, double theH); Standard_EXPORT Handle(GEOM_Object) MakeSphereR (double theR); Standard_EXPORT Handle(GEOM_Object) MakeSpherePntR (Handle(GEOM_Object) thePnt, double theR); @@ -68,8 +68,8 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeTorusRR (double theRMajor, double theRMinor); Standard_EXPORT Handle(GEOM_Object) MakeTorusPntVecRR (Handle(GEOM_Object) thePnt, - Handle(GEOM_Object) theVec, - double theRMajor, double theRMinor); + Handle(GEOM_Object) theVec, + double theRMajor, double theRMinor); Standard_EXPORT Handle(GEOM_Object) MakePrismVecH (Handle(GEOM_Object) theBase, Handle(GEOM_Object) theVec, @@ -109,7 +109,7 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Handle(GEOM_Object) theAxis, double theAngle); - Standard_EXPORT Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape, + Standard_EXPORT Handle(GEOM_Object) MakeFilling (std::list< Handle(GEOM_Object)> & theContours, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter, int theMethod, diff --git a/src/GEOMImpl/GEOMImpl_IFilling.hxx b/src/GEOMImpl/GEOMImpl_IFilling.hxx index a8fabe3bb..c130b162e 100644 --- a/src/GEOMImpl/GEOMImpl_IFilling.hxx +++ b/src/GEOMImpl/GEOMImpl_IFilling.hxx @@ -23,44 +23,61 @@ //NOTE: This is an intreface to a function for the Filling operation. // #include "GEOM_Function.hxx" +#include -#define FILL_ARG_MINDEG 1 -#define FILL_ARG_MAXDEG 2 -#define FILL_ARG_TOL2D 3 -#define FILL_ARG_TOL3D 4 -#define FILL_ARG_SHAPE 5 -#define FILL_ARG_NBITER 6 -#define FILL_ARG_APPROX 7 -#define FILL_ARG_METHOD 8 +enum GEOMImpl_IFilling_Arg { + FILL_ARG_MINDEG = 1, + FILL_ARG_MAXDEG = 2, + FILL_ARG_TOL2D = 3, + FILL_ARG_TOL3D = 4, + FILL_ARG_SHAPE = 5, + FILL_ARG_NBITER = 6, + FILL_ARG_APPROX = 7, + FILL_ARG_METHOD = 8 +}; class GEOMImpl_IFilling { - public: +public: GEOMImpl_IFilling(Handle(GEOM_Function) theFunction): _func(theFunction) {} - + void SetTol2D(double theTol2D) { _func->SetReal(FILL_ARG_TOL2D, theTol2D); } - void SetTol3D(double theTol3D) { _func->SetReal(FILL_ARG_TOL3D, theTol3D); } + void SetTol3D(double theTol3D) { _func->SetReal(FILL_ARG_TOL3D, theTol3D); } double GetTol2D() { return _func->GetReal(FILL_ARG_TOL2D); } - double GetTol3D() { return _func->GetReal(FILL_ARG_TOL3D); } - + double GetTol3D() { return _func->GetReal(FILL_ARG_TOL3D); } + void SetMinDeg(int theMinDeg) { _func->SetInteger(FILL_ARG_MINDEG, theMinDeg); } void SetMaxDeg(int theMaxDeg) { _func->SetInteger(FILL_ARG_MAXDEG, theMaxDeg); } int GetMinDeg() { return _func->GetInteger(FILL_ARG_MINDEG); } int GetMaxDeg() { return _func->GetInteger(FILL_ARG_MAXDEG); } void SetNbIter(int theNbIter) { _func->SetInteger(FILL_ARG_NBITER, theNbIter); } - int GetNbIter() { return _func->GetInteger(FILL_ARG_NBITER); } + int GetNbIter() { return _func->GetInteger(FILL_ARG_NBITER); } void SetApprox(bool theApprox) { _func->SetInteger(FILL_ARG_APPROX, theApprox); } - bool GetApprox() { return _func->GetInteger(FILL_ARG_APPROX); } + bool GetApprox() { return _func->GetInteger(FILL_ARG_APPROX); } void SetMethod(int theMethod) { _func->SetInteger(FILL_ARG_METHOD, theMethod); } - int GetMethod() { return _func->GetInteger(FILL_ARG_METHOD); } + int GetMethod() { return _func->GetInteger(FILL_ARG_METHOD); } + void SetShapes(const Handle(TColStd_HSequenceOfTransient)& theShapes) + { _func->SetReferenceList(FILL_ARG_SHAPE, theShapes); } + Handle(TColStd_HSequenceOfTransient) GetShapes() + { + Handle(TColStd_HSequenceOfTransient) aSeq = _func->GetReferenceList(FILL_ARG_SHAPE); + if ( aSeq.IsNull() ) { + Handle(GEOM_Function) fun = GetShape(); + if ( !fun.IsNull() ) { + aSeq = new TColStd_HSequenceOfTransient; + aSeq->Append( fun ); + } + } + return aSeq; + } void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(FILL_ARG_SHAPE, theShape); } Handle(GEOM_Function) GetShape() { return _func->GetReference(FILL_ARG_SHAPE); } - private: +private: Handle(GEOM_Function) _func; }; diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index ef874e824..e302bdb1e 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -880,14 +880,14 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle2Ways */ //============================================================================= GEOM::GEOM_Object_ptr -GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape, - CORBA::Long theMinDeg, - CORBA::Long theMaxDeg, - CORBA::Double theTol2D, - CORBA::Double theTol3D, - CORBA::Long theNbIter, +GEOM_I3DPrimOperations_i::MakeFilling(const GEOM::ListOfGO& theContours, + CORBA::Long theMinDeg, + CORBA::Long theMaxDeg, + CORBA::Double theTol2D, + CORBA::Double theTol3D, + CORBA::Long theNbIter, GEOM::filling_oper_method theMethod, - CORBA::Boolean theApprox) + CORBA::Boolean theApprox) { GEOM::GEOM_Object_var aGEOMObject; @@ -895,9 +895,9 @@ GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape, GetOperations()->SetNotDone(); //Get the reference objects - Handle(GEOM_Object) aShape = GetObjectImpl(theShape); - - if (aShape.IsNull()) return aGEOMObject._retn(); + std::list< Handle(GEOM_Object) > aShapes; + if (! GetListOfObjectsImpl( theContours, aShapes )) + return aGEOMObject._retn(); int aMethod = 0; switch (theMethod) { @@ -925,8 +925,7 @@ GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_ptr theShape, //Create the Solid Handle(GEOM_Object) anObject = GetOperations()->MakeFilling - (aShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, - aMethod, theApprox); + (aShapes, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, aMethod, theApprox); if (!GetOperations()->IsDone() || anObject.IsNull()) return aGEOMObject._retn(); diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh index 56c1cbc7b..844067dd4 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -166,7 +166,7 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr theAxis, CORBA::Double theAngle); - GEOM::GEOM_Object_ptr MakeFilling(GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_ptr MakeFilling(const GEOM::ListOfGO& theContours, CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, CORBA::Long theNbIter, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 867a5c6f7..98cc96638 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1453,8 +1453,11 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilling (GEOM::GEOM_Object_ptr theShape beginService( " GEOM_Superv_i::MakeFilling" ); MESSAGE("GEOM_Superv_i::MakeFilling"); get3DPrimOp(); + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length( 1 ); + objList[0] = theShape; GEOM::GEOM_Object_ptr anObj = - my3DPrimOp->MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, + my3DPrimOp->MakeFilling(objList, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, theMethod, theApprox); endService( " GEOM_Superv_i::MakeFilling" ); return anObj; @@ -2348,8 +2351,11 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeGlueFaces (GEOM::GEOM_Object_ptr theSha beginService( " GEOM_Superv_i::MakeGlueFaces" ); MESSAGE("GEOM_Superv_i::MakeGlueFaces"); getShapesOp(); + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length( 1 ); + objList[0] = theShape; GEOM::GEOM_Object_ptr anObj = - myShapesOp->MakeGlueFaces(theShape, theTolerance, doKeepNonSolids); + myShapesOp->MakeGlueFaces(objList, theTolerance, doKeepNonSolids); endService( " GEOM_Superv_i::MakeGlueFaces" ); return anObj; } @@ -2363,7 +2369,10 @@ GEOM::GEOM_List_ptr GEOM_Superv_i::GetGlueFaces (GEOM::GEOM_Object_ptr theShape, beginService( " GEOM_Superv_i::GetGlueFaces" ); MESSAGE("GEOM_Superv_i::GetGlueFaces"); getShapesOp(); - GEOM::ListOfGO* aList = myShapesOp->GetGlueFaces(theShape, theTolerance); + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length( 1 ); + objList[0] = theShape; + GEOM::ListOfGO* aList = myShapesOp->GetGlueFaces(objList, theTolerance); GEOM_List_i* aListPtr = new GEOM_List_i(*(aList)); MESSAGE(" List of "<GetList().length()<<" element(s)"); endService( " GEOM_Superv_i::GetGlueFaces" ); @@ -2382,8 +2391,11 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeGlueFacesByList (GEOM::GEOM_Object_ptr beginService( " GEOM_Superv_i::MakeGlueFacesByList" ); MESSAGE("GEOM_Superv_i::MakeGlueFacesByList"); getShapesOp(); + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length( 1 ); + objList[0] = theShape; GEOM::GEOM_Object_ptr anObj = - myShapesOp->MakeGlueFacesByList(theShape, theTolerance, theFaces, + myShapesOp->MakeGlueFacesByList(objList, theTolerance, theFaces, doKeepNonSolids, doGlueAllEdges); endService( " GEOM_Superv_i::MakeGlueFacesByList" ); return anObj; diff --git a/src/GEOM_SWIG/geomBuilder.py b/src/GEOM_SWIG/geomBuilder.py index e20f6031e..32c1c23dc 100644 --- a/src/GEOM_SWIG/geomBuilder.py +++ b/src/GEOM_SWIG/geomBuilder.py @@ -3725,14 +3725,15 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): self._autoPublish(anObj, theName, "revolution") return anObj - ## Create a filling from the given compound of contours. - # @param theShape the compound of contours - # @param theMinDeg a minimal degree of BSpline surface to create - # @param theMaxDeg a maximal degree of BSpline surface to create - # @param theTol2D a 2d tolerance to be reached - # @param theTol3D a 3d tolerance to be reached - # @param theNbIter a number of iteration of approximation algorithm - # @param theMethod Kind of method to perform filling operation(see GEOM::filling_oper_method()) + ## Create a face from a given set of contours. + # @param theContours either a list or a compound of edges/wires. + # @param theMinDeg a minimal degree of BSpline surface to create. + # @param theMaxDeg a maximal degree of BSpline surface to create. + # @param theTol2D a 2d tolerance to be reached. + # @param theTol3D a 3d tolerance to be reached. + # @param theNbIter a number of iteration of approximation algorithm. + # @param theMethod Kind of method to perform filling operation + # (see GEOM.filling_oper_method enum). # @param isApprox if True, BSpline curves are generated in the process # of surface construction. By default it is False, that means # the surface is created using given curves. The usage of @@ -3742,41 +3743,42 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return New GEOM.GEOM_Object, containing the created filling surface. + # @return New GEOM.GEOM_Object (face), containing the created filling surface. # # @ref tui_creation_filling "Example" @ManageTransactions("PrimOp") - def MakeFilling(self, theShape, theMinDeg=2, theMaxDeg=5, theTol2D=0.0001, + def MakeFilling(self, theContours, theMinDeg=2, theMaxDeg=5, theTol2D=0.0001, theTol3D=0.0001, theNbIter=0, theMethod=GEOM.FOM_Default, isApprox=0, theName=None): """ - Create a filling from the given compound of contours. + Create a face from a given set of contours. Parameters: - theShape the compound of contours - theMinDeg a minimal degree of BSpline surface to create - theMaxDeg a maximal degree of BSpline surface to create - theTol2D a 2d tolerance to be reached - theTol3D a 3d tolerance to be reached - theNbIter a number of iteration of approximation algorithm - theMethod Kind of method to perform filling operation(see GEOM::filling_oper_method()) + theContours either a list or a compound of edges/wires. + theMinDeg a minimal degree of BSpline surface to create. + theMaxDeg a maximal degree of BSpline surface to create. + theTol2D a 2d tolerance to be reached. + theTol3D a 3d tolerance to be reached. + theNbIter a number of iteration of approximation algorithm. + theMethod Kind of method to perform filling operation + (see GEOM.filling_oper_method enum). isApprox if True, BSpline curves are generated in the process of surface construction. By default it is False, that means the surface is created using given curves. The usage of Approximation makes the algorithm work slower, but allows - building the surface for rather complex cases + building the surface for rather complex cases. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created filling surface. + New GEOM.GEOM_Object (face), containing the created filling surface. Example of usage: filling = geompy.MakeFilling(compound, 2, 5, 0.0001, 0.0001, 5) """ # Example: see GEOM_TestAll.py theMinDeg,theMaxDeg,theTol2D,theTol3D,theNbIter,Parameters = ParseParameters(theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter) - anObj = self.PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, + anObj = self.PrimOp.MakeFilling(ToList(theContours), theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, theMethod, isApprox) RaiseIfFailed("MakeFilling", self.PrimOp) @@ -3785,43 +3787,43 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): return anObj - ## Create a filling from the given compound of contours. - # This method corresponds to MakeFilling with isApprox=True - # @param theShape the compound of contours - # @param theMinDeg a minimal degree of BSpline surface to create - # @param theMaxDeg a maximal degree of BSpline surface to create - # @param theTol3D a 3d tolerance to be reached + ## Create a face from a given set of contours. + # This method corresponds to MakeFilling() with isApprox=True. + # @param theContours either a list or a compound of edges/wires. + # @param theMinDeg a minimal degree of BSpline surface to create. + # @param theMaxDeg a maximal degree of BSpline surface to create. + # @param theTol3D a 3d tolerance to be reached. # @param theName Object name; when specified, this parameter is used # for result publication in the study. Otherwise, if automatic # publication is switched on, default value is used for result name. # - # @return New GEOM.GEOM_Object, containing the created filling surface. + # @return New GEOM.GEOM_Object (face), containing the created filling surface. # # @ref tui_creation_filling "Example" @ManageTransactions("PrimOp") - def MakeFillingNew(self, theShape, theMinDeg=2, theMaxDeg=5, theTol3D=0.0001, theName=None): + def MakeFillingNew(self, theContours, theMinDeg=2, theMaxDeg=5, theTol3D=0.0001, theName=None): """ Create a filling from the given compound of contours. - This method corresponds to MakeFilling with isApprox=True + This method corresponds to MakeFilling() with isApprox=True. Parameters: - theShape the compound of contours - theMinDeg a minimal degree of BSpline surface to create - theMaxDeg a maximal degree of BSpline surface to create - theTol3D a 3d tolerance to be reached + theContours either a list or a compound of edges/wires. + theMinDeg a minimal degree of BSpline surface to create. + theMaxDeg a maximal degree of BSpline surface to create. + theTol3D a 3d tolerance to be reached. theName Object name; when specified, this parameter is used for result publication in the study. Otherwise, if automatic publication is switched on, default value is used for result name. Returns: - New GEOM.GEOM_Object, containing the created filling surface. + New GEOM.GEOM_Object (face), containing the created filling surface. Example of usage: filling = geompy.MakeFillingNew(compound, 2, 5, 0.0001) """ # Example: see GEOM_TestAll.py theMinDeg,theMaxDeg,theTol3D,Parameters = ParseParameters(theMinDeg, theMaxDeg, theTol3D) - anObj = self.PrimOp.MakeFilling(theShape, theMinDeg, theMaxDeg, + anObj = self.PrimOp.MakeFilling(theContours, theMinDeg, theMaxDeg, 0, theTol3D, 0, GEOM.FOM_Default, True) RaiseIfFailed("MakeFillingNew", self.PrimOp) anObj.SetParameters(Parameters) @@ -4500,7 +4502,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the created face. """ # Example: see GEOM_TestAll.py - anObj = self.ShapesOp.MakeFaceWires(theWires, isPlanarWanted) + anObj = self.ShapesOp.MakeFaceWires(ToList(theWires), isPlanarWanted) if isPlanarWanted and anObj is not None and self.ShapesOp.GetErrorCode() == "MAKE_FACE_TOLERANCE_TOO_BIG": print "WARNING: Cannot build a planar face: required tolerance is too big. Non-planar face is built." else: @@ -4574,6 +4576,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the created solid. """ # Example: see GEOM_TestAll.py + theShells = ToList(theShells) if len(theShells) == 1: descr = self._IsGoodForSolid(theShells[0]) #if len(descr) > 0: @@ -4609,7 +4612,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen): New GEOM.GEOM_Object, containing the created compound. """ # Example: see GEOM_TestAll.py - anObj = self.ShapesOp.MakeCompound(theShapes) + anObj = self.ShapesOp.MakeCompound(ToList(theShapes)) RaiseIfFailed("MakeCompound", self.ShapesOp) self._autoPublish(anObj, theName, "compound") return anObj diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx index 141b9598f..cb85fad52 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx @@ -35,7 +35,8 @@ #include #include -#include +#include + #include //================================================================================= @@ -105,7 +106,7 @@ void GenerationGUI_FillingDlg::Init() myEditCurrentArgument = GroupPoints->LineEdit1; GroupPoints->LineEdit1->setReadOnly(true); - globalSelection(GEOM_COMPOUND); + initSelection(); int SpecificStep1 = 1; double SpecificStep2 = 0.0001; @@ -186,9 +187,24 @@ bool GenerationGUI_FillingDlg::ClickOnApply() return false; initName(); + initSelection(); + return true; } +//================================================================================= +// function : initSelection +// purpose : +//================================================================================= +void GenerationGUI_FillingDlg::initSelection() +{ + TColStd_MapOfInteger aTypes; + aTypes.Add( GEOM_EDGE ); + aTypes.Add( GEOM_WIRE ); + aTypes.Add( GEOM_COMPOUND ); + globalSelection( aTypes ); +} + //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case @@ -199,18 +215,13 @@ void GenerationGUI_FillingDlg::SelectionIntoArgument() myEditCurrentArgument->setText(""); if (myEditCurrentArgument == GroupPoints->LineEdit1) { - myCompound = getSelected(TopAbs_COMPOUND); - if (myCompound) { - if (myCompound->GetMaxShapeType() < GEOM::WIRE || myCompound->GetMinShapeType() > GEOM::EDGE) { - myCompound.nullify(); - } - else { - QString aName = GEOMBase::GetName(myCompound.get()); - myEditCurrentArgument->setText(aName); - } + QList objs = getSelected(TopAbs_SHAPE, -1); + GEOMBase::Synchronize(myObjects, objs); + if ( !myObjects.isEmpty() ) { + QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() ); + myEditCurrentArgument->setText( aName ); } } - processPreview(); } @@ -240,7 +251,7 @@ void GenerationGUI_FillingDlg::ActivateThisDialog() GEOMBase_Skeleton::ActivateThisDialog(); connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); - globalSelection(GEOM_COMPOUND); + initSelection(); processPreview(); } @@ -319,12 +330,12 @@ GEOM::GEOM_IOperations_ptr GenerationGUI_FillingDlg::createOperation() //================================================================================= bool GenerationGUI_FillingDlg::isValid(QString& msg) { - bool ok = GroupPoints->SpinBox1->isValid(msg, !IsPreview()) && - GroupPoints->SpinBox2->isValid(msg, !IsPreview()) && - GroupPoints->SpinBox3->isValid(msg, !IsPreview()) && - GroupPoints->SpinBox4->isValid(msg, !IsPreview()) && - GroupPoints->SpinBox5->isValid(msg, !IsPreview()) && - myCompound; + bool ok = ( GroupPoints->SpinBox1->isValid(msg, !IsPreview()) && + GroupPoints->SpinBox2->isValid(msg, !IsPreview()) && + GroupPoints->SpinBox3->isValid(msg, !IsPreview()) && + GroupPoints->SpinBox4->isValid(msg, !IsPreview()) && + GroupPoints->SpinBox5->isValid(msg, !IsPreview()) && + myObjects.count() ); return ok; } @@ -340,21 +351,26 @@ bool GenerationGUI_FillingDlg::execute(ObjectList& objects) GEOM::filling_oper_method aMethod; switch (GroupPoints->ComboBox1->currentIndex()) { - case 0: aMethod = GEOM::FOM_Default; break; - case 1: aMethod = GEOM::FOM_UseOri; break; - case 2: aMethod = GEOM::FOM_AutoCorrect; break; - default: break; + case 0: aMethod = GEOM::FOM_Default; break; + case 1: aMethod = GEOM::FOM_UseOri; break; + case 2: aMethod = GEOM::FOM_AutoCorrect; break; + default: break; } + GEOM::ListOfGO_var objList = new GEOM::ListOfGO; + objList->length( myObjects.count() ); + for ( int i = 0; i < myObjects.count(); ++i ) + objList[i] = myObjects[i].copy(); + GEOM::GEOM_Object_var anObj = - anOper->MakeFilling(myCompound.get(), - GroupPoints->SpinBox1->value(), - GroupPoints->SpinBox4->value(), - GroupPoints->SpinBox2->value(), - GroupPoints->SpinBox5->value(), - GroupPoints->SpinBox3->value(), - aMethod, - GroupPoints->CheckBox1->isChecked()); + anOper->MakeFilling(objList, + GroupPoints->SpinBox1->value(), + GroupPoints->SpinBox4->value(), + GroupPoints->SpinBox2->value(), + GroupPoints->SpinBox5->value(), + GroupPoints->SpinBox3->value(), + aMethod, + GroupPoints->CheckBox1->isChecked()); if (!anObj->_is_nil()) { if (!IsPreview()) diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.h b/src/GenerationGUI/GenerationGUI_FillingDlg.h index a6a828a04..f849cc468 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.h +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.h @@ -53,9 +53,10 @@ protected: private: void Init(); void enterEvent( QEvent* ); + void initSelection(); private: - GEOM::GeomObjPtr myCompound; /* compound of curves */ + QList myObjects;/* lit or compound of curves */ DlgRef_1Sel5Spin1Check* GroupPoints; private slots: