summaryrefslogtreecommitdiff
path: root/src/AIS/AIS_C0RegularityFilter.cxx
blob: ebc5ed48d1ecb48a6698b08ab523929b5d28a059 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// File:	AIS_C0RegularityFilter.cxx
// Created:	Wed Feb  4 19:04:30 1998
// Author:	Julia GERASIMOVA
//		<jgv@orthodox.nnov.matra-dtv.fr>


#include <AIS_C0RegularityFilter.ixx>

#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopExp.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <GeomAbs_Shape.hxx>
#include <BRep_Tool.hxx>
#include <StdSelect_BRepOwner.hxx>


//=======================================================================
//function : AIS_C0RegularityFilter
//purpose  : 
//=======================================================================

AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape)
{
  TopTools_IndexedDataMapOfShapeListOfShape SubShapes;
  TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes);
  Standard_Boolean Ok;
  for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) {
    Ok = Standard_False;
    TopTools_ListIteratorOfListOfShape it(SubShapes(i));
    TopoDS_Face Face1, Face2;
    if (it.More()) {
      Face1 = TopoDS::Face(it.Value());
      it.Next();
      if (it.More()) {
	Face2 = TopoDS::Face(it.Value());
	it.Next();
	if (!it.More()) {
	  GeomAbs_Shape ShapeContinuity =
	    BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2);
	  Ok = (ShapeContinuity == GeomAbs_C0);
	}
      }
    }
    if (Ok) {
      TopoDS_Shape curEdge = SubShapes.FindKey( i );
      myMapOfEdges.Add(curEdge);
    }
  }
}

//=======================================================================
//function : ActsOn
//purpose  : 
//=======================================================================

Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const
{
  return (aType == TopAbs_EDGE);
}

//=======================================================================
//function : IsOk
//purpose  : 
//=======================================================================

Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
{
  if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull())
    return Standard_False;

  const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape();

  if(aShape.ShapeType()!= TopAbs_EDGE)
    return Standard_False;

  return (myMapOfEdges.Contains(aShape));
}