Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:13

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 
0029   //! Constructor.
0030   BRepMesh_DefaultRangeSplitter()
0031     : myIsValid (Standard_True)
0032   {
0033   }
0034 
0035   //! Destructor.
0036   virtual ~BRepMesh_DefaultRangeSplitter()
0037   {
0038   }
0039 
0040   //! Resets this splitter. Must be called before first use.
0041   Standard_EXPORT virtual void Reset(const IMeshData::IFaceHandle& theDFace,
0042                                      const IMeshTools_Parameters& theParameters);
0043 
0044   //! Registers border point.
0045   Standard_EXPORT virtual void AddPoint(const gp_Pnt2d& thePoint);
0046 
0047   //! Updates discrete range of surface according to its geometric range.
0048   Standard_EXPORT virtual void AdjustRange();
0049 
0050   //! Returns True if computed range is valid.
0051   Standard_EXPORT virtual Standard_Boolean IsValid();
0052 
0053   //! Scales the given point from real parametric space 
0054   //! to face basis and otherwise.
0055   //! @param thePoint point to be scaled.
0056   //! @param isToFaceBasis if TRUE converts point to face basis,
0057   //! otherwise performs reverse conversion.
0058   //! @return scaled point.
0059   Standard_EXPORT gp_Pnt2d Scale(const gp_Pnt2d&        thePoint,
0060                                  const Standard_Boolean isToFaceBasis) const;
0061 
0062   //! Returns list of nodes generated using surface data and specified parameters.
0063   //! By default returns null ptr.
0064   Standard_EXPORT virtual Handle(IMeshData::ListOfPnt2d) GenerateSurfaceNodes(
0065     const IMeshTools_Parameters& theParameters) const;
0066 
0067   //! Returns point in 3d space corresponded to the given 
0068   //! point defined in parameteric space of surface.
0069   gp_Pnt Point(const gp_Pnt2d& thePoint2d) const
0070   {
0071     return GetSurface()->Value(thePoint2d.X(), thePoint2d.Y());
0072   }
0073 
0074 protected:
0075 
0076   //! Computes parametric tolerance taking length along U and V into account.
0077   Standard_EXPORT virtual void computeTolerance (const Standard_Real theLenU, const Standard_Real theLenV);
0078 
0079   //! Computes parametric delta taking length along U and V and value of tolerance into account.
0080   Standard_EXPORT virtual void computeDelta (const Standard_Real theLengthU, const Standard_Real theLengthV);
0081 
0082 public:
0083   //! Returns face model.
0084   const IMeshData::IFaceHandle& GetDFace() const
0085   {
0086     return myDFace;
0087   }
0088 
0089   //! Returns surface.
0090   const Handle(BRepAdaptor_Surface)& GetSurface() const
0091   {
0092     return myDFace->GetSurface();
0093   }
0094 
0095   //! Returns U range.
0096   const std::pair<Standard_Real, Standard_Real>& GetRangeU() const
0097   {
0098     return myRangeU;
0099   }
0100 
0101   //! Returns V range.
0102   const std::pair<Standard_Real, Standard_Real>& GetRangeV() const
0103   {
0104     return myRangeV;
0105   }
0106 
0107   //! Returns delta.
0108   const std::pair<Standard_Real, Standard_Real>& GetDelta () const
0109   {
0110     return myDelta;
0111   }
0112 
0113   const std::pair<Standard_Real, Standard_Real>& GetToleranceUV() const
0114   {
0115     return myTolerance;
0116   }
0117 
0118 private:
0119 
0120   //! Computes length along U direction.
0121   Standard_Real computeLengthU();
0122 
0123   //! Computes length along V direction.
0124   Standard_Real computeLengthV();
0125 
0126   //! Updates discrete range of surface according to its geometric range.
0127   void updateRange(const Standard_Real     theGeomFirst,
0128                    const Standard_Real     theGeomLast,
0129                    const Standard_Boolean  isPeriodic,
0130                    Standard_Real&          theDiscreteFirst,
0131                    Standard_Real&          theDiscreteLast);
0132 
0133 protected:
0134   IMeshData::IFaceHandle                  myDFace;
0135   std::pair<Standard_Real, Standard_Real> myRangeU;
0136   std::pair<Standard_Real, Standard_Real> myRangeV;
0137   std::pair<Standard_Real, Standard_Real> myDelta;
0138   std::pair<Standard_Real, Standard_Real> myTolerance;
0139   Standard_Boolean                        myIsValid;
0140 };
0141 
0142 #endif