Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-01 09:00:50

0001 // Created on: 1996-04-03
0002 // Created by: Stagiaire Frederic CALOONE
0003 // Copyright (c) 1996-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 _GeomPlate_BuildPlateSurface_HeaderFile
0018 #define _GeomPlate_BuildPlateSurface_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 #include <GeomPlate_CurveConstraint.hxx>
0024 #include <NCollection_Sequence.hxx>
0025 #include <NCollection_HSequence.hxx>
0026 #include <NCollection_Array1.hxx>
0027 #include <NCollection_HArray1.hxx>
0028 #include <GeomPlate_PointConstraint.hxx>
0029 #include <Plate_Plate.hxx>
0030 #include <Standard_Integer.hxx>
0031 #include <Standard_Real.hxx>
0032 #include <Extrema_ExtPS.hxx>
0033 #include <Adaptor3d_Curve.hxx>
0034 #include <gp_XY.hxx>
0035 #include <gp_XYZ.hxx>
0036 #include <Geom2d_Curve.hxx>
0037 class Geom_Surface;
0038 class GeomPlate_Surface;
0039 class GeomPlate_CurveConstraint;
0040 class GeomPlate_PointConstraint;
0041 class gp_Pnt2d;
0042 class gp_Pnt;
0043 class Geom2d_Curve;
0044 
0045 //! This class provides an algorithm for constructing such a plate surface that
0046 //! it conforms to given curve and/or point constraints.
0047 //! The algorithm accepts or constructs an initial surface
0048 //! and looks for a deformation of it satisfying the
0049 //! constraints and minimizing energy input.
0050 //! A BuildPlateSurface object provides a framework for:
0051 //! -   defining or setting constraints
0052 //! -   implementing the construction algorithm
0053 //! -   consulting the result.
0054 class GeomPlate_BuildPlateSurface
0055 {
0056 public:
0057   DEFINE_STANDARD_ALLOC
0058 
0059   //! Constructor compatible with the old version
0060   //! with this constructor the constraint are given in a Array of Curve on Surface
0061   //! The array NbPoints contains the number of points for each constraint.
0062   //! The Array Tang contains the order of constraint for each Constraint: The possible values for
0063   //! this order has to be -1 , 0 , 1 , 2 . Order i means constraint Gi. NbIter is the maximum
0064   //! number of iteration to optimise the number of points for resolution Degree is the degree of
0065   //! resolution for Plate Tol2d is the tolerance used to test if two points of different constraint
0066   //! are identical in the parametric space of the initial surface Tol3d is used to test if two
0067   //! identical points in the 2d space are identical in 3d space TolAng is used to compare the angle
0068   //! between normal of two identical points in the 2d space Raises ConstructionError;
0069   Standard_EXPORT GeomPlate_BuildPlateSurface(
0070     const occ::handle<NCollection_HArray1<int>>&                          NPoints,
0071     const occ::handle<NCollection_HArray1<occ::handle<Adaptor3d_Curve>>>& TabCurve,
0072     const occ::handle<NCollection_HArray1<int>>&                          Tang,
0073     const int                                                             Degree,
0074     const int                                                             NbIter      = 3,
0075     const double                                                          Tol2d       = 0.00001,
0076     const double                                                          Tol3d       = 0.0001,
0077     const double                                                          TolAng      = 0.01,
0078     const double                                                          TolCurv     = 0.1,
0079     const bool                                                            Anisotropie = false);
0080 
0081   Standard_EXPORT GeomPlate_BuildPlateSurface(const occ::handle<Geom_Surface>& Surf,
0082                                               const int                        Degree     = 3,
0083                                               const int                        NbPtsOnCur = 10,
0084                                               const int                        NbIter     = 3,
0085                                               const double                     Tol2d      = 0.00001,
0086                                               const double                     Tol3d      = 0.0001,
0087                                               const double                     TolAng     = 0.01,
0088                                               const double                     TolCurv    = 0.1,
0089                                               const bool                       Anisotropie = false);
0090 
0091   //! Initializes the BuildPlateSurface framework for
0092   //! deforming plate surfaces using curve and point
0093   //! constraints. You use the first constructor if you have
0094   //! an initial surface to work with at construction time. If
0095   //! not, you use the second. You can add one later by
0096   //! using the method LoadInitSurface. If no initial
0097   //! surface is loaded, one will automatically be computed.
0098   //! The curve and point constraints will be defined by
0099   //! using the method Add.
0100   //! Before the call to the algorithm, the curve constraints
0101   //! will be transformed into sequences of discrete points.
0102   //! Each curve defined as a constraint will be given the
0103   //! value of NbPtsOnCur as the average number of points on it.
0104   //! Several arguments serve to improve performance of
0105   //! the algorithm. NbIter, for example, expresses the
0106   //! number of iterations allowed and is used to control the
0107   //! duration of computation. To optimize resolution,
0108   //! Degree will have the default value of 3.
0109   //! The surface generated must respect several tolerance values:
0110   //! -   2d tolerance given by Tol2d, with a default value of 0.00001
0111   //! -   3d tolerance expressed by Tol3d, with a default value of 0.0001
0112   //! -   angular tolerance given by TolAng, with a default
0113   //! value of 0.01, defining the greatest angle allowed
0114   //! between the constraint and the target surface.
0115   //! Exceptions
0116   //! Standard_ConstructionError if NbIter is less than 1 or Degree is less than 3.
0117   Standard_EXPORT GeomPlate_BuildPlateSurface(const int    Degree      = 3,
0118                                               const int    NbPtsOnCur  = 10,
0119                                               const int    NbIter      = 3,
0120                                               const double Tol2d       = 0.00001,
0121                                               const double Tol3d       = 0.0001,
0122                                               const double TolAng      = 0.01,
0123                                               const double TolCurv     = 0.1,
0124                                               const bool   Anisotropie = false);
0125 
0126   //! Resets all constraints
0127   Standard_EXPORT void Init();
0128 
0129   //! Loads the initial Surface
0130   Standard_EXPORT void LoadInitSurface(const occ::handle<Geom_Surface>& Surf);
0131 
0132   //! Adds the linear constraint cont.
0133   Standard_EXPORT void Add(const occ::handle<GeomPlate_CurveConstraint>& Cont);
0134 
0135   Standard_EXPORT void SetNbBounds(const int NbBounds);
0136 
0137   //! Adds the point constraint cont.
0138   Standard_EXPORT void Add(const occ::handle<GeomPlate_PointConstraint>& Cont);
0139 
0140   //! Calls the algorithm and computes the plate surface using
0141   //! the loaded constraints. If no initial surface is given, the
0142   //! algorithm automatically computes one.
0143   //! Exceptions
0144   //! Standard_RangeError if the value of the constraint is
0145   //! null or if plate is not done.
0146   Standard_EXPORT void Perform(const Message_ProgressRange& theProgress = Message_ProgressRange());
0147 
0148   //! returns the CurveConstraints of order order
0149   Standard_EXPORT occ::handle<GeomPlate_CurveConstraint> CurveConstraint(const int order) const;
0150 
0151   //! returns the PointConstraint of order order
0152   Standard_EXPORT occ::handle<GeomPlate_PointConstraint> PointConstraint(const int order) const;
0153 
0154   Standard_EXPORT void Disc2dContour(const int nbp, NCollection_Sequence<gp_XY>& Seq2d);
0155 
0156   Standard_EXPORT void Disc3dContour(const int                     nbp,
0157                                      const int                     iordre,
0158                                      NCollection_Sequence<gp_XYZ>& Seq3d);
0159 
0160   //! Tests whether computation of the plate has been completed.
0161   Standard_EXPORT bool IsDone() const;
0162 
0163   //! Returns the result of the computation. This surface can
0164   //! then be used by GeomPlate_MakeApprox for
0165   //! converting the resulting surface into a BSpline.
0166   Standard_EXPORT occ::handle<GeomPlate_Surface> Surface() const;
0167 
0168   //! Returns the initial surface
0169   Standard_EXPORT occ::handle<Geom_Surface> SurfInit() const;
0170 
0171   //! Allows you to ensure that the array of curves returned by
0172   //! Curves2d has the correct orientation. Returns the
0173   //! orientation of the curves in the array returned by
0174   //! Curves2d. Computation changes the orientation of
0175   //! these curves. Consequently, this method returns the
0176   //! orientation prior to computation.
0177   Standard_EXPORT occ::handle<NCollection_HArray1<int>> Sense() const;
0178 
0179   //! Extracts the array of curves on the plate surface which
0180   //! correspond to the curve constraints set in Add.
0181   Standard_EXPORT occ::handle<NCollection_HArray1<occ::handle<Geom2d_Curve>>> Curves2d() const;
0182 
0183   //! Returns the order of the curves in the array returned by
0184   //! Curves2d. Computation changes this order.
0185   //! Consequently, this method returns the order of the
0186   //! curves prior to computation.
0187   Standard_EXPORT occ::handle<NCollection_HArray1<int>> Order() const;
0188 
0189   //! Returns the max distance between the result and the constraints
0190   Standard_EXPORT double G0Error() const;
0191 
0192   //! Returns the max angle between the result and the constraints
0193   Standard_EXPORT double G1Error() const;
0194 
0195   //! Returns the max difference of curvature between the result and the constraints
0196   Standard_EXPORT double G2Error() const;
0197 
0198   //! Returns the max distance between the result and the constraint Index
0199   Standard_EXPORT double G0Error(const int Index);
0200 
0201   //! Returns the max angle between the result and the constraint Index
0202   Standard_EXPORT double G1Error(const int Index);
0203 
0204   //! Returns the max difference of curvature between the result and the constraint Index
0205   Standard_EXPORT double G2Error(const int Index);
0206 
0207 private:
0208   //! Evaluates the distance, the angle between normals, and the "courbure"
0209   //! on middle points of constraints and corresponding points on the GeomPlate_Surface
0210   //! the results are given for a curve c
0211   Standard_EXPORT void EcartContraintesMil(const int                                 c,
0212                                            occ::handle<NCollection_HArray1<double>>& d,
0213                                            occ::handle<NCollection_HArray1<double>>& an,
0214                                            occ::handle<NCollection_HArray1<double>>& courb);
0215 
0216   Standard_EXPORT gp_Pnt2d ProjectPoint(const gp_Pnt& P);
0217 
0218   Standard_EXPORT occ::handle<Geom2d_Curve> ProjectCurve(const occ::handle<Adaptor3d_Curve>& Curv);
0219 
0220   Standard_EXPORT occ::handle<Adaptor2d_Curve2d> ProjectedCurve(occ::handle<Adaptor3d_Curve>& Curv);
0221 
0222   Standard_EXPORT void ComputeSurfInit(const Message_ProgressRange& theProgress);
0223 
0224   Standard_EXPORT void Intersect(
0225     occ::handle<NCollection_HArray1<NCollection_Sequence<double>>>& PntInter,
0226     occ::handle<NCollection_HArray1<NCollection_Sequence<double>>>& PntG1G1);
0227 
0228   Standard_EXPORT void Discretise(
0229     const occ::handle<NCollection_HArray1<NCollection_Sequence<double>>>& PntInter,
0230     const occ::handle<NCollection_HArray1<NCollection_Sequence<double>>>& PntG1G1);
0231 
0232   Standard_EXPORT void LoadCurve(const int NbBoucle, const int OrderMax = 2);
0233 
0234   Standard_EXPORT void LoadPoint(const int NbBoucle, const int OrderMax = 2);
0235 
0236   Standard_EXPORT void CalculNbPtsInit();
0237 
0238   Standard_EXPORT bool VerifSurface(const int NbLoop);
0239 
0240   Standard_EXPORT void VerifPoints(double& dist, double& ang, double& curv) const;
0241 
0242   Standard_EXPORT bool CourbeJointive(const double tolerance);
0243 
0244   Standard_EXPORT double ComputeAnisotropie() const;
0245 
0246   Standard_EXPORT bool IsOrderG1() const;
0247 
0248   occ::handle<NCollection_HSequence<occ::handle<GeomPlate_CurveConstraint>>> myLinCont;
0249   occ::handle<NCollection_HArray1<NCollection_Sequence<double>>>             myParCont;
0250   occ::handle<NCollection_HArray1<NCollection_Sequence<double>>>             myPlateCont;
0251   occ::handle<NCollection_HSequence<occ::handle<GeomPlate_PointConstraint>>> myPntCont;
0252   occ::handle<Geom_Surface>                                                  mySurfInit;
0253   occ::handle<Geom_Surface>                                                  myPlanarSurfInit;
0254   occ::handle<GeomPlate_Surface>                                             myGeomPlateSurface;
0255   Plate_Plate                                                                myPlate;
0256   Plate_Plate                                                                myPrevPlate;
0257   bool                                                                       myAnisotropie;
0258   occ::handle<NCollection_HArray1<int>>                                      mySense;
0259   int                                                                        myDegree;
0260   occ::handle<NCollection_HArray1<int>>                                      myInitOrder;
0261   double                                                                     myG0Error;
0262   double                                                                     myG1Error;
0263   double                                                                     myG2Error;
0264   int                                                                        myNbPtsOnCur;
0265   bool                                                                       mySurfInitIsGive;
0266   int                                                                        myNbIter;
0267   Extrema_ExtPS                                                              myProj;
0268   double                                                                     myTol2d;
0269   double                                                                     myTol3d;
0270   double                                                                     myTolAng;
0271   double                                                                     myTolU;
0272   double                                                                     myTolV;
0273   int                                                                        myNbBounds;
0274   bool                                                                       myIsLinear;
0275   bool                                                                       myFree;
0276 };
0277 
0278 #endif // _GeomPlate_BuildPlateSurface_HeaderFile