Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-06 08:35:42

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(Standard_True)
0031   {
0032   }
0033 
0034   //! Destructor.
0035   virtual ~BRepMesh_DefaultRangeSplitter() {}
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 Standard_Boolean 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,
0057                                  const Standard_Boolean isToFaceBasis) const;
0058 
0059   //! Returns list of nodes generated using surface data and specified parameters.
0060   //! By default returns null ptr.
0061   Standard_EXPORT virtual Handle(IMeshData::ListOfPnt2d) GenerateSurfaceNodes(
0062     const IMeshTools_Parameters& theParameters) const;
0063 
0064   //! Returns point in 3d space corresponded to the given
0065   //! point defined in parametric space of surface.
0066   gp_Pnt Point(const gp_Pnt2d& thePoint2d) const
0067   {
0068     return GetSurface()->Value(thePoint2d.X(), thePoint2d.Y());
0069   }
0070 
0071 protected:
0072   //! Computes parametric tolerance taking length along U and V into account.
0073   Standard_EXPORT virtual void computeTolerance(const Standard_Real theLenU,
0074                                                 const Standard_Real theLenV);
0075 
0076   //! Computes parametric delta taking length along U and V and value of tolerance into account.
0077   Standard_EXPORT virtual void computeDelta(const Standard_Real theLengthU,
0078                                             const Standard_Real theLengthV);
0079 
0080 public:
0081   //! Returns face model.
0082   const IMeshData::IFaceHandle& GetDFace() const { return myDFace; }
0083 
0084   //! Returns surface.
0085   const Handle(BRepAdaptor_Surface)& GetSurface() const { return myDFace->GetSurface(); }
0086 
0087   //! Returns U range.
0088   const std::pair<Standard_Real, Standard_Real>& GetRangeU() const { return myRangeU; }
0089 
0090   //! Returns V range.
0091   const std::pair<Standard_Real, Standard_Real>& GetRangeV() const { return myRangeV; }
0092 
0093   //! Returns delta.
0094   const std::pair<Standard_Real, Standard_Real>& GetDelta() const { return myDelta; }
0095 
0096   const std::pair<Standard_Real, Standard_Real>& GetToleranceUV() const { return myTolerance; }
0097 
0098 private:
0099   //! Computes length along U direction.
0100   Standard_Real computeLengthU();
0101 
0102   //! Computes length along V direction.
0103   Standard_Real computeLengthV();
0104 
0105   //! Updates discrete range of surface according to its geometric range.
0106   void updateRange(const Standard_Real    theGeomFirst,
0107                    const Standard_Real    theGeomLast,
0108                    const Standard_Boolean isPeriodic,
0109                    Standard_Real&         theDiscreteFirst,
0110                    Standard_Real&         theDiscreteLast);
0111 
0112 protected:
0113   IMeshData::IFaceHandle                  myDFace;
0114   std::pair<Standard_Real, Standard_Real> myRangeU;
0115   std::pair<Standard_Real, Standard_Real> myRangeV;
0116   std::pair<Standard_Real, Standard_Real> myDelta;
0117   std::pair<Standard_Real, Standard_Real> myTolerance;
0118   Standard_Boolean                        myIsValid;
0119 };
0120 
0121 #endif