diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp index 74b7890155f159b26cdfb6e1a672b6418cc924e0..bc91283cc01b5827fb19e47079f7e607c585a6b4 100644 --- a/Fltk/GUI_Projection.cpp +++ b/Fltk/GUI_Projection.cpp @@ -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 diff --git a/contrib/FourierModel/FM_Reader.cpp b/contrib/FourierModel/FM_Reader.cpp index 84740443b36380caeb2608e6a11dc38999b48ab7..397ae813aafcaee48bc4d9214469dcf53c1abe3f 100644 --- a/contrib/FourierModel/FM_Reader.cpp +++ b/contrib/FourierModel/FM_Reader.cpp @@ -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) diff --git a/contrib/FourierModel/FM_Reader.h b/contrib/FourierModel/FM_Reader.h index f6d4fa33894e9ecd6fcaa5b962f416ca8db426b6..55bc6f8e2e606162edc9747755885daf30cfaf0d 100644 --- a/contrib/FourierModel/FM_Reader.h +++ b/contrib/FourierModel/FM_Reader.h @@ -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" diff --git a/contrib/FourierModel/FPatch.cpp b/contrib/FourierModel/FPatch.cpp index cc32c3704735a7a55d2710cca858bd42328787a1..8c897275d1bf16e69bc54e0833fe50eab7effcbc 100644 --- a/contrib/FourierModel/FPatch.cpp +++ b/contrib/FourierModel/FPatch.cpp @@ -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); diff --git a/contrib/FourierModel/ParaboloidProjectionSurface.cpp b/contrib/FourierModel/ParaboloidProjectionSurface.cpp index e4d551941231920f85618eb5697c0a0bddfcfa7a..5407cca67755f8275205a6b73aafcaeaf486e5ce 100755 --- a/contrib/FourierModel/ParaboloidProjectionSurface.cpp +++ b/contrib/FourierModel/ParaboloidProjectionSurface.cpp @@ -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; diff --git a/contrib/FourierModel/PlaneProjectionSurface.cpp b/contrib/FourierModel/PlaneProjectionSurface.cpp index 675967dab8df748576cf2f1cb4880dd31083137a..f50a6164234c91bff0e16cb1a2303aaa3499ad0b 100755 --- a/contrib/FourierModel/PlaneProjectionSurface.cpp +++ b/contrib/FourierModel/PlaneProjectionSurface.cpp @@ -1,10 +1,10 @@ #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")); diff --git a/contrib/FourierModel/ProjectionSurface.cpp b/contrib/FourierModel/ProjectionSurface.cpp index a5db40119488cbc3fb2521532b5c725727587b2a..ece8137e234731be9b85125223bc6bfb8007f5c5 100755 --- a/contrib/FourierModel/ProjectionSurface.cpp +++ b/contrib/FourierModel/ProjectionSurface.cpp @@ -4,6 +4,7 @@ ProjectionSurface::ProjectionSurface (double uPeriod, double vPeriod) { + printf("here in ProjectoionSufrace\n"); tag_ = -1; name_ = std::string("default"); numParameters_ = 0; diff --git a/contrib/FourierModel/RevolvedParabolaProjectionSurface.cpp b/contrib/FourierModel/RevolvedParabolaProjectionSurface.cpp index 33a988015091b4fa1c4dd88f6287e8992b3c4006..837d024aedb15a5bb48fd9d776811e431b63b469 100755 --- a/contrib/FourierModel/RevolvedParabolaProjectionSurface.cpp +++ b/contrib/FourierModel/RevolvedParabolaProjectionSurface.cpp @@ -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