Test for 0022778: Bug in BRepMesh
[occt.git] / src / XSControl / XSControl_ConnectedShapes.cxx
CommitLineData
b311480e 1// Copyright (c) 1999-2012 OPEN CASCADE SAS
2//
3// The content of this file is subject to the Open CASCADE Technology Public
4// License Version 6.5 (the "License"). You may not use the content of this file
5// except in compliance with the License. Please obtain a copy of the License
6// at http://www.opencascade.org and read it completely before using this file.
7//
8// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
9// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
10//
11// The Original Code and all software distributed under the License is
12// distributed on an "AS IS" basis, without warranty of any kind, and the
13// Initial Developer hereby disclaims all such warranties, including without
14// limitation, any warranties of merchantability, fitness for a particular
15// purpose or non-infringement. Please see the License for the specific terms
16// and conditions governing the rights and limitations under the License.
17
7fd59977 18#include <XSControl_ConnectedShapes.ixx>
19#include <TopExp_Explorer.hxx>
20#include <TopTools_MapOfShape.hxx>
21#include <TransferBRep.hxx>
22
23
b311480e 24XSControl_ConnectedShapes::XSControl_ConnectedShapes ()
7fd59977 25 : IFSelect_SelectExplore (1) { }
26
27 XSControl_ConnectedShapes::XSControl_ConnectedShapes
28 (const Handle(XSControl_TransferReader)& TR)
29 : IFSelect_SelectExplore (1) , theTR (TR) { }
30
31 void XSControl_ConnectedShapes::SetReader
32 (const Handle(XSControl_TransferReader)& TR)
33 { theTR = TR; }
34
35 Standard_Boolean XSControl_ConnectedShapes::Explore
36 (const Standard_Integer /*level*/, const Handle(Standard_Transient)& ent,
37 const Interface_Graph& /*G*/, Interface_EntityIterator& explored) const
38{
39 Handle(Transfer_TransientProcess) TP;
40 if (!theTR.IsNull()) TP = theTR->TransientProcess();
41 if (TP.IsNull()) return Standard_False;
42 TopoDS_Shape Shape = TransferBRep::ShapeResult (TP,ent);
43 if (Shape.IsNull()) return Standard_False;
44 Handle(TColStd_HSequenceOfTransient) li = AdjacentEntities (Shape,TP,TopAbs_FACE);
45 explored.AddList (li);
46 return Standard_True;
47}
48
49 TCollection_AsciiString XSControl_ConnectedShapes::ExploreLabel () const
50{
51 TCollection_AsciiString lab("Connected Entities through produced Shapes");
52 return lab;
53}
54
55 Handle(TColStd_HSequenceOfTransient) XSControl_ConnectedShapes::AdjacentEntities
56 (const TopoDS_Shape& ashape,
57 const Handle(Transfer_TransientProcess)& TP,
58 const TopAbs_ShapeEnum type)
59{
60 Handle(TColStd_HSequenceOfTransient) li = new TColStd_HSequenceOfTransient();
61 Standard_Integer i, nb = TP->NbMapped();
62// TopTools_MapOfShape adj (nb);
63 TopTools_MapOfShape vtx(20);
64
65 for (TopExp_Explorer vert(ashape,TopAbs_VERTEX); vert.More(); vert.Next()) {
66 vtx.Add (vert.Current());
67 }
68
69 for (i = 1; i <= nb; i ++) {
70 Handle(Transfer_Binder) bnd = TP->MapItem(i);
71 TopoDS_Shape sh = TransferBRep::ShapeResult (bnd);
72 if (sh.IsNull()) continue;
73 if (sh.ShapeType() != type) continue;
74 for (TopExp_Explorer vsh(sh,TopAbs_VERTEX); vsh.More(); vsh.Next()) {
75 TopoDS_Shape avtx = vsh.Current();
76 if (vtx.Contains(avtx)) {
77 li->Append (TP->Mapped(i));
78 break; // break de ce for interieur, entite suivante
79 }
80 }
81 }
82
83 return li;
84}