Salome HOME
0021209: Bug GetInPlace with faces. Integrate self-intersections checker.
[modules/geom.git] / src / GEOMImpl / BRepBuilderAPI_GTransform_21423.cxx
1 // File:        BRepBuilderAPI_GTransform_21423.cxx
2 // Created:     Mon Dec 30 17:12:14 1996
3 // Author:      Stagiaire Mary FABIEN
4 //              <fbi@zozox.paris1.matra-dtv.fr>
5
6 #include <BRepBuilderAPI_GTransform_21423.hxx>
7
8 #include <Standard_NoSuchObject.hxx>
9 #include <gp_GTrsf.hxx>
10 #include <TopoDS_Shape.hxx>
11 #include <TopTools_ListOfShape.hxx>
12
13 #include <TopTools_ListIteratorOfListOfShape.hxx>
14 #include <BRepTools_GTrsfModification.hxx>
15 #include <BRepTools_NurbsConvertModification_21423.hxx>
16 #include <BRepBuilderAPI_NurbsConvert_21423.hxx>
17 #include <gp.hxx>
18
19 #include <BRep_Builder.hxx>
20 #include <TopoDS.hxx>
21
22 //=======================================================================
23 //function : BRepBuilderAPI_GTransform_21423
24 //purpose  : 
25 //=======================================================================
26
27 BRepBuilderAPI_GTransform_21423::BRepBuilderAPI_GTransform_21423 (const gp_GTrsf& T) :
28   myGTrsf(T)
29 {
30   myModification = new BRepTools_GTrsfModification(T);
31 }
32
33
34 //=======================================================================
35 //function : BRepBuilderAPI_GTransform_21423
36 //purpose  : 
37 //=======================================================================
38
39 BRepBuilderAPI_GTransform_21423::BRepBuilderAPI_GTransform_21423 (const TopoDS_Shape& S,
40                                         const gp_GTrsf& T,
41                                         const Standard_Boolean Copy) :
42   myGTrsf(T)
43 {
44   myModification = new BRepTools_GTrsfModification(T);
45   Perform(S,Copy);
46 }
47
48
49
50 //=======================================================================
51 //function : Perform
52 //purpose  : 
53 //=======================================================================
54
55 void BRepBuilderAPI_GTransform_21423::Perform(const TopoDS_Shape& S,
56                                  const Standard_Boolean Copy)
57 {
58   BRepBuilderAPI_NurbsConvert_21423 nc;
59   nc.Perform(S, Copy);
60   myHist.Add(S,nc);
61   TopoDS_Shape Slocal = nc.Shape();
62   Handle(BRepTools_GTrsfModification) theModif =
63     Handle(BRepTools_GTrsfModification)::DownCast(myModification);
64   theModif->GTrsf() = myGTrsf;
65   DoModif(Slocal,myModification);
66 //  myHist.Filter (Shape());
67 }
68
69
70 //=======================================================================
71 //function : Modified
72 //purpose  : 
73 //=======================================================================
74
75 const TopTools_ListOfShape& BRepBuilderAPI_GTransform_21423::Modified
76   (const TopoDS_Shape& F)
77 {
78   myGenerated.Clear();
79   const TopTools_DataMapOfShapeListOfShape& M = myHist.Modification();
80   if (M.IsBound(F)) { 
81     TopTools_ListOfShape Li;
82     TopTools_ListIteratorOfListOfShape itL(M(F));
83     for (;itL.More();itL.Next())
84       Li.Assign(BRepBuilderAPI_ModifyShape_21423::Modified(itL.Value()));
85   }
86   return myGenerated;
87 }
88
89
90 //=======================================================================
91 //function : ModifiedShape
92 //purpose  : 
93 //=======================================================================
94
95 const TopoDS_Shape& BRepBuilderAPI_GTransform_21423::ModifiedShape
96   (const TopoDS_Shape& S) const
97 {
98   const TopTools_DataMapOfShapeListOfShape &aMapModif = myHist.Modification();
99   TopoDS_Shape                              aShape    = S;
100
101   if (aMapModif.IsBound(S)) {
102     const TopTools_ListOfShape &aListModShape = aMapModif(S);
103     Standard_Integer            aNbShapes     = aListModShape.Extent();
104
105     if (aNbShapes > 0)
106       aShape = aListModShape.First();
107   }
108
109   return BRepBuilderAPI_ModifyShape_21423::ModifiedShape(aShape);
110 }
111