[1] | 1 | /*! \file Contour.c
|
---|
| 2 | * \sa Contour.h
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #ifdef HAVE_CONFIG_H
|
---|
[9320] | 6 | #include <config.h>
|
---|
[1] | 7 | #else
|
---|
| 8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
[3681] | 11 | #include "./objects.h"
|
---|
[3775] | 12 | #include "../include/include.h"
|
---|
[9761] | 13 | #include "../io/io.h"
|
---|
[1] | 14 |
|
---|
[12004] | 15 | /*Contour constructors and destructors:*/
|
---|
| 16 | /*FUNCTION Contour::Contour() default constructor {{{1*/
|
---|
| 17 | Contour::Contour(){
|
---|
| 18 | this->id=0;
|
---|
| 19 | this->nods=0;
|
---|
| 20 | this->x=NULL;
|
---|
| 21 | this->y=NULL;
|
---|
| 22 | this->closed=false;
|
---|
| 23 | }
|
---|
| 24 | /*}}}*/
|
---|
| 25 | /*FUNCTION Contour::Contour(int pid, int nods, double* x, double* y,bool closed) {{{1*/
|
---|
| 26 | Contour::Contour(int pid,int pnods, double* px, double* py,bool pclosed){
|
---|
| 27 |
|
---|
| 28 | this->id=pid;
|
---|
| 29 | this->nods=pnods;
|
---|
| 30 | this->closed=pclosed;
|
---|
| 31 | if(nods){
|
---|
| 32 | this->x=(double*)xmalloc(nods*sizeof(double));
|
---|
| 33 | memcpy(this->x,px,nods*sizeof(double));
|
---|
| 34 | this->y=(double*)xmalloc(nods*sizeof(double));
|
---|
| 35 | memcpy(this->y,py,nods*sizeof(double));
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
| 38 | /*}}}*/
|
---|
| 39 | /*FUNCTION Contour::Contour() default constructor {{{1*/
|
---|
| 40 | Contour::~Contour(){
|
---|
| 41 | xfree((void**)&this->x);
|
---|
| 42 | xfree((void**)&this->y);
|
---|
| 43 | }
|
---|
| 44 | /*}}}*/
|
---|
[1] | 45 |
|
---|
[12004] | 46 |
|
---|
| 47 | /*Object virtual function resolutoin: */
|
---|
| 48 | /*FUNCTION Contour::Echo(){{{1*/
|
---|
| 49 | void Contour::Echo(void){
|
---|
| 50 |
|
---|
[1] | 51 | int i;
|
---|
| 52 |
|
---|
[12004] | 53 | printf("Contour: %i:\n",id);
|
---|
| 54 | printf(" nods: %i\n",nods);
|
---|
| 55 | printf(" closed: %s\n",closed?"true":"false");
|
---|
| 56 | if(nods){
|
---|
| 57 | printf(" x,y:\n");
|
---|
| 58 | for(i=0;i<nods;i++){
|
---|
| 59 | printf("%i: %g|%g\n",i,x[i],y[i]);
|
---|
| 60 | }
|
---|
[1] | 61 | }
|
---|
| 62 | }
|
---|
[12004] | 63 | /*}}}*/
|
---|
| 64 | /*FUNCTION Contour::DeepEcho(){{{1*/
|
---|
| 65 | void Contour::DeepEcho(void){
|
---|
| 66 | this->Echo();
|
---|
| 67 | }
|
---|
| 68 | /*}}}*/
|
---|
| 69 | /*FUNCTION Contour::Id(){{{1*/
|
---|
| 70 | int Contour::Id(void){
|
---|
| 71 | return id;
|
---|
| 72 | }
|
---|
| 73 | /*}}}*/
|
---|
| 74 | /*FUNCTION Contour::MyRank{{{1*/
|
---|
| 75 | int Contour::MyRank(void){
|
---|
| 76 | extern int my_rank;
|
---|
| 77 |
|
---|
| 78 | return my_rank;
|
---|
| 79 | }
|
---|
| 80 | /*}}}*/
|
---|
| 81 | #ifdef _SERIAL_
|
---|
| 82 | /*FUNCTION Contour::Marshall{{{1*/
|
---|
| 83 | void Contour::Marshall(char** pmarshalled_dataset){
|
---|
| 84 |
|
---|
| 85 | char* marshalled_dataset=NULL;
|
---|
| 86 | int enum_type=0;
|
---|
| 87 | char* marshalled_inputs=NULL;
|
---|
| 88 | int marshalled_inputssize;
|
---|
| 89 |
|
---|
| 90 | /*recover marshalled_dataset: */
|
---|
| 91 | marshalled_dataset=*pmarshalled_dataset;
|
---|
| 92 |
|
---|
| 93 | /*get enum type of Contour: */
|
---|
| 94 | enum_type=ContourEnum;
|
---|
| 95 |
|
---|
| 96 | /*marshall enum: */
|
---|
| 97 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
| 98 |
|
---|
| 99 | /*marshall Contour data: */
|
---|
| 100 | memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
|
---|
| 101 | memcpy(marshalled_dataset,&nods,sizeof(nods));marshalled_dataset+=sizeof(nods);
|
---|
| 102 | memcpy(marshalled_dataset,&closed,sizeof(closed));marshalled_dataset+=sizeof(closed);
|
---|
| 103 | memcpy(marshalled_dataset,x,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
|
---|
| 104 | memcpy(marshalled_dataset,y,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
|
---|
| 105 |
|
---|
| 106 | *pmarshalled_dataset=marshalled_dataset;
|
---|
| 107 | return;
|
---|
| 108 | }
|
---|
| 109 | /*}}}*/
|
---|
| 110 | /*FUNCTION Contour::MarshallSize{{{1*/
|
---|
| 111 | int Contour::MarshallSize(){
|
---|
| 112 |
|
---|
| 113 | return sizeof(id)+
|
---|
| 114 | sizeof(nods)+
|
---|
| 115 | sizeof(closed)+
|
---|
| 116 | 2*nods*sizeof(double)+
|
---|
| 117 | sizeof(int); //sizeof(int) for enum type
|
---|
| 118 | }
|
---|
| 119 | /*}}}*/
|
---|
| 120 | /*FUNCTION Contour::Demarshall{{{1*/
|
---|
| 121 | void Contour::Demarshall(char** pmarshalled_dataset){
|
---|
| 122 |
|
---|
| 123 | char* marshalled_dataset=NULL;
|
---|
| 124 |
|
---|
| 125 | /*recover marshalled_dataset: */
|
---|
| 126 | marshalled_dataset=*pmarshalled_dataset;
|
---|
| 127 |
|
---|
| 128 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
---|
| 129 | *object data (thanks to DataSet::Demarshall):*/
|
---|
| 130 |
|
---|
| 131 | memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
|
---|
| 132 | memcpy(&nods,marshalled_dataset,sizeof(nods));marshalled_dataset+=sizeof(nods);
|
---|
| 133 | memcpy(&closed,marshalled_dataset,sizeof(closed));marshalled_dataset+=sizeof(closed);
|
---|
| 134 |
|
---|
| 135 | if(nods){
|
---|
| 136 | this->x=(double*)xmalloc(nods*sizeof(double));
|
---|
| 137 | this->y=(double*)xmalloc(nods*sizeof(double));
|
---|
| 138 | memcpy(x,marshalled_dataset,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
|
---|
| 139 | memcpy(y,marshalled_dataset,nods*sizeof(double));marshalled_dataset+=nods*sizeof(double);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | /*return: */
|
---|
| 143 | *pmarshalled_dataset=marshalled_dataset;
|
---|
| 144 | return;
|
---|
| 145 | }
|
---|
| 146 | /*}}}*/
|
---|
| 147 | #endif
|
---|
| 148 | /*FUNCTION Contour::ObjectEnum{{{1*/
|
---|
| 149 | int Contour::ObjectEnum(void){
|
---|
| 150 |
|
---|
| 151 | return ContourEnum;
|
---|
| 152 |
|
---|
| 153 | }
|
---|
| 154 | /*}}}*/
|
---|
| 155 | /*FUNCTION Contour::copy {{{1*/
|
---|
| 156 | Object* Contour::copy() {
|
---|
| 157 |
|
---|
| 158 | return new Contour(*this);
|
---|
| 159 |
|
---|
| 160 | }
|
---|
| 161 | /*}}}*/
|
---|