Skip to content
Snippets Groups Projects
Commit d65fdbf1 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

clenup projectionFace a bit
parent a73c3fa5
No related branches found
No related tags found
No related merge requests found
...@@ -3,24 +3,23 @@ ...@@ -3,24 +3,23 @@
#include "GModel.h" #include "GModel.h"
#include "projectionFace.h" #include "projectionFace.h"
#include "Draw.h" #include "Draw.h"
#include "Options.h"
#include "Context.h" #include "Context.h"
#include "Shortcut_Window.h" #include "Shortcut_Window.h"
#include <FL/Fl_Button.H> #include <FL/Fl_Button.H>
#include <FL/Fl_Return_Button.H> #include <FL/Fl_Return_Button.H>
#include <FL/Fl_Value_Slider.H> #include <FL/Fl_Value_Input.H>
extern GModel *GMODEL; extern GModel *GMODEL;
extern Context_T CTX; extern Context_T CTX;
int projection_editor(char *title, projectionFace *p) int projection_editor(char *title, projectionFace *p)
{ {
struct _editor{ struct _editor{
Fl_Window *window; Fl_Window *window;
Fl_Value_Slider *sa, *sb, *sc, *ra, *rb, *rc, *ta, *tb, *tc; Fl_Value_Input *scale[3], *rotation[3], *translation[3];
Fl_Button *cancel; Fl_Button *cancel, *print;
}; };
static _editor *editor = 0; static _editor *editor = 0;
...@@ -34,83 +33,60 @@ int projection_editor(char *title, projectionFace *p) ...@@ -34,83 +33,60 @@ int projection_editor(char *title, projectionFace *p)
editor = new _editor; editor = new _editor;
editor->window = new Dialog_Window(2 * BB + 3 * WB, 10 * BH + 3 * WB); editor->window = new Dialog_Window(2 * BB + 3 * WB, 10 * BH + 3 * WB);
editor->sa = new Fl_Value_Slider(WB, WB, BB, BH, "Scale Factor X"); editor->scale[0] = new Fl_Value_Input(WB, WB, BB, BH, "Scale Factor X");
editor->sa->type(FL_HOR_SLIDER); editor->scale[1] = new Fl_Value_Input(WB, WB + BH, BB, BH, "Scale Factor Y");
editor->sa->align(FL_ALIGN_RIGHT); editor->scale[2] = new Fl_Value_Input(WB, WB + 2 * BH, BB, BH, "Scale Factor Z");
editor->sa->maximum( bounds.max()[0] + 1 ); for(int i = 0; i < 3; i++){
editor->sa->minimum(.1); editor->scale[i]->align(FL_ALIGN_RIGHT);
editor->sb = new Fl_Value_Slider(WB, WB + BH, BB, BH, "Scale Factor Y"); editor->scale[i]->maximum(CTX.lc * 10.);
editor->sb->type(FL_HOR_SLIDER); editor->scale[i]->minimum(CTX.lc / 100.);
editor->sb->align(FL_ALIGN_RIGHT); editor->scale[i]->step(CTX.lc / 100.);
editor->sb->maximum( bounds.max()[1] + 1 ); }
editor->sb->minimum(.1);
editor->sc = new Fl_Value_Slider(WB, WB + 2 * BH, BB, BH, "Scale Factor Z"); editor->rotation[0] = new Fl_Value_Input(WB, WB + 3*BH, BB, BH, "Rotation X");
editor->sc->type(FL_HOR_SLIDER); editor->rotation[1] = new Fl_Value_Input(WB, WB + 4*BH, BB, BH, "Rotation Y");
editor->sc->align(FL_ALIGN_RIGHT); editor->rotation[2] = new Fl_Value_Input(WB, WB + 5*BH, BB, BH, "Rotation Z");
editor->sc->maximum( bounds.max()[2] + 1 ); for(int i = 0; i < 3; i++){
editor->sc->minimum(.1); editor->rotation[i]->align(FL_ALIGN_RIGHT);
editor->rotation[i]->maximum(-180.);
editor->ra = new Fl_Value_Slider(WB, WB + 3*BH, BB, BH, "Rotation X"); editor->rotation[i]->minimum(180.);
editor->ra->type(FL_HOR_SLIDER); editor->rotation[i]->step(0.1);
editor->ra->align(FL_ALIGN_RIGHT); }
editor->ra->maximum(360);
editor->ra->minimum(0); editor->translation[0] = new Fl_Value_Input(WB, WB + 6*BH, BB, BH, "Translation X");
editor->translation[1] = new Fl_Value_Input(WB, WB + 7*BH, BB, BH, "Translation Y");
editor->rb = new Fl_Value_Slider(WB, WB + 4*BH, BB, BH, "Rotation Y"); editor->translation[2] = new Fl_Value_Input(WB, WB + 8*BH, BB, BH, "Translation Z");
editor->rb->type(FL_HOR_SLIDER); for(int i = 0; i < 3; i++){
editor->rb->align(FL_ALIGN_RIGHT); editor->translation[i]->align(FL_ALIGN_RIGHT);
editor->rb->maximum(360); editor->translation[i]->maximum(bounds.max()[i] + CTX.lc);
editor->rb->minimum(0); editor->translation[i]->minimum(bounds.min()[i] - CTX.lc);
editor->translation[i]->step(CTX.lc / 100.);
editor->rc = new Fl_Value_Slider(WB, WB + 5*BH, BB, BH, "Rotation Z"); }
editor->rc->type(FL_HOR_SLIDER);
editor->rc->align(FL_ALIGN_RIGHT);
editor->rc->maximum(360);
editor->rc->minimum(0);
editor->ta = new Fl_Value_Slider(WB, WB + 6*BH, BB, BH, "Translation X");
editor->ta->type(FL_HOR_SLIDER);
editor->ta->align(FL_ALIGN_RIGHT);
editor->ta->maximum( bounds.max()[0] + 2 );
editor->ta->minimum( bounds.min()[0] - 2 );
editor->tb = new Fl_Value_Slider(WB, WB + 7*BH, BB, BH, "Translation Y");
editor->tb->type(FL_HOR_SLIDER);
editor->tb->align(FL_ALIGN_RIGHT);
editor->tb->maximum( bounds.max()[1] + 2 );
editor->tb->minimum( bounds.min()[1] - 2 );
editor->tc = new Fl_Value_Slider(WB, WB + 8*BH, BB, BH, "Translation Z");
editor->tc->type(FL_HOR_SLIDER);
editor->tc->align(FL_ALIGN_RIGHT);
editor->tc->maximum( bounds.max()[2] + 2 );
editor->tc->minimum( bounds.min()[2] - 2 );
editor->print = new Fl_Button(WB , 2 * WB + 9 * BH, BB, BH, "Print");
editor->cancel = new Fl_Button(2 * WB + BB, 2 * WB + 9 * BH, BB, BH, "Cancel"); editor->cancel = new Fl_Button(2 * WB + BB, 2 * WB + 9 * BH, BB, BH, "Cancel");
editor->window->end(); editor->window->end();
editor->window->hotspot(editor->window); editor->window->hotspot(editor->window);
} }
editor->window->label(title); editor->window->label(title);
editor->sa->value( (bounds.max()[0] + bounds.min()[0])/2 ); for(int i = 0; i < 3; i++){
editor->sb->value( (bounds.max()[1] + bounds.min()[1])/2 ); editor->scale[i]->value(CTX.lc);
editor->sc->value( (bounds.max()[2] + bounds.min()[2])/2 ); editor->rotation[i]->value(0.);
editor->ra->value(0); editor->translation[i]->value(0.5 * (bounds.max()[i] + bounds.min()[i]));
editor->rb->value(0); }
editor->rc->value(0);
editor->ta->value( (bounds.max()[0] + bounds.min()[0])/2 );
editor->tb->value( (bounds.max()[1] + bounds.min()[1])/2 );
editor->tc->value( (bounds.max()[2] + bounds.min()[2])/2 );
SVector3 rescale(editor->sa->value(),editor->sb->value(),editor->sc->value());
p->setScale(rescale);
SVector3 rerot(editor->ra->value(),editor->rb->value(),editor->rc->value());
p->setRotation(rerot);
SVector3 retrans(editor->ta->value(),editor->tb->value(),editor->tc->value());
p->setTranslation(retrans);
Draw();
p->setScale(SVector3(editor->scale[0]->value(),
editor->scale[1]->value(),
editor->scale[2]->value()));
p->setRotation(SVector3(editor->rotation[0]->value(),
editor->rotation[1]->value(),
editor->rotation[2]->value()));
p->setTranslation(SVector3(editor->translation[0]->value(),
editor->translation[1]->value(),
editor->translation[2]->value()));
Draw();
editor->window->show(); editor->window->show();
...@@ -118,37 +94,28 @@ int projection_editor(char *title, projectionFace *p) ...@@ -118,37 +94,28 @@ int projection_editor(char *title, projectionFace *p)
Fl::wait(); Fl::wait();
for (;;) { for (;;) {
Fl_Widget* o = Fl::readqueue(); Fl_Widget* o = Fl::readqueue();
if (!o) break; if(!o) break;
if(o == editor->window || o == editor->cancel){
/* if (o == editor->sa) editor->window->hide();
SVector3 rescale(editor->sa->value(),0,0);
p->scale(rescale);
if (o == editor->sb)
SVector3 rescale(editor->sa->value(),0,0);
p->scale(rescale);
if (o == editor->sc)
SVector3 rescale(editor->sa->value(),0,0);
p->scale(rescale);
*/
if (o == editor->window || o == editor->cancel)
{
editor->window->hide();
return 0; return 0;
} }
else else if(o == editor->print){
{ for(int i = 0; i < 3; i++) printf("%g\n", editor->scale[i]->value());
SVector3 rescale(editor->sa->value(),editor->sb->value(),editor->sc->value()); for(int i = 0; i < 3; i++) printf("%g\n", editor->rotation[i]->value());
p->setScale(rescale); for(int i = 0; i < 3; i++) printf("%g\n", editor->translation[i]->value());
}
SVector3 rerot(editor->ra->value(),editor->rb->value(),editor->rc->value()); else{
p->setRotation(rerot); p->setScale(SVector3(editor->scale[0]->value(),
editor->scale[1]->value(),
SVector3 retrans(editor->ta->value(),editor->tb->value(),editor->tc->value()); editor->scale[2]->value()));
p->setTranslation(retrans); p->setRotation(SVector3(editor->rotation[0]->value(),
editor->rotation[1]->value(),
editor->rotation[2]->value()));
p->setTranslation(SVector3(editor->translation[0]->value(),
editor->translation[1]->value(),
editor->translation[2]->value()));
} }
Draw(); Draw();
} }
} }
return 0; return 0;
...@@ -156,19 +123,17 @@ int projection_editor(char *title, projectionFace *p) ...@@ -156,19 +123,17 @@ int projection_editor(char *title, projectionFace *p)
void mesh_parameterize_cb(Fl_Widget* w, void* data) void mesh_parameterize_cb(Fl_Widget* w, void* data)
{ {
projectionFace *p = new parabolicCylinder(GMODEL,10000); projectionFace *p = new parabolicCylinder(GMODEL, 10000);
GMODEL->add( p ); GMODEL->add(p);
CTX.mesh.changed = ENT_SURFACE; CTX.mesh.changed = ENT_SURFACE;
CTX.geom.surfaces = 1;
opt_geometry_surfaces(0, GMSH_SET | GMSH_GUI, 1);
Draw(); Draw();
projection_editor("Projection editor", p); projection_editor("Projection editor", p);
//SBoundingBox3d bb = GMODEL->bounds();
Msg(INFO, "Model added: %d faces", GMODEL->numFace()); Msg(INFO, "Model added: %d faces", GMODEL->numFace());
} }
...@@ -2,68 +2,71 @@ ...@@ -2,68 +2,71 @@
SVector3 scalePoint(SVector3 p, SVector3 s) SVector3 scalePoint(SVector3 p, SVector3 s)
{ {
double x = p[0]*s[0]; double x = p[0]*s[0];
double y = p[1]*s[1]; double y = p[1]*s[1];
double z = p[2]*s[2]; double z = p[2]*s[2];
SVector3 result(x,y,z); SVector3 result(x,y,z);
return result; return result;
} }
SVector3 rotatePoint(SVector3 p, SVector3 r) SVector3 rotatePoint(SVector3 p, SVector3 r)
{ {
double rot[16];
double rot[16]; double x = r[0] * Pi / 180.;
double x = r[0] * Pi / 180.; double y = r[1] * Pi / 180.;
double y = r[1] * Pi / 180.; double z = r[2] * Pi / 180.;
double z = r[2] * Pi / 180.; double A = cos(x);
double A = cos(x); double B = sin(x);
double B = sin(x); double C = cos(y);
double C = cos(y); double D = sin(y);
double D = sin(y); double E = cos(z);
double E = cos(z); double F = sin(z);
double F = sin(z); double AD = A * D;
double AD = A * D; double BD = B * D;
double BD = B * D; rot[0] = C*E; rot[1] = BD*E+A*F; rot[2] =-AD*E+B*F; rot[3] = 0.;
rot[0] = C*E; rot[1] = BD*E+A*F; rot[2] =-AD*E+B*F; rot[3] = 0.; rot[4] =-C*F; rot[5] =-BD*F+A*E; rot[6] = AD*F+B*E; rot[7] = 0.;
rot[4] =-C*F; rot[5] =-BD*F+A*E; rot[6] = AD*F+B*E; rot[7] = 0.; rot[8] = D; rot[9] =-B*C; rot[10] = A*C; rot[11] = 0.;
rot[8] = D; rot[9] =-B*C; rot[10] = A*C; rot[11] = 0.; rot[12] = 0.; rot[13] = 0.; rot[14] = 0.; rot[15] = 1.;
rot[12] = 0.; rot[13] = 0.; rot[14] = 0.; rot[15] = 1.;
x = p[0]*rot[0] + p[1]*rot[1] + p[2]*rot[2];
x = p[0]*rot[0] + p[1]*rot[1] + p[2]*rot[2]; y = p[0]*rot[4] + p[1]*rot[5] + p[2]*rot[6];
y = p[0]*rot[4] + p[1]*rot[5] + p[2]*rot[6]; z = p[0]*rot[8] + p[1]*rot[9] + p[2]*rot[10];
z = p[0]*rot[8] + p[1]*rot[9] + p[2]*rot[10];
SVector3 result(x,y,z);
SVector3 result(x,y,z); return result;
return result;
} }
void projectionFace::rotate(SVector3 rot) void projectionFace::rotate(SVector3 rot)
{ {
rotation = rot + rotation; rotation = rot + rotation;
} }
void projectionFace::translate(SVector3 trans) void projectionFace::translate(SVector3 trans)
{ {
translation = trans + translation; translation = trans + translation;
} }
void projectionFace::scale(SVector3 sc) void projectionFace::scale(SVector3 sc)
{ {
scaleFactor[0] *= sc[0]; scaleFactor[0] *= sc[0];
scaleFactor[1] *= sc[1]; scaleFactor[1] *= sc[1];
scaleFactor[2] *= sc[2]; scaleFactor[2] *= sc[2];
} }
void projectionFace::setScale(SVector3 sc) void projectionFace::setScale(SVector3 sc)
{ {
scaleFactor[0] = sc[0]; scaleFactor[0] = sc[0];
scaleFactor[1] = sc[1]; scaleFactor[1] = sc[1];
scaleFactor[2] = sc[2]; scaleFactor[2] = sc[2];
} }
void projectionFace::setRotation(SVector3 r) void projectionFace::setRotation(SVector3 r)
{ {
rotation[0] = r[0]; rotation[0] = r[0];
rotation[1] = r[1]; rotation[1] = r[1];
rotation[2] = r[2]; rotation[2] = r[2];
} }
void projectionFace::setTranslation(SVector3 t) void projectionFace::setTranslation(SVector3 t)
{ {
translation = t; translation = t;
...@@ -71,157 +74,119 @@ void projectionFace::setTranslation(SVector3 t) ...@@ -71,157 +74,119 @@ void projectionFace::setTranslation(SVector3 t)
projectionFace::projectionFace(GModel *m,int num) : GFace(m,num) projectionFace::projectionFace(GModel *m,int num) : GFace(m,num)
{ {
for(int j = 0; j<3; j++) for(int j = 0; j<3; j++){
{
translation[j] = 0; translation[j] = 0;
rotation[j] = 0; rotation[j] = 0;
} }
} }
projectionFace::~projectionFace() projectionFace::~projectionFace()
{ {
} }
parabolicCylinder::parabolicCylinder(GModel *m, int num) : projectionFace(m,num) parabolicCylinder::parabolicCylinder(GModel *m, int num) : projectionFace(m,num)
{ {
focalPoint = 1; focalPoint = 1;
scaleFactor[0] = 1; scaleFactor[0] = 1;
scaleFactor[1] = 1; scaleFactor[1] = 1;
scaleFactor[2] = 1; scaleFactor[2] = 1;
// translation
// scaleFactor = new SVector3(1,1,1);
// rotation = new SVector3(0,0,0);
} }
parabolicCylinder::~parabolicCylinder() parabolicCylinder::~parabolicCylinder()
{ {
} }
GPoint parabolicCylinder::point(double par1, double par2) const GPoint parabolicCylinder::point(double par1, double par2) const
{ {
//first let's find the vertex //first let's find the vertex
//SPoint3 k = focalPoint - directrixPoint; //SPoint3 k = focalPoint - directrixPoint;
//k.setPosition(k.x/2,k.y/2,k.z/2); //k.setPosition(k.x/2,k.y/2,k.z/2);
//double f = sqrt(k.x^2 + k.y^2 + k.z^2); //double f = sqrt(k.x^2 + k.y^2 + k.z^2);
//SPoint3 vertex = directrixPoint + k; //SPoint3 vertex = directrixPoint + k;
par1 -= .5; //I need these to make sure the 'vertex' occurs at the parameter point (.5,.5) par1 -= .5; //I need these to make sure the 'vertex' occurs at the parameter point (.5,.5)
par2 -= .5; par2 -= .5;
SVector3 p(par1, (1/(4*focalPoint))*pow(par1,2.0), par2); SVector3 p(par1, (1/(4*focalPoint))*pow(par1,2.0), par2);
//now we have to do the necessary transformations //now we have to do the necessary transformations
p = scalePoint(p,scaleFactor); //LOCAL SCALING p = scalePoint(p,scaleFactor); //LOCAL SCALING
p = rotatePoint(p,rotation); p = rotatePoint(p,rotation);
p = translation + p; p = translation + p;
GPoint gp(p[0],p[1],p[2]); GPoint gp(p[0],p[1],p[2]);
return gp; return gp;
} }
GPoint parabolicCylinder::point(const SPoint2 &pt) const GPoint parabolicCylinder::point(const SPoint2 &pt) const
{ {
double par1 = pt[0]; double par1 = pt[0];
double par2 = pt[1]; double par2 = pt[1];
return point(par1,par2); return point(par1,par2);
} }
/*
It is my understanding that this method assumes the point is actually on the surface...
also...what does the syntax in the argument mean?
*/
SPoint2 parabolicCylinder::parFromPoint(const SPoint3 &p) const SPoint2 parabolicCylinder::parFromPoint(const SPoint3 &p) const
{ {
//ok...first we need to untranslate, unrotate and unscale it // ok...first we need to untranslate, unrotate and unscale it
SVector3 trans(-translation[0], -translation[1], -translation[2]);
SVector3 trans(-translation[0], -translation[1], -translation[2]); SVector3 rot(-rotation[0],-rotation[1],-rotation[2]);
SVector3 rot(-rotation[0],-rotation[1],-rotation[2]); SVector3 scalar(1/scaleFactor[0],1/scaleFactor[1],1/scaleFactor[2]); //LOCAL SCALING?
SVector3 scalar(1/scaleFactor[0],1/scaleFactor[1],1/scaleFactor[2]); //LOCAL SCALING?
SVector3 pos(p[0],p[1],p[2]);
SVector3 pos(p[0],p[1],p[2]); pos = trans + pos;
pos = trans + pos; pos = rotatePoint(pos,rot);
pos = rotatePoint(pos,rot); pos = scalePoint(pos, scalar);
pos = scalePoint(pos, scalar);
// since the y co-ordinate is completely dependent on u, I actually
//since the y co-ordinate is completely dependent on u, I actually don't need it to compute the u-v point? // don't need it to compute the u-v point?
double u = pos[0] + .5; double u = pos[0] + .5;
double v = pos[1] + .5; double v = pos[1] + .5;
SPoint2 q(pos[0],pos[1]);
return q;
}
// du/dx, du/dy, du/dz; dv/dx, dv/dy, dv/dz
// v - (1/4f)*u^2 = 0
SPoint2 q(pos[0],pos[1]);
return q;
}
/*
du/dx, du/dy, du/dz; dv/dx, dv/dy, dv/dz
v - (1/4f)*u^2 = 0
*/
Pair<SVector3,SVector3> parabolicCylinder::firstDer(const SPoint2 &param) const Pair<SVector3,SVector3> parabolicCylinder::firstDer(const SPoint2 &param) const
{ {
SVector3 du; SVector3 du;
SVector3 dv; SVector3 dv;
du[0] = 1; du[0] = 1;
du[1] = -(1/(2*focalPoint))*(param[0]-.5); du[1] = -(1/(2*focalPoint))*(param[0]-.5);
du[2] = 0; du[2] = 0;
dv[0] = 0; dv[0] = 0;
dv[1] = 0; dv[1] = 0;
dv[2] = 1; dv[2] = 1;
//ok, now we need to scale and rotate...hmm
du = scalePoint(du, scaleFactor); //ok, now we need to scale and rotate...hmm
dv = scalePoint(dv, scaleFactor); du = scalePoint(du, scaleFactor);
du = rotatePoint(du, rotation); dv = scalePoint(dv, scaleFactor);
dv = rotatePoint(dv, rotation); du = rotatePoint(du, rotation);
//yeah...that "might" work dv = rotatePoint(dv, rotation);
//yeah...that "might" work
Pair<SVector3,SVector3> result(du,dv);
return result; Pair<SVector3,SVector3> result(du,dv);
return result;
} }
/* // By convention, we're going to return the normal facing the interior
By convention, we're going to return the normal facing the interior of the parabola // of the parabola
*/
SVector3 parabolicCylinder::normal(const SPoint2 &param) const SVector3 parabolicCylinder::normal(const SPoint2 &param) const
{ {
SVector3 n; SVector3 n;
Pair<SVector3,SVector3> result = firstDer(param); Pair<SVector3,SVector3> result = firstDer(param);
const SVector3 left = result.left(); const SVector3 left = result.left();
const SVector3 right = result.right(); const SVector3 right = result.right();
n = crossprod( left, right); n = crossprod(left, right);
//I forget...do we want to normalize this? n.normalize();
n.normalize(); return n;
return n;
} }
/*
COPIED DIRECTLY FROM GMODELIO_FOURIER.CPP
*/
Range<double> parabolicCylinder::parBounds(int i) const Range<double> parabolicCylinder::parBounds(int i) const
{ {
return Range<double>(0, 1); return Range<double>(0, 1);
} }
/*
GPoint parabolicCylinder::closestPoint(const SPoint3 & queryPoint) const
{
throw;
}
int parabolicCylinder::containsPoint(const SPoint3 &pt) const
{
throw;
}
int parabolicCylinder::containsParam(const SPoint2 &pt) const
{
return 1;
}
GEntity::GeomType parabolicCylinder::geomType() const
{
return GEntity::DiscreteSurface;
}
*/
...@@ -3,59 +3,42 @@ ...@@ -3,59 +3,42 @@
#include "GFace.h" #include "GFace.h"
/* /* Specific to the derived classes, we're going to need functions
What functions we need for this class and all derived classes: which can be used to easily adjust the parameters of the functions.
1. given point in xyz space, compute xyz point on surface plus, we're going to have to implement all that stuff in GFace
2. given point in xyz on surface, compute uv co-ordinate eventually. */
3. given point in uv, compute xyz co-ordinate on surface
functions 2 and 3 are already virtual functions associated with GFace so let's make sure we implement them correctly.
Specific to the derived classes, we're going to also need functions which can be used to easily adjust the parameters of the functions.
plus, we're going to have to implement all that stuff in GFace eventually.
*/
SVector3 scalePoint(SVector3 p, SVector3 s); SVector3 scalePoint(SVector3 p, SVector3 s);
SVector3 rotatePoint(SVector3 p, SVector3 r); SVector3 rotatePoint(SVector3 p, SVector3 r);
class projectionFace : public GFace class projectionFace : public GFace {
{
protected: protected:
//Surface *s; //what is this? SVector3 rotation; //this vector holds the euler angles at which the surface is rotated
SVector3 translation; //this vector holds the location of the reference point in xyz space
SVector3 rotation; //this vector holds the euler angles at which the surface is rotated SVector3 scaleFactor; //this vector holds the scaling factors w.r.t x,y,z
SVector3 translation; //this vector holds the location of the reference point in xyz space
SVector3 scaleFactor; //this vector holds the scaling factors w.r.t x,y,z
public: public:
projectionFace(GModel *m, int num); projectionFace(GModel *m, int num);
~projectionFace(); ~projectionFace();
void rotate(SVector3 rot); //rotates the surface by the euler angles rot void rotate(SVector3 rot); //rotates the surface by the euler angles rot
void translate(SVector3 trans); //translates the surface by trans void translate(SVector3 trans); //translates the surface by trans
void scale(SVector3 sc); //scales the surface along the (local?) x,y,z axes by sc void scale(SVector3 sc); //scales the surface along the (local?) x,y,z axes by sc
void setScale(SVector3 sc); void setScale(SVector3 sc);
void setRotation(SVector3 r); void setRotation(SVector3 r);
void setTranslation(SVector3 t); void setTranslation(SVector3 t);
Range<double> parBounds(int i) const {throw;} Range<double> parBounds(int i) const {throw;}
virtual int paramDegeneracies(int dir, double *par) { return 0; } virtual int paramDegeneracies(int dir, double *par) { return 0; }
virtual GPoint point(double par1, double par2) const {throw;} virtual GPoint point(double par1, double par2) const {throw;}
virtual GPoint point(const SPoint2 &pt) const {throw;} virtual GPoint point(const SPoint2 &pt) const {throw;}
virtual GPoint closestPoint(const SPoint3 & queryPoint) const {throw;} virtual GPoint closestPoint(const SPoint3 & queryPoint) const {throw;}
virtual int containsPoint(const SPoint3 &pt) const {throw;} virtual int containsPoint(const SPoint3 &pt) const {throw;}
virtual int containsParam(const SPoint2 &pt) const {throw;} virtual int containsParam(const SPoint2 &pt) const {throw;}
virtual SVector3 normal(const SPoint2 &param) const {throw;} virtual SVector3 normal(const SPoint2 &param) const {throw;}
virtual Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const {throw;} virtual Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const {throw;}
virtual double * nthDerivative(const SPoint2 &param, int n, virtual double * nthDerivative(const SPoint2 &param, int n,
double *array) const {throw;} double *array) const {throw;}
virtual GEntity::GeomType geomType() const { return GEntity::ProjectionSurface; } virtual GEntity::GeomType geomType() const { return GEntity::ProjectionSurface; }
virtual int geomDirection() const { return 1; } virtual int geomDirection() const { return 1; }
virtual bool continuous(int dim) const { return true; } virtual bool continuous(int dim) const { return true; }
virtual bool periodic(int dim) const { return false; } virtual bool periodic(int dim) const { return false; }
virtual bool degenerate(int dim) const { return false; } virtual bool degenerate(int dim) const { return false; }
...@@ -66,43 +49,18 @@ class projectionFace : public GFace ...@@ -66,43 +49,18 @@ class projectionFace : public GFace
virtual SPoint2 parFromPoint(const SPoint3 &) const {throw;} virtual SPoint2 parFromPoint(const SPoint3 &) const {throw;}
}; };
class parabolicCylinder : public projectionFace class parabolicCylinder : public projectionFace {
{ protected:
protected: double focalPoint; //the length from the vertex to the focal point
double focalPoint; //the length from the vertex to the focal point public:
//SPoint3 directrixPoint; //the point on the directrix opposite wrt the vertex of the focal point
//SVector3 directrixLine; //the direction in which the directrix extends
// double length; //the length of the parabola - just scaling factors
// double height; //the height of the cylinder - just scaling factors
public:
parabolicCylinder(GModel *m, int num); parabolicCylinder(GModel *m, int num);
~parabolicCylinder();
~parabolicCylinder();
Range<double> parBounds(int i) const; Range<double> parBounds(int i) const;
GPoint point(double par1, double par2) const; GPoint point(double par1, double par2) const;
GPoint point(const SPoint2 &pt) const; GPoint point(const SPoint2 &pt) const;
// virtual GPoint closestPoint(const SPoint3 & queryPoint) const;
SVector3 normal(const SPoint2 &param) const; SVector3 normal(const SPoint2 &param) const;
Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const; Pair<SVector3,SVector3> firstDer(const SPoint2 &param) const;
//virtual double * nthDerivative(const SPoint2 &param, int n,
// double *array) const {throw;}
// virtual int geomDirection() const { return 1; }
// virtual bool continuous(int dim) const { return true; }
// virtual bool periodic(int dim) const { return false; }
// virtual bool degenerate(int dim) const { return false; }
// virtual double period(int dir) const {throw;}
// ModelType getNativeType() const { return UnknownModel; }
// void * getNativePtr() const {throw;}
// virtual bool surfPeriodic(int dim) const {throw;}
SPoint2 parFromPoint(const SPoint3 &) const; SPoint2 parFromPoint(const SPoint3 &) const;
}; };
#endif #endif
// $Id: Geom.cpp,v 1.126 2006-12-08 16:54:02 jacob Exp $ // $Id: Geom.cpp,v 1.127 2006-12-15 03:15:32 geuzaine Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -180,16 +180,13 @@ class drawGFace { ...@@ -180,16 +180,13 @@ class drawGFace {
glLineStipple(1, 0x1F1F); glLineStipple(1, 0x1F1F);
gl2psEnable(GL2PS_LINE_STIPPLE); gl2psEnable(GL2PS_LINE_STIPPLE);
int N = 20; int N = 20;
Range<double> ubounds = f->parBounds(0);
Range<double> vbounds = f->parBounds(1);
const double uav = 0.5 * (ubounds.high() + ubounds.low());
const double vav = 0.5 * (vbounds.high() + vbounds.low());
const double ud = (ubounds.high() - ubounds.low());
const double vd = (vbounds.high() - vbounds.low());
glBegin(GL_LINE_STRIP); glBegin(GL_LINE_STRIP);
Range<double> ubounds = f->parBounds ( 0 );
Range<double> vbounds = f->parBounds ( 1 );
const double uav = 0.5 * ( ubounds.high() + ubounds.low());
const double vav = 0.5 * ( vbounds.high() + vbounds.low());
const double ud = ( ubounds.high() - ubounds.low());
const double vd = ( vbounds.high() - vbounds.low());
for(int i = 0; i < N; i++) { for(int i = 0; i < N; i++) {
GPoint p = f->point(ubounds.low() + ud * (double)i / (double)(N - 1), vav); GPoint p = f->point(ubounds.low() + ud * (double)i / (double)(N - 1), vav);
glVertex3d(p.x(), p.y(), p.z()); glVertex3d(p.x(), p.y(), p.z());
...@@ -232,46 +229,42 @@ class drawGFace { ...@@ -232,46 +229,42 @@ class drawGFace {
{ {
Range<double> ubounds = f->parBounds(0); Range<double> ubounds = f->parBounds(0);
Range<double> vbounds = f->parBounds(1); Range<double> vbounds = f->parBounds(1);
double umin = ubounds.low(), umax = ubounds.high();
double vmin = vbounds.low(), vmax = vbounds.high();
const int N = 15; const int N = 15;
glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColor3f(1.0f,0.5f,0.0f); //glEnable(GL_LIGHTING);
//glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
glColor4ubv((GLubyte *) & CTX.color.geom.surface_sel);
glBegin(GL_QUADS); glBegin(GL_QUADS);
for(int i = 1; i < N; i++) for(int i = 1; i < N; i++){
{ for(int j = 1; j < N; j++){
for(int j = 1; j < N; j++) double u1 = umin + (double)i/(double)(N-1) * (umax - umin);
{ double v1 = vmin + (double)j/(double)(N-1) * (vmax - vmin);
double u1 = ubounds.low() + (double)i/(double)(N-1) * double u2 = umin + (double)(i-1)/(double)(N-1) * (umax - umin);
(ubounds.high() - ubounds.low()); double v2 = vmin + (double)(j-1)/(double)(N-1) * (vmax - vmin);
double v1 = vbounds.low() + (double)j/(double)(N-1) * GPoint p1 = f->point(u1, v1);
(vbounds.high() - vbounds.low()); GPoint p2 = f->point(u2, v1);
double u2 = ubounds.low() + (double)(i-1)/(double)(N-1) * GPoint p3 = f->point(u2, v2);
(ubounds.high() - ubounds.low()); GPoint p4 = f->point(u1, v2);
double v2 = vbounds.low() + (double)j/(double)(N-1) * //SVector3 n1 = f->normal(SPoint2(u1, v1));
(vbounds.high() - vbounds.low()); //SVector3 n2 = f->normal(SPoint2(u2, v1));
double u3 = ubounds.low() + (double)(i-1)/(double)(N-1) * //SVector3 n3 = f->normal(SPoint2(u2, v2));
(ubounds.high() - ubounds.low()); //SVector3 n4 = f->normal(SPoint2(u1, v2));
double v3 = vbounds.low() + (double)(j-1)/(double)(N-1) * //glNormal3d(n1.x(), n1.y(), n1.z());
(vbounds.high() - vbounds.low()); glVertex3d(p1.x(), p1.y(), p1.z());
double u4 = ubounds.low() + (double)i/(double)(N-1) * //glNormal3d(n2.x(), n2.y(), n2.z());
(ubounds.high() - ubounds.low()); glVertex3d(p2.x(), p2.y(), p2.z());
double v4 = vbounds.low() + (double)(j-1)/(double)(N-1) * //glNormal3d(n3.x(), n3.y(), n3.z());
(vbounds.high() - vbounds.low()); glVertex3d(p3.x(), p3.y(), p3.z());
GPoint p1 = f->point(u1, v1); //glNormal3d(n4.x(), n4.y(), n4.z());
GPoint p2 = f->point(u2,v2); glVertex3d(p4.x(), p4.y(), p4.z());
GPoint p3 = f->point(u3,v3);
GPoint p4 = f->point(u4,v4);
// printf("%g %g %g\n", p.x(), p.y(), p.z());
glVertex3d(p1.x(), p1.y(), p1.z());
glVertex3d(p2.x(), p2.y(), p2.z());
glVertex3d(p3.x(), p3.y(), p3.z());
glVertex3d(p4.x(), p4.y(), p4.z());
} }
} }
glEnd(); glEnd();
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); //glDisable(GL_LIGHTING);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
} }
void _drawPlaneGFace(GFace *f) void _drawPlaneGFace(GFace *f)
......
// $Id: meshGFace.cpp,v 1.41 2006-12-12 18:16:41 geuzaine Exp $ // $Id: meshGFace.cpp,v 1.42 2006-12-15 03:15:32 geuzaine Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -1371,6 +1371,7 @@ void deMeshGFace :: operator() (GFace *gf) ...@@ -1371,6 +1371,7 @@ void deMeshGFace :: operator() (GFace *gf)
void meshGFace :: operator() (GFace *gf) void meshGFace :: operator() (GFace *gf)
{ {
if(gf->geomType() == GEntity::DiscreteSurface) return; if(gf->geomType() == GEntity::DiscreteSurface) return;
if(gf->geomType() == GEntity::ProjectionSurface) return;
Msg(STATUS2, "Meshing surface %d (%s)", gf->tag(),gf->getTypeString().c_str()); Msg(STATUS2, "Meshing surface %d (%s)", gf->tag(),gf->getTypeString().c_str());
...@@ -1424,6 +1425,8 @@ bool shouldRevert(MEdge &reference, std::vector<T*> &elements) ...@@ -1424,6 +1425,8 @@ bool shouldRevert(MEdge &reference, std::vector<T*> &elements)
void orientMeshGFace::operator()(GFace *gf) void orientMeshGFace::operator()(GFace *gf)
{ {
if(gf->geomType() == GEntity::ProjectionSurface) return;
// in old versions we did not reorient transfinite surface meshes; // in old versions we did not reorient transfinite surface meshes;
// we could add the following to provide backward compatibility: // we could add the following to provide backward compatibility:
// if(gf->meshAttributes.Method == TRANSFINI) return; // if(gf->meshAttributes.Method == TRANSFINI) return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment