Integration of OCCT 6.5.0 from SVN
[occt.git] / src / XSControl / XSControl_ConnectedShapes.cxx
CommitLineData
7fd59977 1#include <XSControl_ConnectedShapes.ixx>
2#include <TopExp_Explorer.hxx>
3#include <TopTools_MapOfShape.hxx>
4#include <TransferBRep.hxx>
5
6
7 XSControl_ConnectedShapes::XSControl_ConnectedShapes ()
8 : IFSelect_SelectExplore (1) { }
9
10 XSControl_ConnectedShapes::XSControl_ConnectedShapes
11 (const Handle(XSControl_TransferReader)& TR)
12 : IFSelect_SelectExplore (1) , theTR (TR) { }
13
14 void XSControl_ConnectedShapes::SetReader
15 (const Handle(XSControl_TransferReader)& TR)
16 { theTR = TR; }
17
18 Standard_Boolean XSControl_ConnectedShapes::Explore
19 (const Standard_Integer /*level*/, const Handle(Standard_Transient)& ent,
20 const Interface_Graph& /*G*/, Interface_EntityIterator& explored) const
21{
22 Handle(Transfer_TransientProcess) TP;
23 if (!theTR.IsNull()) TP = theTR->TransientProcess();
24 if (TP.IsNull()) return Standard_False;
25 TopoDS_Shape Shape = TransferBRep::ShapeResult (TP,ent);
26 if (Shape.IsNull()) return Standard_False;
27 Handle(TColStd_HSequenceOfTransient) li = AdjacentEntities (Shape,TP,TopAbs_FACE);
28 explored.AddList (li);
29 return Standard_True;
30}
31
32 TCollection_AsciiString XSControl_ConnectedShapes::ExploreLabel () const
33{
34 TCollection_AsciiString lab("Connected Entities through produced Shapes");
35 return lab;
36}
37
38 Handle(TColStd_HSequenceOfTransient) XSControl_ConnectedShapes::AdjacentEntities
39 (const TopoDS_Shape& ashape,
40 const Handle(Transfer_TransientProcess)& TP,
41 const TopAbs_ShapeEnum type)
42{
43 Handle(TColStd_HSequenceOfTransient) li = new TColStd_HSequenceOfTransient();
44 Standard_Integer i, nb = TP->NbMapped();
45// TopTools_MapOfShape adj (nb);
46 TopTools_MapOfShape vtx(20);
47
48 for (TopExp_Explorer vert(ashape,TopAbs_VERTEX); vert.More(); vert.Next()) {
49 vtx.Add (vert.Current());
50 }
51
52 for (i = 1; i <= nb; i ++) {
53 Handle(Transfer_Binder) bnd = TP->MapItem(i);
54 TopoDS_Shape sh = TransferBRep::ShapeResult (bnd);
55 if (sh.IsNull()) continue;
56 if (sh.ShapeType() != type) continue;
57 for (TopExp_Explorer vsh(sh,TopAbs_VERTEX); vsh.More(); vsh.Next()) {
58 TopoDS_Shape avtx = vsh.Current();
59 if (vtx.Contains(avtx)) {
60 li->Append (TP->Mapped(i));
61 break; // break de ce for interieur, entite suivante
62 }
63 }
64 }
65
66 return li;
67}