Changeset 4943


Ignore:
Timestamp:
08/03/10 09:43:56 (15 years ago)
Author:
Mathieu Morlighem
Message:

Added DuplicateInput method of inputs called by InputDuplicate

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

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/Container/Inputs.cpp

    r4927 r4943  
    315315}
    316316/*}}}*/
     317/*FUNCTION Inputs::ChangeEnum{{{1*/
     318void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){
     319
     320        /*Go through dataset of inputs and look for input with
     321         * same enum as input enum, once found, just change its name */
     322        vector<Object*>::iterator object;
     323        Input* input=NULL;
     324
     325        /*Delete existing input of newenumtype if it exists*/
     326        for ( object=objects.begin() ; object < objects.end(); object++ ){
     327                input=(Input*)(*object);
     328
     329                if (input->EnumType()==newenumtype){
     330                        this->DeleteObject(input);
     331                        break;
     332                }
     333        }
     334
     335        /*Change enum_type of input of oldenumtype*/
     336        for ( object=objects.begin() ; object < objects.end(); object++ ){
     337
     338                input=(Input*)(*object);
     339
     340                if (input->EnumType()==oldenumtype){
     341                        input->ChangeEnum(newenumtype);
     342                        break;
     343                }
     344        }
     345}
     346/*}}}*/
    317347/*FUNCTION Inputs::GetInput{{{1*/
    318348Input* Inputs::GetInput(int enum_name){
     
    352382}
    353383/*}}}*/
    354 /*FUNCTION Inputs::ChangeEnum{{{1*/
    355 void  Inputs::ChangeEnum(int oldenumtype,int newenumtype){
    356 
    357         /*Go through dataset of inputs and look for input with
    358          * same enum as input enum, once found, just change its name */
    359         vector<Object*>::iterator object;
    360         Input* input=NULL;
    361 
    362         /*Delete existing input of newenumtype if it exists*/
    363         for ( object=objects.begin() ; object < objects.end(); object++ ){
    364                 input=(Input*)(*object);
    365 
    366                 if (input->EnumType()==newenumtype){
    367                         this->DeleteObject(input);
    368                         break;
    369                 }
    370         }
    371 
    372         /*Change enum_type of input of oldenumtype*/
    373         for ( object=objects.begin() ; object < objects.end(); object++ ){
    374 
    375                 input=(Input*)(*object);
    376 
    377                 if (input->EnumType()==oldenumtype){
    378                         input->ChangeEnum(newenumtype);
    379                         break;
    380                 }
    381         }
     384/*FUNCTION Inputs::DuplicateInput{{{1*/
     385void  Inputs::DuplicateInput(int original_enum,int new_enum){
     386
     387        Input* original=NULL;
     388        Input* copy=NULL;
     389
     390        /*Make a copy of the original input: */
     391        original=(Input*)this->GetInput(original_enum);
     392        if(!original)ISSMERROR("could not find input with enum: %s",EnumAsString(original_enum));
     393        copy=(Input*)original->copy();
     394
     395        /*Change copy enum to reinitialized_enum: */
     396        copy->ChangeEnum(new_enum);
     397
     398        /*Add copy into inputs, it will wipe off the one already there: */
     399        this->AddInput((Input*)copy);
    382400}
    383401/*}}}*/
  • issm/trunk/src/c/Container/Inputs.h

    r4927 r4943  
    2929                /*numerics: {{{1*/
    3030                int     AddInput(Input* in_input);
     31                void    ChangeEnum(int enumtype,int new_enumtype);
    3132                int     DeleteInput(int enum_type);
     33                void    DuplicateInput(int original_enum,int new_enum);
    3234                Input*  GetInput(int enum_name);
    3335                Inputs* SpawnTriaInputs(int* indices);
    3436               
     37                void GetParameterAverage(double* pvalue, int enum_type);
    3538                void GetParameterValue(bool* pvalue,int enum_type);
    3639                void GetParameterValue(int* pvalue,int enum_type);
     
    3841                void GetParameterValue(double* pvalue,double* gauss,int enum_type);
    3942                void GetParameterValue(double* pvalue,double* gauss,int enum_type,double defaultvalue);
    40                 void GetParameterAverage(double* pvalue, int enum_type);
    41                
    4243                void GetParameterValues(double* values,double* gauss_pointers, int numgauss,int enum_type);
    4344                void GetParameterValues(double* values,double* gauss_pointers, int numgauss,int enum_type,double* defaultvalues);
    44        
    4545                void GetParameterDerivativeValue(double* derivativevalues, double* xyz_list, double* gauss,int enum_type);
    46 
    47                 void ChangeEnum(int enumtype,int new_enumtype);
    48 
    4946                /*}}}*/
    5047
  • issm/trunk/src/c/objects/Elements/Penta.cpp

    r4942 r4943  
    11301130void  Penta::InputDuplicate(int original_enum,int new_enum){
    11311131
    1132         Input* original=NULL;
    1133         Input* copy=NULL;
    1134 
    1135         /*Make a copy of the original input: */
    1136         original=(Input*)this->inputs->GetInput(original_enum);
    1137         if(!original)ISSMERROR(" could not find old input with enum: %s",EnumAsString(original_enum));
    1138         copy=(Input*)original->copy();
    1139 
    1140         /*Change copy enum to reinitialized_enum: */
    1141         copy->ChangeEnum(new_enum);
    1142 
    1143         /*Add copy into inputs, it will wipe off the one already there: */
    1144         inputs->AddInput((Input*)copy);
     1132        /*Call inputs method*/
     1133        inputs->DuplicateInput(original_enum,new_enum);
     1134
    11451135}
    11461136/*}}}*/
  • issm/trunk/src/c/objects/Elements/Tria.cpp

    r4941 r4943  
    13181318void  Tria::InputDuplicate(int original_enum,int new_enum){
    13191319
    1320         Input* original=NULL;
    1321         Input* copy=NULL;
    1322 
    1323         /*Make a copy of the original input: */
    1324         original=(Input*)this->inputs->GetInput(original_enum);
    1325         if(!original)ISSMERROR(" could not find old input with enum: %s",EnumAsString(original_enum));
    1326         copy=(Input*)original->copy();
    1327 
    1328         /*Change copy enum to reinitialized_enum: */
    1329         copy->ChangeEnum(new_enum);
    1330 
    1331         /*Add copy into inputs, it will wipe off the one already there: */
    1332         inputs->AddInput((Input*)copy);
     1320        /*Call inputs method*/
     1321        inputs->DuplicateInput(original_enum,new_enum);
     1322
    13331323}
    13341324/*}}}*/
Note: See TracChangeset for help on using the changeset viewer.