netgen/libsrc/geom2d/vsgeom2d.cpp

111 lines
2.2 KiB
C++
Raw Normal View History

2011-01-11 01:18:01 +05:00
#include <meshing.hpp>
2011-02-19 03:50:58 +05:00
#include <geometry2d.hpp>
2011-01-11 01:18:01 +05:00
#include <visual.hpp>
#include "vsgeom2d.hpp"
namespace netgen
{
/* *********************** Draw 2D Geometry **************** */
VisualSceneGeometry2d :: VisualSceneGeometry2d ()
: VisualScene()
{
;
}
VisualSceneGeometry2d :: ~VisualSceneGeometry2d ()
{
;
}
void VisualSceneGeometry2d :: DrawScene ()
{
if (changeval != geometry2d->GetSplines().Size())
BuildScene();
changeval = geometry2d->GetSplines().Size();
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetLight();
// glEnable (GL_LIGHT0);
glDisable (GL_LIGHTING);
glPushMatrix();
glMultMatrixf (transformationmat);
// SetClippingPlane ();
glShadeModel (GL_SMOOTH);
glEnable (GL_COLOR_MATERIAL);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
// float mat_col[] = { 0, 0, 1, 1 };
// glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
glColor3f (0, 0, 1);
Array<Point<2> > points, otherpoints;
for (int i = 1; i <= geometry2d->GetSplines().Size(); i++)
{
2012-10-29 23:50:16 +06:00
geometry2d->GetSplines().Get(i)->GetPoints (200, points);
2011-01-11 01:18:01 +05:00
glBegin (GL_LINE_STRIP);
for (int j = 0; j < points.Size(); j++)
glVertex3d (points[j](0), points[j](1), 0);
2011-01-11 01:18:01 +05:00
glEnd();
2012-10-29 23:50:16 +06:00
}
2011-01-11 01:18:01 +05:00
glColor3f (1, 0, 0);
for (int i = 1; i <= geometry2d->GetSplines().Size(); i++)
{
2011-02-28 17:59:27 +05:00
int other = geometry2d->GetSpline(i-1).copyfrom;
2011-01-11 01:18:01 +05:00
if (other != -1)
{
geometry2d->GetSplines().Get(i)->GetPoints (6, points);
geometry2d->GetSplines().Get(other)->GetPoints (6, otherpoints);
glBegin (GL_LINES);
for (int j = 1; j < 5; j++)
{
glVertex3d (points[j](0), points[j](1), 0);
glVertex3d (otherpoints[j](0), otherpoints[j](1), 0);
2011-01-11 01:18:01 +05:00
}
glEnd ();
}
}
glPopMatrix();
DrawCoordinateCross ();
DrawNetgenLogo ();
glFinish();
}
void VisualSceneGeometry2d :: BuildScene (int zoomall)
{
Box<2> bbox;
geometry2d->GetBoundingBox (bbox);
Point<2> c = Center (bbox.PMin(), bbox.PMax());
center = Point3d (c(0), c(1), 0);
rad = Dist (bbox.PMin(), bbox.PMax()) / 2;
CalcTransformationMatrices();
}
}