1 // GEOM GEOMFiltersSelection : 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : GEOM_EdgeFilter.cxx
25 // Author : Nicolas REJNERI
30 #include "GEOM_EdgeFilter.ixx"
31 #include "GEOM_Client.hxx"
33 #include "SALOME_InteractiveObject.hxx"
34 #include "GEOM_InteractiveObject.hxx"
35 #include "GEOM_ShapeTypeFilter.hxx"
36 #include "SALOME_TypeFilter.hxx"
38 #include "utilities.h"
39 #include "QAD_Application.h"
40 #include "QAD_Desktop.h"
41 #include "QAD_Study.h"
43 // Open CASCADE Includes
44 #include <BRepAdaptor_Curve.hxx>
45 #include <TopoDS_Edge.hxx>
50 static GEOM_Client ShapeReader;
54 enumeration TypeOfEdge is AnyEdge,Line,Circle;
56 GEOM_EdgeFilter::GEOM_EdgeFilter(const StdSelect_TypeOfEdge Edge,
57 GEOM::GEOM_Gen_ptr geom)
60 myComponentGeom = GEOM::GEOM_Gen::_narrow(geom);
63 Standard_Boolean GEOM_EdgeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const
65 Handle(SALOME_TypeFilter) GeomFilter = new SALOME_TypeFilter( "GEOM" );
66 if ( !GeomFilter->IsOk(anObj) )
69 Handle(GEOM_ShapeTypeFilter) GeomShapeTypeFilter = new GEOM_ShapeTypeFilter( TopAbs_EDGE, myComponentGeom );
70 if ( !GeomShapeTypeFilter->IsOk(anObj) )
73 if ( anObj->hasEntry() ) {
74 QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
75 SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument();
76 SALOMEDS::SObject_var obj = aStudy->FindObjectID( anObj->getEntry() );
77 SALOMEDS::GenericAttribute_var anAttr;
78 SALOMEDS::AttributeIOR_var anIOR;
79 if ( !obj->_is_nil() ) {
80 if (obj->FindAttribute(anAttr, "AttributeIOR")) {
81 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
82 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( anIOR->Value() );
83 if ( aShape->_is_nil() )
86 TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
91 case StdSelect_AnyEdge:
95 BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
96 return (curv.GetType() == GeomAbs_Line);
99 case StdSelect_Circle:
100 BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
101 return (curv.GetType() == GeomAbs_Circle);
107 if ( anObj->IsInstance(STANDARD_TYPE(GEOM_InteractiveObject)) ) {
108 Handle(GEOM_InteractiveObject) GObject =
109 Handle(GEOM_InteractiveObject)::DownCast(anObj);
111 GEOM::GEOM_Shape_var aShape = myComponentGeom->GetIORFromString( GObject->getIOR() );
112 if ( aShape->_is_nil() )
115 TopoDS_Shape Shape = ShapeReader.GetShape( myComponentGeom, aShape );
116 if ( Shape.IsNull() )
120 case StdSelect_AnyEdge:
121 return Standard_True;
124 BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
125 return (curv.GetType() == GeomAbs_Line);
128 case StdSelect_Circle:
129 BRepAdaptor_Curve curv(TopoDS::Edge(Shape));
130 return (curv.GetType() == GeomAbs_Circle);