Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:17:38

0001 // Created on: 1995-10-13
0002 // Created by: Laurent BOURESCHE
0003 // Copyright (c) 1995-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 _GeomFill_ConstrainedFilling_HeaderFile
0018 #define _GeomFill_ConstrainedFilling_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Integer.hxx>
0025 #include <GeomFill_CornerState.hxx>
0026 #include <gp_Vec.hxx>
0027 #include <gp_Pnt.hxx>
0028 #include <NCollection_Array1.hxx>
0029 #include <NCollection_HArray1.hxx>
0030 #include <NCollection_Array2.hxx>
0031 #include <NCollection_HArray2.hxx>
0032 class GeomFill_CoonsAlgPatch;
0033 class GeomFill_TgtField;
0034 class Geom_BSplineSurface;
0035 class GeomFill_Boundary;
0036 class GeomFill_BoundWithSurf;
0037 
0038 //! An algorithm for constructing a BSpline surface filled
0039 //! from a series of boundaries which serve as path
0040 //! constraints and optionally, as tangency constraints.
0041 //! The algorithm accepts three or four curves as the
0042 //! boundaries of the target surface.
0043 //! The only FillingStyle used is Coons.
0044 //! A ConstrainedFilling object provides a framework for:
0045 //! -   defining the boundaries of the surface
0046 //! -   implementing the construction algorithm
0047 //! -   consulting the result.
0048 //! Warning
0049 //! This surface filling algorithm is specifically designed to
0050 //! be used in connection with fillets. Satisfactory results
0051 //! cannot be guaranteed for other uses.
0052 class GeomFill_ConstrainedFilling
0053 {
0054 public:
0055   DEFINE_STANDARD_ALLOC
0056 
0057   //! Constructs an empty framework for filling a surface from boundaries.
0058   //! The boundaries of the surface will be defined, and the
0059   //! surface will be built by using the function Init.
0060   //! The surface will respect the following constraints:
0061   //! -   its degree will not be greater than MaxDeg
0062   //! -   the maximum number of segments MaxSeg which
0063   //! BSpline surfaces can have.
0064   Standard_EXPORT GeomFill_ConstrainedFilling(const int MaxDeg, const int MaxSeg);
0065 
0066   Standard_EXPORT void Init(const occ::handle<GeomFill_Boundary>& B1,
0067                             const occ::handle<GeomFill_Boundary>& B2,
0068                             const occ::handle<GeomFill_Boundary>& B3,
0069                             const bool                            NoCheck = false);
0070 
0071   //! Constructs a BSpline surface filled from the series of
0072   //! boundaries B1, B2, B3 and, if need be, B4, which serve:
0073   //! -   as path constraints
0074   //! -   and optionally, as tangency constraints if they are
0075   //! GeomFill_BoundWithSurf curves.
0076   //! The boundaries may be given in any order: they are
0077   //! classified and if necessary, reversed and reparameterized.
0078   //! The surface will also respect the following constraints:
0079   //! -   its degree will not be greater than the maximum
0080   //! degree defined at the time of construction of this framework, and
0081   //! -   the maximum number of segments MaxSeg which BSpline surfaces can have
0082   Standard_EXPORT void Init(const occ::handle<GeomFill_Boundary>& B1,
0083                             const occ::handle<GeomFill_Boundary>& B2,
0084                             const occ::handle<GeomFill_Boundary>& B3,
0085                             const occ::handle<GeomFill_Boundary>& B4,
0086                             const bool                            NoCheck = false);
0087 
0088   //! Allows to modify domain on which the blending function
0089   //! associated to the constrained boundary B will propag
0090   //! the influence of the field of tangency. Can be
0091   //! useful to reduce influence of boundaries on which
0092   //! the Coons compatibility conditions are not respected.
0093   //! l is a relative value of the parametric range of B.
0094   //! Default value for l is 1 (used in Init).
0095   //! Warning: Must be called after Init with a constrained boundary
0096   //! used in the call to Init.
0097   Standard_EXPORT void SetDomain(const double l, const occ::handle<GeomFill_BoundWithSurf>& B);
0098 
0099   //! Computes the new poles of the surface using the new
0100   //! blending functions set by several calls to SetDomain.
0101   Standard_EXPORT void ReBuild();
0102 
0103   //! Returns the bound of index i after sort.
0104   Standard_EXPORT occ::handle<GeomFill_Boundary> Boundary(const int I) const;
0105 
0106   //! Returns the BSpline surface after computation of the fill by this framework.
0107   Standard_EXPORT occ::handle<Geom_BSplineSurface> Surface() const;
0108 
0109   //! Internal use for Advmath approximation call.
0110   Standard_EXPORT int Eval(const double W, const int Ord, double& Result) const;
0111 
0112   //! Computes the fields of tangents on 30 points along the
0113   //! bound I, these are not the constraint tangents but
0114   //! gives an idea of the coonsAlgPatch regularity.
0115   Standard_EXPORT void CheckCoonsAlgPatch(const int I);
0116 
0117   //! Computes the fields of tangents and normals on 30
0118   //! points along the bound I, draw them, and computes the
0119   //! max dot product that must be near than 0.
0120   Standard_EXPORT void CheckTgteField(const int I);
0121 
0122   //! Computes values and normals along the bound I and
0123   //! compare them to the approx result curves (bound and
0124   //! tgte field) , draw the normals and tangents.
0125   Standard_EXPORT void CheckApprox(const int I);
0126 
0127   //! Computes values and normals along the bound I on both
0128   //! constraint surface and result surface, draw the
0129   //! normals, and computes the max distance between values
0130   //! and the max angle between normals.
0131   Standard_EXPORT void CheckResult(const int I);
0132 
0133 private:
0134   //! Performs the approximation an compute the poles of the
0135   //! surface.
0136   Standard_EXPORT void Build();
0137 
0138   //! Performs the parallel approximation on two oppsite
0139   //! bounds
0140   Standard_EXPORT void PerformApprox();
0141 
0142   //! matches the nodal vectors of the blending functions
0143   //! and the results of the approx to allow the surface
0144   //! computation.
0145   Standard_EXPORT void MatchKnots();
0146 
0147   //! performs the poles of the partial construction S0.
0148   Standard_EXPORT void PerformS0();
0149 
0150   //! performs the poles of the partial construction S1.
0151   Standard_EXPORT void PerformS1();
0152 
0153   //! performs the poles of the surface using the partial
0154   //! constructions S0 and S1.
0155   Standard_EXPORT void PerformSurface();
0156 
0157   //! Checks if the field of tangency doesn t twist along the
0158   //! boundary.
0159   Standard_EXPORT bool CheckTgte(const int I);
0160 
0161   //! Evaluates the min magnitude of the field of tangency
0162   //! along bound I to allow a simple evaluation of the
0163   //! tolerance needed for the approximation of the field of
0164   //! tangency.
0165   Standard_EXPORT void MinTgte(const int I);
0166 
0167   int                                      degmax;
0168   int                                      segmax;
0169   occ::handle<GeomFill_CoonsAlgPatch>      ptch;
0170   occ::handle<GeomFill_TgtField>           tgalg[4];
0171   double                                   mig[4];
0172   GeomFill_CornerState                     stcor[4];
0173   gp_Vec                                   v[4];
0174   bool                                     appdone;
0175   int                                      degree[2];
0176   occ::handle<NCollection_HArray1<gp_Pnt>> curvpol[4];
0177   occ::handle<NCollection_HArray1<gp_Pnt>> tgtepol[4];
0178   occ::handle<NCollection_HArray1<int>>    mults[2];
0179   occ::handle<NCollection_HArray1<double>> knots[2];
0180   occ::handle<NCollection_HArray1<double>> ab[4];
0181   occ::handle<NCollection_HArray1<double>> pq[4];
0182   double                                   dom[4];
0183   occ::handle<NCollection_HArray1<gp_Pnt>> ncpol[4];
0184   occ::handle<NCollection_HArray1<gp_Pnt>> ntpol[4];
0185   occ::handle<NCollection_HArray1<int>>    nm[2];
0186   occ::handle<NCollection_HArray1<double>> nk[2];
0187   int                                      ibound[2];
0188   int                                      ctr[2];
0189   int                                      nbd3;
0190   occ::handle<NCollection_HArray2<gp_Pnt>> S0;
0191   occ::handle<NCollection_HArray2<gp_Pnt>> S1;
0192   occ::handle<Geom_BSplineSurface>         surf;
0193 };
0194 
0195 #endif // _GeomFill_ConstrainedFilling_HeaderFile