1 // Created on: 2016-04-07
2 // Copyright (c) 2016 OPEN CASCADE SAS
3 // Created by: Oleg AGASHIN
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _IMeshTools_Context_HeaderFile
17 #define _IMeshTools_Context_HeaderFile
19 #include <IMeshData_Shape.hxx>
20 #include <Standard_Type.hxx>
21 #include <IMeshTools_ModelBuilder.hxx>
22 #include <IMeshData_Model.hxx>
23 #include <IMeshTools_Parameters.hxx>
24 #include <IMeshTools_ModelAlgo.hxx>
26 //! Interface class representing context of BRepMesh algorithm.
27 //! Intended to cache discrete model and instances of tools for
29 class IMeshTools_Context : public IMeshData_Shape
34 Standard_EXPORT IMeshTools_Context()
39 Standard_EXPORT virtual ~IMeshTools_Context()
43 //! Builds model using assined model builder.
44 //! @return True on success, False elsewhere.
45 Standard_EXPORT virtual Standard_Boolean BuildModel ()
47 if (myModelBuilder.IsNull())
49 return Standard_False;
52 myModel = myModelBuilder->Perform(GetShape(), myParameters);
54 return !myModel.IsNull();
57 //! Performs discretization of model edges using assigned edge discret algorithm.
58 //! @return True on success, False elsewhere.
59 Standard_EXPORT virtual Standard_Boolean DiscretizeEdges()
61 if (myModel.IsNull() || myEdgeDiscret.IsNull())
63 return Standard_False;
66 // Discretize edges of a model.
67 return myEdgeDiscret->Perform(myModel, myParameters);
70 //! Performs healing of discrete model built by DiscretizeEdges() method
71 //! using assigned healing algorithm.
72 //! @return True on success, False elsewhere.
73 Standard_EXPORT virtual Standard_Boolean HealModel()
77 return Standard_False;
80 return myModelHealer.IsNull() ?
82 myModelHealer->Perform(myModel, myParameters);
85 //! Performs pre-processing of discrete model using assigned algorithm.
86 //! Performs auxiliary actions such as cleaning shape from old triangulation.
87 //! @return True on success, False elsewhere.
88 Standard_EXPORT virtual Standard_Boolean PreProcessModel()
92 return Standard_False;
95 return myPreProcessor.IsNull() ?
97 myPreProcessor->Perform(myModel, myParameters);
100 //! Performs meshing of faces of discrete model using assigned meshing algorithm.
101 //! @return True on success, False elsewhere.
102 Standard_EXPORT virtual Standard_Boolean DiscretizeFaces()
104 if (myModel.IsNull() || myFaceDiscret.IsNull())
106 return Standard_False;
109 // Discretize faces of a model.
110 return myFaceDiscret->Perform(myModel, myParameters);
113 //! Performs post-processing of discrete model using assigned algorithm.
114 //! @return True on success, False elsewhere.
115 Standard_EXPORT virtual Standard_Boolean PostProcessModel()
117 if (myModel.IsNull())
119 return Standard_False;
122 return myPostProcessor.IsNull() ?
124 myPostProcessor->Perform(myModel, myParameters);
127 //! Cleans temporary context data.
128 Standard_EXPORT virtual void Clean()
130 if (myParameters.CleanModel)
136 //! Gets instance of a tool to be used to build discrete model.
137 inline const Handle (IMeshTools_ModelBuilder)& GetModelBuilder () const
139 return myModelBuilder;
142 //! Sets instance of a tool to be used to build discrete model.
143 inline void SetModelBuilder (const Handle (IMeshTools_ModelBuilder)& theBuilder)
145 myModelBuilder = theBuilder;
148 //! Gets instance of a tool to be used to discretize edges of a model.
149 inline const Handle (IMeshTools_ModelAlgo)& GetEdgeDiscret () const
151 return myEdgeDiscret;
154 //! Sets instance of a tool to be used to discretize edges of a model.
155 inline void SetEdgeDiscret (const Handle (IMeshTools_ModelAlgo)& theEdgeDiscret)
157 myEdgeDiscret = theEdgeDiscret;
160 //! Gets instance of a tool to be used to heal discrete model.
161 inline const Handle(IMeshTools_ModelAlgo)& GetModelHealer() const
163 return myModelHealer;
166 //! Sets instance of a tool to be used to heal discrete model.
167 inline void SetModelHealer(const Handle(IMeshTools_ModelAlgo)& theModelHealer)
169 myModelHealer = theModelHealer;
172 //! Gets instance of pre-processing algorithm.
173 inline const Handle(IMeshTools_ModelAlgo)& GetPreProcessor() const
175 return myPreProcessor;
178 //! Sets instance of pre-processing algorithm.
179 inline void SetPreProcessor(const Handle(IMeshTools_ModelAlgo)& thePreProcessor)
181 myPreProcessor = thePreProcessor;
184 //! Gets instance of meshing algorithm.
185 inline const Handle(IMeshTools_ModelAlgo)& GetFaceDiscret() const
187 return myFaceDiscret;
190 //! Sets instance of meshing algorithm.
191 inline void SetFaceDiscret(const Handle(IMeshTools_ModelAlgo)& theFaceDiscret)
193 myFaceDiscret = theFaceDiscret;
196 //! Gets instance of post-processing algorithm.
197 inline const Handle(IMeshTools_ModelAlgo)& GetPostProcessor() const
199 return myPostProcessor;
202 //! Sets instance of post-processing algorithm.
203 inline void SetPostProcessor(const Handle(IMeshTools_ModelAlgo)& thePostProcessor)
205 myPostProcessor = thePostProcessor;
208 //! Gets parameters to be used for meshing.
209 inline const IMeshTools_Parameters& GetParameters () const
214 //! Gets reference to parameters to be used for meshing.
215 inline IMeshTools_Parameters& ChangeParameters ()
220 //! Returns discrete model of a shape.
221 inline const Handle (IMeshData_Model)& GetModel () const
226 DEFINE_STANDARD_RTTI_INLINE(IMeshTools_Context, IMeshData_Shape)
230 Handle (IMeshTools_ModelBuilder) myModelBuilder;
231 Handle (IMeshData_Model) myModel;
232 Handle (IMeshTools_ModelAlgo) myEdgeDiscret;
233 Handle (IMeshTools_ModelAlgo) myModelHealer;
234 Handle (IMeshTools_ModelAlgo) myPreProcessor;
235 Handle (IMeshTools_ModelAlgo) myFaceDiscret;
236 Handle (IMeshTools_ModelAlgo) myPostProcessor;
237 IMeshTools_Parameters myParameters;