Implementation of NPAL16149 (EDF 442 GEOM : Create a shell from a compound containing only faces).

This commit is contained in:
rnv 2008-03-18 07:41:27 +00:00
parent c75ecc0adc
commit be31b630d5
9 changed files with 258 additions and 10 deletions

View File

@ -101,7 +101,11 @@ void BuildGUI_ShellDlg::Init()
TColStd_MapOfInteger aMap;
aMap.Add(GEOM_SHELL);
aMap.Add(GEOM_FACE);
globalSelection( aMap );
aMap.Add(GEOM_COMPOUNDFILTER);
QValueList<int> aSubShapes;
aSubShapes.append(GEOM_FACE);
globalSelection( aMap, aSubShapes );
/* signals and slots connections */
connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
@ -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<int> 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<int> aSubShapes;
aSubShapes.append(GEOM_FACE);
globalSelection( aMap, aSubShapes );
}

View File

@ -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<int>& subShapes,
const bool update )
{
getDisplayer()->GlobalSelection( theModes, update, &subShapes);
}
//================================================================
// Function : addInStudy
// Purpose : Add object in study

View File

@ -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<int>& ,const bool = false );
void updateViewer ();
void prepareSelection( const ObjectList&, const int );

View File

@ -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 <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS_Iterator.hxx>
//=======================================================================
// 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<int>::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<int>& 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;
}
}
}

View File

@ -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<int>& );
private:
void getInfo(const TopoDS_Shape&, bool subTypes []) const;
private:
QValueList<int> myKinds;
};
#endif

View File

@ -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

View File

@ -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<int>* aSubShapes)
{
GEOM_CompoundFilter* aFilter;
if(aSubShapes != NULL ) {
aFilter = new GEOM_CompoundFilter(getStudy());
QValueList<int> aTopAbsTypes;
QValueList<int>::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<int>* theSubShapes)
{
SUIT_Session* session = SUIT_Session::session();
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
@ -1076,6 +1101,10 @@ void GEOM_Displayer::GlobalSelection( const TColStd_MapOfInteger& theModes,
if ( theModes.Extent() == 1 )
{
int aMode = TColStd_MapIteratorOfMapOfInteger( theModes ).Key();
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<SUIT_SelectionFilter> 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 );
}

View File

@ -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<int>* = 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<int>* );
protected:
Handle(SALOME_InteractiveObject) myIO;

View File

@ -81,6 +81,8 @@
#define GEOM_THRUSECTIONS 40
#define GEOM_COMPOUNDFILTER 41
//GEOM_Function types
#define COPY_WITH_REF 1