Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-22 08:57:18

0001 // Copyright (c) 2013 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _BRepMesh_IncrementalMesh_HeaderFile
0015 #define _BRepMesh_IncrementalMesh_HeaderFile
0016 
0017 #include <BRepMesh_DiscretRoot.hxx>
0018 #include <IMeshTools_Context.hxx>
0019 #include <Standard_NumericError.hxx>
0020 
0021 //! Builds the mesh of a shape with respect of their
0022 //! correctly triangulated parts
0023 class BRepMesh_IncrementalMesh : public BRepMesh_DiscretRoot
0024 {
0025 public: //! @name mesher API
0026   //! Default constructor
0027   Standard_EXPORT BRepMesh_IncrementalMesh();
0028 
0029   //! Destructor
0030   Standard_EXPORT ~BRepMesh_IncrementalMesh() override;
0031 
0032   //! Constructor.
0033   //! Automatically calls method Perform.
0034   //! @param theShape shape to be meshed.
0035   //! @param theLinDeflection linear deflection.
0036   //! @param isRelative if TRUE deflection used for discretization of
0037   //! each edge will be <theLinDeflection> * <size of edge>. Deflection
0038   //! used for the faces will be the maximum deflection of their edges.
0039   //! @param theAngDeflection angular deflection.
0040   //! @param isInParallel if TRUE shape will be meshed in parallel.
0041   Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape& theShape,
0042                                            const double        theLinDeflection,
0043                                            const bool          isRelative       = false,
0044                                            const double        theAngDeflection = 0.5,
0045                                            const bool          isInParallel     = false);
0046 
0047   //! Constructor.
0048   //! Automatically calls method Perform.
0049   //! @param theShape shape to be meshed.
0050   //! @param theParameters - parameters of meshing
0051   Standard_EXPORT BRepMesh_IncrementalMesh(
0052     const TopoDS_Shape&          theShape,
0053     const IMeshTools_Parameters& theParameters,
0054     const Message_ProgressRange& theRange = Message_ProgressRange());
0055 
0056   //! Performs meshing of the shape.
0057   Standard_EXPORT void Perform(
0058     const Message_ProgressRange& theRange = Message_ProgressRange()) override;
0059 
0060   //! Performs meshing using custom context;
0061   Standard_EXPORT void Perform(const occ::handle<IMeshTools_Context>& theContext,
0062                                const Message_ProgressRange& theRange = Message_ProgressRange());
0063 
0064 public: //! @name accessing to parameters.
0065   //! Returns meshing parameters
0066   const IMeshTools_Parameters& Parameters() const { return myParameters; }
0067 
0068   //! Returns modifiable meshing parameters
0069   IMeshTools_Parameters& ChangeParameters() { return myParameters; }
0070 
0071   //! Returns modified flag.
0072   bool IsModified() const { return myModified; }
0073 
0074   //! Returns accumulated status flags faced during meshing.
0075   int GetStatusFlags() const { return myStatus; }
0076 
0077 private:
0078   //! Initializes specific parameters
0079   void initParameters()
0080   {
0081     if (myParameters.Deflection < Precision::Confusion())
0082     {
0083       throw Standard_NumericError(
0084         "BRepMesh_IncrementalMesh::initParameters : invalid parameter value");
0085     }
0086     if (myParameters.DeflectionInterior < Precision::Confusion())
0087     {
0088       myParameters.DeflectionInterior = myParameters.Deflection;
0089     }
0090 
0091     if (myParameters.MinSize < Precision::Confusion())
0092     {
0093       myParameters.MinSize =
0094         (std::max)(IMeshTools_Parameters::RelMinSize()
0095                      * (std::min)(myParameters.Deflection, myParameters.DeflectionInterior),
0096                    Precision::Confusion());
0097     }
0098 
0099     if (myParameters.Angle < Precision::Angular())
0100     {
0101       throw Standard_NumericError(
0102         "BRepMesh_IncrementalMesh::initParameters : invalid parameter value");
0103     }
0104     if (myParameters.AngleInterior < Precision::Angular())
0105     {
0106       myParameters.AngleInterior = 2.0 * myParameters.Angle;
0107     }
0108   }
0109 
0110 public: //! @name plugin API
0111   //! Plugin interface for the Mesh Factories.
0112   //! Initializes meshing algorithm with the given parameters.
0113   //! @param theShape shape to be meshed.
0114   //! @param theLinDeflection linear deflection.
0115   //! @param theAngDeflection angular deflection.
0116   //! @param[out] theAlgo pointer to initialized algorithm.
0117   Standard_EXPORT static int Discret(const TopoDS_Shape&    theShape,
0118                                      const double           theLinDeflection,
0119                                      const double           theAngDeflection,
0120                                      BRepMesh_DiscretRoot*& theAlgo);
0121 
0122   //! Returns multi-threading usage flag set by default in
0123   //! Discret() static method (thus applied only to Mesh Factories).
0124   Standard_EXPORT static bool IsParallelDefault();
0125 
0126   //! Setup multi-threading usage flag set by default in
0127   //! Discret() static method (thus applied only to Mesh Factories).
0128   Standard_EXPORT static void SetParallelDefault(const bool isInParallel);
0129 
0130   DEFINE_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
0131 
0132 protected:
0133   IMeshTools_Parameters myParameters;
0134   bool                  myModified;
0135   int                   myStatus;
0136 };
0137 
0138 #endif