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

draw intersection of cutting planes with the bounding box
parent 7c1add3a
No related branches found
No related tags found
No related merge requests found
// $Id: Draw.cpp,v 1.59 2004-06-04 02:07:06 geuzaine Exp $
// $Id: Draw.cpp,v 1.60 2004-07-22 19:32:02 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -294,3 +294,4 @@ void myZoom(GLdouble X1, GLdouble X2, GLdouble Y1, GLdouble Y2,
InitPosition();
Draw();
}
......@@ -76,6 +76,7 @@ void Draw_Vector(int Type, int Fill,
double relHeadRadius, double relStemLength, double relStemRadius,
double x, double y, double z, double dx, double dy, double dz,
double Raise[3][8], int light);
void Draw_Mesh(Mesh *M);
void Draw_Mesh_Volume(void *a, void *b);
void Draw_Mesh_Surface(void *a, void *b);
......@@ -91,6 +92,10 @@ void Draw_Mesh_Prism(void *a, void *b);
void Draw_Mesh_Pyramid(void *a, void *b);
void Draw_Mesh_Array(VertexArray *va, int faces, int edges);
void Draw_PlaneInBoundingBox(double xmin, double ymin, double zmin,
double xmax, double ymax, double zmax,
double a, double b, double c, double d);
void Draw_ScalarPoint(Post_View *View, int preproNormals,
double ValMin, double ValMax,
double *X, double *Y, double *Z, double *V);
......
// $Id: Entity.cpp,v 1.43 2004-07-05 15:20:06 geuzaine Exp $
// $Id: Entity.cpp,v 1.44 2004-07-22 19:32:02 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -363,3 +363,88 @@ void Draw_Vector(int Type, int Fill,
}
}
void Draw_PlaneInBoundingBox(double xmin, double ymin, double zmin,
double xmax, double ymax, double zmax,
double a, double b, double c, double d)
{
class point{
public:
double x, y, z;
bool valid;
point() : x(0.), y(0.), z(0.), valid(false) {;};
point(double xi, double yi, double zi) :
x(xi), y(yi), z(zi), valid(true) {;};
};
class plane{
private:
double _a, _b, _c, _d;
public:
plane(double a, double b, double c, double d) :
_a(a), _b(b), _c(c), _d(d) {;};
double val(point &p){
return _a*p.x + _b*p.y + _c*p.z + _d;
};
point intersect(point &p1, point &p2){
double v1 = val(p1), v2 = val(p2);
if(fabs(v1) < 1.e-12)
return point(p1.x, p1.y, p1.z);
else if(fabs(v2) < 1.e-12)
return point(p2.x, p2.y, p2.z);
else if(v1 * v2 < 0.){
double coef = - v1 / (v2 - v1);
return point(coef * (p2.x - p1.x) + p1.x,
coef * (p2.y - p1.y) + p1.y,
coef * (p2.z - p1.z) + p1.z);
}
else
return point();
};
};
plane pl(a, b, c, d);
point p1(xmin, ymin, zmin), p2(xmax, ymin, zmin);
point p3(xmax, ymax, zmin), p4(xmin, ymax, zmin);
point p5(xmin, ymin, zmax), p6(xmax, ymin, zmax);
point p7(xmax, ymax, zmax), p8(xmin, ymax, zmax);
point edge[12];
edge[0] = pl.intersect(p1, p2);
edge[1] = pl.intersect(p1, p4);
edge[2] = pl.intersect(p1, p5);
edge[3] = pl.intersect(p2, p3);
edge[4] = pl.intersect(p2, p6);
edge[5] = pl.intersect(p3, p4);
edge[6] = pl.intersect(p3, p7);
edge[7] = pl.intersect(p4, p8);
edge[8] = pl.intersect(p5, p6);
edge[9] = pl.intersect(p5, p8);
edge[10] = pl.intersect(p6, p7);
edge[11] = pl.intersect(p7, p8);
int face[6][4] = {
{0, 2, 4, 8},
{0, 1, 3, 5},
{1, 2, 7, 9},
{3, 4, 6, 10},
{5, 6, 7, 11},
{8, 9, 10, 11}
};
for(int i = 0; i < 6; i++){
int nb = 0;
point p[4];
for(int j = 0; j < 4; j++){
if(edge[face[i][j]].valid == true)
p[nb++] = edge[face[i][j]];
}
if(nb > 1){
glColor3d(1.,0.,0.);
glBegin(GL_LINE_STRIP);
for(int j = 0; j < nb; j++)
glVertex3d(p[j].x, p[j].y, p[j].z);
glEnd();
}
}
}
// $Id: Mesh.cpp,v 1.104 2004-07-22 05:47:46 geuzaine Exp $
// $Id: Mesh.cpp,v 1.105 2004-07-22 19:32:02 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -173,6 +173,18 @@ void Draw_Mesh(Mesh * M)
CTX.max[2] + offset / CTX.s[0]);
sprintf(label, "(%g,%g,%g)", CTX.max[0], CTX.max[1], CTX.max[2]);
Draw_String(label);
for(int i = 0; i < 6; i++)
if(CTX.clip[i] & 1 || CTX.clip[i] & 2)
Draw_PlaneInBoundingBox(CTX.min[0], CTX.min[1], CTX.min[2],
CTX.max[0], CTX.max[1], CTX.max[2],
CTX.clip_plane[i][0], CTX.clip_plane[i][1],
CTX.clip_plane[i][2], CTX.clip_plane[i][3]);
if(CTX.mesh.use_cut_plane)
Draw_PlaneInBoundingBox(CTX.min[0], CTX.min[1], CTX.min[2],
CTX.max[0], CTX.max[1], CTX.max[2],
CTX.mesh.cut_planea, CTX.mesh.cut_planeb,
CTX.mesh.cut_planec, CTX.mesh.cut_planed);
}
// draw the mesh
......
// $Id: Post.cpp,v 1.74 2004-07-22 05:47:47 geuzaine Exp $
// $Id: Post.cpp,v 1.75 2004-07-22 19:32:02 geuzaine Exp $
//
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
......@@ -355,6 +355,13 @@ void Draw_Post(void)
v->BBox[5] + offset / CTX.s[0]);
sprintf(label, "(%g,%g,%g)", v->BBox[1], v->BBox[3], v->BBox[5]);
Draw_String(label);
for(int i = 0; i < 6; i++)
if(CTX.clip[i] & (1<<(2+iView)))
Draw_PlaneInBoundingBox(v->BBox[0], v->BBox[2], v->BBox[4],
v->BBox[1], v->BBox[3], v->BBox[5],
CTX.clip_plane[i][0], CTX.clip_plane[i][1],
CTX.clip_plane[i][2], CTX.clip_plane[i][3]);
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment