Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0027   //! Default constructor
0028   Standard_EXPORT BRepMesh_IncrementalMesh();
0029 
0030   //! Destructor
0031   Standard_EXPORT virtual ~BRepMesh_IncrementalMesh();
0032 
0033   //! Constructor.
0034   //! Automatically calls method Perform.
0035   //! @param theShape shape to be meshed.
0036   //! @param theLinDeflection linear deflection.
0037   //! @param isRelative if TRUE deflection used for discretization of 
0038   //! each edge will be <theLinDeflection> * <size of edge>. Deflection 
0039   //! used for the faces will be the maximum deflection of their edges.
0040   //! @param theAngDeflection angular deflection.
0041   //! @param isInParallel if TRUE shape will be meshed in parallel.
0042   Standard_EXPORT BRepMesh_IncrementalMesh(const TopoDS_Shape&    theShape,
0043                                            const Standard_Real    theLinDeflection,
0044                                            const Standard_Boolean isRelative = Standard_False,
0045                                            const Standard_Real    theAngDeflection = 0.5,
0046                                            const Standard_Boolean isInParallel = Standard_False);
0047 
0048   //! Constructor.
0049   //! Automatically calls method Perform.
0050   //! @param theShape shape to be meshed.
0051   //! @param theParameters - parameters of meshing
0052   Standard_EXPORT BRepMesh_IncrementalMesh(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 virtual void Perform(const Message_ProgressRange& theRange = Message_ProgressRange()) Standard_OVERRIDE;
0058 
0059   //! Performs meshing using custom context;
0060   Standard_EXPORT void Perform(const Handle(IMeshTools_Context)& theContext,
0061                                const Message_ProgressRange& theRange = Message_ProgressRange());
0062   
0063 public: //! @name accessing to parameters.
0064 
0065   //! Returns meshing parameters
0066   const IMeshTools_Parameters& Parameters() const
0067   {
0068     return myParameters;
0069   }
0070 
0071   //! Returns modifiable meshing parameters
0072   IMeshTools_Parameters& ChangeParameters()
0073   {
0074     return myParameters;
0075   }
0076 
0077   //! Returns modified flag.
0078   Standard_Boolean IsModified() const
0079   {
0080     return myModified;
0081   }
0082   
0083   //! Returns accumulated status flags faced during meshing.
0084   Standard_Integer GetStatusFlags() const
0085   {
0086     return myStatus;
0087   }
0088   
0089 private:
0090 
0091   //! Initializes specific parameters
0092   void initParameters()
0093   {
0094     if (myParameters.Deflection < Precision::Confusion())
0095     {
0096       throw Standard_NumericError ("BRepMesh_IncrementalMesh::initParameters : invalid parameter value");
0097     }
0098     if (myParameters.DeflectionInterior < Precision::Confusion())
0099     {
0100       myParameters.DeflectionInterior = myParameters.Deflection;
0101     }
0102 
0103     if (myParameters.MinSize < Precision::Confusion())
0104     {
0105       myParameters.MinSize =
0106         Max(IMeshTools_Parameters::RelMinSize() * Min(myParameters.Deflection,
0107                                                       myParameters.DeflectionInterior),
0108             Precision::Confusion());
0109     }
0110 
0111     if (myParameters.Angle < Precision::Angular())
0112     {
0113       throw Standard_NumericError ("BRepMesh_IncrementalMesh::initParameters : invalid parameter value");
0114     }
0115     if (myParameters.AngleInterior < Precision::Angular())
0116     {
0117       myParameters.AngleInterior = 2.0 * myParameters.Angle;
0118     }
0119   }
0120 
0121 public: //! @name plugin API
0122 
0123   //! Plugin interface for the Mesh Factories.
0124   //! Initializes meshing algorithm with the given parameters.
0125   //! @param theShape shape to be meshed.
0126   //! @param theLinDeflection linear deflection.
0127   //! @param theAngDeflection angular deflection.
0128   //! @param[out] theAlgo pointer to initialized algorithm.
0129   Standard_EXPORT static Standard_Integer Discret(const TopoDS_Shape&    theShape,
0130                                                   const Standard_Real    theLinDeflection,
0131                                                   const Standard_Real    theAngDeflection,
0132                                                   BRepMesh_DiscretRoot* &theAlgo);
0133   
0134   //! Returns multi-threading usage flag set by default in 
0135   //! Discret() static method (thus applied only to Mesh Factories).
0136   Standard_EXPORT static Standard_Boolean IsParallelDefault();
0137   
0138   //! Setup multi-threading usage flag set by default in 
0139   //! Discret() static method (thus applied only to Mesh Factories).
0140   Standard_EXPORT static void SetParallelDefault(const Standard_Boolean isInParallel);
0141 
0142   DEFINE_STANDARD_RTTIEXT(BRepMesh_IncrementalMesh, BRepMesh_DiscretRoot)
0143 
0144 protected:
0145 
0146   IMeshTools_Parameters myParameters;
0147   Standard_Boolean      myModified;
0148   Standard_Integer      myStatus;
0149 };
0150 
0151 #endif