Skip to content
Snippets Groups Projects
Commit ba08d9a7 authored by Jacob Bedrossian's avatar Jacob Bedrossian
Browse files

Parabolic Cylinder with Editor

parent 6ac41739
Branches
Tags
No related merge requests found
...@@ -14,11 +14,12 @@ ...@@ -14,11 +14,12 @@
extern GModel *GMODEL; extern GModel *GMODEL;
extern Context_T CTX; extern Context_T CTX;
int projection_editor(char *title, double &a, double &b, double &c) int projection_editor(char *title, projectionFace *p)
{ {
struct _editor{ struct _editor{
Fl_Window *window; Fl_Window *window;
Fl_Value_Slider *sa, *sb, *sc; Fl_Value_Slider *sa, *sb, *sc, *ra, *rb, *rc, *ta, *tb, *tc;
Fl_Button *cancel; Fl_Button *cancel;
}; };
static _editor *editor = 0; static _editor *editor = 0;
...@@ -27,27 +28,90 @@ int projection_editor(char *title, double &a, double &b, double &c) ...@@ -27,27 +28,90 @@ int projection_editor(char *title, double &a, double &b, double &c)
const int BB = 7 * CTX.fontsize; const int BB = 7 * CTX.fontsize;
const int WB = 7; const int WB = 7;
SBoundingBox3d bounds = GMODEL->bounds();
if(!editor){ if(!editor){
editor = new _editor; editor = new _editor;
editor->window = new Dialog_Window(2 * BB + 3 * WB, 4 * 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, "blabla");
editor->sa = new Fl_Value_Slider(WB, WB, BB, BH, "Scale Factor X");
editor->sa->type(FL_HOR_SLIDER); editor->sa->type(FL_HOR_SLIDER);
editor->sa->align(FL_ALIGN_RIGHT); editor->sa->align(FL_ALIGN_RIGHT);
editor->sb = new Fl_Value_Slider(WB, WB + BH, BB, BH, "blibli"); 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->type(FL_HOR_SLIDER);
editor->sb->align(FL_ALIGN_RIGHT); editor->sb->align(FL_ALIGN_RIGHT);
editor->sc = new Fl_Value_Slider(WB, WB + 2 * BH, BB, BH, "blublu"); 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->type(FL_HOR_SLIDER);
editor->sc->align(FL_ALIGN_RIGHT); editor->sc->align(FL_ALIGN_RIGHT);
editor->cancel = new Fl_Button(2 * WB + BB, 2 * WB + 3 * BH, BB, BH, "Cancel"); 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->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(a); editor->sa->value( (bounds.max()[0] + bounds.min()[0])/2 );
editor->sb->value(b); editor->sb->value( (bounds.max()[1] + bounds.min()[1])/2 );
editor->sc->value(c); 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();
editor->window->show(); editor->window->show();
while(editor->window->shown()){ while(editor->window->shown()){
...@@ -56,18 +120,35 @@ int projection_editor(char *title, double &a, double &b, double &c) ...@@ -56,18 +120,35 @@ int projection_editor(char *title, double &a, double &b, double &c)
Fl_Widget* o = Fl::readqueue(); Fl_Widget* o = Fl::readqueue();
if (!o) break; if (!o) break;
Draw(); /* if (o == editor->sa)
SVector3 rescale(editor->sa->value(),0,0);
if (o == editor->sa) p->scale(rescale);
a = editor->sa->value();
if (o == editor->sb) if (o == editor->sb)
b = editor->sb->value(); SVector3 rescale(editor->sa->value(),0,0);
p->scale(rescale);
if (o == editor->sc) if (o == editor->sc)
c = editor->sc->value(); SVector3 rescale(editor->sa->value(),0,0);
if (o == editor->window || o == editor->cancel){ p->scale(rescale);
*/
if (o == editor->window || o == editor->cancel)
{
editor->window->hide(); editor->window->hide();
return 0; 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);
}
Draw();
} }
} }
return 0; return 0;
...@@ -82,11 +163,11 @@ void mesh_parameterize_cb(Fl_Widget* w, void* data) ...@@ -82,11 +163,11 @@ void mesh_parameterize_cb(Fl_Widget* w, void* data)
CTX.mesh.changed = ENT_SURFACE; CTX.mesh.changed = ENT_SURFACE;
CTX.geom.surfaces = 1; CTX.geom.surfaces = 1;
double a=0., b=0., c=0.;
projection_editor("Projection editor", a, b, c);
Draw(); Draw();
projection_editor("Projection editor", p);
//SBoundingBox3d bb = GMODEL->bounds(); //SBoundingBox3d bb = GMODEL->bounds();
Msg(INFO, "Model added: %d faces", GMODEL->numFace()); Msg(INFO, "Model added: %d faces", GMODEL->numFace());
......
...@@ -52,6 +52,22 @@ void projectionFace::scale(SVector3 sc) ...@@ -52,6 +52,22 @@ void projectionFace::scale(SVector3 sc)
scaleFactor[1] *= sc[1]; scaleFactor[1] *= sc[1];
scaleFactor[2] *= sc[2]; 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;
}
projectionFace::projectionFace(GModel *m,int num) : GFace(m,num) projectionFace::projectionFace(GModel *m,int num) : GFace(m,num)
{ {
......
...@@ -33,8 +33,9 @@ class projectionFace : public GFace ...@@ -33,8 +33,9 @@ class projectionFace : public GFace
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 setRotation(SVector3 r);
void setTranslation(SVector3 t);
Range<double> parBounds(int i) const {throw;} Range<double> parBounds(int i) const {throw;}
......
// $Id: Geom.cpp,v 1.125 2006-12-05 18:34:58 geuzaine Exp $ // $Id: Geom.cpp,v 1.126 2006-12-08 16:54:02 jacob Exp $
// //
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
// //
...@@ -232,21 +232,46 @@ class drawGFace { ...@@ -232,21 +232,46 @@ 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);
const int N = 10; const int N = 15;
glBegin(GL_POINTS); glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
for(int i = 0; i < N; i++){ glColor3f(1.0f,0.5f,0.0f);
for(int j = 0; j < N; j++){ glBegin(GL_QUADS);
double u = ubounds.low() + (double)i/(double)(N-1) * 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()); (ubounds.high() - ubounds.low());
double v = vbounds.low() + (double)j/(double)(N-1) * double v1 = vbounds.low() + (double)j/(double)(N-1) *
(vbounds.high() - vbounds.low()); (vbounds.high() - vbounds.low());
GPoint p = f->point(u, v); double u2 = ubounds.low() + (double)(i-1)/(double)(N-1) *
printf("%g %g %g\n", p.x(), p.y(), p.z()); (ubounds.high() - ubounds.low());
glVertex3d(p.x(), p.y(), p.z()); 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());
} }
} }
glEnd(); glEnd();
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
} }
void _drawPlaneGFace(GFace *f) void _drawPlaneGFace(GFace *f)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment