e984dc56a63273d89cd87c2e67f5a471d60ec2c6
[occt.git] / src / StdSelect / StdSelect_EdgeFilter.cxx
1 // Created on: 1996-03-13
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <StdSelect_EdgeFilter.ixx>
18 #include <BRepAdaptor_Curve.hxx>
19 #include <TopoDS_Edge.hxx>
20 #include <TopoDS.hxx>
21 #include <TopAbs.hxx>
22 #include <StdSelect_BRepOwner.hxx>
23 /*#include <.hxx>
24 #include <.hxx>
25 #include <.hxx>
26 #include <.hxx>
27 #include <.hxx>
28 */
29
30 //==================================================
31 // Function: 
32 // Purpose :
33 //==================================================
34 StdSelect_EdgeFilter
35 ::StdSelect_EdgeFilter (const StdSelect_TypeOfEdge Edge):
36 mytype(Edge){}
37
38 //==================================================
39 // Function: 
40 // Purpose :
41 //==================================================
42 void StdSelect_EdgeFilter
43 ::SetType(const StdSelect_TypeOfEdge aNewType)
44 {
45   mytype=aNewType;
46 }
47
48
49
50 //==================================================
51 // Function: 
52 // Purpose :
53 //==================================================
54 StdSelect_TypeOfEdge StdSelect_EdgeFilter::Type() const 
55 {
56   return mytype;
57 }
58
59 //==================================================
60 // Function: 
61 // Purpose :
62 //==================================================
63 Standard_Boolean StdSelect_EdgeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const 
64 {
65   if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull()) return Standard_False;
66   
67   const TopoDS_Shape& sh = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
68   if(sh.ShapeType()!= TopAbs_EDGE) return Standard_False;
69   
70   switch(mytype){
71   case StdSelect_AnyEdge:
72       return Standard_True;
73   case StdSelect_Line:
74     {
75       BRepAdaptor_Curve curv(TopoDS::Edge(sh));
76       return (curv.GetType() == GeomAbs_Line);
77     }
78     break;
79   case StdSelect_Circle:
80     BRepAdaptor_Curve curv(TopoDS::Edge(sh));
81     return (curv.GetType() == GeomAbs_Circle);
82   }
83   
84   return Standard_False ;
85 }
86
87 Standard_Boolean StdSelect_EdgeFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const 
88 {return aStandardMode==TopAbs_EDGE;}