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