Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F122151456
TwoDTab.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jul 16, 04:46
Size
1 KB
Mime Type
text/x-c
Expires
Fri, Jul 18, 04:46 (2 d)
Engine
blob
Format
Raw Data
Handle
27441465
Attached To
R1695 PCSC - Numerical Integration - Ollitrault Rouaze
TwoDTab.cpp
View Options
//
// Created by Pauline Ollitrault on 28.11.16.
//
#include "TwoDTab.hpp"
/**
* @brief Default constructor
*/
TwoDTab::TwoDTab() : AbstractTabFunction() {}
/**
* @brief Alternate constructor that sets the function
* @details Calls the @e SetFunction() method with the string passed as argument
* @param function string containing the name of the data file
*/
TwoDTab::TwoDTab(const std::string function) : AbstractTabFunction()
{
SetFunction(function);
}
/**
* @brief Sets the function to be integrated
* @details Reads the data file and stores the datas into class member vectors
* Returns an error if the number of nodes in the data file is not greated than 1.
* @param function
*/
void TwoDTab::SetFunction(const std::string function)
{
std::ifstream read_file(function);
try {
if (!read_file.is_open())
{
throw Error("Error opening data file : ");
}
}
catch(Error err)
{
std::cerr << "ERROR : " << err.what() << function <<std::endl;
exit(0);
}
double x;
double y;
double z;
while (!read_file.eof())
{
read_file >> x >> y >> z;
X.push_back(x);
Y.push_back(y);
Z.push_back(z);
}
read_file.close();
try {
if (X.size() <= 1 or Y.size() <=1 or Z.size()<=1)
{
throw Error("Number of nodes must be greater than 1.");
}
}
catch(Error err)
{
std::cerr << "ERROR : " << err.what() << std::endl;
exit(0);
}
}
Event Timeline
Log In to Comment