0025765: Coding rules - clean up code from obsolete macro checks
[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 #include <StdSelect_FaceFilter.ixx>
18 #include <BRepAdaptor_Surface.hxx>
19 #include <TopoDS_Face.hxx>
20 #include <TopoDS_Shape.hxx>
21 #include <TopoDS.hxx>
22 #include <TopAbs.hxx>
23 #include <StdSelect_BRepOwner.hxx>
24 /*#include <.hxx>
25 #include <.hxx>
26 #include <.hxx>
27 #include <.hxx>
28 #include <.hxx>
29 #include <.hxx>
30 */
31
32 StdSelect_FaceFilter::
33 StdSelect_FaceFilter(const StdSelect_TypeOfFace aTypeOfFace):
34 mytype(aTypeOfFace){}
35
36 void StdSelect_FaceFilter::
37 SetType(const StdSelect_TypeOfFace aTypeOfFace)
38 {mytype = aTypeOfFace;}
39
40
41 //==================================================
42 // Function: 
43 // Purpose :
44 //==================================================
45 StdSelect_TypeOfFace StdSelect_FaceFilter::Type() const 
46 {
47   return mytype;
48 }
49
50 Standard_Boolean StdSelect_FaceFilter::
51 IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
52 {
53   if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull()) return Standard_False;
54   const TopoDS_Shape& anobj= ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
55   if(anobj.ShapeType()!= TopAbs_FACE)return Standard_False;  
56   switch(mytype) {
57   case StdSelect_AnyFace:
58     return Standard_True;
59   case StdSelect_Plane:
60     {
61       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
62       return (surf.GetType() == GeomAbs_Plane);
63     }
64   case StdSelect_Cylinder:
65     {
66       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
67       return (surf.GetType() == GeomAbs_Cylinder);
68     }
69   case StdSelect_Sphere: 
70     {
71       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
72       return (surf.GetType() == GeomAbs_Sphere);      
73     }
74   case StdSelect_Torus: 
75     {
76       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
77       return ( surf.GetType() == GeomAbs_Torus);      
78     }
79   case StdSelect_Revol: 
80     {
81       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
82       return ( surf.GetType() == GeomAbs_Cylinder || 
83                surf.GetType() == GeomAbs_Cone     ||
84                surf.GetType() == GeomAbs_Torus    
85                ||
86                surf.GetType() == GeomAbs_Sphere   || 
87                surf.GetType() == GeomAbs_SurfaceOfRevolution 
88              ); 
89     }
90   case StdSelect_Cone: // waiting for the free cdl, it is used for Cone
91     {
92       BRepAdaptor_Surface surf(TopoDS::Face(anobj));
93       return (surf.GetType() == GeomAbs_Cone);      
94     }
95   }
96   return Standard_False;
97 }
98 Standard_Boolean StdSelect_FaceFilter::ActsOn(const TopAbs_ShapeEnum aStandardMode) const 
99 {return aStandardMode==TopAbs_FACE;}