Salome HOME
First publish of HEXABLOCKcomponant
[modules/hexablock.git] / src / HEXABLOCK_I / HexQuad_impl.cxx
1 using namespace std;
2 #include "HEXABLOCK.hxx"
3 #include "utilities.h"
4
5 #include <string>
6
7 #include "hexa_base.hxx"
8 #include "HexQuad_impl.hxx"
9 #include "HexVertex_impl.hxx"
10 #include "HexEdge_impl.hxx"
11 #include "HexShape.hxx"
12
13 Quad_impl::Quad_impl( HEXA_NS::Quad *ptrCpp ):_quad_cpp(ptrCpp)
14 {
15 }
16
17 HEXA_NS::Quad* Quad_impl::GetImpl()
18   throw (SALOME::SALOME_Exception)
19 {
20   return _quad_cpp;
21 }
22
23 Edge_ptr Quad_impl::getEdge(::CORBA::Long n)
24   throw (SALOME::SALOME_Exception)
25 {
26   Edge_ptr result = Edge::_nil();
27
28   HEXA_NS::Edge* e = _quad_cpp->getEdge( n );
29   if ( e != NULL ){
30     Edge_impl* servantCorba = new Edge_impl(e);
31     result = servantCorba->_this();
32   }
33   return result;
34 }
35
36
37 Vertex_ptr Quad_impl::getVertex(::CORBA::Long n)
38    throw (SALOME::SALOME_Exception)
39 {
40   Vertex_ptr result = Vertex::_nil();
41
42   HEXA_NS::Vertex* v = _quad_cpp->getVertex( n );
43   if ( v != NULL ){
44     Vertex_impl* servantCorba = new Vertex_impl(v);
45     result = servantCorba->_this();
46   }
47   return result;
48 }
49
50
51
52
53 ::CORBA::Long Quad_impl::addAssociation( GEOM::GEOM_Object_ptr geom_object_2D)
54   throw (SALOME::SALOME_Exception)
55 {
56   ::CORBA::Long ok;
57   TopoDS_Shape aShape = HEXABLOCK::GetHEXABLOCKGen()->geomObjectToShape( geom_object_2D );
58
59   string strBrep = shape2string( aShape );
60   HEXA_NS::Shape* s = new HEXA_NS::Shape( strBrep );
61   ok = _quad_cpp->addAssociation( s );
62
63 //   _associations.push_back(GEOM::GEOM_Object::_duplicate( geom_object_2D ));
64
65   return ok;
66 }
67
68
69 GEOM::ListOfGO* Quad_impl::getAssociations() //CS_NOT_SPEC
70   throw (SALOME::SALOME_Exception)
71 // {
72 //   GEOM::ListOfGO* result = new GEOM::ListOfGO;
73 //   result->length( _associations.size() );
74 // 
75 //   CORBA::ULong i = 0;
76 //   for ( std::vector<GEOM::GEOM_Object_ptr>::const_iterator iter = _associations.begin();
77 //      iter != _associations.end();
78 //         ++iter){
79 // //       (*result)[i++] = *iter;
80 //       (*result)[i++] = GEOM::GEOM_Object::_duplicate( *iter );
81 //   }
82 //   return result;
83 // }
84 {
85   TopoDS_Shape aShape;
86   const std::vector<HEXA_NS::Shape*> shapes = _quad_cpp->getAssociations();
87
88   GEOM::ListOfGO* result = new GEOM::ListOfGO;
89   result->length( shapes.size() );
90
91   HEXABLOCK_ORB::EdgeAssociation assoc;
92   CORBA::ULong i = 0;
93   for ( std::vector<HEXA_NS::Shape*>::const_iterator iter = shapes.begin();
94         iter != shapes.end();
95         ++iter ){
96       aShape = string2shape( (*iter)->getBrep());
97       (*result)[ i++ ] = HEXABLOCK::GetHEXABLOCKGen()->shapeToGeomObject( aShape );
98   }
99
100   return result;
101 }
102
103
104
105
106
107
108
109
110 // void Quad_impl::setAssociation(GEOM::GEOM_Object_ptr geom_object_2D) throw (SALOME::SALOME_Exception)
111 // {
112 // }
113 // 
114 // GEOM::GEOM_Object_ptr Quad_impl::getAssociation() throw (SALOME::SALOME_Exception)
115 // {
116 // }
117 // 
118 // void Quad_impl::removeAssociation() throw (SALOME::SALOME_Exception)
119 // {
120 // }
121
122 void Quad_impl::setScalar( ::CORBA::Double val )throw (SALOME::SALOME_Exception)
123 {
124   _quad_cpp->setScalar(val);
125 }
126
127 void Quad_impl::dump() throw (SALOME::SALOME_Exception)
128 {
129   _quad_cpp->dump();
130 }
131
132
133 void Quad_impl::printName() throw (SALOME::SALOME_Exception)
134 {
135   _quad_cpp->printName();
136 }