Version: 9.16.0
SMESH_Hypothesis_i.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, OPEN CASCADE
2//
3// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5//
6// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19//
20// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21//
22
23// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
24// File : SMESH_Hypothesis_i.hxx
25// Author : Paul RASCLE, EDF
26// Module : SMESH
27//
28#ifndef _SMESH_HYPOTHESIS_I_HXX_
29#define _SMESH_HYPOTHESIS_I_HXX_
30
31#include "SMESH.hxx"
32
33#include <SALOMEconfig.h>
34#include CORBA_SERVER_HEADER(SMESH_Hypothesis)
35
36#include "SMESH_Hypothesis.hxx"
37#include "SALOME_GenericObj_i.hh"
38
39#include "SMESH_Gen.hxx"
40
41#include <map>
42#include <string>
43#include <vector>
44
45class TCollection_AsciiString;
46
47// ======================================================
48// Generic hypothesis
49// ======================================================
51 public virtual POA_SMESH::SMESH_Hypothesis,
52 public virtual SALOME::GenericObj_i
53{
54public:
55 // Constructor : placed in protected section to prohibit creation of generic class instance
56 SMESH_Hypothesis_i( PortableServer::POA_ptr thePOA );
57
58public:
59 // Destructor
60 virtual ~SMESH_Hypothesis_i();
61
62 // Get type name of hypothesis
63 virtual char* GetName();
64
65 // Get plugin library name of hypothesis
66 virtual char* GetLibName();
67
68 // Set plugin library name of hypothesis
69 void SetLibName( const char* theLibName );
70
71 // Get unique id of hypothesis
72 virtual CORBA::Short GetId();
73
74 // Return true if a hypothesis has parameters
75 virtual CORBA::Boolean HasParameters();
76
77 // Set the variable parameter (a variable name or a parameter value); \a method is a name
78 // of method setting this parameter.
79 // This method must be called by the hypothesis creator just before calling hyp->method()
80 virtual void SetVarParameter (const char* parameter, const char* method);
81
82 // Return the variable parameter used at Hypothesis Creation by the name of method
83 // setting this parameter. The returned variable name is used at Hypothesis Edition.
84 virtual char* GetVarParameter (const char* methodName);
85
86 // Store a hypothesis wrapping this not published one. This hyp, which has
87 // no own parameters but is published, is used to store variables defining parameters
88 // of this hypothesis. This method is to be called before setting parameters
89 // of this hypothesis.
90 virtual void SetHolderHypothesis(const SMESH::SMESH_Hypothesis_ptr hyp);
91
92 //Return true if hypothesis was published in study
93 bool IsPublished();
94
95 // Get implementation
96 ::SMESH_Hypothesis* GetImpl();
97
98 // Persistence
99 virtual char* SaveTo();
100 virtual void LoadFrom( const char* theStream );
101 virtual void UpdateAsMeshesRestored(); // for hyps needing full study data restored
102
103
104 // Methods for copying mesh definition to other geometry
105
106 // Return geometry this hypothesis depends on. Return false if there is no geometry parameter
107 virtual bool getObjectsDependOn( std::vector< std::string > & entryArray,
108 std::vector< int > & subIDArray ) const = 0;
109
110 // Set new geometry instead of that returned by getObjectsDependOn()
111 virtual bool setObjectsDependOn( std::vector< std::string > & entryArray,
112 std::vector< int > & subIDArray ) = 0;
113
114 protected:
115
116 // base hypothesis implementation
118
119 // a published hypothesis wrapping this not published one
120 SMESH::SMESH_Hypothesis_var myHolder;
121
122 // variable parameters
123 std::map< std::string, std::string > myMethod2VarParams;
124
125 public:
126 // Methods for backward compatibility of notebook variables
127
128 // restore myMethod2VarParams by parameters stored in an old study
129 virtual void setOldParameters (const char* theParameters);
130
131 // method used to convert variable parameters stored in an old study
132 // into myMethod2VarParams. It should return a method name for an index of
133 // variable parameters. Index is countered from zero
134 virtual std::string getMethodOfParameter(const int /*paramIndex*/, int /*nbVars*/) const { return ""; }
135
136 // method intended to remove explicit treatment of Netgen hypotheses from SMESH_NoteBook
137 virtual int getParamIndex(const TCollection_AsciiString& /*method*/, int /*nbVars*/) const { return -1; }
138};
139
140// ======================================================
141// Generic hypothesis creator
142// ======================================================
144{
145public:
146 // Create a hypothesis
147 virtual SMESH_Hypothesis_i* Create(PortableServer::POA_ptr thePOA,
148 ::SMESH_Gen* theGenImpl) = 0;
150
151 // Return the name of IDL module
152 virtual std::string GetModuleName() = 0;
153
154 // Check if an algorithm is applicable to a shape
155 virtual bool IsApplicable( const TopoDS_Shape &S, bool /*toCheckAll*/, int algoDim )
156 {
157 return IsShapeOfDim( S, algoDim );
158 }
159
160 // Check if a shape includes sub-shapes of a given dimension
161 static bool IsShapeOfDim( const TopoDS_Shape &S, int dim );
162};
163
164//=============================================================================
165//
166// Specific Hypothesis Creators are generated with a template which inherits a
167// generic hypothesis creator. Each creator returns an hypothesis of the type
168// given in the template.
169//
170//=============================================================================
171template <class T> class HypothesisCreator_i: public GenericHypothesisCreator_i
172{
173public:
174 virtual SMESH_Hypothesis_i* Create (PortableServer::POA_ptr thePOA,
175 ::SMESH_Gen* theGenImpl)
176 {
177 return new T (thePOA, theGenImpl);
178 };
179};
180
181#endif
#define SMESH_I_EXPORT
Definition: SMESH.hxx:39
Definition: SMESH_Hypothesis_i.hxx:144
virtual SMESH_Hypothesis_i * Create(PortableServer::POA_ptr thePOA, ::SMESH_Gen *theGenImpl)=0
virtual std::string GetModuleName()=0
virtual ~GenericHypothesisCreator_i()
Definition: SMESH_Hypothesis_i.hxx:149
virtual bool IsApplicable(const TopoDS_Shape &S, bool, int algoDim)
Definition: SMESH_Hypothesis_i.hxx:155
Definition: SMESH_Hypothesis_i.hxx:172
virtual SMESH_Hypothesis_i * Create(PortableServer::POA_ptr thePOA, ::SMESH_Gen *theGenImpl)
Definition: SMESH_Hypothesis_i.hxx:174
Definition: SMESH_Gen.hxx:68
Definition: SMESH_Hypothesis_i.hxx:53
virtual bool setObjectsDependOn(std::vector< std::string > &entryArray, std::vector< int > &subIDArray)=0
virtual std::string getMethodOfParameter(const int, int) const
Definition: SMESH_Hypothesis_i.hxx:134
std::map< std::string, std::string > myMethod2VarParams
Definition: SMESH_Hypothesis_i.hxx:123
::SMESH_Hypothesis * myBaseImpl
Definition: SMESH_Hypothesis_i.hxx:117
SMESH::SMESH_Hypothesis_var myHolder
Definition: SMESH_Hypothesis_i.hxx:120
virtual int getParamIndex(const TCollection_AsciiString &, int) const
Definition: SMESH_Hypothesis_i.hxx:137
virtual bool getObjectsDependOn(std::vector< std::string > &entryArray, std::vector< int > &subIDArray) const =0
Definition: SMESH_Hypothesis.hxx:48
QString GetName(const Handle(SALOME_InteractiveObject)&theIO)
Definition: SMESHGUI_Utils.cxx:252