1 // Copyright (c) 2013 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _BRepMesh_DiscretFactory_HeaderFile
15 #define _BRepMesh_DiscretFactory_HeaderFile
17 #include <Standard.hxx>
18 #include <Standard_DefineAlloc.hxx>
19 #include <Standard_Macro.hxx>
20 #include <BRepMesh_PluginEntryType.hxx>
21 #include <BRepMesh_FactoryError.hxx>
22 #include <TColStd_MapOfAsciiString.hxx>
23 #include <TCollection_AsciiString.hxx>
24 #include <Plugin_MapOfFunctions.hxx>
25 #include <BRepMesh_DiscretRoot.hxx>
29 //! This class intended to setup / retrieve default triangulation algorithm. <br>
30 //! Use BRepMesh_DiscretFactory::Get() static method to retrieve global Factory instance. <br>
31 //! Use BRepMesh_DiscretFactory::Discret() method to retrieve meshing tool. <br>
32 class BRepMesh_DiscretFactory
38 //! Returns the global factory instance.
39 Standard_EXPORT static BRepMesh_DiscretFactory& Get();
41 //! Returns the list of registered meshing algorithms.
42 inline const TColStd_MapOfAsciiString& Names() const
47 //! Setup meshing algorithm by name. <br>
48 //! Returns TRUE if requested tool is available. <br>
49 //! On fail Factory will continue to use previous algo.
50 Standard_Boolean SetDefaultName(const TCollection_AsciiString& theName)
52 return SetDefault(theName, myFunctionName);
55 //! Returns name for current meshing algorithm.
56 inline const TCollection_AsciiString& DefaultName() const
61 //! Advanced function. Changes function name to retrieve from plugin. <br>
62 //! Returns TRUE if requested tool is available. <br>
63 //! On fail Factory will continue to use previous algo.
64 Standard_Boolean SetFunctionName(const TCollection_AsciiString& theFuncName)
66 return SetDefault(myDefaultName, theFuncName);
69 //! Returns function name that should be exported by plugin.
70 inline const TCollection_AsciiString& FunctionName() const
72 return myFunctionName;
75 //! Returns error status for last meshing algorithm switch.
76 inline BRepMesh_FactoryError ErrorStatus() const
81 //! Setup meshing algorithm that should be created by this Factory. <br>
82 //! Returns TRUE if requested tool is available. <br>
83 //! On fail Factory will continue to use previous algo. <br>
84 //! Call ::ErrorStatus() method to retrieve fault reason.
85 Standard_EXPORT Standard_Boolean SetDefault(const TCollection_AsciiString& theName,
86 const TCollection_AsciiString& theFuncName = "DISCRETALGO");
88 //! Returns triangulation algorithm instance.
89 //! @param theShape shape to be meshed.
90 //! @param theLinDeflection linear deflection to be used for meshing.
91 //! @param theAngDeflection angular deflection to be used for meshing.
92 Standard_EXPORT Handle(BRepMesh_DiscretRoot) Discret(const TopoDS_Shape& theShape,
93 const Standard_Real theLinDeflection,
94 const Standard_Real theAngDeflection);
99 Standard_EXPORT BRepMesh_DiscretFactory();
102 Standard_EXPORT virtual ~BRepMesh_DiscretFactory();
104 //! Clears factory data.
105 Standard_EXPORT void clear();
107 BRepMesh_PluginEntryType myPluginEntry;
108 BRepMesh_FactoryError myErrorStatus;
109 TColStd_MapOfAsciiString myNames;
110 TCollection_AsciiString myDefaultName;
111 TCollection_AsciiString myFunctionName;
112 Plugin_MapOfFunctions myFactoryMethods;