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

changes for FM

parent 71d31a42
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ extern Context_T CTX; ...@@ -17,6 +17,7 @@ extern Context_T CTX;
#include "FM_BlendedPatch.h" #include "FM_BlendedPatch.h"
#include "FM_BlendOperator.h" #include "FM_BlendOperator.h"
#include "FM_PlaneProjectionSurface.h" #include "FM_PlaneProjectionSurface.h"
#include "FM_TrapezoidProjectionSurface.h"
#include "FM_SphericalProjectionSurface.h" #include "FM_SphericalProjectionSurface.h"
#include "FM_ParaboloidProjectionSurface.h" #include "FM_ParaboloidProjectionSurface.h"
#include "FM_CylindricalProjectionSurface.h" #include "FM_CylindricalProjectionSurface.h"
...@@ -30,6 +31,8 @@ static fourierProjectionFace *createProjectionFaceFromName(const char *name) ...@@ -30,6 +31,8 @@ static fourierProjectionFace *createProjectionFaceFromName(const char *name)
fourierProjectionFace *f = 0; fourierProjectionFace *f = 0;
if(!strcmp(name, "plane")) if(!strcmp(name, "plane"))
f = new fourierProjectionFace(m, tag, new FM::PlaneProjectionSurface(tag)); f = new fourierProjectionFace(m, tag, new FM::PlaneProjectionSurface(tag));
else if(!strcmp(name, "trapezoid"))
f = new fourierProjectionFace(m, tag, new FM::TrapezoidProjectionSurface(tag));
else if(!strcmp(name, "sphere")) else if(!strcmp(name, "sphere"))
f = new fourierProjectionFace(m, tag, new FM::SphericalProjectionSurface(tag)); f = new fourierProjectionFace(m, tag, new FM::SphericalProjectionSurface(tag));
else if(!strcmp(name, "paraboloid")) else if(!strcmp(name, "paraboloid"))
...@@ -226,6 +229,13 @@ projection::projection(fourierProjectionFace *f, int x, int y, int w, int h, ...@@ -226,6 +229,13 @@ projection::projection(fourierProjectionFace *f, int x, int y, int w, int h,
projectionEditor::projectionEditor() projectionEditor::projectionEditor()
{ {
GModel *m = GModel::current();
// construct FM_Internals
m->readFourier();
printf("readerSize = %d\n",m->getFMInternals()->getSize());
printf("currentSize = %d\n",m->getFMInternals()->current()->GetNumGroups());
// construct GUI in terms of standard sizes // construct GUI in terms of standard sizes
const int BH = 2 * GetFontSize() + 1, BB = 7 * GetFontSize(), WB = 7; const int BH = 2 * GetFontSize() + 1, BB = 7 * GetFontSize(), WB = 7;
const int width = (int)(3.75 * BB), height = 25 * BH; const int width = (int)(3.75 * BB), height = 25 * BH;
...@@ -238,7 +248,7 @@ projectionEditor::projectionEditor() ...@@ -238,7 +248,7 @@ projectionEditor::projectionEditor()
Fl_Group *o = new Fl_Group(WB, WB, 2 * BB, 3 * BH); Fl_Group *o = new Fl_Group(WB, WB, 2 * BB, 3 * BH);
_select[0] = new Fl_Round_Button(2 * WB + BB / 2, WB, BB, BH, "Points"); _select[0] = new Fl_Round_Button(2 * WB + BB / 2, WB, BB, BH, "Points");
_select[1] = new Fl_Round_Button(2 * WB + BB / 2, WB + BH, BB, BH, "Elements"); _select[1] = new Fl_Round_Button(2 * WB + BB / 2, WB + BH, BB, BH, "Elements");
if(GModel::current()->getNumMeshElements()) if(m->getNumMeshElements())
_select[1]->value(1); _select[1]->value(1);
else else
_select[0]->value(1); _select[0]->value(1);
...@@ -389,6 +399,8 @@ projectionEditor::projectionEditor() ...@@ -389,6 +399,8 @@ projectionEditor::projectionEditor()
_window->hotspot(_window); _window->hotspot(_window);
_window->resizable(_uvPlot); _window->resizable(_uvPlot);
_window->size_range(width, (int)(0.85 * height)); _window->size_range(width, (int)(0.85 * height));
// create
} }
void projectionEditor::load(fourierProjectionFace *face, std::string tag) void projectionEditor::load(fourierProjectionFace *face, std::string tag)
...@@ -901,6 +913,10 @@ void save_projection_cb(Fl_Widget *w, void *data) ...@@ -901,6 +913,10 @@ void save_projection_cb(Fl_Widget *w, void *data)
void compute_cb(Fl_Widget *w, void *data) void compute_cb(Fl_Widget *w, void *data)
{ {
GModel* m = GModel::current();
printf("ngroups = %d\n",m->getFMInternals()->current()->GetNumGroups());
projectionEditor *e = (projectionEditor*)data; projectionEditor *e = (projectionEditor*)data;
projection *p = e->getCurrentProjection(); projection *p = e->getCurrentProjection();
...@@ -931,7 +947,10 @@ void compute_cb(Fl_Widget *w, void *data) ...@@ -931,7 +947,10 @@ void compute_cb(Fl_Widget *w, void *data)
// create the US-FFT/Windowing faces (with boundaries) // create the US-FFT/Windowing faces (with boundaries)
FM::Patch* patch = FM::Patch* patch =
new FM::WFPatch(0, ps->clone(), u, v, f, 3, uModes, vModes); new FM::WFPatch(0, ps->clone(), u, v, f, 3, uModes, vModes);
makeGFace(GModel::current(), patch); m->getFMInternals()->current()->GetGroup(0)->GetBlendGroup()->
AddPatch(patch);
m->getFMInternals()->makeGFace(patch,m);
//makeGFace(patch);
} }
else { else {
// create the Fourier faces (with boundaries) // create the Fourier faces (with boundaries)
...@@ -941,13 +960,19 @@ void compute_cb(Fl_Widget *w, void *data) ...@@ -941,13 +960,19 @@ void compute_cb(Fl_Widget *w, void *data)
uM, vM, h0, h1, h2, h3); uM, vM, h0, h1, h2, h3);
patchL->SetMinU(-0.35); patchL->SetMinU(-0.35);
patchL->SetMaxU(0.35); patchL->SetMaxU(0.35);
makeGFace(GModel::current(), patchL); m->getFMInternals()->current()->GetGroup(0)->GetBlendGroup()->
AddPatch(patchL);
m->getFMInternals()->makeGFace(patchL,m);
//makeGFace(patchL);
FM::Patch* patchR = FM::Patch* patchR =
new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes,
uM, vM, h0, h1, h2, h3); uM, vM, h0, h1, h2, h3);
patchR->SetMinU(0.15); patchR->SetMinU(0.15);
patchR->SetMaxU(0.85); patchR->SetMaxU(0.85);
makeGFace(GModel::current(), patchR); m->getFMInternals()->current()->GetGroup(0)->GetBlendGroup()->
AddPatch(patchR);
m->getFMInternals()->makeGFace(patchR,m);
//makeGFace(patchR);
} }
else if (ps->IsVPeriodic()) { else if (ps->IsVPeriodic()) {
FM::Patch* patchL = FM::Patch* patchL =
...@@ -955,23 +980,33 @@ void compute_cb(Fl_Widget *w, void *data) ...@@ -955,23 +980,33 @@ void compute_cb(Fl_Widget *w, void *data)
uM, vM, h0, h1, h2, h3); uM, vM, h0, h1, h2, h3);
patchL->SetMinV(-0.35); patchL->SetMinV(-0.35);
patchL->SetMaxV(0.35); patchL->SetMaxV(0.35);
makeGFace(GModel::current(), patchL); m->getFMInternals()->current()->GetGroup(0)->GetBlendGroup()->
AddPatch(patchL);
m->getFMInternals()->makeGFace(patchL,m);
//makeGFace(patchL);
FM::Patch* patchR = FM::Patch* patchR =
new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes,
uM, vM, h0, h1, h2, h3); uM, vM, h0, h1, h2, h3);
patchR->SetMinV(0.15); patchR->SetMinV(0.15);
patchR->SetMaxV(0.85); patchR->SetMaxV(0.85);
makeGFace(GModel::current(), patchR); m->getFMInternals()->current()->GetGroup(0)->GetBlendGroup()->
AddPatch(patchR);
m->getFMInternals()->makeGFace(patchR,m);
//makeGFace(patchR);
} }
else { else {
FM::Patch* patch = FM::Patch* patch =
new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes, new FM::FPatch(0, ps->clone(), u, v, f, 3, uModes, vModes,
uM, vM, h0, h1, h2, h3); uM, vM, h0, h1, h2, h3);
makeGFace(GModel::current(), patch); m->getFMInternals()->current()->GetGroup(0)->GetBlendGroup()->
AddPatch(patch);
m->getFMInternals()->makeGFace(patch,m);
//makeGFace(patch);
} }
} }
} }
printf("nPatches = %d\n",m->getFMInternals()->current()->GetGroup(0)->
GetBlendGroup()->GetNumPatches());
Draw(); Draw();
} }
...@@ -995,27 +1030,22 @@ void delete_fourier(GFace *gf) ...@@ -995,27 +1030,22 @@ void delete_fourier(GFace *gf)
void blend_cb(Fl_Widget *w, void *data) void blend_cb(Fl_Widget *w, void *data)
{ {
std::vector<GFace*> faces;
std::vector<FM::Patch*> patches;
GModel *m = GModel::current(); GModel *m = GModel::current();
std::vector<GFace*> faces;
for (GModel::fiter it = m->firstFace(); it != m->lastFace(); it++) for (GModel::fiter it = m->firstFace(); it != m->lastFace(); it++)
if ((*it)->getNativeType() == GEntity::FourierModel) if ((*it)->getNativeType() == GEntity::FourierModel)
faces.push_back(*it); faces.push_back(*it);
for(unsigned int i = 0; i < faces.size(); i++){
fourierFace* ff = (fourierFace*)faces[i]; m->getFMInternals()->current()->GetGroup(0)->GetBlendGroup()->Blend();
FM::TopoFace* tf = (FM::TopoFace*)ff->getNativePtr(); for (int i = 0; i < m->getFMInternals()->current()->GetGroup(0)->
patches.push_back(tf->GetPatch()); GetBlendGroup()->GetNumPatches(); i++)
} m->getFMInternals()->makeGFace(m->getFMInternals()->current()->
FM::BlendOperator* blendOp = new FM::BlendOperator(patches); GetGroup(0)->GetBlendGroup()->
for (unsigned int i = 0; i < patches.size(); i++) { GetPatch(i),m);
FM::BlendedPatch* patch = new FM::BlendedPatch(i, blendOp); for (int i = 0; i < faces.size(); i++) {
makeGFace(GModel::current(), patch); //delete_fourier(faces[i]);
} faces[i]->setVisibility(0, true);
for(unsigned int i = 0; i < faces.size(); i++) {
delete_fourier(faces[i]);
//faces[i]->setVisibility(0, true);
} }
} }
...@@ -1083,6 +1113,7 @@ void mesh_parameterize_cb(Fl_Widget* w, void* data) ...@@ -1083,6 +1113,7 @@ void mesh_parameterize_cb(Fl_Widget* w, void* data)
if(!editor){ if(!editor){
editor = new projectionEditor(); editor = new projectionEditor();
editor->load(createProjectionFaceFromName("plane")); editor->load(createProjectionFaceFromName("plane"));
editor->load(createProjectionFaceFromName("trapezoid"));
editor->load(createProjectionFaceFromName("sphere")); editor->load(createProjectionFaceFromName("sphere"));
editor->load(createProjectionFaceFromName("paraboloid")); editor->load(createProjectionFaceFromName("paraboloid"));
editor->load(createProjectionFaceFromName("cylinder")); editor->load(createProjectionFaceFromName("cylinder"));
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "GRegion.h" #include "GRegion.h"
#include "SBoundingBox3d.h" #include "SBoundingBox3d.h"
class FM_Internals;
class GEO_Internals; class GEO_Internals;
class OCC_Internals; class OCC_Internals;
class smooth_normals; class smooth_normals;
...@@ -68,6 +69,10 @@ class GModel ...@@ -68,6 +69,10 @@ class GModel
// index of the current model // index of the current model
static int _current; static int _current;
FM_Internals *_fm_internals;
void createFMInternals();
void deleteFMInternals();
protected: protected:
std::string modelName; std::string modelName;
std::set<GRegion*, GEntityLessThan> regions; std::set<GRegion*, GEntityLessThan> regions;
...@@ -95,6 +100,7 @@ class GModel ...@@ -95,6 +100,7 @@ class GModel
void destroy(); void destroy();
// Access internal CAD representations // Access internal CAD representations
FM_Internals *getFMInternals() { return _fm_internals; }
GEO_Internals *getGEOInternals(){ return _geo_internals; } GEO_Internals *getGEOInternals(){ return _geo_internals; }
OCC_Internals *getOCCInternals(){ return _occ_internals; } OCC_Internals *getOCCInternals(){ return _occ_internals; }
...@@ -224,7 +230,9 @@ class GModel ...@@ -224,7 +230,9 @@ class GModel
int writeGEO(const std::string &name, bool printLabels=true); int writeGEO(const std::string &name, bool printLabels=true);
// Fourier model // Fourier model
int readFourier();
int readFourier(const std::string &name); int readFourier(const std::string &name);
int writeFourier(const std::string &name);
// OCC model // OCC model
int readOCCBREP(const std::string &name); int readOCCBREP(const std::string &name);
......
...@@ -9,13 +9,12 @@ ...@@ -9,13 +9,12 @@
#if defined(HAVE_FOURIER_MODEL) #if defined(HAVE_FOURIER_MODEL)
#include "FM_FPatch.h" #include "FM_FPatch.h"
#include "FM_FCurve.h" #include "FM_PCurve.h"
#include "FM_TopoVertex.h" #include "FM_TopoVertex.h"
#include "FM_TopoEdge.h" #include "FM_TopoEdge.h"
#include "FM_TopoFace.h" #include "FM_TopoFace.h"
#include "FM_Reader.h"
void makeGFace(GModel *m, FM::Patch* patch) void FM_Internals::makeGFace(FM::Patch* patch, GModel* model)
{ {
double LL[2], LR[2], UL[2], UR[2]; double LL[2], LR[2], UL[2], UR[2];
LL[0] = 0.0; LL[1] = 0.0; LL[0] = 0.0; LL[1] = 0.0;
...@@ -26,66 +25,106 @@ void makeGFace(GModel *m, FM::Patch* patch) ...@@ -26,66 +25,106 @@ void makeGFace(GModel *m, FM::Patch* patch)
int i1, i2; int i1, i2;
double xx,yy,zz; double xx,yy,zz;
int tagVertex = m->getNumVertices(); int tagVertex = model->getNumVertices();
patch->F(LL[0], LL[1], xx, yy, zz); patch->F(LL[0], LL[1], xx, yy, zz);
FM::TopoVertex* vLL = new FM::TopoVertex(++tagVertex, xx, yy, zz); FM::TopoVertex* vLL = new FM::TopoVertex(++tagVertex, xx, yy, zz);
m->add(new fourierVertex(m, vLL->GetTag(), vLL)); model->add(new fourierVertex(model, vLL->GetTag(), vLL));
patch->F(LR[0], LR[1], xx, yy, zz); patch->F(LR[0], LR[1], xx, yy, zz);
FM::TopoVertex* vLR = new FM::TopoVertex(++tagVertex, xx, yy, zz); FM::TopoVertex* vLR = new FM::TopoVertex(++tagVertex, xx, yy, zz);
m->add(new fourierVertex(m, vLR->GetTag(), vLR)); model->add(new fourierVertex(model, vLR->GetTag(), vLR));
patch->F(UL[0], UL[1], xx, yy, zz); patch->F(UL[0], UL[1], xx, yy, zz);
FM::TopoVertex* vUL = new FM::TopoVertex(++tagVertex, xx, yy, zz); FM::TopoVertex* vUL = new FM::TopoVertex(++tagVertex, xx, yy, zz);
m->add(new fourierVertex(m, vUL->GetTag(), vUL)); model->add(new fourierVertex(model, vUL->GetTag(), vUL));
patch->F(UR[0], UR[1], xx, yy, zz); patch->F(UR[0], UR[1], xx, yy, zz);
FM::TopoVertex* vUR = new FM::TopoVertex(++tagVertex, xx, yy, zz); FM::TopoVertex* vUR = new FM::TopoVertex(++tagVertex, xx, yy, zz);
m->add(new fourierVertex(m, vUR->GetTag(), vUR)); model->add(new fourierVertex(model, vUR->GetTag(), vUR));
FM::Curve* curveB = new FM::FCurve(0, patch, LL, LR); FM::Curve* curveB = new FM::PCurve(LL, LR, patch);
FM::Curve* curveR = new FM::FCurve(0, patch, LR, UR); FM::Curve* curveR = new FM::PCurve(LR, UR, patch);
FM::Curve* curveT = new FM::FCurve(0, patch, UR, UL); FM::Curve* curveT = new FM::PCurve(UR, UL, patch);
FM::Curve* curveL = new FM::FCurve(0, patch, UL, LL); FM::Curve* curveL = new FM::PCurve(UL, LL, patch);
int tagEdge = m->getNumEdges(); int tagEdge = model->getNumEdges();
FM::TopoEdge* eB = new FM::TopoEdge(++tagEdge, curveB, vLL, vLR); FM::TopoEdge* eB = new FM::TopoEdge(++tagEdge, curveB, vLL, vLR);
i1 = eB->GetStartPoint()->GetTag(); i1 = eB->GetStartPoint()->GetTag();
i2 = eB->GetEndPoint()->GetTag(); i2 = eB->GetEndPoint()->GetTag();
m->add(new fourierEdge(m, eB, eB->GetTag(), m->getVertexByTag(i1), model->add(new fourierEdge(model, eB, eB->GetTag(), model->getVertexByTag(i1),
m->getVertexByTag(i2))); model->getVertexByTag(i2)));
FM::TopoEdge* eR = new FM::TopoEdge(++tagEdge, curveR, vLR, vUR); FM::TopoEdge* eR = new FM::TopoEdge(++tagEdge, curveR, vLR, vUR);
i1 = eR->GetStartPoint()->GetTag(); i1 = eR->GetStartPoint()->GetTag();
i2 = eR->GetEndPoint()->GetTag(); i2 = eR->GetEndPoint()->GetTag();
m->add(new fourierEdge(m, eR, eR->GetTag(), m->getVertexByTag(i1), model->add(new fourierEdge(model, eR, eR->GetTag(), model->getVertexByTag(i1),
m->getVertexByTag(i2))); model->getVertexByTag(i2)));
FM::TopoEdge* eT = new FM::TopoEdge(++tagEdge, curveT, vUR, vUL); FM::TopoEdge* eT = new FM::TopoEdge(++tagEdge, curveT, vUR, vUL);
i1 = eT->GetStartPoint()->GetTag(); i1 = eT->GetStartPoint()->GetTag();
i2 = eT->GetEndPoint()->GetTag(); i2 = eT->GetEndPoint()->GetTag();
m->add(new fourierEdge(m, eT, eT->GetTag(), m->getVertexByTag(i1), model->add(new fourierEdge(model, eT, eT->GetTag(), model->getVertexByTag(i1),
m->getVertexByTag(i2))); model->getVertexByTag(i2)));
FM::TopoEdge* eL = new FM::TopoEdge(++tagEdge, curveL, vUL, vLL); FM::TopoEdge* eL = new FM::TopoEdge(++tagEdge, curveL, vUL, vLL);
i1 = eL->GetStartPoint()->GetTag(); i1 = eL->GetStartPoint()->GetTag();
i2 = eL->GetEndPoint()->GetTag(); i2 = eL->GetEndPoint()->GetTag();
m->add(new fourierEdge(m, eL, eL->GetTag(), m->getVertexByTag(i1), model->add(new fourierEdge(model, eL, eL->GetTag(), model->getVertexByTag(i1),
m->getVertexByTag(i2))); model->getVertexByTag(i2)));
FM::TopoFace* face = new FM::TopoFace(m->getNumFaces() + 1, patch); FM::TopoFace* face = new FM::TopoFace(model->getNumFaces() + 1, patch);
face->AddEdge(eB); face->AddEdge(eR); face->AddEdge(eB); face->AddEdge(eR);
face->AddEdge(eT); face->AddEdge(eL); face->AddEdge(eT); face->AddEdge(eL);
std::list<GEdge*> l_edges; std::list<GEdge*> l_edges;
for (int j = 0; j < face->GetNumEdges(); j++) { for (int j = 0; j < face->GetNumEdges(); j++) {
int tag = face->GetEdge(j)->GetTag(); int tag = face->GetEdge(j)->GetTag();
l_edges.push_back(m->getEdgeByTag(tag)); l_edges.push_back(model->getEdgeByTag(tag));
} }
m->add(new fourierFace(m, face, face->GetTag(), l_edges)); model->add(new fourierFace(model, face, face->GetTag(), l_edges));
} }
int GModel::readFourier(const std::string &filename) void FM_Internals::loadFM()
{
reader.push_back(new FM::Reader());
}
void FM_Internals::loadFM(const char* filename)
{
reader.push_back(new FM::Reader(filename));
}
void FM_Internals::buildGModel(FM::Reader* reader, GModel* model)
{ {
FM::Reader *reader = new FM::Reader(filename.c_str());
for (int i = 0; i < reader->GetNumPatches(); i++) for (int i = 0; i < reader->GetNumPatches(); i++)
makeGFace(this, reader->GetPatch(i)); makeGFace(reader->GetPatch(i), model);
}
void GModel::createFMInternals()
{
if (!_fm_internals)
_fm_internals = new FM_Internals;
}
void GModel::deleteFMInternals()
{
delete _fm_internals;
_fm_internals = 0;
}
int GModel::readFourier()
{
createFMInternals();
getFMInternals()->loadFM();
}
int GModel::readFourier(const std::string &filename)
{
createFMInternals();
getFMInternals()->loadFM(filename.c_str());
getFMInternals()->buildGModel(getFMInternals()->current(),this);
return 1; return 1;
} }
int GModel::writeFourier(const std::string &filename)
{
FILE *fp = fopen(filename.c_str(), "w");
}
#else #else
int GModel::readFourier(const std::string &fn) int GModel::readFourier(const std::string &fn)
...@@ -95,4 +134,11 @@ int GModel::readFourier(const std::string &fn) ...@@ -95,4 +134,11 @@ int GModel::readFourier(const std::string &fn)
return 0; return 0;
} }
int GModel::writeFourier(const std::string &fn)
{
Msg(GERROR, "Gmsh has to be compiled with Fourier Model support to load '%s'",
fn.c_str());
return 0;
}
#endif #endif
#ifndef _GMODEL_IO_FOURIER_H_ #ifndef _GMODEL_IO_FOURIER_H_
#define _GMODEL_IO_FOURIER_H_ #define _GMODEL_IO_FOURIER_H_
#include <vector>
#include "GModel.h" #include "GModel.h"
#if defined(HAVE_FOURIER_MODEL) #if defined(HAVE_FOURIER_MODEL)
#include "FM_Patch.h" #include "FM_Reader.h"
void makeGFace(GModel *m, FM::Patch* patch); class FM_Internals {
private:
std::vector<FM::Reader*> reader;
public:
FM_Internals() {}
~FM_Internals() {}
void loadFM();
void loadFM(const char* filename);
void makeGFace(FM::Patch* patch, GModel* model);
void buildGModel(FM::Reader* reater, GModel* model);
FM::Reader* getReader(int tag)
{
if (tag < reader.size())
return reader[tag];
}
int getSize() { return reader.size(); }
FM::Reader* current() { return reader[reader.size() - 1]; }
};
#endif #endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment