mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-27 13:20:34 +05:00
Merge branch 'draw_stl_to_plain' into 'master'
Draw stl to plain See merge request jschoeberl/netgen!241
This commit is contained in:
commit
1fb048e399
@ -1,9 +1,13 @@
|
|||||||
#include <mystdlib.h>
|
#include <mystdlib.h>
|
||||||
#include "meshing.hpp"
|
#include "meshing.hpp"
|
||||||
|
#include <visual.hpp>
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
{
|
{
|
||||||
|
extern DLL_HEADER void Render(bool blocking = false);
|
||||||
static void glrender (int wait);
|
static void glrender (int wait);
|
||||||
|
DLL_HEADER extern VisualSceneSurfaceMeshing vssurfacemeshing;
|
||||||
|
VisualSceneSurfaceMeshing vssurfacemeshing;
|
||||||
|
|
||||||
|
|
||||||
// global variable for visualization
|
// global variable for visualization
|
||||||
@ -241,14 +245,21 @@ namespace netgen
|
|||||||
bool debugflag;
|
bool debugflag;
|
||||||
|
|
||||||
// double h;
|
// double h;
|
||||||
|
|
||||||
NgArray<Point3d> locpoints;
|
auto locpointsptr = make_shared<NgArray<Point3d>>();
|
||||||
|
vssurfacemeshing.locpointsptr = locpointsptr;
|
||||||
|
auto& locpoints = *locpointsptr;
|
||||||
NgArray<int> legalpoints;
|
NgArray<int> legalpoints;
|
||||||
NgArray<Point2d> plainpoints;
|
auto plainpointsptr = make_shared<NgArray<Point2d>>();
|
||||||
|
auto& plainpoints = *plainpointsptr;
|
||||||
|
vssurfacemeshing.plainpointsptr = plainpointsptr;
|
||||||
NgArray<int> plainzones;
|
NgArray<int> plainzones;
|
||||||
NgArray<INDEX_2> loclines;
|
auto loclinesptr = make_shared<NgArray<INDEX_2>>();
|
||||||
|
auto &loclines = *loclinesptr;
|
||||||
|
vssurfacemeshing.loclinesptr = loclinesptr;
|
||||||
int cntelem = 0, trials = 0, nfaces = 0;
|
int cntelem = 0, trials = 0, nfaces = 0;
|
||||||
int oldnl = 0;
|
int oldnl = 0;
|
||||||
|
vssurfacemeshing.oldnl = oldnl;
|
||||||
int qualclass;
|
int qualclass;
|
||||||
|
|
||||||
|
|
||||||
@ -514,6 +525,7 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
oldnp = locpoints.Size();
|
oldnp = locpoints.Size();
|
||||||
oldnl = loclines.Size();
|
oldnl = loclines.Size();
|
||||||
|
vssurfacemeshing.oldnl = oldnl;
|
||||||
|
|
||||||
if (debugflag)
|
if (debugflag)
|
||||||
(*testout) << "define new transformation" << endl;
|
(*testout) << "define new transformation" << endl;
|
||||||
@ -1452,6 +1464,7 @@ namespace netgen
|
|||||||
(*testout) << adfront.GetGlobalIndex (pindex.Get(i)) << endl;
|
(*testout) << adfront.GetGlobalIndex (pindex.Get(i)) << endl;
|
||||||
|
|
||||||
(*testout) << "old number of lines = " << oldnl << endl;
|
(*testout) << "old number of lines = " << oldnl << endl;
|
||||||
|
vssurfacemeshing.oldnl = oldnl;
|
||||||
for (int i = 1; i <= loclines.Size(); i++)
|
for (int i = 1; i <= loclines.Size(); i++)
|
||||||
{
|
{
|
||||||
(*testout) << "line ";
|
(*testout) << "line ";
|
||||||
@ -1579,14 +1592,11 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef OPENGL
|
||||||
// #define OPENGL
|
|
||||||
#ifdef OPENGLxx
|
|
||||||
|
|
||||||
/* *********************** Draw Surface Meshing **************** */
|
/* *********************** Draw Surface Meshing **************** */
|
||||||
|
|
||||||
|
|
||||||
#include <visual.hpp>
|
|
||||||
#include <stlgeom.hpp>
|
#include <stlgeom.hpp>
|
||||||
|
|
||||||
namespace netgen
|
namespace netgen
|
||||||
@ -1594,7 +1604,6 @@ namespace netgen
|
|||||||
|
|
||||||
extern STLGeometry * stlgeometry;
|
extern STLGeometry * stlgeometry;
|
||||||
extern Mesh * mesh;
|
extern Mesh * mesh;
|
||||||
VisualSceneSurfaceMeshing vssurfacemeshing;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1604,7 +1613,7 @@ namespace netgen
|
|||||||
|
|
||||||
if (multithread.drawing)
|
if (multithread.drawing)
|
||||||
{
|
{
|
||||||
// vssurfacemeshing.Render();
|
// vssurfacemeshing.DrawScene();
|
||||||
Render ();
|
Render ();
|
||||||
|
|
||||||
if (wait || multithread.testmode)
|
if (wait || multithread.testmode)
|
||||||
@ -1630,14 +1639,19 @@ namespace netgen
|
|||||||
|
|
||||||
void VisualSceneSurfaceMeshing :: DrawScene ()
|
void VisualSceneSurfaceMeshing :: DrawScene ()
|
||||||
{
|
{
|
||||||
int i, j, k;
|
// int i, j, k;
|
||||||
|
if(!locpointsptr)
|
||||||
|
return;
|
||||||
|
auto& locpoints = *locpointsptr;
|
||||||
|
auto& loclines = *loclinesptr;
|
||||||
|
auto& plainpoints = *plainpointsptr;
|
||||||
|
|
||||||
if (loclines.Size() != changeval)
|
if (loclines.Size() != changeval)
|
||||||
{
|
{
|
||||||
center = Point<3>(0,0,-5);
|
center = Point<3>(0,0,-5);
|
||||||
rad = 0.1;
|
rad = 0.1;
|
||||||
|
|
||||||
CalcTransformationMatrices();
|
// CalcTransformationMatrices();
|
||||||
changeval = loclines.Size();
|
changeval = loclines.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1657,7 +1671,7 @@ namespace netgen
|
|||||||
// SetLight();
|
// SetLight();
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glMultMatrixf (transformationmat);
|
glMultMatrixd (transformationmat);
|
||||||
|
|
||||||
glShadeModel (GL_SMOOTH);
|
glShadeModel (GL_SMOOTH);
|
||||||
// glDisable (GL_COLOR_MATERIAL);
|
// glDisable (GL_COLOR_MATERIAL);
|
||||||
@ -1677,7 +1691,7 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
float mat_col[] = { 0.2, 0.2, 0.8, 1 };
|
float mat_col[] = { 0.2, 0.2, 0.8, 1 };
|
||||||
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
|
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
|
||||||
@ -1694,7 +1708,7 @@ namespace netgen
|
|||||||
glPolygonOffset (1, -1);
|
glPolygonOffset (1, -1);
|
||||||
glLineWidth (3);
|
glLineWidth (3);
|
||||||
|
|
||||||
for (i = 1; i <= loclines.Size(); i++)
|
for (int i = 1; i <= loclines.Size(); i++)
|
||||||
{
|
{
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
{
|
{
|
||||||
@ -1731,7 +1745,7 @@ namespace netgen
|
|||||||
float mat_colp[] = { 1, 0, 0, 1 };
|
float mat_colp[] = { 1, 0, 0, 1 };
|
||||||
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp);
|
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp);
|
||||||
glBegin (GL_POINTS);
|
glBegin (GL_POINTS);
|
||||||
for (i = 1; i <= locpoints.Size(); i++)
|
for (int i = 1; i <= locpoints.Size(); i++)
|
||||||
{
|
{
|
||||||
Point3d p = locpoints.Get(i);
|
Point3d p = locpoints.Get(i);
|
||||||
glVertex3f (p.X(), p.Y(), p.Z());
|
glVertex3f (p.X(), p.Y(), p.Z());
|
||||||
@ -1740,18 +1754,16 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
*/
|
|
||||||
|
|
||||||
float mat_colp[] = { 1, 0, 0, 1 };
|
// float mat_colp[] = { 1, 0, 0, 1 };
|
||||||
|
|
||||||
float mat_col2d1[] = { 1, 0.5, 0.5, 1 };
|
float mat_col2d1[] = { 1, 0.5, 0.5, 1 };
|
||||||
float mat_col2d[] = { 1, 1, 1, 1 };
|
float mat_col2d[] = { 1, 1, 1, 1 };
|
||||||
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d);
|
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d);
|
||||||
|
|
||||||
double scalex = 0.1, scaley = 0.1;
|
|
||||||
|
|
||||||
glBegin (GL_LINES);
|
glBegin (GL_LINES);
|
||||||
for (i = 1; i <= loclines.Size(); i++)
|
for (int i = 1; i <= loclines.Size(); i++)
|
||||||
{
|
{
|
||||||
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d);
|
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col2d);
|
||||||
if (i == 1)
|
if (i == 1)
|
||||||
@ -1766,8 +1778,8 @@ namespace netgen
|
|||||||
Point2d p2 = plainpoints.Get(pi2);
|
Point2d p2 = plainpoints.Get(pi2);
|
||||||
|
|
||||||
glBegin (GL_LINES);
|
glBegin (GL_LINES);
|
||||||
glVertex3f (scalex * p1.X(), scaley * p1.Y(), -5);
|
glVertex3f (scalex * p1.X() + shiftx, scaley * p1.Y() + shifty, -5);
|
||||||
glVertex3f (scalex * p2.X(), scaley * p2.Y(), -5);
|
glVertex3f (scalex * p2.X() + shiftx, scaley * p2.Y() + shifty, -5);
|
||||||
glEnd();
|
glEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1776,10 +1788,10 @@ namespace netgen
|
|||||||
|
|
||||||
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp);
|
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_colp);
|
||||||
glBegin (GL_POINTS);
|
glBegin (GL_POINTS);
|
||||||
for (i = 1; i <= plainpoints.Size(); i++)
|
for (int i = 1; i <= plainpoints.Size(); i++)
|
||||||
{
|
{
|
||||||
Point2d p = plainpoints.Get(i);
|
Point2d p = plainpoints.Get(i);
|
||||||
glVertex3f (scalex * p.X(), scaley * p.Y(), -5);
|
glVertex3f (scalex * p.X() + shiftx, scaley * p.Y() + shifty, -5);
|
||||||
}
|
}
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
@ -1971,7 +1983,7 @@ namespace netgen
|
|||||||
|
|
||||||
void VisualSceneSurfaceMeshing :: BuildScene (int zoomall)
|
void VisualSceneSurfaceMeshing :: BuildScene (int zoomall)
|
||||||
{
|
{
|
||||||
int i, j, k;
|
// int i, j, k;
|
||||||
/*
|
/*
|
||||||
center = stlgeometry -> GetBoundingBox().Center();
|
center = stlgeometry -> GetBoundingBox().Center();
|
||||||
rad = stlgeometry -> GetBoundingBox().Diam() / 2;
|
rad = stlgeometry -> GetBoundingBox().Diam() / 2;
|
||||||
|
@ -758,9 +758,26 @@ namespace netgen
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void VisualSceneSurfaceMeshing::MouseMove(int oldx, int oldy,
|
||||||
|
int newx, int newy,
|
||||||
|
char mode)
|
||||||
|
{
|
||||||
|
double fac = 0.001;
|
||||||
|
if(mode == 'M')
|
||||||
|
{
|
||||||
|
shiftx += fac * (newx - oldx);
|
||||||
|
shifty += fac * (oldy - newy);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if(mode == 'Z')
|
||||||
|
{
|
||||||
|
scalex *= (1 - fac * (newy - oldy));
|
||||||
|
scaley *= (1 - fac * (newy - oldy));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
VisualScene::MouseMove(oldx, oldy, newx, newy, mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PARALLELGL
|
#ifdef PARALLELGL
|
||||||
|
@ -52,9 +52,9 @@ namespace netgen
|
|||||||
DLL_HEADER void ArbitraryRotation (const NgArray<double> & alpha, const NgArray<Vec3d> & vec);
|
DLL_HEADER void ArbitraryRotation (const NgArray<double> & alpha, const NgArray<Vec3d> & vec);
|
||||||
DLL_HEADER void ArbitraryRotation (const double alpha, const Vec3d & vec);
|
DLL_HEADER void ArbitraryRotation (const double alpha, const Vec3d & vec);
|
||||||
|
|
||||||
DLL_HEADER void MouseMove(int oldx, int oldy,
|
DLL_HEADER virtual void MouseMove(int oldx, int oldy,
|
||||||
int newx, int newy,
|
int newx, int newy,
|
||||||
char mode);
|
char mode);
|
||||||
|
|
||||||
DLL_HEADER void LookAt (const Point<3> & cam, const Point<3> & obj,
|
DLL_HEADER void LookAt (const Point<3> & cam, const Point<3> & obj,
|
||||||
const Point<3> & camup);
|
const Point<3> & camup);
|
||||||
@ -95,12 +95,20 @@ namespace netgen
|
|||||||
|
|
||||||
class VisualSceneSurfaceMeshing : public VisualScene
|
class VisualSceneSurfaceMeshing : public VisualScene
|
||||||
{
|
{
|
||||||
|
double scalex = 1., scaley = 1., shiftx = 0., shifty = 0.;
|
||||||
public:
|
public:
|
||||||
|
shared_ptr<NgArray<Point3d>> locpointsptr;
|
||||||
|
shared_ptr<NgArray<INDEX_2>> loclinesptr;
|
||||||
|
shared_ptr<NgArray<Point2d>> plainpointsptr;
|
||||||
|
int oldnl;
|
||||||
|
bool clearptr;
|
||||||
VisualSceneSurfaceMeshing ();
|
VisualSceneSurfaceMeshing ();
|
||||||
virtual ~VisualSceneSurfaceMeshing ();
|
virtual ~VisualSceneSurfaceMeshing ();
|
||||||
|
|
||||||
virtual void BuildScene (int zoomall = 0);
|
void BuildScene (int zoomall = 0) override;
|
||||||
virtual void DrawScene ();
|
void DrawScene () override;
|
||||||
|
void MouseMove(int oldx, int oldy, int newx, int newy,
|
||||||
|
char mode) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,6 +81,18 @@ if { $toglok == 1} {
|
|||||||
.ndraw render
|
.ndraw render
|
||||||
set oldmousex %x; set oldmousey %y;
|
set oldmousex %x; set oldmousey %y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bind .ndraw <Alt-B2-Motion> {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y Move2d
|
||||||
|
.ndraw render
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .ndraw <Alt-B3-Motion> {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y Zoom2d
|
||||||
|
.ndraw render
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,6 +54,18 @@ if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth t
|
|||||||
.ndraw render
|
.ndraw render
|
||||||
set oldmousex %x; set oldmousey %y;
|
set oldmousex %x; set oldmousey %y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bind .ndraw <Alt-B2-Motion> {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y Move2d
|
||||||
|
.ndraw render
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
|
|
||||||
|
bind .ndraw <Alt-B3-Motion> {
|
||||||
|
Ng_MouseMove $oldmousex $oldmousey %x %y Zoom2d
|
||||||
|
.ndraw render
|
||||||
|
set oldmousex %x; set oldmousey %y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1940,7 +1940,7 @@ namespace netgen
|
|||||||
vs = &vsmeshdoc;
|
vs = &vsmeshdoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing;
|
if (strcmp (vismode, "surfmeshing") == 0) vs = &vssurfacemeshing;
|
||||||
if (strcmp (vismode, "specpoints") == 0) vs = &vsspecpoints;
|
if (strcmp (vismode, "specpoints") == 0) vs = &vsspecpoints;
|
||||||
if (strcmp (vismode, "solution") == 0) vs = &netgen::GetVSSolution();
|
if (strcmp (vismode, "solution") == 0) vs = &netgen::GetVSSolution();
|
||||||
}
|
}
|
||||||
|
@ -3373,6 +3373,16 @@ const char * ngscript[] = {""
|
|||||||
,".ndraw render\n"
|
,".ndraw render\n"
|
||||||
,"set oldmousex %x; set oldmousey %y;\n"
|
,"set oldmousex %x; set oldmousey %y;\n"
|
||||||
,"}\n"
|
,"}\n"
|
||||||
|
,"bind .ndraw <Alt-B2-Motion> {\n"
|
||||||
|
,"Ng_MouseMove $oldmousex $oldmousey %x %y Move2d\n"
|
||||||
|
,".ndraw render\n"
|
||||||
|
,"set oldmousex %x; set oldmousey %y;\n"
|
||||||
|
,"}\n"
|
||||||
|
,"bind .ndraw <Alt-B3-Motion> {\n"
|
||||||
|
,"Ng_MouseMove $oldmousex $oldmousey %x %y Zoom2d\n"
|
||||||
|
,".ndraw render\n"
|
||||||
|
,"set oldmousex %x; set oldmousey %y;\n"
|
||||||
|
,"}\n"
|
||||||
,"}\n"
|
,"}\n"
|
||||||
,"proc popupcheckredraw { vari { x 0 } } {\n"
|
,"proc popupcheckredraw { vari { x 0 } } {\n"
|
||||||
,"upvar $vari varname\n"
|
,"upvar $vari varname\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user