Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F69425517
surface_generator_crenel.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
Mon, Jul 1, 18:08
Size
1 KB
Mime Type
text/x-c
Expires
Wed, Jul 3, 18:08 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
18707017
Attached To
rTAMAAS tamaas
surface_generator_crenel.cpp
View Options
/* -------------------------------------------------------------------------- */
#include "surface_generator_crenel.hh"
#include <math.h>
#include <iostream>
#include <fstream>
/* -------------------------------------------------------------------------- */
using namespace std;
/* -------------------------------------------------------------------------- */
SurfaceGeneratorCrenel::SurfaceGeneratorCrenel(const string & inputfile):
SurfaceGenerator(inputfile){
}
/* -------------------------------------------------------------------------- */
void SurfaceGeneratorCrenel::Init(){
SurfaceGenerator::Init();
}
/* -------------------------------------------------------------------------- */
void SurfaceGeneratorCrenel::parseInputFile(ifstream & fp){
int gridsize;
string line;
while (! fp.eof() )
{
getline (fp,line);
size_t pos = line.find("#"); //remove the comment
line = line.substr(0, pos);
trim(line); // remove unnecessary spaces
/* Read all options one by one */
readInput(line, "gridsize" , gridsize);
readInput(line, "c" , c);
readInput(line, "div_crenel", div_crenel);
}
return;
}
/* -------------------------------------------------------------------------- */
Surface<Real> & SurfaceGeneratorCrenel::buildSurface(){
UInt n = surface->size();
for (UInt i = 0 ; i < n ; ++i)
for (UInt j = 0 ; j < n ; ++j){
int sub_n = n/div_crenel;
int sub_i = i%sub_n;
int sub_j = j%sub_n;
int sub_c = c/div_crenel;
if (fabs(sub_i-sub_n/2) < sub_c/2 &&
fabs(sub_j-sub_n/2) < sub_c/2){
surface->at(i,j) = 1.;
}
else surface->at(i,j) = 0.;
}
return *surface;
}
Event Timeline
Log In to Comment