0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / AIS / AIS_C0RegularityFilter.cxx
CommitLineData
b311480e 1// Created on: 1998-02-04
2// Created by: Julia GERASIMOVA
3// Copyright (c) 1998-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <AIS_C0RegularityFilter.hxx>
7fd59977 19#include <BRep_Tool.hxx>
42cf5bc1 20#include <GeomAbs_Shape.hxx>
21#include <SelectMgr_EntityOwner.hxx>
22#include <Standard_Type.hxx>
7fd59977 23#include <StdSelect_BRepOwner.hxx>
42cf5bc1 24#include <TopExp.hxx>
25#include <TopoDS.hxx>
26#include <TopoDS_Face.hxx>
27#include <TopoDS_Shape.hxx>
28#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
29#include <TopTools_ListIteratorOfListOfShape.hxx>
7fd59977 30
92efcf78 31IMPLEMENT_STANDARD_RTTIEXT(AIS_C0RegularityFilter,SelectMgr_Filter)
32
7fd59977 33//=======================================================================
34//function : AIS_C0RegularityFilter
35//purpose :
36//=======================================================================
7fd59977 37AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape)
38{
39 TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
40 TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes);
41 Standard_Boolean Ok;
42 for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
43 Ok = Standard_False;
44 TopTools_ListIteratorOfListOfShape it(SubShapes(i));
45 TopoDS_Face Face1, Face2;
46 if (it.More()) {
47 Face1 = TopoDS::Face(it.Value());
48 it.Next();
49 if (it.More()) {
50 Face2 = TopoDS::Face(it.Value());
51 it.Next();
52 if (!it.More()) {
53 GeomAbs_Shape ShapeContinuity =
54 BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2);
55 Ok = (ShapeContinuity == GeomAbs_C0);
56 }
57 }
58 }
59 if (Ok) {
60 TopoDS_Shape curEdge = SubShapes.FindKey( i );
61 myMapOfEdges.Add(curEdge);
62 }
63 }
64}
65
66//=======================================================================
67//function : ActsOn
68//purpose :
69//=======================================================================
70
71Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
72{
73 return (aType == TopAbs_EDGE);
74}
75
76//=======================================================================
77//function : IsOk
78//purpose :
79//=======================================================================
80
81Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
82{
5b111128 83 Handle(StdSelect_BRepOwner) aBO (Handle(StdSelect_BRepOwner)::DownCast(EO));
84 if (aBO.IsNull())
7fd59977 85 return Standard_False;
86
5b111128 87 const TopoDS_Shape& aShape = aBO->Shape();
7fd59977 88
89 if(aShape.ShapeType()!= TopAbs_EDGE)
90 return Standard_False;
91
92 return (myMapOfEdges.Contains(aShape));
93}