Changeset 4178


Ignore:
Timestamp:
06/23/10 16:49:11 (15 years ago)
Author:
Mathieu Morlighem
Message:

fixed hook initialization

Location:
issm/trunk/src/c/objects
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Elements/PentaHook.cpp

    r4021 r4178  
    3333/*}}}*/
    3434/*FUNCTION PentaHook::InitHookNodes(int numanalyses){{{1*/
    35 void PentaHook::InitHookNodes(int numanalyses){
    36         this->hnodes=(Hook*)xmalloc(numanalyses*sizeof(Hook));
     35void PentaHook::InitHookNodes(int in_numanalyses){
     36
     37        ISSMASSERT(in_numanalyses);
     38
     39        this->numanalyses=in_numanalyses;
     40        this->hnodes=(Hook*)xmalloc(in_numanalyses*sizeof(Hook));
     41
     42        for (int i=0;i<in_numanalyses;i++) this->hnodes[i].Init(NULL,0);
    3743}
    3844/*}}}*/
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r4175 r4178  
    5555        tria_matpar_id=iomodel->numberofelements+1; //refers to the constant material parameters object
    5656
    57         this->InitHookNodes(nummodels);this->nodes=NULL;
     57        this->InitHookNodes(nummodels);      this->nodes=NULL;
    5858        this->InitHookMatice(tria_matice_id);this->matice=NULL;
    5959        this->InitHookMatpar(tria_matpar_id);this->matpar=NULL;
  • issm/trunk/src/c/objects/Elements/TriaHook.cpp

    r4177 r4178  
    3434/*FUNCTION TriaHook::InitHookNodes(int numanalyses){{{1*/
    3535void TriaHook::InitHookNodes(int in_numanalyses){
     36
     37        ISSMASSERT(in_numanalyses);
     38
    3639        this->numanalyses=in_numanalyses;
    37         this->hnodes=(Hook*)xmalloc(numanalyses*sizeof(Hook));
     40        this->hnodes=(Hook*)xmalloc(in_numanalyses*sizeof(Hook));
     41
     42        for (int i=0;i<in_numanalyses;i++) this->hnodes[i].Init(NULL,0);
    3843}
    3944/*}}}*/
  • issm/trunk/src/c/objects/Hook.cpp

    r4137 r4178  
    3737void Hook::Init(int* in_ids, int in_num){
    3838
    39         int i;
     39        /*Intermediaries*/
     40        int i;
     41
     42        /*Get number of objects to hook*/
    4043        this->num=in_num;
    41        
    42         /*Allocate: */
    43         this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
    44         this->ids=(int*)xmalloc(this->num*sizeof(int));
    45         this->offsets=(int*)xmalloc(this->num*sizeof(int));
    46 
    47         /*Copy ids: */
    48         for (i=0;i<this->num;i++){
    49                 this->ids[i]=in_ids[i];
    50                 this->objects[i]=NULL;
    51                 this->offsets[i]=0;
     44
     45        /*Get out if num=0*/
     46        if (num==0){
     47                /*Empty hook*/
     48                this->ids=NULL;
     49                this->objects=NULL;
     50                this->offsets=NULL;
     51        }
     52        else{
     53                /*Allocate: */
     54                this->objects=(Object**)xmalloc(this->num*sizeof(Object*));
     55                this->ids=(int*)xmalloc(this->num*sizeof(int));
     56                this->offsets=(int*)xmalloc(this->num*sizeof(int));
     57
     58                /*Copy ids: */
     59                for (i=0;i<this->num;i++){
     60                        this->ids[i]=in_ids[i];
     61                        this->objects[i]=NULL;
     62                        this->offsets[i]=0;
     63                }
    5264        }
    5365}
     
    213225        Object* object=NULL;
    214226        int i;
     227
     228        /*Checks if debugging mode*/
     229        ISSMASSERT(this->num==0 || this->ids!=NULL);
    215230
    216231        for(i=0;i<this->num;i++){
Note: See TracChangeset for help on using the changeset viewer.