fc9b36d6 |
1 | // Copyright (c) 2013 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #ifndef _BRepMesh_DiscretFactory_HeaderFile |
15 | #define _BRepMesh_DiscretFactory_HeaderFile |
16 | |
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> |
26 | |
fc9b36d6 |
27 | class TopoDS_Shape; |
28 | |
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 |
33 | { |
34 | public: |
35 | |
36 | DEFINE_STANDARD_ALLOC |
37 | |
38 | //! Returns the global factory instance. |
39 | Standard_EXPORT static BRepMesh_DiscretFactory& Get(); |
40 | |
41 | //! Returns the list of registered meshing algorithms. |
42 | inline const TColStd_MapOfAsciiString& Names() const |
43 | { |
44 | return myNames; |
45 | } |
46 | |
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_EXPORT Standard_Boolean SetDefaultName(const TCollection_AsciiString& theName) |
51 | { |
52 | return SetDefault(theName, myFunctionName); |
53 | } |
54 | |
55 | //! Returns name for current meshing algorithm. |
56 | inline const TCollection_AsciiString& DefaultName() const |
57 | { |
58 | return myDefaultName; |
59 | } |
60 | |
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_EXPORT Standard_Boolean SetFunctionName(const TCollection_AsciiString& theFuncName) |
65 | { |
66 | return SetDefault(myDefaultName, theFuncName); |
67 | } |
68 | |
69 | //! Returns function name that should be exported by plugin. |
70 | inline const TCollection_AsciiString& FunctionName() const |
71 | { |
72 | return myFunctionName; |
73 | } |
74 | |
75 | //! Returns error status for last meshing algorithm switch. |
76 | inline BRepMesh_FactoryError ErrorStatus() const |
77 | { |
78 | return myErrorStatus; |
79 | } |
80 | |
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"); |
87 | |
88 | //! Returns triangulation algorithm instance. |
848fa7e3 |
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. |
fc9b36d6 |
92 | Standard_EXPORT Handle(BRepMesh_DiscretRoot) Discret(const TopoDS_Shape& theShape, |
93 | const Standard_Real theLinDeflection, |
94 | const Standard_Real theAngDeflection); |
95 | |
96 | protected: |
97 | |
98 | //! Constructor |
99 | Standard_EXPORT BRepMesh_DiscretFactory(); |
100 | |
101 | //! Destructor |
102 | Standard_EXPORT virtual ~BRepMesh_DiscretFactory(); |
103 | |
104 | //! Clears factory data. |
105 | Standard_EXPORT void clear(); |
106 | |
107 | BRepMesh_PluginEntryType myPluginEntry; |
108 | BRepMesh_FactoryError myErrorStatus; |
109 | TColStd_MapOfAsciiString myNames; |
110 | TCollection_AsciiString myDefaultName; |
111 | TCollection_AsciiString myFunctionName; |
112 | Plugin_MapOfFunctions myFactoryMethods; |
113 | }; |
114 | |
115 | #endif |