12 #include "MEDMEM_DriversDef.hxx"
13 #include "MEDMEM_Field.hxx"
14 #include "MEDMEM_Mesh.hxx"
16 #include "MEDMEM_Support.hxx"
17 #include "MEDMEM_Family.hxx"
18 #include "MEDMEM_Group.hxx"
19 #include "MEDMEM_Coordinate.hxx"
20 #include "MEDMEM_Connectivity.hxx"
21 #include "MEDMEM_CellModel.hxx"
22 using namespace MEDMEM;
23 //#include "MEDMEM_Grid.hxx" this inclision should have never be here !!!
25 //update Families with content list
26 //int family_count(int family_number, int count, int * entities_number, int * entities_list) ;
28 // ------- Drivers Management Part
30 // MESH::INSTANCE_DE<MED_MESH_RDONLY_DRIVER> MESH::inst_med_rdonly ;
31 //const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ;
33 // Add a similar line for your personnal driver (step 3)
35 MESH::INSTANCE_DE<MED_MESH_RDWR_DRIVER> MESH::inst_med ;
36 MESH::INSTANCE_DE<GIBI_MESH_RDWR_DRIVER> MESH::inst_gibi ;
37 MESH::INSTANCE_DE<VTK_MESH_DRIVER> MESH::inst_vtk;
39 // Add your own driver in the driver list (step 4)
40 // Note the list must be coherent with the driver type list defined in MEDMEM_DRIVER.hxx.
41 const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med, &MESH::inst_gibi, &MESH::inst_vtk } ;
43 /*! Add a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>. The meshname used in the file
44 is <driverName>. addDriver returns an int handler. */
45 int MESH::addDriver(driverTypes driverType,
46 const string & fileName/*="Default File Name.med"*/,const string & driverName/*="Default Mesh Name"*/) {
48 const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\") : ";
52 int itDriver = (int) NO_DRIVER;
58 SCRUTE(instances[driverType]);
63 itDriver = (int) driverType ;
68 itDriver = (int) driverType ;
78 throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed"));
82 if (itDriver == ((int) NO_DRIVER))
83 throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "othe driver than MED_DRIVER GIBI_DRIVER and VT_DRIVER has been specified to the method which is not allowed"));
85 driver = instances[itDriver]->run(fileName, this) ;
87 _drivers.push_back(driver);
89 current = _drivers.size()-1;
91 _drivers[current]->setMeshName(driverName);
98 /*! Add an existing MESH driver. */
99 int MESH::addDriver(GENDRIVER & driver) {
100 const char * LOC = "MESH::addDriver(GENDRIVER &) : ";
103 // A faire : Vérifier que le driver est de type MESH.
104 GENDRIVER * newDriver = driver.copy() ;
106 _drivers.push_back(newDriver);
107 return _drivers.size()-1;
112 /*! Remove an existing MESH driver. */
113 void MESH::rmDriver (int index/*=0*/) {
114 const char * LOC = "MESH::rmDriver (int index=0): ";
117 if ( _drivers[index] ) {
118 //_drivers.erase(&_drivers[index]);
120 MESSAGE ("detruire");
123 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
124 << "The index given is invalid, index must be between 0 and |"
133 // ------ End of Drivers Management Part
138 const char * LOC = "MESH::init(): ";
142 string _name = "NOT DEFINED"; // A POSITIONNER EN FCT DES IOS ?
144 _coordinate = (COORDINATE *) NULL;
145 _connectivity = (CONNECTIVITY *) NULL;
147 _spaceDimension = MED_INVALID; // 0 ?!?
148 _meshDimension = MED_INVALID;
149 _numberOfNodes = MED_INVALID;
151 _numberOfNodesFamilies = 0; // MED_INVALID ?!?
152 _numberOfCellsFamilies = 0;
153 _numberOfFacesFamilies = 0;
154 _numberOfEdgesFamilies = 0;
156 _numberOfNodesGroups = 0; // MED_INVALID ?!?
157 _numberOfCellsGroups = 0;
158 _numberOfFacesGroups = 0;
159 _numberOfEdgesGroups = 0;
166 /*! Create an empty MESH. */
167 MESH::MESH():_coordinate(NULL),_connectivity(NULL), _isAGrid(false) {
174 _isAGrid = m._isAGrid;
176 if (m._coordinate != NULL)
177 _coordinate = new COORDINATE(* m._coordinate);
179 _coordinate = (COORDINATE *) NULL;
181 if (m._connectivity != NULL)
182 _connectivity = new CONNECTIVITY(* m._connectivity);
184 _connectivity = (CONNECTIVITY *) NULL;
186 _spaceDimension = m._spaceDimension;
187 _meshDimension = m._meshDimension;
188 _numberOfNodes = m._numberOfNodes;
190 _numberOfNodesFamilies = m._numberOfNodesFamilies;
191 _familyNode = m._familyNode;
192 for (int i=0; i<m._numberOfNodesFamilies; i++)
194 _familyNode[i] = new FAMILY(* m._familyNode[i]);
195 _familyNode[i]->setMesh(this);
198 _numberOfCellsFamilies = m._numberOfCellsFamilies;
199 _familyCell = m._familyCell;
200 for (int i=0; i<m._numberOfCellsFamilies; i++)
202 _familyCell[i] = new FAMILY(* m._familyCell[i]);
203 _familyCell[i]->setMesh(this);
206 _numberOfFacesFamilies = m._numberOfFacesFamilies;
207 _familyFace = m._familyFace;
208 for (int i=0; i<m._numberOfFacesFamilies; i++)
210 _familyFace[i] = new FAMILY(* m._familyFace[i]);
211 _familyFace[i]->setMesh(this);
214 _numberOfEdgesFamilies = m._numberOfEdgesFamilies;
215 _familyEdge = m._familyEdge;
216 for (int i=0; i<m._numberOfEdgesFamilies; i++)
218 _familyEdge[i] = new FAMILY(* m._familyEdge[i]);
219 _familyEdge[i]->setMesh(this);
222 _numberOfNodesGroups = m._numberOfNodesGroups;
223 _groupNode = m._groupNode;
224 for (int i=0; i<m._numberOfNodesGroups; i++)
226 _groupNode[i] = new GROUP(* m._groupNode[i]);
227 _groupNode[i]->setMesh(this);
230 _numberOfCellsGroups = m._numberOfCellsGroups;
231 _groupCell = m._groupCell;
232 for (int i=0; i<m._numberOfCellsGroups; i++)
234 _groupCell[i] = new GROUP(* m._groupCell[i]);
235 _groupCell[i]->setMesh(this);
238 _numberOfFacesGroups = m._numberOfFacesGroups;
239 _groupFace = m._groupFace;
240 for (int i=0; i<m._numberOfFacesGroups; i++)
242 _groupFace[i] = new GROUP(* m._groupFace[i]);
243 _groupFace[i]->setMesh(this);
246 _numberOfEdgesGroups = m._numberOfEdgesGroups;
247 _groupEdge = m._groupEdge;
248 for (int i=0; i<m._numberOfEdgesGroups; i++)
250 _groupEdge[i] = new GROUP(* m._groupEdge[i]);
251 _groupEdge[i]->setMesh(this);
254 //_drivers = m._drivers; //Recopie des drivers?
259 MESSAGE("MESH::~MESH() : Destroying the Mesh");
260 if (_coordinate != ((COORDINATE *) NULL)) delete _coordinate ;
261 if (_connectivity != ((CONNECTIVITY *) NULL)) delete _connectivity ;
263 size = _familyNode.size() ;
264 for (int i=0;i<size;i++)
265 delete _familyNode[i] ;
266 size = _familyCell.size() ;
267 for (int i=0;i<size;i++)
268 delete _familyCell[i] ;
269 size = _familyFace.size() ;
270 for (int i=0;i<size;i++)
271 delete _familyFace[i] ;
272 size = _familyEdge.size() ;
273 for (int i=0;i<size;i++)
274 delete _familyEdge[i] ;
275 size = _groupNode.size() ;
276 for (int i=0;i<size;i++)
277 delete _groupNode[i] ;
278 size = _groupCell.size() ;
279 for (int i=0;i<size;i++)
280 delete _groupCell[i] ;
281 size = _groupFace.size() ;
282 for (int i=0;i<size;i++)
283 delete _groupFace[i] ;
284 size = _groupEdge.size() ;
285 for (int i=0;i<size;i++)
286 delete _groupEdge[i] ;
288 MESSAGE("In this object MESH there is(are) " << _drivers.size() << " driver(s)");
290 for (unsigned int index=0; index < _drivers.size(); index++ )
292 SCRUTE(_drivers[index]);
293 if ( _drivers[index] != NULL) delete _drivers[index];
298 MESH & MESH::operator=(const MESH &m)
300 const char * LOC = "MESH & MESH::operator=(const MESH &m) : ";
303 MESSAGE(LOC <<"Not yet implemented, operating on the object " << m);
306 // ATTENTION CET OPERATEUR DE RECOPIE EST DANGEREUX POUR LES
307 // POINTEURS : ex : nodal_connectivity ???? EXPRES ????
308 // _drivers = m._drivers;
310 // space_dimension=m.space_dimension;
311 // mesh_dimension=m.mesh_dimension;
313 // nodes_count=m.nodes_count;
314 // coordinates=m.coordinates;
315 // coordinates_name=m.coordinates_name ;
316 // coordinates_unit=m.coordinates_unit ;
317 // nodes_numbers=m.nodes_numbers ;
319 // cells_types_count=m.cells_types_count;
320 // cells_type=m.cells_type;
321 // cells_count=m.cells_count;
322 // nodal_connectivity=m.nodal_connectivity;
324 // nodes_families_count=m.nodes_families_count;
325 // nodes_Families=m.nodes_Families;
327 // cells_families_count=m.cells_families_count;
328 // cells_Families=m.cells_Families;
330 // maximum_cell_number_by_node = m.maximum_cell_number_by_node;
331 // if (maximum_cell_number_by_node > 0)
333 // reverse_nodal_connectivity = m.reverse_nodal_connectivity;
334 // reverse_nodal_connectivity_index = m.reverse_nodal_connectivity_index ;
341 /*! Create a MESH object using a MESH driver of type (MED_DRIVER, ....) associated with file <fileName>.
342 The meshname <driverName> must already exists in the file.*/
343 MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string & driverName/*=""*/) throw (MEDEXCEPTION)
345 const char * LOC ="MESH::MESH(driverTypes driverType, const string & fileName="", const string & driverName="") : ";
356 MED_MESH_RDONLY_DRIVER myDriver(fileName,this);
357 myDriver.setMeshName(driverName);
358 current = addDriver(myDriver);
363 GIBI_MESH_RDONLY_DRIVER myDriver(fileName,this);
364 current = addDriver(myDriver);
369 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Driver type unknown : can't create driver!"));
374 // current = addDriver(driverType,fileName,driverName);
375 // switch(_drivers[current]->getAccessMode() ) {
376 // case MED_WRONLY : {
377 // MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must not be a MED_WRONLY accessMode");
378 // rmDriver(current);
383 _drivers[current]->open();
384 _drivers[current]->read();
385 _drivers[current]->close();
388 // ((GRID *) this)->fillMeshAfterRead();
394 // Node MESH::Donne_Barycentre(const Maille &m) const
396 // Node N=node[m[0]];
397 // for (int i=1;i<m.donne_nbr_sommets();i++) N=N+node[m[i]];
398 // N=N*(1.0/m.donne_nbr_sommets());
402 ostream & MEDMEM::operator<<(ostream &os, const MESH &myMesh)
404 int spacedimension = myMesh.getSpaceDimension();
405 int meshdimension = myMesh.getMeshDimension();
406 int numberofnodes = myMesh.getNumberOfNodes();
408 os << "Space Dimension : " << spacedimension << endl << endl;
410 os << "Mesh Dimension : " << meshdimension << endl << endl;
412 const double * coordinates = myMesh.getCoordinates(MED_FULL_INTERLACE);
413 os << "SHOW NODES COORDINATES : " << endl;
415 os << "Name :" << endl;
416 const string * coordinatesnames = myMesh.getCoordinatesNames();
417 for(int i=0; i<spacedimension ; i++)
419 os << " - " << coordinatesnames[i] << endl;
421 os << "Unit :" << endl;
422 const string * coordinatesunits = myMesh.getCoordinatesUnits();
423 for(int i=0; i<spacedimension ; i++)
425 os << " - " << coordinatesunits[i] << endl;
427 for(int i=0; i<numberofnodes ; i++)
429 os << "Nodes " << i+1 << " : ";
430 for (int j=0; j<spacedimension ; j++)
431 os << coordinates[i*spacedimension+j] << " ";
435 os << endl << "SHOW CONNECTIVITY :" << endl;
436 os << *myMesh._connectivity << endl;
438 medEntityMesh entity;
439 os << endl << "SHOW FAMILIES :" << endl << endl;
440 for (int k=1; k<=4; k++)
442 if (k==1) entity = MED_NODE;
443 if (k==2) entity = MED_CELL;
444 if (k==3) entity = MED_FACE;
445 if (k==4) entity = MED_EDGE;
446 int numberoffamilies = myMesh.getNumberOfFamilies(entity);
447 using namespace MED_FR;
448 os << "NumberOfFamilies on "<< entNames[(MED_FR::med_entite_maillage) entity] <<" : "<<numberoffamilies<<endl;
449 using namespace MED_EN;
450 for (int i=1; i<numberoffamilies+1;i++)
452 os << * myMesh.getFamily(entity,i) << endl;
456 os << endl << "SHOW GROUPS :" << endl << endl;
457 for (int k=1; k<=4; k++)
459 if (k==1) entity = MED_NODE;
460 if (k==2) entity = MED_CELL;
461 if (k==3) entity = MED_FACE;
462 if (k==4) entity = MED_EDGE;
463 int numberofgroups = myMesh.getNumberOfGroups(entity);
464 using namespace MED_FR;
465 os << "NumberOfGroups on "<< entNames[(MED_FR::med_entite_maillage) entity] <<" : "<<numberofgroups<<endl;
466 using namespace MED_EN;
467 for (int i=1; i<numberofgroups+1;i++)
469 os << * myMesh.getGroup(entity,i) << endl;
477 Get global number of element which have same connectivity than connectivity argument.
479 It do not take care of connectivity order (3,4,7,10 is same as 7,3,10,4).
481 Return -1 if not found.
483 int MESH::getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity) const
485 const char* LOC="MESH::getElementNumber " ;
488 int numberOfValue ; // size of connectivity array
489 CELLMODEL myType(Type) ;
490 if (ConnectivityType==MED_DESCENDING)
491 numberOfValue = myType.getNumberOfConstituents(1) ; // faces (3D) or edges (2D)
493 numberOfValue = myType.getNumberOfNodes() ; // nodes
495 const int * myReverseConnectivityValue = getReverseConnectivity(ConnectivityType,Entity) ;
496 const int * myReverseConnectivityIndex = getReverseConnectivityIndex(ConnectivityType,Entity) ;
498 // First node or face/edge
499 int indexBegin = myReverseConnectivityIndex[connectivity[0]-1] ;
500 int indexEnd = myReverseConnectivityIndex[connectivity[0]] ;
502 // list to put cells numbers
503 list<int> cellsList ;
504 list<int>::iterator itList ;
505 for (int i=indexBegin; i<indexEnd; i++)
506 cellsList.push_back(myReverseConnectivityValue[i-1]) ;
508 // Foreach node or face/edge in cell, we search cells which are in common.
509 // At the end, we must have only one !
511 for (int i=1; i<numberOfValue; i++) {
512 int connectivity_i = connectivity[i] ;
513 for (itList=cellsList.begin();itList!=cellsList.end();itList++) {
515 for (int j=myReverseConnectivityIndex[connectivity_i-1]; j<myReverseConnectivityIndex[connectivity_i]; j++) {
516 if ((*itList)==myReverseConnectivityValue[j-1]) {
522 itList=cellsList.erase(itList);
523 itList--; // well : rigth if itList = cellsList.begin() ??
528 if (cellsList.size()>1) // we have more than one cell
529 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Found more than one element !")) ;
531 if (cellsList.size()==0)
536 return cellsList.front() ;
541 Return a support which reference all elements on the boundary of mesh.
543 For instance, we could get only face in 3D and edge in 2D.
545 SUPPORT * MESH::getBoundaryElements(medEntityMesh Entity)
548 const char * LOC = "MESH::getBoundaryElements : " ;
551 // actually we could only get face (in 3D) and edge (in 2D)
552 if (_spaceDimension == 3)
553 if (Entity != MED_FACE)
554 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 3D mesh for entity "<<Entity<<" !"));
555 if (_spaceDimension == 2)
556 if (Entity != MED_EDGE)
557 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined in 2D mesh for entity "<<Entity<<" !"));
560 SUPPORT * mySupport = new SUPPORT(this,"Boundary",Entity);
561 //mySupport.setDescription("boundary of type ...");
562 mySupport->setAll(false);
565 const int * myConnectivityValue = getReverseConnectivity(MED_DESCENDING) ;
566 const int * myConnectivityIndex = getReverseConnectivityIndex(MED_DESCENDING) ;
567 int numberOf = getNumberOfElements(Entity,MED_ALL_ELEMENTS) ;
568 list<int> myElementsList ;
570 for (int i=0 ; i<numberOf; i++)
571 if (myConnectivityValue[myConnectivityIndex[i]] == 0) {
572 myElementsList.push_back(i+1) ;
575 // Well, we must know how many geometric type we have found
576 int * myListArray = new int[size] ;
578 list<int>::iterator myElementsListIt ;
579 for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
580 myListArray[id]=(*myElementsListIt) ;
584 int numberOfGeometricType ;
585 medGeometryElement* geometricType ;
586 int * numberOfGaussPoint ;
587 int * geometricTypeNumber ;
588 int * numberOfElements ;
589 //MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
590 int * mySkyLineArrayIndex ;
592 int numberOfType = getNumberOfTypes(Entity) ;
593 if (numberOfType == 1) { // wonderfull : it's easy !
594 numberOfGeometricType = 1 ;
595 geometricType = new medGeometryElement[1] ;
596 const medGeometryElement * allType = getTypes(Entity);
597 geometricType[0] = allType[0] ;
598 numberOfGaussPoint = new int[1] ;
599 numberOfGaussPoint[0] = 1 ;
600 geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
601 geometricTypeNumber[0] = 0 ;
602 numberOfElements = new int[1] ;
603 numberOfElements[0] = size ;
604 mySkyLineArrayIndex = new int[2] ;
605 mySkyLineArrayIndex[0]=1 ;
606 mySkyLineArrayIndex[1]=1+size ;
609 map<medGeometryElement,int> theType ;
610 for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
611 medGeometryElement myType = getElementType(Entity,*myElementsListIt) ;
612 if (theType.find(myType) != theType.end() )
617 numberOfGeometricType = theType.size() ;
618 geometricType = new medGeometryElement[numberOfGeometricType] ;
619 //const medGeometryElement * allType = getTypes(Entity); !! UNUSZED VARIABLE !!
620 numberOfGaussPoint = new int[numberOfGeometricType] ;
621 geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
622 numberOfElements = new int[numberOfGeometricType] ;
623 mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
625 mySkyLineArrayIndex[0]=1 ;
626 map<medGeometryElement,int>::iterator theTypeIt ;
627 for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
628 geometricType[index] = (*theTypeIt).first ;
629 numberOfGaussPoint[index] = 1 ;
630 geometricTypeNumber[index] = 0 ;
631 numberOfElements[index] = (*theTypeIt).second ;
632 mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfElements[index] ;
636 //mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
637 MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
639 mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
640 mySupport->setGeometricType(geometricType) ;
641 mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
642 mySupport->setNumberOfElements(numberOfElements) ;
643 mySupport->setTotalNumberOfElements(size) ;
644 // mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
645 mySupport->setNumber(mySkyLineArray) ;
647 delete[] numberOfElements;
648 delete[] geometricTypeNumber;
649 delete[] numberOfGaussPoint;
650 delete[] geometricType;
651 delete[] mySkyLineArrayIndex;
652 delete[] myListArray;
653 // delete mySkyLineArray;
659 FIELD<double>* MESH::getVolume(const SUPPORT * Support) const throw (MEDEXCEPTION)
661 const char * LOC = "MESH::getVolume(SUPPORT*) : ";
664 // Support must be on 3D elements
666 // Make sure that the MESH class is the same as the MESH class attribut
667 // in the class Support
668 MESH* myMesh = Support->getMesh();
670 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
672 int dim_space = getSpaceDimension();
673 medEntityMesh support_entity = Support->getEntity();
674 bool onAll = Support->isOnAllElements();
676 int nb_type, length_values;
677 const medGeometryElement* types;
679 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
680 const int* global_connectivity;
684 // nb_type = myMesh->getNumberOfTypes(support_entity);
685 // length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
686 // types = getTypes(support_entity);
690 nb_type = Support->getNumberOfTypes();
691 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
692 types = Support->getTypes();
696 FIELD<double>* Volume = new FIELD<double>::FIELD(Support,1);
697 // double *volume = new double [length_values];
698 Volume->setName("VOLUME");
699 Volume->setDescription("cells volume");
700 Volume->setComponentName(1,"volume");
701 Volume->setComponentDescription(1,"desc-comp");
703 /* string MEDComponentUnit(MED_TAILLE_PNOM,' ');*/
705 string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1]+"*"+myMesh->getCoordinatesUnits()[2];
707 Volume->setMEDComponentUnit(1,MEDComponentUnit);
709 Volume->setValueType(MED_REEL64);
711 Volume->setIterationNumber(0);
712 Volume->setOrderNumber(0);
713 Volume->setTime(0.0);
715 //const double *volume = Volume->getValue(MED_FULL_INTERLACE);
716 MEDARRAY<double> *volume = Volume->getvalue();
719 const double * coord = getCoordinates(MED_FULL_INTERLACE);
721 for (int i=0;i<nb_type;i++)
723 medGeometryElement type = types[i] ;
728 nb_entity_type = getNumberOfElements(support_entity,type);
729 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
733 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all"));
735 nb_entity_type = Support->getNumberOfElements(type);
737 const int * supp_number = Support->getNumber(type);
738 const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
739 const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
740 int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
742 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
743 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
744 global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
747 global_connectivity = global_connectivity_tmp ;
752 case MED_TETRA4 : case MED_TETRA10 :
754 for (int tetra=0;tetra<nb_entity_type;tetra++)
756 int tetra_index = (type%100)*tetra;
758 int N1 = global_connectivity[tetra_index]-1;
759 int N2 = global_connectivity[tetra_index+1]-1;
760 int N3 = global_connectivity[tetra_index+2]-1;
761 int N4 = global_connectivity[tetra_index+3]-1;
763 double x1 = coord[dim_space*N1];
764 double x2 = coord[dim_space*N2];
765 double x3 = coord[dim_space*N3];
766 double x4 = coord[dim_space*N4];
768 double y1 = coord[dim_space*N1+1];
769 double y2 = coord[dim_space*N2+1];
770 double y3 = coord[dim_space*N3+1];
771 double y4 = coord[dim_space*N4+1];
773 double z1 = coord[dim_space*N1+2];
774 double z2 = coord[dim_space*N2+2];
775 double z3 = coord[dim_space*N3+2];
776 double z4 = coord[dim_space*N4+2];
778 xvolume = ((x3-x1)*((y2-y1)*(z4-z1) - (z2-z1)*(y4-y1)) -
779 (x2-x1)*((y3-y1)*(z4-z1) - (z3-z1)*(y4-y1)) +
780 (x4-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1)))/6.0;
782 //volume[index] = xvolume ;
783 volume->setIJ(index,1,xvolume) ;
788 case MED_PYRA5 : case MED_PYRA13 :
790 for (int pyra=0;pyra<nb_entity_type;pyra++)
792 int pyra_index = (type%100)*pyra;
794 int N1 = global_connectivity[pyra_index]-1;
795 int N2 = global_connectivity[pyra_index+1]-1;
796 int N3 = global_connectivity[pyra_index+2]-1;
797 int N4 = global_connectivity[pyra_index+3]-1;
798 int N5 = global_connectivity[pyra_index+4]-1;
800 double x1 = coord[dim_space*N1];
801 double x2 = coord[dim_space*N2];
802 double x3 = coord[dim_space*N3];
803 double x4 = coord[dim_space*N4];
804 double x5 = coord[dim_space*N5];
806 double y1 = coord[dim_space*N1+1];
807 double y2 = coord[dim_space*N2+1];
808 double y3 = coord[dim_space*N3+1];
809 double y4 = coord[dim_space*N4+1];
810 double y5 = coord[dim_space*N5+1];
812 double z1 = coord[dim_space*N1+2];
813 double z2 = coord[dim_space*N2+2];
814 double z3 = coord[dim_space*N3+2];
815 double z4 = coord[dim_space*N4+2];
816 double z5 = coord[dim_space*N5+2];
818 xvolume = (((x3-x1)*((y2-y1)*(z5-z1) - (z2-z1)*(y5-y1)) -
819 (x2-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) +
820 (x5-x1)*((y3-y1)*(z2-z1) - (z3-z1)*(y2-y1))) +
821 ((x4-x1)*((y3-y1)*(z5-z1) - (z3-z1)*(y5-y1)) -
822 (x3-x1)*((y4-y1)*(z5-z1) - (z4-z1)*(y5-y1)) +
823 (x5-x1)*((y4-y1)*(z3-z1) - (z4-z1)*(y3-y1)))
826 //volume[index] = xvolume ;
827 volume->setIJ(index,1,xvolume) ;
832 case MED_PENTA6 : case MED_PENTA15 :
834 for (int penta=0;penta<nb_entity_type;penta++)
836 int penta_index = (type%100)*penta;
838 int N1 = global_connectivity[penta_index]-1;
839 int N2 = global_connectivity[penta_index+1]-1;
840 int N3 = global_connectivity[penta_index+2]-1;
841 int N4 = global_connectivity[penta_index+3]-1;
842 int N5 = global_connectivity[penta_index+4]-1;
843 int N6 = global_connectivity[penta_index+5]-1;
845 double x1 = coord[dim_space*N1];
846 double x2 = coord[dim_space*N2];
847 double x3 = coord[dim_space*N3];
848 double x4 = coord[dim_space*N4];
849 double x5 = coord[dim_space*N5];
850 double x6 = coord[dim_space*N6];
852 double y1 = coord[dim_space*N1+1];
853 double y2 = coord[dim_space*N2+1];
854 double y3 = coord[dim_space*N3+1];
855 double y4 = coord[dim_space*N4+1];
856 double y5 = coord[dim_space*N5+1];
857 double y6 = coord[dim_space*N6+1];
859 double z1 = coord[dim_space*N1+2];
860 double z2 = coord[dim_space*N2+2];
861 double z3 = coord[dim_space*N3+2];
862 double z4 = coord[dim_space*N4+2];
863 double z5 = coord[dim_space*N5+2];
864 double z6 = coord[dim_space*N6+2];
866 double a1 = (x2-x3)/2.0, a2 = (y2-y3)/2.0, a3 = (z2-z3)/2.0;
867 double b1 = (x5-x6)/2.0, b2 = (y5-y6)/2.0, b3 = (z5-z6)/2.0;
868 double c1 = (x4-x1)/2.0, c2 = (y4-y1)/2.0, c3 = (z4-z1)/2.0;
869 double d1 = (x5-x2)/2.0, d2 = (y5-y2)/2.0, d3 = (z5-z2)/2.0;
870 double e1 = (x6-x3)/2.0, e2 = (y6-y3)/2.0, e3 = (z6-z3)/2.0;
871 double f1 = (x1-x3)/2.0, f2 = (y1-y3)/2.0, f3 = (z1-z3)/2.0;
872 double h1 = (x4-x6)/2.0, h2 = (y4-y6)/2.0, h3 = (z4-z6)/2.0;
874 double A = a1*c2*f3 - a1*c3*f2 - a2*c1*f3 + a2*c3*f1 +
876 double B = b1*c2*h3 - b1*c3*h2 - b2*c1*h3 + b2*c3*h1 +
878 double C = (a1*c2*h3 + b1*c2*f3) - (a1*c3*h2 + b1*c3*f2) -
879 (a2*c1*h3 + b2*c1*f3) + (a2*c3*h1 + b2*c3*f1) +
880 (a3*c1*h2 + b3*c1*f2) - (a3*c2*h1 + b3*c2*f1);
881 double D = a1*d2*f3 - a1*d3*f2 - a2*d1*f3 + a2*d3*f1 +
883 double E = b1*d2*h3 - b1*d3*h2 - b2*d1*h3 + b2*d3*h1 +
885 double F = (a1*d2*h3 + b1*d2*f3) - (a1*d3*h2 + b1*d3*f2) -
886 (a2*d1*h3 + b2*d1*f3) + (a2*d3*h1 + b2*d3*f1) +
887 (a3*d1*h2 + b3*d1*f2) - (a3*d2*h1 + b3*d2*f1);
888 double G = a1*e2*f3 - a1*e3*f2 - a2*e1*f3 + a2*e3*f1 +
890 double H = b1*e2*h3 - b1*e3*h2 - b2*e1*h3 + b2*e3*h1 +
892 double P = (a1*e2*h3 + b1*e2*f3) - (a1*e3*h2 + b1*e3*f2) -
893 (a2*e1*h3 + b2*e1*f3) + (a2*e3*h1 + b2*e3*f1) +
894 (a3*e1*h2 + b3*e1*f2) - (a3*e2*h1 + b3*e2*f1);
896 xvolume = -2.0*(2.0*(A + B + D + E + G + H) + C + F + P)/9.0;
898 //volume[index] = xvolume ;
899 volume->setIJ(index,1,xvolume) ;
904 case MED_HEXA8 : case MED_HEXA20 :
906 for (int hexa=0;hexa<nb_entity_type;hexa++)
908 int hexa_index = (type%100)*hexa;
910 int N1 = global_connectivity[hexa_index]-1;
911 int N2 = global_connectivity[hexa_index+1]-1;
912 int N3 = global_connectivity[hexa_index+2]-1;
913 int N4 = global_connectivity[hexa_index+3]-1;
914 int N5 = global_connectivity[hexa_index+4]-1;
915 int N6 = global_connectivity[hexa_index+5]-1;
916 int N7 = global_connectivity[hexa_index+6]-1;
917 int N8 = global_connectivity[hexa_index+7]-1;
919 double x1 = coord[dim_space*N1];
920 double x2 = coord[dim_space*N2];
921 double x3 = coord[dim_space*N3];
922 double x4 = coord[dim_space*N4];
923 double x5 = coord[dim_space*N5];
924 double x6 = coord[dim_space*N6];
925 double x7 = coord[dim_space*N7];
926 double x8 = coord[dim_space*N8];
928 double y1 = coord[dim_space*N1+1];
929 double y2 = coord[dim_space*N2+1];
930 double y3 = coord[dim_space*N3+1];
931 double y4 = coord[dim_space*N4+1];
932 double y5 = coord[dim_space*N5+1];
933 double y6 = coord[dim_space*N6+1];
934 double y7 = coord[dim_space*N7+1];
935 double y8 = coord[dim_space*N8+1];
937 double z1 = coord[dim_space*N1+2];
938 double z2 = coord[dim_space*N2+2];
939 double z3 = coord[dim_space*N3+2];
940 double z4 = coord[dim_space*N4+2];
941 double z5 = coord[dim_space*N5+2];
942 double z6 = coord[dim_space*N6+2];
943 double z7 = coord[dim_space*N7+2];
944 double z8 = coord[dim_space*N8+2];
946 double a1 = (x3-x4)/8.0, a2 = (y3-y4)/8.0, a3 = (z3-z4)/8.0;
947 double b1 = (x2-x1)/8.0, b2 = (y2-y1)/8.0, b3 = (z2-z1)/8.0;
948 double c1 = (x7-x8)/8.0, c2 = (y7-y8)/8.0, c3 = (z7-z8)/8.0;
949 double d1 = (x6-x5)/8.0, d2 = (y6-y5)/8.0, d3 = (z6-z5)/8.0;
950 double e1 = (x3-x2)/8.0, e2 = (y3-y2)/8.0, e3 = (z3-z2)/8.0;
951 double f1 = (x4-x1)/8.0, f2 = (y4-y1)/8.0, f3 = (z4-z1)/8.0;
952 double h1 = (x7-x6)/8.0, h2 = (y7-y6)/8.0, h3 = (z7-z6)/8.0;
953 double p1 = (x8-x5)/8.0, p2 = (y8-y5)/8.0, p3 = (z8-z5)/8.0;
954 double q1 = (x3-x7)/8.0, q2 = (y3-y7)/8.0, q3 = (z3-z7)/8.0;
955 double r1 = (x4-x8)/8.0, r2 = (y4-y8)/8.0, r3 = (z4-z8)/8.0;
956 double s1 = (x2-x6)/8.0, s2 = (y2-y6)/8.0, s3 = (z2-z6)/8.0;
957 double t1 = (x1-x5)/8.0, t2 = (y1-y5)/8.0, t3 = (z1-z5)/8.0;
959 double A = a1*e2*q3 - a1*e3*q2 - a2*e1*q3 + a2*e3*q1 +
961 double B = c1*h2*q3 - c1*h3*q2 - c2*h1*q3 + c2*h3*q1 +
963 double C = (a1*h2 + c1*e2)*q3 - (a1*h3 + c1*e3)*q2 -
964 (a2*h1 + c2*e1)*q3 + (a2*h3 + c2*e3)*q1 +
965 (a3*h1 + c3*e1)*q2 - (a3*h2 + c3*e2)*q1;
966 double D = b1*e2*s3 - b1*e3*s2 - b2*e1*s3 + b2*e3*s1 +
968 double E = d1*h2*s3 - d1*h3*s2 - d2*h1*s3 + d2*h3*s1 +
970 double F = (b1*h2 + d1*e2)*s3 - (b1*h3 + d1*e3)*s2 -
971 (b2*h1 + d2*e1)*s3 + (b2*h3 + d2*e3)*s1 +
972 (b3*h1 + d3*e1)*s2 - (b3*h2 + d3*e2)*s1;
973 double G = (a1*e2*s3 + b1*e2*q3) - (a1*e3*s2 + b1*e3*q2) -
974 (a2*e1*s3 + b2*e1*q3) + (a2*e3*s1 + b2*e3*q1) +
975 (a3*e1*s2 + b3*e1*q2) - (a3*e2*s1 + b3*e2*q1);
976 double H = (c1*h2*s3 + d1*h2*q3) - (c1*h3*s2 + d1*h3*q2) -
977 (c2*h1*s3 + d2*h1*q3) + (c2*h3*s1 + d2*h3*q1) +
978 (c3*h1*s2 + d3*h1*q2) - (c3*h2*s1 + d3*h2*q1);
979 double I = ((a1*h2 + c1*e2)*s3 + (b1*h2 + d1*e2)*q3) -
980 ((a1*h3 + c1*e3)*s2 + (b1*h3 + d1*e3)*q2) -
981 ((a2*h1 + c2*e1)*s3 + (b2*h1 + d2*e1)*q3) +
982 ((a2*h3 + c2*e3)*s1 + (b2*h3 + d2*e3)*q1) +
983 ((a3*h1 + c3*e1)*s2 + (b3*h1 + d3*e1)*q2) -
984 ((a3*h2 + c3*e2)*s1 + (b3*h2 + d3*e2)*q1);
985 double J = a1*f2*r3 - a1*f3*r2 - a2*f1*r3 + a2*f3*r1 +
987 double K = c1*p2*r3 - c1*p3*r2 - c2*p1*r3 + c2*p3*r1 +
989 double L = (a1*p2 + c1*f2)*r3 - (a1*p3 + c1*f3)*r2 -
990 (a2*p1 + c2*f1)*r3 + (a2*p3 + c2*f3)*r1 +
991 (a3*p1 + c3*f1)*r2 - (a3*p2 + c3*f2)*r1;
992 double M = b1*f2*t3 - b1*f3*t2 - b2*f1*t3 + b2*f3*t1 +
994 double N = d1*p2*t3 - d1*p3*t2 - d2*p1*t3 + d2*p3*t1 +
996 double O = (b1*p2 + d1*f2)*t3 - (b1*p3 + d1*f3)*t2 -
997 (b2*p1 + d2*f1)*t3 + (b2*p3 + d2*f3)*t1 +
998 (b3*p1 + d3*f1)*t2 - (b3*p2 + d3*f2)*t1;
999 double P = (a1*f2*t3 + b1*f2*r3) - (a1*f3*t2 + b1*f3*r2) -
1000 (a2*f1*t3 + b2*f1*r3) + (a2*f3*t1 + b2*f3*r1) +
1001 (a3*f1*t2 + b3*f1*r2) - (a3*f2*t1 + b3*f2*r1);
1002 double Q = (c1*p2*t3 + d1*p2*r3) - (c1*p3*t2 + d1*p3*r2) -
1003 (c2*p1*t3 + d2*p1*r3) + (c2*p3*t1 + d2*p3*r1) +
1004 (c3*p1*t2 + d3*p1*r2) - (c3*p2*t1 + d3*p2*r1);
1005 double R = ((a1*p2 + c1*f2)*t3 + (b1*p2 + d1*f2)*r3) -
1006 ((a1*p3 + c1*f3)*t2 + (b1*p3 + d1*f3)*r2) -
1007 ((a2*p1 + c2*f1)*t3 + (b2*p1 + d2*f1)*r3) +
1008 ((a2*p3 + c2*f3)*t1 + (b2*p3 + d2*f3)*r1) +
1009 ((a3*p1 + c3*f1)*t2 + (b3*p1 + d3*f1)*r2) -
1010 ((a3*p2 + c3*f2)*t1 + (b3*p2 + d3*f2)*r1);
1011 double S = (a1*e2*r3 + a1*f2*q3) - (a1*e3*r2 + a1*f3*q2) -
1012 (a2*e1*r3 + a2*f1*q3) + (a2*e3*r1 + a2*f3*q1) +
1013 (a3*e1*r2 + a3*f1*q2) - (a3*e2*r1 + a3*f2*q1);
1014 double T = (c1*h2*r3 + c1*p2*q3) - (c1*h3*r2 + c1*p3*q2) -
1015 (c2*h1*r3 + c2*p1*q3) + (c2*h3*r1 + c2*p3*q1) +
1016 (c3*h1*r2 + c3*p1*q2) - (c3*h2*r1 + c3*p2*q1);
1017 double U = ((a1*h2 + c1*e2)*r3 + (a1*p2 + c1*f2)*q3) -
1018 ((a1*h3 + c1*e3)*r2 + (a1*p3 + c1*f3)*q2) -
1019 ((a2*h1 + c2*e1)*r3 + (a2*p1 + c2*f1)*q3) +
1020 ((a2*h3 + c2*e3)*r1 + (a2*p3 + c2*f3)*q1) +
1021 ((a3*h1 + c3*e1)*r2 + (a3*p1 + c3*f1)*q2) -
1022 ((a3*h2 + c3*e2)*r1 + (a3*p2 + c3*f2)*q1);
1023 double V = (b1*e2*t3 + b1*f2*s3) - (b1*e3*t2 + b1*f3*s2) -
1024 (b2*e1*t3 + b2*f1*s3) + (b2*e3*t1 + b2*f3*s1) +
1025 (b3*e1*t2 + b3*f1*s2) - (b3*e2*t1 + b3*f2*s1);
1026 double W = (d1*h2*t3 + d1*p2*s3) - (d1*h3*t2 + d1*p3*s2) -
1027 (d2*h1*t3 + d2*p1*s3) + (d2*h3*t1 + d2*p3*s1) +
1028 (d3*h1*t2 + d3*p1*s2) - (d3*h2*t1 + d3*p2*s1);
1029 double X = ((b1*h2 + d1*e2)*t3 + (b1*p2 + d1*f2)*s3) -
1030 ((b1*h3 + d1*e3)*t2 + (b1*p3 + d1*f3)*s2) -
1031 ((b2*h1 + d2*e1)*t3 + (b2*p1 + d2*f1)*s3) +
1032 ((b2*h3 + d2*e3)*t1 + (b2*p3 + d2*f3)*s1) +
1033 ((b3*h1 + d3*e1)*t2 + (b3*p1 + d3*f1)*s2) -
1034 ((b3*h2 + d3*e2)*t1 + (b3*p2 + d3*f2)*s1);
1035 double Y = (a1*e2*t3 + a1*f2*s3 + b1*e2*r3 + b1*f2*q3) -
1036 (a1*e3*t2 + a1*f3*s2 + b1*e3*r2 + b1*f3*q2) -
1037 (a2*e1*t3 + a2*f1*s3 + b2*e1*r3 + b2*f1*q3) +
1038 (a2*e3*t1 + a2*f3*s1 + b2*e3*r1 + b2*f3*q1) +
1039 (a3*e1*t2 + a3*f1*s2 + b3*e1*r2 + b3*f1*q2) -
1040 (a3*e2*t1 + a3*f2*s1 + b3*e2*r1 + b3*f2*q1);
1041 double Z = (c1*h2*t3 + c1*p2*s3 + d1*h2*r3 + d1*p2*q3) -
1042 (c1*h3*t2 + c1*p3*s2 + d1*h3*r2 + d1*p3*q2) -
1043 (c2*h1*t3 + c2*p1*s3 + d2*h1*r3 + d2*p1*q3) +
1044 (c2*h3*t1 + c2*p3*s1 + d2*h3*r1 + d2*p3*q1) +
1045 (c3*h1*t2 + c3*p1*s2 + d3*h1*r2 + d3*p1*q2) -
1046 (c3*h2*t1 + c3*p2*s1 + d3*h2*r1 + d3*p2*q1);
1047 double AA = ((a1*h2 + c1*e2)*t3 + (a1*p2 + c1*f2)*s3 +
1048 (b1*h2 + d1*e2)*r3 + (b1*p2 + d1*f2)*q3) -
1049 ((a1*h3 + c1*e3)*t2 + (a1*p3 + c1*f3)*s2 +
1050 (b1*h3 + d1*e3)*r2 + (b1*p3 + d1*f3)*q2) -
1051 ((a2*h1 + c2*e1)*t3 + (a2*p1 + c2*f1)*s3 +
1052 (b2*h1 + d2*e1)*r3 + (b2*p1 + d2*f1)*q3) +
1053 ((a2*h3 + c2*e3)*t1 + (a2*p3 + c2*f3)*s1 +
1054 (b2*h3 + d2*e3)*r1 + (b2*p3 + d2*f3)*q1) +
1055 ((a3*h1 + c3*e1)*t2 + (a3*p1 + c3*f1)*s2 +
1056 (b3*h1 + d3*e1)*r2 + (b3*p1 + d3*f1)*q2) -
1057 ((a3*h2 + c3*e2)*t1 + (a3*p2 + c3*f2)*s1 +
1058 (b3*h2 + d3*e2)*r1 + (b3*p2 + d3*f2)*q1);
1060 xvolume = 64.0*(8.0*(A + B + D + E + J + K + M + N) +
1061 4.0*(C + F + G + H + L + O + P + Q + S + T +
1062 V + W) + 2.0*(I + R + U + X + Y + Z) +
1065 //volume[index] = xvolume ;
1066 volume->setIJ(index,1,xvolume) ;
1072 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Volumes on it !"));
1076 if (!onAll) delete [] global_connectivity ;
1082 FIELD<double>* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION)
1084 const char * LOC = "MESH::getArea(SUPPORT*) : ";
1087 // Support must be on 2D elements
1089 // Make sure that the MESH class is the same as the MESH class attribut
1090 // in the class Support
1091 MESH* myMesh = Support->getMesh();
1093 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
1095 int dim_space = getSpaceDimension();
1096 medEntityMesh support_entity = Support->getEntity();
1097 bool onAll = Support->isOnAllElements();
1099 int nb_type, length_values;
1100 const medGeometryElement* types;
1102 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
1103 const int* global_connectivity;
1107 // nb_type = myMesh->getNumberOfTypes(support_entity);
1108 // length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
1109 // types = getTypes(support_entity);
1113 nb_type = Support->getNumberOfTypes();
1114 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
1115 types = Support->getTypes();
1119 FIELD<double>* Area;
1121 Area = new FIELD<double>::FIELD(Support,1);
1122 Area->setName("AREA");
1123 Area->setDescription("cells or faces area");
1125 Area->setComponentName(1,"area");
1126 Area->setComponentDescription(1,"desc-comp");
1128 /* string MEDComponentUnit = myMesh->getCoordinatesUnits()[0]+"*"+myMesh->getCoordinatesUnits()[1];*/
1130 string MEDComponentUnit="trucmuch";
1132 Area->setMEDComponentUnit(1,MEDComponentUnit);
1134 Area->setValueType(MED_REEL64);
1136 Area->setIterationNumber(0);
1137 Area->setOrderNumber(0);
1140 double *area = new double[length_values];
1141 //double *area = Area->getValue(MED_FULL_INTERLACE);
1143 const double * coord = getCoordinates(MED_FULL_INTERLACE);
1146 for (int i=0;i<nb_type;i++)
1148 medGeometryElement type = types[i] ;
1153 nb_entity_type = getNumberOfElements(support_entity,type);
1154 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
1158 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
1160 nb_entity_type = Support->getNumberOfElements(type);
1162 const int * supp_number = Support->getNumber(type);
1163 const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
1164 const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
1165 int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
1167 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
1168 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
1169 global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
1173 global_connectivity = global_connectivity_tmp ;
1179 case MED_TRIA3 : case MED_TRIA6 :
1181 for (int tria=0;tria<nb_entity_type;tria++)
1183 int tria_index = (type%100)*tria;
1185 int N1 = global_connectivity[tria_index]-1;
1186 int N2 = global_connectivity[tria_index+1]-1;
1187 int N3 = global_connectivity[tria_index+2]-1;
1189 double x1 = coord[dim_space*N1];
1190 double x2 = coord[dim_space*N2];
1191 double x3 = coord[dim_space*N3];
1193 double y1 = coord[dim_space*N1+1];
1194 double y2 = coord[dim_space*N2+1];
1195 double y3 = coord[dim_space*N3+1];
1199 xarea = - ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
1203 double z1 = coord[dim_space*N1+2];
1204 double z2 = coord[dim_space*N2+2];
1205 double z3 = coord[dim_space*N3+2];
1207 xarea = sqrt(((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))*
1208 ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1)) +
1209 ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))*
1210 ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1)) +
1211 ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))*
1212 ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1)))/2.0;
1215 area[index] = xarea ;
1220 case MED_QUAD4 : case MED_QUAD8 :
1222 for (int quad=0;quad<nb_entity_type;quad++)
1224 int quad_index = (type%100)*quad;
1226 int N1 = global_connectivity[quad_index]-1;
1227 int N2 = global_connectivity[quad_index+1]-1;
1228 int N3 = global_connectivity[quad_index+2]-1;
1229 int N4 = global_connectivity[quad_index+3]-1;
1231 double x1 = coord[dim_space*N1];
1232 double x2 = coord[dim_space*N2];
1233 double x3 = coord[dim_space*N3];
1234 double x4 = coord[dim_space*N4];
1236 double y1 = coord[dim_space*N1+1];
1237 double y2 = coord[dim_space*N2+1];
1238 double y3 = coord[dim_space*N3+1];
1239 double y4 = coord[dim_space*N4+1];
1243 double a1 = (x2-x1)/4.0, a2 = (y2-y1)/4.0;
1244 double b1 = (x3-x4)/4.0, b2 = (y3-y4)/4.0;
1245 double c1 = (x3-x2)/4.0, c2 = (y3-y2)/4.0;
1246 double d1 = (x4-x1)/4.0, d2 = (y4-y1)/4.0;
1248 xarea = - 4.0*(b1*c2 - c1*b2 + a1*c2 - c1*a2 + b1*d2 -
1249 d1*b2 + a1*d2 - d1*a2);
1253 double z1 = coord[dim_space*N1+2];
1254 double z2 = coord[dim_space*N2+2];
1255 double z3 = coord[dim_space*N3+2];
1256 double z4 = coord[dim_space*N4+2];
1258 xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
1259 ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
1260 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
1261 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
1262 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
1263 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
1264 sqrt(((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3))*
1265 ((y4-y3)*(z2-z3) - (y2-y3)*(z4-z3)) +
1266 ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3))*
1267 ((x2-x3)*(z4-z3) - (x4-x3)*(z2-z3)) +
1268 ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))*
1269 ((x4-x3)*(y2-y3) - (x2-x3)*(y4-y3))))/2.0;
1272 area[index] = xarea ;
1278 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Areas on it !"));
1282 if (!onAll) delete [] global_connectivity ;
1285 Area->setValue(MED_FULL_INTERLACE,area);
1290 FIELD<double>* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION)
1292 const char * LOC = "MESH::getLength(SUPPORT*) : ";
1295 // Support must be on 1D elements
1297 // Make sure that the MESH class is the same as the MESH class attribut
1298 // in the class Support
1299 MESH* myMesh = Support->getMesh();
1301 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
1303 int dim_space = getSpaceDimension();
1304 medEntityMesh support_entity = Support->getEntity();
1305 bool onAll = Support->isOnAllElements();
1307 int nb_type, length_values;
1308 const medGeometryElement* types;
1310 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
1311 const int* global_connectivity;
1315 // nb_type = myMesh->getNumberOfTypes(support_entity);
1316 // length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
1317 // types = getTypes(support_entity);
1321 nb_type = Support->getNumberOfTypes();
1322 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
1323 types = Support->getTypes();
1327 FIELD<double>* Length;
1329 Length = new FIELD<double>::FIELD(Support,1);
1330 // double *length = new double [length_values];
1331 Length->setValueType(MED_REEL64);
1333 //const double *length = Length->getValue(MED_FULL_INTERLACE);
1334 MEDARRAY<double> * length = Length->getvalue();
1336 const double * coord = getCoordinates(MED_FULL_INTERLACE);
1339 for (int i=0;i<nb_type;i++)
1341 medGeometryElement type = types[i] ;
1346 nb_entity_type = getNumberOfElements(support_entity,type);
1347 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
1351 //throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
1353 nb_entity_type = Support->getNumberOfElements(type);
1355 const int * supp_number = Support->getNumber(type);
1356 const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
1357 const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
1358 int* global_connectivity_tmp = new int[(type%100)*nb_entity_type];
1360 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
1361 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
1362 global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
1365 global_connectivity = global_connectivity_tmp ;
1370 case MED_SEG2 : case MED_SEG3 :
1372 for (int edge=0;edge<nb_entity_type;edge++)
1374 int edge_index = (type%100)*edge;
1376 int N1 = global_connectivity[edge_index]-1;
1377 int N2 = global_connectivity[edge_index+1]-1;
1379 double x1 = coord[dim_space*N1];
1380 double x2 = coord[dim_space*N2];
1382 double y1 = coord[dim_space*N1+1];
1383 double y2 = coord[dim_space*N2+1];
1385 double z1, z2 ; z1 = 0.0 ; z2 = 0.0 ; if (dim_space==3) {
1386 z1 = coord[dim_space*N1+2]; z2 = coord[dim_space*N2+2];}
1388 xlength = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) +
1389 (z1 - z2)*(z1 - z2));
1391 length->setIJ(index,1,xlength) ;
1397 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Lengths on it !"));
1401 if (!onAll) delete [] global_connectivity ;
1407 FIELD<double>* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION)
1409 const char * LOC = "MESH::getNormal(SUPPORT*) : ";
1412 // Support must be on 2D or 1D elements
1414 // Make sure that the MESH class is the same as the MESH class attribut
1415 // in the class Support
1416 MESH* myMesh = Support->getMesh();
1418 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : pointeur problem !"));
1420 int dim_space = getSpaceDimension();
1421 medEntityMesh support_entity = Support->getEntity();
1422 bool onAll = Support->isOnAllElements();
1424 int nb_type, length_values;
1425 const medGeometryElement* types;
1427 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
1428 const int* global_connectivity;
1432 // nb_type = myMesh->getNumberOfTypes(support_entity);
1433 // length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
1434 // types = getTypes(support_entity);
1438 nb_type = Support->getNumberOfTypes();
1439 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
1440 types = Support->getTypes();
1445 FIELD<double>* Normal = new FIELD<double>::FIELD(Support,dim_space);
1446 Normal->setName("NORMAL");
1447 Normal->setDescription("cells or faces normal");
1448 for (int k=1;k<=dim_space;k++) {
1449 Normal->setComponentName(k,"normal");
1450 Normal->setComponentDescription(k,"desc-comp");
1451 Normal->setMEDComponentUnit(k,"unit");
1454 Normal->setValueType(MED_REEL64);
1456 Normal->setIterationNumber(MED_NOPDT);
1457 Normal->setOrderNumber(MED_NONOR);
1458 Normal->setTime(0.0);
1460 double * normal = new double [dim_space*length_values];
1461 //double *normal = Normal->getValue(MED_FULL_INTERLACE);
1463 const double * coord = getCoordinates(MED_FULL_INTERLACE);
1466 for (int i=0;i<nb_type;i++)
1468 medGeometryElement type = types[i] ;
1470 // Make sure we trying to get Normals on
1471 // TRIA3 or TRIA6 or QUAD4 QUAD8 (2D) cells on a 3D mesh
1472 // or on SEG2 or SEG3 (1D) cells on a 2D mesh
1474 if ( (((type==MED_TRIA3) || (type==MED_TRIA6) ||
1475 (type==MED_QUAD4) || (type==MED_QUAD8)) &&
1476 (dim_space != 3)) || (((type==MED_SEG2) || (type==MED_SEG3)) &&
1478 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh : dimension problem !"));
1480 double xnormal1, xnormal2, xnormal3 ;
1484 nb_entity_type = getNumberOfElements(support_entity,type);
1485 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
1489 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all for instance !"));
1490 nb_entity_type = Support->getNumberOfElements(type);
1492 const int * supp_number = Support->getNumber(type);
1493 const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
1494 const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
1495 int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
1497 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
1498 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
1499 global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
1503 global_connectivity = global_connectivity_tmp ;
1509 case MED_TRIA3 : case MED_TRIA6 :
1511 for (int tria=0;tria<nb_entity_type;tria++)
1513 int tria_index = (type%100)*tria;
1515 int N1 = global_connectivity[tria_index]-1;
1516 int N2 = global_connectivity[tria_index+1]-1;
1517 int N3 = global_connectivity[tria_index+2]-1;
1519 //double xarea; !! UNUSED VARIABLE !!
1520 double x1 = coord[dim_space*N1];
1521 double x2 = coord[dim_space*N2];
1522 double x3 = coord[dim_space*N3];
1524 double y1 = coord[dim_space*N1+1];
1525 double y2 = coord[dim_space*N2+1];
1526 double y3 = coord[dim_space*N3+1];
1528 double z1 = coord[dim_space*N1+2];
1529 double z2 = coord[dim_space*N2+2];
1530 double z3 = coord[dim_space*N3+2];
1532 xnormal1 = ((y2-y1)*(z3-z1) - (y3-y1)*(z2-z1))/2.0;
1533 xnormal2 = ((x3-x1)*(z2-z1) - (x2-x1)*(z3-z1))/2.0;
1534 xnormal3 = ((x2-x1)*(y3-y1) - (x3-x1)*(y2-y1))/2.0;
1536 normal[3*index] = xnormal1 ;
1537 normal[3*index+1] = xnormal2 ;
1538 normal[3*index+2] = xnormal3 ;
1544 case MED_QUAD4 : case MED_QUAD8 :
1546 for (int quad=0;quad<nb_entity_type;quad++)
1548 int quad_index = (type%100)*quad;
1550 int N1 = global_connectivity[quad_index]-1;
1551 int N2 = global_connectivity[quad_index+1]-1;
1552 int N3 = global_connectivity[quad_index+2]-1;
1553 int N4 = global_connectivity[quad_index+3]-1;
1556 double x1 = coord[dim_space*N1];
1557 double x2 = coord[dim_space*N2];
1558 double x3 = coord[dim_space*N3];
1559 double x4 = coord[dim_space*N4];
1561 double y1 = coord[dim_space*N1+1];
1562 double y2 = coord[dim_space*N2+1];
1563 double y3 = coord[dim_space*N3+1];
1564 double y4 = coord[dim_space*N4+1];
1566 double z1 = coord[dim_space*N1+2];
1567 double z2 = coord[dim_space*N2+2];
1568 double z3 = coord[dim_space*N3+2];
1569 double z4 = coord[dim_space*N4+2];
1571 xnormal1 = (y2-y1)*(z4-z1) - (y4-y1)*(z2-z1);
1572 xnormal2 = (x4-x1)*(z2-z1) - (x2-x1)*(z4-z1);
1573 xnormal3 = (x2-x1)*(y4-y1) - (x4-x1)*(y2-y1);
1574 xarea = sqrt(xnormal1*xnormal1 + xnormal2*xnormal2 +
1577 xnormal1 = xnormal1/xarea;
1578 xnormal2 = xnormal2/xarea;
1579 xnormal3 = xnormal3/xarea;
1581 xarea = (sqrt(((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1))*
1582 ((y2-y1)*(z4-z1) - (y4-y1)*(z2-z1)) +
1583 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1))*
1584 ((x4-x1)*(z2-z1) - (x2-x1)*(z4-z1)) +
1585 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))*
1586 ((x2-x1)*(y4-y1) - (x4-x1)*(y2-y1))) +
1587 sqrt(((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2))*
1588 ((y3-y2)*(z4-z3) - (y4-y3)*(z3-z2)) +
1589 ((x4-x3)*(z2-z2) - (x3-x2)*(z4-z3))*
1590 ((x4-x3)*(z4-z2) - (x3-x2)*(z4-z3)) +
1591 ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))*
1592 ((x3-x2)*(y4-y3) - (x4-x3)*(y3-y2))))/2.0;
1594 xnormal1 = xnormal1*xarea;
1595 xnormal2 = xnormal2*xarea;
1596 xnormal3 = xnormal3*xarea;
1598 normal[3*index] = xnormal1 ;
1599 normal[3*index+1] = xnormal2 ;
1600 normal[3*index+2] = xnormal3 ;
1606 case MED_SEG2 : case MED_SEG3 :
1608 for (int edge=0;edge<nb_entity_type;edge++)
1610 int edge_index = (type%100)*edge;
1612 int N1 = global_connectivity[edge_index]-1;
1613 int N2 = global_connectivity[edge_index+1]-1;
1615 double x1 = coord[dim_space*N1];
1616 double x2 = coord[dim_space*N2];
1618 double y1 = coord[dim_space*N1+1];
1619 double y2 = coord[dim_space*N2+1];
1621 xnormal1 = -(y2-y1);
1624 normal[2*index] = xnormal1 ;
1625 normal[2*index+1] = xnormal2 ;
1632 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get Normals on it !"));
1636 if (!onAll) delete [] global_connectivity ;
1639 Normal->setValue(MED_FULL_INTERLACE,normal);
1647 FIELD<double>* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION)
1649 const char * LOC = "MESH::getBarycenter(SUPPORT*) : ";
1652 // Make sure that the MESH class is the same as the MESH class attribut
1653 // in the class Support
1654 MESH* myMesh = Support->getMesh();
1656 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no compatibility between *this and SUPPORT::_mesh !"));
1658 int dim_space = getSpaceDimension();
1659 medEntityMesh support_entity = Support->getEntity();
1660 bool onAll = Support->isOnAllElements();
1662 int nb_type, length_values;
1663 const medGeometryElement* types;
1665 // !!!! WARNING : use of nodal global numbering in the mesh !!!!
1666 const int* global_connectivity;
1670 // nb_type = myMesh->getNumberOfTypes(support_entity);
1671 // length_values = getNumberOfElements(support_entity,MED_ALL_ELEMENTS);
1672 // types = getTypes(support_entity);
1676 nb_type = Support->getNumberOfTypes();
1677 length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS);
1678 types = Support->getTypes();
1682 FIELD<double>* Barycenter;
1684 Barycenter = new FIELD<double>::FIELD(Support,dim_space);
1685 Barycenter->setName("BARYCENTER");
1686 Barycenter->setDescription("cells or faces barycenter");
1688 for (int k=0;k<dim_space;k++) {
1690 Barycenter->setComponentName(kp1,myMesh->getCoordinatesNames()[k]);
1691 Barycenter->setComponentDescription(kp1,"desc-comp");
1692 Barycenter->setMEDComponentUnit(kp1,myMesh->getCoordinatesUnits()[k]);
1695 Barycenter->setValueType(MED_REEL64);
1697 Barycenter->setIterationNumber(0);
1698 Barycenter->setOrderNumber(0);
1699 Barycenter->setTime(0.0);
1701 double *barycenter = new double [dim_space*length_values];
1702 // double *barycenter = Barycenter->getValue(MED_FULL_INTERLACE);
1704 const double * coord = getCoordinates(MED_FULL_INTERLACE);
1707 for (int i=0;i<nb_type;i++)
1709 medGeometryElement type = types[i] ;
1710 double xbarycenter1, xbarycenter2, xbarycenter3;
1714 nb_entity_type = getNumberOfElements(support_entity,type);
1715 global_connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,type);
1719 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support must be on all !"));
1720 nb_entity_type = Support->getNumberOfElements(type);
1722 const int * supp_number = Support->getNumber(type);
1723 const int * connectivity = getConnectivity(MED_FULL_INTERLACE,MED_NODAL,support_entity,MED_ALL_ELEMENTS);
1724 const int * connectivityIndex = getConnectivityIndex(MED_NODAL,support_entity);
1725 int * global_connectivity_tmp = new int[(type%100)*nb_entity_type];
1727 for (int k_type = 0; k_type<nb_entity_type; k_type++) {
1728 for (int j_ent = 0; j_ent<(type%100); j_ent++) {
1729 global_connectivity_tmp[k_type*(type%100)+j_ent] = connectivity[connectivityIndex[supp_number[k_type]-1]+j_ent-1];
1732 global_connectivity = global_connectivity_tmp;
1737 case MED_TETRA4 : case MED_TETRA10 :
1739 for (int tetra =0;tetra<nb_entity_type;tetra++)
1741 int tetra_index = (type%100)*tetra;
1743 int N1 = global_connectivity[tetra_index]-1;
1744 int N2 = global_connectivity[tetra_index+1]-1;
1745 int N3 = global_connectivity[tetra_index+2]-1;
1746 int N4 = global_connectivity[tetra_index+3]-1;
1748 double x1 = coord[dim_space*N1];
1749 double x2 = coord[dim_space*N2];
1750 double x3 = coord[dim_space*N3];
1751 double x4 = coord[dim_space*N4];
1753 double y1 = coord[dim_space*N1+1];
1754 double y2 = coord[dim_space*N2+1];
1755 double y3 = coord[dim_space*N3+1];
1756 double y4 = coord[dim_space*N4+1];
1758 double z1 = coord[dim_space*N1+2];
1759 double z2 = coord[dim_space*N2+2];
1760 double z3 = coord[dim_space*N3+2];
1761 double z4 = coord[dim_space*N4+2];
1763 xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
1764 xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
1765 xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
1766 barycenter[3*index] = xbarycenter1 ;
1767 barycenter[3*index+1] = xbarycenter2 ;
1768 barycenter[3*index+2] = xbarycenter3 ;
1773 case MED_PYRA5 : case MED_PYRA13 :
1775 for (int pyra=0;pyra<nb_entity_type;pyra++)
1777 int pyra_index = (type%100)*pyra;
1779 int N1 = global_connectivity[pyra_index]-1;
1780 int N2 = global_connectivity[pyra_index+1]-1;
1781 int N3 = global_connectivity[pyra_index+2]-1;
1782 int N4 = global_connectivity[pyra_index+3]-1;
1783 int N5 = global_connectivity[pyra_index+4]-1;
1785 double x1 = coord[dim_space*N1];
1786 double x2 = coord[dim_space*N2];
1787 double x3 = coord[dim_space*N3];
1788 double x4 = coord[dim_space*N4];
1789 double x5 = coord[dim_space*N5];
1791 double y1 = coord[dim_space*N1+1];
1792 double y2 = coord[dim_space*N2+1];
1793 double y3 = coord[dim_space*N3+1];
1794 double y4 = coord[dim_space*N4+1];
1795 double y5 = coord[dim_space*N5+1];
1797 double z1 = coord[dim_space*N1+2];
1798 double z2 = coord[dim_space*N2+2];
1799 double z3 = coord[dim_space*N3+2];
1800 double z4 = coord[dim_space*N4+2];
1801 double z5 = coord[dim_space*N5+2];
1803 xbarycenter1 = (x1 + x2 + x3 + x4 + x5)/5.0;
1804 xbarycenter2 = (y1 + y2 + y3 + y4 + y5)/5.0;
1805 xbarycenter3 = (z1 + z2 + z3 + z4 + z5)/5.0;
1806 barycenter[3*index] = xbarycenter1 ;
1807 barycenter[3*index+1] = xbarycenter2 ;
1808 barycenter[3*index+2] = xbarycenter3 ;
1813 case MED_PENTA6 : case MED_PENTA15 :
1815 for (int penta=0;penta<nb_entity_type;penta++)
1817 int penta_index = (type%100)*penta;
1819 int N1 = global_connectivity[penta_index]-1;
1820 int N2 = global_connectivity[penta_index+1]-1;
1821 int N3 = global_connectivity[penta_index+2]-1;
1822 int N4 = global_connectivity[penta_index+3]-1;
1823 int N5 = global_connectivity[penta_index+4]-1;
1824 int N6 = global_connectivity[penta_index+5]-1;
1826 double x1 = coord[dim_space*N1];
1827 double x2 = coord[dim_space*N2];
1828 double x3 = coord[dim_space*N3];
1829 double x4 = coord[dim_space*N4];
1830 double x5 = coord[dim_space*N5];
1831 double x6 = coord[dim_space*N6];
1833 double y1 = coord[dim_space*N1+1];
1834 double y2 = coord[dim_space*N2+1];
1835 double y3 = coord[dim_space*N3+1];
1836 double y4 = coord[dim_space*N4+1];
1837 double y5 = coord[dim_space*N5+1];
1838 double y6 = coord[dim_space*N6+1];
1840 double z1 = coord[dim_space*N1+2];
1841 double z2 = coord[dim_space*N2+2];
1842 double z3 = coord[dim_space*N3+2];
1843 double z4 = coord[dim_space*N4+2];
1844 double z5 = coord[dim_space*N5+2];
1845 double z6 = coord[dim_space*N6+2];
1847 xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6)/6.0;
1848 xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6)/6.0;
1849 xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6)/6.0;
1850 barycenter[3*index] = xbarycenter1 ;
1851 barycenter[3*index+1] = xbarycenter2 ;
1852 barycenter[3*index+2] = xbarycenter3 ;
1857 case MED_HEXA8 : case MED_HEXA20 :
1859 for (int hexa=0;hexa<nb_entity_type;hexa++)
1861 int hexa_index = (type%100)*hexa;
1863 int N1 = global_connectivity[hexa_index]-1;
1864 int N2 = global_connectivity[hexa_index+1]-1;
1865 int N3 = global_connectivity[hexa_index+2]-1;
1866 int N4 = global_connectivity[hexa_index+3]-1;
1867 int N5 = global_connectivity[hexa_index+4]-1;
1868 int N6 = global_connectivity[hexa_index+5]-1;
1869 int N7 = global_connectivity[hexa_index+6]-1;
1870 int N8 = global_connectivity[hexa_index+7]-1;
1872 double x1 = coord[dim_space*N1];
1873 double x2 = coord[dim_space*N2];
1874 double x3 = coord[dim_space*N3];
1875 double x4 = coord[dim_space*N4];
1876 double x5 = coord[dim_space*N5];
1877 double x6 = coord[dim_space*N6];
1878 double x7 = coord[dim_space*N7];
1879 double x8 = coord[dim_space*N8];
1881 double y1 = coord[dim_space*N1+1];
1882 double y2 = coord[dim_space*N2+1];
1883 double y3 = coord[dim_space*N3+1];
1884 double y4 = coord[dim_space*N4+1];
1885 double y5 = coord[dim_space*N5+1];
1886 double y6 = coord[dim_space*N6+1];
1887 double y7 = coord[dim_space*N7+1];
1888 double y8 = coord[dim_space*N8+1];
1890 double z1 = coord[dim_space*N1+2];
1891 double z2 = coord[dim_space*N2+2];
1892 double z3 = coord[dim_space*N3+2];
1893 double z4 = coord[dim_space*N4+2];
1894 double z5 = coord[dim_space*N5+2];
1895 double z6 = coord[dim_space*N6+2];
1896 double z7 = coord[dim_space*N7+2];
1897 double z8 = coord[dim_space*N8+2];
1899 xbarycenter1 = (x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8)/8.0;
1900 xbarycenter2 = (y1 + y2 + y3 + y4 + y5 + y6 + y7 + y8)/8.0;
1901 xbarycenter3 = (z1 + z2 + z3 + z4 + z5 + z6 + z7 + z8)/8.0;
1903 barycenter[3*index] = xbarycenter1 ;
1904 barycenter[3*index+1] = xbarycenter2 ;
1905 barycenter[3*index+2] = xbarycenter3 ;
1911 case MED_TRIA3 : case MED_TRIA6 :
1913 for (int tria=0;tria<nb_entity_type;tria++)
1915 int tria_index = (type%100)*tria;
1917 int N1 = global_connectivity[tria_index]-1;
1918 int N2 = global_connectivity[tria_index+1]-1;
1919 int N3 = global_connectivity[tria_index+2]-1;
1921 double x1 = coord[dim_space*N1];
1922 double x2 = coord[dim_space*N2];
1923 double x3 = coord[dim_space*N3];
1925 double y1 = coord[dim_space*N1+1];
1926 double y2 = coord[dim_space*N2+1];
1927 double y3 = coord[dim_space*N3+1];
1929 xbarycenter1 = (x1 + x2 + x3)/3.0;
1930 xbarycenter2 = (y1 + y2 + y3)/3.0;
1934 barycenter[2*index] = xbarycenter1 ;
1935 barycenter[2*index+1] = xbarycenter2 ;
1940 coord[dim_space*N1+2];
1942 coord[dim_space*N2+2];
1944 coord[dim_space*N3+2];
1946 xbarycenter3 = (z1 + z2 + z3)/3.0;
1948 barycenter[3*index] = xbarycenter1 ;
1949 barycenter[3*index+1] = xbarycenter2 ;
1950 barycenter[3*index+2] = xbarycenter3 ;
1957 case MED_QUAD4 : case MED_QUAD8 :
1959 for (int quad=0;quad<nb_entity_type;quad++)
1961 int quad_index = (type%100)*quad;
1963 int N1 = global_connectivity[quad_index]-1;
1964 int N2 = global_connectivity[quad_index+1]-1;
1965 int N3 = global_connectivity[quad_index+2]-1;
1966 int N4 = global_connectivity[quad_index+3]-1;
1968 double x1 = coord[dim_space*N1];
1969 double x2 = coord[dim_space*N2];
1970 double x3 = coord[dim_space*N3];
1971 double x4 = coord[dim_space*N4];
1973 double y1 = coord[dim_space*N1+1];
1974 double y2 = coord[dim_space*N2+1];
1975 double y3 = coord[dim_space*N3+1];
1976 double y4 = coord[dim_space*N4+1];
1978 xbarycenter1 = (x1 + x2 + x3 + x4)/4.0;
1979 xbarycenter2 = (y1 + y2 + y3 + y4)/4.0;
1983 barycenter[2*index] = xbarycenter1 ;
1984 barycenter[2*index+1] = xbarycenter2 ;
1988 double z1 = coord[dim_space*N1+2];
1989 double z2 = coord[dim_space*N2+2];
1990 double z3 = coord[dim_space*N3+2];
1991 double z4 = coord[dim_space*N4+2];
1993 xbarycenter3 = (z1 + z2 + z3 + z4)/4.0;
1995 barycenter[3*index] = xbarycenter1 ;
1996 barycenter[3*index+1] = xbarycenter2 ;
1997 barycenter[3*index+2] = xbarycenter3 ;
2003 case MED_SEG2 : case MED_SEG3 :
2005 for (int edge=0;edge<nb_entity_type;edge++)
2007 int edge_index = (type%100)*edge;
2009 int N1 = global_connectivity[edge_index]-1;
2010 int N2 = global_connectivity[edge_index+1]-1;
2012 double x1 = coord[dim_space*N1];
2013 double x2 = coord[dim_space*N2];
2015 double y1 = coord[dim_space*N1+1];
2016 double y2 = coord[dim_space*N2+1];
2018 xbarycenter1 = (x1 + x2)/2.0;
2019 xbarycenter2 = (y1 + y2)/2.0;
2023 barycenter[2*index] = xbarycenter1 ;
2024 barycenter[2*index+1] = xbarycenter2 ;
2028 double z1 = coord[dim_space*N1+2];
2029 double z2 = coord[dim_space*N2+2];
2031 xbarycenter3 = (z1 + z2)/2.0;
2033 barycenter[3*index] = xbarycenter1 ;
2034 barycenter[3*index+1] = xbarycenter2 ;
2035 barycenter[3*index+2] = xbarycenter3 ;
2042 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Bad Support to get a barycenter on it (in fact unknown type) !"));
2046 if (!onAll) delete [] global_connectivity ;
2049 Barycenter->setValue(MED_FULL_INTERLACE,barycenter);
2051 delete[] barycenter ;
2058 //=======================================================================
2059 //function : checkGridFillCoords
2060 //purpose : if this->_isAGrid, assure that _coordinate is filled
2061 //=======================================================================
2063 // inline void MESH::checkGridFillCoords() const
2066 // ((GRID *) this)->fillCoordinates();
2069 //=======================================================================
2070 //function : checkGridFillConnectivity
2071 //purpose : if this->_isAGrid, assure that _connectivity is filled
2072 //=======================================================================
2074 // inline void MESH::checkGridFillConnectivity() const
2077 // ((GRID *) this)->fillConnectivity();
2080 bool MESH::isEmpty() const
2082 bool notempty = _name != "" || _coordinate != NULL || _connectivity != NULL ||
2083 _spaceDimension !=MED_INVALID || _meshDimension !=MED_INVALID ||
2084 _numberOfNodes !=MED_INVALID || _numberOfNodesFamilies !=0 ||
2085 _familyNode.size() != 0 || _numberOfCellsFamilies != 0 ||
2086 _familyCell.size() != 0 || _numberOfFacesFamilies != 0 ||
2087 _familyFace.size() != 0 || _numberOfEdgesFamilies !=0 ||
2088 _familyEdge.size() != 0 || _isAGrid != 0 ;
2092 void MESH::read(int index)
2094 const char * LOC = "MESH::read(int index=0) : ";
2097 if (_drivers[index]) {
2098 _drivers[index]->open();
2099 _drivers[index]->read();
2100 _drivers[index]->close();
2103 throw MED_EXCEPTION ( LOCALIZED( STRING(LOC)
2104 << "The index given is invalid, index must be between 0 and |"
2109 // ((GRID *) this)->fillMeshAfterRead();
2113 //=======================================================================
2114 //function : getSkin
2116 //=======================================================================
2118 SUPPORT * MESH::getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION)
2120 const char * LOC = "MESH::getSkin : " ;
2123 if (this != Support3D->getMesh())
2124 throw MEDEXCEPTION(STRING(LOC) << "no compatibility between *this and SUPPORT::_mesh !");
2125 if (_meshDimension != 3 || Support3D->getEntity() != MED_CELL)
2126 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Defined on 3D cells only"));
2128 // well, all rigth !
2129 SUPPORT * mySupport = new SUPPORT(this,"Skin",MED_FACE);
2130 mySupport->setAll(false);
2132 list<int> myElementsList ;
2135 calculateConnectivity(MED_FULL_INTERLACE, MED_DESCENDING, MED_CELL);
2136 if (Support3D->isOnAllElements())
2138 int * myConnectivityValue = const_cast <int*> (getReverseConnectivity(MED_DESCENDING)) ;
2139 int nbFaces = getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS);
2140 for (i=0, j=1 ; j<=nbFaces; ++j, i += 2)
2142 int cellNb1 = myConnectivityValue [i];
2143 int cellNb2 = myConnectivityValue [i+1];
2144 //MESSAGE( " FACE # " << j << " -- Cells: " << cellNb1 << ", " << cellNb2 );
2145 if ((cellNb1 == 0 || cellNb2 == 0) && (cellNb1 + cellNb2 > 0))
2147 myElementsList.push_back( j ) ;
2154 map<int,int> FaceNbEncounterNb;
2156 int * myConnectivityValue = const_cast <int *>
2157 (getConnectivity(MED_FULL_INTERLACE, MED_DESCENDING,
2158 MED_CELL, MED_ALL_ELEMENTS));
2159 int * myConnectivityIndex = const_cast <int *> (getConnectivityIndex(MED_DESCENDING, MED_CELL));
2160 int * myCellNbs = const_cast <int *> (Support3D->getnumber()->getValue());
2161 int nbCells = Support3D->getnumber()->getLength();
2162 for (i=0; i<nbCells; ++i)
2164 int cellNb = myCellNbs [ i ];
2165 int faceFirst = myConnectivityIndex[ cellNb-1 ];
2166 int faceLast = myConnectivityIndex[ cellNb ];
2167 for (j = faceFirst; j < faceLast; ++j)
2169 int faceNb = abs( myConnectivityValue [ j-1 ] );
2170 //MESSAGE( "Cell # " << i << " -- Face: " << faceNb);
2171 if (FaceNbEncounterNb.find( faceNb ) == FaceNbEncounterNb.end())
2172 FaceNbEncounterNb[ faceNb ] = 1;
2174 FaceNbEncounterNb[ faceNb ] ++;
2177 map<int,int>::iterator FaceNbEncounterNbItr;
2178 for (FaceNbEncounterNbItr = FaceNbEncounterNb.begin();
2179 FaceNbEncounterNbItr != FaceNbEncounterNb.end();
2180 FaceNbEncounterNbItr ++)
2181 if ((*FaceNbEncounterNbItr).second == 1)
2183 myElementsList.push_back( (*FaceNbEncounterNbItr).first) ;
2187 // Well, we must know how many geometric type we have found
2188 int * myListArray = new int[size] ;
2190 list<int>::iterator myElementsListIt ;
2191 for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
2192 myListArray[id]=(*myElementsListIt) ;
2196 int numberOfGeometricType ;
2197 medGeometryElement* geometricType ;
2198 int * numberOfGaussPoint ;
2199 int * geometricTypeNumber ;
2200 int * numberOfEntities ;
2201 // MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY() ;
2202 int * mySkyLineArrayIndex ;
2204 int numberOfType = getNumberOfTypes(MED_FACE) ;
2205 if (numberOfType == 1) { // wonderfull : it's easy !
2206 numberOfGeometricType = 1 ;
2207 geometricType = new medGeometryElement[1] ;
2208 const medGeometryElement * allType = getTypes(MED_FACE);
2209 geometricType[0] = allType[0] ;
2210 numberOfGaussPoint = new int[1] ;
2211 numberOfGaussPoint[0] = 1 ;
2212 geometricTypeNumber = new int[1] ; // not use, but initialized to nothing
2213 geometricTypeNumber[0] = 0 ;
2214 numberOfEntities = new int[1] ;
2215 numberOfEntities[0] = size ;
2216 mySkyLineArrayIndex = new int[2] ;
2217 mySkyLineArrayIndex[0]=1 ;
2218 mySkyLineArrayIndex[1]=1+size ;
2221 map<medGeometryElement,int> theType ;
2222 for (myElementsListIt=myElementsList.begin();myElementsListIt!=myElementsList.end();myElementsListIt++) {
2223 medGeometryElement myType = getElementType(MED_FACE,*myElementsListIt) ;
2224 if (theType.find(myType) != theType.end() )
2225 theType[myType]+=1 ;
2229 numberOfGeometricType = theType.size() ;
2230 geometricType = new medGeometryElement[numberOfGeometricType] ;
2231 //const medGeometryElement * allType = getTypes(MED_FACE); !! UNUSED VARIABLE !!
2232 numberOfGaussPoint = new int[numberOfGeometricType] ;
2233 geometricTypeNumber = new int[numberOfGeometricType] ; // not use, but initialized to nothing
2234 numberOfEntities = new int[numberOfGeometricType] ;
2235 mySkyLineArrayIndex = new int[numberOfGeometricType+1] ;
2237 mySkyLineArrayIndex[0]=1 ;
2238 map<medGeometryElement,int>::iterator theTypeIt ;
2239 for (theTypeIt=theType.begin();theTypeIt!=theType.end();theTypeIt++) {
2240 geometricType[index] = (*theTypeIt).first ;
2241 numberOfGaussPoint[index] = 1 ;
2242 geometricTypeNumber[index] = 0 ;
2243 numberOfEntities[index] = (*theTypeIt).second ;
2244 mySkyLineArrayIndex[index+1]=mySkyLineArrayIndex[index]+numberOfEntities[index] ;
2248 // mySkyLineArray->setMEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
2249 MEDSKYLINEARRAY * mySkyLineArray = new MEDSKYLINEARRAY(numberOfGeometricType,size,mySkyLineArrayIndex,myListArray) ;
2251 mySupport->setNumberOfGeometricType(numberOfGeometricType) ;
2252 mySupport->setGeometricType(geometricType) ;
2253 mySupport->setNumberOfGaussPoint(numberOfGaussPoint) ;
2254 // mySupport->setGeometricTypeNumber(geometricTypeNumber) ;
2255 mySupport->setNumberOfElements(numberOfEntities) ;
2256 mySupport->setTotalNumberOfElements(size) ;
2257 mySupport->setNumber(mySkyLineArray) ;
2259 delete[] numberOfEntities;
2260 delete[] geometricTypeNumber;
2261 delete[] numberOfGaussPoint;
2262 delete[] geometricType;
2263 delete[] mySkyLineArrayIndex;
2264 delete[] myListArray;
2265 // delete mySkyLineArray;
2273 return a SUPPORT pointer on the union of all SUPPORTs in Supports.
2274 You should delete this pointer after use to avoid memory leaks.
2276 SUPPORT * MESH::mergeSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION)
2278 const char * LOC = "MESH:::mergeSupports(const vector<SUPPORT *> ) : " ;
2281 SUPPORT * returnedSupport;
2282 string returnedSupportName;
2283 string returnedSupportDescription;
2284 char * returnedSupportNameChar;
2285 char * returnedSupportDescriptionChar;
2286 int size = Supports.size();
2290 MESSAGE(LOC <<" there is only one SUPPORT in the argument list, the method return a copy of this object !");
2291 SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
2293 returnedSupport = new SUPPORT(*obj);
2295 int lenName = strlen((Supports[0]->getName()).c_str()) + 8 + 1;
2296 int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 8 + 1;
2298 returnedSupportNameChar = new char[lenName];
2299 returnedSupportDescriptionChar = new char[lenDescription];
2301 returnedSupportNameChar = strcpy(returnedSupportNameChar,"Copy of ");
2302 returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str());
2303 returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Copy of ");
2304 returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
2305 (Supports[0]->getDescription()).c_str());
2307 returnedSupportName = string(returnedSupportNameChar);
2308 returnedSupportDescription = string(returnedSupportDescriptionChar);
2310 returnedSupport->setName(returnedSupportName);
2311 returnedSupport->setDescription(returnedSupportDescription);
2313 delete [] returnedSupportNameChar;
2314 delete [] returnedSupportDescriptionChar;
2318 SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
2319 returnedSupport = new SUPPORT(*obj);
2321 int lenName = strlen((Supports[0]->getName()).c_str()) + 9 + 1;
2322 int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 9 + 1;
2324 for(int i = 1;i<size;i++)
2326 obj = const_cast <SUPPORT *> (Supports[i]);
2327 returnedSupport->blending(obj);
2331 lenName = lenName + 5 + strlen((Supports[i]->getName()).c_str());
2332 lenDescription = lenDescription + 5 +
2333 strlen((Supports[i]->getDescription()).c_str());
2337 lenName = lenName + 2 + strlen((Supports[i]->getName()).c_str());
2338 lenDescription = lenDescription + 2 +
2339 strlen((Supports[i]->getDescription()).c_str());
2343 returnedSupportNameChar = new char[lenName];
2344 returnedSupportDescriptionChar = new char[lenDescription];
2346 returnedSupportNameChar = strcpy(returnedSupportNameChar,"Merge of ");
2347 returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Merge of ");
2349 returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str());
2350 returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
2351 (Supports[0]->getDescription()).c_str());
2353 for(int i = 1;i<size;i++)
2357 returnedSupportNameChar = strcat(returnedSupportNameChar," and ");
2358 returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar," and ");
2360 returnedSupportNameChar = strcat(returnedSupportNameChar,
2361 (Supports[i]->getName()).c_str());
2362 returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
2363 (Supports[i]->getDescription()).c_str());
2367 returnedSupportNameChar = strcat(returnedSupportNameChar,", ");
2368 returnedSupportNameChar = strcat(returnedSupportNameChar,
2369 (Supports[i]->getName()).c_str());
2371 returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,", ");
2372 returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
2373 (Supports[i]->getDescription()).c_str());
2377 returnedSupportName = string(returnedSupportNameChar);
2378 returnedSupport->setName(returnedSupportName);
2380 returnedSupportDescription = string(returnedSupportDescriptionChar);
2381 returnedSupport->setDescription(returnedSupportDescription);
2383 delete [] returnedSupportNameChar;
2384 delete [] returnedSupportDescriptionChar;
2388 return returnedSupport;
2392 return a SUPPORT pointer on the intersection of all SUPPORTs in Supports.
2393 The (SUPPORT *) NULL pointer is returned if the intersection is empty.
2394 You should delete this pointer after use to avois memory leaks.
2396 SUPPORT * MESH::intersectSupports(const vector<SUPPORT *> Supports) const throw (MEDEXCEPTION)
2398 const char * LOC = "MESH:::intersectSupports(const vector<SUPPORT *> ) : " ;
2401 SUPPORT * returnedSupport;
2402 string returnedSupportName;
2403 string returnedSupportDescription;
2404 char * returnedSupportNameChar;
2405 char * returnedSupportDescriptionChar;
2406 int size = Supports.size();
2410 MESSAGE(LOC <<" there is only one SUPPORT in the argument list, the method return a copy of this object !");
2411 SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
2413 returnedSupport = new SUPPORT(*obj);
2415 int lenName = strlen((Supports[0]->getName()).c_str()) + 8 + 1;
2416 int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 8 + 1;
2418 returnedSupportNameChar = new char[lenName];
2419 returnedSupportDescriptionChar = new char[lenDescription];
2421 returnedSupportNameChar = strcpy(returnedSupportNameChar,"Copy of ");
2422 returnedSupportNameChar = strcat(returnedSupportNameChar,(Supports[0]->getName()).c_str());
2423 returnedSupportDescriptionChar = strcpy(returnedSupportDescriptionChar,"Copy of ");
2424 returnedSupportDescriptionChar = strcat(returnedSupportDescriptionChar,
2425 (Supports[0]->getDescription()).c_str());
2427 returnedSupportName = string(returnedSupportNameChar);
2428 returnedSupportDescription = string(returnedSupportDescriptionChar);
2430 returnedSupport->setName(returnedSupportName);
2431 returnedSupport->setDescription(returnedSupportDescription);
2433 delete [] returnedSupportNameChar;
2434 delete [] returnedSupportDescriptionChar;
2438 SUPPORT * obj = const_cast <SUPPORT *> (Supports[0]);
2439 returnedSupport = new SUPPORT(*obj);
2441 int lenName = strlen((Supports[0]->getName()).c_str()) + 16 + 1;
2442 int lenDescription = strlen((Supports[0]->getDescription()).c_str()) + 16 + 1;
2444 for(int i = 1;i<size;i++)
2446 obj = const_cast <SUPPORT *> (Supports[i]);
2447 returnedSupport->intersecting(obj);
2451 lenName = lenName + 5 + strlen((Supports[i]->getName()).c_str());
2452 lenDescription = lenDescription + 5 +
2453 strlen((Supports[i]->getDescription()).c_str());
2457 lenName = lenName + 2 + strlen((Supports[i]->getName()).c_str());
2458 lenDescription = lenDescription + 2 +
2459 strlen((Supports[i]->getDescription()).c_str());
2463 if(returnedSupport != (SUPPORT *) NULL)
2465 returnedSupportNameChar = new char[lenName];
2466 returnedSupportDescriptionChar = new char[lenDescription];
2468 returnedSupportNameChar = strcpy(returnedSupportNameChar,
2469 "Intersection of ");
2470 returnedSupportDescriptionChar =
2471 strcpy(returnedSupportDescriptionChar,"Intersection of ");
2473 returnedSupportNameChar = strcat(returnedSupportNameChar,
2474 (Supports[0]->getName()).c_str());
2475 returnedSupportDescriptionChar =
2476 strcat(returnedSupportDescriptionChar,
2477 (Supports[0]->getDescription()).c_str());
2479 for(int i = 1;i<size;i++)
2483 returnedSupportNameChar = strcat(returnedSupportNameChar,
2485 returnedSupportDescriptionChar =
2486 strcat(returnedSupportDescriptionChar," and ");
2488 returnedSupportNameChar =
2489 strcat(returnedSupportNameChar,
2490 (Supports[i]->getName()).c_str());
2491 returnedSupportDescriptionChar =
2492 strcat(returnedSupportDescriptionChar,
2493 (Supports[i]->getDescription()).c_str());
2497 returnedSupportNameChar = strcat(returnedSupportNameChar,
2499 returnedSupportNameChar =
2500 strcat(returnedSupportNameChar,
2501 (Supports[i]->getName()).c_str());
2503 returnedSupportDescriptionChar =
2504 strcat(returnedSupportDescriptionChar,", ");
2505 returnedSupportDescriptionChar =
2506 strcat(returnedSupportDescriptionChar,
2507 (Supports[i]->getDescription()).c_str());
2511 returnedSupportName = string(returnedSupportNameChar);
2512 returnedSupport->setName(returnedSupportName);
2514 returnedSupportDescription = string(returnedSupportDescriptionChar);
2515 returnedSupport->setDescription(returnedSupportDescription);
2517 delete [] returnedSupportNameChar;
2518 delete [] returnedSupportDescriptionChar;
2523 return returnedSupport;