1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM GEOM_CompoundFilter : filter selector for the viewer
23 // File : GEOM_CompoundFilter.cxx
24 // Author : Roman NIKOLAEV
27 #include "GEOM_CompoundFilter.h"
30 #include <TopTools_MapOfShape.hxx>
31 #include <TopTools_ListOfShape.hxx>
32 #include <TopTools_ListIteratorOfListOfShape.hxx>
33 #include <TopoDS_Iterator.hxx>
37 //=======================================================================
38 // function : GEOM_CompoundFilter
40 //=======================================================================
41 GEOM_CompoundFilter::GEOM_CompoundFilter(SalomeApp_Study* study)
42 : GEOM_SelectionFilter( study )
44 add( TopAbs_COMPOUND );
47 //=======================================================================
48 // function : ~GEOM_CompoundFilter
50 //=======================================================================
51 GEOM_CompoundFilter::~GEOM_CompoundFilter()
55 //=======================================================================
58 //=======================================================================
59 bool GEOM_CompoundFilter::isOk( const SUIT_DataOwner* sOwner) const
61 if(GEOM_SelectionFilter::isOk(sOwner)){
63 GEOM::GEOM_Object_var obj = getObject( sOwner );
65 if ( getShape( obj, shape )){
66 bool subTypes[TopAbs_SHAPE];
67 getInfo(shape,subTypes);
68 QList<int>::const_iterator it;
70 for ( it = myKinds.constBegin(); it != myKinds.constEnd(); ++it )
71 result = result || subTypes[(*it)];
80 //=======================================================================
81 // function : addSubType
83 //=======================================================================
84 void GEOM_CompoundFilter::addSubType( const int type)
86 if(!myKinds.contains(type))
90 //=======================================================================
91 // function : addSubTypes
93 //=======================================================================
94 void GEOM_CompoundFilter::addSubTypes(const QList<int>& kinds)
99 //=======================================================================
100 // function : getInfo()
102 //=======================================================================
103 void GEOM_CompoundFilter::getInfo(const TopoDS_Shape& aShape, bool subTypes[]) const
105 int iType, nbTypes[TopAbs_SHAPE];
106 for (iType = 0; iType < TopAbs_SHAPE; ++iType){
108 subTypes[iType] = false;
111 nbTypes[aShape.ShapeType()]++;
112 TopTools_MapOfShape aMapOfShape;
113 aMapOfShape.Add(aShape);
114 TopTools_ListOfShape aListOfShape;
115 aListOfShape.Append(aShape);
117 TopTools_ListIteratorOfListOfShape itL (aListOfShape);
118 for (; itL.More(); itL.Next()) {
119 TopoDS_Iterator it (itL.Value());
120 for (; it.More(); it.Next()) {
121 TopoDS_Shape s = it.Value();
122 if (aMapOfShape.Add(s)) {
123 aListOfShape.Append(s);
124 nbTypes[s.ShapeType()]++;
129 for(iType = TopAbs_COMPSOLID; iType < TopAbs_SHAPE; ++iType) {
130 if(nbTypes[iType] > 0) {
131 subTypes[iType] = true;