712a5325c67fe9b7ab5961fca350f23147d2f201
[occt.git] / src / BRepBuilderAPI / BRepBuilderAPI_GTransform.cxx
1 // Created on: 1996-12-30
2 // Created by: Stagiaire Mary FABIEN
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <BRepBuilderAPI_GTransform.ixx>
18
19 #include <TopTools_ListIteratorOfListOfShape.hxx>
20 #include <BRepTools_GTrsfModification.hxx>
21 #include <BRepTools_NurbsConvertModification.hxx>
22 #include <BRepBuilderAPI_NurbsConvert.hxx>
23 #include <gp.hxx>
24
25 #include <TopTools_ListOfShape.hxx>
26 #include <BRep_Builder.hxx>
27 #include <TopoDS.hxx>
28 //=======================================================================
29 //function : BRepBuilderAPI_GTransform
30 //purpose  : 
31 //=======================================================================
32
33 BRepBuilderAPI_GTransform::BRepBuilderAPI_GTransform (const gp_GTrsf& T) :
34   myGTrsf(T)
35 {
36   myModification = new BRepTools_GTrsfModification(T);
37 }
38
39
40 //=======================================================================
41 //function : BRepBuilderAPI_GTransform
42 //purpose  : 
43 //=======================================================================
44
45 BRepBuilderAPI_GTransform::BRepBuilderAPI_GTransform (const TopoDS_Shape& S,
46                                         const gp_GTrsf& T,
47                                         const Standard_Boolean Copy) :
48   myGTrsf(T)
49 {
50   myModification = new BRepTools_GTrsfModification(T);
51   Perform(S,Copy);
52 }
53
54
55
56 //=======================================================================
57 //function : Perform
58 //purpose  : 
59 //=======================================================================
60
61 void BRepBuilderAPI_GTransform::Perform(const TopoDS_Shape& S,
62                                  const Standard_Boolean Copy)
63 {
64   BRepBuilderAPI_NurbsConvert nc;
65   nc.Perform(S, Copy);
66   myHist.Add(S,nc);
67   TopoDS_Shape Slocal = nc.Shape();
68   Handle(BRepTools_GTrsfModification) theModif =
69     Handle(BRepTools_GTrsfModification)::DownCast(myModification);
70   theModif->GTrsf() = myGTrsf;
71   DoModif(Slocal,myModification);
72 //  myHist.Filter (Shape());
73 }
74
75
76 //=======================================================================
77 //function : Modified
78 //purpose  : 
79 //=======================================================================
80
81 const TopTools_ListOfShape& BRepBuilderAPI_GTransform::Modified
82   (const TopoDS_Shape& F)
83 {
84   myGenerated.Clear();
85   const TopTools_DataMapOfShapeListOfShape& M = myHist.Modification();
86   if (M.IsBound(F)) { 
87     TopTools_ListOfShape Li;
88     TopTools_ListIteratorOfListOfShape itL(M(F));
89     for (;itL.More();itL.Next())
90       Li.Assign(BRepBuilderAPI_ModifyShape::Modified(itL.Value()));
91   }
92   return myGenerated;
93 }
94
95
96 //=======================================================================
97 //function : ModifiedShape
98 //purpose  : 
99 //=======================================================================
100
101 const TopoDS_Shape& BRepBuilderAPI_GTransform::ModifiedShape
102   (const TopoDS_Shape& S) const
103 {
104   const TopTools_DataMapOfShapeListOfShape &aMapModif = myHist.Modification();
105   TopoDS_Shape                              aShape    = S;
106
107   if (aMapModif.IsBound(S)) {
108     const TopTools_ListOfShape &aListModShape = aMapModif(S);
109     Standard_Integer            aNbShapes     = aListModShape.Extent();
110
111     if (aNbShapes > 0)
112       aShape = aListModShape.First();
113   }
114
115   return BRepBuilderAPI_ModifyShape::ModifiedShape(aShape);
116 }
117