Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-12 08:47:37

0001 // Created on: 1999-04-27
0002 // Created by: Andrey BETENEV
0003 // Copyright (c) 1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _ShapeExtend_CompositeSurface_HeaderFile
0018 #define _ShapeExtend_CompositeSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TColGeom_HArray2OfSurface.hxx>
0024 #include <TColStd_HArray1OfReal.hxx>
0025 #include <Geom_Surface.hxx>
0026 #include <ShapeExtend_Parametrisation.hxx>
0027 #include <TColStd_Array1OfReal.hxx>
0028 #include <Standard_Integer.hxx>
0029 #include <GeomAbs_Shape.hxx>
0030 class gp_Pnt2d;
0031 class gp_Trsf2d;
0032 class gp_Trsf;
0033 class Geom_Geometry;
0034 class Geom_Curve;
0035 class gp_Pnt;
0036 class gp_Vec;
0037 
0038 class ShapeExtend_CompositeSurface;
0039 DEFINE_STANDARD_HANDLE(ShapeExtend_CompositeSurface, Geom_Surface)
0040 
0041 //! Composite surface is represented by a grid of surfaces
0042 //! (patches) connected geometrically. Patches may have different
0043 //! parametrisation ranges, but they should be parametrised in
0044 //! the same manner so that parameter of each patch (u,v) can be converted
0045 //! to global parameter on the whole surface (U,V) with help of linear
0046 //! transformation:
0047 //!
0048 //! for any i,j-th patch
0049 //! U = Ui + ( u - uijmin ) * ( Ui+1 - Ui ) / ( uijmax - uijmin )
0050 //! V = Vj + ( v - vijmin ) * ( Vj+1 - Vj ) / ( vijmax - vijmin )
0051 //!
0052 //! where
0053 //!
0054 //! [uijmin, uijmax] * [ vijmin, vijmax] - parametric range of i,j-th patch,
0055 //!
0056 //! Ui (i=1,..,Nu+1), Vi (j=1,..,Nv+1) - values defining global
0057 //! parametrisation by U and V (correspond to points between patches and
0058 //! bounds, (Ui,Uj) corresponds to (uijmin,vijmin) on i,j-th patch) and to
0059 //! (u(i-1)(j-1)max,v(i-1)(j-1)max) on (i-1),(j-1)-th patch.
0060 //!
0061 //! Geometrical connectivity is expressed via global parameters:
0062 //! S[i,j](Ui+1,V) = S[i+1,j](Ui+1,V) for any i, j, V
0063 //! S[i,j](U,Vj+1) = S[i,j+1](U,Vj+1) for any i, j, U
0064 //! It is checked with Precision::Confusion() by default.
0065 //!
0066 //! NOTE 1: This class is inherited from Geom_Surface in order to
0067 //! make it more easy to store and deal with it. However, it should
0068 //! not be passed to standard methods dealing with geometry since
0069 //! this type is not known to them.
0070 //! NOTE 2: Not all the inherited methods are implemented, and some are
0071 //! implemented not in the full form.
0072 class ShapeExtend_CompositeSurface : public Geom_Surface
0073 {
0074 
0075 public:
0076   //! Empty constructor.
0077   Standard_EXPORT ShapeExtend_CompositeSurface();
0078 
0079   //! Initializes by a grid of surfaces (calls Init()).
0080   Standard_EXPORT ShapeExtend_CompositeSurface(
0081     const Handle(TColGeom_HArray2OfSurface)& GridSurf,
0082     const ShapeExtend_Parametrisation        param = ShapeExtend_Natural);
0083 
0084   //! Initializes by a grid of surfaces (calls Init()).
0085   Standard_EXPORT ShapeExtend_CompositeSurface(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
0086                                                const TColStd_Array1OfReal&              UJoints,
0087                                                const TColStd_Array1OfReal&              VJoints);
0088 
0089   //! Initializes by a grid of surfaces.
0090   //! All the Surfaces of the grid must have geometrical
0091   //! connectivity as stated above.
0092   //! If geometrical connectivity is not satisfied, method
0093   //! returns False.
0094   //! However, class is initialized even in that case.
0095   //!
0096   //! Last parameter defines how global parametrisation
0097   //! (joint values) will be computed:
0098   //! ShapeExtend_Natural: U1 = u11min, Ui+1 = Ui + (ui1max-ui1min), etc.
0099   //! ShapeExtend_Uniform: Ui = i-1, Vj = j-1
0100   //! ShapeExtend_Unitary: Ui = (i-1)/Nu, Vi = (j-1)/Nv
0101   Standard_EXPORT Standard_Boolean
0102     Init(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
0103          const ShapeExtend_Parametrisation        param = ShapeExtend_Natural);
0104 
0105   //! Initializes by a grid of surfaces with given global
0106   //! parametrisation defined by UJoints and VJoints arrays,
0107   //! each having length equal to number of patches in corresponding
0108   //! direction + 1. Global joint values should be sorted in
0109   //! increasing order.
0110   //! All the Surfaces of the grid must have geometrical
0111   //! connectivity as stated above.
0112   //! If geometrical connectivity is not satisfied, method
0113   //! returns False.
0114   //! However, class is initialized even in that case.
0115   Standard_EXPORT Standard_Boolean Init(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
0116                                         const TColStd_Array1OfReal&              UJoints,
0117                                         const TColStd_Array1OfReal&              VJoints);
0118 
0119   //! Returns number of patches in U direction.
0120   Standard_EXPORT Standard_Integer NbUPatches() const;
0121 
0122   //! Returns number of patches in V direction.
0123   Standard_EXPORT Standard_Integer NbVPatches() const;
0124 
0125   //! Returns one surface patch
0126   Standard_EXPORT const Handle(Geom_Surface)& Patch(const Standard_Integer i,
0127                                                     const Standard_Integer j) const;
0128 
0129   //! Returns grid of surfaces
0130   Standard_EXPORT const Handle(TColGeom_HArray2OfSurface)& Patches() const;
0131 
0132   //! Returns the array of U values corresponding to joint
0133   //! points between patches as well as to start and end points,
0134   //! which define global parametrisation of the surface
0135   Standard_EXPORT Handle(TColStd_HArray1OfReal) UJointValues() const;
0136 
0137   //! Returns the array of V values corresponding to joint
0138   //! points between patches as well as to start and end points,
0139   //! which define global parametrisation of the surface
0140   Standard_EXPORT Handle(TColStd_HArray1OfReal) VJointValues() const;
0141 
0142   //! Returns i-th joint value in U direction
0143   //! (1-st is global Umin, (NbUPatches()+1)-th is global Umax
0144   //! on the composite surface)
0145   Standard_EXPORT Standard_Real UJointValue(const Standard_Integer i) const;
0146 
0147   //! Returns j-th joint value in V direction
0148   //! (1-st is global Vmin, (NbVPatches()+1)-th is global Vmax
0149   //! on the composite surface)
0150   Standard_EXPORT Standard_Real VJointValue(const Standard_Integer j) const;
0151 
0152   //! Sets the array of U values corresponding to joint
0153   //! points, which define global parametrisation of the surface.
0154   //! Number of values in array should be equal to NbUPatches()+1.
0155   //! All the values should be sorted in increasing order.
0156   //! If this is not satisfied, does nothing and returns False.
0157   Standard_EXPORT Standard_Boolean SetUJointValues(const TColStd_Array1OfReal& UJoints);
0158 
0159   //! Sets the array of V values corresponding to joint
0160   //! points, which define global parametrisation of the surface
0161   //! Number of values in array should be equal to NbVPatches()+1.
0162   //! All the values should be sorted in increasing order.
0163   //! If this is not satisfied, does nothing and returns False.
0164   Standard_EXPORT Standard_Boolean SetVJointValues(const TColStd_Array1OfReal& VJoints);
0165 
0166   //! Changes starting value for global U parametrisation (all
0167   //! other joint values are shifted accordingly)
0168   Standard_EXPORT void SetUFirstValue(const Standard_Real UFirst);
0169 
0170   //! Changes starting value for global V parametrisation (all
0171   //! other joint values are shifted accordingly)
0172   Standard_EXPORT void SetVFirstValue(const Standard_Real VFirst);
0173 
0174   //! Returns number of col that contains given (global) parameter
0175   Standard_EXPORT Standard_Integer LocateUParameter(const Standard_Real U) const;
0176 
0177   //! Returns number of row that contains given (global) parameter
0178   Standard_EXPORT Standard_Integer LocateVParameter(const Standard_Real V) const;
0179 
0180   //! Returns number of row and col of surface that contains
0181   //! given point
0182   Standard_EXPORT void LocateUVPoint(const gp_Pnt2d&   pnt,
0183                                      Standard_Integer& i,
0184                                      Standard_Integer& j) const;
0185 
0186   //! Returns one surface patch that contains given (global) parameters
0187   Standard_EXPORT const Handle(Geom_Surface)& Patch(const Standard_Real U,
0188                                                     const Standard_Real V) const;
0189 
0190   //! Returns one surface patch that contains given point
0191   Standard_EXPORT const Handle(Geom_Surface)& Patch(const gp_Pnt2d& pnt) const;
0192 
0193   //! Converts local parameter u on patch i,j to global parameter U
0194   Standard_EXPORT Standard_Real ULocalToGlobal(const Standard_Integer i,
0195                                                const Standard_Integer j,
0196                                                const Standard_Real    u) const;
0197 
0198   //! Converts local parameter v on patch i,j to global parameter V
0199   Standard_EXPORT Standard_Real VLocalToGlobal(const Standard_Integer i,
0200                                                const Standard_Integer j,
0201                                                const Standard_Real    v) const;
0202 
0203   //! Converts local parameters uv on patch i,j to global parameters UV
0204   Standard_EXPORT gp_Pnt2d LocalToGlobal(const Standard_Integer i,
0205                                          const Standard_Integer j,
0206                                          const gp_Pnt2d&        uv) const;
0207 
0208   //! Converts global parameter U to local parameter u on patch i,j
0209   Standard_EXPORT Standard_Real UGlobalToLocal(const Standard_Integer i,
0210                                                const Standard_Integer j,
0211                                                const Standard_Real    U) const;
0212 
0213   //! Converts global parameter V to local parameter v on patch i,j
0214   Standard_EXPORT Standard_Real VGlobalToLocal(const Standard_Integer i,
0215                                                const Standard_Integer j,
0216                                                const Standard_Real    V) const;
0217 
0218   //! Converts global parameters UV to local parameters uv on patch i,j
0219   Standard_EXPORT gp_Pnt2d GlobalToLocal(const Standard_Integer i,
0220                                          const Standard_Integer j,
0221                                          const gp_Pnt2d&        UV) const;
0222 
0223   //! Computes transformation operator and uFactor descrinbing affine
0224   //! transformation required to convert global parameters on composite
0225   //! surface to local parameters on patch (i,j):
0226   //! uv = ( uFactor, 1. ) X Trsf * UV;
0227   //! NOTE: Thus Trsf contains shift and scale by V, scale by U is stored in uFact.
0228   //! Returns True if transformation is not an identity
0229   Standard_EXPORT Standard_Boolean GlobalToLocalTransformation(const Standard_Integer i,
0230                                                                const Standard_Integer j,
0231                                                                Standard_Real&         uFact,
0232                                                                gp_Trsf2d&             Trsf) const;
0233 
0234   //! Applies transformation to all the patches
0235   Standard_EXPORT virtual void Transform(const gp_Trsf& T) Standard_OVERRIDE;
0236 
0237   //! Returns a copy of the surface
0238   Standard_EXPORT virtual Handle(Geom_Geometry) Copy() const Standard_OVERRIDE;
0239 
0240   //! NOT IMPLEMENTED (does nothing)
0241   Standard_EXPORT virtual void UReverse() Standard_OVERRIDE;
0242 
0243   //! Returns U
0244   Standard_EXPORT virtual Standard_Real UReversedParameter(const Standard_Real U) const
0245     Standard_OVERRIDE;
0246 
0247   //! NOT IMPLEMENTED (does nothing)
0248   Standard_EXPORT virtual void VReverse() Standard_OVERRIDE;
0249 
0250   //! Returns V
0251   Standard_EXPORT virtual Standard_Real VReversedParameter(const Standard_Real V) const
0252     Standard_OVERRIDE;
0253 
0254   //! Returns the parametric bounds of grid
0255   Standard_EXPORT virtual void Bounds(Standard_Real& U1,
0256                                       Standard_Real& U2,
0257                                       Standard_Real& V1,
0258                                       Standard_Real& V2) const Standard_OVERRIDE;
0259 
0260   //! Returns True if grid is closed in U direction
0261   //! (i.e. connected with Precision::Confusion)
0262   Standard_EXPORT virtual Standard_Boolean IsUClosed() const Standard_OVERRIDE;
0263 
0264   //! Returns True if grid is closed in V direction
0265   //! (i.e. connected with Precision::Confusion)
0266   Standard_EXPORT virtual Standard_Boolean IsVClosed() const Standard_OVERRIDE;
0267 
0268   //! Returns False
0269   Standard_EXPORT virtual Standard_Boolean IsUPeriodic() const Standard_OVERRIDE;
0270 
0271   //! Returns False
0272   Standard_EXPORT virtual Standard_Boolean IsVPeriodic() const Standard_OVERRIDE;
0273 
0274   //! NOT IMPLEMENTED (returns Null curve)
0275   Standard_EXPORT virtual Handle(Geom_Curve) UIso(const Standard_Real U) const Standard_OVERRIDE;
0276 
0277   //! NOT IMPLEMENTED (returns Null curve)
0278   Standard_EXPORT virtual Handle(Geom_Curve) VIso(const Standard_Real V) const Standard_OVERRIDE;
0279 
0280   //! returns C0
0281   Standard_EXPORT virtual GeomAbs_Shape Continuity() const Standard_OVERRIDE;
0282 
0283   //! returns True if N <=0
0284   Standard_EXPORT virtual Standard_Boolean IsCNu(const Standard_Integer N) const Standard_OVERRIDE;
0285 
0286   //! returns True if N <=0
0287   Standard_EXPORT virtual Standard_Boolean IsCNv(const Standard_Integer N) const Standard_OVERRIDE;
0288 
0289   //! Computes the point of parameter U,V on the grid.
0290   Standard_EXPORT virtual void D0(const Standard_Real U,
0291                                   const Standard_Real V,
0292                                   gp_Pnt&             P) const Standard_OVERRIDE;
0293 
0294   //! Computes the point P and the first derivatives in the
0295   //! directions U and V at this point.
0296   Standard_EXPORT virtual void D1(const Standard_Real U,
0297                                   const Standard_Real V,
0298                                   gp_Pnt&             P,
0299                                   gp_Vec&             D1U,
0300                                   gp_Vec&             D1V) const Standard_OVERRIDE;
0301 
0302   //! Computes the point P, the first and the second derivatives in
0303   //! the directions U and V at this point.
0304   Standard_EXPORT virtual void D2(const Standard_Real U,
0305                                   const Standard_Real V,
0306                                   gp_Pnt&             P,
0307                                   gp_Vec&             D1U,
0308                                   gp_Vec&             D1V,
0309                                   gp_Vec&             D2U,
0310                                   gp_Vec&             D2V,
0311                                   gp_Vec&             D2UV) const Standard_OVERRIDE;
0312 
0313   //! Computes the point P, the first,the second and the third
0314   //! derivatives in the directions U and V at this point.
0315   Standard_EXPORT virtual void D3(const Standard_Real U,
0316                                   const Standard_Real V,
0317                                   gp_Pnt&             P,
0318                                   gp_Vec&             D1U,
0319                                   gp_Vec&             D1V,
0320                                   gp_Vec&             D2U,
0321                                   gp_Vec&             D2V,
0322                                   gp_Vec&             D2UV,
0323                                   gp_Vec&             D3U,
0324                                   gp_Vec&             D3V,
0325                                   gp_Vec&             D3UUV,
0326                                   gp_Vec&             D3UVV) const Standard_OVERRIDE;
0327 
0328   //! Computes the derivative of order Nu in the direction U and Nv
0329   //! in the direction V at the point P(U, V).
0330   Standard_EXPORT virtual gp_Vec DN(const Standard_Real    U,
0331                                     const Standard_Real    V,
0332                                     const Standard_Integer Nu,
0333                                     const Standard_Integer Nv) const Standard_OVERRIDE;
0334 
0335   //! Computes the point of parameter pnt on the grid.
0336   Standard_EXPORT gp_Pnt Value(const gp_Pnt2d& pnt) const;
0337 
0338   //! Computes Joint values according to parameter
0339   Standard_EXPORT void ComputeJointValues(
0340     const ShapeExtend_Parametrisation param = ShapeExtend_Natural);
0341 
0342   //! Checks geometrical connectivity of the patches, including
0343   //! closedness (sets fields muUClosed and myVClosed)
0344   Standard_EXPORT Standard_Boolean CheckConnectivity(const Standard_Real prec);
0345 
0346   DEFINE_STANDARD_RTTIEXT(ShapeExtend_CompositeSurface, Geom_Surface)
0347 
0348 protected:
0349 private:
0350   Handle(TColGeom_HArray2OfSurface) myPatches;
0351   Handle(TColStd_HArray1OfReal)     myUJointValues;
0352   Handle(TColStd_HArray1OfReal)     myVJointValues;
0353   Standard_Boolean                  myUClosed;
0354   Standard_Boolean                  myVClosed;
0355 };
0356 
0357 #endif // _ShapeExtend_CompositeSurface_HeaderFile