From: rnv Date: Tue, 18 Mar 2008 07:41:27 +0000 (+0000) Subject: Implementation of NPAL16149 (EDF 442 GEOM : Create a shell from a compound containing... X-Git-Tag: V4_1_2rc1~30 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=be31b630d57bc96dbadf94a13698e7f6dbb33e01;p=modules%2Fgeom.git Implementation of NPAL16149 (EDF 442 GEOM : Create a shell from a compound containing only faces). --- diff --git a/src/BuildGUI/BuildGUI_ShellDlg.cxx b/src/BuildGUI/BuildGUI_ShellDlg.cxx index 99c99f03f..4d5c0e367 100644 --- a/src/BuildGUI/BuildGUI_ShellDlg.cxx +++ b/src/BuildGUI/BuildGUI_ShellDlg.cxx @@ -101,8 +101,12 @@ void BuildGUI_ShellDlg::Init() TColStd_MapOfInteger aMap; aMap.Add(GEOM_SHELL); aMap.Add(GEOM_FACE); - globalSelection( aMap ); - + aMap.Add(GEOM_COMPOUNDFILTER); + + QValueList aSubShapes; + aSubShapes.append(GEOM_FACE); + globalSelection( aMap, aSubShapes ); + /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); @@ -179,7 +183,12 @@ void BuildGUI_ShellDlg::SetEditCurrentArgument() TColStd_MapOfInteger aMap; aMap.Add(GEOM_SHELL); aMap.Add(GEOM_FACE); - globalSelection( aMap ); + aMap.Add(GEOM_COMPOUNDFILTER); + + QValueList aSubShapes; + aSubShapes.append(GEOM_FACE); + globalSelection( aMap, aSubShapes ); + myEditCurrentArgument = GroupShell->LineEdit1; myEditCurrentArgument->setFocus(); @@ -196,10 +205,16 @@ void BuildGUI_ShellDlg::ActivateThisDialog() GEOMBase_Skeleton::ActivateThisDialog(); connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())) ; + TColStd_MapOfInteger aMap; aMap.Add(GEOM_SHELL); aMap.Add(GEOM_FACE); - globalSelection( aMap ); + aMap.Add(GEOM_COMPOUNDFILTER); + + QValueList aSubShapes; + aSubShapes.append(GEOM_FACE); + globalSelection( aMap, aSubShapes ); + } diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index d62fc63cd..32f321691 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -498,6 +498,18 @@ void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes, getDisplayer()->GlobalSelection( theModes, update ); } +//================================================================ +// Function : globalSelection +// Purpose : Activate selection of subshapes. Set selection filters +// in accordance with mode. theMode is from GEOMImpl_Types +//================================================================ +void GEOMBase_Helper::globalSelection( const TColStd_MapOfInteger& theModes, + const QValueList& subShapes, + const bool update ) +{ + getDisplayer()->GlobalSelection( theModes, update, &subShapes); +} + //================================================================ // Function : addInStudy // Purpose : Add object in study diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 911d6e443..62d1f2bb0 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -100,6 +100,7 @@ protected: void activate( const int ); void globalSelection( const int = GEOM_ALLOBJECTS, const bool = false ); void globalSelection( const TColStd_MapOfInteger&, const bool = false ); + void globalSelection( const TColStd_MapOfInteger&, const QValueList& ,const bool = false ); void updateViewer (); void prepareSelection( const ObjectList&, const int ); diff --git a/src/GEOMFiltersSelection/GEOM_CompoundFilter.cxx b/src/GEOMFiltersSelection/GEOM_CompoundFilter.cxx new file mode 100644 index 000000000..485988561 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_CompoundFilter.cxx @@ -0,0 +1,136 @@ +// GEOM GEOM_CompoundFilter : filter selector for the viewer +// +// 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 : GEOM_CompoundFilter.cxx +// Author : Roman NIKOLAEV +// Module : GEOM + +#include "GEOM_CompoundFilter.h" + +// OCCT Includes +#include +#include +#include +#include + + + +//======================================================================= +// function : GEOM_CompoundFilter +// purpose : +//======================================================================= +GEOM_CompoundFilter::GEOM_CompoundFilter(SalomeApp_Study* study) +: GEOM_SelectionFilter( study ) +{ + add( TopAbs_COMPOUND ); +} + +//======================================================================= +// function : ~GEOM_CompoundFilter +// purpose : +//======================================================================= +GEOM_CompoundFilter::~GEOM_CompoundFilter() +{ +} + +//======================================================================= +// function : isOk +// purpose : +//======================================================================= +bool GEOM_CompoundFilter::isOk( const SUIT_DataOwner* sOwner) const +{ + if(GEOM_SelectionFilter::isOk(sOwner)){ + + GEOM::GEOM_Object_var obj = getObject( sOwner ); + TopoDS_Shape shape; + if ( getShape( obj, shape )){ + bool subTypes[TopAbs_SHAPE]; + getInfo(shape,subTypes); + QValueList::const_iterator it; + bool result = false; + for ( it = myKinds.constBegin(); it != myKinds.constEnd(); ++it ) + result = result || subTypes[(*it)]; + + return result; + } + } + return false; +} + + +//======================================================================= +// function : addSubType +// purpose : +//======================================================================= +void GEOM_CompoundFilter::addSubType( const int type) +{ + if(!myKinds.contains(type)) + myKinds.append(type); +} + +//======================================================================= +// function : addSubTypes +// purpose : +//======================================================================= +void GEOM_CompoundFilter::addSubTypes(const QValueList& kinds) +{ + myKinds = kinds; +} + +//======================================================================= +// function : getInfo() +// purpose : +//======================================================================= +void GEOM_CompoundFilter::getInfo(const TopoDS_Shape& aShape, bool subTypes[]) const +{ + int iType, nbTypes[TopAbs_SHAPE]; + for (iType = 0; iType < TopAbs_SHAPE; ++iType){ + nbTypes[iType] = 0; + subTypes[iType] = false; + } + + nbTypes[aShape.ShapeType()]++; + TopTools_MapOfShape aMapOfShape; + aMapOfShape.Add(aShape); + TopTools_ListOfShape aListOfShape; + aListOfShape.Append(aShape); + + TopTools_ListIteratorOfListOfShape itL (aListOfShape); + for (; itL.More(); itL.Next()) { + TopoDS_Iterator it (itL.Value()); + for (; it.More(); it.Next()) { + TopoDS_Shape s = it.Value(); + if (aMapOfShape.Add(s)) { + aListOfShape.Append(s); + nbTypes[s.ShapeType()]++; + } + } + } + + for(iType = TopAbs_COMPSOLID; iType < TopAbs_SHAPE; ++iType) { + if(nbTypes[iType] > 0) { + subTypes[iType] = true; + break; + } + } +} diff --git a/src/GEOMFiltersSelection/GEOM_CompoundFilter.h b/src/GEOMFiltersSelection/GEOM_CompoundFilter.h new file mode 100644 index 000000000..2e20c08e5 --- /dev/null +++ b/src/GEOMFiltersSelection/GEOM_CompoundFilter.h @@ -0,0 +1,44 @@ +// 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 +// +#ifndef GEOM_COMPOUNDFILTER_H +#define GEOM_COMPOUNDFILTER_H +#include "GEOM_SelectionFilter.h" + +class Standard_EXPORT GEOM_CompoundFilter : public GEOM_SelectionFilter +{ + public: + GEOM_CompoundFilter( SalomeApp_Study* study ); + ~GEOM_CompoundFilter(); + + virtual bool isOk( const SUIT_DataOwner* ) const; + void addSubType(const int ); + void addSubTypes(const QValueList& ); + + private: + void getInfo(const TopoDS_Shape&, bool subTypes []) const; + + + private: + QValueList myKinds; +}; + + +#endif + diff --git a/src/GEOMFiltersSelection/Makefile.am b/src/GEOMFiltersSelection/Makefile.am index 43f5b0d17..42c88bb30 100644 --- a/src/GEOMFiltersSelection/Makefile.am +++ b/src/GEOMFiltersSelection/Makefile.am @@ -40,7 +40,8 @@ salomeinclude_HEADERS = \ GEOM_TypeFilter.h \ GEOM_PreviewFilter.h \ GEOM_LogicalFilter.h \ - GEOM_OCCFilter.h + GEOM_OCCFilter.h \ + GEOM_CompoundFilter.h # Sources dist_libGEOMFiltersSelection_la_SOURCES = \ @@ -50,7 +51,8 @@ dist_libGEOMFiltersSelection_la_SOURCES = \ GEOM_TypeFilter.cxx \ GEOM_PreviewFilter.cxx \ GEOM_LogicalFilter.cxx \ - GEOM_OCCFilter.cxx + GEOM_OCCFilter.cxx \ + GEOM_CompoundFilter.cxx # LIB_CLIENT_IDL= GEOM_Gen.idl SALOMEDS.idl SALOME_Exception.idl SALOME_GenericObj.idl SALOME_Component.idl diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index fdceadb4d..79e6926fc 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -33,6 +33,7 @@ #include "GEOM_TypeFilter.h" #include "GEOM_EdgeFilter.h" #include "GEOM_FaceFilter.h" +#include "GEOM_CompoundFilter.h" #include "GEOM_PreviewFilter.h" #include "GEOM_LogicalFilter.h" #include "GEOM_OCCFilter.h" @@ -167,6 +168,30 @@ SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode ) return aFilter; } +//================================================================ +// Function : getComplexFilter +// Purpose : Get compound filter corresponding to the type of +// object from GEOMImpl_Types.h +//================================================================ +SUIT_SelectionFilter* GEOM_Displayer::getComplexFilter( const QValueList* aSubShapes) +{ + GEOM_CompoundFilter* aFilter; + + if(aSubShapes != NULL ) { + aFilter = new GEOM_CompoundFilter(getStudy()); + QValueList aTopAbsTypes; + QValueList::const_iterator it; + for(it = aSubShapes->constBegin(); it != aSubShapes->constEnd(); ++it ) { + int topAbsMode = getTopAbsMode(*it); + if(topAbsMode != -1 ) + aTopAbsTypes.append(topAbsMode); + } + aFilter->addSubTypes(aTopAbsTypes); + } + + return aFilter; +} + //================================================================ // Function : getEntry // Purpose : @@ -1032,7 +1057,7 @@ void GEOM_Displayer::GlobalSelection( const int theMode, const bool update ) */ //================================================================= void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, - const bool update ) + const bool update, const QValueList* theSubShapes) { SUIT_Session* session = SUIT_Session::session(); SalomeApp_Application* app = dynamic_cast( session->activeApplication() ); @@ -1076,7 +1101,11 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, if ( theModes.Extent() == 1 ) { int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key(); - aFilter = getFilter( aMode ); + + if(aMode == GEOM_COMPOUNDFILTER) + aFilter = getComplexFilter(theSubShapes); + else + aFilter = getFilter( aMode ); } else if ( theModes.Extent() > 1 ) { @@ -1085,7 +1114,13 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes, QPtrList aListOfFilters; for ( ; anIter.More(); anIter.Next() ) { - SUIT_SelectionFilter* aFilter = getFilter( anIter.Key() ); + SUIT_SelectionFilter* aFilter; + int aMode = anIter.Key(); + if(aMode == GEOM_COMPOUNDFILTER) + aFilter = getComplexFilter(theSubShapes); + else + aFilter = getFilter( aMode ); + if ( aFilter ) aListOfFilters.append( aFilter ); } diff --git a/src/GEOMGUI/GEOM_Displayer.h b/src/GEOMGUI/GEOM_Displayer.h index 8c877c94f..e5b736e7a 100644 --- a/src/GEOMGUI/GEOM_Displayer.h +++ b/src/GEOMGUI/GEOM_Displayer.h @@ -148,7 +148,7 @@ public: void LocalSelection( const Handle(SALOME_InteractiveObject)&, const int ); void LocalSelection( const SALOME_ListIO& theIOList, const int ); void GlobalSelection( const int = GEOM_ALLOBJECTS, const bool = false ); - void GlobalSelection( const TColStd_MapOfInteger&, const bool = false ); + void GlobalSelection( const TColStd_MapOfInteger&, const bool = false, const QValueList* = 0 ); SalomeApp_Study* getStudy() const; @@ -171,6 +171,7 @@ protected: void clearTemporary( LightApp_SelectionMgr* theSelMgr ); SUIT_SelectionFilter* getFilter( const int theMode ); + SUIT_SelectionFilter* getComplexFilter(const QValueList* ); protected: Handle(SALOME_InteractiveObject) myIO; diff --git a/src/GEOMImpl/GEOMImpl_Types.hxx b/src/GEOMImpl/GEOMImpl_Types.hxx index b2d1ddf84..df856b856 100755 --- a/src/GEOMImpl/GEOMImpl_Types.hxx +++ b/src/GEOMImpl/GEOMImpl_Types.hxx @@ -81,6 +81,8 @@ #define GEOM_THRUSECTIONS 40 +#define GEOM_COMPOUNDFILTER 41 + //GEOM_Function types #define COPY_WITH_REF 1