Skip to content
Snippets Groups Projects
Commit 83dfa5df authored by Akash Anand's avatar Akash Anand
Browse files

for FM

parent cd973b19
Branches
Tags
No related merge requests found
......@@ -849,19 +849,27 @@ void compute_cb(Fl_Widget *w, void *data)
// IO Test Code
char *filename = "patches.fm";
FILE *fp = fopen(filename, "w");
FILE *fp = fopen(filename, "w+");
if(!fp){
printf("Unable to open file '%s'\n", filename);
return;
}
std::set<GFace*, GEntityLessThan>::iterator fiter;
int numFourierPatches = 0;
for (fiter = GMODEL->firstFace(); fiter != GMODEL->lastFace(); fiter++) {
if ((*fiter)->getNativeType() == GEntity::FourierModel) {
numFourierPatches++;
}
}
fprintf(fp, "%d\n", numFourierPatches);
for (fiter = GMODEL->firstFace(); fiter != GMODEL->lastFace(); fiter++) {
if ((*fiter)->getNativeType() == GEntity::FourierModel) {
FFace* ff = (FFace*) (*fiter);
ff->GetFMFace()->GetPatch()->Export(fp);
}
}
fclose(fp);
FM_Reader* reader = new FM_Reader(filename);
// End Test
......
......@@ -7,7 +7,9 @@ FM_Reader::FM_Reader(const char* fn)
{
char c;
char Exact[8] = "Exact";
char plane[16] = "plane";
char cylinder[16] = "cylinder";
char paraboloid[16] = "paraboloid";
char revolvedParabola[32] = "revolvedParabola";
std::ifstream InputFile(fn);
......@@ -15,57 +17,88 @@ FM_Reader::FM_Reader(const char* fn)
Msg::Info("Failed to open input file.");
exit(EXIT_FAILURE);
}
//InputFile >> _nPatches;
//for (unsigned int i = 0; i < _nPatches; i++) {
unsigned int i = 0;
while (!InputFile.eof()) {
InputFile >> _nPatches;
_ps.resize(_nPatches, 0);
std::cout << "npatches = " << _nPatches << std::endl;
for (unsigned int i = 0; i < _nPatches; i++) {
char psName[32];
InputFile >> psName;
std::cout << psName;
std::cout << "psName = " << psName << std::endl;
int psTag;
std::cout << psTag;
InputFile >> psTag;
std::cout << "psTag = " << psTag << std::endl;
double origin[3];
InputFile >> origin[0] >> origin[1] >> origin[2];
std::cout << "o = "<<origin[0]<<" "<<origin[1]<<" "<<origin[2]<<std::endl;
double E0[3];
InputFile >> E0[0] >> E0[1] >> E0[2];
std::cout << "E0 = " << E0[0] <<" "<< E0[1] <<" "<< E0[2] << std::endl;
double E1[3];
InputFile >> E1[0] >> E1[1] >> E1[2];
std::cout << "E1 = " << E1[0] <<" "<< E1[1] <<" "<< E1[2] << std::endl;
double scale[3];
InputFile >> scale[0] >> scale[1] >> scale[2];
std::cout << "s = " <<scale[0]<<" "<< scale[1]<<" "<<scale[2]<<std::endl;
int psNumParams;
InputFile >> psNumParams;
std::vector<double> psParams;
std::cout << "psNumParams = " << psNumParams << std::endl;
double *psParams = new double [psNumParams];
for (unsigned int j = 0; j < psNumParams; j++) {
double tmp;
InputFile >> tmp;
psParams.push_back(tmp);
InputFile >> psParams[j];
std::cout << "psParams[" << j << "] = " << psParams[j] << std::endl;
}
if (!strcmp(psName,plane))
_ps[i] = new PlaneProjectionSurface(psTag,origin,E0,E1,scale);
else if (!strcmp(psName,cylinder))
_ps[i] = new CylindricalProjectionSurface
(psTag,origin,E0,E1,scale,psParams[0],psParams[1]);
else if (!strcmp(psName,paraboloid)) {
double K[2];
K[0] = psParams[0]; K[1] = psParams[1];
_ps[i] = new ParaboloidProjectionSurface
(psTag,origin,E0,E1,scale,K);
}
if (!strcmp(psName,cylinder))
_ps.push_back
(new CylindricalProjectionSurface
(psTag,origin,E0,E1,scale,psParams[0],psParams[1]));
else if (!strcmp(psName,revolvedParabola)) {
double R = psParams[0];
double K[2];
K[0] = psParams[1]; K[1] = psParams[2];
_ps.push_back(new RevolvedParabolaProjectionSurface
(i,origin,E0,E1,scale,psParams[0],K));
printf("%d :: P : %g %g %g\n",i,R,K[0],K[1]);
printf("%d :: O : %g %g %g\n",i,origin[0],origin[1],origin[2]);
printf("%d :: E0 : %g %g %g\n",i,E0[0],E0[1],E0[2]);
printf("%d :: E1 : %g %g %g\n",i,E1[0],E1[1],E1[2]);
printf("%d :: s : %g %g %g\n",i,scale[0],scale[1],scale[2]);
_ps[i] = new RevolvedParabolaProjectionSurface
(psTag,origin,E0,E1,scale,R,K);
printf("%d : here :: %g %g\n",i,K[0],K[1]);
}
else {
_ps.push_back
(new CylindricalProjectionSurface(i,origin,E0,E1,scale));
_ps[i] = new CylindricalProjectionSurface(psTag,origin,E0,E1,scale);
Msg::Error("Unknown projection surface. Replaced by Cylinder...");
}
delete [] psParams;
InputFile >> psName;
std::cout << "psName = " << psName << std::endl;
_patchList.push_back(new PatchInfo);
InputFile >> _patchList[i]->tag;
InputFile >> _patchList[i]->tag;
std::cout << "pTag = " << _patchList[i]->tag << std::endl;
InputFile >> _patchList[i]->derivative;
std::cout << "pDerivative = " << _patchList[i]->derivative << std::endl;
InputFile >> _patchList[i]->uMin >> _patchList[i]->uMax;
std::cout <<"uLim = "<<_patchList[i]->uMin<<" "<<_patchList[i]->uMax <<
std::endl;
InputFile >> _patchList[i]->vMin >> _patchList[i]->vMax;
std::cout <<"vLim = "<<_patchList[i]->vMin<<" "<<_patchList[i]->vMax <<
std::endl;
if (strcmp(psName,Exact)) {
InputFile >> _patchList[i]->hardEdge[0] >> _patchList[i]->hardEdge[1] >>
_patchList[i]->hardEdge[2] >> _patchList[i]->hardEdge[3];
std::cout<<"HE : "<< _patchList[i]->hardEdge[0] << " " <<
_patchList[i]->hardEdge[1] << " " << _patchList[i]->hardEdge[2]
<< " " << _patchList[i]->hardEdge[3] << std::endl;
InputFile >> _patchList[i]->nModes[0] >> _patchList[i]->nModes[1];
std::cout <<"Modes = "<<_patchList[i]->nModes[0] << " " <<
_patchList[i]->nModes[1] << std::endl;
_patchList[i]->coeffFourier.resize(_patchList[i]->nModes[0]);
for (int j=0;j<_patchList[i]->nModes[0];j++) {
_patchList[i]->coeffFourier[j].resize(_patchList[i]->nModes[1]);
......@@ -74,10 +107,14 @@ FM_Reader::FM_Reader(const char* fn)
InputFile >> realCoeff >> imagCoeff;
_patchList[i]->coeffFourier[j][k] =
std::complex<double>(realCoeff,imagCoeff);
std::cout << realCoeff << " " << imagCoeff << std::endl;
}
}
InputFile >> _patchList[i]->nM[0] >> _patchList[i]->nM[1];
std::cout <<"M = "<<_patchList[i]->nM[0] << " " <<
_patchList[i]->nM[1] << std::endl;
InputFile >> _patchList[i]->recompute;
std::cout << "pRecompute = " << _patchList[i]->recompute << std::endl;
if ((_patchList[i]->derivative) && (!_patchList[i]->recompute)) {
_patchList[i]->coeffCheby.resize(_patchList[i]->nM[0]);
for (int j=0;j<_patchList[i]->nM[0];j++) {
......@@ -87,6 +124,7 @@ FM_Reader::FM_Reader(const char* fn)
InputFile >> realCoeff >> imagCoeff;
_patchList[i]->coeffCheby[j][k] =
std::complex<double>(realCoeff,imagCoeff);
std::cout << realCoeff << " " << imagCoeff << std::endl;
}
}
_patchList[i]->coeffDerivU.resize(_patchList[i]->nM[0]);
......@@ -97,6 +135,7 @@ FM_Reader::FM_Reader(const char* fn)
InputFile >> realCoeff >> imagCoeff;
_patchList[i]->coeffDerivU[j][k] =
std::complex<double>(realCoeff,imagCoeff);
std::cout << realCoeff << " " << imagCoeff << std::endl;
}
}
_patchList[i]->coeffDerivV.resize(_patchList[i]->nM[0]);
......@@ -107,6 +146,7 @@ FM_Reader::FM_Reader(const char* fn)
InputFile >> realCoeff >> imagCoeff;
_patchList[i]->coeffDerivV[j][k] =
std::complex<double>(realCoeff,imagCoeff);
std::cout << realCoeff << " " << imagCoeff << std::endl;
}
}
_patchList[i]->coeffDerivUU.resize(_patchList[i]->nM[0]);
......@@ -117,6 +157,7 @@ FM_Reader::FM_Reader(const char* fn)
InputFile >> realCoeff >> imagCoeff;
_patchList[i]->coeffDerivUU[j][k] =
std::complex<double>(realCoeff,imagCoeff);
std::cout << realCoeff << " " << imagCoeff << std::endl;
}
}
_patchList[i]->coeffDerivUV.resize(_patchList[i]->nM[0]);
......@@ -127,6 +168,7 @@ FM_Reader::FM_Reader(const char* fn)
InputFile >> realCoeff >> imagCoeff;
_patchList[i]->coeffDerivUV[j][k] =
std::complex<double>(realCoeff,imagCoeff);
std::cout << realCoeff << " " << imagCoeff << std::endl;
}
}
_patchList[i]->coeffDerivVV.resize(_patchList[i]->nM[0]);
......@@ -137,14 +179,13 @@ FM_Reader::FM_Reader(const char* fn)
InputFile >> realCoeff >> imagCoeff;
_patchList[i]->coeffDerivVV[j][k] =
std::complex<double>(realCoeff,imagCoeff);
std::cout << realCoeff << " " << imagCoeff << std::endl;
}
}
}
}
_patch.push_back(new ContinuationPatch(_patchList[i], _ps[i]));
i++;
}
_nPatches = _patch.size();
}
Patch* FM_Reader::GetPatch(int tag)
......
......@@ -8,7 +8,9 @@
#include "IntersectionCurve.h"
#include "ExactPatch.h"
#include "ContinuationPatch.h"
#include "PlaneProjectionSurface.h"
#include "CylindricalProjectionSurface.h"
#include "ParaboloidProjectionSurface.h"
#include "RevolvedParabolaProjectionSurface.h"
#include "FM_Info.h"
#include "FM_Face.h"
......
......@@ -860,7 +860,6 @@ void FPatch::Export(FILE *fp)
{
double x,y,z;
fprintf(fp, "\n");
fprintf(fp, "%s\n", _ps->GetName().c_str());
fprintf(fp, "%d\n", _ps->GetTag());
_ps->GetOrigin(x,y,z);
......
......@@ -4,7 +4,7 @@ ParaboloidProjectionSurface::ParaboloidProjectionSurface
(int tag) : ProjectionSurface(1.)
{
SetTag(tag);
SetName(std::string("Paraboloid"));
SetName(std::string("paraboloid"));
twoPi_ = 2 * M_PI;
K_[0] = K_[1] = 0.5;
......
#include "PlaneProjectionSurface.h"
PlaneProjectionSurface::PlaneProjectionSurface
(int tag) : ProjectionSurface(1.)
(int tag) : ProjectionSurface()
{
SetTag(tag);
SetName(std::string("Plane"));
SetName(std::string("plane"));
numParameters_ = 0;
......@@ -19,7 +19,7 @@ PlaneProjectionSurface::PlaneProjectionSurface
PlaneProjectionSurface::PlaneProjectionSurface
(int tag, double O[3], double E0[3], double E1[3], double scale[3])
: ProjectionSurface(1.)
: ProjectionSurface()
{
SetTag(tag);
SetName(std::string("Plane"));
......
......@@ -4,6 +4,7 @@
ProjectionSurface::ProjectionSurface
(double uPeriod, double vPeriod)
{
printf("here in ProjectoionSufrace\n");
tag_ = -1;
name_ = std::string("default");
numParameters_ = 0;
......
......@@ -26,6 +26,8 @@ RevolvedParabolaProjectionSurface::RevolvedParabolaProjectionSurface
(int tag, double O[3], double E0[3], double E1[3], double scale[3],
double R, double K[2]) : ProjectionSurface(1.)
{
printf("here\n");
SetTag(tag);
SetName(std::string("revolvedParabola"));
......@@ -44,6 +46,12 @@ RevolvedParabolaProjectionSurface::RevolvedParabolaProjectionSurface
E2_[2] = E0_[0] * E1_[1] - E0_[1] * E1_[0];
scale_[0] = scale[0]; scale_[1] = scale[1]; scale_[2] = scale[2];
printf("P : %g %g %g\n",R_,K_[0],K_[1]);
printf("O : %g %g %g\n",O_[0],O_[1],O_[2]);
printf("E0 : %g %g %g\n",E0_[0],E0_[1],E0_[2]);
printf("E1 : %g %g %g\n",E1_[0],E1_[1],E1_[2]);
printf("s : %g %g %g\n",scale_[0],scale_[1],scale_[2]);
}
void RevolvedParabolaProjectionSurface::F
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment