Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:05

0001 // Created on: 2016-04-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 _IMeshTools_Context_HeaderFile
0017 #define _IMeshTools_Context_HeaderFile
0018 
0019 #include <Standard_Type.hxx>
0020 #include <IMeshTools_ModelBuilder.hxx>
0021 #include <IMeshData_Model.hxx>
0022 #include <IMeshTools_Parameters.hxx>
0023 #include <IMeshTools_ModelAlgo.hxx>
0024 #include <Message_ProgressRange.hxx>
0025 
0026 //! Interface class representing context of BRepMesh algorithm.
0027 //! Intended to cache discrete model and instances of tools for 
0028 //! its processing.
0029 class IMeshTools_Context : public IMeshData_Shape
0030 {
0031 public:
0032 
0033   //! Constructor.
0034   IMeshTools_Context()
0035   {
0036   }
0037 
0038   //! Destructor.
0039   virtual ~IMeshTools_Context()
0040   {
0041   }
0042 
0043   //! Builds model using assigned model builder.
0044   //! @return True on success, False elsewhere.
0045   virtual Standard_Boolean BuildModel ()
0046   {
0047     if (myModelBuilder.IsNull())
0048     {
0049       return Standard_False;
0050     }
0051 
0052     myModel = myModelBuilder->Perform(GetShape(), myParameters);
0053 
0054     return !myModel.IsNull();
0055   }
0056 
0057   //! Performs discretization of model edges using assigned edge discret algorithm.
0058   //! @return True on success, False elsewhere.
0059   virtual Standard_Boolean DiscretizeEdges()
0060   {
0061     if (myModel.IsNull() || myEdgeDiscret.IsNull())
0062     {
0063       return Standard_False;
0064     }
0065 
0066     // Discretize edges of a model.
0067     return myEdgeDiscret->Perform(myModel, myParameters, Message_ProgressRange());
0068   }
0069 
0070   //! Performs healing of discrete model built by DiscretizeEdges() method
0071   //! using assigned healing algorithm.
0072   //! @return True on success, False elsewhere.
0073   virtual Standard_Boolean HealModel()
0074   {
0075     if (myModel.IsNull())
0076     {
0077       return Standard_False;
0078     }
0079 
0080     return myModelHealer.IsNull() ?
0081       Standard_True :
0082       myModelHealer->Perform (myModel, myParameters, Message_ProgressRange());
0083   }
0084 
0085   //! Performs pre-processing of discrete model using assigned algorithm.
0086   //! Performs auxiliary actions such as cleaning shape from old triangulation.
0087   //! @return True on success, False elsewhere.
0088   virtual Standard_Boolean PreProcessModel()
0089   {
0090     if (myModel.IsNull())
0091     {
0092       return Standard_False;
0093     }
0094 
0095     return myPreProcessor.IsNull() ? 
0096       Standard_True :
0097       myPreProcessor->Perform (myModel, myParameters, Message_ProgressRange());
0098   }
0099 
0100   //! Performs meshing of faces of discrete model using assigned meshing algorithm.
0101   //! @return True on success, False elsewhere.
0102   virtual Standard_Boolean DiscretizeFaces (const Message_ProgressRange& theRange)
0103   {
0104     if (myModel.IsNull() || myFaceDiscret.IsNull())
0105     {
0106       return Standard_False;
0107     }
0108 
0109     // Discretize faces of a model.
0110     return myFaceDiscret->Perform (myModel, myParameters, theRange);
0111   }
0112 
0113   //! Performs post-processing of discrete model using assigned algorithm.
0114   //! @return True on success, False elsewhere.
0115   virtual Standard_Boolean PostProcessModel()
0116   {
0117     if (myModel.IsNull())
0118     {
0119       return Standard_False;
0120     }
0121 
0122     return myPostProcessor.IsNull() ?
0123       Standard_True :
0124       myPostProcessor->Perform(myModel, myParameters, Message_ProgressRange());
0125   }
0126 
0127   //! Cleans temporary context data.
0128   virtual void Clean()
0129   {
0130     if (myParameters.CleanModel)
0131     {
0132       myModel.Nullify();
0133     }
0134   }
0135 
0136   //! Gets instance of a tool to be used to build discrete model.
0137   const Handle (IMeshTools_ModelBuilder)& GetModelBuilder () const
0138   {
0139     return myModelBuilder;
0140   }
0141 
0142   //! Sets instance of a tool to be used to build discrete model.
0143   void SetModelBuilder (const Handle (IMeshTools_ModelBuilder)& theBuilder)
0144   {
0145     myModelBuilder = theBuilder;
0146   }
0147 
0148   //! Gets instance of a tool to be used to discretize edges of a model.
0149   const Handle (IMeshTools_ModelAlgo)& GetEdgeDiscret () const
0150   {
0151     return myEdgeDiscret;
0152   }
0153 
0154   //! Sets instance of a tool to be used to discretize edges of a model.
0155   void SetEdgeDiscret (const Handle (IMeshTools_ModelAlgo)& theEdgeDiscret)
0156   {
0157     myEdgeDiscret = theEdgeDiscret;
0158   }
0159 
0160   //! Gets instance of a tool to be used to heal discrete model.
0161   const Handle(IMeshTools_ModelAlgo)& GetModelHealer() const
0162   {
0163     return myModelHealer;
0164   }
0165 
0166   //! Sets instance of a tool to be used to heal discrete model.
0167   void SetModelHealer(const Handle(IMeshTools_ModelAlgo)& theModelHealer)
0168   {
0169     myModelHealer = theModelHealer;
0170   }
0171 
0172   //! Gets instance of pre-processing algorithm.
0173   const Handle(IMeshTools_ModelAlgo)& GetPreProcessor() const
0174   {
0175     return myPreProcessor;
0176   }
0177 
0178   //! Sets instance of pre-processing algorithm.
0179   void SetPreProcessor(const Handle(IMeshTools_ModelAlgo)& thePreProcessor)
0180   {
0181     myPreProcessor = thePreProcessor;
0182   }
0183 
0184   //! Gets instance of meshing algorithm.
0185   const Handle(IMeshTools_ModelAlgo)& GetFaceDiscret() const
0186   {
0187     return myFaceDiscret;
0188   }
0189 
0190   //! Sets instance of meshing algorithm.
0191   void SetFaceDiscret(const Handle(IMeshTools_ModelAlgo)& theFaceDiscret)
0192   {
0193     myFaceDiscret = theFaceDiscret;
0194   }
0195 
0196   //! Gets instance of post-processing algorithm.
0197   const Handle(IMeshTools_ModelAlgo)& GetPostProcessor() const
0198   {
0199     return myPostProcessor;
0200   }
0201 
0202   //! Sets instance of post-processing algorithm.
0203   void SetPostProcessor(const Handle(IMeshTools_ModelAlgo)& thePostProcessor)
0204   {
0205     myPostProcessor = thePostProcessor;
0206   }
0207 
0208   //! Gets parameters to be used for meshing.
0209   const IMeshTools_Parameters& GetParameters () const 
0210   {
0211     return myParameters;
0212   }
0213 
0214   //! Gets reference to parameters to be used for meshing.
0215   IMeshTools_Parameters& ChangeParameters ()
0216   {
0217     return myParameters;
0218   }
0219 
0220   //! Returns discrete model of a shape.
0221   const Handle (IMeshData_Model)& GetModel () const
0222   {
0223     return myModel;
0224   }
0225 
0226   DEFINE_STANDARD_RTTIEXT(IMeshTools_Context, IMeshData_Shape)
0227 
0228 private:
0229 
0230   Handle (IMeshTools_ModelBuilder) myModelBuilder;
0231   Handle (IMeshData_Model)         myModel;
0232   Handle (IMeshTools_ModelAlgo)    myEdgeDiscret;
0233   Handle (IMeshTools_ModelAlgo)    myModelHealer;
0234   Handle (IMeshTools_ModelAlgo)    myPreProcessor;
0235   Handle (IMeshTools_ModelAlgo)    myFaceDiscret;
0236   Handle (IMeshTools_ModelAlgo)    myPostProcessor;
0237   IMeshTools_Parameters            myParameters;
0238 };
0239 
0240 #endif