1 // GEOM GEOM_CompoundFilter : filter selector for the viewer
3 // Copyright (C) 2003 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
24 // File : GEOM_CompoundFilter.cxx
25 // Author : Roman NIKOLAEV
28 #include "GEOM_CompoundFilter.h"
31 #include <TopTools_MapOfShape.hxx>
32 #include <TopTools_ListOfShape.hxx>
33 #include <TopTools_ListIteratorOfListOfShape.hxx>
34 #include <TopoDS_Iterator.hxx>
38 //=======================================================================
39 // function : GEOM_CompoundFilter
41 //=======================================================================
42 GEOM_CompoundFilter::GEOM_CompoundFilter(SalomeApp_Study* study)
43 : GEOM_SelectionFilter( study )
45 add( TopAbs_COMPOUND );
48 //=======================================================================
49 // function : ~GEOM_CompoundFilter
51 //=======================================================================
52 GEOM_CompoundFilter::~GEOM_CompoundFilter()
56 //=======================================================================
59 //=======================================================================
60 bool GEOM_CompoundFilter::isOk( const SUIT_DataOwner* sOwner) const
62 if(GEOM_SelectionFilter::isOk(sOwner)){
64 GEOM::GEOM_Object_var obj = getObject( sOwner );
66 if ( getShape( obj, shape )){
67 bool subTypes[TopAbs_SHAPE];
68 getInfo(shape,subTypes);
69 QValueList<int>::const_iterator it;
71 for ( it = myKinds.constBegin(); it != myKinds.constEnd(); ++it )
72 result = result || subTypes[(*it)];
81 //=======================================================================
82 // function : addSubType
84 //=======================================================================
85 void GEOM_CompoundFilter::addSubType( const int type)
87 if(!myKinds.contains(type))
91 //=======================================================================
92 // function : addSubTypes
94 //=======================================================================
95 void GEOM_CompoundFilter::addSubTypes(const QValueList<int>& kinds)
100 //=======================================================================
101 // function : getInfo()
103 //=======================================================================
104 void GEOM_CompoundFilter::getInfo(const TopoDS_Shape& aShape, bool subTypes[]) const
106 int iType, nbTypes[TopAbs_SHAPE];
107 for (iType = 0; iType < TopAbs_SHAPE; ++iType){
109 subTypes[iType] = false;
112 nbTypes[aShape.ShapeType()]++;
113 TopTools_MapOfShape aMapOfShape;
114 aMapOfShape.Add(aShape);
115 TopTools_ListOfShape aListOfShape;
116 aListOfShape.Append(aShape);
118 TopTools_ListIteratorOfListOfShape itL (aListOfShape);
119 for (; itL.More(); itL.Next()) {
120 TopoDS_Iterator it (itL.Value());
121 for (; it.More(); it.Next()) {
122 TopoDS_Shape s = it.Value();
123 if (aMapOfShape.Add(s)) {
124 aListOfShape.Append(s);
125 nbTypes[s.ShapeType()]++;
130 for(iType = TopAbs_COMPSOLID; iType < TopAbs_SHAPE; ++iType) {
131 if(nbTypes[iType] > 0) {
132 subTypes[iType] = true;