Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:10

0001 // Copyright (c) 2025 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _GeomFill_NetworkSurface_HeaderFile
0015 #define _GeomFill_NetworkSurface_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 #include <Standard_Handle.hxx>
0020 
0021 #include <Geom_BSplineCurve.hxx>
0022 #include <Geom_BSplineSurface.hxx>
0023 #include <NCollection_Array1.hxx>
0024 #include <NCollection_Array2.hxx>
0025 #include <gp_Pnt.hxx>
0026 
0027 //! Low-level Gordon surface construction from a compatible B-spline curve network.
0028 //!
0029 //! This class builds the final surface for an already prepared Gordon network:
0030 //! input curves must be explicit non-periodic B-spline curves, consistently
0031 //! ordered, and consistently reparametrized. Curve families are made compatible
0032 //! by the builder before skinning when they are polynomial.
0033 //!
0034 //! Profile skin, guide skin, and an intersection-grid reference surface are
0035 //! built in B-spline form and aligned to a common knot basis. The final surface
0036 //! is obtained by moving the profile-skin poles by the guide-skin deviation
0037 //! measured from this reference surface. No point-grid surface approximation is
0038 //! performed here.
0039 //!
0040 //! This class does not find curve intersections, sort the network, convert
0041 //! arbitrary curves, or reparametrize the input. These operations are handled
0042 //! by GeomFill_Gordon before calling this builder.
0043 //!
0044 //! Limitations:
0045 //! - Periodic input curves are not accepted; callers should expand a required
0046 //!   period before initialization.
0047 //! - Rational construction uses exact common-denominator multiplication and
0048 //!   can fail if the resulting product degree exceeds OCCT's B-spline degree
0049 //!   limit.
0050 //! - At least two profiles and two guides are required
0051 class GeomFill_NetworkSurface
0052 {
0053 public:
0054   DEFINE_STANDARD_ALLOC
0055 
0056   //! Result state of the last Perform() call.
0057   enum class ResultStatus
0058   {
0059     NotStarted,                 //!< Perform() has not been called since initialization.
0060     Done,                       //!< Surface has been constructed.
0061     InvalidInput,               //!< Prepared network does not satisfy builder requirements.
0062     CurveCompatibilityFailed,   //!< Curve families could not be converted to a compatible basis.
0063     SkinningFailed,             //!< Profile or guide skin interpolation has failed.
0064     ReferenceSurfaceFailed,     //!< Intersection-grid reference surface could not be built.
0065     KnotAlignmentFailed,        //!< Intermediate surfaces could not be aligned to one knot basis.
0066     RationalDegreeOverflow,     //!< Exact rational product degree exceeds OCCT's B-spline limit.
0067     RationalConstructionFailed, //!< Exact rational numerator/denominator construction has failed.
0068     ConstructionFailed,         //!< Internal B-spline construction has failed.
0069     PeriodicityFailed           //!< Closed seam could not be converted to periodic form.
0070   };
0071 
0072   //! Creates an empty network surface algorithm.
0073   Standard_EXPORT GeomFill_NetworkSurface();
0074 
0075   //! Initializes the algorithm with a compatible profile/guide B-spline network.
0076   //! @param[in] theProfiles          profile curves evaluated in U direction
0077   //! @param[in] theGuides            guide curves evaluated in V direction
0078   //! @param[in] theProfileParameters V parameters locating profiles on guide skin
0079   //! @param[in] theGuideParameters   U parameters locating guides on profile skin
0080   //! @param[in] theIntersectionPoints validated profile/guide contact grid
0081   //! @param[in] theIntersectionWeights rational weights for the contact grid
0082   //! @param[in] theTolerance         geometric tolerance for closed-seam checks
0083   //! @param[in] theIsUClosed         indicates that first/last guide curves close the U seam
0084   //! @param[in] theIsVClosed         indicates that first/last profile curves close the V seam
0085   Standard_EXPORT void Init(const NCollection_Array1<occ::handle<Geom_BSplineCurve>>& theProfiles,
0086                             const NCollection_Array1<occ::handle<Geom_BSplineCurve>>& theGuides,
0087                             const NCollection_Array1<double>& theProfileParameters,
0088                             const NCollection_Array1<double>& theGuideParameters,
0089                             const NCollection_Array2<gp_Pnt>& theIntersectionPoints,
0090                             const NCollection_Array2<double>& theIntersectionWeights,
0091                             double                            theTolerance,
0092                             bool                              theIsUClosed,
0093                             bool                              theIsVClosed);
0094 
0095   //! Performs the pole-based network surface construction.
0096   Standard_EXPORT void Perform();
0097 
0098   //! Returns true if the surface was successfully constructed.
0099   [[nodiscard]] bool IsDone() const { return myStatus == ResultStatus::Done; }
0100 
0101   //! Returns the result state of the last Perform() call.
0102   [[nodiscard]] ResultStatus Status() const { return myStatus; }
0103 
0104   //! Returns the constructed B-spline surface.
0105   //! @throws StdFail_NotDone if Perform() has not completed successfully.
0106   [[nodiscard]] Standard_EXPORT const occ::handle<Geom_BSplineSurface>& Surface() const;
0107 
0108 private:
0109   NCollection_Array1<occ::handle<Geom_BSplineCurve>> myProfiles;
0110   NCollection_Array1<occ::handle<Geom_BSplineCurve>> myGuides;
0111   NCollection_Array1<double>                         myProfileParameters;
0112   NCollection_Array1<double>                         myGuideParameters;
0113   NCollection_Array2<gp_Pnt>                         myIntersectionPoints;
0114   NCollection_Array2<double>                         myIntersectionWeights;
0115   occ::handle<Geom_BSplineSurface>                   mySurface;
0116   double                                             myTolerance = 0.0;
0117   bool                                               myIsUClosed = false;
0118   bool                                               myIsVClosed = false;
0119   ResultStatus                                       myStatus    = ResultStatus::NotStarted;
0120 };
0121 
0122 #endif // _GeomFill_NetworkSurface_HeaderFile