From: dmv Date: Tue, 23 Dec 2008 11:21:26 +0000 (+0000) Subject: 0016819: EDF PAL 564: Make fillet on 2D surface X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=32059ef998ff2c9f025d8a480bffa9355d6758b9;p=modules%2Fgeom.git 0016819: EDF PAL 564: Make fillet on 2D surface --- diff --git a/doc/salome/gui/GEOM/images/fillet2d_1.png b/doc/salome/gui/GEOM/images/fillet2d_1.png new file mode 100755 index 000000000..859796aae Binary files /dev/null and b/doc/salome/gui/GEOM/images/fillet2d_1.png differ diff --git a/doc/salome/gui/GEOM/images/fillet2d_2.png b/doc/salome/gui/GEOM/images/fillet2d_2.png new file mode 100755 index 000000000..39a337845 Binary files /dev/null and b/doc/salome/gui/GEOM/images/fillet2d_2.png differ diff --git a/doc/salome/gui/GEOM/input/fillet2d_operation.doc b/doc/salome/gui/GEOM/input/fillet2d_operation.doc new file mode 100755 index 000000000..52d49f9ea --- /dev/null +++ b/doc/salome/gui/GEOM/input/fillet2d_operation.doc @@ -0,0 +1,25 @@ +/*! + +\page fillet2d_operation_page Fillet 2D + +This operation creates fillets on the corners of a 2D Planar Face. + +\image html fillet2d_2.png + +To produce a \b Fillet 2D in the Main Menu select +Operations - > Transformation - > Fillet 2D + +Define the Main Object to create a fillet on, select the necessary +vertexes on this face in the OCC Viewer and define the \b Radius of the Fillet. + +TUI Command: geompy.MakeFillet(Shape, R, ListVertexes) +\n Arguments: Name + 1 shape + one or several vertexes + 1 value (Fillet radius). + +Examples: + +\image html fillet2d_1.png + +Our TUI Scripts provide you with useful examples of the use of +\ref tui_fillet2d "Transformation Operations". + +*/ diff --git a/doc/salome/gui/GEOM/input/index.doc b/doc/salome/gui/GEOM/input/index.doc index 12941c823..919dee491 100644 --- a/doc/salome/gui/GEOM/input/index.doc +++ b/doc/salome/gui/GEOM/input/index.doc @@ -86,6 +86,7 @@
  • \ref offset_operation_page
  • \ref multi_translation_operation_page
  • \ref multi_rotation_operation_page
  • +
  • \ref fillet2d_operation_page
  • \ref fillet_operation_page
  • \ref chamfer_operation_page
  • diff --git a/doc/salome/gui/GEOM/input/transformation_operations.doc b/doc/salome/gui/GEOM/input/transformation_operations.doc index efb331f1c..cb8246a80 100644 --- a/doc/salome/gui/GEOM/input/transformation_operations.doc +++ b/doc/salome/gui/GEOM/input/transformation_operations.doc @@ -11,6 +11,7 @@
  • \subpage offset_operation_page
  • \subpage multi_translation_operation_page
  • \subpage multi_rotation_operation_page
  • +
  • \subpage fillet2d_operation_page
  • \subpage fillet_operation_page
  • \subpage chamfer_operation_page
  • diff --git a/doc/salome/gui/GEOM/input/transforming_geom_objs.doc b/doc/salome/gui/GEOM/input/transforming_geom_objs.doc index 3daec5a37..ab22d3c10 100644 --- a/doc/salome/gui/GEOM/input/transforming_geom_objs.doc +++ b/doc/salome/gui/GEOM/input/transforming_geom_objs.doc @@ -26,6 +26,7 @@
  • \ref offset_operation_page
  • \ref multi_translation_operation_page
  • \ref multi_rotation_operation_page
  • +
  • \ref fillet2d_operation_page
  • \ref fillet_operation_page
  • \ref chamfer_operation_page
  • diff --git a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc index 73985a581..8301afa6f 100644 --- a/doc/salome/gui/GEOM/input/tui_transformation_operations.doc +++ b/doc/salome/gui/GEOM/input/tui_transformation_operations.doc @@ -349,6 +349,27 @@ gg.createAndDisplayGO(id_rot2d) gg.setDisplayMode(id_rot2d,1) \endcode +\anchor tui_fillet2d +

    Fillet 2D

    + +\code +import geompy +import salome +gg = salome.ImportComponentGUI("GEOM") + +# create a face in OXY plane +face = geompy.MakeFaceHW(100, 100, 1) +fillet2d = geompy.MakeFillet2D(face, 30, [7, 9]) + +# add objects in the study +id_face = geompy.addToStudy(face,"Face_1") +id_fillet2d = geompy.addToStudy(fillet2d,"Fillet 2D_1") + +# display disks +gg.createAndDisplayGO(id_face) +gg.createAndDisplayGO(id_fillet2d) +\endcode + \anchor tui_fillet

    Fillet

    diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index bffefb664..397012d34 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2244,10 +2244,24 @@ module GEOM GEOM_Object MakeFilletFaces (in GEOM_Object theShape, in double theR, in ListOfLong theFaces); + GEOM_Object MakeFilletFacesR1R2 (in GEOM_Object theShape, in double theR1, in double theR2, in ListOfLong theFaces); + + /*! + * Perform a fillet on face of the specified vertexes of the given shape. + * \param theShape Shape, to perform fillet on. + * \param theR Fillet radius. + * \param theVertexes Global indices of vertexes to perform fillet on. + * \note Global index of sub-shape can be obtained, using method + * GEOM_IShapesOperations.GetSubShapeIndex(). + * \return New GEOM_Object, containing the result shape. + */ + GEOM_Object MakeFillet2D (in GEOM_Object theShape, + in double theR, + in ListOfLong theVertexes); /*! * Perform a symmetric chamfer on all edges of the given shape. diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 50c350166..5b5605b61 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -512,6 +512,9 @@ module GEOM in double theR1, in double theR2, in GEOM_List theFaces) ; + GEOM_Object MakeFillet2D (in GEOM_Object theShape, + in double theR, + in GEOM_List theVertexes) ; GEOM_Object MakeChamferAll (in GEOM_Object theShape, in double theD) ; GEOM_Object MakeChamferEdge (in GEOM_Object theShape, diff --git a/resources/Makefile.am b/resources/Makefile.am index f37e8e9e8..15d23bbac 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -87,6 +87,7 @@ eraseall.png \ face_hw.png \ face_vechw.png \ fillet.png \ +fillet2d.png \ filletall.png \ filletedge.png \ filletface.png \ diff --git a/resources/fillet2d.png b/resources/fillet2d.png new file mode 100755 index 000000000..a17cef65b Binary files /dev/null and b/resources/fillet2d.png differ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index 8d0a032d8..147625f05 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -202,6 +202,10 @@ ICON_DLG_FILLET fillet.png + + ICON_DLG_FILLET_2D + fillet2d.png + ICON_DLG_FILLET_ALL filletall.png @@ -738,6 +742,10 @@ ICO_FILLET fillet.png + + ICO_FILLET_2D + fillet2d.png + ICO_FILLING filling.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 9d466b0aa..af217b165 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -580,6 +580,10 @@ Please, select face, shell or solid and try again GEOM_FILLET Fillet + + GEOM_FILLET_2D + Fillet 2D + GEOM_FILLET_ABORT Fillet can't be computed with radius %1 @@ -596,10 +600,18 @@ Please, select face, shell or solid and try again GEOM_FILLET_FACES Fillet On Faces From Shape + + GEOM_FILLET_VERTEXES + Fillet On Vertexes From Face + GEOM_FILLET_TITLE Fillet Construction + + GEOM_FILLET_2D_TITLE + 2D Fillet Construction + GEOM_FILLING Filling @@ -1812,6 +1824,10 @@ Please, select face, shell or solid and try again GEOM_VERTEX Vertex + + GEOM_VERTEXES + Vertexes + GEOM_WATER_DENSITY Water Density : @@ -2120,6 +2136,10 @@ Please, select face, shell or solid and try again MEN_FILLET Fillet + + MEN_FILLET_2D + Fillet 2D + MEN_FILLING Filling diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 3b514664a..a3f8e4e11 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -491,7 +491,8 @@ void GeometryGUI::OnGUIEvent( int id ) id == 505 || // MENU OPERATION - FILLET id == 506 || // MENU OPERATION - CHAMFER id == 507 || // MENU OPERATION - CLIPPING RANGE - id == 508 ) { // MENU OPERATION - GET SHAPES ON SHAPE + id == 508 || // MENU OPERATION - GET SHAPES ON SHAPE + id == 509 ) { // MENU OPERATION - FILLET 2D #ifndef WNT library = getLibrary( "libOperationGUI.so" ); #else @@ -828,6 +829,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 506, "CHAMFER" ); //createGeomAction( 507, "CLIPPING" ); createGeomAction( 508, "GET_SHAPES_ON_SHAPES" ); + createGeomAction( 509, "FILLET_2D" ); createGeomAction( 9998, "MUL_TRANSFORM" ); createGeomAction( 9995, "EXPLODE_BLOCKS" ); @@ -982,6 +984,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 504, operId, -1 ); createMenu( 508, operId, -1 ); createMenu( separator(), operId, -1 ); + createMenu( 509, transId, -1 ); createMenu( 505, transId, -1 ); createMenu( 506, transId, -1 ); //createMenu( 507, transId, -1 ); diff --git a/src/GEOMImpl/GEOMImpl.pro b/src/GEOMImpl/GEOMImpl.pro index 618fc4abc..e6ee52aab 100644 --- a/src/GEOMImpl/GEOMImpl.pro +++ b/src/GEOMImpl/GEOMImpl.pro @@ -87,6 +87,7 @@ SOURCES += GEOMImpl_ArcDriver.cxx SOURCES += GEOMImpl_SplineDriver.cxx SOURCES += GEOMImpl_SketcherDriver.cxx SOURCES += GEOMImpl_FilletDriver.cxx +SOURCES += GEOMImpl_Fillet2dDriver.cxx SOURCES += GEOMImpl_ChamferDriver.cxx SOURCES += GEOMImpl_BooleanDriver.cxx SOURCES += GEOMImpl_PartitionDriver.cxx diff --git a/src/GEOMImpl/GEOMImpl_Fillet2dDriver.cxx b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.cxx new file mode 100755 index 000000000..f7f2050ae --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.cxx @@ -0,0 +1,152 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +//======================================================================= +//function : GetID +//purpose : +//======================================================================= +const Standard_GUID& GEOMImpl_Fillet2dDriver::GetID() +{ + static Standard_GUID aFillet2dDriver("FF1AAB41-2A14-4df2-581B-3A568163BA46"); + return aFillet2dDriver; +} + + +//======================================================================= +//function : GEOMImpl_Fillet2dDriver +//purpose : +//======================================================================= +GEOMImpl_Fillet2dDriver::GEOMImpl_Fillet2dDriver() +{ +} + +//======================================================================= +//function : Execute +//purpose : +//======================================================================= +Standard_Integer GEOMImpl_Fillet2dDriver::Execute(TFunction_Logbook& log) const +{ + if (Label().IsNull()) return 0; + Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label()); + + GEOMImpl_IFillet2d aCI (aFunction); + + TopoDS_Shape aShape; + + Handle(GEOM_Function) aRefShape = aCI.GetShape(); + TopoDS_Face aFaceShape = TopoDS::Face(aRefShape->GetValue()); + + if (aFaceShape.ShapeType() != TopAbs_FACE) + Standard_ConstructionError::Raise("Wrong arguments: two faces must be given"); + + BRepFilletAPI_MakeFillet2d fillet2d (aFaceShape); + + int aLen = aCI.GetLength(); + int ind = 1; + double rad = aCI.GetR(); + for (; ind <= aLen; ind++) { + TopoDS_Shape aShapeVertex; + if (GEOMImpl_ILocalOperations::GetSubShape + (aFaceShape, aCI.GetVertex(ind), aShapeVertex)) { + fillet2d.AddFillet(TopoDS::Vertex(aShapeVertex), rad); + } + } + + fillet2d.Build(); + if (!fillet2d.IsDone()) { + StdFail_NotDone::Raise("2D Fillet can't be computed on the given shape with the given radius"); + } + aShape = fillet2d.Shape(); + + if (aShape.IsNull()) return 0; + + aFunction->SetValue(aShape); + log.SetTouched(Label()); + + return 1; +} + + +//======================================================================= +//function : GEOMImpl_Fillet2dDriver_Type_ +//purpose : +//======================================================================= +Standard_EXPORT Handle_Standard_Type& GEOMImpl_Fillet2dDriver_Type_() +{ + + static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver); + if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver); + static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared); + if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); + static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient); + if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient); + + + static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL}; + static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_Fillet2dDriver", + sizeof(GEOMImpl_Fillet2dDriver), + 1, + (Standard_Address)_Ancestors, + (Standard_Address)NULL); + + return _aType; +} + +//======================================================================= +//function : DownCast +//purpose : +//======================================================================= +const Handle(GEOMImpl_Fillet2dDriver) Handle(GEOMImpl_Fillet2dDriver)::DownCast(const Handle(Standard_Transient)& AnObject) +{ + Handle(GEOMImpl_Fillet2dDriver) _anOtherObject; + + if (!AnObject.IsNull()) { + if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_Fillet2dDriver))) { + _anOtherObject = Handle(GEOMImpl_Fillet2dDriver)((Handle(GEOMImpl_Fillet2dDriver)&)AnObject); + } + } + + return _anOtherObject ; +} diff --git a/src/GEOMImpl/GEOMImpl_Fillet2dDriver.hxx b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.hxx new file mode 100755 index 000000000..a5448db66 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_Fillet2dDriver.hxx @@ -0,0 +1,158 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : GEOMImpl_Fillet2dDriver.ixx +// Module : GEOMImpl + +#ifndef _GEOMImpl_Fillet2dDriver_HeaderFile +#define _GEOMImpl_Fillet2dDriver_HeaderFile + +#ifndef _TColStd_SequenceOfExtendedString_HeaderFile +#include +#endif +#ifndef _Standard_TypeMismatch_HeaderFile +#include +#endif + +#ifndef _Standard_HeaderFile +#include +#endif + +#ifndef _Standard_Macro_HeaderFile +#include +#endif +#ifndef _Standard_HeaderFile +#include +#endif +#ifndef _Standard_GUID_HeaderFile +#include +#endif + +#ifndef _Handle_TFunction_Driver_HeaderFile +#include +#endif + +class Standard_Transient; +class Handle_Standard_Type; +class Handle(TFunction_Driver); +class GEOMImpl_Fillet2dDriver; + +Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_Fillet2dDriver); + +class Handle(GEOMImpl_Fillet2dDriver) : public Handle(TFunction_Driver) { + public: + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + Handle(GEOMImpl_Fillet2dDriver)():Handle(TFunction_Driver)() {} + Handle(GEOMImpl_Fillet2dDriver)(const Handle(GEOMImpl_Fillet2dDriver)& aHandle) : Handle(TFunction_Driver)(aHandle) + { + } + + Handle(GEOMImpl_Fillet2dDriver)(const GEOMImpl_Fillet2dDriver* anItem) : Handle(TFunction_Driver)((TFunction_Driver *)anItem) + { + } + + Handle(GEOMImpl_Fillet2dDriver)& operator=(const Handle(GEOMImpl_Fillet2dDriver)& aHandle) + { + Assign(aHandle.Access()); + return *this; + } + + Handle(GEOMImpl_Fillet2dDriver)& operator=(const GEOMImpl_Fillet2dDriver* anItem) + { + Assign((Standard_Transient *)anItem); + return *this; + } + + GEOMImpl_Fillet2dDriver* operator->() + { + return (GEOMImpl_Fillet2dDriver *)ControlAccess(); + } + + GEOMImpl_Fillet2dDriver* operator->() const + { + return (GEOMImpl_Fillet2dDriver *)ControlAccess(); + } + + Standard_EXPORT ~Handle(GEOMImpl_Fillet2dDriver)() {}; + + Standard_EXPORT static const Handle(GEOMImpl_Fillet2dDriver) DownCast(const Handle(Standard_Transient)& AnObject); +}; + +#ifndef _TFunction_Driver_HeaderFile +#include +#endif +#ifndef _TFunction_Logbook_HeaderFile +#include +#endif +#ifndef _Standard_CString_HeaderFile +#include +#endif + +class TColStd_SequenceOfExtendedString; + + +class GEOMImpl_Fillet2dDriver : public TFunction_Driver { + +public: + + inline void* operator new(size_t,void* anAddress) + { + return anAddress; + } + inline void* operator new(size_t size) + { + return Standard::Allocate(size); + } + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); + } + + // Methods PUBLIC + // +Standard_EXPORT GEOMImpl_Fillet2dDriver(); +Standard_EXPORT virtual Standard_Integer Execute(TFunction_Logbook& log) const; +Standard_EXPORT virtual void Validate(TFunction_Logbook&) const {} +Standard_EXPORT Standard_Boolean MustExecute(const TFunction_Logbook&) const { return Standard_True; } +Standard_EXPORT static const Standard_GUID& GetID(); +Standard_EXPORT ~GEOMImpl_Fillet2dDriver() {}; + + + // Type management + // +Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_Fillet2dDriver_Type_(); +Standard_EXPORT const Handle(Standard_Type)& DynamicType() const { return STANDARD_TYPE(GEOMImpl_Fillet2dDriver) ; } +Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)& AType) const { return (STANDARD_TYPE(GEOMImpl_Fillet2dDriver) == AType || TFunction_Driver::IsKind(AType)); } + + +}; + +#endif diff --git a/src/GEOMImpl/GEOMImpl_Gen.cxx b/src/GEOMImpl/GEOMImpl_Gen.cxx index ad458c33c..e0cd62fd4 100644 --- a/src/GEOMImpl/GEOMImpl_Gen.cxx +++ b/src/GEOMImpl/GEOMImpl_Gen.cxx @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -131,6 +132,7 @@ GEOMImpl_Gen::GEOMImpl_Gen() // Local Operations TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ChamferDriver::GetID(), new GEOMImpl_ChamferDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FilletDriver::GetID(), new GEOMImpl_FilletDriver()); + TFunction_DriverTable::Get()->AddDriver(GEOMImpl_Fillet2dDriver::GetID(), new GEOMImpl_Fillet2dDriver()); TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ArchimedeDriver::GetID(), new GEOMImpl_ArchimedeDriver()); // Geometrical Transformations, Offset, Scale diff --git a/src/GEOMImpl/GEOMImpl_IFillet2d.hxx b/src/GEOMImpl/GEOMImpl_IFillet2d.hxx new file mode 100755 index 000000000..ba67a6a18 --- /dev/null +++ b/src/GEOMImpl/GEOMImpl_IFillet2d.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +//NOTE: This is an interface to a function for the Fillet2d and creation. + + +#include "GEOM_Function.hxx" + +#define FILLET2D_ARG_SH 1 +#define FILLET2D_ARG_R 2 +#define FILLET2D_ARG_LENG 3 +#define FILLET2D_ARG_LAST 4 + +class GEOMImpl_IFillet2d +{ + public: + + GEOMImpl_IFillet2d(Handle(GEOM_Function) theFunction): _func(theFunction) {} + + void SetShape(Handle(GEOM_Function) theRef) { _func->SetReference(FILLET2D_ARG_SH, theRef); } + Handle(GEOM_Function) GetShape() { return _func->GetReference(FILLET2D_ARG_SH); } + + void SetR(double theR) { _func->SetReal(FILLET2D_ARG_R, theR); } + void SetLength(int theLen) { _func->SetInteger(FILLET2D_ARG_LENG, theLen); } + void SetVertex(int theInd, int theVertex) + { _func->SetInteger(FILLET2D_ARG_LAST + theInd, theVertex); } + + double GetR() { return _func->GetReal(FILLET2D_ARG_R); } + int GetLength() { return _func->GetInteger(FILLET2D_ARG_LENG); } + int GetVertex(int theInd) { return _func->GetInteger(FILLET2D_ARG_LAST + theInd); } + + private: + + Handle(GEOM_Function) _func; +}; diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx index c5f402992..33842e24a 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -27,9 +27,11 @@ #include #include +#include #include #include +#include #include #include @@ -408,6 +410,75 @@ Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFilletFacesR1R2 return aFillet; } +//============================================================================= +/*! + * MakeFillet2D + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_ILocalOperations::MakeFillet2D + (Handle(GEOM_Object) theShape, double theR, std::list theVertexes) +{ + SetErrorCode(KO); + + //Add a new Fillet object + Handle(GEOM_Object) aFillet2D = GetEngine()->AddObject(GetDocID(), GEOM_FILLET_2D); + + //Add a new Fillet function + Handle(GEOM_Function) aFunction = + aFillet2D->AddFunction(GEOMImpl_Fillet2dDriver::GetID(), FILLET_2D_SHAPE_VERTEXES); + if (aFunction.IsNull()) return NULL; + + //Check if the function is set correctly + if (aFunction->GetDriverGUID() != GEOMImpl_Fillet2dDriver::GetID()) return NULL; + + GEOMImpl_IFillet2d aCI (aFunction); + + Handle(GEOM_Function) aRefShape = theShape->GetLastFunction(); + if (aRefShape.IsNull()) return NULL; + + aCI.SetShape(aRefShape); + aCI.SetR(theR); + int aLen = theVertexes.size(); + aCI.SetLength(aLen); + + int ind = 1; + std::list::iterator it = theVertexes.begin(); + for (; it != theVertexes.end(); it++, ind++) { + aCI.SetVertex(ind, (*it)); + } + + //Compute the Fillet value + try { +#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 + OCC_CATCH_SIGNALS; +#endif + if (!GetSolver()->ComputeFunction(aFunction)) { + SetErrorCode("2D Fillet driver failed"); + return NULL; + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + SetErrorCode(aFail->GetMessageString()); + return NULL; + } + + //Make a Python command + GEOM::TPythonDump pd (aFunction); + pd << aFillet2D << " = geompy.MakeFillet2D(" << theShape + << ", " << theR << ", ["; + + it = theVertexes.begin(); + pd << (*it++); + while (it != theVertexes.end()) { + pd << ", " << (*it++); + } + pd << "])"; + + SetErrorCode(OK); + return aFillet2D; +} + //============================================================================= /*! * MakeChamferAll diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx index 4f65acc43..cffebf519 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.hxx @@ -45,6 +45,8 @@ class GEOMImpl_ILocalOperations : public GEOM_IOperations { Standard_EXPORT Handle(GEOM_Object) MakeFilletFacesR1R2 (Handle(GEOM_Object) theShape, double theR1, double theR2, std::list theFaces); + Standard_EXPORT Handle(GEOM_Object) MakeFillet2D (Handle(GEOM_Object) theShape, double theR, + std::list theVertexes); Standard_EXPORT Handle(GEOM_Object) MakeChamferAll (Handle(GEOM_Object) theShape, double theD); Standard_EXPORT Handle(GEOM_Object) MakeChamferEdge (Handle(GEOM_Object) theShape, diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index ec7b469d0..c12650765 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -45,8 +45,9 @@ #define GEOM_ELLIPSE 18 #define GEOM_CIRC_ARC 19 -#define GEOM_FILLET 20 -#define GEOM_CHAMFER 21 +#define GEOM_FILLET 20 +#define GEOM_FILLET_2D 45 +#define GEOM_CHAMFER 21 #define GEOM_EDGE 22 #define GEOM_WIRE 23 @@ -227,6 +228,8 @@ #define FILLET_SHAPE_EDGES_2R 4 #define FILLET_SHAPE_FACES_2R 5 +#define FILLET_2D_SHAPE_VERTEXES 1 + #define CHAMFER_SHAPE_ALL 1 #define CHAMFER_SHAPE_EDGE 2 #define CHAMFER_SHAPE_FACES 3 diff --git a/src/GEOMImpl/Makefile.am b/src/GEOMImpl/Makefile.am index c68c850a2..236d4e3f6 100644 --- a/src/GEOMImpl/Makefile.am +++ b/src/GEOMImpl/Makefile.am @@ -55,6 +55,7 @@ salomeinclude_HEADERS = \ GEOMImpl_ISpline.hxx \ GEOMImpl_IEllipse.hxx \ GEOMImpl_IFillet.hxx \ + GEOMImpl_IFillet2d.hxx \ GEOMImpl_IChamfer.hxx \ GEOMImpl_ICopy.hxx \ GEOMImpl_IArchimede.hxx \ @@ -126,6 +127,7 @@ salomeinclude_HEADERS = \ GEOMImpl_SketcherDriver.hxx \ GEOMImpl_3DSketcherDriver.hxx \ GEOMImpl_FilletDriver.hxx \ + GEOMImpl_Fillet2dDriver.hxx \ GEOMImpl_ChamferDriver.hxx \ GEOMImpl_BooleanDriver.hxx \ GEOMImpl_PartitionDriver.hxx \ @@ -188,6 +190,7 @@ dist_libGEOMimpl_la_SOURCES = \ GEOMImpl_SketcherDriver.cxx \ GEOMImpl_3DSketcherDriver.cxx \ GEOMImpl_FilletDriver.cxx \ + GEOMImpl_Fillet2dDriver.cxx \ GEOMImpl_ChamferDriver.cxx \ GEOMImpl_BooleanDriver.cxx \ GEOMImpl_PartitionDriver.cxx \ diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.cc b/src/GEOM_I/GEOM_ILocalOperations_i.cc index a9ec1fc6d..08423c6aa 100644 --- a/src/GEOM_I/GEOM_ILocalOperations_i.cc +++ b/src/GEOM_I/GEOM_ILocalOperations_i.cc @@ -219,6 +219,41 @@ GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFilletFacesR1R2 return GetObject(anObject); } +//============================================================================= +/*! + * MakeFillet2D + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_ILocalOperations_i::MakeFillet2D + (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theVertexes) +{ + GEOM::GEOM_Object_var aGEOMObject; + + if (theShape == NULL) return aGEOMObject._retn(); + + //Get the reference shape + Handle(GEOM_Object) aShapeRef = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + if (aShapeRef.IsNull()) return aGEOMObject._retn(); + + //Get the reference vertex + int ind = 0; + int aLen = theVertexes.length(); + list aVertexes; + for (; ind < aLen; ind++) { + aVertexes.push_back(theVertexes[ind]); + } + + //Create the Fillet + Handle(GEOM_Object) anObject = + GetOperations()->MakeFillet2D(aShapeRef, theR, aVertexes); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(anObject); +} + //============================================================================= /*! * MakeChamferAll diff --git a/src/GEOM_I/GEOM_ILocalOperations_i.hh b/src/GEOM_I/GEOM_ILocalOperations_i.hh index 79a80acfc..d7a508f65 100644 --- a/src/GEOM_I/GEOM_ILocalOperations_i.hh +++ b/src/GEOM_I/GEOM_ILocalOperations_i.hh @@ -58,6 +58,9 @@ class GEOM_I_EXPORT GEOM_ILocalOperations_i : CORBA::Double theR1, CORBA::Double theR2, const GEOM::ListOfLong& theFaces); + + GEOM::GEOM_Object_ptr MakeFillet2D (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + const GEOM::ListOfLong& theVertexes); GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index 2ee744c7f..283910acf 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -2766,6 +2766,26 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFilletFacesR1R2 (GEOM::GEOM_Object_ptr return NULL; } +//============================================================================= +// MakeFillet2D: +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeFillet2D (GEOM::GEOM_Object_ptr theShape, + CORBA::Double theR, + GEOM::GEOM_List_ptr theVertexes) +{ + beginService( " GEOM_Superv_i::MakeFillet2D" ); + MESSAGE("GEOM_Superv_i::MakeFillet2D"); + if (GEOM_List_i* aListImplV = + dynamic_cast*>(GetServant(theVertexes, myPOA).in())) { + getLocalOp(); + GEOM::GEOM_Object_ptr anObj = myLocalOp->MakeFillet2D(theShape, theR, aListImplV->GetList()); + endService( " GEOM_Superv_i::MakeFillet2D" ); + return anObj; + } + endService( " GEOM_Superv_i::MakeFillet2D" ); + return NULL; +} + //============================================================================= // MakeChamferAll: //============================================================================= diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index d667c1222..ca3781a07 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -584,6 +584,8 @@ public: GEOM::GEOM_List_ptr theFaces); GEOM::GEOM_Object_ptr MakeFilletFacesR1R2 (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR1, CORBA::Double theR2, GEOM::GEOM_List_ptr theFaces); + GEOM::GEOM_Object_ptr MakeFillet2D (GEOM::GEOM_Object_ptr theShape, CORBA::Double theR, + GEOM::GEOM_List_ptr theVertexes); GEOM::GEOM_Object_ptr MakeChamferAll (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD); GEOM::GEOM_Object_ptr MakeChamferEdge (GEOM::GEOM_Object_ptr theShape, CORBA::Double theD1, CORBA::Double theD2, diff --git a/src/GEOM_SWIG/GEOM_TestAll.py b/src/GEOM_SWIG/GEOM_TestAll.py index f8d842be9..b852c52f5 100644 --- a/src/GEOM_SWIG/GEOM_TestAll.py +++ b/src/GEOM_SWIG/GEOM_TestAll.py @@ -235,6 +235,7 @@ def TestAll (geompy, math): IDlist_f = [f_ind_1, f_ind_2] #Local operations + Fillet2d = geompy.MakeFillet2D(Face3, radius, [4, 7, 9]) #(GEOM_Object_ptr, Double, ListOfLong)->GEOM_Object_ptr Fillet = geompy.MakeFillet (Prism, radius, ShapeTypeEdge, IDlist_e) #(GEOM_Object_ptr, Double, Short, ListOfLong)->GEOM_Object_ptr Fillet2 = geompy.MakeFilletR1R2 (Prism, 7., 13., ShapeTypeEdge, @@ -381,6 +382,7 @@ def TestAll (geompy, math): id_Fillet = geompy.addToStudy(Fillet, "Fillet") id_Fillet2 = geompy.addToStudy(Fillet2, "Fillet2") + id_Fillet2d = geompy.addToStudy(Fillet2d, "Fillet2D") id_Chamfer = geompy.addToStudy(Chamfer, "Chamfer on Edge") id_Chamfer2 = geompy.addToStudy(Chamfer2, "Chamfer on Faces") diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index 072fd41f7..341506dd1 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -2408,6 +2408,20 @@ class geompyDC(GEOM._objref_GEOM_Gen): anObj = self.LocalOp.MakeFilletFacesR1R2(theShape, theR1, theR2, theListShapes) RaiseIfFailed("MakeFilletFacesR1R2", self.LocalOp) return anObj + + ## Perform a fillet on the specified edges/faces of the given shape + # @param theShape - Face Shape to perform fillet on. + # @param theR - Fillet radius. + # @param theListOfVertexes Global indices of vertexes to perform fillet on. + # \note Global index of sub-shape can be obtained, using method geompy.GetSubShapeID(). + # @return New GEOM_Object, containing the result shape. + # + # @ref tui_fillet2d "Example" + def MakeFillet2D(self,theShape, theR, theListOfVertexes): + # Example: see GEOM_TestAll.py + anObj = self.LocalOp.MakeFillet2D(theShape, theR, theListOfVertexes) + RaiseIfFailed("MakeFillet2D", self.LocalOp) + return anObj ## Perform a symmetric chamfer on all edges of the given shape. # @param theShape Shape, to perform chamfer on. diff --git a/src/OperationGUI/Makefile.am b/src/OperationGUI/Makefile.am index d92ee6493..79f12e7a0 100644 --- a/src/OperationGUI/Makefile.am +++ b/src/OperationGUI/Makefile.am @@ -32,6 +32,7 @@ salomeinclude_HEADERS = \ OperationGUI_ArchimedeDlg.h \ OperationGUI_PartitionDlg.h \ OperationGUI_FilletDlg.h \ + OperationGUI_Fillet2dDlg.h \ OperationGUI_ChamferDlg.h \ OperationGUI_GetShapesOnShapeDlg.h \ OperationGUI_ClippingDlg.h @@ -45,6 +46,7 @@ dist_libOperationGUI_la_SOURCES = \ OperationGUI_PartitionDlg.cxx \ OperationGUI_GetShapesOnShapeDlg.cxx \ OperationGUI_FilletDlg.cxx \ + OperationGUI_Fillet2dDlg.cxx \ OperationGUI_ChamferDlg.cxx \ OperationGUI_ClippingDlg.cxx @@ -53,6 +55,7 @@ MOC_FILES = \ OperationGUI_PartitionDlg_moc.cxx \ OperationGUI_GetShapesOnShapeDlg_moc.cxx\ OperationGUI_FilletDlg_moc.cxx \ + OperationGUI_Fillet2dDlg_moc.cxx \ OperationGUI_ChamferDlg_moc.cxx \ OperationGUI_ClippingDlg_moc.cxx diff --git a/src/OperationGUI/OperationGUI.cxx b/src/OperationGUI/OperationGUI.cxx index a220f99b2..a1099a7b2 100644 --- a/src/OperationGUI/OperationGUI.cxx +++ b/src/OperationGUI/OperationGUI.cxx @@ -38,6 +38,7 @@ #include "OperationGUI_PartitionDlg.h" // Method PARTITION #include "OperationGUI_ArchimedeDlg.h" // Method ARCHIMEDE #include "OperationGUI_FilletDlg.h" // Method FILLET +#include "OperationGUI_Fillet2dDlg.h" // Method FILLET 2D #include "OperationGUI_ChamferDlg.h" // Method CHAMFER #include "OperationGUI_ClippingDlg.h" // Clipping dialog box #include "OperationGUI_GetShapesOnShapeDlg.h" @@ -78,6 +79,7 @@ bool OperationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case 506: ( new OperationGUI_ChamferDlg ( getGeometryGUI(), parent ) )->show(); break; case 507: ( new OperationGUI_ClippingDlg ( getGeometryGUI(), parent ) )->show(); break; case 508: ( new OperationGUI_GetShapesOnShapeDlg( getGeometryGUI(), parent ) )->show(); break; + case 509: ( new OperationGUI_Fillet2dDlg ( getGeometryGUI(), parent ) )->show(); break; default: app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) ); } diff --git a/src/OperationGUI/OperationGUI_Fillet2dDlg.cxx b/src/OperationGUI/OperationGUI_Fillet2dDlg.cxx new file mode 100755 index 000000000..055b513dd --- /dev/null +++ b/src/OperationGUI/OperationGUI_Fillet2dDlg.cxx @@ -0,0 +1,400 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : OperationGUI_Fillet2dDlg.cxx +// Author : DMV, OCN. +// + +#include "OperationGUI_Fillet2dDlg.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// OCCT Includes +#include +#include + +#include + +//================================================================================= +// class : OperationGUI_Fillet2dDlg() +// purpose : Constructs a OperationGUI_Fillet2dDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +OperationGUI_Fillet2dDlg::OperationGUI_Fillet2dDlg (GeometryGUI* theGeometryGUI, QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent, false) +{ + SUIT_ResourceMgr* aResMgr = myGeomGUI->getApp()->resourceMgr(); + QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_FILLET_2D"))); + QPixmap iconSelect (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("GEOM_FILLET_2D_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("GEOM_FILLET_2D")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->close(); + + GroupVertexes = new DlgRef_2Sel1Spin(centralWidget()); + GroupVertexes->GroupBox1->setTitle(tr("GEOM_FILLET_2D")); + GroupVertexes->TextLabel1->setText(tr("GEOM_MAIN_OBJECT")); + GroupVertexes->TextLabel2->setText(tr("GEOM_VERTEXES")); + GroupVertexes->TextLabel3->setText(tr("GEOM_RADIUS")); + GroupVertexes->PushButton1->setIcon(iconSelect); + GroupVertexes->PushButton2->setIcon(iconSelect); + GroupVertexes->LineEdit1->setReadOnly(true); + GroupVertexes->LineEdit2->setReadOnly(true); + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(GroupVertexes); + + /***************************************************************/ + + // Set range of spinboxes + double SpecificStep = 10.0; + initSpinBox(GroupVertexes->SpinBox_DX, 0.00001, COORD_MAX, SpecificStep, 5); // VSR: TODO: DBL_DIGITS_DISPLAY + + setHelpFileName("fillet2d_operation_page.html"); + + // Initialisation + Init(); + resize(0,0); +} + +//================================================================================= +// function : ~OperationGUI_Fillet2dDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +OperationGUI_Fillet2dDlg::~OperationGUI_Fillet2dDlg() +{ +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::Init() +{ + // Set Initial values of spinboxes + GroupVertexes->SpinBox_DX->setValue(5); + + // Clear line edits + GroupVertexes->LineEdit1->setText(""); + GroupVertexes->LineEdit2->setText(""); + + myShape = GEOM::GEOM_Object::_nil(); + + myVertexes.Clear(); + + // signals and slots connections + + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk() )); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + // connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int))); + + connect(GroupVertexes->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(GroupVertexes->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(GroupVertexes->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(GroupVertexes->LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + + connect(GroupVertexes->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); + + initName(tr("GEOM_FILLET_2D")); + GroupVertexes->PushButton1->click(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool OperationGUI_Fillet2dDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + initName(); + // Reset dialog state + GroupVertexes->LineEdit1->setText(""); + GroupVertexes->LineEdit2->setText(""); + myShape = GEOM::GEOM_Object::_nil(); + myVertexes.Clear(); + GroupVertexes->PushButton1->click(); + + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection is changed or on dialog initialization or activation +//================================================================================= +void OperationGUI_Fillet2dDlg::SelectionIntoArgument() +{ + erasePreview(); + myEditCurrentArgument->setText(""); + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + // If selection of main object is activated + if (myEditCurrentArgument == GroupVertexes->LineEdit1) { + myShape = GEOM::GEOM_Object::_nil(); + if (aSelList.Extent() == 1) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); + + if (aResult && !anObj->_is_nil()) { + QString aName = GEOMBase::GetName( anObj ); + TopoDS_Shape aShape; + if ( GEOMBase::GetShape( anObj, aShape, TopAbs_SHAPE ) && !aShape.IsNull() ) { + TColStd_IndexedMapOfInteger aMap; + aSelMgr->GetIndexes(aSelList.First(), aMap); + if ( aMap.Extent() == 1 ) { // Local Selection + int anIndex = aMap( 1 ); + aName += QString( ":face_%1" ).arg( anIndex ); + + //Find SubShape Object in Father + GEOM::GEOM_Object_var aFindedObject = GEOMBase_Helper::findObjectInFather( anObj, aName ); + + if ( aFindedObject == GEOM::GEOM_Object::_nil() ) { // Object not found in study + GEOM::GEOM_IShapesOperations_var aShapesOp = getGeomEngine()->GetIShapesOperations( getStudyId() ); + anObj = aShapesOp->GetSubShape( anObj, anIndex ); + } + else + anObj = aFindedObject; // get Object from study + } + else { // Global Selection + if ( aShape.ShapeType() != TopAbs_FACE ) { + anObj = GEOM::GEOM_Object::_nil(); + aName = ""; + } + } + } + myShape = anObj; + myEditCurrentArgument->setText(aName +); + displayPreview(); + } + } + } else if (myEditCurrentArgument == GroupVertexes->LineEdit2) { + myVertexes.Clear(); + if (aSelList.Extent() == 1) { + Standard_Boolean aResult = Standard_False; + GEOM::GEOM_Object_var anObj = + GEOMBase::ConvertIOinGEOMObject(aSelList.First(), aResult); + + if (aResult && !anObj->_is_nil()) { + TColStd_IndexedMapOfInteger anIndexes; + aSelMgr->GetIndexes(aSelList.First(), anIndexes); + + if (anIndexes.Extent() > 0) { + QString aName; + if (anIndexes.Extent() == 1) { + int anIndex = anIndexes(1); + aName = QString(GEOMBase::GetName(anObj)) + QString(":vertex_%1").arg(anIndex); + } + else + aName = tr("GEOM_MEN_POPUP_NAME").arg(anIndexes.Extent()); + + myEditCurrentArgument->setText(aName); + myVertexes = anIndexes; + displayPreview(); + } + } + } + } + + if (myEditCurrentArgument == GroupVertexes->LineEdit1) { + if (!myShape->_is_nil() && myVertexes.Extent() == 0) + GroupVertexes->PushButton2->click(); + } +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + if (send == GroupVertexes->PushButton1) { + myEditCurrentArgument = GroupVertexes->LineEdit1; + GroupVertexes->PushButton2->setDown(false); + GroupVertexes->LineEdit2->setEnabled(false); + } + else if (send == GroupVertexes->PushButton2) { + myEditCurrentArgument = GroupVertexes->LineEdit2; + GroupVertexes->PushButton1->setDown(false); + GroupVertexes->LineEdit1->setEnabled(false); + } + + // enable line edit + myEditCurrentArgument->setEnabled(true); + myEditCurrentArgument->setFocus(); + // after setFocus(), because it will be setDown(false) when loses focus + send->setDown(true); + + activateSelection(); + + // seems we need it only to avoid preview disappearing, caused by selection mode change + displayPreview(); +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + + if (send == GroupVertexes->LineEdit1) + myEditCurrentArgument = GroupVertexes->LineEdit1; + else if (send == GroupVertexes->LineEdit2) + myEditCurrentArgument = GroupVertexes->LineEdit2; + else + return; + + GEOMBase_Skeleton::LineEditReturnPressed(); +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::enterEvent (QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + this->ActivateThisDialog(); +} + +//================================================================================= +// function : ValueChangedInSpinBox() +// purpose : +//================================================================================= +void OperationGUI_Fillet2dDlg::ValueChangedInSpinBox (double) +{ + displayPreview(); +} + +//================================================================================= +// function : activateSelection +// purpose : Activate selection in accordance with myEditCurrentArgument +//================================================================================= +void OperationGUI_Fillet2dDlg::activateSelection() +{ + disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0); + globalSelection(); + if (myEditCurrentArgument == GroupVertexes->LineEdit1) + globalSelection( GEOM_FACE ); // localSelection(myShape, TopAbs_FACE); + else if (!myShape->_is_nil() && myEditCurrentArgument == GroupVertexes->LineEdit2) + localSelection(myShape, TopAbs_VERTEX); + + connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()), + this, SLOT(SelectionIntoArgument())); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr OperationGUI_Fillet2dDlg::createOperation() +{ + return getGeomEngine()->GetILocalOperations(getStudyId()); +} + +//================================================================================= +// function : isValid() +// purpose : Verify validity of input data +//================================================================================= +bool OperationGUI_Fillet2dDlg::isValid (QString&) +{ + return !myShape->_is_nil() && myVertexes.Extent() > 0; +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool OperationGUI_Fillet2dDlg::execute (ObjectList& objects) +{ + GEOM::GEOM_Object_var anObj; + + GEOM::ListOfLong_var aListOfIndexes = new GEOM::ListOfLong; + aListOfIndexes->length(myVertexes.Extent()); + + for (int i = 1, n = myVertexes.Extent(); i <= n; i++) + aListOfIndexes[ i - 1 ] = myVertexes(i); + + anObj = GEOM::GEOM_ILocalOperations::_narrow(getOperation())-> + MakeFillet2D(myShape, getRadius(), aListOfIndexes); + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + + return true; +} + +//================================================================================= +// function : getRadius +// purpose : Get radius +//================================================================================= +double OperationGUI_Fillet2dDlg::getRadius() const +{ + return GroupVertexes ->SpinBox_DX->value(); +} diff --git a/src/OperationGUI/OperationGUI_Fillet2dDlg.h b/src/OperationGUI/OperationGUI_Fillet2dDlg.h new file mode 100755 index 000000000..523dbad04 --- /dev/null +++ b/src/OperationGUI/OperationGUI_Fillet2dDlg.h @@ -0,0 +1,75 @@ +// GEOM GEOMGUI : GUI for Geometry component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : OperationGUI_Fillet2dDlg.h +// Author : DMV, OCN +// + +#ifndef OPERATIONGUI_FILLET2DDLG_H +#define OPERATIONGUI_FILLET2DDLG_H + +#include + +#include + +class DlgRef_2Sel1Spin; + +//================================================================================= +// class : OperationGUI_Fillet2dDlg +// purpose : +//================================================================================= +class OperationGUI_Fillet2dDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + OperationGUI_Fillet2dDlg( GeometryGUI*, QWidget* ); + ~OperationGUI_Fillet2dDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid( QString& ); + virtual bool execute( ObjectList& ); + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + void ValueChangedInSpinBox( double ); + +private: + void Init(); + void enterEvent( QEvent* ); + void activateSelection(); + double getRadius() const; + +private: + GEOM::GEOM_Object_var myShape; + TColStd_IndexedMapOfInteger myVertexes; + + DlgRef_2Sel1Spin* GroupVertexes; +}; + +#endif // OPERATIONGUI_FILLET2DDLG_H