1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "HEXABLOCK.hxx"
21 #include "utilities.h"
25 #include "hexa_base.hxx"
26 #include "HexEltBase.hxx"
27 #include "HexGroup.hxx"
29 #include "HexElements_impl.hxx"
31 #include "HexVertex_impl.hxx"
32 #include "HexEdge_impl.hxx"
33 #include "HexQuad_impl.hxx"
34 #include "HexHexa_impl.hxx"
35 #include "HexGroup_impl.hxx"
37 Group_impl::Group_impl( HEXA_NS::Group *ptrCpp ):_group_cpp(ptrCpp)
41 HEXA_NS::Group* Group_impl::GetImpl() throw (SALOME::SALOME_Exception)
46 char* Group_impl::getName() throw (SALOME::SALOME_Exception)
48 return CORBA::string_dup (_group_cpp->getName());
51 void Group_impl::setName(const char* name) throw (SALOME::SALOME_Exception)
53 _group_cpp->setName( name );
57 GroupKind Group_impl::getKind() throw (SALOME::SALOME_Exception)
59 HEXA_NS::EnumGroup k = _group_cpp->getKind();
62 case HEXA_NS::HexaCell: return HEXA_GROUP;
63 case HEXA_NS::QuadCell: return QUAD_GROUP;
64 case HEXA_NS::EdgeCell: return EDGE_GROUP;
65 case HEXA_NS::HexaNode: return HEXANODE_GROUP;
66 case HEXA_NS::QuadNode: return QUADNODE_GROUP;
67 case HEXA_NS::EdgeNode: return EDGENODE_GROUP;
68 case HEXA_NS::VertexNode: return VERTEXNODE_GROUP;
69 default : ASSERT(false);
74 ::CORBA::Long Group_impl::addElement(Element_ptr eIn) throw (SALOME::SALOME_Exception)
77 Vertex_impl* vInServant = ::DownCast<Vertex_impl*>( eIn );
78 Edge_impl* eInServant = ::DownCast<Edge_impl*>( eIn );
79 Quad_impl* qInServant = ::DownCast<Quad_impl*>( eIn );
80 Hexa_impl* hInServant = ::DownCast<Hexa_impl*>( eIn );
82 ASSERT( vInServant or eInServant or qInServant or hInServant );
83 HEXA_NS::EltBase* e = NULL;
85 e = vInServant->GetImpl();
86 } else if ( eInServant ) {
87 e = eInServant->GetImpl();
88 } else if ( qInServant ) {
89 e = qInServant->GetImpl();
90 } else if ( hInServant ) {
91 e = hInServant->GetImpl();
93 ok = _group_cpp->addElement(e);
99 ::CORBA::Long Group_impl::countElement() throw (SALOME::SALOME_Exception)
101 return _group_cpp->countElement();
105 Element_ptr Group_impl::getElement(::CORBA::Long index) throw (SALOME::SALOME_Exception)
107 HEXA_NS::EltBase* elt = _group_cpp->getElement(index);
109 HEXA_NS::Vertex* v = dynamic_cast<HEXA_NS::Vertex*>(elt);
110 HEXA_NS::Edge* e = dynamic_cast<HEXA_NS::Edge*>(elt);
111 HEXA_NS::Quad* q = dynamic_cast<HEXA_NS::Quad*>(elt);
112 HEXA_NS::Hexa* h = dynamic_cast<HEXA_NS::Hexa*>(elt);
114 ASSERT( v or e or q or h );
117 Vertex_impl* servantCorba = new Vertex_impl(v);
118 return servantCorba->_this();
120 Edge_impl* servantCorba = new Edge_impl(e);
121 return servantCorba->_this();
123 Quad_impl* servantCorba = new Quad_impl(q);
124 return servantCorba->_this();
126 Hexa_impl* servantCorba = new Hexa_impl(h);
127 return servantCorba->_this();
129 return Element::_nil();
134 ::CORBA::Long Group_impl::removeElement(Element_ptr eIn)
135 throw (SALOME::SALOME_Exception)
137 Vertex_impl* vInServant = ::DownCast<Vertex_impl*>( eIn );
138 Edge_impl* eInServant = ::DownCast<Edge_impl* >( eIn );
139 Quad_impl* qInServant = ::DownCast<Quad_impl* >( eIn );
140 Hexa_impl* hInServant = ::DownCast<Hexa_impl* >( eIn );
142 ASSERT( vInServant or eInServant or qInServant or hInServant );
143 HEXA_NS::EltBase* elt = NULL;
144 if (vInServant != NULL)
145 elt = vInServant->GetImpl();
146 else if (eInServant != NULL)
147 elt = eInServant->GetImpl();
148 else if (qInServant != NULL)
149 elt = qInServant->GetImpl();
150 else if (hInServant != NULL)
151 elt = hInServant->GetImpl();
153 ::CORBA::Long ier = _group_cpp->removeElement (elt);
157 void Group_impl::clearElement() throw (SALOME::SALOME_Exception)
159 _group_cpp->clearElement();