Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-03 10:54:19

0001 // Created on: 2016-07-07
0002 // Copyright (c) 2016 OPEN CASCADE SAS
0003 // Created by: Oleg AGASHIN
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BRepMesh_DefaultRangeSplitter_HeaderFile
0017 #define _BRepMesh_DefaultRangeSplitter_HeaderFile
0018 
0019 #include <IMeshData_Face.hxx>
0020 
0021 struct IMeshTools_Parameters;
0022 
0023 //! Default tool to define range of discrete face model and
0024 //! obtain grid points distributed within this range.
0025 class BRepMesh_DefaultRangeSplitter
0026 {
0027 public:
0028   //! Constructor.
0029   BRepMesh_DefaultRangeSplitter()
0030       : myIsValid(true)
0031   {
0032   }
0033 
0034   //! Destructor.
0035   virtual ~BRepMesh_DefaultRangeSplitter() = default;
0036 
0037   //! Resets this splitter. Must be called before first use.
0038   Standard_EXPORT virtual void Reset(const IMeshData::IFaceHandle& theDFace,
0039                                      const IMeshTools_Parameters&  theParameters);
0040 
0041   //! Registers border point.
0042   Standard_EXPORT virtual void AddPoint(const gp_Pnt2d& thePoint);
0043 
0044   //! Updates discrete range of surface according to its geometric range.
0045   Standard_EXPORT virtual void AdjustRange();
0046 
0047   //! Returns True if computed range is valid.
0048   Standard_EXPORT virtual bool IsValid();
0049 
0050   //! Scales the given point from real parametric space
0051   //! to face basis and otherwise.
0052   //! @param thePoint point to be scaled.
0053   //! @param isToFaceBasis if TRUE converts point to face basis,
0054   //! otherwise performs reverse conversion.
0055   //! @return scaled point.
0056   Standard_EXPORT gp_Pnt2d Scale(const gp_Pnt2d& thePoint, const bool isToFaceBasis) const;
0057 
0058   //! Returns list of nodes generated using surface data and specified parameters.
0059   //! By default returns null ptr.
0060   Standard_EXPORT virtual Handle(IMeshData::ListOfPnt2d) GenerateSurfaceNodes(
0061     const IMeshTools_Parameters& theParameters) const;
0062 
0063   //! Returns point in 3d space corresponded to the given
0064   //! point defined in parametric space of surface.
0065   gp_Pnt Point(const gp_Pnt2d& thePoint2d) const
0066   {
0067     return GetSurface()->Value(thePoint2d.X(), thePoint2d.Y());
0068   }
0069 
0070 protected:
0071   //! Computes parametric tolerance taking length along U and V into account.
0072   Standard_EXPORT virtual void computeTolerance(const double theLenU, const double theLenV);
0073 
0074   //! Computes parametric delta taking length along U and V and value of tolerance into account.
0075   Standard_EXPORT virtual void computeDelta(const double theLengthU, const double theLengthV);
0076 
0077 public:
0078   //! Returns face model.
0079   const IMeshData::IFaceHandle& GetDFace() const { return myDFace; }
0080 
0081   //! Returns surface.
0082   const occ::handle<BRepAdaptor_Surface>& GetSurface() const { return myDFace->GetSurface(); }
0083 
0084   //! Returns U range.
0085   const std::pair<double, double>& GetRangeU() const { return myRangeU; }
0086 
0087   //! Returns V range.
0088   const std::pair<double, double>& GetRangeV() const { return myRangeV; }
0089 
0090   //! Returns delta.
0091   const std::pair<double, double>& GetDelta() const { return myDelta; }
0092 
0093   const std::pair<double, double>& GetToleranceUV() const { return myTolerance; }
0094 
0095 private:
0096   //! Computes length along U direction using grid evaluation.
0097   //! @return computed length along U direction
0098   double computeLengthU();
0099 
0100   //! Computes length along V direction using grid evaluation.
0101   //! @return computed length along V direction
0102   double computeLengthV();
0103 
0104   //! Updates discrete range of surface according to its geometric range.
0105   void updateRange(const double theGeomFirst,
0106                    const double theGeomLast,
0107                    const bool   isPeriodic,
0108                    double&      theDiscreteFirst,
0109                    double&      theDiscreteLast);
0110 
0111 protected:
0112   IMeshData::IFaceHandle    myDFace;
0113   std::pair<double, double> myRangeU;
0114   std::pair<double, double> myRangeV;
0115   std::pair<double, double> myDelta;
0116   std::pair<double, double> myTolerance;
0117   bool                      myIsValid;
0118 };
0119 
0120 #endif