0033022: Coding - get rid of unused headers [ShapeBuild to STEPControl]
[occt.git] / src / StdSelect / StdSelect_FaceFilter.cxx
1 // Created on: 1996-03-08
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
18 #include <BRepAdaptor_Surface.hxx>
19 #include <Standard_Type.hxx>
20 #include <StdSelect_BRepOwner.hxx>
21 #include <StdSelect_FaceFilter.hxx>
22 #include <TopAbs.hxx>
23 #include <TopoDS.hxx>
24 #include <TopoDS_Shape.hxx>
25
26 IMPLEMENT_STANDARD_RTTIEXT(StdSelect_FaceFilter,SelectMgr_Filter)
27
28 /*#include <.hxx>
29 #include <.hxx>
30 #include <.hxx>
31 #include <.hxx>
32 #include <.hxx>
33 #include <.hxx>
34 */
35 StdSelect_FaceFilter::
36 StdSelect_FaceFilter(const StdSelect_TypeOfFace aTypeOfFace):
37 mytype(aTypeOfFace){}
38
39 void StdSelect_FaceFilter::
40 SetType(const StdSelect_TypeOfFace aTypeOfFace)
41 {mytype = aTypeOfFace;}
42
43
44 //==================================================
45 // Function: 
46 // Purpose :
47 //==================================================
48 StdSelect_TypeOfFace StdSelect_FaceFilter::Type() const 
49 {
50   return mytype;
51 }
52
53 Standard_Boolean StdSelect_FaceFilter::
54 IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
55 {
56   Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO));
57   if (aBO.IsNull())
58     return Standard_False;
59
60   const TopoDS_Shape& anobj = aBO->Shape();
61   if(anobj.ShapeType()!= TopAbs_FACE)
62     return Standard_False;  
63
64   switch(mytype) {
65   case StdSelect_AnyFace:
66     return Standard_True;
67   case StdSelect_Plane:
68     {
69       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
70       return (surf.GetType() == GeomAbs_Plane);
71     }
72   case StdSelect_Cylinder:
73     {
74       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
75       return (surf.GetType() == GeomAbs_Cylinder);
76     }
77   case StdSelect_Sphere: 
78     {
79       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
80       return (surf.GetType() == GeomAbs_Sphere);      
81     }
82   case StdSelect_Torus: 
83     {
84       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
85       return ( surf.GetType() == GeomAbs_Torus);      
86     }
87   case StdSelect_Revol: 
88     {
89       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
90       return ( surf.GetType() == GeomAbs_Cylinder || 
91                surf.GetType() == GeomAbs_Cone     ||
92                surf.GetType() == GeomAbs_Torus    
93                ||
94                surf.GetType() == GeomAbs_Sphere   || 
95                surf.GetType() == GeomAbs_SurfaceOfRevolution 
96              ); 
97     }
98   case StdSelect_Cone: // waiting for the free cdl, it is used for Cone
99     {
100       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
101       return (surf.GetType() == GeomAbs_Cone);      
102     }
103   }
104   return Standard_False;
105 }
106 Standard_Boolean StdSelect_FaceFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const 
107 {return aStandardMode==TopAbs_FACE;}