From: skl Date: Thu, 13 Jul 2006 10:12:22 +0000 (+0000) Subject: Implementation of change orientation in Repair in GEOM. X-Git-Tag: T3_2_1_pre~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=50d053afee3946b223684b1bab736f6beaa0f0db;p=modules%2Fgeom.git Implementation of change orientation in Repair in GEOM. --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index dec1d38cb..6f3652d8c 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -1894,6 +1894,15 @@ module GEOM boolean GetFreeBoundary (in GEOM_Object theObject, out ListOfGO theClosedWires, out ListOfGO theOpenWires); + + /*! + * Change orientation of the given object. + * \param theObject Shape to be processed. + * \return New GEOM_Object, containing processed shape. + */ + GEOM_Object ChangeOrientation (in GEOM_Object theObject); + GEOM_Object ChangeOrientationCopy (in GEOM_Object theObject); + }; /*! diff --git a/src/GEOMContext/GEOM_icons.po b/src/GEOMContext/GEOM_icons.po index 0bd0c46ee..996122d66 100644 --- a/src/GEOMContext/GEOM_icons.po +++ b/src/GEOMContext/GEOM_icons.po @@ -337,6 +337,10 @@ msgstr "supresshole.png" msgid "ICON_DLG_SUPRESS_HOLE_FACE_SHELL" msgstr "supressHolesOnFaceShell.png" +#ChangeOrientationDlg +msgid "ICON_DLG_CHANGE_ORIENTATION" +msgstr "change_orientation.png" + #MultiTranslationDlg msgid "ICON_DLG_MULTITRANSLATION_SIMPLE" msgstr "multitranslationsimple.png" diff --git a/src/GEOMGUI/GEOM_images.po b/src/GEOMGUI/GEOM_images.po index bd3321fd2..e8132904a 100644 --- a/src/GEOMGUI/GEOM_images.po +++ b/src/GEOMGUI/GEOM_images.po @@ -307,6 +307,10 @@ msgstr "pointonedge.png" msgid "ICON_DLG_SEWING" msgstr "sewing.png" +#ChangeOrientationDlg +msgid "ICON_DLG_CHANGE_ORIENTATION" +msgstr "change_orientation.png" + #PipeDlg msgid "ICON_DLG_PIPE" msgstr "pipe.png" @@ -701,6 +705,9 @@ msgstr "free_bound.png" msgid "ICO_CHECK_FREE_FACES" msgstr "free_faces.png" +msgid "ICO_CHANGE_ORIENTATION" +msgstr "change_orientation.png" + msgid "ICO_POINT_COORDS" msgstr "point_coord.png" diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index 80750baff..8bbe3cae2 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -1642,6 +1642,12 @@ msgstr "Free boundaries" msgid "GEOM_FREE_FACES" msgstr "Free faces" +msgid "GEOM_CHANGE_ORIENTATION_TITLE" +msgstr "Change orientation" + +msgid "GEOM_CHANGE_ORIENTATION" +msgstr "Objects to change orientation" + msgid "GEOM_BY_PARAMETER" msgstr "By parameter" @@ -1988,6 +1994,9 @@ msgstr "ProcessShape" msgid "SUPRESS_FACE_NEW_OBJ_NAME" msgstr "SupressFaces" +msgid "CHANGE_ORIENTATION_NEW_OBJ_NAME" +msgstr "Invert" + msgid "NON_GEOM_OBJECTS_SELECTED" msgstr "There are objects selected which do not belong to %1 component." @@ -2613,6 +2622,15 @@ msgstr "Check free faces" msgid "STB_CHECK_FREE_FACES" msgstr "Check free faces" +msgid "TOP_CHANGE_ORIENTATION" +msgstr "Change orientation" + +msgid "MEN_CHANGE_ORIENTATION" +msgstr "Change orientation" + +msgid "STB_CHANGE_ORIENTATION" +msgstr "Change orientation" + msgid "MEN_MEASURES" msgstr "Measures" diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index bced30d60..8db643a17 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -503,6 +503,7 @@ void GeometryGUI::OnGUIEvent( int id ) id == 608 || // MENU REPAIR - ADD POINT ON EDGE id == 609 || // MENU REPAIR - FREE BOUNDARIES id == 610 || // MENU REPAIR - FREE FACES + id == 611 || // MENU REPAIR - CHANGE ORIENTATION id == 602 ) { // MENU REPAIR - GLUE FACES #ifndef WNT library = getLibrary( "libRepairGUI.so" ); @@ -829,6 +830,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 608, "POINT_ON_EDGE" ); createGeomAction( 609, "CHECK_FREE_BNDS" ); createGeomAction( 610, "CHECK_FREE_FACES" ); + createGeomAction( 611, "CHANGE_ORIENTATION" ); createGeomAction( 708, "POINT_COORDS" ); createGeomAction( 701, "BASIC_PROPS" ); @@ -971,6 +973,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( 608, repairId, -1 ); createMenu( 609, repairId, -1 ); createMenu( 610, repairId, -1 ); + createMenu( 611, repairId, -1 ); int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 ); createMenu( 708, measurId, -1 ); diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.cc b/src/GEOM_I/GEOM_IHealingOperations_i.cc index a3dc9b4aa..cdd3f1efe 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.cc +++ b/src/GEOM_I/GEOM_IHealingOperations_i.cc @@ -454,3 +454,71 @@ CORBA::Boolean GEOM_IHealingOperations_i::GetFreeBoundary ( GEOM::GEOM_Object_pt return true; } + + +//============================================================================= +/*! + * ChangeOrientation + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ChangeOrientation (GEOM::GEOM_Object_ptr theObject) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) ) + return aGEOMObject._retn(); + + aGEOMObject = GEOM::GEOM_Object::_duplicate(theObject); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform +// Handle(GEOM_Object) aNewObject = + GetOperations()->ChangeOrientation( anObject ); +// if (!GetOperations()->IsDone() || aNewObject.IsNull()) +// return aGEOMObject._retn(); + + //return GetObject(aNewObject); + return aGEOMObject._retn(); +} + + +//============================================================================= +/*! + * ChangeOrientationCopy + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ChangeOrientationCopy (GEOM::GEOM_Object_ptr theObject) +{ + GEOM::GEOM_Object_var aGEOMObject; + + // Set a not done flag + GetOperations()->SetNotDone(); + + // Check parameters + if ( CORBA::is_nil(theObject) ) + return aGEOMObject._retn(); + + // Get the object itself + Handle(GEOM_Object) anObject = + GetOperations()->GetEngine()->GetObject(theObject->GetStudyID(), theObject->GetEntry()); + if (anObject.IsNull()) + return aGEOMObject._retn(); + + // Perform + Handle(GEOM_Object) aNewObject = + GetOperations()->ChangeOrientationCopy( anObject ); + if (!GetOperations()->IsDone() || aNewObject.IsNull()) + return aGEOMObject._retn(); + + return GetObject(aNewObject); +} + diff --git a/src/GEOM_I/GEOM_IHealingOperations_i.hh b/src/GEOM_I/GEOM_IHealingOperations_i.hh index 5314af087..ca859dc50 100644 --- a/src/GEOM_I/GEOM_IHealingOperations_i.hh +++ b/src/GEOM_I/GEOM_IHealingOperations_i.hh @@ -61,6 +61,9 @@ class GEOM_IHealingOperations_i : CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject, GEOM::ListOfGO_out theClosedWires, GEOM::ListOfGO_out theOpenWires ); + GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theObject); + GEOM::GEOM_Object_ptr ChangeOrientationCopy (GEOM::GEOM_Object_ptr theObject); + ::GEOMImpl_IHealingOperations* GetOperations() { return (::GEOMImpl_IHealingOperations*)GetImpl(); } private: diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index 0a231ab73..d22a825a4 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -1199,6 +1199,23 @@ def DivideEdge(theObject, theEdgeIndex, theValue, isByParameter): print "DivideEdge : ", HealOp.GetErrorCode() return anObj +## Change orientation of the given object. +# @param theObject Shape to be processed. +# @update given shape +def ChangeOrientation(theObject): + theObject = HealOp.ChangeOrientation(theObject) + if HealOp.IsDone() == 0: + print "ChangeOrientation : ", HealOp.GetErrorCode() + +## Change orientation of the given object. +# @param theObject Shape to be processed. +# @return New GEOM_Object, containing processed shape. +def ChangeOrientationCopy(theObject): + anObj = HealOp.ChangeOrientation(theObject) + if HealOp.IsDone() == 0: + print "ChangeOrientation : ", HealOp.GetErrorCode() + return anObj + ## Get a list of wires (wrapped in GEOM_Object-s), # that constitute a free boundary of the given shape. # @param theObject Shape to get free boundary of. diff --git a/src/ShHealOper/Makefile.in b/src/ShHealOper/Makefile.in index f164e12eb..2497fc526 100644 --- a/src/ShHealOper/Makefile.in +++ b/src/ShHealOper/Makefile.in @@ -47,6 +47,7 @@ LIB_SRC = \ ShHealOper_ShapeProcess.cxx \ ShHealOper_SplitCurve2d.cxx \ ShHealOper_SplitCurve3d.cxx \ + ShHealOper_ChangeOrientation.cxx \ ShHealOper_Tool.cxx \ LIB_CLIENT_IDL = @@ -64,6 +65,7 @@ EXPORT_HEADERS = \ ShHealOper_SpiltCurve2d.hxx \ ShHealOper_SplitCurve2d.hxx \ ShHealOper_SplitCurve3d.hxx \ + ShHealOper_ChangeOrientation.hxx \ ShHealOper_Tool.hxx # idl files diff --git a/src/ShHealOper/ShHealOper_ChangeOrientation.cxx b/src/ShHealOper/ShHealOper_ChangeOrientation.cxx new file mode 100644 index 000000000..0bd3c9780 --- /dev/null +++ b/src/ShHealOper/ShHealOper_ChangeOrientation.cxx @@ -0,0 +1,82 @@ +// 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: ShHealOper_ChangeOrientation.cxx +// Created: 11.07.06 11:46:45 +// Author: Sergey KUUL + + +#include + +#include +#include + +//======================================================================= +//function : ShHealOper_ChangeOrientation() +//purpose : Constructor +//======================================================================= + +ShHealOper_ChangeOrientation::ShHealOper_ChangeOrientation ( const TopoDS_Shape& theShape ) +{ + Init(theShape); +} + +//======================================================================= +//function : Init +//purpose : +//======================================================================= + +void ShHealOper_ChangeOrientation::Init(const TopoDS_Shape& theShape) +{ + ShHealOper_Tool::Init(theShape); +} + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +Standard_Boolean ShHealOper_ChangeOrientation::Perform() +{ + if (myInitShape.ShapeType() == TopAbs_SHELL) { + BRep_Builder B; + myResultShape = myInitShape.EmptyCopied(); + TopoDS_Iterator itr(myInitShape); + while (itr.More()) { + B.Add(myResultShape,itr.Value().Reversed()); + itr.Next(); + } + } + else if (myInitShape.ShapeType() == TopAbs_FACE) { + myResultShape = myInitShape.Reversed(); + } + else if (myInitShape.ShapeType() == TopAbs_WIRE) { + myResultShape = myInitShape.Reversed(); + } + else if (myInitShape.ShapeType() == TopAbs_EDGE) { + myResultShape = myInitShape.Reversed(); + } + else { + return false; + } + + return true; + +} diff --git a/src/ShHealOper/ShHealOper_ChangeOrientation.hxx b/src/ShHealOper/ShHealOper_ChangeOrientation.hxx new file mode 100644 index 000000000..fe6ee94e2 --- /dev/null +++ b/src/ShHealOper/ShHealOper_ChangeOrientation.hxx @@ -0,0 +1,66 @@ +// 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: ShHealOper_ChangeOrientation.hxx +// Created: 11.07.06 11:22:26 +// Author: Sergey KUUL + + +#ifndef ShHealOper_ChangeOrientation_HeaderFile +#define ShHealOper_ChangeOrientation_HeaderFile + +#include +#include +#include + +/// Class ShHealOper_ChangeOrientation +// Intended for change orientation of given shape +// if shape is Shell - create empty copy and put to it +// each face as Reversed() + +class ShHealOper_ChangeOrientation : public ShHealOper_Tool +{ + public: + // ---------- PUBLIC METHODS ---------- + + /// Empty constructor + Standard_EXPORT ShHealOper_ChangeOrientation () {} + + /// Copy constructor + Standard_EXPORT ShHealOper_ChangeOrientation (const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT virtual void Init(const TopoDS_Shape& theShape); + //Method for initalization by whole shape. + + Standard_EXPORT Standard_Boolean Perform(); + //Change orientation + + + public: +// Declaration of CASCADE RTTI +//DEFINE_STANDARD_RTTI (ShHealOper_RemoveInternalWires) +}; + +// Definition of HANDLE object using Standard_DefineHandle.hxx +//DEFINE_STANDARD_HANDLE (ShHealOper_RemoveInternalWires, ) + + +#endif