diff --git a/Fltk/GUI_Projection.cpp b/Fltk/GUI_Projection.cpp index 43098deafb3f84c2c759a85a98326383099bed1d..53354f939e8df3fefd68fc6071a2e0a05063a224 100644 --- a/Fltk/GUI_Projection.cpp +++ b/Fltk/GUI_Projection.cpp @@ -3,24 +3,23 @@ #include "GModel.h" #include "projectionFace.h" #include "Draw.h" +#include "Options.h" #include "Context.h" #include "Shortcut_Window.h" - #include <FL/Fl_Button.H> #include <FL/Fl_Return_Button.H> -#include <FL/Fl_Value_Slider.H> +#include <FL/Fl_Value_Input.H> extern GModel *GMODEL; extern Context_T CTX; int projection_editor(char *title, projectionFace *p) { - struct _editor{ Fl_Window *window; - Fl_Value_Slider *sa, *sb, *sc, *ra, *rb, *rc, *ta, *tb, *tc; - Fl_Button *cancel; + Fl_Value_Input *scale[3], *rotation[3], *translation[3]; + Fl_Button *cancel, *print; }; static _editor *editor = 0; @@ -34,83 +33,60 @@ int projection_editor(char *title, projectionFace *p) editor = new _editor; 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->sa->type(FL_HOR_SLIDER); - editor->sa->align(FL_ALIGN_RIGHT); - editor->sa->maximum( bounds.max()[0] + 1 ); - editor->sa->minimum(.1); - editor->sb = new Fl_Value_Slider(WB, WB + BH, BB, BH, "Scale Factor Y"); - editor->sb->type(FL_HOR_SLIDER); - editor->sb->align(FL_ALIGN_RIGHT); - 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->sc->type(FL_HOR_SLIDER); - editor->sc->align(FL_ALIGN_RIGHT); - editor->sc->maximum( bounds.max()[2] + 1 ); - editor->sc->minimum(.1); - - editor->ra = new Fl_Value_Slider(WB, WB + 3*BH, BB, BH, "Rotation X"); - editor->ra->type(FL_HOR_SLIDER); - editor->ra->align(FL_ALIGN_RIGHT); - editor->ra->maximum(360); - editor->ra->minimum(0); - - editor->rb = new Fl_Value_Slider(WB, WB + 4*BH, BB, BH, "Rotation Y"); - editor->rb->type(FL_HOR_SLIDER); - editor->rb->align(FL_ALIGN_RIGHT); - editor->rb->maximum(360); - editor->rb->minimum(0); - - 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->scale[0] = new Fl_Value_Input(WB, WB, BB, BH, "Scale Factor X"); + editor->scale[1] = new Fl_Value_Input(WB, WB + BH, BB, BH, "Scale Factor Y"); + editor->scale[2] = new Fl_Value_Input(WB, WB + 2 * BH, BB, BH, "Scale Factor Z"); + for(int i = 0; i < 3; i++){ + editor->scale[i]->align(FL_ALIGN_RIGHT); + editor->scale[i]->maximum(CTX.lc * 10.); + editor->scale[i]->minimum(CTX.lc / 100.); + editor->scale[i]->step(CTX.lc / 100.); + } + + editor->rotation[0] = new Fl_Value_Input(WB, WB + 3*BH, BB, BH, "Rotation X"); + editor->rotation[1] = new Fl_Value_Input(WB, WB + 4*BH, BB, BH, "Rotation Y"); + editor->rotation[2] = new Fl_Value_Input(WB, WB + 5*BH, BB, BH, "Rotation Z"); + for(int i = 0; i < 3; i++){ + editor->rotation[i]->align(FL_ALIGN_RIGHT); + editor->rotation[i]->maximum(-180.); + editor->rotation[i]->minimum(180.); + editor->rotation[i]->step(0.1); + } + + 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->translation[2] = new Fl_Value_Input(WB, WB + 8*BH, BB, BH, "Translation Z"); + for(int i = 0; i < 3; i++){ + editor->translation[i]->align(FL_ALIGN_RIGHT); + editor->translation[i]->maximum(bounds.max()[i] + CTX.lc); + editor->translation[i]->minimum(bounds.min()[i] - CTX.lc); + editor->translation[i]->step(CTX.lc / 100.); + } + 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->window->end(); editor->window->hotspot(editor->window); } editor->window->label(title); - editor->sa->value( (bounds.max()[0] + bounds.min()[0])/2 ); - editor->sb->value( (bounds.max()[1] + bounds.min()[1])/2 ); - editor->sc->value( (bounds.max()[2] + bounds.min()[2])/2 ); - editor->ra->value(0); - 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(); + for(int i = 0; i < 3; i++){ + editor->scale[i]->value(CTX.lc); + editor->rotation[i]->value(0.); + editor->translation[i]->value(0.5 * (bounds.max()[i] + bounds.min()[i])); + } + 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(); @@ -118,37 +94,28 @@ int projection_editor(char *title, projectionFace *p) Fl::wait(); for (;;) { Fl_Widget* o = Fl::readqueue(); - if (!o) break; - - /* if (o == editor->sa) - 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(); + if(!o) break; + if(o == editor->window || o == editor->cancel){ + editor->window->hide(); return 0; } - else - { - 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); + else if(o == editor->print){ + for(int i = 0; i < 3; i++) printf("%g\n", editor->scale[i]->value()); + for(int i = 0; i < 3; i++) printf("%g\n", editor->rotation[i]->value()); + for(int i = 0; i < 3; i++) printf("%g\n", editor->translation[i]->value()); + } + else{ + 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(); - } } return 0; @@ -156,19 +123,17 @@ int projection_editor(char *title, projectionFace *p) 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.geom.surfaces = 1; - + + opt_geometry_surfaces(0, GMSH_SET | GMSH_GUI, 1); + Draw(); projection_editor("Projection editor", p); - - //SBoundingBox3d bb = GMODEL->bounds(); - Msg(INFO, "Model added: %d faces", GMODEL->numFace()); } diff --git a/Geo/projectionFace.cpp b/Geo/projectionFace.cpp index e56bc103b19738bf2db3d0e03a2bb29ee711d974..d59a5124b7e391fb7818690d7f08563aac41fa44 100644 --- a/Geo/projectionFace.cpp +++ b/Geo/projectionFace.cpp @@ -2,68 +2,71 @@ SVector3 scalePoint(SVector3 p, SVector3 s) { - double x = p[0]*s[0]; - double y = p[1]*s[1]; - double z = p[2]*s[2]; - SVector3 result(x,y,z); - return result; + double x = p[0]*s[0]; + double y = p[1]*s[1]; + double z = p[2]*s[2]; + SVector3 result(x,y,z); + return result; } SVector3 rotatePoint(SVector3 p, SVector3 r) { - - double rot[16]; - double x = r[0] * Pi / 180.; - double y = r[1] * Pi / 180.; - double z = r[2] * Pi / 180.; - double A = cos(x); - double B = sin(x); - double C = cos(y); - double D = sin(y); - double E = cos(z); - double F = sin(z); - double AD = A * 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[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[12] = 0.; rot[13] = 0.; rot[14] = 0.; rot[15] = 1.; - - 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]; - z = p[0]*rot[8] + p[1]*rot[9] + p[2]*rot[10]; - - SVector3 result(x,y,z); - return result; + double rot[16]; + double x = r[0] * Pi / 180.; + double y = r[1] * Pi / 180.; + double z = r[2] * Pi / 180.; + double A = cos(x); + double B = sin(x); + double C = cos(y); + double D = sin(y); + double E = cos(z); + double F = sin(z); + double AD = A * 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[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[12] = 0.; rot[13] = 0.; rot[14] = 0.; rot[15] = 1.; + + 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]; + z = p[0]*rot[8] + p[1]*rot[9] + p[2]*rot[10]; + + SVector3 result(x,y,z); + return result; } - void projectionFace::rotate(SVector3 rot) { - rotation = rot + rotation; + rotation = rot + rotation; } + void projectionFace::translate(SVector3 trans) { - translation = trans + translation; + translation = trans + translation; } + void projectionFace::scale(SVector3 sc) { - scaleFactor[0] *= sc[0]; - scaleFactor[1] *= sc[1]; - scaleFactor[2] *= sc[2]; + scaleFactor[0] *= sc[0]; + scaleFactor[1] *= sc[1]; + scaleFactor[2] *= sc[2]; } + void projectionFace::setScale(SVector3 sc) { scaleFactor[0] = sc[0]; scaleFactor[1] = sc[1]; scaleFactor[2] = sc[2]; } + void projectionFace::setRotation(SVector3 r) { rotation[0] = r[0]; rotation[1] = r[1]; rotation[2] = r[2]; } + void projectionFace::setTranslation(SVector3 t) { translation = t; @@ -71,157 +74,119 @@ void projectionFace::setTranslation(SVector3 t) 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; rotation[j] = 0; } } + projectionFace::~projectionFace() { } - parabolicCylinder::parabolicCylinder(GModel *m, int num) : projectionFace(m,num) { focalPoint = 1; - scaleFactor[0] = 1; scaleFactor[1] = 1; scaleFactor[2] = 1; -// translation -// scaleFactor = new SVector3(1,1,1); -// rotation = new SVector3(0,0,0); - } - parabolicCylinder::~parabolicCylinder() { } GPoint parabolicCylinder::point(double par1, double par2) const { - //first let's find the vertex - //SPoint3 k = focalPoint - directrixPoint; - //k.setPosition(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; - par1 -= .5; //I need these to make sure the 'vertex' occurs at the parameter point (.5,.5) - par2 -= .5; - - SVector3 p(par1, (1/(4*focalPoint))*pow(par1,2.0), par2); - - //now we have to do the necessary transformations - p = scalePoint(p,scaleFactor); //LOCAL SCALING - p = rotatePoint(p,rotation); - p = translation + p; - - GPoint gp(p[0],p[1],p[2]); - return gp; + //first let's find the vertex + //SPoint3 k = focalPoint - directrixPoint; + //k.setPosition(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; + par1 -= .5; //I need these to make sure the 'vertex' occurs at the parameter point (.5,.5) + par2 -= .5; + + SVector3 p(par1, (1/(4*focalPoint))*pow(par1,2.0), par2); + + //now we have to do the necessary transformations + p = scalePoint(p,scaleFactor); //LOCAL SCALING + p = rotatePoint(p,rotation); + p = translation + p; + + GPoint gp(p[0],p[1],p[2]); + return gp; } GPoint parabolicCylinder::point(const SPoint2 &pt) const { - double par1 = pt[0]; - double par2 = pt[1]; - return point(par1,par2); + double par1 = pt[0]; + double par2 = pt[1]; + 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 { - //ok...first we need to untranslate, unrotate and unscale it - - SVector3 trans(-translation[0], -translation[1], -translation[2]); - SVector3 rot(-rotation[0],-rotation[1],-rotation[2]); - SVector3 scalar(1/scaleFactor[0],1/scaleFactor[1],1/scaleFactor[2]); //LOCAL SCALING? - - SVector3 pos(p[0],p[1],p[2]); - pos = trans + pos; - pos = rotatePoint(pos,rot); - pos = scalePoint(pos, scalar); - - //since the y co-ordinate is completely dependent on u, I actually don't need it to compute the u-v point? + // ok...first we need to untranslate, unrotate and unscale it + SVector3 trans(-translation[0], -translation[1], -translation[2]); + SVector3 rot(-rotation[0],-rotation[1],-rotation[2]); + SVector3 scalar(1/scaleFactor[0],1/scaleFactor[1],1/scaleFactor[2]); //LOCAL SCALING? + + SVector3 pos(p[0],p[1],p[2]); + pos = trans + pos; + pos = rotatePoint(pos,rot); + pos = scalePoint(pos, scalar); + + // since the y co-ordinate is completely dependent on u, I actually + // don't need it to compute the u-v point? double u = pos[0] + .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 ¶m) const { - SVector3 du; - SVector3 dv; - - du[0] = 1; - du[1] = -(1/(2*focalPoint))*(param[0]-.5); - du[2] = 0; - - dv[0] = 0; - dv[1] = 0; - dv[2] = 1; - //ok, now we need to scale and rotate...hmm - du = scalePoint(du, scaleFactor); - dv = scalePoint(dv, scaleFactor); - du = rotatePoint(du, rotation); - dv = rotatePoint(dv, rotation); - //yeah...that "might" work - - Pair<SVector3,SVector3> result(du,dv); - return result; + SVector3 du; + SVector3 dv; + + du[0] = 1; + du[1] = -(1/(2*focalPoint))*(param[0]-.5); + du[2] = 0; + + dv[0] = 0; + dv[1] = 0; + dv[2] = 1; + + //ok, now we need to scale and rotate...hmm + du = scalePoint(du, scaleFactor); + dv = scalePoint(dv, scaleFactor); + du = rotatePoint(du, rotation); + dv = rotatePoint(dv, rotation); + //yeah...that "might" work + + Pair<SVector3,SVector3> result(du,dv); + return result; } -/* -By convention, we're going to return the normal facing the interior of the parabola -*/ +// By convention, we're going to return the normal facing the interior +// of the parabola SVector3 parabolicCylinder::normal(const SPoint2 ¶m) const { - SVector3 n; - Pair<SVector3,SVector3> result = firstDer(param); - - const SVector3 left = result.left(); - const SVector3 right = result.right(); - n = crossprod( left, right); - //I forget...do we want to normalize this? - n.normalize(); - return n; + SVector3 n; + Pair<SVector3,SVector3> result = firstDer(param); + + const SVector3 left = result.left(); + const SVector3 right = result.right(); + n = crossprod(left, right); + n.normalize(); + return n; } -/* - COPIED DIRECTLY FROM GMODELIO_FOURIER.CPP -*/ - - Range<double> parabolicCylinder::parBounds(int i) const { 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; -} -*/ - - diff --git a/Geo/projectionFace.h b/Geo/projectionFace.h index 4d02efd4c89ab6d957e3880afc22fe296de5291c..5a21b357d683199c64f27727cacfc59430eb1a89 100644 --- a/Geo/projectionFace.h +++ b/Geo/projectionFace.h @@ -3,59 +3,42 @@ #include "GFace.h" -/* -What functions we need for this class and all derived classes: -1. given point in xyz space, compute xyz point on surface -2. given point in xyz on surface, compute uv co-ordinate -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. -*/ +/* Specific to the derived classes, we're going to 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 rotatePoint(SVector3 p, SVector3 r); -class projectionFace : public GFace -{ +class projectionFace : public GFace { 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 scaleFactor; //this vector holds the scaling factors w.r.t x,y,z + 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 scaleFactor; //this vector holds the scaling factors w.r.t x,y,z public: - projectionFace(GModel *m, int num); - ~projectionFace(); - void rotate(SVector3 rot); //rotates the surface by the euler angles rot - 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 rotate(SVector3 rot); //rotates the surface by the euler angles rot + 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 setScale(SVector3 sc); void setRotation(SVector3 r); void setTranslation(SVector3 t); - Range<double> parBounds(int i) const {throw;} virtual int paramDegeneracies(int dir, double *par) { return 0; } - virtual GPoint point(double par1, double par2) const {throw;} virtual GPoint point(const SPoint2 &pt) const {throw;} virtual GPoint closestPoint(const SPoint3 & queryPoint) const {throw;} - virtual int containsPoint(const SPoint3 &pt) const {throw;} virtual int containsParam(const SPoint2 &pt) const {throw;} - virtual SVector3 normal(const SPoint2 ¶m) const {throw;} virtual Pair<SVector3,SVector3> firstDer(const SPoint2 ¶m) const {throw;} virtual double * nthDerivative(const SPoint2 ¶m, int n, double *array) const {throw;} - virtual GEntity::GeomType geomType() const { return GEntity::ProjectionSurface; } 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; } @@ -66,43 +49,18 @@ class projectionFace : public GFace virtual SPoint2 parFromPoint(const SPoint3 &) const {throw;} }; -class parabolicCylinder : public projectionFace -{ - protected: - double focalPoint; //the length from the vertex to the focal point - //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: - +class parabolicCylinder : public projectionFace { + protected: + double focalPoint; //the length from the vertex to the focal point + public: parabolicCylinder(GModel *m, int num); - - ~parabolicCylinder(); - + ~parabolicCylinder(); Range<double> parBounds(int i) const; - GPoint point(double par1, double par2) const; GPoint point(const SPoint2 &pt) const; -// virtual GPoint closestPoint(const SPoint3 & queryPoint) const; - SVector3 normal(const SPoint2 ¶m) const; Pair<SVector3,SVector3> firstDer(const SPoint2 ¶m) const; - //virtual double * nthDerivative(const SPoint2 ¶m, 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; - }; + #endif diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index b99e7de31b3013ce125c5954740cdaeee06bf1a1..82c139d761b154742404cef188459c800f245963 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $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 // @@ -180,16 +180,13 @@ class drawGFace { glLineStipple(1, 0x1F1F); gl2psEnable(GL2PS_LINE_STIPPLE); 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); - - 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++) { GPoint p = f->point(ubounds.low() + ud * (double)i / (double)(N - 1), vav); glVertex3d(p.x(), p.y(), p.z()); @@ -232,46 +229,42 @@ class drawGFace { { Range<double> ubounds = f->parBounds(0); Range<double> vbounds = f->parBounds(1); + double umin = ubounds.low(), umax = ubounds.high(); + double vmin = vbounds.low(), vmax = vbounds.high(); const int N = 15; - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - glColor3f(1.0f,0.5f,0.0f); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + //glEnable(GL_LIGHTING); + //glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); + glColor4ubv((GLubyte *) & CTX.color.geom.surface_sel); glBegin(GL_QUADS); - for(int i = 1; i < N; i++) - { - for(int j = 1; j < N; j++) - { - double u1 = ubounds.low() + (double)i/(double)(N-1) * - (ubounds.high() - ubounds.low()); - double v1 = vbounds.low() + (double)j/(double)(N-1) * - (vbounds.high() - vbounds.low()); - double u2 = ubounds.low() + (double)(i-1)/(double)(N-1) * - (ubounds.high() - ubounds.low()); - double v2 = vbounds.low() + (double)j/(double)(N-1) * - (vbounds.high() - vbounds.low()); - double u3 = ubounds.low() + (double)(i-1)/(double)(N-1) * - (ubounds.high() - ubounds.low()); - double v3 = vbounds.low() + (double)(j-1)/(double)(N-1) * - (vbounds.high() - vbounds.low()); - double u4 = ubounds.low() + (double)i/(double)(N-1) * - (ubounds.high() - ubounds.low()); - double v4 = vbounds.low() + (double)(j-1)/(double)(N-1) * - (vbounds.high() - vbounds.low()); - GPoint p1 = f->point(u1, v1); - GPoint p2 = f->point(u2,v2); - 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()); - - + for(int i = 1; i < N; i++){ + 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 u2 = umin + (double)(i-1)/(double)(N-1) * (umax - umin); + double v2 = vmin + (double)(j-1)/(double)(N-1) * (vmax - vmin); + GPoint p1 = f->point(u1, v1); + GPoint p2 = f->point(u2, v1); + GPoint p3 = f->point(u2, v2); + GPoint p4 = f->point(u1, v2); + //SVector3 n1 = f->normal(SPoint2(u1, v1)); + //SVector3 n2 = f->normal(SPoint2(u2, v1)); + //SVector3 n3 = f->normal(SPoint2(u2, v2)); + //SVector3 n4 = f->normal(SPoint2(u1, v2)); + //glNormal3d(n1.x(), n1.y(), n1.z()); + glVertex3d(p1.x(), p1.y(), p1.z()); + //glNormal3d(n2.x(), n2.y(), n2.z()); + glVertex3d(p2.x(), p2.y(), p2.z()); + //glNormal3d(n3.x(), n3.y(), n3.z()); + glVertex3d(p3.x(), p3.y(), p3.z()); + //glNormal3d(n4.x(), n4.y(), n4.z()); + glVertex3d(p4.x(), p4.y(), p4.z()); } } glEnd(); - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); + //glDisable(GL_LIGHTING); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } void _drawPlaneGFace(GFace *f) diff --git a/Mesh/meshGFace.cpp b/Mesh/meshGFace.cpp index 93fdbc0f2da82c6cd51bc29ecb88cf277056d2d3..19fc7e6da7120bd085c618597b1f1f121fd89ebd 100644 --- a/Mesh/meshGFace.cpp +++ b/Mesh/meshGFace.cpp @@ -1,4 +1,4 @@ -// $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 // @@ -1371,6 +1371,7 @@ void deMeshGFace :: operator() (GFace *gf) void meshGFace :: operator() (GFace *gf) { if(gf->geomType() == GEntity::DiscreteSurface) return; + if(gf->geomType() == GEntity::ProjectionSurface) return; Msg(STATUS2, "Meshing surface %d (%s)", gf->tag(),gf->getTypeString().c_str()); @@ -1424,6 +1425,8 @@ bool shouldRevert(MEdge &reference, std::vector<T*> &elements) void orientMeshGFace::operator()(GFace *gf) { + if(gf->geomType() == GEntity::ProjectionSurface) return; + // in old versions we did not reorient transfinite surface meshes; // we could add the following to provide backward compatibility: // if(gf->meshAttributes.Method == TRANSFINI) return;