0024624: Lost word in license statement in source files
[occt.git] / src / BRepBuilderAPI / BRepBuilderAPI_Copy.cxx
CommitLineData
b311480e 1// Created on: 1994-12-12
2// Created by: Jacques GOUSSARD
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <BRepBuilderAPI_Copy.ixx>
18
19#include <Geom_Surface.hxx>
20#include <Geom_Curve.hxx>
21#include <Geom2d_Curve.hxx>
22#include <BRepTools_Modification.hxx>
23#include <BRep_Tool.hxx>
24#include <TopoDS_Vertex.hxx>
25#include <gp_Pnt.hxx>
26
27//! Tool class implementing necessary functionality for copying geometry
28class BRepBuilderAPI_Copy_Modification : public BRepTools_Modification
29{
30public:
31 BRepBuilderAPI_Copy_Modification (const Standard_Boolean copyGeom)
32 : myCopyGeom(copyGeom)
33 {
34 }
35
36 //! Returns true to indicate the need to copy face;
37 //! copies surface if requested
38 Standard_Boolean NewSurface (const TopoDS_Face& F, Handle(Geom_Surface)& S,
39 TopLoc_Location& L, Standard_Real& Tol,
40 Standard_Boolean& RevWires, Standard_Boolean& RevFace)
41 {
42 S = BRep_Tool::Surface(F,L);
43 Tol = BRep_Tool::Tolerance(F);
44 RevWires = RevFace = Standard_False;
45
46 if ( ! S.IsNull() && myCopyGeom )
47 S = Handle(Geom_Surface)::DownCast(S->Copy());
48
49 return Standard_True;
50 }
51
52 //! Returns true to indicate the need to copy edge;
53 //! copies curves if requested
54 Standard_Boolean NewCurve (const TopoDS_Edge& E, Handle(Geom_Curve)& C,
55 TopLoc_Location& L, Standard_Real& Tol)
56 {
57 Standard_Real f,l;
58 C = BRep_Tool::Curve (E, L, f, l);
59 Tol = BRep_Tool::Tolerance(E);
60
61 if ( ! C.IsNull() && myCopyGeom )
62 C = Handle(Geom_Curve)::DownCast(C->Copy());
63
64 return Standard_True;
65 }
66
67 //! Returns true to indicate the need to copy vertex
68 Standard_Boolean NewPoint (const TopoDS_Vertex& V, gp_Pnt& P,
69 Standard_Real& Tol)
70 {
71 P = BRep_Tool::Pnt(V);
72 Tol = BRep_Tool::Tolerance(V);
73 return Standard_True;
74 }
75
76 //! Returns true to indicate the need to copy edge;
77 //! copies pcurve if requested
35e08fe8 78 Standard_Boolean NewCurve2d (const TopoDS_Edge& E,
79 const TopoDS_Face& F,
80 const TopoDS_Edge& /*NewE*/,
81 const TopoDS_Face& /*NewF*/,
82 Handle(Geom2d_Curve)& C,
83 Standard_Real& Tol)
7fd59977 84 {
85 Tol = BRep_Tool::Tolerance(E);
86 Standard_Real f, l;
87 C = BRep_Tool::CurveOnSurface (E, F, f, l);
88
89 if ( ! C.IsNull() && myCopyGeom )
90 C = Handle(Geom2d_Curve)::DownCast (C->Copy());
91
92 return Standard_True;
93 }
94
95 //! Returns true to indicate the need to copy vertex
96 Standard_Boolean NewParameter (const TopoDS_Vertex& V, const TopoDS_Edge& E,
97 Standard_Real& P, Standard_Real& Tol)
98 {
99 if (V.IsNull()) return Standard_False; // infinite edge may have Null vertex
100
101 Tol = BRep_Tool::Tolerance(V);
102 P = BRep_Tool::Parameter (V, E);
103
104 return Standard_True;
105 }
106
107 //! Returns the continuity of E between F1 and F2
108 GeomAbs_Shape Continuity (const TopoDS_Edge& E, const TopoDS_Face& F1,
109 const TopoDS_Face& F2, const TopoDS_Edge&,
110 const TopoDS_Face&, const TopoDS_Face&)
111 {
112 return BRep_Tool::Continuity (E, F1, F2);
113 }
114
115public:
116 DEFINE_STANDARD_RTTI(BRepBuilderAPI_Copy_Modification)
117
118private:
119 Standard_Boolean myCopyGeom;
120};
121
122DEFINE_STANDARD_HANDLE(BRepBuilderAPI_Copy_Modification, BRepTools_Modification)
123IMPLEMENT_STANDARD_HANDLE(BRepBuilderAPI_Copy_Modification, BRepTools_Modification)
124
125IMPLEMENT_STANDARD_RTTIEXT(BRepBuilderAPI_Copy_Modification, BRepTools_Modification)
126
127//=======================================================================
128//function : BRepBuilderAPI_Copy
129//purpose :
130//=======================================================================
131
132BRepBuilderAPI_Copy::BRepBuilderAPI_Copy ()
133{
134 myModification = new BRepBuilderAPI_Copy_Modification(Standard_True);
135}
136
137
138//=======================================================================
139//function : BRepBuilderAPI_Copy
140//purpose :
141//=======================================================================
142
143BRepBuilderAPI_Copy::BRepBuilderAPI_Copy(const TopoDS_Shape& S, const Standard_Boolean copyGeom)
144{
145 myModification = new BRepBuilderAPI_Copy_Modification(copyGeom);
146 DoModif(S);
147}
148
149
150//=======================================================================
151//function : Perform
152//purpose :
153//=======================================================================
154
155void BRepBuilderAPI_Copy::Perform(const TopoDS_Shape& S, const Standard_Boolean copyGeom)
156{
157 myModification = new BRepBuilderAPI_Copy_Modification(copyGeom);
158 NotDone(); // on force la copie si on vient deja d`en faire une
159 DoModif(S);
160}
161