Page principale | Liste des namespaces | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de namespace | Membres de classe | Membres de fichier

LagrangianParam.cpp

Aller à la documentation de ce fichier.
00001 /*
00002     Copyright (c) 2005, Quentin Lequy and Romain Gaucher
00003     All rights reserved.
00004 
00005     Redistribution and use in source and binary forms, with or 
00006     without modification, are permitted provided that the following 
00007     conditions are met:
00008 
00009         * Redistributions of source code must retain the above copyright 
00010           notice, this list of conditions and the following disclaimer.
00011 
00012         * Redistributions in binary form must reproduce the above copyright 
00013           notice, this list of conditions and the following disclaimer in the 
00014           documentation and/or other materials provided with the distribution.
00015 
00016         * Neither the name of Quentin Lequy or Romain Gaucher nor the names 
00017           of its contributors may be used to endorse or promote products 
00018           derived from this software without specific prior written permission.
00019 
00020     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023     ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
00025     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
00026     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00027     AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00028     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
00029     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00030 */
00031 
00032 #include "LagrangianParam.h"
00033 #include "Model.h"
00034 #include <iostream>
00035 
00036 namespace Modelib {
00037 
00038 using namespace std;
00039 
00040 
00041 /*-----------------------------------------------------------------------------------------------------------*/
00050 LagrangianParam::LagrangianParam(Model & _model, string constraintName )
00051 {
00052   Constraint c = _model.GetConstraint(constraintName);
00053   //si la contrainte existe
00054   if( !(c == Constraint())  )
00055   {
00056      model = &_model;
00057       
00058      id = c.GetId();
00059      //il prend l'identifiant de la variable
00060   }
00061   else
00062   {
00063     cerr << "Warning in LagrangianParam::LagrangianParam : constraint doesn't exist" << endl;
00064     model = 0;
00065     id = 0;
00066     //sinon elle prend les caractéristiques de la contrainte nulle
00067   }
00068 }
00069 /*-----------------------------------------------------------------------------------------------------------*/
00078 LagrangianParam::LagrangianParam(Model & _model, VarId _id )
00079 {
00080   Constraint c = _model.GetConstraint(_id);
00081   //si la contrainte existe
00082   if( !(c == Constraint())  )
00083   {
00084      model = &_model;
00085      id = _id;
00086      //il prend l'identifiant de la variable
00087   }
00088   else
00089   {
00090     cerr << "Warning in LagrangianParam::LagrangianParam : constraint doesn't exist" << endl;
00091     model = 0;
00092     id = 0;
00093     //sinon elle prend les caractéristiques de la contrainte nulle
00094   }
00095 }
00096 
00097 /*-----------------------------------------------------------------------------------------------------------*/
00102 float LagrangianParam::GetValue() const
00103 {
00104    //si le modèle existe
00105    if(model)
00106    {
00107       return model->GetLagrangianParamValue(id);
00108       //on retoune la valeur qui se trouve dans Model::constraintMap
00109    }
00110    else
00111    {
00112       cerr << "Warning in LagrangianParam::GetValue : undefined model" << endl;
00113       return 0;
00114       //sinon on retourne 0
00115    }
00116 }
00117 
00122 void LagrangianParam::SetValue(float _value)
00123 {
00124   //si le modele existe
00125   if(model)
00126      model->SetLagrangianParamValue(id,_value);
00127      //on appelle la fonction qui va changer la valeur du lagrangien dans Model::constraintMap
00128   else
00129      cerr << "Warning in LagrangianParam::SetValue : undefined model" << endl;
00130 
00131 }
00132 
00133 
00134 #ifdef COMPILE_FOR_PYTHON
00135        #include "py_LagrangianParam.cxx"
00136 #endif
00137 
00138 }

Généré le Sun Oct 2 19:13:12 2005 pour Modelib par  doxygen 1.4.4