0024750: Replace instantiations of TCollection generic classes by NCollection templat...
[occt.git] / src / XSControl / XSControl_ConnectedShapes.cxx
CommitLineData
973c2be1 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 2//
973c2be1 3// This file is part of Open CASCADE Technology software library.
b311480e 4//
d5f74e42 5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
b311480e 10//
973c2be1 11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
b311480e 13
7fd59977 14#include <XSControl_ConnectedShapes.ixx>
15#include <TopExp_Explorer.hxx>
16#include <TopTools_MapOfShape.hxx>
17#include <TransferBRep.hxx>
18
19
b311480e 20XSControl_ConnectedShapes::XSControl_ConnectedShapes ()
7fd59977 21 : IFSelect_SelectExplore (1) { }
22
23 XSControl_ConnectedShapes::XSControl_ConnectedShapes
24 (const Handle(XSControl_TransferReader)& TR)
25 : IFSelect_SelectExplore (1) , theTR (TR) { }
26
27 void XSControl_ConnectedShapes::SetReader
28 (const Handle(XSControl_TransferReader)& TR)
29 { theTR = TR; }
30
31 Standard_Boolean XSControl_ConnectedShapes::Explore
32 (const Standard_Integer /*level*/, const Handle(Standard_Transient)& ent,
33 const Interface_Graph& /*G*/, Interface_EntityIterator& explored) const
34{
35 Handle(Transfer_TransientProcess) TP;
36 if (!theTR.IsNull()) TP = theTR->TransientProcess();
37 if (TP.IsNull()) return Standard_False;
38 TopoDS_Shape Shape = TransferBRep::ShapeResult (TP,ent);
39 if (Shape.IsNull()) return Standard_False;
40 Handle(TColStd_HSequenceOfTransient) li = AdjacentEntities (Shape,TP,TopAbs_FACE);
41 explored.AddList (li);
42 return Standard_True;
43}
44
45 TCollection_AsciiString XSControl_ConnectedShapes::ExploreLabel () const
46{
47 TCollection_AsciiString lab("Connected Entities through produced Shapes");
48 return lab;
49}
50
51 Handle(TColStd_HSequenceOfTransient) XSControl_ConnectedShapes::AdjacentEntities
52 (const TopoDS_Shape& ashape,
53 const Handle(Transfer_TransientProcess)& TP,
54 const TopAbs_ShapeEnum type)
55{
56 Handle(TColStd_HSequenceOfTransient) li = new TColStd_HSequenceOfTransient();
57 Standard_Integer i, nb = TP->NbMapped();
58// TopTools_MapOfShape adj (nb);
59 TopTools_MapOfShape vtx(20);
60
61 for (TopExp_Explorer vert(ashape,TopAbs_VERTEX); vert.More(); vert.Next()) {
62 vtx.Add (vert.Current());
63 }
64
65 for (i = 1; i <= nb; i ++) {
66 Handle(Transfer_Binder) bnd = TP->MapItem(i);
67 TopoDS_Shape sh = TransferBRep::ShapeResult (bnd);
68 if (sh.IsNull()) continue;
69 if (sh.ShapeType() != type) continue;
70 for (TopExp_Explorer vsh(sh,TopAbs_VERTEX); vsh.More(); vsh.Next()) {
71 TopoDS_Shape avtx = vsh.Current();
72 if (vtx.Contains(avtx)) {
73 li->Append (TP->Mapped(i));
74 break; // break de ce for interieur, entite suivante
75 }
76 }
77 }
78
79 return li;
80}