Salome HOME
d2b205ef08422d822c73952f9d8458f529fafea3
[plugins/ghs3dplugin.git] / src / GHS3DPlugin / GHS3DPlugin_OptimizerHypothesis_i.cxx
1 // Copyright (C) 2004-2016  CEA/DEN, EDF R&D
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                                    int                     theStudyId,
32                                    ::SMESH_Gen*            theGenImpl)
33   : SALOME::GenericObj_i( thePOA ), 
34     SMESH_Hypothesis_i( thePOA ),
35     GHS3DPlugin_Hypothesis_i( thePOA, theStudyId, theGenImpl )
36 {
37   int id = myBaseImpl ? myBaseImpl->GetID() : theGenImpl->GetANewId();
38   if ( myBaseImpl )
39     delete myBaseImpl;
40
41   myBaseImpl = new ::GHS3DPlugin_OptimizerHypothesis( id, theStudyId, theGenImpl );
42 }
43
44 namespace
45 {
46   const char* dumpMode( GHS3DPlugin::Mode mode )
47   {
48     switch( mode ) {
49     case GHS3DPlugin::NO:   return "GHS3DPlugin.NO";
50     case GHS3DPlugin::YES:  return "GHS3DPlugin.YES";
51     case GHS3DPlugin::ONLY: return "GHS3DPlugin.ONLY";
52     default:                return "GHS3DPlugin.NO";
53     }
54     return 0;
55   }
56 }
57
58 void GHS3DPlugin_OptimizerHypothesis_i::SetOptimization( GHS3DPlugin::Mode mode )
59 {
60   if ((int) GetImpl()->GetOptimization() != (int) mode )
61   {
62     GetImpl()->SetOptimization( ::GHS3DPlugin_OptimizerHypothesis::Mode( mode ));
63     SMESH::TPythonDump() << _this() << ".SetOptimization( " << dumpMode( mode ) << " )";
64   }
65 }
66
67 GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetOptimization()
68 {
69   return GHS3DPlugin::Mode( GetImpl()->GetOptimization() );
70 }
71
72 void GHS3DPlugin_OptimizerHypothesis_i::SetSplitOverConstrained( GHS3DPlugin::Mode mode )
73 {
74   if ((int) GetImpl()->GetSplitOverConstrained() != (int) mode )
75   {
76     GetImpl()->SetSplitOverConstrained((::GHS3DPlugin_OptimizerHypothesis::Mode) mode );
77     SMESH::TPythonDump() << _this() << ".SetSplitOverConstrained( " << dumpMode( mode ) << " )";
78   }
79 }
80
81 GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetSplitOverConstrained()
82 {
83   return (GHS3DPlugin::Mode) GetImpl()->GetSplitOverConstrained();
84 }
85
86 void GHS3DPlugin_OptimizerHypothesis_i::SetSmoothOffSlivers( CORBA::Boolean toSmooth )
87 {
88   if ( GetImpl()->GetSmoothOffSlivers() != (bool) toSmooth )
89   {
90     GetImpl()->SetSmoothOffSlivers((bool) toSmooth );
91     SMESH::TPythonDump() << _this() << ".SetSmoothOffSlivers( " << toSmooth << " )";
92   }
93 }
94
95 CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::GetSmoothOffSlivers()
96 {
97   return GetImpl()->GetSmoothOffSlivers();
98 }
99
100 void GHS3DPlugin_OptimizerHypothesis_i::SetPThreadsMode( GHS3DPlugin::PThreadsMode mode )
101 {
102   if ((int) GetImpl()->GetPThreadsMode() != (int) mode )
103   {
104     GetImpl()->SetPThreadsMode((::GHS3DPlugin_OptimizerHypothesis::PThreadsMode) mode );
105
106     std::string modeStr;
107     switch( mode ) {
108     case ::GHS3DPlugin_OptimizerHypothesis::SAFE:       modeStr = "SAFE"; break;
109     case ::GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE: modeStr = "AGGRESSIVE"; break;
110     default:                                            modeStr = "NONE";
111     }
112     SMESH::TPythonDump() << _this() << ".SetPThreadsMode( GHS3DPlugin." << modeStr << " )";
113   }
114 }
115
116 GHS3DPlugin::PThreadsMode GHS3DPlugin_OptimizerHypothesis_i::GetPThreadsMode()
117 {
118   return (GHS3DPlugin::PThreadsMode) GetImpl()->GetPThreadsMode();
119 }
120
121 void GHS3DPlugin_OptimizerHypothesis_i::SetMaximalNumberOfThreads( CORBA::Short nb )
122 {
123   if ( GetImpl()->GetMaximalNumberOfThreads() != nb )
124   {
125     GetImpl()->SetMaximalNumberOfThreads( nb );
126     SMESH::TPythonDump() << _this() << ".SetMaximalNumberOfThreads( " << nb << " )";
127   }
128 }
129
130 CORBA::Short GHS3DPlugin_OptimizerHypothesis_i::GetMaximalNumberOfThreads()
131 {
132   return (CORBA::Short) GetImpl()->GetMaximalNumberOfThreads();
133 }
134
135 ::GHS3DPlugin_OptimizerHypothesis* GHS3DPlugin_OptimizerHypothesis_i::GetImpl()
136 {
137   return (::GHS3DPlugin_OptimizerHypothesis*)myBaseImpl;
138 }
139
140 CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::IsDimSupported( SMESH::Dimension type )
141 {
142   return type == SMESH::DIM_3D;
143 }
144
145