From: skl Date: Thu, 18 Mar 2010 13:18:15 +0000 (+0000) Subject: Changes for 0020673 - Implementation of "Auto-correct edges orientation". X-Git-Tag: V5_1_4a1~34 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=04e48a49077a1dbdffb320370fd97927e935950b;p=modules%2Fgeom.git Changes for 0020673 - Implementation of "Auto-correct edges orientation". --- diff --git a/doc/salome/gui/GEOM/images/filling.png b/doc/salome/gui/GEOM/images/filling.png index da4ad8d41..2b2f4fb10 100755 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 b096fd8e7..e082127ac 100644 --- a/doc/salome/gui/GEOM/input/creating_filling.doc +++ b/doc/salome/gui/GEOM/input/creating_filling.doc @@ -18,9 +18,13 @@ created surface and the reference edge; 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 Use orientation - if checked, orientation of edges are used: -if edge is reversed curve from this edge is reversed before using in -filling algorithm. +\n Method - Kind of method to perform filling operation +1. Default - standard behaviour +2. Use edges orientation - orientation of edges are used: if edge is +reversed curve from this edge is reversed before using in filling +algorithm. +3. Auto-correct edges orientation - change orientation of curves using +minimization of sum of distances between ends points of edges. \n Approximation - if checked, BSpline curves are generated in the process of surface construction (using GeomAPI_PointsToBSplineSurface functionality). By default the surface diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 451d7e6d2..a93cdb751 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -114,6 +114,22 @@ module GEOM FSM_GetInPlaceByHistory }; + /*! + * Kind of method to perform filling operation + * Is used in functions GEOM_Gen.MakeFilling() + */ + enum filling_oper_method + { + /*! Default (standard behaviour) */ + FOM_Default, + + /*! Use edges orientation */ + FOM_UseOri, + + /*! Auto-correct edges orientation */ + FOM_AutoCorrect + }; + typedef sequence string_array; typedef sequence short_array; @@ -1180,12 +1196,14 @@ module GEOM * \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. * \return New GEOM_Object, containing the created filling surface. */ GEOM_Object MakeFilling (in GEOM_Object theShape, in long theMinDeg, in long theMaxDeg, in double theTol2D, in double theTol3D, - in long theNbIter, in boolean theUseOri, + in long theNbIter, + in filling_oper_method theMethod, in boolean theApprox); /*! diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 8fdc7d1c0..1c7986bf8 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -200,7 +200,8 @@ module GEOM GEOM_Object MakeFilling (in GEOM_Object theShape, in long theMinDeg, in long theMaxDeg, in double theTol2D, in double theTol3D, - in long theNbIter, in boolean theUseOri, + in long theNbIter, + in filling_oper_method theMethod, in boolean theApprox) ; GEOM_Object MakeThruSections(in ListOfGO theSeqSections, in boolean theModeSolid, diff --git a/src/DlgRef/DlgRef_1Sel5Spin1Check_QTD.ui b/src/DlgRef/DlgRef_1Sel5Spin1Check_QTD.ui index cbb0de7d9..da4fd5062 100644 --- a/src/DlgRef/DlgRef_1Sel5Spin1Check_QTD.ui +++ b/src/DlgRef/DlgRef_1Sel5Spin1Check_QTD.ui @@ -7,13 +7,13 @@ 0 0 200 - 153 + 162 - + 0 @@ -59,13 +59,25 @@ - - + + + + + 0 + 0 + + - + TL7 + + + false + + + @@ -187,7 +199,7 @@ PushButton1 LineEdit1 - CheckBox2 + ComboBox1 SpinBox1 SpinBox2 SpinBox4 diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 1f7fb0a0b..766fcc0cb 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -3787,9 +3787,21 @@ Please, select face, shell or solid and try again GEOM_FILLING_APPROX Approximation + + GEOM_FILLING_METHOD + Method + + + GEOM_FILLING_DEFAULT + Default (standard behaviour) + GEOM_FILLING_USEORI - Use orientation + Use edges orientation + + + GEOM_FILLING_AUTO + Auto-correct edges orientation GEOM_WRN_NO_APPROPRIATE_SELECTION diff --git a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx index cf893cd46..a941a0f69 100644 --- a/src/GEOMImpl/GEOMImpl_FillingDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_FillingDriver.cxx @@ -110,7 +110,7 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const Standard_Real tol2d = IF.GetTol3D(); Standard_Integer nbiter = IF.GetNbIter(); Standard_Boolean isApprox = IF.GetApprox(); - Standard_Boolean isUseOri = IF.GetUseOri(); + Standard_Integer aMethod = IF.GetMethod(); if (mindeg > maxdeg) { Standard_RangeError::Raise("Minimal degree can not be more than maximal degree"); @@ -224,6 +224,8 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const // make filling as in old version of SALOME (before 4.1.1) GeomFill_SectionGenerator Section; Standard_Integer i = 0; + Handle(Geom_Curve) aLastC; + gp_Pnt PL1,PL2; for (Ex.Init(aShape, TopAbs_EDGE); Ex.More(); Ex.Next()) { Scurrent = Ex.Current(); if (Scurrent.IsNull() || Scurrent.ShapeType() != TopAbs_EDGE) return 0; @@ -235,9 +237,33 @@ Standard_Integer GEOMImpl_FillingDriver::Execute(TFunction_Logbook& log) const //else // C = new Geom_TrimmedCurve(C, First, Last); C = new Geom_TrimmedCurve(C, First, Last); - if( isUseOri && Scurrent.Orientation() == TopAbs_REVERSED ) { + gp_Pnt P1,P2; + C->D0(First,P1); + C->D0(Last,P2); + + if( aMethod==1 && Scurrent.Orientation() == TopAbs_REVERSED ) { C->Reverse(); } + else if( aMethod==2 ) { + if( i==0 ) { + PL1 = P1; + PL2 = P2; + } + else { + double d1 = PL1.Distance(P1) + PL2.Distance(P2); + double d2 = PL1.Distance(P2) + PL2.Distance(P1); + if(d2Reverse(); + PL1 = P2; + PL2 = P1; + } + else { + PL1 = P1; + PL2 = P2; + } + } + } + Section.AddCurve(C); i++; } diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index 185f6bb72..6c03dd7fb 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -1454,7 +1454,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle2Ways Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter, - bool isUseOri, bool isApprox) + int theMethod, bool isApprox) { SetErrorCode(KO); @@ -1483,7 +1483,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeFilling aFI.SetTol3D(theTol3D); aFI.SetNbIter(theNbIter); aFI.SetApprox(isApprox); - aFI.SetUseOri(isUseOri); + aFI.SetMethod(theMethod); //Compute the Solid value try { diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx index f8652b3fa..87277ae71 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.hxx @@ -100,7 +100,7 @@ class GEOMImpl_I3DPrimOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, - int theNbIter, bool isUseOri, + int theNbIter, int theMethod, bool isApprox); Standard_EXPORT Handle(GEOM_Object) MakeThruSections diff --git a/src/GEOMImpl/GEOMImpl_IFilling.hxx b/src/GEOMImpl/GEOMImpl_IFilling.hxx index d5d875684..c24aa9692 100644 --- a/src/GEOMImpl/GEOMImpl_IFilling.hxx +++ b/src/GEOMImpl/GEOMImpl_IFilling.hxx @@ -30,7 +30,7 @@ #define FILL_ARG_SHAPE 5 #define FILL_ARG_NBITER 6 #define FILL_ARG_APPROX 7 -#define FILL_ARG_USEORI 8 +#define FILL_ARG_METHOD 8 class GEOMImpl_IFilling { @@ -53,8 +53,8 @@ class GEOMImpl_IFilling void SetApprox(bool theApprox) { _func->SetInteger(FILL_ARG_APPROX, theApprox); } bool GetApprox() { return _func->GetInteger(FILL_ARG_APPROX); } - void SetUseOri(bool theUseOri) { _func->SetInteger(FILL_ARG_USEORI, theUseOri); } - bool GetUseOri() { return _func->GetInteger(FILL_ARG_USEORI); } + void SetMethod(int theMethod) { _func->SetInteger(FILL_ARG_METHOD, theMethod); } + int GetMethod() { return _func->GetInteger(FILL_ARG_METHOD); } void SetShape(Handle(GEOM_Function) theShape) { _func->SetReference(FILL_ARG_SHAPE, theShape); } Handle(GEOM_Function) GetShape() { return _func->GetReference(FILL_ARG_SHAPE); } diff --git a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc index c1ae47314..b56c70e63 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.cc +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.cc @@ -704,14 +704,15 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeRevolutionAxisAngle2Ways * MakeFilling */ //============================================================================= -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, - CORBA::Boolean theUseOri, - CORBA::Boolean theApprox) +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::filling_oper_method theMethod, + CORBA::Boolean theApprox) { GEOM::GEOM_Object_var aGEOMObject; @@ -723,10 +724,34 @@ GEOM::GEOM_Object_ptr GEOM_I3DPrimOperations_i::MakeFilling(GEOM::GEOM_Object_pt if (aShape.IsNull()) return aGEOMObject._retn(); + int aMethod = 0; + switch (theMethod) { + case GEOM::FOM_Default: + { + // Default (standard behaviour) + aMethod = 0; + } + break; + case GEOM::FOM_UseOri: + { + // Use edges orientation + aMethod = 1; + } + break; + case GEOM::FOM_AutoCorrect: + { + // Auto-correct edges orientation + aMethod = 2; + } + break; + default: + {} + } + //Create the Solid Handle(GEOM_Object) anObject = GetOperations()->MakeFilling (aShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, theNbIter, - theUseOri, theApprox); + 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 a31221abb..cabae19a5 100644 --- a/src/GEOM_I/GEOM_I3DPrimOperations_i.hh +++ b/src/GEOM_I/GEOM_I3DPrimOperations_i.hh @@ -137,7 +137,8 @@ class GEOM_I_EXPORT GEOM_I3DPrimOperations_i : GEOM::GEOM_Object_ptr MakeFilling(GEOM::GEOM_Object_ptr theShape, CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, - CORBA::Long theNbIter, CORBA::Boolean theUseOri, + CORBA::Long theNbIter, + GEOM::filling_oper_method theMethod, CORBA::Boolean theApprox); GEOM::GEOM_Object_ptr MakeThruSections(const GEOM::ListOfGO& theSeqSections, diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 0ce3c9539..46d820c65 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -1247,7 +1247,7 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilling (GEOM::GEOM_Object_ptr theShape CORBA::Double theTol2D, CORBA::Double theTol3D, CORBA::Long theNbIter, - CORBA::Boolean theUseOri, + GEOM::filling_oper_method theMethod, CORBA::Boolean theApprox) { beginService( " GEOM_Superv_i::MakeFilling" ); @@ -1255,7 +1255,7 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilling (GEOM::GEOM_Object_ptr theShape get3DPrimOp(); GEOM::GEOM_Object_ptr anObj = my3DPrimOp->MakeFilling(theShape, theMinDeg, theMaxDeg, theTol2D, theTol3D, - theNbIter, theUseOri, theApprox); + theNbIter, theMethod, theApprox); endService( " GEOM_Superv_i::MakeFilling" ); return anObj; } diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index a1d19e9fd..a5f4c9f04 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -288,7 +288,8 @@ public: GEOM::GEOM_Object_ptr MakeFilling (GEOM::GEOM_Object_ptr theShape, CORBA::Long theMinDeg, CORBA::Long theMaxDeg, CORBA::Double theTol2D, CORBA::Double theTol3D, - CORBA::Long theNbIter, CORBA::Boolean theUseOri, + CORBA::Long theNbIter, + GEOM::filling_oper_method theMethod, CORBA::Boolean theApprox); GEOM::GEOM_Object_ptr MakeThruSections(const GEOM::ListOfGO& theSeqSections, diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx index c43b3fd2c..38ccb0933 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.cxx +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.cxx @@ -70,7 +70,7 @@ GenerationGUI_FillingDlg::GenerationGUI_FillingDlg( GeometryGUI* theGeometryGUI, GroupPoints->TextLabel5->setText( tr( "GEOM_FILLING_MAX_DEG" ) ); GroupPoints->TextLabel6->setText( tr( "GEOM_FILLING_TOL_3D" ) ); GroupPoints->CheckBox1->setText( tr( "GEOM_FILLING_APPROX" ) ); - GroupPoints->CheckBox2->setText( tr( "GEOM_FILLING_USEORI" ) ); + GroupPoints->TextLabel7->setText( tr( "GEOM_FILLING_METHOD" ) ); GroupPoints->PushButton1->setIcon( image1 ); GroupPoints->LineEdit1->setReadOnly( true ); @@ -109,7 +109,7 @@ void GenerationGUI_FillingDlg::Init() myTol3D = 0.0001; myTol2D = 0.0001; myNbIter = 0; - myIsUseOri = false; + myMethod = 0; myIsApprox = false; myOkCompound = false; @@ -130,6 +130,10 @@ void GenerationGUI_FillingDlg::Init() GroupPoints->SpinBox4->setValue( myMaxDeg ); GroupPoints->SpinBox5->setValue( myTol3D ); + GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_DEFAULT")); + GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_USEORI")); + GroupPoints->ComboBox1->addItem(tr("GEOM_FILLING_AUTO")); + /* signals and slots connections */ connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ); @@ -137,6 +141,8 @@ void GenerationGUI_FillingDlg::Init() connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) ); connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) ); + connect( GroupPoints->ComboBox1, SIGNAL(activated(int)), this, SLOT(MethodChanged())); + connect( GroupPoints->SpinBox1, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPoints->SpinBox2, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); connect( GroupPoints->SpinBox3, SIGNAL( valueChanged( double ) ), this, SLOT( ValueChangedInSpinBox( double ) ) ); @@ -146,9 +152,6 @@ void GenerationGUI_FillingDlg::Init() connect( GroupPoints->CheckBox1, SIGNAL( stateChanged( int ) ), this, SLOT( ApproxChanged() ) ); - connect( GroupPoints->CheckBox2, SIGNAL( stateChanged( int ) ), - this, SLOT( UseOriChanged() ) ); - connect( myGeomGUI, SIGNAL( SignalDefaultStepValueChanged( double ) ), this, SLOT( SetDoubleSpinBoxStep( double ) ) ); connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(), @@ -322,12 +325,12 @@ void GenerationGUI_FillingDlg::ValueChangedInSpinBox( double newValue ) } //================================================================================= -// function : UseOriChanged() +// function : MethodChanged // purpose : //================================================================================= -void GenerationGUI_FillingDlg::UseOriChanged() +void GenerationGUI_FillingDlg::MethodChanged() { - myIsUseOri = GroupPoints->CheckBox2->isChecked(); + myMethod = GroupPoints->ComboBox1->currentIndex(); displayPreview(); } @@ -375,9 +378,19 @@ bool GenerationGUI_FillingDlg::execute( ObjectList& objects ) { GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation()); + + 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; + } + GEOM::GEOM_Object_var anObj = anOper->MakeFilling( myCompound, myMinDeg, myMaxDeg, myTol2D, myTol3D, - myNbIter, myIsUseOri, myIsApprox ); + myNbIter, aMethod, myIsApprox ); if ( !anObj->_is_nil() ) { if ( !IsPreview() ) diff --git a/src/GenerationGUI/GenerationGUI_FillingDlg.h b/src/GenerationGUI/GenerationGUI_FillingDlg.h index f30dfa2bd..e7b8ac075 100644 --- a/src/GenerationGUI/GenerationGUI_FillingDlg.h +++ b/src/GenerationGUI/GenerationGUI_FillingDlg.h @@ -60,7 +60,7 @@ private: Standard_Real myTol2D; Standard_Integer myNbIter; bool myIsApprox; - bool myIsUseOri; + int myMethod; bool myOkCompound; /* to check when curv. compound is defined */ DlgRef_1Sel5Spin1Check* GroupPoints; @@ -73,7 +73,7 @@ private slots: void SelectionIntoArgument(); void SetEditCurrentArgument(); void ValueChangedInSpinBox( double ); - void UseOriChanged(); + void MethodChanged(); void ApproxChanged(); void SetDoubleSpinBoxStep( double ); };