Commit bce1600b authored by promayon's avatar promayon
Browse files

NEW type of loads (acceleration)



git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@311 ec899d31-69d1-42ba-9299-647d76f65fb3
parent b29d02d9
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2012 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef ACCELERATION_H
#define ACCELERATION_H
#include "AccelerationUnit.h"
#include "Load.h"
/** Class that defines the type of Load 'Acceleration', for example to set the gravity.
*/
class Acceleration : public Load {
public:
Acceleration() { typeString="Acceleration";unit=AccelerationUnit::MSm2;}
};
#endif //ACCELERATION_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2012 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include <AccelerationUnit.h>
/// initializing the static class member
AccelerationUnit AccelerationUnit::MSm2("m/s^2"); /** Standard SI unit for acceleration: m/s^2 */
AccelerationUnit AccelerationUnit::CMSm2("cm/s^2"); /** cm/s^2 */
AccelerationUnit AccelerationUnit::MMSm2("mm/s^2"); /** mm/s^2 */
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2012 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef ACCELERATIONUNIT_H
#define ACCELERATIONUNIT_H
#include "Unit.h"
/** Class that defines the different units of a Load 'Acceleration'.
*
* This class implements the type-safe design pattern.
*/
class AccelerationUnit : public Unit {
public:
/// Standard SI unit for acceleration: m/s^2
static AccelerationUnit MSm2;
/// cm/s^2
static AccelerationUnit CMSm2;
/// mm/s^2
static AccelerationUnit MMSm2;
private:
AccelerationUnit(std::string n) {unitString = n;}
};
#endif //ACCELERATIONUNIT_H
......@@ -49,7 +49,9 @@ set( HEADERS
RotationUnit.h
TargetList.h
Translation.h
TranslationUnit.h
TranslationUnit.h
Acceleration.h
AccelerationUnit.h
Unit.h
ValueEvent.h
XMLLoads.h
......@@ -64,7 +66,8 @@ set( SRCS
RotationUnit.cpp
TargetList.cpp
Translation.cpp
TranslationUnit.cpp
TranslationUnit.cpp
AccelerationUnit.cpp
ValueEvent.cpp
XMLLoads.cpp
${HEADERS}
......
......@@ -31,6 +31,7 @@
#include "Rotation.h"
#include "Force.h"
#include "Pressure.h"
#include "Acceleration.h"
//--------- static factory -------------
Load * Load::LoadFactory(std::string type) {
......@@ -52,6 +53,10 @@ Load * Load::LoadFactory(std::string type) {
else if(type=="Pressure") {
newOne = new Pressure();
}
// case acceleration
else if(type=="Acceleration") {
newOne = new Acceleration();
}
return newOne;
}
......@@ -174,9 +179,7 @@ void Load::addEvent(ValueEvent * ve) {
// insert the event
eventList.push_back(ve);
// !TODO : SORT the <value event *> by date
//* sort the list
//-- sort the list by date
#if defined(_WIN32) && !defined(__MINGW32__) // MSVC only
std::sort(eventList.begin(), eventList.end(), std::greater); // use the greater() method (see above)
#else
......
......@@ -36,12 +36,14 @@
#include "Translation.h"
#include "TranslationUnit.h"
#include "Rotation.h"
#include "Force.h"
#include "ForceUnit.h"
#include "Pressure.h"
#include "RotationUnit.h"
#include "PressureUnit.h"
#include "Rotation.h"
#include "RotationUnit.h"
#include "Acceleration.h"
#include "AccelerationUnit.h"
//---------------------- constructor --------------------
XMLLoads::XMLLoads() {
......@@ -81,8 +83,10 @@ void XMLLoads::xmlRead(std::string fileName) {
// Set the locale to C for using dot as decimal point dispite locale
// Set utf8 for output to enforce using utf8 strings.
char * statusOk = setlocale(LC_CTYPE, "C.UTF-8");
if (statusOk!=NULL)
statusOk = setlocale(LC_NUMERIC, "C.UTF-8");
if (statusOk!=NULL)
statusOk = setlocale(LC_TIME, "C.UTF-8");
......@@ -91,7 +95,7 @@ void XMLLoads::xmlRead(std::string fileName) {
std::cerr << "Could not set the locale to C. This is mandatory to enforce using dot as decimal separator (platform independency)." << std::endl;
std::cerr << "This can cause a lot of trouble for XML I/O... Beware of decimal dots..." << std::endl;
}
// the resulting document tree
xmlDocPtr doc;
//the pointer to the root node of the document
......@@ -152,7 +156,13 @@ bool XMLLoads::parseElement(xmlNodePtr elem) {
if (!xmlStrcmp(ptype, (const xmlChar*)"Force"))
currentL = new Force();
else
currentL = new Pressure();
if (!xmlStrcmp(ptype, (const xmlChar*)"Pressure"))
currentL = new Pressure();
else
if(!xmlStrcmp(ptype, (const xmlChar*)"Acceleration"))
currentL = new Acceleration();
else
return false;
//parse th load children to get its properties
for (xmlNodePtr child = elem->xmlChildrenNode; child != NULL; child = child->next) {
......
......@@ -39,5 +39,12 @@
<valueEvent value="25" date="40.0"/>
<unit>radian</unit>
</load>
<load xsi:type="Acceleration">
<appliedTo>0-10</appliedTo>
<valueEvent date="0" value="1"/>
<direction x="0" y="-9.81" z="0"/>
<unit>m/s^2</unit>
</load>
</loads>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment