spline files restructured

This commit is contained in:
Joachim Schoeberl 2011-02-28 12:59:27 +00:00
parent 55282bac84
commit 5204be0657
16 changed files with 668 additions and 315 deletions

View File

@ -21,5 +21,6 @@ solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp
libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp
libcsgvis_la_LIBADD = libcsg.la $(top_builddir)/libsrc/geom2d/libgeom2d.la
libcsgvis_la_LIBADD = libcsg.la
# $(top_builddir)/libsrc/geom2d/libgeom2d.la

View File

@ -11,9 +11,9 @@
#include <gprim.hpp>
#include <meshing.hpp>
#include <geometry2d.hpp>
// #include <geometry2d.hpp>
#include "../gprim/spline.hpp"
#include "../gprim/splinegeometry.hpp"

View File

@ -34,6 +34,7 @@ public:
#ifdef MSVC_EXPRESS
// #include <pthread.h>
class NgMutex
{
pthread_mutex_t mut;

View File

@ -1,12 +1,11 @@
noinst_HEADERS = geom2dmesh.hpp splinegeometry.hpp spline.hpp geometry2d.hpp vsgeom2d.hpp
noinst_HEADERS = geom2dmesh.hpp geometry2d.hpp vsgeom2d.hpp
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(TCL_INCLUDES)
METASOURCES = AUTO
noinst_LTLIBRARIES = libgeom2d.la libgeom2dvis.la
lib_LTLIBRARIES = libgeom2d.la libgeom2dvis.la
libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp spline.cpp \
splinegeometry.cpp
libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp geometry2d.cpp
libgeom2dvis_la_SOURCES = geom2dpkg.cpp vsgeom2d.cpp

View File

@ -6,10 +6,6 @@
namespace netgen
{
// static Array<Point<2> > points2;
// static Array<int> lp1, lp2;
extern void Optimize2d (Mesh & mesh, MeshingParameters & mp);
@ -18,6 +14,275 @@ namespace netgen
void CalcPartition (double l, double h, double h1, double h2,
double hcurve, double elto0, Array<double> & points);
// partitionizes spline curve
void Partition (const SplineSegExt & spline,
double h, double elto0,
Mesh & mesh, Point3dTree & searchtree, int segnr)
{
enum { D = 2 };
int i, j;
double l; // , r1, r2, ra;
double lold, dt, frac;
int n = 100;
Point<D> p, pold, mark, oldmark;
Array<double> curvepoints;
double edgelength, edgelengthold;
l = spline.Length();
double h1 = min (spline.StartPI().hmax, h/spline.StartPI().refatpoint);
double h2 = min (spline.EndPI().hmax, h/spline.EndPI().refatpoint);
double hcurve = min (spline.hmax, h/spline.reffak);
CalcPartition (l, h, h1, h2, hcurve, elto0, curvepoints);
// cout << "curvepoints = " << curvepoints << endl;
dt = 1.0 / n;
l = 0;
j = 1;
pold = spline.GetPoint (0);
lold = 0;
oldmark = pold;
edgelengthold = 0;
Array<int> locsearch;
for (i = 1; i <= n; i++)
{
p = spline.GetPoint (i*dt);
l = lold + Dist (p, pold);
while (j < curvepoints.Size() && (l >= curvepoints[j] || i == n))
{
frac = (curvepoints[j]-lold) / (l-lold);
edgelength = i*dt + (frac-1)*dt;
// mark = pold + frac * (p-pold);
mark = spline.GetPoint (edgelength);
// cout << "mark = " << mark << " =?= " << GetPoint (edgelength) << endl;
{
PointIndex pi1 = -1, pi2 = -1;
Point3d mark3(mark(0), mark(1), 0);
Point3d oldmark3(oldmark(0), oldmark(1), 0);
Vec<3> v (1e-4*h, 1e-4*h, 1e-4*h);
searchtree.GetIntersecting (oldmark3 - v, oldmark3 + v, locsearch);
for (int k = 0; k < locsearch.Size(); k++)
if ( mesh[PointIndex(locsearch[k])].GetLayer() == spline.layer)
pi1 = locsearch[k];
// if (locsearch.Size()) pi1 = locsearch[0];
searchtree.GetIntersecting (mark3 - v, mark3 + v, locsearch);
for (int k = 0; k < locsearch.Size(); k++)
if ( mesh[PointIndex(locsearch[k])].GetLayer() == spline.layer)
pi2 = locsearch[k];
// if (locsearch.Size()) pi2 = locsearch[0];
/*
for (PointIndex pk = PointIndex::BASE;
pk < mesh.GetNP()+PointIndex::BASE; pk++)
{
if (Dist (mesh[pk], oldmark3) < 1e-4 * h) pi1 = pk;
if (Dist (mesh[pk], mark3) < 1e-4 * h) pi2 = pk;
}
*/
// cout << "pi1 = " << pi1 << endl;
// cout << "pi2 = " << pi2 << endl;
if (pi1 == -1)
{
pi1 = mesh.AddPoint(oldmark3, spline.layer);
searchtree.Insert (oldmark3, pi1);
}
if (pi2 == -1)
{
pi2 = mesh.AddPoint(mark3, spline.layer);
searchtree.Insert (mark3, pi2);
}
Segment seg;
seg.edgenr = segnr;
seg.si = spline.bc; // segnr;
seg[0] = pi1;
seg[1] = pi2;
seg.domin = spline.leftdom;
seg.domout = spline.rightdom;
seg.epgeominfo[0].edgenr = segnr;
seg.epgeominfo[0].dist = edgelengthold;
seg.epgeominfo[1].edgenr = segnr;
seg.epgeominfo[1].dist = edgelength;
seg.singedge_left = spline.hpref_left;
seg.singedge_right = spline.hpref_right;
mesh.AddSegment (seg);
}
oldmark = mark;
edgelengthold = edgelength;
j++;
}
pold = p;
lold = l;
}
}
void SplineGeometry2d :: PartitionBoundary (double h, Mesh & mesh2d)
{
enum { D = 2 };
Box<D> bbox;
GetBoundingBox (bbox);
double dist = Dist (bbox.PMin(), bbox.PMax());
Point<3> pmin;
Point<3> pmax;
pmin(2) = -dist; pmax(2) = dist;
for(int j=0;j<D;j++)
{
pmin(j) = bbox.PMin()(j);
pmax(j) = bbox.PMax()(j);
}
Point3dTree searchtree (pmin, pmax);
for (int i = 0; i < splines.Size(); i++)
for (int side = 0; side <= 1; side++)
{
int dom = (side == 0) ? GetSpline(i).leftdom : GetSpline(i).rightdom;
if (dom != 0) GetSpline(i).layer = GetDomainLayer (dom);
}
for (int i = 0; i < splines.Size(); i++)
if (GetSpline(i).copyfrom == -1)
{
// astrid - set boundary meshsize to domain meshsize h
// if no domain mesh size is given, the max h value from the bounding box is used
double minimum = min2 ( GetDomainMaxh ( GetSpline(i).leftdom ), GetDomainMaxh ( GetSpline(i).rightdom ) );
double maximum = max2 ( GetDomainMaxh ( GetSpline(i).leftdom ), GetDomainMaxh ( GetSpline(i).rightdom ) );
minimum = min2 ( minimum, h );
maximum = min2 ( maximum, h);
if ( minimum > 0 )
// GetSpline(i).Partition(minimum, elto0, mesh2d, searchtree, i+1);
Partition(GetSpline(i), minimum, elto0, mesh2d, searchtree, i+1);
else if ( maximum > 0 )
// GetSpline(i).Partition(maximum, elto0, mesh2d, searchtree, i+1);
Partition(GetSpline(i), maximum, elto0, mesh2d, searchtree, i+1);
else
// GetSpline(i).Partition(h, elto0, mesh2d, searchtree, i+1);
Partition(GetSpline(i), h, elto0, mesh2d, searchtree, i+1);
}
else
{
CopyEdgeMesh (GetSpline(i).copyfrom, i+1, mesh2d, searchtree);
}
}
void SplineGeometry2d :: CopyEdgeMesh (int from, int to, Mesh & mesh, Point3dTree & searchtree)
{
const int D = 2;
int i;
Array<int, PointIndex::BASE> mappoints (mesh.GetNP());
Array<double, PointIndex::BASE> param (mesh.GetNP());
mappoints = -1;
param = 0;
Point3d pmin, pmax;
mesh.GetBox (pmin, pmax);
double diam2 = Dist2(pmin, pmax);
if (printmessage_importance>0)
cout << "copy edge, from = " << from << " to " << to << endl;
for (i = 1; i <= mesh.GetNSeg(); i++)
{
const Segment & seg = mesh.LineSegment(i);
if (seg.edgenr == from)
{
mappoints.Elem(seg[0]) = 1;
param.Elem(seg[0]) = seg.epgeominfo[0].dist;
mappoints.Elem(seg[1]) = 1;
param.Elem(seg[1]) = seg.epgeominfo[1].dist;
}
}
bool mapped = false;
for (i = 1; i <= mappoints.Size(); i++)
{
if (mappoints.Get(i) != -1)
{
Point<D> newp = splines.Get(to)->GetPoint (param.Get(i));
Point<3> newp3;
for(int j=0; j<min2(D,3); j++)
newp3(j) = newp(j);
for(int j=min2(D,3); j<3; j++)
newp3(j) = 0;
int npi = -1;
for (PointIndex pi = PointIndex::BASE;
pi < mesh.GetNP()+PointIndex::BASE; pi++)
if (Dist2 (mesh.Point(pi), newp3) < 1e-12 * diam2)
npi = pi;
if (npi == -1)
{
npi = mesh.AddPoint (newp3);
searchtree.Insert (newp3, npi);
}
mappoints.Elem(i) = npi;
mesh.GetIdentifications().Add (i, npi, to);
mapped = true;
}
}
if(mapped)
mesh.GetIdentifications().SetType(to,Identifications::PERIODIC);
// copy segments
int oldnseg = mesh.GetNSeg();
for (i = 1; i <= oldnseg; i++)
{
const Segment & seg = mesh.LineSegment(i);
if (seg.edgenr == from)
{
Segment nseg;
nseg.edgenr = to;
nseg.si = GetSpline(to-1).bc; // splines.Get(to)->bc;
nseg[0] = mappoints.Get(seg[0]);
nseg[1] = mappoints.Get(seg[1]);
nseg.domin = GetSpline(to-1).leftdom;
nseg.domout = GetSpline(to-1).rightdom;
nseg.epgeominfo[0].edgenr = to;
nseg.epgeominfo[0].dist = param.Get(seg[0]);
nseg.epgeominfo[1].edgenr = to;
nseg.epgeominfo[1].dist = param.Get(seg[1]);
mesh.AddSegment (nseg);
}
}
}
void MeshFromSpline2D (SplineGeometry2d & geometry,
Mesh *& mesh,
MeshingParameters & mp)

View File

@ -13,10 +13,10 @@ namespace netgen
class Refinement2d : public Refinement
{
const SplineGeometry2d & geometry;
const class SplineGeometry2d & geometry;
public:
Refinement2d (const SplineGeometry2d & ageometry);
Refinement2d (const class SplineGeometry2d & ageometry);
virtual ~Refinement2d ();
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,

View File

@ -11,7 +11,7 @@
#include "vsgeom2d.hpp"
extern "C" int Ng_CSG_Init (Tcl_Interp * interp);
// extern "C" int Ng_CSG_Init (Tcl_Interp * interp);
namespace netgen
{
@ -63,10 +63,10 @@ namespace netgen
}
using namespace netgen;
extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp);
using namespace netgen;
extern "C" int Ng_geom2d_Init (Tcl_Interp * interp);
int Ng_Geom2d_Init (Tcl_Interp * interp)
int Ng_geom2d_Init (Tcl_Interp * interp)
{
geometryregister.Append (new SplineGeometryRegister);
}

View File

@ -11,9 +11,175 @@
#include <gprim.hpp>
#include "spline.hpp"
#include "splinegeometry.hpp"
#include "../gprim/spline.hpp"
#include "../gprim/splinegeometry.hpp"
#include "geom2dmesh.hpp"
namespace netgen
{
class SplineSegExt : public SplineSeg<2>
{
public:
const SplineSeg & seg;
/// left domain
int leftdom;
/// right domain
int rightdom;
/// refinement at line
double reffak;
/// maximal h;
double hmax;
/// boundary condition number
int bc;
/// copy spline mesh from other spline (-1.. do not copy)
int copyfrom;
/// perfrom anisotropic refinement (hp-refinement) to edge
bool hpref_left;
/// perfrom anisotropic refinement (hp-refinement) to edge
bool hpref_right;
///
int layer;
SplineSegExt (const SplineSeg & hseg)
: seg(hseg)
{
layer = 1;
}
virtual const GeomPoint<2> & StartPI () const
{
return seg.StartPI();
}
virtual const GeomPoint<2> & EndPI () const
{
return seg.EndPI();
}
virtual Point<2> GetPoint (double t) const
{
return seg.GetPoint(t);
}
virtual Vec<2> GetTangent (const double t) const
{
return seg.GetTangent(t);
}
virtual void GetDerivatives (const double t,
Point<2> & point,
Vec<2> & first,
Vec<2> & second) const
{
seg.GetDerivatives (t, point, first, second);
}
virtual void GetCoeff (Vector & coeffs) const
{
seg.GetCoeff (coeffs);
}
virtual void GetPoints (int n, Array<Point<2> > & points) const
{
seg.GetPoints (n, points);
}
virtual double MaxCurvature () const
{
return seg.MaxCurvature();
}
virtual string GetType () const
{
return seg.GetType();
}
};
class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry
{
protected:
Array<char*> materials;
Array<double> maxh;
Array<bool> quadmeshing;
Array<bool> tensormeshing;
Array<int> layer;
Array<string*> bcnames;
double elto0;
public:
virtual ~SplineGeometry2d();
void Load (const char * filename);
void LoadData( ifstream & infile );
void LoadDataNew ( ifstream & infile );
void LoadDataV2 ( ifstream & infile );
void TestComment ( ifstream & infile ) ;
const SplineSegExt & GetSpline (const int i) const
{
return dynamic_cast<const SplineSegExt&> (*splines[i]);
}
SplineSegExt & GetSpline (const int i)
{
return dynamic_cast<SplineSegExt&> (*splines[i]);
}
virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend);
void PartitionBoundary (double h, Mesh & mesh2d);
void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree);
void GetMaterial( const int domnr, char* & material );
double GetDomainMaxh ( const int domnr );
bool GetDomainQuadMeshing ( int domnr )
{
if ( quadmeshing.Size() ) return quadmeshing[domnr-1];
else return false;
}
bool GetDomainTensorMeshing ( int domnr )
{
if ( tensormeshing.Size() ) return tensormeshing[domnr-1];
else return false;
}
int GetDomainLayer ( int domnr )
{
if ( layer.Size() ) return layer[domnr-1];
else return 1;
}
string GetBCName ( const int bcnr ) const;
string * BCNamePtr ( const int bcnr );
virtual Refinement & GetRefinement () const;
};
}
#endif

View File

@ -73,7 +73,7 @@ namespace netgen
for (int i = 1; i <= geometry2d->GetSplines().Size(); i++)
{
int other = geometry2d->GetSplines().Get(i)->copyfrom;
int other = geometry2d->GetSpline(i-1).copyfrom;
if (other != -1)
{
geometry2d->GetSplines().Get(i)->GetPoints (6, points);
@ -112,11 +112,4 @@ namespace netgen
CalcTransformationMatrices();
}
}

View File

@ -10,7 +10,6 @@
namespace netgen
{
class VisualSceneGeometry2d : public VisualScene
{
const class SplineGeometry2d * geometry2d;
@ -22,8 +21,6 @@ namespace netgen
virtual void DrawScene ();
};
}

View File

@ -1,7 +1,7 @@
noinst_HEADERS = adtree.hpp geom3d.hpp geomobjects2.hpp geomops2.hpp geomtest3d.hpp transform3d.hpp geom2d.hpp geomfuncs.hpp geomobjects.hpp geomops.hpp gprim.hpp
noinst_HEADERS = adtree.hpp geom3d.hpp geomobjects2.hpp geomops2.hpp geomtest3d.hpp transform3d.hpp geom2d.hpp geomfuncs.hpp geomobjects.hpp geomops.hpp gprim.hpp spline.hpp splinegeometry.hpp
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include
METASOURCES = AUTO
noinst_LTLIBRARIES = libgprim.la
libgprim_la_SOURCES = adtree.cpp geom2d.cpp geom3d.cpp geomfuncs.cpp \
geomtest3d.cpp transform3d.cpp
geomtest3d.cpp transform3d.cpp spline.cpp splinegeometry.cpp

View File

@ -3,12 +3,11 @@ include_HEADERS =
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES)
bin_PROGRAMS = netgen
netgen_SOURCES = demoview.cpp ngappinit.cpp ngpkg.cpp onetcl.cpp nginterface.cpp nginterface_v2.cpp parallelfunc.cpp parallelinterface.cpp demoview.hpp parallelfunc.hpp togl_1_7.h
netgen_SOURCES = demoview.cpp ngappinit.cpp onetcl.cpp nginterface.cpp nginterface_v2.cpp parallelfunc.cpp parallelinterface.cpp ngpkg.cpp demoview.hpp parallelfunc.hpp togl_1_7.h
netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \
$(top_builddir)/libsrc/csg/libcsgvis.la \
$(top_builddir)/libsrc/geom2d/libgeom2dvis.la \
$(top_builddir)/libsrc/interface/libinterface.la \
$(top_builddir)/libsrc/meshing/libmesh.la \
$(top_builddir)/libsrc/gprim/libgprim.la \
@ -21,6 +20,7 @@ netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \
# $(top_builddir)/libsrc/stlgeom/libstlvis.la
# $(top_builddir)/libsrc/stlgeom/libstl.la
# $(top_builddir)/libsrc/geom2d/libgeom2d.la
# $(top_builddir)/libsrc/geom2d/libgeom2dvis.la
# add for static linkage of ngsolve:

View File

@ -10,10 +10,7 @@ set oldmousey 0
# if { 1 } {
# if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true -create init -display draw -reshape reshape }] } {
if {[catch {togl .ndraw -width 400 -height 300 -rgba true -double true -depth true -privatecmap false -stereo false -indirect true }] } {
puts "no OpenGL"
} {

View File

@ -82,6 +82,13 @@ catch {
source ${ngdir}/drawing.tcl
}
if { [catch { load libgeom2dvis[info sharedlibextension] Ng_Geom2d } result ] } {
puts "cannot load 2d meshing mordule"
puts "error: $result"
}
source ${ngdir}/csgeom.tcl
source ${ngdir}/stlgeom.tcl

View File

@ -18,42 +18,8 @@
namespace netgen
{
#include "writeuser.hpp"
extern NetgenGeometry * ng_geometry;
extern AutoPtr<Mesh> mesh;
#ifndef NOTCL
extern Tcl_Interp * tcl_interp;
#endif
#ifdef ACIS
extern ACISGeometry * acisgeometry;
#endif
#ifdef OPENGL
extern VisualSceneSolution vssolution;
#endif
extern CSGeometry * ParseCSG (istream & istr);
#ifdef SOCKETS
extern AutoPtr<ClientSocket> clientsocket;
//extern Array< AutoPtr < ServerInfo > > servers;
extern Array< ServerInfo* > servers;
#endif
extern void Render ();
}
using namespace netgen;
/*
#ifdef _MSC_VER
// Philippose - 30/01/2009
@ -124,11 +90,47 @@ using namespace netgen;
#endif // #ifdef _MSC_VER
*/
namespace netgen
{
#include "writeuser.hpp"
// global variable mesh (should not be used in libraries)
AutoPtr<Mesh> mesh;
NetgenGeometry * ng_geometry = new NetgenGeometry;
// extern NetgenGeometry * ng_geometry;
// extern AutoPtr<Mesh> mesh;
#ifndef NOTCL
extern Tcl_Interp * tcl_interp;
#endif
#ifdef OPENGL
extern VisualSceneSolution vssolution;
#endif
extern CSGeometry * ParseCSG (istream & istr);
#ifdef SOCKETS
extern AutoPtr<ClientSocket> clientsocket;
//extern Array< AutoPtr < ServerInfo > > servers;
extern Array< ServerInfo* > servers;
#endif
extern void Render ();
}
using namespace netgen;
void Ng_LoadGeometry (const char * filename)
@ -185,30 +187,30 @@ void Ng_LoadMeshFromStream ( istream & input )
if(auxstring == "csgsurfaces")
{
/*
if (geometry)
if (geometry)
{
geometry.Reset (new CSGeometry (""));
geometry.Reset (new CSGeometry (""));
}
if (stlgeometry)
if (stlgeometry)
{
delete stlgeometry;
stlgeometry = NULL;
delete stlgeometry;
stlgeometry = NULL;
}
#ifdef OCCGEOMETRY
if (occgeometry)
#ifdef OCCGEOMETRY
if (occgeometry)
{
delete occgeometry;
occgeometry = NULL;
delete occgeometry;
occgeometry = NULL;
}
#endif
#ifdef ACIS
if (acisgeometry)
#endif
#ifdef ACIS
if (acisgeometry)
{
delete acisgeometry;
acisgeometry = NULL;
delete acisgeometry;
acisgeometry = NULL;
}
#endif
geometry2d.Reset (0);
#endif
geometry2d.Reset (0);
*/
// geometry -> LoadSurfaces(input);
CSGeometry * geometry = new CSGeometry ("");
@ -369,7 +371,7 @@ NG_ELEMENT_TYPE Ng_GetElement (int ei, int * epi, int * np)
if (np) *np = el.GetNP();
return NG_ELEMENT_TYPE (el.GetType());
/*
switch (el.GetNP())
switch (el.GetNP())
{
case 3: return NG_TRIG;
case 4: return NG_QUAD;
@ -579,8 +581,6 @@ void Ng_GetNormalVector (int sei, int locpi, double * nv)
nv[0] = 0;
nv[1] = 0;
nv[2] = 1;
(*testout) << "Ng_GetNormalVector (sei = " << sei << ", locpi = " << locpi << ")" << endl;
if (mesh->GetDimension() == 3)
{
@ -605,9 +605,7 @@ void Ng_GetNormalVector (int sei, int locpi, double * nv)
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (geometry)
{
(*testout) << "geometry defined" << endl;
n = geometry->GetSurface (surfi) -> GetNormalVector(p);
(*testout) << "aus is" << endl;
nv[0] = n(0);
nv[1] = n(1);
nv[2] = n(2);
@ -689,7 +687,7 @@ int Ng_FindSurfaceElementOfPoint (double * p, double * lami, int build_searchtre
else
{
//throw NgException("FindSurfaceElementOfPoint for 2D meshes not yet implemented");
cerr << "FindSurfaceElementOfPoint for 2D meshes not yet implemented" << endl;
cerr << "FindSurfaceElementOfPoint for 2D meshes not yet implemented" << endl;
}
delete dummy;
@ -771,7 +769,7 @@ void Ng_GetElementTransformation (int ei, const double * xi,
}
#ifdef OLD
void Ng_GetBufferedElementTransformation (int ei, const double * xi,
double * x, double * dxdxi,
void * buffer, int buffervalid)
@ -791,32 +789,32 @@ void Ng_GetBufferedElementTransformation (int ei, const double * xi,
buffer, (buffervalid != 0));
/*
Point<3> xl(xi[0], xi[1], xi[2]);
Point<3> xg;
Mat<3,3> dx;
// buffervalid = 0;
mesh->GetCurvedElements().CalcElementTransformation (xl, ei-1, xg, dx, buffer, buffervalid);
Point<3> xl(xi[0], xi[1], xi[2]);
Point<3> xg;
Mat<3,3> dx;
// buffervalid = 0;
mesh->GetCurvedElements().CalcElementTransformation (xl, ei-1, xg, dx, buffer, buffervalid);
// still 1-based arrays
if (x)
// still 1-based arrays
if (x)
{
for (int i = 0; i < 3; i++)
x[i] = xg(i);
for (int i = 0; i < 3; i++)
x[i] = xg(i);
}
if (dxdxi)
if (dxdxi)
{
for (int i=0; i<3; i++)
{
dxdxi[3*i] = dx(i,0);
dxdxi[3*i+1] = dx(i,1);
dxdxi[3*i+2] = dx(i,2);
}
for (int i=0; i<3; i++)
{
dxdxi[3*i] = dx(i,0);
dxdxi[3*i+1] = dx(i,1);
dxdxi[3*i+2] = dx(i,2);
}
}
*/
}
}
#endif
@ -1037,31 +1035,31 @@ void Ng_Refine (NG_REFINEMENT_TYPE reftype)
MeshOptimize2d * opt = NULL;
/*
if (geometry2d)
if (geometry2d)
ref = new Refinement2d(*geometry2d);
else if (stlgeometry)
else if (stlgeometry)
ref = new RefinementSTLGeometry(*stlgeometry);
#ifdef OCCGEOMETRY
else if (occgeometry)
#ifdef OCCGEOMETRY
else if (occgeometry)
ref = new OCCRefinementSurfaces (*occgeometry);
#endif
#ifdef ACIS
else if (acisgeometry)
#endif
#ifdef ACIS
else if (acisgeometry)
{
ref = new ACISRefinementSurfaces (*acisgeometry);
opt = new ACISMeshOptimize2dSurfaces(*acisgeometry);
ref->Set2dOptimizer(opt);
ref = new ACISRefinementSurfaces (*acisgeometry);
opt = new ACISMeshOptimize2dSurfaces(*acisgeometry);
ref->Set2dOptimizer(opt);
}
#endif
else if (geometry && mesh->GetDimension() == 3)
#endif
else if (geometry && mesh->GetDimension() == 3)
{
ref = new RefinementSurfaces(*geometry);
opt = new MeshOptimize2dSurfaces(*geometry);
ref->Set2dOptimizer(opt);
ref = new RefinementSurfaces(*geometry);
opt = new MeshOptimize2dSurfaces(*geometry);
ref->Set2dOptimizer(opt);
}
else
else
{
ref = new Refinement();
ref = new Refinement();
}
*/
@ -1079,65 +1077,65 @@ void Ng_SecondOrder ()
{
const_cast<Refinement&> (ng_geometry->GetRefinement()).MakeSecondOrder(*mesh);
/*
if (stlgeometry)
if (stlgeometry)
{
RefinementSTLGeometry ref (*stlgeometry);
ref.MakeSecondOrder (*mesh);
RefinementSTLGeometry ref (*stlgeometry);
ref.MakeSecondOrder (*mesh);
}
else if (geometry2d)
else if (geometry2d)
{
Refinement2d ref (*geometry2d);
ref.MakeSecondOrder (*mesh);
Refinement2d ref (*geometry2d);
ref.MakeSecondOrder (*mesh);
}
else if (geometry && mesh->GetDimension() == 3)
else if (geometry && mesh->GetDimension() == 3)
{
RefinementSurfaces ref (*geometry);
ref.MakeSecondOrder (*mesh);
RefinementSurfaces ref (*geometry);
ref.MakeSecondOrder (*mesh);
}
else
else
{
if (printmessage_importance>0)
cout << "no geom" << endl;
Refinement ref;
ref.MakeSecondOrder (*mesh);
if (printmessage_importance>0)
cout << "no geom" << endl;
Refinement ref;
ref.MakeSecondOrder (*mesh);
}
*/
mesh -> UpdateTopology();
}
/*
void Ng_HPRefinement (int levels)
{
void Ng_HPRefinement (int levels)
{
Refinement * ref;
if (stlgeometry)
ref = new RefinementSTLGeometry (*stlgeometry);
ref = new RefinementSTLGeometry (*stlgeometry);
else if (geometry2d)
ref = new Refinement2d (*geometry2d);
ref = new Refinement2d (*geometry2d);
else
ref = new RefinementSurfaces (*geometry);
ref = new RefinementSurfaces (*geometry);
HPRefinement (*mesh, ref, levels);
}
}
void Ng_HPRefinement (int levels, double parameter)
{
void Ng_HPRefinement (int levels, double parameter)
{
Refinement * ref;
if (stlgeometry)
ref = new RefinementSTLGeometry (*stlgeometry);
ref = new RefinementSTLGeometry (*stlgeometry);
else if (geometry2d)
ref = new Refinement2d (*geometry2d);
ref = new Refinement2d (*geometry2d);
else
ref = new RefinementSurfaces (*geometry);
ref = new RefinementSurfaces (*geometry);
HPRefinement (*mesh, ref, levels, parameter);
}
}
*/
void Ng_HPRefinement (int levels, double parameter, bool setorders,
@ -1147,16 +1145,16 @@ void Ng_HPRefinement (int levels, double parameter, bool setorders,
Refinement & ref = const_cast<Refinement&> (ng_geometry -> GetRefinement());
HPRefinement (*mesh, &ref, levels);
/*
Refinement * ref;
Refinement * ref;
if (stlgeometry)
if (stlgeometry)
ref = new RefinementSTLGeometry (*stlgeometry);
else if (geometry2d)
else if (geometry2d)
ref = new Refinement2d (*geometry2d);
else
else
ref = new RefinementSurfaces (*geometry);
HPRefinement (*mesh, ref, levels, parameter, setorders, ref_level);
HPRefinement (*mesh, ref, levels, parameter, setorders, ref_level);
*/
}
@ -1165,25 +1163,25 @@ void Ng_HighOrder (int order, bool rational)
{
NgLock meshlock (mesh->MajorMutex(), true);
/*
Refinement * ref;
Refinement * ref;
if (stlgeometry)
if (stlgeometry)
ref = new RefinementSTLGeometry (*stlgeometry);
#ifdef OCCGEOMETRY
else if (occgeometry)
#ifdef OCCGEOMETRY
else if (occgeometry)
ref = new OCCRefinementSurfaces (*occgeometry);
#endif
#ifdef ACIS
else if (acisgeometry)
#endif
#ifdef ACIS
else if (acisgeometry)
{
ref = new ACISRefinementSurfaces (*acisgeometry);
ref = new ACISRefinementSurfaces (*acisgeometry);
}
#endif
else if (geometry2d)
#endif
else if (geometry2d)
ref = new Refinement2d (*geometry2d);
else
else
{
ref = new RefinementSurfaces (*geometry);
ref = new RefinementSurfaces (*geometry);
}
*/
// cout << "parameter 1: " << argv[1] << " (conversion to int = " << atoi(argv[1]) << ")" << endl;
@ -1194,7 +1192,7 @@ void Ng_HighOrder (int order, bool rational)
mesh -> SetNextMajorTimeStamp();
/*
if(mesh)
if(mesh)
mesh -> GetCurvedElements().BuildCurvedElements (ref, order, rational);
*/
@ -1235,7 +1233,7 @@ int Ng_ME_GetNVertices (NG_ELEMENT_TYPE et)
return 5;
case NG_PRISM:
case NG_PRISM12:
case NG_PRISM12:
return 6;
case NG_HEX:
@ -1850,10 +1848,10 @@ void Ng_Redraw ()
#ifdef OPENGL
extern bool nodisplay; // he: global in ngappinit.cpp
if (!nodisplay)
{
vssolution.UpdateSolutionTimeStamp();
Render();
}
{
vssolution.UpdateSolutionTimeStamp();
Render();
}
#endif
}
@ -1865,10 +1863,10 @@ void Ng_SetVisualizationParameter (const char * name, const char * value)
char buf[100];
sprintf (buf, "visoptions.%s", name);
if (printmessage_importance>0)
{
cout << "name = " << name << ", value = " << value << endl;
cout << "set tcl-variable " << buf << " to " << value << endl;
}
{
cout << "name = " << name << ", value = " << value << endl;
cout << "set tcl-variable " << buf << " to " << value << endl;
}
Tcl_SetVar (tcl_interp, buf, const_cast<char*> (value), 0);
Tcl_Eval (tcl_interp, "Ng_Vis_Set parameters;");
#endif
@ -1885,8 +1883,8 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
//extern Mesh * mesh;
/*
if (mesh.Ptr()) mesh->DeleteMesh();
if (!mesh.Ptr()) mesh = new Mesh();
if (mesh.Ptr()) mesh->DeleteMesh();
if (!mesh.Ptr()) mesh = new Mesh();
*/
mesh.Reset (new Mesh());
@ -1933,7 +1931,7 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
//firsttime = 0;
Ng_Redraw();
}
}
}
@ -1968,22 +1966,22 @@ int Ng_GetNPeriodicEdges (int idnr)
int cnt = 0;
// for (int id = 1; id <= mesh->GetIdentifications().GetMaxNr(); id++)
{
mesh->GetIdentifications().GetMap(idnr, map);
//(*testout) << "ident-map " << id << ":" << endl << map << endl;
{
mesh->GetIdentifications().GetMap(idnr, map);
//(*testout) << "ident-map " << id << ":" << endl << map << endl;
for (SegmentIndex si = 0; si < nse; si++)
{
PointIndex other1 = map[(*mesh)[si][0]];
PointIndex other2 = map[(*mesh)[si][1]];
// (*testout) << "seg = " << (*mesh)[si] << "; other = "
// << other1 << "-" << other2 << endl;
if (other1 && other2 && mesh->IsSegment (other1, other2))
{
cnt++;
}
}
}
for (SegmentIndex si = 0; si < nse; si++)
{
PointIndex other1 = map[(*mesh)[si][0]];
PointIndex other2 = map[(*mesh)[si][1]];
// (*testout) << "seg = " << (*mesh)[si] << "; other = "
// << other1 << "-" << other2 << endl;
if (other1 && other2 && mesh->IsSegment (other1, other2))
{
cnt++;
}
}
}
return cnt;
}
@ -1995,23 +1993,23 @@ void Ng_GetPeriodicEdges (int idnr, int * pairs)
int cnt = 0;
// for (int id = 1; id <= mesh->GetIdentifications().GetMaxNr(); id++)
{
mesh->GetIdentifications().GetMap(idnr, map);
{
mesh->GetIdentifications().GetMap(idnr, map);
//(*testout) << "map = " << map << endl;
//(*testout) << "map = " << map << endl;
for (SegmentIndex si = 0; si < nse; si++)
{
PointIndex other1 = map[(*mesh)[si][0]];
PointIndex other2 = map[(*mesh)[si][1]];
if (other1 && other2 && mesh->IsSegment (other1, other2))
{
SegmentIndex otherseg = mesh->SegmentNr (other1, other2);
pairs[cnt++] = top.GetSegmentEdge (si+1);
pairs[cnt++] = top.GetSegmentEdge (otherseg+1);
}
}
}
for (SegmentIndex si = 0; si < nse; si++)
{
PointIndex other1 = map[(*mesh)[si][0]];
PointIndex other2 = map[(*mesh)[si][1]];
if (other1 && other2 && mesh->IsSegment (other1, other2))
{
SegmentIndex otherseg = mesh->SegmentNr (other1, other2);
pairs[cnt++] = top.GetSegmentEdge (si+1);
pairs[cnt++] = top.GetSegmentEdge (otherseg+1);
}
}
}
}
@ -2211,25 +2209,25 @@ int Ng_Bisect_WithInfo ( const char * refinementfile, double ** qualityloss, int
Refinement * ref = const_cast<Refinement*> (&ng_geometry -> GetRefinement());
MeshOptimize2d * opt = NULL;
/*
if (stlgeometry)
if (stlgeometry)
ref = new RefinementSTLGeometry(*stlgeometry);
#ifdef OCCGEOMETRY
else if (occgeometry)
#ifdef OCCGEOMETRY
else if (occgeometry)
ref = new OCCRefinementSurfaces (*occgeometry);
#endif
#ifdef ACIS
else if (acisgeometry)
#endif
#ifdef ACIS
else if (acisgeometry)
{
ref = new ACISRefinementSurfaces(*acisgeometry);
opt = new ACISMeshOptimize2dSurfaces(*acisgeometry);
ref->Set2dOptimizer(opt);
ref = new ACISRefinementSurfaces(*acisgeometry);
opt = new ACISMeshOptimize2dSurfaces(*acisgeometry);
ref->Set2dOptimizer(opt);
}
#endif
else
#endif
else
{
ref = new RefinementSurfaces(*geometry);
opt = new MeshOptimize2dSurfaces(*geometry);
ref->Set2dOptimizer(opt);
ref = new RefinementSurfaces(*geometry);
opt = new MeshOptimize2dSurfaces(*geometry);
ref->Set2dOptimizer(opt);
}
*/
#ifdef ACIS
@ -2388,13 +2386,13 @@ int Ng_GetNElements (int dim)
/*
closure nodes of element
nodeset is bit-coded, bit 0 includes Vertices, bit 1 edges, etc
E.g., nodeset = 6 includes edge and face nodes
nodes is pair of integers (nodetype, nodenr)
return value is number of nodes
*/
/*
closure nodes of element
nodeset is bit-coded, bit 0 includes Vertices, bit 1 edges, etc
E.g., nodeset = 6 includes edge and face nodes
nodes is pair of integers (nodetype, nodenr)
return value is number of nodes
*/
int Ng_GetElementClosureNodes (int dim, int elementnr, int nodeset, int * nodes)
{
switch (dim)

View File

@ -32,78 +32,8 @@ The interface between the GUI and the netgen library
extern bool nodisplay;
#include <nginterface.h>
#ifdef _MSC_VER
// Philippose - 30/01/2009
// MSVC Express Edition Support
#ifdef MSVC_EXPRESS
// #include <pthread.h>
static pthread_t meshingthread;
void RunParallel ( void * (*fun)(void *), void * in)
{
if (netgen::mparam.parthread)
{
pthread_attr_t attr;
pthread_attr_init (&attr);
// the following call can be removed if not available:
pthread_attr_setstacksize(&attr, 1000000);
//pthread_create (&meshingthread, &attr, fun, NULL);
pthread_create (&meshingthread, &attr, fun, in);
}
else
fun (in);
}
#else // Using MS VC++ Standard / Enterprise / Professional edition
// Afx - Threads need different return - value:
static void* (*sfun)(void *);
unsigned int fun2 (void * val)
{
sfun (val);
return 0;
}
void RunParallel ( void* (*fun)(void *), void * in)
{
sfun = fun;
if (netgen::mparam.parthread)
AfxBeginThread (fun2, in);
//AfxBeginThread (fun2, NULL);
else
fun (in);
}
#endif // #ifdef MSVC_EXPRESS
#else // For #ifdef _MSC_VER
// #include <pthread.h>
static pthread_t meshingthread;
void RunParallel ( void * (*fun)(void *), void * in)
{
if (netgen::mparam.parthread)
{
pthread_attr_t attr;
pthread_attr_init (&attr);
// the following call can be removed if not available:
pthread_attr_setstacksize(&attr, 1000000);
//pthread_create (&meshingthread, &attr, fun, NULL);
pthread_create (&meshingthread, &attr, fun, in);
}
else
fun (in);
}
#endif // #ifdef _MSC_VER
// #include <nginterface.h>
extern "C" void RunParallel ( void * (*fun)(void *), void * in);
@ -164,9 +94,8 @@ namespace netgen
}
// global variable mesh (should not be used in libraries)
AutoPtr<Mesh> mesh;
NetgenGeometry * ng_geometry = new NetgenGeometry;
extern NetgenGeometry * ng_geometry;
extern AutoPtr<Mesh> mesh;
Tcl_Interp * tcl_interp;
@ -2011,7 +1940,7 @@ namespace netgen
return TCL_ERROR;
cout << "call Togl - load font (crash on my Linux64)" << endl;
togl_font = Togl_LoadBitmapFont( togl, "Times"); // TOGL_BITMAP_8_BY_13 );
// togl_font = Togl_LoadBitmapFont( togl, "Times"); // TOGL_BITMAP_8_BY_13 );
// togl_font = Togl_LoadBitmapFont( togl, TOGL_BITMAP_8_BY_13 );
// togl_font = Togl_LoadBitmapFont( togl, NULL );
cout << "success" << endl;
@ -2994,7 +2923,7 @@ namespace netgen
// extern "C" int Ng_occ_Init (Tcl_Interp * interp);
#endif
extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp);
// extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp);
// int main_Eero (ClientData clientData,
// Tcl_Interp * interp,
@ -3012,7 +2941,7 @@ namespace netgen
// Ng_stl_Init(interp);
Ng_Geom2d_Init(interp);
// Ng_Geom2d_Init(interp);
tcl_interp = interp;