Salome HOME
6d2e149c2a00632e90ffe9abac10d410fb064b37
[modules/geom.git] / src / CurveCreator / CurveCreator_ShapeFilter.cxx
1 // Copyright (C) 2013-2023  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // File:        CurveCreator_ShapeFilter.cxx
21 // Author:      Ilya Shchekin
22
23
24 #include "CurveCreator_ShapeFilter.hxx"
25
26 #include <SelectMgr_EntityOwner.hxx>
27 #include <StdSelect_BRepOwner.hxx>
28 #include <TopoDS_Vertex.hxx>
29
30 IMPLEMENT_STANDARD_RTTIEXT(CurveCreator_ShapeFilter,SelectMgr_Filter)
31
32 CurveCreator_ShapeFilter::CurveCreator_ShapeFilter()
33 : SelectMgr_Filter()
34 {
35 }
36
37 CurveCreator_ShapeFilter::~CurveCreator_ShapeFilter()
38 {
39 }
40
41 Standard_Boolean CurveCreator_ShapeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
42 {
43   return (aType == TopAbs_VERTEX);
44 }
45
46 Standard_Boolean CurveCreator_ShapeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
47 {
48   Handle(StdSelect_BRepOwner) aBO = Handle(StdSelect_BRepOwner)::DownCast(EO);
49   if (aBO.IsNull())
50     return Standard_False;
51
52   const TopoDS_Shape& aShape = aBO->Shape();
53
54   if(aShape.ShapeType()!= TopAbs_VERTEX)
55     return Standard_False;
56
57   return myShapes.Contains(aShape);
58 }
59
60 void CurveCreator_ShapeFilter::AddShape(const TopoDS_Shape& aShape)
61 {
62   myShapes.Add(aShape);  
63 }
64
65 void CurveCreator_ShapeFilter::RemoveShape(const TopoDS_Shape& aShape)
66 {
67   myShapes.Remove(aShape);
68 }
69
70 void CurveCreator_ShapeFilter::ClearShapes()
71 {
72   myShapes.Clear();
73 }
74