Salome HOME
Updated copyright comment
[plugins/ghs3dplugin.git] / src / GHS3DPlugin / GHS3DPlugin_OptimizerHypothesis_i.cxx
1 // Copyright (C) 2004-2024  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File      : GHS3DPlugin_OptimizerHypothesis_i.cxx
20 // Created   : Tue Nov  1 17:46:39 2016
21
22 #include "GHS3DPlugin_OptimizerHypothesis_i.hxx"
23
24 #include <SMESH_Gen.hxx>
25 #include <SMESH_PythonDump.hxx>
26
27 #include <Utils_CorbaException.hxx>
28
29 GHS3DPlugin_OptimizerHypothesis_i::
30 GHS3DPlugin_OptimizerHypothesis_i (PortableServer::POA_ptr thePOA,
31                                    ::SMESH_Gen*            theGenImpl)
32   : SALOME::GenericObj_i( thePOA ), 
33     SMESH_Hypothesis_i( thePOA ),
34     GHS3DPlugin_Hypothesis_i( thePOA, theGenImpl )
35 {
36   int id = myBaseImpl ? myBaseImpl->GetID() : theGenImpl->GetANewId();
37   if ( myBaseImpl )
38     delete myBaseImpl;
39
40   myBaseImpl = new ::GHS3DPlugin_OptimizerHypothesis( id, theGenImpl );
41 }
42
43 namespace
44 {
45   const char* dumpMode( GHS3DPlugin::Mode mode )
46   {
47     switch( mode ) {
48     case GHS3DPlugin::NO:   return "GHS3DPlugin.NO";
49     case GHS3DPlugin::YES:  return "GHS3DPlugin.YES";
50     case GHS3DPlugin::ONLY: return "GHS3DPlugin.ONLY";
51     default:                return "GHS3DPlugin.NO";
52     }
53     return 0;
54   }
55 }
56
57 void GHS3DPlugin_OptimizerHypothesis_i::SetOptimization( GHS3DPlugin::Mode mode )
58 {
59   if ((int) GetImpl()->GetOptimization() != (int) mode )
60   {
61     GetImpl()->SetOptimization( ::GHS3DPlugin_OptimizerHypothesis::Mode( mode ));
62     SMESH::TPythonDump() << _this() << ".SetOptimization( " << dumpMode( mode ) << " )";
63   }
64 }
65
66 GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetOptimization()
67 {
68   return GHS3DPlugin::Mode( GetImpl()->GetOptimization() );
69 }
70
71 void GHS3DPlugin_OptimizerHypothesis_i::SetSplitOverConstrained( GHS3DPlugin::Mode mode )
72 {
73   if ((int) GetImpl()->GetSplitOverConstrained() != (int) mode )
74   {
75     GetImpl()->SetSplitOverConstrained((::GHS3DPlugin_OptimizerHypothesis::Mode) mode );
76     SMESH::TPythonDump() << _this() << ".SetSplitOverConstrained( " << dumpMode( mode ) << " )";
77   }
78 }
79
80 GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetSplitOverConstrained()
81 {
82   return (GHS3DPlugin::Mode) GetImpl()->GetSplitOverConstrained();
83 }
84
85 void GHS3DPlugin_OptimizerHypothesis_i::SetSmoothOffSlivers( CORBA::Boolean toSmooth )
86 {
87   if ( GetImpl()->GetSmoothOffSlivers() != (bool) toSmooth )
88   {
89     GetImpl()->SetSmoothOffSlivers((bool) toSmooth );
90     SMESH::TPythonDump() << _this() << ".SetSmoothOffSlivers( " << toSmooth << " )";
91   }
92 }
93
94 CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::GetSmoothOffSlivers()
95 {
96   return GetImpl()->GetSmoothOffSlivers();
97 }
98
99 void GHS3DPlugin_OptimizerHypothesis_i::SetPThreadsMode( GHS3DPlugin::PThreadsMode mode )
100 {
101   if ((int) GetImpl()->GetPThreadsMode() != (int) mode )
102   {
103     GetImpl()->SetPThreadsMode((::GHS3DPlugin_OptimizerHypothesis::PThreadsMode) mode );
104
105     std::string modeStr;
106     switch( mode ) {
107     case ::GHS3DPlugin_OptimizerHypothesis::SAFE:       modeStr = "SAFE"; break;
108     case ::GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE: modeStr = "AGGRESSIVE"; break;
109     default:                                            modeStr = "NONE";
110     }
111     SMESH::TPythonDump() << _this() << ".SetPThreadsMode( GHS3DPlugin." << modeStr << " )";
112   }
113 }
114
115 GHS3DPlugin::PThreadsMode GHS3DPlugin_OptimizerHypothesis_i::GetPThreadsMode()
116 {
117   return (GHS3DPlugin::PThreadsMode) GetImpl()->GetPThreadsMode();
118 }
119
120 void GHS3DPlugin_OptimizerHypothesis_i::SetMaximalNumberOfThreads( CORBA::Short nb )
121 {
122   if ( GetImpl()->GetMaximalNumberOfThreads() != nb )
123   {
124     GetImpl()->SetMaximalNumberOfThreads( nb );
125     SMESH::TPythonDump() << _this() << ".SetMaximalNumberOfThreads( " << nb << " )";
126   }
127 }
128
129 CORBA::Short GHS3DPlugin_OptimizerHypothesis_i::GetMaximalNumberOfThreads()
130 {
131   return (CORBA::Short) GetImpl()->GetMaximalNumberOfThreads();
132 }
133
134 ::GHS3DPlugin_OptimizerHypothesis* GHS3DPlugin_OptimizerHypothesis_i::GetImpl()
135 {
136   return (::GHS3DPlugin_OptimizerHypothesis*)myBaseImpl;
137 }
138
139 CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::IsDimSupported( SMESH::Dimension type )
140 {
141   return type == SMESH::DIM_3D;
142 }
143
144