1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
15 #include <Interface_EntityIterator.hxx>
16 #include <Interface_Graph.hxx>
17 #include <Standard_Transient.hxx>
18 #include <Standard_Type.hxx>
19 #include <TCollection_AsciiString.hxx>
20 #include <TopExp_Explorer.hxx>
21 #include <TopoDS_Shape.hxx>
22 #include <TopTools_MapOfShape.hxx>
23 #include <Transfer_TransientProcess.hxx>
24 #include <TransferBRep.hxx>
25 #include <XSControl_ConnectedShapes.hxx>
26 #include <XSControl_TransferReader.hxx>
28 IMPLEMENT_STANDARD_RTTIEXT(XSControl_ConnectedShapes,IFSelect_SelectExplore)
30 XSControl_ConnectedShapes::XSControl_ConnectedShapes ()
31 : IFSelect_SelectExplore (1) { }
33 XSControl_ConnectedShapes::XSControl_ConnectedShapes
34 (const Handle(XSControl_TransferReader)& TR)
35 : IFSelect_SelectExplore (1) , theTR (TR) { }
37 void XSControl_ConnectedShapes::SetReader
38 (const Handle(XSControl_TransferReader)& TR)
41 Standard_Boolean XSControl_ConnectedShapes::Explore
42 (const Standard_Integer /*level*/, const Handle(Standard_Transient)& ent,
43 const Interface_Graph& /*G*/, Interface_EntityIterator& explored) const
45 Handle(Transfer_TransientProcess) TP;
46 if (!theTR.IsNull()) TP = theTR->TransientProcess();
47 if (TP.IsNull()) return Standard_False;
48 TopoDS_Shape Shape = TransferBRep::ShapeResult (TP,ent);
49 if (Shape.IsNull()) return Standard_False;
50 Handle(TColStd_HSequenceOfTransient) li = AdjacentEntities (Shape,TP,TopAbs_FACE);
51 explored.AddList (li);
55 TCollection_AsciiString XSControl_ConnectedShapes::ExploreLabel () const
57 TCollection_AsciiString lab("Connected Entities through produced Shapes");
61 Handle(TColStd_HSequenceOfTransient) XSControl_ConnectedShapes::AdjacentEntities
62 (const TopoDS_Shape& ashape,
63 const Handle(Transfer_TransientProcess)& TP,
64 const TopAbs_ShapeEnum type)
66 Handle(TColStd_HSequenceOfTransient) li = new TColStd_HSequenceOfTransient();
67 Standard_Integer i, nb = TP->NbMapped();
68 // TopTools_MapOfShape adj (nb);
69 TopTools_MapOfShape vtx(20);
71 for (TopExp_Explorer vert(ashape,TopAbs_VERTEX); vert.More(); vert.Next()) {
72 vtx.Add (vert.Current());
75 for (i = 1; i <= nb; i ++) {
76 Handle(Transfer_Binder) bnd = TP->MapItem(i);
77 TopoDS_Shape sh = TransferBRep::ShapeResult (bnd);
78 if (sh.IsNull()) continue;
79 if (sh.ShapeType() != type) continue;
80 for (TopExp_Explorer vsh(sh,TopAbs_VERTEX); vsh.More(); vsh.Next()) {
81 TopoDS_Shape avtx = vsh.Current();
82 if (vtx.Contains(avtx)) {
83 li->Append (TP->Mapped(i));
84 break; // break de ce for interieur, entite suivante