|
|
|||
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_Gordon_HeaderFile 0015 #define _GeomFill_Gordon_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 <Geom_Curve.hxx> 0024 #include <NCollection_Array1.hxx> 0025 #include <NCollection_Array2.hxx> 0026 0027 //! High-level Gordon surface construction from arbitrary curve networks. 0028 //! 0029 //! A Gordon surface (transfinite interpolation) constructs a smooth B-spline 0030 //! surface from a network of intersecting profile (V) and guide (U) curves. 0031 //! 0032 //! This generalizes the existing GeomFill_Coons (4-boundary patch) to N x M 0033 //! curve networks. 0034 //! 0035 //! This class accepts arbitrary Geom_Curve inputs, handles conversion to BSpline, 0036 //! expands periodic B-splines into explicit non-periodic form, finds intersections, 0037 //! sorts the network, reparametrizes curves for compatibility, then evaluates a 0038 //! transfinite interpolation surface over the compatible network. 0039 //! 0040 //! Usage: 0041 //! @code 0042 //! GeomFill_Gordon aGordon; 0043 //! aGordon.Init(theProfiles, theGuides, theTolerance); 0044 //! aGordon.Perform(); 0045 //! if (aGordon.IsDone()) 0046 //! { 0047 //! const occ::handle<Geom_BSplineSurface>& aSurf = aGordon.Surface(); 0048 //! } 0049 //! @endcode 0050 //! 0051 //! Limitations: 0052 //! - Every profile must intersect every guide. Multiple contacts are accepted 0053 //! only when they contain a single monotone branch over the ordered network. 0054 //! - Rational networks are combined by exact common-denominator multiplication. 0055 //! Construction can fail if the resulting product degree exceeds OCCT's 0056 //! B-spline degree limit. 0057 //! - ApproximationMode::AllowApproximateFallback may build a sampled surface 0058 //! when exact construction fails, or rebuild rational curves approximately 0059 //! when exact reparametrization is required. Such a surface is marked by 0060 //! IsApproximate() and does not guarantee exact interpolation of the input curves. 0061 class GeomFill_Gordon 0062 { 0063 public: 0064 DEFINE_STANDARD_ALLOC 0065 0066 //! Result state of the last Perform() call. 0067 enum class ResultStatus 0068 { 0069 NotStarted, //!< Perform() has not been called since initialization. 0070 Done, //!< Surface has been constructed. 0071 InvalidInput, //!< Input network has too few profile or guide curves. 0072 ConversionFailed, //!< Curves could not be converted/reparametrized to B-splines. 0073 IntersectionFailed, //!< Full profile/guide intersection table could not be built. 0074 OrderingFailed, //!< Network curves could not be ordered consistently. 0075 ReparametrizationFailed, //!< Intersections could not be equalized in parameter space. 0076 CompatibilityFailed, //!< Prepared network failed geometric compatibility checks. 0077 CurveCompatibilityFailed, //!< Prepared curve families are not B-spline compatible. 0078 RationalReparametrizationFailed, //!< Rational curves require unsupported exact 0079 //!< reparametrization. 0080 SkinningFailed, //!< Intermediate profile/guide skinning has failed. 0081 ReferenceSurfaceFailed, //!< Intersection-grid reference surface could not be built. 0082 KnotAlignmentFailed, //!< Intermediate surfaces could not be aligned. 0083 RationalDegreeOverflow, //!< Exact rational product degree exceeds OCCT's B-spline limit. 0084 RationalConstructionFailed, //!< Exact rational numerator/denominator construction has failed. 0085 PeriodicityFailed, //!< Closed seam could not be converted to periodic form. 0086 ApproximationFailed, //!< Optional approximate fallback has failed. 0087 ConstructionFailed //!< Final B-spline surface construction has failed. 0088 }; 0089 0090 //! Controls behavior when exact pole-based construction fails. 0091 enum class ApproximationMode 0092 { 0093 ExactOnly, //!< Report exact construction failure (default). 0094 AllowApproximateFallback //!< Try a sampled B-spline fallback without exact interpolation. 0095 }; 0096 0097 //! Construction stage reached by the last Perform() call. 0098 enum class BuildStage 0099 { 0100 NotStarted, //!< Perform() has not started. 0101 InputConversion, //!< Input curves are being converted to working B-splines. 0102 ContactDiscovery, //!< Profile/guide contacts are being collected. 0103 NetworkOrdering, //!< Contacts and curves are being ordered into a monotone network. 0104 Reparametrization, //!< Curves are being rebuilt to shared network parameters. 0105 ExactConstruction, //!< Exact B-spline network surface is being constructed. 0106 Validation, //!< Result is being checked against prepared curves. 0107 Approximation //!< Optional sampled fallback is being built. 0108 }; 0109 0110 //! Diagnostics for the last Perform() call. 0111 struct BuildReport 0112 { 0113 ResultStatus Status = ResultStatus::NotStarted; 0114 BuildStage FailedStage = BuildStage::NotStarted; 0115 bool IsApproximate = false; 0116 double MaxContactGap = 0.0; 0117 double MaxReparametrizationDeviation = 0.0; 0118 double MaxProfileDeviation = 0.0; 0119 double MaxGuideDeviation = 0.0; 0120 double MaxApproximationDeviation = 0.0; 0121 }; 0122 0123 //! Creates an empty Gordon surface algorithm. 0124 Standard_EXPORT GeomFill_Gordon(); 0125 0126 //! Initializes the algorithm with profile and guide curves. 0127 //! @param[in] theProfiles array of profile curves (V-direction sections, must be >= 2) 0128 //! @param[in] theGuides array of guide curves (U-direction sections, must be >= 2) 0129 //! @param[in] theTolerance geometric tolerance for intersection detection 0130 Standard_EXPORT void Init(const NCollection_Array1<occ::handle<Geom_Curve>>& theProfiles, 0131 const NCollection_Array1<occ::handle<Geom_Curve>>& theGuides, 0132 double theTolerance); 0133 0134 //! Performs the Gordon surface construction. 0135 Standard_EXPORT void Perform(); 0136 0137 //! Enables/disables parallel processing in internal stages. 0138 //! By default, single-thread mode is used. 0139 void SetParallelMode(bool theToUseParallel) { myToUseParallel = theToUseParallel; } 0140 0141 //! Sets optional fallback behavior for failures in exact B-spline construction. 0142 //! Approximate fallback results should be checked by IsApproximate(). 0143 void SetApproximationMode(ApproximationMode theMode) { myApproximationMode = theMode; } 0144 0145 //! Returns current fallback behavior. 0146 [[nodiscard]] ApproximationMode GetApproximationMode() const { return myApproximationMode; } 0147 0148 //! Returns true if internal parallel processing is enabled. 0149 [[nodiscard]] bool IsParallelMode() const { return myToUseParallel; } 0150 0151 //! Returns true if the surface was successfully constructed. 0152 [[nodiscard]] bool IsDone() const { return myReport.Status == ResultStatus::Done; } 0153 0154 //! Returns true if the resulting surface was produced by approximate fallback. 0155 //! Approximate results do not have the exact Gordon interpolation guarantee. 0156 [[nodiscard]] bool IsApproximate() const { return myReport.IsApproximate; } 0157 0158 //! Returns the result state of the last Perform() call. 0159 [[nodiscard]] ResultStatus Status() const { return myReport.Status; } 0160 0161 //! Returns diagnostics for the last Perform() call. 0162 [[nodiscard]] const BuildReport& Report() const { return myReport; } 0163 0164 //! Returns the resulting Gordon B-spline surface. 0165 [[nodiscard]] Standard_EXPORT const occ::handle<Geom_BSplineSurface>& Surface() const; 0166 0167 private: 0168 NCollection_Array1<occ::handle<Geom_BSplineCurve>> myInputProfiles; 0169 NCollection_Array1<occ::handle<Geom_BSplineCurve>> myInputGuides; 0170 NCollection_Array1<occ::handle<Geom_BSplineCurve>> myProfiles; 0171 NCollection_Array1<occ::handle<Geom_BSplineCurve>> myGuides; 0172 NCollection_Array2<double> myProfileParams; 0173 NCollection_Array2<double> myGuideParams; 0174 occ::handle<Geom_BSplineSurface> mySurface; 0175 double myTolerance = 0.0; 0176 bool myIsUClosed = false; 0177 bool myIsVClosed = false; 0178 bool myToUseParallel = false; 0179 ApproximationMode myApproximationMode = ApproximationMode::ExactOnly; 0180 BuildReport myReport; 0181 }; 0182 0183 #endif // _GeomFill_Gordon_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|