Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-12 09:17:14

0001 // Created on: 1993-03-10
0002 // Created by: JCV
0003 // Copyright (c) 1993-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 _Geom_RectangularTrimmedSurface_HeaderFile
0018 #define _Geom_RectangularTrimmedSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <Geom_BoundedSurface.hxx>
0024 #include <GeomAbs_Shape.hxx>
0025 class Geom_Surface;
0026 class Geom_Curve;
0027 class gp_Trsf;
0028 class gp_GTrsf2d;
0029 class Geom_Geometry;
0030 
0031 //! Describes a portion of a surface (a patch) limited
0032 //! by two values of the u parameter in the u
0033 //! parametric direction, and two values of the v
0034 //! parameter in the v parametric direction. The
0035 //! domain of the trimmed surface must be within the
0036 //! domain of the surface being trimmed.
0037 //! The trimmed surface is defined by:
0038 //! - the basis surface, and
0039 //! - the values (umin, umax) and (vmin, vmax)
0040 //! which limit it in the u and v parametric directions.
0041 //! The trimmed surface is built from a copy of the basis
0042 //! surface. Therefore, when the basis surface is
0043 //! modified the trimmed surface is not changed.
0044 //! Consequently, the trimmed surface does not
0045 //! necessarily have the same orientation as the basis surface.
0046 //! Warning: The case of surface being trimmed is periodic and
0047 //! parametrics values are outside the domain is possible.
0048 //! But, domain of the trimmed surface can be translated
0049 //! by (n X) the period.
0050 class Geom_RectangularTrimmedSurface : public Geom_BoundedSurface
0051 {
0052 
0053 public:
0054   //! The U parametric direction of the surface is oriented from U1
0055   //! to U2. The V parametric direction of the surface is oriented
0056   //! from V1 to V2.
0057   //! These two directions define the orientation of the surface
0058   //! (normal). If the surface is not periodic USense and VSense are
0059   //! not used for the construction. If the surface S is periodic in
0060   //! one direction USense and VSense give the available part of the
0061   //! surface. By default in this case the surface has the same
0062   //! orientation as the basis surface S.
0063   //! The returned surface is not closed and not periodic.
0064   //! ConstructionError Raised if
0065   //! S is not periodic in the UDirection and U1 or U2 are out of the
0066   //! bounds of S.
0067   //! S is not periodic in the VDirection and V1 or V2 are out of the
0068   //! bounds of S.
0069   //! U1 = U2 or V1 = V2
0070   Standard_EXPORT Geom_RectangularTrimmedSurface(const occ::handle<Geom_Surface>& S,
0071                                                  const double                     U1,
0072                                                  const double                     U2,
0073                                                  const double                     V1,
0074                                                  const double                     V2,
0075                                                  const bool                       USense = true,
0076                                                  const bool                       VSense = true);
0077 
0078   //! The basis surface S is only trim in one parametric direction.
0079   //! If UTrim = True the surface is trimmed in the U parametric
0080   //! direction else the surface is trimmed in the V parametric
0081   //! direction.
0082   //! In the considered parametric direction the resulting surface is
0083   //! oriented from Param1 to Param2. If S is periodic Sense gives the
0084   //! available part of the surface. By default the trimmed surface has
0085   //! the same orientation as the basis surface S in the considered
0086   //! parametric direction (Sense = True).
0087   //! If the basis surface S is closed or periodic in the parametric
0088   //! direction opposite to the trimming direction the trimmed surface
0089   //! has the same characteristics as the surface S in this direction.
0090   //! Warnings :
0091   //! In this package the entities are not shared.
0092   //! The RectangularTrimmedSurface is built with a copy of the
0093   //! surface S. So when S is modified the RectangularTrimmedSurface
0094   //! is not modified
0095   //! Raised if
0096   //! S is not periodic in the considered parametric direction and
0097   //! Param1 or Param2 are out of the bounds of S.
0098   //! Param1 = Param2
0099   Standard_EXPORT Geom_RectangularTrimmedSurface(const occ::handle<Geom_Surface>& S,
0100                                                  const double                     Param1,
0101                                                  const double                     Param2,
0102                                                  const bool                       UTrim,
0103                                                  const bool                       Sense = true);
0104 
0105   //! Modifies this patch by changing the trim values
0106   //! applied to the original surface
0107   //! The u parametric direction of
0108   //! this patch is oriented from U1 to U2. The v
0109   //! parametric direction of this patch is oriented
0110   //! from V1 to V2. USense and VSense are used
0111   //! for the construction only if the surface is periodic
0112   //! in the corresponding parametric direction, and
0113   //! define the available part of the surface; by default
0114   //! in this case, this patch has the same orientation
0115   //! as the basis surface.
0116   //! Raised if
0117   //! The BasisSurface is not periodic in the UDirection and U1 or U2
0118   //! are out of the bounds of the BasisSurface.
0119   //! The BasisSurface is not periodic in the VDirection and V1 or V2
0120   //! are out of the bounds of the BasisSurface.
0121   //! U1 = U2 or V1 = V2
0122   Standard_EXPORT void SetTrim(const double U1,
0123                                const double U2,
0124                                const double V1,
0125                                const double V2,
0126                                const bool   USense = true,
0127                                const bool   VSense = true);
0128 
0129   //! Modifies this patch by changing the trim values
0130   //! applied to the original surface
0131   //! The basis surface is trimmed only in one parametric direction: if UTrim
0132   //! is true, the surface is trimmed in the u parametric
0133   //! direction; if it is false, it is trimmed in the v
0134   //! parametric direction. In the "trimmed" direction,
0135   //! this patch is oriented from Param1 to Param2. If
0136   //! the basis surface is periodic in the "trimmed"
0137   //! direction, Sense defines its available part. By
0138   //! default in this case, this patch has the same
0139   //! orientation as the basis surface in this parametric
0140   //! direction. If the basis surface is closed or periodic
0141   //! in the other parametric direction (i.e. not the
0142   //! "trimmed" direction), this patch has the same
0143   //! characteristics as the basis surface in that parametric direction.
0144   //! Raised if
0145   //! The BasisSurface is not periodic in the considered direction and
0146   //! Param1 or Param2 are out of the bounds of the BasisSurface.
0147   //! Param1 = Param2
0148   Standard_EXPORT void SetTrim(const double Param1,
0149                                const double Param2,
0150                                const bool   UTrim,
0151                                const bool   Sense = true);
0152 
0153   //! Returns the Basis surface of <me>.
0154   Standard_EXPORT occ::handle<Geom_Surface> BasisSurface() const;
0155 
0156   //! Changes the orientation of this patch in the u
0157   //! parametric direction. The bounds of the surface are
0158   //! not changed, but the given parametric direction is
0159   //! reversed. Hence the orientation of the surface is reversed.
0160   Standard_EXPORT void UReverse() final;
0161 
0162   //! Computes the u parameter on the modified
0163   //! surface, produced by when reversing its u
0164   //! parametric direction, for any point of u parameter U on this patch.
0165   Standard_EXPORT double UReversedParameter(const double U) const final;
0166 
0167   //! Changes the orientation of this patch in the v
0168   //! parametric direction. The bounds of the surface are
0169   //! not changed, but the given parametric direction is
0170   //! reversed. Hence the orientation of the surface is reversed.
0171   Standard_EXPORT void VReverse() final;
0172 
0173   //! Computes the v parameter on the modified
0174   //! surface, produced by when reversing its v
0175   //! parametric direction, for any point of v parameter V on this patch.
0176   Standard_EXPORT double VReversedParameter(const double V) const final;
0177 
0178   //! Returns the parametric bounds U1, U2, V1 and V2 of this patch.
0179   Standard_EXPORT void Bounds(double& U1, double& U2, double& V1, double& V2) const final;
0180 
0181   //! Returns the continuity of the surface :
0182   //! C0 : only geometric continuity,
0183   //! C1 : continuity of the first derivative all along the Surface,
0184   //! C2 : continuity of the second derivative all along the Surface,
0185   //! C3 : continuity of the third derivative all along the Surface,
0186   //! CN : the order of continuity is infinite.
0187   Standard_EXPORT GeomAbs_Shape Continuity() const final;
0188 
0189   //! Returns true if this patch is closed in U: either not trimmed in U
0190   //! and the basis surface is U-closed, or trimmed with a length that is
0191   //! an integer multiple of the U period of a U-periodic basis surface.
0192   Standard_EXPORT bool IsUClosed() const final;
0193 
0194   //! Returns true if this patch is closed in V: either not trimmed in V
0195   //! and the basis surface is V-closed, or trimmed with a length that is
0196   //! an integer multiple of the V period of a V-periodic basis surface.
0197   Standard_EXPORT bool IsVClosed() const final;
0198 
0199   //! Returns true if the order of derivation in the U parametric
0200   //! direction is N.
0201   //! Raised if N < 0.
0202   Standard_EXPORT bool IsCNu(const int N) const final;
0203 
0204   //! Returns true if the order of derivation in the V parametric
0205   //! direction is N.
0206   //! Raised if N < 0.
0207   Standard_EXPORT bool IsCNv(const int N) const final;
0208 
0209   //! Returns true if the basis surface is U-periodic and either not trimmed
0210   //! in U, or the trim spans an integer multiple of the U period.
0211   Standard_EXPORT bool IsUPeriodic() const final;
0212 
0213   //! Returns the period of this patch in the u
0214   //! parametric direction.
0215   //! raises if the surface is not uperiodic.
0216   Standard_EXPORT double UPeriod() const final;
0217 
0218   //! Returns true if the basis surface is V-periodic and either not trimmed
0219   //! in V, or the trim spans an integer multiple of the V period.
0220   Standard_EXPORT bool IsVPeriodic() const final;
0221 
0222   //! Returns the period of this patch in the v
0223   //! parametric direction.
0224   //! raises if the surface is not vperiodic.
0225   //! value and derivatives
0226   Standard_EXPORT double VPeriod() const final;
0227 
0228   //! computes the U isoparametric curve.
0229   Standard_EXPORT occ::handle<Geom_Curve> UIso(const double U) const final;
0230 
0231   //! Computes the V isoparametric curve.
0232   Standard_EXPORT occ::handle<Geom_Curve> VIso(const double V) const final;
0233 
0234   //! Computes the point of parameter (U, V) on the surface.
0235   //! Can be raised if the basis surface is an OffsetSurface.
0236   //! Raises an exception on failure.
0237   Standard_EXPORT gp_Pnt EvalD0(const double U, const double V) const final;
0238 
0239   //! Computes the point and first partial derivatives at (U, V).
0240   //! The returned derivatives have the same orientation as the
0241   //! derivatives of the basis surface even if the trimmed surface
0242   //! has not the same parametric orientation.
0243   //! Raises an exception if the surface continuity is not C1.
0244   Standard_EXPORT Geom_Surface::ResD1 EvalD1(const double U, const double V) const final;
0245 
0246   //! Computes the point and partial derivatives up to 2nd order at (U, V).
0247   //! The returned derivatives have the same orientation as the
0248   //! derivatives of the basis surface even if the trimmed surface
0249   //! has not the same parametric orientation.
0250   //! Raises an exception if the surface continuity is not C2.
0251   Standard_EXPORT Geom_Surface::ResD2 EvalD2(const double U, const double V) const final;
0252 
0253   //! Computes the point and partial derivatives up to 3rd order at (U, V).
0254   //! The returned derivatives have the same orientation as the
0255   //! derivatives of the basis surface even if the trimmed surface
0256   //! has not the same parametric orientation.
0257   //! Raises an exception if the surface continuity is not C3.
0258   Standard_EXPORT Geom_Surface::ResD3 EvalD3(const double U, const double V) const final;
0259 
0260   //! Computes the derivative of order Nu in U and Nv in V at (U, V).
0261   //! The returned derivative has the same orientation as the
0262   //! derivative of the basis surface even if the trimmed surface
0263   //! has not the same parametric orientation.
0264   //! Raises an exception on failure.
0265   //! RangeError Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0.
0266   Standard_EXPORT gp_Vec EvalDN(const double U,
0267                                 const double V,
0268                                 const int    Nu,
0269                                 const int    Nv) const final;
0270 
0271   //! Applies the transformation T to this patch.
0272   //! Warning
0273   //! As a consequence, the basis surface included in the
0274   //! data structure of this patch is also modified.
0275   Standard_EXPORT void Transform(const gp_Trsf& T) final;
0276 
0277   //! Computes the parameters on the transformed surface for
0278   //! the transform of the point of parameters U,V on <me>.
0279   //! @code
0280   //!   me->Transformed(T)->Value(U',V')
0281   //! @endcode
0282   //! is the same point as
0283   //! @code
0284   //!   me->Value(U,V).Transformed(T)
0285   //! @endcode
0286   //! Where U',V' are the new values of U,V after calling
0287   //! @code
0288   //!   me->TransformParameters(U,V,T)
0289   //! @endcode
0290   //! This method calls the basis surface method.
0291   Standard_EXPORT void TransformParameters(double& U, double& V, const gp_Trsf& T) const final;
0292 
0293   //! Returns a 2d transformation used to find the new
0294   //! parameters of a point on the transformed surface.
0295   //! @code
0296   //!   me->Transformed(T)->Value(U',V')
0297   //! @endcode
0298   //! is the same point as
0299   //! @code
0300   //!   me->Value(U,V).Transformed(T)
0301   //! @endcode
0302   //! Where U',V' are obtained by transforming U,V with
0303   //! the 2d transformation returned by
0304   //! @code
0305   //!   me->ParametricTransformation(T)
0306   //! @endcode
0307   //! This method calls the basis surface method.
0308   Standard_EXPORT gp_GTrsf2d ParametricTransformation(const gp_Trsf& T) const final;
0309 
0310   //! Creates a new object which is a copy of this patch.
0311   Standard_EXPORT occ::handle<Geom_Geometry> Copy() const final;
0312 
0313   //! Dumps the content of me into the stream
0314   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const final;
0315 
0316   DEFINE_STANDARD_RTTIEXT(Geom_RectangularTrimmedSurface, Geom_BoundedSurface)
0317 
0318 private:
0319   //! General set trim, to implement constructors and
0320   //! others set trim.
0321   Standard_EXPORT void SetTrim(const double U1,
0322                                const double U2,
0323                                const double V1,
0324                                const double V2,
0325                                const bool   UTrim,
0326                                const bool   VTrim,
0327                                const bool   USense,
0328                                const bool   VSense);
0329 
0330   occ::handle<Geom_Surface> basisSurf;
0331   double                    utrim1;
0332   double                    vtrim1;
0333   double                    utrim2;
0334   double                    vtrim2;
0335   bool                      isutrimmed;
0336   bool                      isvtrimmed;
0337 };
0338 
0339 #endif // _Geom_RectangularTrimmedSurface_HeaderFile