1 // Created on: 1993-02-22 2 // Created by: Remi LEQUETTE 3 // Copyright (c) 1993-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 #ifndef _BRepAdaptor_Surface_HeaderFile 18 #define _BRepAdaptor_Surface_HeaderFile 19 20 #include <Adaptor3d_Surface.hxx> 21 #include <GeomAdaptor_Surface.hxx> 22 #include <GeomAbs_Shape.hxx> 23 #include <GeomAbs_SurfaceType.hxx> 24 #include <gp_Trsf.hxx> 25 #include <TColStd_Array1OfReal.hxx> 26 #include <TopoDS_Face.hxx> 27 28 class gp_Pnt; 29 class gp_Vec; 30 class gp_Pln; 31 class gp_Cylinder; 32 class gp_Cone; 33 class gp_Sphere; 34 class gp_Torus; 35 class Geom_BezierSurface; 36 class Geom_BSplineSurface; 37 class gp_Ax1; 38 class gp_Dir; 39 40 DEFINE_STANDARD_HANDLE(BRepAdaptor_Surface, Adaptor3d_Surface) 41 42 //! The Surface from BRepAdaptor allows to use a Face 43 //! of the BRep topology look like a 3D surface. 44 //! 45 //! It has the methods of the class Surface from 46 //! Adaptor3d. 47 //! 48 //! It is created or initialized with a Face. It takes 49 //! into account the local coordinates system. 50 //! 51 //! The u,v parameter range is the minmax value for 52 //! the restriction, unless the flag restriction is 53 //! set to false. 54 class BRepAdaptor_Surface : public Adaptor3d_Surface 55 { 56 DEFINE_STANDARD_RTTIEXT(BRepAdaptor_Surface, Adaptor3d_Surface) 57 public: 58 59 //! Creates an undefined surface with no face loaded. 60 Standard_EXPORT BRepAdaptor_Surface(); 61 62 //! Creates a surface to access the geometry of <F>. 63 //! If <Restriction> is true the parameter range is 64 //! the parameter range in the UV space of the 65 //! restriction. 66 Standard_EXPORT BRepAdaptor_Surface(const TopoDS_Face& F, const Standard_Boolean R = Standard_True); 67 68 //! Shallow copy of adaptor 69 Standard_EXPORT virtual Handle(Adaptor3d_Surface) ShallowCopy() const Standard_OVERRIDE; 70 71 //! Sets the surface to the geometry of <F>. 72 Standard_EXPORT void Initialize (const TopoDS_Face& F, const Standard_Boolean Restriction = Standard_True); 73 74 //! Returns the surface. 75 Standard_EXPORT const GeomAdaptor_Surface& Surface() const; 76 77 //! Returns the surface. 78 Standard_EXPORT GeomAdaptor_Surface& ChangeSurface(); 79 80 //! Returns the surface coordinate system. 81 Standard_EXPORT const gp_Trsf& Trsf() const; 82 83 //! Returns the face. 84 Standard_EXPORT const TopoDS_Face& Face() const; 85 86 //! Returns the face tolerance. 87 Standard_EXPORT Standard_Real Tolerance() const; 88 FirstUParameter() const89 virtual Standard_Real FirstUParameter() const Standard_OVERRIDE { return mySurf.FirstUParameter(); } 90 LastUParameter() const91 virtual Standard_Real LastUParameter() const Standard_OVERRIDE { return mySurf.LastUParameter(); } 92 FirstVParameter() const93 virtual Standard_Real FirstVParameter() const Standard_OVERRIDE { return mySurf.FirstVParameter(); } 94 LastVParameter() const95 virtual Standard_Real LastVParameter() const Standard_OVERRIDE { return mySurf.LastVParameter(); } 96 UContinuity() const97 virtual GeomAbs_Shape UContinuity() const Standard_OVERRIDE { return mySurf.UContinuity(); } 98 VContinuity() const99 virtual GeomAbs_Shape VContinuity() const Standard_OVERRIDE { return mySurf.VContinuity(); } 100 101 //! If necessary, breaks the surface in U intervals of 102 //! continuity <S>. And returns the number of 103 //! intervals. NbUIntervals(const GeomAbs_Shape theSh) const104 virtual Standard_Integer NbUIntervals (const GeomAbs_Shape theSh) const Standard_OVERRIDE { return mySurf.NbUIntervals (theSh); } 105 106 //! If necessary, breaks the surface in V intervals of 107 //! continuity <S>. And returns the number of 108 //! intervals. NbVIntervals(const GeomAbs_Shape theSh) const109 virtual Standard_Integer NbVIntervals (const GeomAbs_Shape theSh) const Standard_OVERRIDE { return mySurf.NbVIntervals (theSh); } 110 111 //! Returns the intervals with the requested continuity 112 //! in the U direction. 113 Standard_EXPORT void UIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; 114 115 //! Returns the intervals with the requested continuity 116 //! in the V direction. 117 Standard_EXPORT void VIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const Standard_OVERRIDE; 118 119 //! Returns a surface trimmed in the U direction 120 //! equivalent of <me> between 121 //! parameters <First> and <Last>. <Tol> is used to 122 //! test for 3d points confusion. 123 //! If <First> >= <Last> 124 Standard_EXPORT Handle(Adaptor3d_Surface) UTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; 125 126 //! Returns a surface trimmed in the V direction between 127 //! parameters <First> and <Last>. <Tol> is used to 128 //! test for 3d points confusion. 129 //! If <First> >= <Last> 130 Standard_EXPORT Handle(Adaptor3d_Surface) VTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const Standard_OVERRIDE; 131 IsUClosed() const132 virtual Standard_Boolean IsUClosed() const Standard_OVERRIDE { return mySurf.IsUClosed(); } 133 IsVClosed() const134 virtual Standard_Boolean IsVClosed() const Standard_OVERRIDE { return mySurf.IsVClosed(); } 135 IsUPeriodic() const136 virtual Standard_Boolean IsUPeriodic() const Standard_OVERRIDE { return mySurf.IsUPeriodic(); } 137 UPeriod() const138 virtual Standard_Real UPeriod() const Standard_OVERRIDE { return mySurf.UPeriod(); } 139 IsVPeriodic() const140 virtual Standard_Boolean IsVPeriodic() const Standard_OVERRIDE { return mySurf.IsVPeriodic(); } 141 VPeriod() const142 virtual Standard_Real VPeriod() const Standard_OVERRIDE { return mySurf.VPeriod(); } 143 144 //! Computes the point of parameters U,V on the surface. 145 Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const Standard_OVERRIDE; 146 147 //! Computes the point of parameters U,V on the surface. 148 Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE; 149 150 //! Computes the point and the first derivatives on 151 //! the surface. 152 //! Raised if the continuity of the current 153 //! intervals is not C1. 154 Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE; 155 156 //! Computes the point, the first and second 157 //! derivatives on the surface. 158 //! Raised if the continuity of the current 159 //! intervals is not C2. 160 Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const Standard_OVERRIDE; 161 162 //! Computes the point, the first, second and third 163 //! derivatives on the surface. 164 //! Raised if the continuity of the current 165 //! intervals is not C3. 166 Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const Standard_OVERRIDE; 167 168 //! Computes the derivative of order Nu in the direction 169 //! U and Nv in the direction V at the point P(U, V). 170 //! Raised if the current U interval is not not CNu 171 //! and the current V interval is not CNv. 172 //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. 173 Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE; 174 175 //! Returns the parametric U resolution corresponding 176 //! to the real space resolution <R3d>. UResolution(const Standard_Real theR3d) const177 virtual Standard_Real UResolution (const Standard_Real theR3d) const Standard_OVERRIDE { return mySurf.UResolution (theR3d); } 178 179 //! Returns the parametric V resolution corresponding 180 //! to the real space resolution <R3d>. VResolution(const Standard_Real theR3d) const181 virtual Standard_Real VResolution (const Standard_Real theR3d) const Standard_OVERRIDE { return mySurf.VResolution (theR3d); } 182 183 //! Returns the type of the surface : Plane, Cylinder, 184 //! Cone, Sphere, Torus, BezierSurface, 185 //! BSplineSurface, SurfaceOfRevolution, 186 //! SurfaceOfExtrusion, OtherSurface GetType() const187 virtual GeomAbs_SurfaceType GetType() const Standard_OVERRIDE { return mySurf.GetType(); } 188 189 Standard_EXPORT gp_Pln Plane() const Standard_OVERRIDE; 190 191 Standard_EXPORT gp_Cylinder Cylinder() const Standard_OVERRIDE; 192 193 Standard_EXPORT gp_Cone Cone() const Standard_OVERRIDE; 194 195 Standard_EXPORT gp_Sphere Sphere() const Standard_OVERRIDE; 196 197 Standard_EXPORT gp_Torus Torus() const Standard_OVERRIDE; 198 UDegree() const199 virtual Standard_Integer UDegree() const Standard_OVERRIDE { return mySurf.UDegree(); } 200 NbUPoles() const201 virtual Standard_Integer NbUPoles() const Standard_OVERRIDE { return mySurf.NbUPoles(); } 202 VDegree() const203 virtual Standard_Integer VDegree() const Standard_OVERRIDE { return mySurf.VDegree(); } 204 NbVPoles() const205 virtual Standard_Integer NbVPoles() const Standard_OVERRIDE { return mySurf.NbVPoles(); } 206 NbUKnots() const207 virtual Standard_Integer NbUKnots() const Standard_OVERRIDE { return mySurf.NbUKnots(); } 208 NbVKnots() const209 virtual Standard_Integer NbVKnots() const Standard_OVERRIDE { return mySurf.NbVKnots(); } 210 IsURational() const211 virtual Standard_Boolean IsURational() const Standard_OVERRIDE { return mySurf.IsURational(); } 212 IsVRational() const213 virtual Standard_Boolean IsVRational() const Standard_OVERRIDE { return mySurf.IsVRational(); } 214 215 Standard_EXPORT Handle(Geom_BezierSurface) Bezier() const Standard_OVERRIDE; 216 217 //! Warning : this will make a copy of the 218 //! BSpline Surface since it applies 219 //! to it the myTsrf transformation 220 //! Be Careful when using this method 221 Standard_EXPORT Handle(Geom_BSplineSurface) BSpline() const Standard_OVERRIDE; 222 223 Standard_EXPORT gp_Ax1 AxeOfRevolution() const Standard_OVERRIDE; 224 225 Standard_EXPORT gp_Dir Direction() const Standard_OVERRIDE; 226 227 //! only for SurfaceOfExtrusion and SurfaceOfRevolution 228 //! Warning: this will make a copy of the underlying curve 229 //! since it applies to it the transformation 230 //! myTrsf. Be careful when using this method. 231 Standard_EXPORT Handle(Adaptor3d_Curve) BasisCurve() const Standard_OVERRIDE; 232 233 Standard_EXPORT Handle(Adaptor3d_Surface) BasisSurface() const Standard_OVERRIDE; 234 235 Standard_EXPORT Standard_Real OffsetValue() const Standard_OVERRIDE; 236 237 private: 238 239 GeomAdaptor_Surface mySurf; 240 gp_Trsf myTrsf; 241 TopoDS_Face myFace; 242 243 }; 244 245 #endif // _BRepAdaptor_Surface_HeaderFile 246