Salome HOME
Merge from V6_main_20120808 08Aug12
[plugins/hexablockplugin.git] / src / HEXABLOCKPlugin / HEXABLOCKPlugin_Hypothesis_i.cxx
1 // Copyright (C) 2009-2012  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.
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
20 // File      : HEXABLOCKPlugin_Hypothesis_i.cxx
21 // Created   : Wed Apr  2 13:53:01 2008
22 // Author    : Lioka RAZAFINDRAZAKA (CEA)
23 //
24 #include <SMESH_Gen.hxx>
25 #include <SMESH_PythonDump.hxx>
26 #include <SMESH_Mesh_i.hxx>
27
28 #include "HEXABLOCK.hxx"
29 #include "HEXABLOCKPlugin_Hypothesis_i.hxx"
30 #include "HexDocument_impl.hxx"
31
32 #include <Utils_CorbaException.hxx>
33 #include <utilities.h>
34
35 #ifdef _DEBUG_
36 static int MYDEBUG = 1;
37 #else
38 static int MYDEBUG = 0;
39 #endif
40
41 //=======================================================================
42 //function : HEXABLOCKPlugin_Hypothesis_i
43 //=======================================================================
44
45 HEXABLOCKPlugin_Hypothesis_i::HEXABLOCKPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
46                                                     int                     theStudyId,
47                                                     ::SMESH_Gen*            theGenImpl)
48   : SALOME::GenericObj_i( thePOA ), 
49     SMESH_Hypothesis_i( thePOA )
50 {
51   if(MYDEBUG) MESSAGE( "HEXABLOCKPlugin_Hypothesis_i::HEXABLOCKPlugin_Hypothesis_i" );
52   myBaseImpl = new ::HEXABLOCKPlugin_Hypothesis (theGenImpl->GetANewId(),
53                                               theStudyId,
54                                               theGenImpl);
55   _poa = PortableServer::POA::_duplicate(thePOA);
56 }
57
58 //=======================================================================
59 //function : ~HEXABLOCKPlugin_Hypothesis_i
60 //=======================================================================
61
62 HEXABLOCKPlugin_Hypothesis_i::~HEXABLOCKPlugin_Hypothesis_i()
63 {
64   if(MYDEBUG) MESSAGE( "HEXABLOCKPlugin_Hypothesis_i::~HEXABLOCKPlugin_Hypothesis_i" );
65 }
66
67 //=============================================================================
68 /*!
69  *  Get implementation
70  */
71 //=============================================================================
72
73 ::HEXABLOCKPlugin_Hypothesis* HEXABLOCKPlugin_Hypothesis_i::GetImpl()
74 {
75   return (::HEXABLOCKPlugin_Hypothesis*)myBaseImpl;
76 }
77
78 //================================================================================
79 /*!
80  * \brief Verify whether hypothesis supports given entity type 
81  */
82 //================================================================================  
83
84 CORBA::Boolean HEXABLOCKPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
85 {
86   return type == SMESH::DIM_3D;
87 }
88
89 //================================================================================
90 /*!
91  * Define the document to be meshed, mandatory
92  */
93 //================================================================================
94
95 HEXABLOCK_ORB::Document_ptr HEXABLOCKPlugin_Hypothesis_i::GetDocument() {
96   ASSERT(myBaseImpl);
97   HEXA_NS::Document* d = this->GetImpl()->GetDocument();
98   Document_impl* servantCorba = new Document_impl(_poa, d);
99   HEXABLOCK_ORB::Document_ptr result = servantCorba->_this();
100   return result;
101 }
102
103 void HEXABLOCKPlugin_Hypothesis_i::SetDocument(HEXABLOCK_ORB::Document_ptr doc) {
104   Document_impl* docServant = ::DownCast<Document_impl*>(doc);
105   if ( docServant ) {
106     HEXA_NS::Document* d = docServant->GetImpl();
107     ASSERT(myBaseImpl);
108     this->GetImpl()->SetDocument(d);
109   }
110 }
111
112 //================================================================================
113 /*!
114  * To define the hight dimension to generated: 3 = hexas, 2 = quads, 1 = segments, 0 = nodes
115  */
116 //================================================================================
117
118 CORBA::Long HEXABLOCKPlugin_Hypothesis_i::GetDimension() {
119   ASSERT(myBaseImpl);
120   return this->GetImpl()->GetDimension();
121 }
122
123 void HEXABLOCKPlugin_Hypothesis_i::SetDimension(CORBA::Long dim) {
124   ASSERT(myBaseImpl);
125   this->GetImpl()->SetDimension(dim);
126 }