b311480e |
1 | // Created on: 1998-02-04 |
2 | // Created by: Julia GERASIMOVA |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <AIS_C0RegularityFilter.ixx> |
24 | |
25 | #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> |
26 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
27 | #include <TopExp.hxx> |
28 | #include <TopoDS_Face.hxx> |
29 | #include <TopoDS.hxx> |
30 | #include <GeomAbs_Shape.hxx> |
31 | #include <BRep_Tool.hxx> |
32 | #include <StdSelect_BRepOwner.hxx> |
33 | |
34 | |
35 | //======================================================================= |
36 | //function : AIS_C0RegularityFilter |
37 | //purpose : |
38 | //======================================================================= |
39 | |
40 | AIS_C0RegularityFilter::AIS_C0RegularityFilter(const TopoDS_Shape& aShape) |
41 | { |
42 | TopTools_IndexedDataMapOfShapeListOfShape SubShapes; |
43 | TopExp::MapShapesAndAncestors(aShape,TopAbs_EDGE,TopAbs_FACE,SubShapes); |
44 | Standard_Boolean Ok; |
45 | for (Standard_Integer i = 1; i <= SubShapes.Extent(); i++) { |
46 | Ok = Standard_False; |
47 | TopTools_ListIteratorOfListOfShape it(SubShapes(i)); |
48 | TopoDS_Face Face1, Face2; |
49 | if (it.More()) { |
50 | Face1 = TopoDS::Face(it.Value()); |
51 | it.Next(); |
52 | if (it.More()) { |
53 | Face2 = TopoDS::Face(it.Value()); |
54 | it.Next(); |
55 | if (!it.More()) { |
56 | GeomAbs_Shape ShapeContinuity = |
57 | BRep_Tool::Continuity(TopoDS::Edge(SubShapes.FindKey(i)),Face1,Face2); |
58 | Ok = (ShapeContinuity == GeomAbs_C0); |
59 | } |
60 | } |
61 | } |
62 | if (Ok) { |
63 | TopoDS_Shape curEdge = SubShapes.FindKey( i ); |
64 | myMapOfEdges.Add(curEdge); |
65 | } |
66 | } |
67 | } |
68 | |
69 | //======================================================================= |
70 | //function : ActsOn |
71 | //purpose : |
72 | //======================================================================= |
73 | |
74 | Standard_Boolean AIS_C0RegularityFilter::ActsOn(const TopAbs_ShapeEnum aType) const |
75 | { |
76 | return (aType == TopAbs_EDGE); |
77 | } |
78 | |
79 | //======================================================================= |
80 | //function : IsOk |
81 | //purpose : |
82 | //======================================================================= |
83 | |
84 | Standard_Boolean AIS_C0RegularityFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const |
85 | { |
86 | if (Handle(StdSelect_BRepOwner)::DownCast(EO).IsNull()) |
87 | return Standard_False; |
88 | |
89 | const TopoDS_Shape& aShape = ((Handle(StdSelect_BRepOwner)&)EO)->Shape(); |
90 | |
91 | if(aShape.ShapeType()!= TopAbs_EDGE) |
92 | return Standard_False; |
93 | |
94 | return (myMapOfEdges.Contains(aShape)); |
95 | } |