0022627: Change OCCT memory management defaults
[occt.git] / src / AIS / AIS_C0RegularityFilter.cxx
CommitLineData
7fd59977 1// File: AIS_C0RegularityFilter.cxx
2// Created: Wed Feb 4 19:04:30 1998
3// Author: Julia GERASIMOVA
4// <jgv@orthodox.nnov.matra-dtv.fr>
5
6
7#include <AIS_C0RegularityFilter.ixx>
8
9#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
10#include <TopTools_ListIteratorOfListOfShape.hxx>
11#include <TopExp.hxx>
12#include <TopoDS_Face.hxx>
13#include <TopoDS.hxx>
14#include <GeomAbs_Shape.hxx>
15#include <BRep_Tool.hxx>
16#include <StdSelect_BRepOwner.hxx>
17
18
19//=======================================================================
20//function : AIS_C0RegularityFilter
21//purpose :
22//=======================================================================
23
24AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape)
25{
26 TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
27 TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes);
28 Standard_Boolean Ok;
29 for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
30 Ok = Standard_False;
31 TopTools_ListIteratorOfListOfShape it(SubShapes(i));
32 TopoDS_Face Face1, Face2;
33 if (it.More()) {
34 Face1 = TopoDS::Face(it.Value());
35 it.Next();
36 if (it.More()) {
37 Face2 = TopoDS::Face(it.Value());
38 it.Next();
39 if (!it.More()) {
40 GeomAbs_Shape ShapeContinuity =
41 BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2);
42 Ok = (ShapeContinuity == GeomAbs_C0);
43 }
44 }
45 }
46 if (Ok) {
47 TopoDS_Shape curEdge = SubShapes.FindKey( i );
48 myMapOfEdges.Add(curEdge);
49 }
50 }
51}
52
53//=======================================================================
54//function : ActsOn
55//purpose :
56//=======================================================================
57
58Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
59{
60 return (aType == TopAbs_EDGE);
61}
62
63//=======================================================================
64//function : IsOk
65//purpose :
66//=======================================================================
67
68Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
69{
70 if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
71 return Standard_False;
72
73 const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();
74
75 if(aShape.ShapeType()!= TopAbs_EDGE)
76 return Standard_False;
77
78 return (myMapOfEdges.Contains(aShape));
79}