0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / AIS / AIS_C0RegularityFilter.cxx
1 // Created on: 1998-02-04
2 // Created by: Julia GERASIMOVA
3 // Copyright (c) 1998-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
9 // under the terms of the GNU Lesser General Public 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 <AIS_C0RegularityFilter.ixx>
18
19 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
20 #include <TopTools_ListIteratorOfListOfShape.hxx>
21 #include <TopExp.hxx>
22 #include <TopoDS_Face.hxx>
23 #include <TopoDS.hxx>
24 #include <GeomAbs_Shape.hxx>
25 #include <BRep_Tool.hxx>
26 #include <StdSelect_BRepOwner.hxx>
27
28
29 //=======================================================================
30 //function : AIS_C0RegularityFilter
31 //purpose  : 
32 //=======================================================================
33
34 AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape)
35 {
36   TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
37   TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes);
38   Standard_Boolean Ok;
39   for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
40     Ok = Standard_False;
41     TopTools_ListIteratorOfListOfShape it(SubShapes(i));
42     TopoDS_Face Face1, Face2;
43     if (it.More()) {
44       Face1 = TopoDS::Face(it.Value());
45       it.Next();
46       if (it.More()) {
47         Face2 = TopoDS::Face(it.Value());
48         it.Next();
49         if (!it.More()) {
50           GeomAbs_Shape ShapeContinuity =
51             BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2);
52           Ok = (ShapeContinuity == GeomAbs_C0);
53         }
54       }
55     }
56     if (Ok) {
57       TopoDS_Shape curEdge = SubShapes.FindKey( i );
58       myMapOfEdges.Add(curEdge);
59     }
60   }
61 }
62
63 //=======================================================================
64 //function : ActsOn
65 //purpose  : 
66 //=======================================================================
67
68 Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
69 {
70   return (aType == TopAbs_EDGE);
71 }
72
73 //=======================================================================
74 //function : IsOk
75 //purpose  : 
76 //=======================================================================
77
78 Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
79 {
80   if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
81     return Standard_False;
82
83   const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
84
85   if(aShape.ShapeType()!= TopAbs_EDGE)
86     return Standard_False;
87
88   return (myMapOfEdges.Contains(aShape));
89 }