geometry restructuring

This commit is contained in:
Joachim Schoeberl 2011-01-10 20:18:01 +00:00
parent 7b64ab44e2
commit b95acb082c
75 changed files with 8118 additions and 7152 deletions

View File

@ -7,9 +7,17 @@ revolution.hpp spline3d.hpp
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include
METASOURCES = AUTO METASOURCES = AUTO
noinst_LTLIBRARIES = libcsg.la
noinst_LTLIBRARIES = libcsg.la libcsgvis.la
libcsg_la_SOURCES = algprim.cpp brick.cpp \ libcsg_la_SOURCES = algprim.cpp brick.cpp \
bspline2d.cpp csgeom.cpp csgparser.cpp curve2d.cpp edgeflw.cpp \ bspline2d.cpp csgeom.cpp csgparser.cpp curve2d.cpp edgeflw.cpp \
explicitcurve2d.cpp extrusion.cpp gencyl.cpp genmesh.cpp identify.cpp \ explicitcurve2d.cpp extrusion.cpp gencyl.cpp genmesh.cpp identify.cpp \
manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \ manifold.cpp meshsurf.cpp polyhedra.cpp revolution.cpp singularref.cpp \
solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp solid.cpp specpoin.cpp spline3d.cpp surface.cpp triapprox.cpp
libcsgvis_la_SOURCES = vscsg.cpp csgpkg.cpp

View File

@ -8,6 +8,8 @@
namespace netgen namespace netgen
{ {
int CSGeometry :: changeval = 0; int CSGeometry :: changeval = 0;
@ -132,19 +134,21 @@ namespace netgen
} }
extern int CSGGenerateMesh (CSGeometry & geom, extern int CSGGenerateMesh (CSGeometry & geom,
Mesh *& mesh, int perfstepsstart, int perfstepsend, Mesh *& mesh, MeshingParameters & mparam,
const char * optstr); int perfstepsstart, int perfstepsend);
int CSGeometry :: GenerateMesh (Mesh*& mesh,
int perfstepsstart, int perfstepsend, char* optstring) int CSGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
{ {
return CSGGenerateMesh (*this, mesh, perfstepsstart, perfstepsend, optstring); return CSGGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
} }
const Refinement & CSGeometry :: GetRefinement () const const Refinement & CSGeometry :: GetRefinement () const
{ {
cout << "get CSGeometry - Refinement" << endl;
// should become class variables // should become class variables
RefinementSurfaces * ref = new RefinementSurfaces(*this); RefinementSurfaces * ref = new RefinementSurfaces(*this);
ref -> Set2dOptimizer(new MeshOptimize2dSurfaces(*this)); ref -> Set2dOptimizer(new MeshOptimize2dSurfaces(*this));
@ -182,9 +186,13 @@ namespace netgen
} }
void CSGeometry :: Save (string filename) const
{
fstream ost (filename.c_str());
Save (ost);
}
void CSGeometry :: Save (ostream & ost) void CSGeometry :: Save (ostream & ost) const
{ {
ost << "boundingbox " ost << "boundingbox "
<< boundingbox.PMin()(0) << " " << boundingbox.PMin()(0) << " "
@ -326,7 +334,7 @@ namespace netgen
void CSGeometry :: SaveSurfaces (ostream & out) void CSGeometry :: SaveSurfaces (ostream & out) const
{ {
if(singfaces.Size() > 0 || singedges.Size() > 0 || singpoints.Size() > 0) if(singfaces.Size() > 0 || singedges.Size() > 0 || singpoints.Size() > 0)
{ {
@ -483,6 +491,10 @@ namespace netgen
} }
void CSGeometry :: SaveToMeshFile (ostream & ost) const
{
SaveSurfaces (ost);
}
@ -969,8 +981,7 @@ namespace netgen
void CSGeometry :: void CSGeometry ::
CalcTriangleApproximation(const Box<3> & aboundingbox, CalcTriangleApproximation(double detail, double facets)
double detail, double facets)
{ {
PrintMessage (1, "Calc Triangle Approximation"); PrintMessage (1, "Calc Triangle Approximation");
@ -1011,7 +1022,7 @@ namespace netgen
continue; continue;
TriangleApproximation tas; TriangleApproximation tas;
GetSurface (j) -> GetTriangleApproximation (tas, aboundingbox, facets); GetSurface (j) -> GetTriangleApproximation (tas, boundingbox, facets);
int oldnp = tams -> GetNP(); int oldnp = tams -> GetNP();
@ -1454,7 +1465,7 @@ namespace netgen
void CSGeometry :: void CSGeometry ::
IterateAllSolids (SolidIterator & it, bool only_once) IterateAllSolids (SolidIterator & it, bool only_once) const
{ {
if (only_once) if (only_once)
{ {

View File

@ -150,12 +150,15 @@ namespace netgen
void Clean (); void Clean ();
void Save (ostream & ost); virtual void Save (string filename) const;
void Save (ostream & ost) const;
void Load (istream & ist); void Load (istream & ist);
void SaveSurfaces (ostream & out); void SaveSurfaces (ostream & out) const;
void LoadSurfaces (istream & in); void LoadSurfaces (istream & in);
virtual void SaveToMeshFile (ostream & ost) const;
int GetChangeVal() { return changeval; } int GetChangeVal() { return changeval; }
void Change() { changeval++; } void Change() { changeval++; }
@ -200,10 +203,10 @@ namespace netgen
} }
TopLevelObject * GetTopLevelObject (const Solid * sol, const Surface * surf = NULL); TopLevelObject * GetTopLevelObject (const Solid * sol, const Surface * surf = NULL);
TopLevelObject * GetTopLevelObject (int nr) TopLevelObject * GetTopLevelObject (int nr) const
{ return toplevelobjects[nr]; }
const TopLevelObject * GetTopLevelObject (int nr) const
{ return toplevelobjects[nr]; } { return toplevelobjects[nr]; }
// const TopLevelObject * GetTopLevelObject (int nr) const
// { return toplevelobjects[nr]; }
void RemoveTopLevelObject (Solid * sol, Surface * surf = NULL); void RemoveTopLevelObject (Solid * sol, Surface * surf = NULL);
@ -237,8 +240,7 @@ namespace netgen
/// ///
void CalcTriangleApproximation(const Box<3> & boundingbox, void CalcTriangleApproximation(double detail, double facets);
double detail, double facets);
/// ///
void FindIdenticSurfaces (double eps); void FindIdenticSurfaces (double eps);
@ -270,7 +272,7 @@ namespace netgen
} }
void IterateAllSolids (SolidIterator & it, bool only_once = false); void IterateAllSolids (SolidIterator & it, bool only_once = false) const;
void RefineTriangleApprox (Solid * locsol, void RefineTriangleApprox (Solid * locsol,
int surfind, int surfind,
@ -309,12 +311,16 @@ namespace netgen
Array<BCModification> bcmodifications; Array<BCModification> bcmodifications;
virtual int GenerateMesh (Mesh*& mesh, virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring); int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;
}; };
} }
#endif #endif

703
libsrc/csg/csgpkg.cpp Normal file
View File

@ -0,0 +1,703 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
#include <incvis.hpp>
#include <visual.hpp>
#include "vscsg.hpp"
extern "C" int Ng_CSG_Init (Tcl_Interp * interp);
namespace netgen
{
extern NetgenGeometry * ng_geometry;
extern AutoPtr<Mesh> mesh;
static VisualSceneGeometry vsgeom;
char * err_needscsgeometry = (char*) "This operation needs an CSG geometry";
extern char * err_needsmesh;
extern char * err_jobrunning;
int Ng_ParseGeometry (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * csgeom = dynamic_cast<CSGeometry*> (ng_geometry);
if (csgeom)
{
double detail = atof (Tcl_GetVar (interp, "::geooptions.detail", 0));
double facets = atof (Tcl_GetVar (interp, "::geooptions.facets", 0));
if (atoi (Tcl_GetVar (interp, "::geooptions.drawcsg", 0)))
csgeom->CalcTriangleApproximation(detail, facets);
}
return TCL_OK;
}
int Ng_GeometryOptions (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
const char * command = argv[1];
if (strcmp (command, "get") == 0)
{
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
char buf[20];
Point3d pmin = geometry->BoundingBox ().PMin();
Point3d pmax = geometry->BoundingBox ().PMax();
sprintf (buf, "%5.1lf", pmin.X());
Tcl_SetVar (interp, "::geooptions.minx", buf, 0);
sprintf (buf, "%5.1lf", pmin.Y());
Tcl_SetVar (interp, "::geooptions.miny", buf, 0);
sprintf (buf, "%5.1lf", pmin.Z());
Tcl_SetVar (interp, "::geooptions.minz", buf, 0);
sprintf (buf, "%5.1lf", pmax.X());
Tcl_SetVar (interp, "::geooptions.maxx", buf, 0);
sprintf (buf, "%5.1lf", pmax.Y());
Tcl_SetVar (interp, "::geooptions.maxy", buf, 0);
sprintf (buf, "%5.1lf", pmax.Z());
Tcl_SetVar (interp, "::geooptions.maxz", buf, 0);
}
else if (strcmp (command, "set") == 0)
{
Point<3> pmin (atof (Tcl_GetVar (interp, "::geooptions.minx", 0)),
atof (Tcl_GetVar (interp, "::geooptions.miny", 0)),
atof (Tcl_GetVar (interp, "::geooptions.minz", 0)));
Point<3> pmax (atof (Tcl_GetVar (interp, "::geooptions.maxx", 0)),
atof (Tcl_GetVar (interp, "::geooptions.maxy", 0)),
atof (Tcl_GetVar (interp, "::geooptions.maxz", 0)));
Box<3> box (pmin, pmax);
if (geometry)
geometry -> SetBoundingBox (box);
CSGeometry::SetDefaultBoundingBox (box);
}
return TCL_OK;
}
// attempt of a simple modeller
int Ng_CreatePrimitive (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * classname = argv[1];
tcl_const char * name = argv[2];
cout << "Create primitive, class = " << classname
<< ", name = " << name << endl;
Primitive * nprim = Primitive::CreatePrimitive (classname);
Solid * nsol = new Solid (nprim);
char sname[100];
for (int j = 1; j <= nprim->GetNSurfaces(); j++)
{
sprintf (sname, "%s,%d", name, j);
geometry -> AddSurface (sname, &nprim->GetSurface(j));
nprim -> SetSurfaceId (j, geometry->GetNSurf());
}
geometry->SetSolid (name, nsol);
return TCL_OK;
}
int Ng_SetPrimitiveData (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * name = argv[1];
tcl_const char * value = argv[2];
Array<double> coeffs;
cout << "Set primitive data, name = " << name
<< ", value = " << value << endl;
istringstream vst (value);
double val;
while (!vst.eof())
{
vst >> val;
coeffs.Append (val);
}
((Primitive*)
geometry->GetSolid (name)->GetPrimitive())->SetPrimitiveData (coeffs);
return TCL_OK;
}
int Ng_SetSolidData (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * name = argv[1];
tcl_const char * val = argv[2];
cout << "Set Solid Data, name = " << name
<< ", value = " << val << endl;
istringstream vst (val);
Solid * nsol = Solid::CreateSolid (vst, geometry->GetSolids());
geometry->SetSolid (name, nsol);
return TCL_OK;
}
int Ng_GetPrimitiveData (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * name = argv[1];
tcl_const char * classnamevar = argv[2];
tcl_const char * valuevar = argv[3];
const char * classname;
Array<double> coeffs;
geometry->GetSolid (name)->GetPrimitive()->GetPrimitiveData (classname, coeffs);
ostringstream vst;
for (int i = 1; i <= coeffs.Size(); i++)
vst << coeffs.Get(i) << " ";
cout << "GetPrimitiveData, name = " << name
<< ", classnamevar = " << classnamevar
<< ", classname = " << classname << endl
<< " valuevar = " << valuevar
<< ", values = " << vst.str() << endl;
Tcl_SetVar (interp, classnamevar, (char*)classname, 0);
Tcl_SetVar (interp, valuevar, (char*)vst.str().c_str(), 0);
return TCL_OK;
}
int Ng_GetSolidData (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * name = argv[1];
tcl_const char * valuevar = argv[2];
ostringstream vst;
const Solid * sol = geometry->GetSolid (name);
sol->GetSolidData (vst);
cout << "GetSolidData, name = " << name << ", data = " << vst.str() << endl;
Tcl_SetVar (interp, valuevar, (char*)vst.str().c_str(), 0);
return TCL_OK;
}
int Ng_GetPrimitiveList (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * valuevar = argv[1];
int i;
stringstream vst;
for (i = 1; i <= geometry->GetNSolids(); i++)
{
const Solid * sol = geometry->GetSolid(i);
if (sol->GetPrimitive())
vst << sol->Name() << " ";
}
cout << "primnames = " << vst.str() << endl;
Tcl_SetVar (interp, valuevar, (char*)vst.str().c_str(), 0);
return TCL_OK;
}
int Ng_GetSurfaceList (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * valuevar = argv[1];
int i;
stringstream vst;
for (i = 1; i <= geometry->GetNSurf(); i++)
{
const Surface * surf = geometry->GetSurface(i);
vst << surf->Name() << " ";
}
cout << "surfnames = " << vst.str() << endl;
Tcl_SetVar (interp, valuevar, (char*)vst.str().c_str(), 0);
return TCL_OK;
}
int Ng_GetSolidList (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
tcl_const char * valuevar = argv[1];
int i;
stringstream vst;
for (i = 1; i <= geometry->GetNSolids(); i++)
{
const Solid * sol = geometry->GetSolid(i);
if (!sol->GetPrimitive())
vst << sol->Name() << " ";
}
cout << "solnames = " << vst.str() << endl;
Tcl_SetVar (interp, valuevar, (char*)vst.str().c_str(), 0);
return TCL_OK;
}
int Ng_TopLevel (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
int i;
/*
for (i = 0; i < argc; i++)
cout << argv[i] << ", ";
cout << endl;
*/
if (strcmp (argv[1], "getlist") == 0)
{
stringstream vst;
for (i = 0; i < geometry->GetNTopLevelObjects(); i++)
{
const Solid * sol;
const Surface * surf;
geometry->GetTopLevelObject (i, sol, surf);
if (!surf)
vst << "{ " << sol->Name() << " } ";
else
vst << "{ " << sol->Name() << " " << surf->Name() << " } ";
}
tcl_const char * valuevar = argv[2];
Tcl_SetVar (interp, valuevar, (char*)vst.str().c_str(), 0);
}
if (strcmp (argv[1], "set") == 0)
{
tcl_const char * solname = argv[2];
tcl_const char * surfname = argv[3];
Solid * sol = (Solid*)geometry->GetSolid (solname);
Surface * surf = (Surface*)geometry->GetSurface (surfname);
geometry->SetTopLevelObject (sol, surf);
}
if (strcmp (argv[1], "remove") == 0)
{
tcl_const char * solname = argv[2];
tcl_const char * surfname = argv[3];
Solid * sol = (Solid*)geometry->GetSolid (solname);
Surface * surf = (Surface*)geometry->GetSurface (surfname);
geometry->RemoveTopLevelObject (sol, surf);
}
if (strcmp (argv[1], "setprop") == 0)
{
tcl_const char * solname = argv[2];
tcl_const char * surfname = argv[3];
tcl_const char * propvar = argv[4];
Solid * sol = (Solid*)geometry->GetSolid (solname);
Surface * surf = (Surface*)geometry->GetSurface (surfname);
TopLevelObject * tlo = geometry->GetTopLevelObject (sol, surf);
if (!tlo) return TCL_OK;
char varname[50];
sprintf (varname, "%s(red)", propvar);
double red = atof (Tcl_GetVar (interp, varname, 0));
sprintf (varname, "%s(blue)", propvar);
double blue = atof (Tcl_GetVar (interp, varname, 0));
sprintf (varname, "%s(green)", propvar);
double green = atof (Tcl_GetVar (interp, varname, 0));
tlo -> SetRGB (red, green, blue);
sprintf (varname, "%s(visible)", propvar);
tlo -> SetVisible (bool(atoi (Tcl_GetVar (interp, varname, 0))));
sprintf (varname, "%s(transp)", propvar);
tlo -> SetTransparent (bool(atoi (Tcl_GetVar (interp, varname, 0))));
}
if (strcmp (argv[1], "getprop") == 0)
{
tcl_const char * solname = argv[2];
tcl_const char * surfname = argv[3];
tcl_const char * propvar = argv[4];
Solid * sol = (Solid*)geometry->GetSolid (solname);
Surface * surf = (Surface*)geometry->GetSurface (surfname);
TopLevelObject * tlo = geometry->GetTopLevelObject (sol, surf);
if (!tlo) return TCL_OK;
char varname[50], varval[10];
sprintf (varname, "%s(red)", propvar);
sprintf (varval, "%lf", tlo->GetRed());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(green)", propvar);
sprintf (varval, "%lf", tlo->GetGreen());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(blue)", propvar);
sprintf (varval, "%lf", tlo->GetBlue());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(visible)", propvar);
sprintf (varval, "%d", tlo->GetVisible());
Tcl_SetVar (interp, varname, varval, 0);
sprintf (varname, "%s(transp)", propvar);
sprintf (varval, "%d", tlo->GetTransparent());
Tcl_SetVar (interp, varname, varval, 0);
}
return TCL_OK;
}
int Ng_SingularEdgeMS (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
if (!mesh.Ptr())
{
Tcl_SetResult (interp, err_needsmesh, TCL_STATIC);
return TCL_ERROR;
}
if (multithread.running)
{
Tcl_SetResult (interp, err_jobrunning, TCL_STATIC);
return TCL_ERROR;
}
double globh = mparam.maxh;
for (int i = 1; i <= geometry->singedges.Size(); i++)
geometry->singedges.Get(i)->SetMeshSize (*mesh, globh);
return TCL_OK;
}
int Ng_SingularPointMS (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (!geometry)
{
Tcl_SetResult (interp, err_needscsgeometry, TCL_STATIC);
return TCL_ERROR;
}
double globh = mparam.maxh;
for (int i = 1; i <= geometry->singpoints.Size(); i++)
geometry->singpoints.Get(i)->SetMeshSize (*mesh, globh);
return TCL_OK;
}
int Ng_SelectSurface (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
int surfnr = atoi (argv[1]);
vsgeom.SelectSurface (surfnr);
return TCL_OK;
}
class CSGeometryRegister : public GeometryRegister
{
public:
virtual NetgenGeometry * Load (string filename) const;
virtual NetgenGeometry * LoadFromMeshFile (istream & ist) const;
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
};
NetgenGeometry * CSGeometryRegister :: Load (string filename) const
{
const char * cfilename = filename.c_str();
if (strcmp (&cfilename[strlen(cfilename)-3], "geo") == 0)
{
PrintMessage (1, "Load CSG geometry file ", cfilename);
extern CSGeometry * ParseCSG (istream & istr);
ifstream infile(cfilename);
CSGeometry * hgeom = ParseCSG (infile);
if (!hgeom)
throw NgException ("geo-file should start with 'algebraic3d'");
hgeom -> FindIdenticSurfaces(1e-8 * hgeom->MaxSize());
return hgeom;
}
if (strcmp (&cfilename[strlen(cfilename)-3], "ngg") == 0)
{
PrintMessage (1, "Load new CSG geometry file ", cfilename);
ifstream infile(cfilename);
CSGeometry * hgeom = new CSGeometry("");
hgeom -> Load (infile);
return hgeom;
}
return NULL;
}
NetgenGeometry * CSGeometryRegister :: LoadFromMeshFile (istream & ist) const
{
string auxstring;
if (ist.good())
{
ist >> auxstring;
if (auxstring == "csgsurfaces")
{
CSGeometry * geometry = new CSGeometry ("");
geometry -> LoadSurfaces(ist);
return geometry;
}
// else
// ist.putback (auxstring);
}
return NULL;
}
VisualScene * CSGeometryRegister :: GetVisualScene (const NetgenGeometry * geom) const
{
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (geometry)
{
vsgeom.SetGeometry (geometry);
return &vsgeom;
}
return NULL;
}
}
using namespace netgen;
int Ng_CSG_Init (Tcl_Interp * interp)
{
geometryregister.Append (new CSGeometryRegister);
Tcl_CreateCommand (interp, "Ng_ParseGeometry", Ng_ParseGeometry,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
// geometry
Tcl_CreateCommand (interp, "Ng_CreatePrimitive", Ng_CreatePrimitive,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_SetPrimitiveData", Ng_SetPrimitiveData,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_GetPrimitiveData", Ng_GetPrimitiveData,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_GetPrimitiveList", Ng_GetPrimitiveList,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_GetSurfaceList", Ng_GetSurfaceList,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_SetSolidData", Ng_SetSolidData,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_GetSolidData", Ng_GetSolidData,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_GetSolidList", Ng_GetSolidList,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_TopLevel", Ng_TopLevel,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_GeometryOptions", Ng_GeometryOptions,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_SingularEdgeMS", Ng_SingularEdgeMS,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_SingularPointMS", Ng_SingularPointMS,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_SelectSurface", Ng_SelectSurface,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
return TCL_OK;
}

View File

@ -653,14 +653,9 @@ namespace netgen
int CSGGenerateMesh (CSGeometry & geom,
Mesh *& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
int CSGGenerateMesh (CSGeometry & geom,
Mesh *& mesh,
int perfstepsstart, int perfstepsend,
const char * optstr)
{ {
if (mesh && mesh->GetNSE() && if (mesh && mesh->GetNSE() &&
!geom.GetNSolids()) !geom.GetNSolids())

View File

@ -134,7 +134,7 @@ PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi) Point<3> & newp, PointGeomInfo & newgi) const
{ {
Point<3> hnewp; Point<3> hnewp;
hnewp = p1+secpoint*(p2-p1); hnewp = p1+secpoint*(p2-p1);
@ -152,7 +152,7 @@ PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi) Point<3> & newp, EdgePointGeomInfo & newgi) const
{ {
Point<3> hnewp = p1+secpoint*(p2-p1); Point<3> hnewp = p1+secpoint*(p2-p1);
//(*testout) << "hnewp " << hnewp << " s1 " << surfi1 << " s2 " << surfi2 << endl; //(*testout) << "hnewp " << hnewp << " s1 " << surfi1 << " s2 " << surfi2 << endl;
@ -192,7 +192,7 @@ Vec<3> RefinementSurfaces :: GetNormal (const Point<3> & p, int surfi1,
void RefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) void RefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
{ {
if (surfi != -1) if (surfi != -1)
geometry.GetSurface (surfi) -> Project (p); geometry.GetSurface (surfi) -> Project (p);

View File

@ -69,13 +69,13 @@ namespace netgen
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi); Point<3> & newp, PointGeomInfo & newgi) const;
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi); Point<3> & newp, EdgePointGeomInfo & newgi) const;
virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1) const; const EdgePointGeomInfo & ap1) const;
@ -84,7 +84,7 @@ namespace netgen
const PointGeomInfo & gi) const; const PointGeomInfo & gi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi); virtual void ProjectToSurface (Point<3> & p, int surfi) const;
virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, const EdgePointGeomInfo & egi) const; virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, const EdgePointGeomInfo & egi) const;

537
libsrc/csg/vscsg.cpp Normal file
View File

@ -0,0 +1,537 @@
#include <mystdlib.h>
#include "incvis.hpp"
#include <myadt.hpp>
#include <meshing.hpp>
#include <csg.hpp>
#include <stlgeom.hpp>
#include <visual.hpp>
#include "vscsg.hpp"
namespace netgen
{
/* *********************** Draw Geometry **************** */
extern AutoPtr<Mesh> mesh;
extern Array<SpecialPoint> specpoints;
extern Array<Box<3> > boxes;
extern Array<Point<3> > project1, project2;
// extern AutoPtr<CSGeometry> geometry;
VisualSceneGeometry :: VisualSceneGeometry ()
: VisualScene()
{
selsurf = 0;
}
VisualSceneGeometry :: ~VisualSceneGeometry ()
{
;
}
void VisualSceneGeometry :: SelectSurface (int aselsurf)
{
selsurf = aselsurf;
DrawScene();
}
void VisualSceneGeometry :: DrawScene ()
{
int i;
if (changeval != geometry->GetChangeVal())
BuildScene();
changeval = geometry->GetChangeVal();
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetLight();
glPushMatrix();
glMultMatrixf (transformationmat);
SetClippingPlane ();
glShadeModel (GL_SMOOTH);
glDisable (GL_COLOR_MATERIAL);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
/*
float mat_spec_col[] = { 1, 1, 1, 1 };
glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, mat_spec_col);
*/
double shine = vispar.shininess;
double transp = vispar.transp;
glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine);
glLogicOp (GL_COPY);
glEnable (GL_NORMALIZE);
for (i = 0; i < geometry->GetNTopLevelObjects(); i++)
{
const TopLevelObject * tlo = geometry -> GetTopLevelObject (i);
if (tlo->GetVisible() && !tlo->GetTransparent())
{
float mat_col[] = { tlo->GetRed(), tlo->GetGreen(), tlo->GetBlue(), 1 };
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
glCallList (trilists[i]);
}
}
glPolygonOffset (1, 1);
glEnable (GL_POLYGON_OFFSET_FILL);
glLogicOp (GL_NOOP);
for (i = 0; i < geometry->GetNTopLevelObjects(); i++)
{
const TopLevelObject * tlo = geometry -> GetTopLevelObject (i);
if (tlo->GetVisible() && tlo->GetTransparent())
{
float mat_col[] = { tlo->GetRed(), tlo->GetGreen(), tlo->GetBlue(), transp };
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
glCallList (trilists[i]);
}
}
glDisable (GL_POLYGON_OFFSET_FILL);
/*
cout << "draw " << project1.Size() << " lines " << endl;
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
glLineWidth (1.0f);
glEnable (GL_COLOR_MATERIAL);
glColor3f (1.0f, 0.0f, 0.0f);
glBegin (GL_LINES);
for (int i = 0; i < project1.Size(); i++)
{
glVertex3dv (project1[i]);
glVertex3dv (project2[i]);
}
glEnd();
*/
glPopMatrix();
glDisable(GL_CLIP_PLANE0);
/*
glFlush();
int err;
do
{
err = glGetError();
// cout << "glerr,1 = " << err << endl;
}
while (err != GL_NO_ERROR);
// CreateTexture (0, 1, GL_DECAL);
CreateTexture (0, 1, GL_MODULATE);
glEnable (GL_TEXTURE_1D);
float mat_col[] = { 1.0, 1.0, 1.0 };
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
glDisable (GL_BLEND);
glDisable (GL_COLOR_MATERIAL);
glEnable (GL_NORMALIZE);
if (geometry->GetNTopLevelObjects())
{
cout << "call list" << endl;
glCallList (trilists[0]);
}
glColor3d (1.0, 1.0, 1.0);
glBegin (GL_TRIANGLES);
glNormal3f (0, 0, 1);
SetOpenGlColor (-1.0, 0, 1, 0);
glVertex3f (0.0, 0.0, 0.0);
SetOpenGlColor (0.5, 0, 1, 0);
glNormal3f (0, 0, 1);
glVertex3f (1.0, 0.0, 0.0);
SetOpenGlColor (2.0, 0, 1, 0);
glNormal3f (0, 0, 1);
glVertex3f (0.0, 1.0, 0.0);
glEnd ();
cout << "trig drawn" << endl;
glDisable (GL_TEXTURE_1D);
glDisable (GL_COLOR_MATERIAL);
glFlush();
cout << "glerr,2 = " << glGetError() << endl;
*/
DrawCoordinateCross ();
DrawNetgenLogo ();
glFinish();
}
void VisualSceneGeometry :: BuildScene (int zoomall)
{
Box<3> box;
int hasp = 0;
for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
{
const TriangleApproximation & ta =
*geometry->GetTriApprox(i);
if (!&ta) continue;
for (int j = 0; j < ta.GetNP(); j++)
{
if (hasp)
box.Add (ta.GetPoint(j));
else
{
hasp = 1;
box.Set (ta.GetPoint(j));
}
}
}
if (hasp)
{
center = box.Center();
rad = box.Diam() / 2;
}
else
{
center = Point3d(0,0,0);
rad = 1;
}
CalcTransformationMatrices();
for (int i = 0; i < trilists.Size(); i++)
glDeleteLists (trilists[i], 1);
trilists.SetSize(0);
for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
{
trilists.Append (glGenLists (1));
glNewList (trilists.Last(), GL_COMPILE);
glEnable (GL_NORMALIZE);
const TriangleApproximation & ta =
*geometry->GetTriApprox(i);
if (&ta)
{
glBegin (GL_TRIANGLES);
for (int j = 0; j < ta.GetNT(); j++)
{
for (int k = 0; k < 3; k++)
{
int pi = ta.GetTriangle(j)[k];
glNormal3dv (ta.GetNormal (pi));
glVertex3dv (ta.GetPoint(pi));
}
}
glEnd ();
}
glEndList ();
}
}
VisualSceneSpecPoints :: VisualSceneSpecPoints ()
: VisualScene()
{
;
}
VisualSceneSpecPoints :: ~VisualSceneSpecPoints ()
{
;
}
void VisualSceneSpecPoints :: DrawScene ()
{
if (!mesh)
{
VisualScene::DrawScene();
return;
}
if (changeval != specpoints.Size())
BuildScene();
changeval = specpoints.Size();
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable (GL_COLOR_MATERIAL);
glColor3f (1.0f, 1.0f, 1.0f);
glLineWidth (1.0f);
glPushMatrix();
glMultMatrixf (transformationmat);
// glEnable (GL_COLOR);
// glDisable (GL_COLOR_MATERIAL);
if (vispar.drawedtangents)
{
glColor3d (1, 0, 0);
glBegin (GL_LINES);
for (int i = 1; i <= specpoints.Size(); i++)
{
const Point3d p1 = specpoints.Get(i).p;
const Point3d p2 = specpoints.Get(i).p + len * specpoints.Get(i).v;
glVertex3d (p1.X(), p1.Y(), p1.Z());
glVertex3d (p2.X(), p2.Y(), p2.Z());
}
glEnd();
}
if (vispar.drawededges)
{
glColor3d (1, 0, 0);
glBegin (GL_LINES);
for (int i = 1; i <= mesh->GetNSeg(); i++)
{
const Segment & seg = mesh -> LineSegment (i);
glVertex3dv ( (*mesh)[seg[0]] );
glVertex3dv ( (*mesh)[seg[1]] );
// glVertex3dv ( &(*mesh)[seg[0]].X() );
// glVertex3dv ( &(*mesh)[seg[1]].X() );
}
glEnd();
}
glColor3d (1, 0, 0);
glBegin (GL_LINES);
for (int i = 0; i < boxes.Size(); i++)
{
glVertex3dv ( boxes[i].PMin() );
glVertex3dv ( boxes[i].PMax() );
}
glEnd();
if (vispar.drawededgenrs)
{
glEnable (GL_COLOR_MATERIAL);
GLfloat textcol[3] = { 1 - backcolor,
1 - backcolor,
1 - backcolor };
glColor3fv (textcol);
glNormal3d (0, 0, 1);
glPushAttrib (GL_LIST_BIT);
// glListBase (fontbase);
char buf[20];
for (int i = 1; i <= mesh->GetNSeg(); i++)
{
const Segment & seg = mesh -> LineSegment (i);
const Point3d p1 = mesh -> Point (seg[0]);
const Point3d p2 = mesh -> Point (seg[1]);
const Point3d p = Center (p1, p2);
glRasterPos3d (p.X(), p.Y(), p.Z());
sprintf (buf, "%d", seg.edgenr);
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf);
}
glPopAttrib ();
glDisable (GL_COLOR_MATERIAL);
}
if (vispar.drawedpoints)
{
glColor3d (0, 0, 1);
/*
glPointSize( 3.0 );
float range[2];
glGetFloatv(GL_POINT_SIZE_RANGE, &range[0]);
cout << "max ptsize = " << range[0] << "-" << range[1] << endl;
glBegin( GL_POINTS );
for (int i = 1; i <= mesh -> GetNP(); i++)
{
const Point3d & p = mesh -> Point(i);
if (i % 2)
glVertex3f( p.X(), p.Y(), p.Z());
}
glEnd();
*/
static GLubyte knoedel[] =
{
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
};
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDisable (GL_COLOR_MATERIAL);
glDisable (GL_LIGHTING);
glDisable (GL_CLIP_PLANE0);
for (int i = 1; i <= mesh -> GetNP(); i++)
{
const Point3d & p = mesh -> Point(i);
glRasterPos3d (p.X(), p.Y(), p.Z());
glBitmap (7, 7, 3, 3, 0, 0, &knoedel[0]);
}
}
if (vispar.drawedpointnrs)
{
glEnable (GL_COLOR_MATERIAL);
GLfloat textcol[3] = { 1 - backcolor,
1 - backcolor,
1 - backcolor };
glColor3fv (textcol);
glNormal3d (0, 0, 1);
glPushAttrib (GL_LIST_BIT);
// glListBase (fontbase);
char buf[20];
for (int i = 1; i <= mesh->GetNP(); i++)
{
const Point3d & p = mesh->Point(i);
glRasterPos3d (p.X(), p.Y(), p.Z());
sprintf (buf, "%d", i);
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf);
}
glPopAttrib ();
glDisable (GL_COLOR_MATERIAL);
}
glPopMatrix();
if (vispar.drawcoordinatecross)
DrawCoordinateCross ();
DrawNetgenLogo ();
glFinish();
}
void VisualSceneSpecPoints :: BuildScene (int zoomall)
{
if (!mesh)
{
VisualScene::BuildScene(zoomall);
return;
}
Box3d box;
if (mesh->GetNSeg())
{
box.SetPoint (mesh->Point (mesh->LineSegment(1)[0]));
for (int i = 1; i <= mesh->GetNSeg(); i++)
{
box.AddPoint (mesh->Point (mesh->LineSegment(i)[0]));
box.AddPoint (mesh->Point (mesh->LineSegment(i)[1]));
}
}
else if (specpoints.Size() >= 2)
{
box.SetPoint (specpoints.Get(1).p);
for (int i = 2; i <= specpoints.Size(); i++)
box.AddPoint (specpoints.Get(i).p);
}
else
{
box = Box3d (Point3d (0,0,0), Point3d (1,1,1));
}
if (zoomall == 2 && ((vispar.centerpoint >= 1 && vispar.centerpoint <= mesh->GetNP()) ||
vispar.use_center_coords))
{
if (vispar.use_center_coords)
{
center.X() = vispar.centerx; center.Y() = vispar.centery; center.Z() = vispar.centerz;
}
else
center = mesh->Point (vispar.centerpoint);
}
else
center = Center (box.PMin(), box.PMax());
rad = 0.5 * Dist (box.PMin(), box.PMax());
CalcTransformationMatrices();
}
}

34
libsrc/csg/vscsg.hpp Normal file
View File

@ -0,0 +1,34 @@
#ifndef FILE_VSCSG
#define FILE_VSCSG
/**************************************************************************/
/* File: vscsg.hpp */
/* Author: Joachim Schoeberl */
/* Date: 05. Jan. 2011 */
/**************************************************************************/
namespace netgen
{
class VisualSceneGeometry : public VisualScene
{
class CSGeometry * geometry;
Array<int> trilists;
int selsurf;
public:
VisualSceneGeometry ();
virtual ~VisualSceneGeometry ();
void SetGeometry (class CSGeometry * ageometry) { geometry = ageometry; }
virtual void SelectSurface (int aselsurf);
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
};
}
#endif

View File

@ -43,19 +43,6 @@ namespace netgen
int Begin() const { return BASE; } int Begin() const { return BASE; }
int End() const { return size+BASE; } int End() const { return size+BASE; }
/*
/// access array.
T & operator[] (int i)
{
#ifdef DEBUG
if (i-BASE < 0 || i-BASE >= size)
cout << "array<" << typeid(T).name() << "> out of range, i = " << i << ", s = " << size << endl;
#endif
return data[i-BASE];
}
*/
/// Access array. BASE-based /// Access array. BASE-based
T & operator[] (int i) const T & operator[] (int i) const
{ {
@ -67,12 +54,6 @@ namespace netgen
return data[i-BASE]; return data[i-BASE];
} }
/*
template <int B2>
IndirectArray<T, BASE, B2> operator[] (const FlatArray<int, B2> & ind)
{ return IndirectArray<T, BASE, B2> (*this, ind); }
*/
/// Access array, one-based (old fashioned) /// Access array, one-based (old fashioned)
T & Elem (int i) T & Elem (int i)
{ {
@ -110,8 +91,6 @@ namespace netgen
((T*)data)[i-1] = el; ((T*)data)[i-1] = el;
} }
/// access first element /// access first element
T & First () const T & First () const
{ {
@ -180,6 +159,9 @@ namespace netgen
class Array : public FlatArray<T, BASE> class Array : public FlatArray<T, BASE>
{ {
protected: protected:
using FlatArray<T,BASE>::size;
using FlatArray<T,BASE>::data;
/// physical size of array /// physical size of array
int allocsize; int allocsize;
/// memory is responsibility of container /// memory is responsibility of container
@ -207,9 +189,9 @@ namespace netgen
explicit Array (const Array<T> & a2) explicit Array (const Array<T> & a2)
: FlatArray<T, BASE> (a2.Size(), a2.Size() ? new T[a2.Size()] : 0) : FlatArray<T, BASE> (a2.Size(), a2.Size() ? new T[a2.Size()] : 0)
{ {
allocsize = this->size; allocsize = size;
ownmem = 1; ownmem = 1;
for (int i = BASE; i < this->size+BASE; i++) for (int i = BASE; i < size+BASE; i++)
(*this)[i] = a2[i]; (*this)[i] = a2[i];
} }
@ -219,7 +201,7 @@ namespace netgen
~Array() ~Array()
{ {
if (ownmem) if (ownmem)
delete [] this->data; delete [] data;
} }
/// Change logical size. If necessary, do reallocation. Keeps contents. /// Change logical size. If necessary, do reallocation. Keeps contents.
@ -227,7 +209,7 @@ namespace netgen
{ {
if (nsize > allocsize) if (nsize > allocsize)
ReSize (nsize); ReSize (nsize);
this->size = nsize; size = nsize;
} }
/// Change physical size. Keeps logical size. Keeps contents. /// Change physical size. Keeps logical size. Keeps contents.
@ -241,36 +223,24 @@ namespace netgen
/// Add element at end of array. reallocation if necessary. /// Add element at end of array. reallocation if necessary.
int Append (const T & el) int Append (const T & el)
{ {
if (this->size == allocsize) if (size == allocsize)
ReSize (this->size+1); ReSize (size+1);
this->data[this->size] = el; data[size] = el;
this->size++; size++;
return this->size; return size;
} }
template <typename T2, int B2> template <typename T2, int B2>
void Append (FlatArray<T2, B2> a2) void Append (FlatArray<T2, B2> a2)
{ {
if (this->size+a2.Size() > allocsize) if (size+a2.Size() > allocsize)
ReSize (this->size+a2.Size()); ReSize (size+a2.Size());
for (int i = 0; i < a2.Size(); i++) for (int i = 0; i < a2.Size(); i++)
this->data[this->size+i] = a2[i+B2]; data[size+i] = a2[i+B2];
this->size += a2.Size(); size += a2.Size();
} }
/*
template <int B1, int B2>
void Append (const IndirectArray<T,B1,B2> & a2)
{
if (this->size+a2.Size() > allocsize)
ReSize (this->size+a2.Size());
for (int i = 0; i < a2.Size(); i++)
this->data[this->size+i] = a2[i+B2];
this->size += a2.Size();
}
*/
/// Delete element i (0-based). Move last element to position i. /// Delete element i (0-based). Move last element to position i.
void Delete (int i) void Delete (int i)
{ {
@ -278,8 +248,8 @@ namespace netgen
RangeCheck (i+1); RangeCheck (i+1);
#endif #endif
this->data[i] = this->data[this->size-1]; data[i] = data[size-1];
this->size--; size--;
// DeleteElement (i+1); // DeleteElement (i+1);
} }
@ -291,23 +261,23 @@ namespace netgen
RangeCheck (i); RangeCheck (i);
#endif #endif
this->data[i-1] = this->data[this->size-1]; data[i-1] = data[size-1];
this->size--; size--;
} }
/// Delete last element. /// Delete last element.
void DeleteLast () void DeleteLast ()
{ {
this->size--; size--;
} }
/// Deallocate memory /// Deallocate memory
void DeleteAll () void DeleteAll ()
{ {
if (ownmem) if (ownmem)
delete [] this->data; delete [] data;
this->data = 0; data = 0;
this->size = allocsize = 0; size = allocsize = 0;
} }
/// Fill array with val /// Fill array with val
@ -321,7 +291,7 @@ namespace netgen
Array & operator= (const Array & a2) Array & operator= (const Array & a2)
{ {
SetSize (a2.Size()); SetSize (a2.Size());
for (int i = BASE; i < this->size+BASE; i++) for (int i = BASE; i < size+BASE; i++)
(*this)[i] = a2[i]; (*this)[i] = a2[i];
return *this; return *this;
} }
@ -330,7 +300,7 @@ namespace netgen
Array & operator= (const FlatArray<T> & a2) Array & operator= (const FlatArray<T> & a2)
{ {
SetSize (a2.Size()); SetSize (a2.Size());
for (int i = BASE; i < this->size+BASE; i++) for (int i = BASE; i < size+BASE; i++)
(*this)[i] = a2[i]; (*this)[i] = a2[i];
return *this; return *this;
} }
@ -344,21 +314,21 @@ namespace netgen
int nsize = 2 * allocsize; int nsize = 2 * allocsize;
if (nsize < minsize) nsize = minsize; if (nsize < minsize) nsize = minsize;
if (this->data) if (data)
{ {
T * p = new T[nsize]; T * p = new T[nsize];
int mins = (nsize < this->size) ? nsize : this->size; int mins = (nsize < size) ? nsize : size;
memcpy (p, this->data, mins * sizeof(T)); memcpy (p, data, mins * sizeof(T));
if (ownmem) if (ownmem)
delete [] this->data; delete [] data;
ownmem = 1; ownmem = 1;
this->data = p; data = p;
} }
else else
{ {
this->data = new T[nsize]; data = new T[nsize];
ownmem = 1; ownmem = 1;
} }
@ -371,6 +341,10 @@ namespace netgen
template <class T, int S> template <class T, int S>
class ArrayMem : public Array<T> class ArrayMem : public Array<T>
{ {
using Array<T>::size;
using Array<T>::data;
using Array<T>::ownmem;
// T mem[S]; // Intel C++ calls dummy constructor // T mem[S]; // Intel C++ calls dummy constructor
// char mem[S*sizeof(T)]; // char mem[S*sizeof(T)];
double mem[(S*sizeof(T)+7) / 8]; double mem[(S*sizeof(T)+7) / 8];
@ -379,13 +353,13 @@ namespace netgen
explicit ArrayMem(int asize = 0) explicit ArrayMem(int asize = 0)
: Array<T> (S, static_cast<T*> (static_cast<void*>(&mem[0]))) : Array<T> (S, static_cast<T*> (static_cast<void*>(&mem[0])))
{ {
this->size = asize; size = asize;
if (asize > S) if (asize > S)
{ {
this->data = new T[asize]; data = new T[asize];
this->ownmem = 1; ownmem = 1;
} }
// this->SetSize (asize); // SetSize (asize);
} }
ArrayMem & operator= (const T & val) ArrayMem & operator= (const T & val)
@ -398,7 +372,7 @@ namespace netgen
ArrayMem & operator= (const FlatArray<T> & a2) ArrayMem & operator= (const FlatArray<T> & a2)
{ {
SetSize (a2.Size()); SetSize (a2.Size());
for (int i = 0; i < this->size; i++) for (int i = 0; i < size; i++)
(*this)[i] = a2[i]; (*this)[i] = a2[i];
return *this; return *this;
} }

View File

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

View File

@ -24,7 +24,7 @@ namespace netgen
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi) Point<3> & newp, PointGeomInfo & newgi) const
{ {
newp = p1+secpoint*(p2-p1); newp = p1+secpoint*(p2-p1);
newgi.trignum = 1; newgi.trignum = 1;
@ -37,7 +37,7 @@ namespace netgen
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi) Point<3> & newp, EdgePointGeomInfo & newgi) const
{ {
Point<2> p2d; Point<2> p2d;
@ -68,7 +68,7 @@ namespace netgen
} }
void Refinement2d :: ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */) void Refinement2d :: ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */) const
{ {
p(2) = 0; p(2) = 0;
} }

View File

@ -23,13 +23,13 @@ namespace netgen
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi); Point<3> & newp, PointGeomInfo & newgi) const;
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi); Point<3> & newp, EdgePointGeomInfo & newgi) const;
virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2,
@ -38,7 +38,7 @@ namespace netgen
virtual Vec<3> GetNormal (const Point<3> & p, int surfi1, virtual Vec<3> GetNormal (const Point<3> & p, int surfi1,
const PointGeomInfo & gi) const; const PointGeomInfo & gi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */); virtual void ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */) const;
virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & egi) const; const EdgePointGeomInfo & egi) const;

View File

@ -0,0 +1,71 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
#include <incvis.hpp>
#include <visual.hpp>
#include "vsgeom2d.hpp"
extern "C" int Ng_CSG_Init (Tcl_Interp * interp);
namespace netgen
{
extern NetgenGeometry * ng_geometry;
static VisualSceneGeometry2d vsgeom2d;
class SplineGeometryRegister : public GeometryRegister
{
public:
virtual NetgenGeometry * Load (string filename) const;
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
};
NetgenGeometry * SplineGeometryRegister :: Load (string filename) const
{
const char * cfilename = filename.c_str();
if (strcmp (&cfilename[strlen(cfilename)-4], "in2d") == 0)
{
PrintMessage (1, "Load 2D-Spline geometry file ", cfilename);
ifstream infile(cfilename);
SplineGeometry2d * hgeom = new SplineGeometry2d();
hgeom -> Load (cfilename);
return hgeom;
}
return NULL;
}
VisualScene * SplineGeometryRegister :: GetVisualScene (const NetgenGeometry * geom) const
{
SplineGeometry2d * geometry = dynamic_cast<SplineGeometry2d*> (ng_geometry);
if (geometry)
{
vsgeom2d.SetGeometry (geometry);
return &vsgeom2d;
}
return NULL;
}
}
using namespace netgen;
extern "C" int Ng_Geom2d_Init (Tcl_Interp * interp);
int Ng_Geom2d_Init (Tcl_Interp * interp)
{
geometryregister.Append (new SplineGeometryRegister);
}

View File

@ -1260,15 +1260,22 @@ SplineGeometry2d :: ~SplineGeometry2d()
} }
int SplineGeometry2d :: GenerateMesh (Mesh*& mesh, extern void MeshFromSpline2D (SplineGeometry2d & geometry,
int perfstepsstart, int perfstepsend, char* optstring) Mesh *& mesh,
MeshingParameters & mp);
int SplineGeometry2d :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
{ {
cout << "SplineGeometry2d::GenerateMesh : only a dummy" << endl; cout << "SplineGeometry2d::GenerateMesh not only a dummy" << endl;
MeshFromSpline2D (*this, mesh, mparam);
return 0; return 0;
} }
const Refinement & SplineGeometry2d :: GetRefinement () const Refinement & SplineGeometry2d :: GetRefinement () const
{ {
return * new Refinement2d (*this); return * new Refinement2d (*this);
} }

View File

@ -137,11 +137,11 @@ namespace netgen
}; };
/*
void MeshFromSpline2D (SplineGeometry<2> & geometry, void MeshFromSpline2D (SplineGeometry<2> & geometry,
Mesh *& mesh, Mesh *& mesh,
MeshingParameters & mp); MeshingParameters & mp);
*/
class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry
@ -149,10 +149,10 @@ namespace netgen
public: public:
virtual ~SplineGeometry2d(); virtual ~SplineGeometry2d();
virtual int GenerateMesh (Mesh*& mesh, virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring); int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual Refinement & GetRefinement () const;
}; };
} }

126
libsrc/geom2d/vsgeom2d.cpp Normal file
View File

@ -0,0 +1,126 @@
#include <mystdlib.h>
#include "incvis.hpp"
#include <myadt.hpp>
#include <meshing.hpp>
#include <csg.hpp>
#include <stlgeom.hpp>
#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++)
{
geometry2d->GetSplines().Get(i)->GetPoints (20, points);
glBegin (GL_LINE_STRIP);
for (int j = 0; j < points.Size(); j++)
glVertex3f (points[j](0), points[j](1), 0);
glEnd();
}
glColor3f (1, 0, 0);
for (int i = 1; i <= geometry2d->GetSplines().Size(); i++)
{
int other = geometry2d->GetSplines().Get(i)->copyfrom;
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++)
{
glVertex3f (points[j](0), points[j](1), 0);
glVertex3f (otherpoints[j](0), otherpoints[j](1), 0);
}
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();
}
}

View File

@ -0,0 +1,31 @@
#ifndef FILE_VSGEOM2D
#define FILE_VSGEOM2D
/**************************************************************************/
/* File: vsgeom2d.hpp */
/* Author: Joachim Schoeberl */
/* Date: 05. Jan. 2011 */
/**************************************************************************/
namespace netgen
{
class VisualSceneGeometry2d : public VisualScene
{
const class SplineGeometry2d * geometry2d;
public:
VisualSceneGeometry2d ();
virtual ~VisualSceneGeometry2d ();
void SetGeometry (const class SplineGeometry2d * ageometry2d) { geometry2d = ageometry2d; }
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
};
}
#endif

View File

@ -3,9 +3,6 @@
#include <tcl.h> #include <tcl.h>
#include <tk.h> #include <tk.h>
// #include "/opt/tcltk86/include/tcl.h"
// #include "/opt/tcltk86/include/tk.h"
#if TK_MAJOR_VERSION==8 && TK_MINOR_VERSION>=4 #if TK_MAJOR_VERSION==8 && TK_MINOR_VERSION>=4
#define tcl_const const #define tcl_const const
@ -38,3 +35,5 @@
#define GL_CLAMP_TO_EDGE 0x812F #define GL_CLAMP_TO_EDGE 0x812F
#endif #endif

View File

@ -62,7 +62,7 @@ namespace netgen
public: public:
NG_ELEMENT_TYPE type; NG_ELEMENT_TYPE type;
NG_ELEMENT_TYPE GetType() const { return type; } NG_ELEMENT_TYPE GetType() const { return type; }
Ng_Points points; // all points Ng_Points points; // all points
Ng_Vertices vertices; Ng_Vertices vertices;
Ng_Edges edges; Ng_Edges edges;

View File

@ -173,6 +173,7 @@ namespace netgen
else if (token == "MATERIALS") else if (token == "MATERIALS")
{ {
*testout << "parse materials" << endl;
Array<double> young_modulus, poisson_ratio, mass_density; Array<double> young_modulus, poisson_ratio, mass_density;
while (1) while (1)
@ -198,6 +199,7 @@ namespace netgen
else else
{ {
sbuf >> val; sbuf >> val;
*testout << "prop = " << prop << ", val = " << val << endl;
if (prop == "YOUNG_MODULUS") if (prop == "YOUNG_MODULUS")
young_modulus.Append (val); young_modulus.Append (val);
else if (prop == "POISSON_RATIO") else if (prop == "POISSON_RATIO")
@ -211,6 +213,8 @@ namespace netgen
mesh.SetUserData ("YOUNG_MODULUS", young_modulus); mesh.SetUserData ("YOUNG_MODULUS", young_modulus);
mesh.SetUserData ("POISSON_RATIO", poisson_ratio); mesh.SetUserData ("POISSON_RATIO", poisson_ratio);
mesh.SetUserData ("MASS_DENSITY", mass_density); mesh.SetUserData ("MASS_DENSITY", mass_density);
*testout << "young = " << young_modulus << endl;
*testout << "poisson = " << poisson_ratio << endl;
break; break;
} }
else else
@ -322,6 +326,7 @@ namespace netgen
FaceDescriptor fd(-1, -1, -1, -1); FaceDescriptor fd(-1, -1, -1, -1);
fd.SetBCProperty (nr); fd.SetBCProperty (nr);
*testout << "add fd " << mesh.GetNFD() << ", nr = " << nr << endl;
mesh.AddFaceDescriptor (fd); mesh.AddFaceDescriptor (fd);
for (int j = 0; j < fnums.Size(); j += 2) for (int j = 0; j < fnums.Size(); j += 2)

View File

@ -54,9 +54,11 @@ namespace netgen
bool WriteUserFormat (const string & format, bool WriteUserFormat (const string & format,
const Mesh & mesh, const Mesh & mesh,
const CSGeometry & geom, const NetgenGeometry & hgeom,
const string & filename) const string & filename)
{ {
const CSGeometry & geom = *dynamic_cast<const CSGeometry*> (&hgeom);
PrintMessage (1, "Export mesh to file ", filename, PrintMessage (1, "Export mesh to file ", filename,
", format is ", format); ", format is ", format);

View File

@ -158,7 +158,7 @@ extern void RegisterUserFormats (Array<const char*> & names,
extern bool WriteUserFormat (const string & format, extern bool WriteUserFormat (const string & format,
const Mesh & mesh, const Mesh & mesh,
const CSGeometry & geom, const NetgenGeometry & geom,
const string & filename); const string & filename);
#endif #endif

View File

@ -4,9 +4,17 @@
namespace netgen namespace netgen
{ {
Array<GeometryRegister*> geometryregister;
GeometryRegister :: ~GeometryRegister()
{ ; }
int NetgenGeometry :: GenerateMesh (Mesh*& mesh, int NetgenGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring) int perfstepsstart, int perfstepsend)
{ {
if (!mesh) return 1; if (!mesh) return 1;
@ -48,4 +56,11 @@ namespace netgen
{ {
return *new Refinement;; return *new Refinement;;
} }
void NetgenGeometry :: Save (string filename) const
{
throw NgException("Cannot save geometry - no geometry available");
}
} }

View File

@ -7,22 +7,43 @@
/* Date: 23. Aug. 09 */ /* Date: 23. Aug. 09 */
/**************************************************************************/ /**************************************************************************/
class Tcl_Interp;
namespace netgen
{
class NetgenGeometry class NetgenGeometry
{ {
public: public:
virtual ~NetgenGeometry () { ; } virtual ~NetgenGeometry () { ; }
virtual int GenerateMesh (Mesh*& mesh, virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring); int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;
virtual void Save (string filename) const;
virtual void SaveToMeshFile (ostream & ost) const { ; }
}; };
class GeometryRegister
{
public:
virtual ~GeometryRegister();
virtual NetgenGeometry * Load (string filename) const = 0;
virtual NetgenGeometry * LoadFromMeshFile (istream & ist) const { return NULL; }
virtual class VisualScene * GetVisualScene (const NetgenGeometry * geom) const
{ return NULL; }
virtual void SetParameters (Tcl_Interp * interp) { ; }
};
extern Array<GeometryRegister*> geometryregister;
}
#endif #endif

View File

@ -2638,7 +2638,7 @@ namespace netgen
void Refinement :: Bisect (Mesh & mesh, void Refinement :: Bisect (Mesh & mesh,
BisectionOptions & opt, BisectionOptions & opt,
Array<double> * quality_loss) Array<double> * quality_loss) const
{ {
PrintMessage(1,"Mesh bisection"); PrintMessage(1,"Mesh bisection");
PushStatus("Mesh bisection"); PushStatus("Mesh bisection");
@ -4027,7 +4027,7 @@ namespace netgen
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi) Point<3> & newp, PointGeomInfo & newgi) const
{ {
newp = p1+secpoint*(p2-p1); newp = p1+secpoint*(p2-p1);
} }
@ -4036,8 +4036,9 @@ namespace netgen
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi) Point<3> & newp, EdgePointGeomInfo & newgi) const
{ {
cout << "base class edge point between" << endl;
newp = p1+secpoint*(p2-p1); newp = p1+secpoint*(p2-p1);
} }
@ -4057,7 +4058,7 @@ namespace netgen
} }
void Refinement :: ProjectToSurface (Point<3> & p, int surfi) void Refinement :: ProjectToSurface (Point<3> & p, int surfi) const
{ {
if (printmessage_importance>0) if (printmessage_importance>0)
cerr << "Refinement :: ProjectToSurface ERROR: no geometry set" << endl; cerr << "Refinement :: ProjectToSurface ERROR: no geometry set" << endl;

View File

@ -31,7 +31,7 @@ extern void BisectTets (Mesh &, const CSGeometry *,
extern void BisectTetsCopyMesh (Mesh &, const class CSGeometry *, extern void BisectTetsCopyMesh (Mesh &, const class CSGeometry *,
BisectionOptions & opt); BisectionOptions & opt);
extern void ZRefinement (Mesh &, const CSGeometry *, extern void ZRefinement (Mesh &, const class NetgenGeometry *,
ZRefinementOptions & opt); ZRefinementOptions & opt);
@ -48,7 +48,7 @@ public:
void Refine (Mesh & mesh) const; void Refine (Mesh & mesh) const;
void Refine (Mesh & mesh); void Refine (Mesh & mesh);
void Bisect (Mesh & mesh, class BisectionOptions & opt, Array<double> * quality_loss = NULL); void Bisect (Mesh & mesh, class BisectionOptions & opt, Array<double> * quality_loss = NULL) const;
void MakeSecondOrder (Mesh & mesh) const; void MakeSecondOrder (Mesh & mesh) const;
void MakeSecondOrder (Mesh & mesh); void MakeSecondOrder (Mesh & mesh);
@ -57,13 +57,13 @@ public:
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi); Point<3> & newp, PointGeomInfo & newgi) const;
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi); Point<3> & newp, EdgePointGeomInfo & newgi) const;
virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & egi) const; const EdgePointGeomInfo & egi) const;
@ -72,9 +72,9 @@ public:
const PointGeomInfo & gi) const; const PointGeomInfo & gi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi); virtual void ProjectToSurface (Point<3> & p, int surfi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */) virtual void ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */) const
{ {
ProjectToSurface (p, surfi); ProjectToSurface (p, surfi);
} }
@ -86,7 +86,7 @@ public:
void ValidateRefinedMesh (Mesh & mesh, void ValidateRefinedMesh (Mesh & mesh,
Array<INDEX_2> & parents); Array<INDEX_2> & parents);
MeshOptimize2d * Get2dOptimizer(void) MeshOptimize2d * Get2dOptimizer(void) const
{ {
return optimizer2d; return optimizer2d;
} }

View File

@ -428,7 +428,7 @@ namespace netgen
} }
void CurvedElements :: BuildCurvedElements(Refinement * ref, int aorder, void CurvedElements :: BuildCurvedElements(const Refinement * ref, int aorder,
bool arational) bool arational)
{ {
order = aorder; order = aorder;

View File

@ -44,7 +44,7 @@ public:
// void SetHighOrder (int aorder) { order=aorder; } // void SetHighOrder (int aorder) { order=aorder; }
void SetIsHighOrder (bool ho) { ishighorder = ho; } void SetIsHighOrder (bool ho) { ishighorder = ho; }
void BuildCurvedElements(Refinement * ref, int aorder, bool arational = false); void BuildCurvedElements(const Refinement * ref, int aorder, bool arational = false);
int GetOrder () { return order; } int GetOrder () { return order; }

View File

@ -17,8 +17,7 @@ namespace netgen
ostream * myerr = &cerr; ostream * myerr = &cerr;
// Flags globflags; // not used anymoure // Flags parameters;
Flags parameters;
int silentflag = 0; int silentflag = 0;

View File

@ -20,13 +20,12 @@ extern void ResetTime ();
extern int testmode; extern int testmode;
/// calling parameters /// calling parameters
extern Flags parameters; // extern Flags parameters;
extern MeshingParameters mparam; extern MeshingParameters mparam;
extern Array<int> tets_in_qualclass; extern Array<int> tets_in_qualclass;
class multithreadt class multithreadt
{ {
public: public:

View File

@ -10,7 +10,7 @@ namespace netgen
extern const char * pyramidrules2[]; extern const char * pyramidrules2[];
extern double teterrpow; // extern double teterrpow;
MESHING3_RESULT MeshVolume (MeshingParameters & mp, Mesh& mesh3d) MESHING3_RESULT MeshVolume (MeshingParameters & mp, Mesh& mesh3d)
{ {
int i, oldne; int i, oldne;
@ -249,7 +249,7 @@ namespace netgen
mesh3d.CalcSurfacesOfNode(); mesh3d.CalcSurfacesOfNode();
mesh3d.FindOpenElements(k); mesh3d.FindOpenElements(k);
teterrpow = 2; // teterrpow = 2;
if (mesh3d.GetNOpenElements() != 0) if (mesh3d.GetNOpenElements() != 0)
{ {
meshed = 0; meshed = 0;
@ -650,7 +650,7 @@ namespace netgen
MeshOptimize3d optmesh; MeshOptimize3d optmesh;
teterrpow = mp.opterrpow; // teterrpow = mp.opterrpow;
for (size_t j = 1; j <= strlen(mp.optimize3d); j++) for (size_t j = 1; j <= strlen(mp.optimize3d); j++)
{ {
if (multithread.terminate) if (multithread.terminate)

View File

@ -2,8 +2,8 @@
#define FILE_MESHFUNC #define FILE_MESHFUNC
/**************************************************************************/ /**************************************************************************/
/* File: meshfunc.hh */ /* File: meshfunc.hpp */
/* Author: Johannes Gerstmayr */ /* Author: Johannes Gerstmayr, Joachim Schoeberl */
/* Date: 26. Jan. 98 */ /* Date: 26. Jan. 98 */
/**************************************************************************/ /**************************************************************************/
@ -16,13 +16,13 @@ class Mesh;
// class CSGeometry; // class CSGeometry;
/// Build tet-mesh /// Build tet-mesh
MESHING3_RESULT MeshVolume(MeshingParameters & mp, Mesh& mesh3d); MESHING3_RESULT MeshVolume (MeshingParameters & mp, Mesh& mesh3d);
/// Build mixed-element mesh /// Build mixed-element mesh
MESHING3_RESULT MeshMixedVolume(MeshingParameters & mp, Mesh& mesh3d); // MESHING3_RESULT MeshMixedVolume (MeshingParameters & mp, Mesh& mesh3d);
/// Optimize tet-mesh /// Optimize tet-mesh
MESHING3_RESULT OptimizeVolume(MeshingParameters & mp, Mesh& mesh3d); MESHING3_RESULT OptimizeVolume (MeshingParameters & mp, Mesh& mesh3d);
// const CSGeometry * geometry = NULL); // const CSGeometry * geometry = NULL);
void RemoveIllegalElements (Mesh & mesh3d); void RemoveIllegalElements (Mesh & mesh3d);

View File

@ -69,11 +69,9 @@ namespace netgen
#include "paralleltop.hpp" #include "paralleltop.hpp"
// #include "../parallel/parallelmesh.hpp" // #include "../parallel/parallelmesh.hpp"
#endif #endif
}
#include "basegeom.hpp" #include "basegeom.hpp"
}
#endif #endif

View File

@ -189,7 +189,7 @@ namespace netgen
double teterrpow = 2; // static double teterrpow = 2;
double CalcTetBadness (const Point3d & p1, const Point3d & p2, double CalcTetBadness (const Point3d & p1, const Point3d & p2,
const Point3d & p3, const Point3d & p4, double h) const Point3d & p3, const Point3d & p4, double h)
@ -224,7 +224,7 @@ namespace netgen
h * h * ( 1 / ll1 + 1 / ll2 + 1 / ll3 + h * h * ( 1 / ll1 + 1 / ll2 + 1 / ll3 +
1 / ll4 + 1 / ll5 + 1 / ll6 ) - 12; 1 / ll4 + 1 / ll5 + 1 / ll6 ) - 12;
teterrpow = mparam.opterrpow; double teterrpow = mparam.opterrpow;
if(teterrpow < 1) teterrpow = 1; if(teterrpow < 1) teterrpow = 1;
if (teterrpow == 1) return err; if (teterrpow == 1) return err;
@ -350,7 +350,7 @@ namespace netgen
double errpow; double errpow;
teterrpow = mparam.opterrpow; double teterrpow = mparam.opterrpow;
if(teterrpow < 1) teterrpow = 1; if(teterrpow < 1) teterrpow = 1;
if (teterrpow == 1) if (teterrpow == 1)

View File

@ -4,14 +4,6 @@
namespace netgen namespace netgen
{ {
ostream & operator<<(ostream & s, const MeshPoint & pt)
{
s << Point<3> (pt);
return s;
}
int MultiPointGeomInfo :: int MultiPointGeomInfo ::
AddPointGeomInfo (const PointGeomInfo & gi) AddPointGeomInfo (const PointGeomInfo & gi)
{ {
@ -475,7 +467,6 @@ namespace netgen
} }
void Element2d :: GetShape (const Point2d & p, Vector & shape) const void Element2d :: GetShape (const Point2d & p, Vector & shape) const
{ {
if (shape.Size() != GetNP()) if (shape.Size() != GetNP())
@ -574,7 +565,6 @@ namespace netgen
void Element2d :: void Element2d ::
GetDShapeNew (const Point<2> & p, MatrixFixWidth<2> & dshape) const GetDShapeNew (const Point<2> & p, MatrixFixWidth<2> & dshape) const
{ {
@ -863,6 +853,7 @@ namespace netgen
void Element2d :: ComputeIntegrationPointData () const void Element2d :: ComputeIntegrationPointData () const
{ {
switch (np) switch (np)
@ -902,7 +893,6 @@ namespace netgen
ostream & operator<<(ostream & s, const Element2d & el) ostream & operator<<(ostream & s, const Element2d & el)
{ {
s << "np = " << el.GetNP(); s << "np = " << el.GetNP();
@ -1750,7 +1740,6 @@ namespace netgen
} }
void Element :: GetShape (const Point<3> & hp, Vector & shape) const void Element :: GetShape (const Point<3> & hp, Vector & shape) const
{ {
Point3d p = hp; Point3d p = hp;
@ -1907,7 +1896,6 @@ namespace netgen
void Element :: void Element ::
GetDShape (const Point<3> & hp, DenseMatrix & dshape) const GetDShape (const Point<3> & hp, DenseMatrix & dshape) const
{ {
@ -1937,7 +1925,6 @@ namespace netgen
} }
void Element :: void Element ::
GetDShapeNew (const Point<3> & p, MatrixFixWidth<3> & dshape) const GetDShapeNew (const Point<3> & p, MatrixFixWidth<3> & dshape) const
{ {
@ -2001,13 +1988,6 @@ namespace netgen
DenseMatrix & pmat) const DenseMatrix & pmat) const
{ {
int np = GetNP(); int np = GetNP();
/*
if (pmat.Width() != np || pmat.Height() != 3)
{
cerr << "Element::GetPointMatrix: sizes don't fit" << endl;
return;
}
*/
for (int i = 1; i <= np; i++) for (int i = 1; i <= np; i++)
{ {
const Point3d & p = points.Get(PNum(i)); const Point3d & p = points.Get(PNum(i));
@ -2020,11 +2000,8 @@ namespace netgen
double Element :: CalcJacobianBadness (const T_POINTS & points) const double Element :: CalcJacobianBadness (const T_POINTS & points) const
{ {
int i, j;
int nip = GetNIP(); int nip = GetNIP();
static DenseMatrix trans(3,3); static DenseMatrix trans(3,3);
static DenseMatrix pmat; static DenseMatrix pmat;
@ -2033,13 +2010,13 @@ namespace netgen
GetPointMatrix (points, pmat); GetPointMatrix (points, pmat);
double err = 0; double err = 0;
for (i = 1; i <= nip; i++) for (int i = 1; i <= nip; i++)
{ {
GetTransformation (i, pmat, trans); GetTransformation (i, pmat, trans);
// Frobenius norm // Frobenius norm
double frob = 0; double frob = 0;
for (j = 1; j <= 9; j++) for (int j = 1; j <= 9; j++)
frob += sqr (trans.Get(j)); frob += sqr (trans.Get(j));
frob = sqrt (frob); frob = sqrt (frob);
frob /= 3; frob /= 3;
@ -2220,7 +2197,6 @@ namespace netgen
void Element :: ComputeIntegrationPointData () const void Element :: ComputeIntegrationPointData () const
{ {
switch (GetType()) switch (GetType())
@ -2266,7 +2242,6 @@ namespace netgen
FaceDescriptor :: FaceDescriptor() FaceDescriptor :: FaceDescriptor()
{ {
surfnr = domin = domout = bcprop = 0; surfnr = domin = domout = bcprop = 0;

View File

@ -233,7 +233,6 @@ class MeshPoint : public Point<3>
public: public:
MeshPoint () MeshPoint ()
// : layer(1), singular(0.), type(INNERPOINT) // would unnecessarily initialize large arrays !
{ {
#ifdef PARALLEL #ifdef PARALLEL
isghost = 0; isghost = 0;
@ -276,17 +275,17 @@ public:
}; };
ostream & operator<<(ostream & s, const MeshPoint & pt); inline ostream & operator<<(ostream & s, const MeshPoint & pt)
{
return (s << Point<3> (pt));
}
// typedef MoveableArray<MeshPoint,PointIndex::BASE> T_POINTS; typedef Array<MeshPoint, PointIndex::BASE> T_POINTS;
typedef Array<MeshPoint,PointIndex::BASE> T_POINTS;
class Element2d;
ostream & operator<<(ostream & s, const Element2d & el);
/** /**
Triangle element for surface mesh generation. Triangle element for surface mesh generation.
@ -435,6 +434,7 @@ public:
/// get number of 'integration points' /// get number of 'integration points'
int GetNIP () const; int GetNIP () const;
void GetIntegrationPoint (int ip, Point2d & p, double & weight) const; void GetIntegrationPoint (int ip, Point2d & p, double & weight) const;
void GetTransformation (int ip, const Array<Point2d> & points, void GetTransformation (int ip, const Array<Point2d> & points,
class DenseMatrix & trans) const; class DenseMatrix & trans) const;
void GetTransformation (int ip, class DenseMatrix & pmat, void GetTransformation (int ip, class DenseMatrix & pmat,
@ -507,11 +507,13 @@ public:
#else #else
bool IsGhost () const { return false; } bool IsGhost () const { return false; }
#endif #endif
}; };
ostream & operator<<(ostream & s, const Element2d & el);
class IntegrationPointData class IntegrationPointData
@ -526,8 +528,7 @@ public:
class Element;
ostream & operator<<(ostream & s, const Element & el);
@ -700,6 +701,7 @@ public:
/// get number of 'integration points' /// get number of 'integration points'
int GetNIP () const; int GetNIP () const;
void GetIntegrationPoint (int ip, Point<3> & p, double & weight) const; void GetIntegrationPoint (int ip, Point<3> & p, double & weight) const;
void GetTransformation (int ip, const T_POINTS & points, void GetTransformation (int ip, const T_POINTS & points,
class DenseMatrix & trans) const; class DenseMatrix & trans) const;
void GetTransformation (int ip, class DenseMatrix & pmat, void GetTransformation (int ip, class DenseMatrix & pmat,
@ -724,7 +726,7 @@ public:
int pi, Vec<3> & grad) const; int pi, Vec<3> & grad) const;
/// ///
friend ostream & operator<<(ostream & s, const Element & el); // friend ostream & operator<<(ostream & s, const Element & el);
void SetRefinementFlag (bool rflag = 1) void SetRefinementFlag (bool rflag = 1)
{ flags.refflag = rflag; } { flags.refflag = rflag; }
@ -777,12 +779,14 @@ public:
bool IsGhost () const { return false; } bool IsGhost () const { return false; }
#endif #endif
friend class Mesh; // friend class Mesh;
}; };
ostream & operator<<(ostream & s, const Element & el);
class Segment;
ostream & operator<<(ostream & s, const Segment & seg);
/** /**
@ -881,6 +885,10 @@ public:
const PointIndex & operator[] (int i) const { return pnums[i]; } const PointIndex & operator[] (int i) const { return pnums[i]; }
}; };
ostream & operator<<(ostream & s, const Segment & seg);
// class Surface; // class Surface;
// class FaceDescriptor; // class FaceDescriptor;

View File

@ -43,7 +43,6 @@ namespace netgen
else else
{ {
Point<3> pnew; Point<3> pnew;
PointBetween (mesh.Point (el[0]), PointBetween (mesh.Point (el[0]),
mesh.Point (el[1]), 0.5, mesh.Point (el[1]), 0.5,
el.surfnr1, el.surfnr2, el.surfnr1, el.surfnr2,

View File

@ -922,20 +922,18 @@ double Opti3EdgeMinFunction :: FuncGrad (const Vector & x, Vector & grad) const
extern double teterrpow;
double CalcTotalBad (const Mesh::T_POINTS & points, double CalcTotalBad (const Mesh::T_POINTS & points,
const Mesh::T_VOLELEMENTS & elements) const Mesh::T_VOLELEMENTS & elements)
{ {
int i;
double sum = 0; double sum = 0;
double elbad; double elbad;
tets_in_qualclass.SetSize(20); tets_in_qualclass.SetSize(20);
for (i = 1; i <= 20; i++) tets_in_qualclass = 0;
tets_in_qualclass.Elem(i) = 0;
double teterrpow = mparam.opterrpow;
for (i = 1; i <= elements.Size(); i++) for (int i = 1; i <= elements.Size(); i++)
{ {
elbad = pow (max2(CalcBad (points, elements.Get(i), 0),1e-10), elbad = pow (max2(CalcBad (points, elements.Get(i), 0),1e-10),
1/teterrpow); 1/teterrpow);

View File

@ -152,7 +152,7 @@ namespace netgen
void RepairBisection(Mesh & mesh, Array<ElementIndex> & bad_elements, void RepairBisection(Mesh & mesh, Array<ElementIndex> & bad_elements,
const BitArray & isnewpoint, Refinement & refinement, const BitArray & isnewpoint, const Refinement & refinement,
const Array<double> & pure_badness, const Array<double> & pure_badness,
double max_worsening, const bool uselocalworsening, double max_worsening, const bool uselocalworsening,
const Array< Array<int,PointIndex::BASE>* > & idmaps) const Array< Array<int,PointIndex::BASE>* > & idmaps)

View File

@ -9,7 +9,7 @@ double Validate(const Mesh & mesh, Array<ElementIndex> & bad_elements,
const Array<double> & pure_badness, const Array<double> & pure_badness,
double max_worsening, const bool uselocalworsening, double max_worsening, const bool uselocalworsening,
Array<double> * quality_loss = NULL); Array<double> * quality_loss = NULL);
void RepairBisection(Mesh & mesh, Array<ElementIndex> & bad_elements, const BitArray & isnewpoint, Refinement & refinement, void RepairBisection(Mesh & mesh, Array<ElementIndex> & bad_elements, const BitArray & isnewpoint, const Refinement & refinement,
const Array<double> & pure_badness, const Array<double> & pure_badness,
double max_worsening, const bool uselocalworsening, double max_worsening, const bool uselocalworsening,
const Array< Array<int,PointIndex::BASE>* > & idmaps); const Array< Array<int,PointIndex::BASE>* > & idmaps);

View File

@ -11,16 +11,14 @@ namespace netgen
INDEX_2_HASHTABLE<int> & singedges, INDEX_2_HASHTABLE<int> & singedges,
ZRefinementOptions & opt) ZRefinementOptions & opt)
{ {
int i, j;
// edges selected in csg input file // edges selected in csg input file
for (i = 1; i <= geom.singedges.Size(); i++) for (int i = 1; i <= geom.singedges.Size(); i++)
{ {
//if(geom.singedges.Get(i)->maxhinit > 0) //if(geom.singedges.Get(i)->maxhinit > 0)
// continue; //!!!! // continue; //!!!!
const SingularEdge & se = *geom.singedges.Get(i); const SingularEdge & se = *geom.singedges.Get(i);
for (j = 1; j <= se.segms.Size(); j++) for (int j = 1; j <= se.segms.Size(); j++)
{ {
INDEX_2 i2 = se.segms.Get(j); INDEX_2 i2 = se.segms.Get(j);
singedges.Set (i2, 1); singedges.Set (i2, 1);
@ -28,7 +26,7 @@ namespace netgen
} }
// edges interactively selected // edges interactively selected
for (i = 1; i <= mesh.GetNSeg(); i++) for (int i = 1; i <= mesh.GetNSeg(); i++)
{ {
const Segment & seg = mesh.LineSegment(i); const Segment & seg = mesh.LineSegment(i);
if (seg.singedge_left || seg.singedge_right) if (seg.singedge_left || seg.singedge_right)
@ -46,16 +44,14 @@ namespace netgen
*/ */
void MakePrismsSingEdge (Mesh & mesh, INDEX_2_HASHTABLE<int> & singedges) void MakePrismsSingEdge (Mesh & mesh, INDEX_2_HASHTABLE<int> & singedges)
{ {
int i, j, k;
// volume elements // volume elements
for (i = 1; i <= mesh.GetNE(); i++) for (int i = 1; i <= mesh.GetNE(); i++)
{ {
Element & el = mesh.VolumeElement(i); Element & el = mesh.VolumeElement(i);
if (el.GetType() != TET) continue; if (el.GetType() != TET) continue;
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
for (k = j+1; k <= 4; k++) for (int k = j+1; k <= 4; k++)
{ {
INDEX_2 edge(el.PNum(j), el.PNum(k)); INDEX_2 edge(el.PNum(j), el.PNum(k));
edge.Sort(); edge.Sort();
@ -80,14 +76,14 @@ namespace netgen
} }
// surface elements // surface elements
for (i = 1; i <= mesh.GetNSE(); i++) for (int i = 1; i <= mesh.GetNSE(); i++)
{ {
Element2d & el = mesh.SurfaceElement(i); Element2d & el = mesh.SurfaceElement(i);
if (el.GetType() != TRIG) continue; if (el.GetType() != TRIG) continue;
for (j = 1; j <= 3; j++) for (int j = 1; j <= 3; j++)
{ {
k = (j % 3) + 1; int k = (j % 3) + 1;
INDEX_2 edge(el.PNum(j), el.PNum(k)); INDEX_2 edge(el.PNum(j), el.PNum(k));
edge.Sort(); edge.Sort();
@ -719,9 +715,12 @@ namespace netgen
void ZRefinement (Mesh & mesh, const CSGeometry * geom, void ZRefinement (Mesh & mesh, const NetgenGeometry * hgeom,
ZRefinementOptions & opt) ZRefinementOptions & opt)
{ {
const CSGeometry * geom = dynamic_cast<const CSGeometry*> (hgeom);
if (!geom) return;
INDEX_2_HASHTABLE<int> singedges(mesh.GetNSeg()); INDEX_2_HASHTABLE<int> singedges(mesh.GetNSeg());
SelectSingularEdges (mesh, *geom, singedges, opt); SelectSingularEdges (mesh, *geom, singedges, opt);

View File

@ -14,8 +14,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include $(OCCFLAGS)
METASOURCES = AUTO METASOURCES = AUTO
noinst_LTLIBRARIES = libocc.la noinst_LTLIBRARIES = libocc.la liboccvis.la
libocc_la_SOURCES = Partition_Inter2d.cxx Partition_Inter3d.cxx \ libocc_la_SOURCES = Partition_Inter2d.cxx Partition_Inter3d.cxx \
Partition_Loop.cxx Partition_Loop2d.cxx Partition_Loop3d.cxx Partition_Spliter.cxx \ Partition_Loop.cxx Partition_Loop2d.cxx Partition_Loop3d.cxx Partition_Spliter.cxx \
occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp
liboccvis_la_SOURCES = occpkg.cpp vsocc.cpp

View File

@ -1266,9 +1266,8 @@ namespace netgen
int OCCGenerateMesh (OCCGeometry & geom, Mesh *& mesh, int OCCGenerateMesh (OCCGeometry & geom, Mesh *& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, int perfstepsstart, int perfstepsend)
char * optstr)
{ {
multithread.percent = 0; multithread.percent = 0;

View File

@ -1233,6 +1233,38 @@ namespace netgen
} }
void OCCGeometry :: Save (string sfilename) const
{
const char * filename = sfilename.c_str();
if (strlen(filename) < 4)
throw NgException ("illegal filename");
if (strcmp (&filename[strlen(filename)-3], "igs") == 0)
{
IGESControl_Writer writer("millimeters", 1);
writer.AddShape (shape);
writer.Write (filename);
}
else if (strcmp (&filename[strlen(filename)-3], "stp") == 0)
{
STEPControl_Writer writer;
writer.Transfer (shape, STEPControl_AsIs);
writer.Write (filename);
}
else if (strcmp (&filename[strlen(filename)-3], "stl") == 0)
{
StlAPI_Writer writer;
writer.ASCIIMode() = Standard_True;
writer.Write (shape, filename);
}
else if (strcmp (&filename[strlen(filename)-4], "stlb") == 0)
{
StlAPI_Writer writer;
writer.ASCIIMode() = Standard_False;
writer.Write (shape, filename);
}
}
const char * shapesname[] = const char * shapesname[] =
@ -1532,10 +1564,10 @@ namespace netgen
int OCCGeometry :: GenerateMesh (Mesh*& mesh, int OCCGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring) int perfstepsstart, int perfstepsend)
{ {
return OCCGenerateMesh (*this, mesh, perfstepsstart, perfstepsend, optstring); return OCCGenerateMesh (*this, mesh, mparam, perfstepsstart, perfstepsend);
} }

View File

@ -203,7 +203,7 @@ namespace netgen
// the system // the system
Handle_XCAFDoc_ColorTool face_colours; Handle_XCAFDoc_ColorTool face_colours;
int changed; mutable int changed;
Array<int> facemeshstatus; Array<int> facemeshstatus;
// Philippose - 15/01/2009 // Philippose - 15/01/2009
@ -241,6 +241,10 @@ namespace netgen
vmap.Clear(); vmap.Clear();
} }
virtual void Save (string filename) const;
void BuildFMap(); void BuildFMap();
Box<3> GetBoundingBox() Box<3> GetBoundingBox()
@ -379,10 +383,10 @@ namespace netgen
void GetNotDrawableFaces (stringstream & str); void GetNotDrawableFaces (stringstream & str);
bool ErrorInSurfaceMeshing (); bool ErrorInSurfaceMeshing ();
void WriteOCC_STL(char * filename); void WriteOCC_STL(char * filename);
virtual int GenerateMesh (Mesh*& mesh, virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring); int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;
}; };
@ -430,10 +434,10 @@ namespace netgen
// External access to the mesh generation functions within the OCC // External access to the mesh generation functions within the OCC
// subsystem (Not sure if this is the best way to implement this....!!) // subsystem (Not sure if this is the best way to implement this....!!)
extern int OCCGenerateMesh (OCCGeometry & occgeometry, Mesh*& mesh, extern int OCCGenerateMesh (OCCGeometry & occgeometry, Mesh*& mesh,
int perfstepsstart, int perfstepsend, MeshingParameters & mparam,
char* optstring); int perfstepsstart, int perfstepsend);
extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh); extern void OCCSetLocalMeshSize(OCCGeometry & geom, Mesh & mesh);
extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend); extern void OCCMeshSurface (OCCGeometry & geom, Mesh & mesh, int perfstepsend);

View File

@ -666,7 +666,7 @@ namespace netgen
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi) Point<3> & newp, PointGeomInfo & newgi) const
{ {
Point<3> hnewp; Point<3> hnewp;
hnewp = p1+secpoint*(p2-p1); hnewp = p1+secpoint*(p2-p1);
@ -697,7 +697,7 @@ namespace netgen
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi) Point<3> & newp, EdgePointGeomInfo & newgi) const
{ {
double s0, s1; double s0, s1;
@ -711,13 +711,13 @@ namespace netgen
}; };
void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) const
{ {
if (surfi > 0) if (surfi > 0)
geometry.Project (surfi, p); geometry.Project (surfi, p);
}; };
void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) void OCCRefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const
{ {
if (surfi > 0) if (surfi > 0)
if (!geometry.FastProject (surfi, p, gi.u, gi.v)) if (!geometry.FastProject (surfi, p, gi.u, gi.v))

View File

@ -181,17 +181,17 @@ public:
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi); Point<3> & newp, PointGeomInfo & newgi) const;
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi); Point<3> & newp, EdgePointGeomInfo & newgi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi); virtual void ProjectToSurface (Point<3> & p, int surfi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi); virtual void ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const;
}; };

1020
libsrc/occ/occpkg.cpp Normal file

File diff suppressed because it is too large Load Diff

764
libsrc/occ/vsocc.cpp Normal file
View File

@ -0,0 +1,764 @@
#ifndef NOTCL
#ifdef OCCGEOMETRY
#include <mystdlib.h>
#include <myadt.hpp>
#include <meshing.hpp>
#include <occgeom.hpp>
#include "TopoDS_Shape.hxx"
#include "TopoDS_Vertex.hxx"
#include "TopExp_Explorer.hxx"
#include "BRep_Tool.hxx"
#include "TopoDS.hxx"
#include "gp_Pnt.hxx"
#include "Geom_Curve.hxx"
#include "Poly_Triangulation.hxx"
#include "Poly_Array1OfTriangle.hxx"
#include "TColgp_Array1OfPnt2d.hxx"
#include "Poly_Triangle.hxx"
#include "Poly_Polygon3D.hxx"
#include "Poly_PolygonOnTriangulation.hxx"
#include <visual.hpp>
#include "vsocc.hpp"
namespace netgen
{
// extern OCCGeometry * occgeometry;
/* *********************** Draw OCC Geometry **************** */
VisualSceneOCCGeometry :: VisualSceneOCCGeometry ()
: VisualScene()
{
trilists.SetSize(0);
linelists.SetSize(1);
}
VisualSceneOCCGeometry :: ~VisualSceneOCCGeometry ()
{
;
}
void VisualSceneOCCGeometry :: DrawScene ()
{
if ( occgeometry->changed )
{
BuildScene();
occgeometry -> changed = 0;
}
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetLight();
glPushMatrix();
glMultMatrixf (transformationmat);
glShadeModel (GL_SMOOTH);
glDisable (GL_COLOR_MATERIAL);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// glEnable (GL_LIGHTING);
double shine = vispar.shininess;
// double transp = vispar.transp;
glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine);
glLogicOp (GL_COPY);
glEnable (GL_NORMALIZE);
float mat_col[] = { 0.2f, 0.2f, 0.8f, 1.0f};
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
glPolygonOffset (1, 1);
glEnable (GL_POLYGON_OFFSET_FILL);
// Philippose - 30/01/2009
// Added clipping planes to Geometry view
SetClippingPlane();
GLfloat matcoledge[] = { 0, 0, 1, 1};
GLfloat matcolhiedge[] = { 1, 0, 0, 1};
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcoledge);
glLineWidth (1.0f);
if (vispar.occshowedges) glCallList (linelists.Get(1));
if (vispar.occshowsurfaces) glCallList (trilists.Get(1));
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge);
glLineWidth (5.0f);
if (vispar.occshowedges) glCallList (linelists.Get(2));
for (int i = 1; i <= occgeometry->vmap.Extent(); i++)
if (occgeometry->vvispar[i-1].IsHighlighted())
{
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, matcolhiedge);
glLineWidth (5.0f);
glBegin (GL_LINES);
gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(occgeometry->vmap(i)));
double d = rad/100;
glVertex3f (p.X()-d, p.Y(), p.Z());
glVertex3f (p.X()+d, p.Y(), p.Z());
glVertex3f (p.X(), p.Y()-d, p.Z());
glVertex3f (p.X(), p.Y()+d, p.Z());
glVertex3f (p.X(), p.Y(), p.Z()-d);
glVertex3f (p.X(), p.Y(), p.Z()+d);
glEnd();
}
glDisable (GL_POLYGON_OFFSET_FILL);
glPopMatrix();
// DrawCoordinateCross ();
// DrawNetgenLogo ();
glFinish();
glDisable (GL_POLYGON_OFFSET_FILL);
}
/*
void VisualSceneOCCGeometry :: BuildScene (int zoomall)
{
int i = 0, j, k;
TopExp_Explorer ex, ex_edge;
if (vispar.occvisproblemfaces || (occgeometry -> changed != 2))
{
Box<3> bb = occgeometry -> GetBoundingBox();
center = bb.Center();
rad = bb.Diam() / 2;
if (vispar.occvisproblemfaces)
{
for (i = 1; i <= occgeometry->fmap.Extent(); i++)
if (occgeometry->facemeshstatus[i-1] == -1)
{
GProp_GProps system;
BRepGProp::LinearProperties(occgeometry->fmap(i), system);
gp_Pnt pnt = system.CentreOfMass();
center = Point<3> (pnt.X(), pnt.Y(), pnt.Z());
cout << "Setting center to mid of face " << i << " = " << center << endl;
}
}
CalcTransformationMatrices();
}
for (i = 1; i <= linelists.Size(); i++)
glDeleteLists (linelists.Elem(i), 1);
linelists.SetSize(0);
linelists.Append (glGenLists (1));
glNewList (linelists.Last(), GL_COMPILE);
i = 0;
for (ex_edge.Init(occgeometry -> shape, TopAbs_EDGE);
ex_edge.More(); ex_edge.Next())
{
if (BRep_Tool::Degenerated(TopoDS::Edge(ex_edge.Current()))) continue;
i++;
TopoDS_Edge edge = TopoDS::Edge(ex_edge.Current());
Handle(Poly_PolygonOnTriangulation) aEdgePoly;
Handle(Poly_Triangulation) T;
TopLoc_Location aEdgeLoc;
BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc);
if(aEdgePoly.IsNull())
{
cout << "cannot visualize edge " << i << endl;
continue;
}
glBegin (GL_LINE_STRIP);
int nbnodes = aEdgePoly -> NbNodes();
for (j = 1; j <= nbnodes; j++)
{
gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc);
glVertex3f (p.X(), p.Y(), p.Z());
}
glEnd ();
}
glEndList ();
for (i = 1; i <= trilists.Size(); i++)
glDeleteLists (trilists.Elem(i), 1);
trilists.SetSize(0);
trilists.Append (glGenLists (1));
glNewList (trilists.Last(), GL_COMPILE);
i = 0;
TopExp_Explorer exp0, exp1, exp2, exp3;
int shapenr = 0;
for (exp0.Init(occgeometry -> shape, TopAbs_SOLID); exp0.More(); exp0.Next())
{
shapenr++;
if (vispar.occshowvolumenr != 0 &&
vispar.occshowvolumenr != shapenr) continue;
float mat_col[4];
mat_col[3] = 1;
switch (shapenr)
{
case 1:
mat_col[0] = 0.2;
mat_col[1] = 0.2;
mat_col[2] = 0.8;
break;
case 2:
mat_col[0] = 0.8;
mat_col[1] = 0.2;
mat_col[2] = 0.8;
break;
case 3:
mat_col[0] = 0.2;
mat_col[1] = 0.8;
mat_col[2] = 0.8;
break;
case 4:
mat_col[0] = 0.8;
mat_col[1] = 0.2;
mat_col[2] = 0.2;
break;
case 5:
mat_col[0] = 0.8;
mat_col[1] = 0.8;
mat_col[2] = 0.8;
break;
case 6:
mat_col[0] = 0.6;
mat_col[1] = 0.6;
mat_col[2] = 0.6;
break;
case 7:
mat_col[0] = 0.2;
mat_col[1] = 0.8;
mat_col[2] = 0.2;
break;
case 8:
mat_col[0] = 0.8;
mat_col[1] = 0.8;
mat_col[2] = 0.2;
break;
default:
// mat_col[0] = 1-(1.0/double(shapenr));
// mat_col[1] = 0.5;
mat_col[0] = 0.5+double((shapenr*shapenr*shapenr*shapenr) % 10)/20.0;
mat_col[1] = 0.5+double(int(shapenr*shapenr*shapenr*shapenr*sin(double(shapenr))) % 10)/20.0;
mat_col[2] = 0.5+double((shapenr*shapenr*shapenr) % 10)/20.0;
}
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
for (exp1.Init(exp0.Current(), TopAbs_SHELL); exp1.More(); exp1.Next())
for (exp2.Init(exp1.Current().Composed(exp0.Current().Orientation()), TopAbs_FACE); exp2.More(); exp2.Next())
{
TopoDS_Face face = TopoDS::Face (exp2.Current().Composed(exp1.Current().Orientation()));
i = occgeometry->fmap.FindIndex(face);
TopLoc_Location loc;
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
BRepAdaptor_Surface sf(face, Standard_False);
BRepLProp_SLProps prop(sf, 1, 1e-5);
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
if (triangulation.IsNull())
{
cout << "cannot visualize face " << i << endl;
continue;
}
if (vispar.occvisproblemfaces)
{
switch (occgeometry->facemeshstatus[i-1])
{
case 0:
mat_col[0] = 0.2;
mat_col[1] = 0.2;
mat_col[2] = 0.8;
break;
case 1:
mat_col[0] = 0.2;
mat_col[1] = 0.8;
mat_col[2] = 0.2;
break;
case -1:
mat_col[0] = 0.8;
mat_col[1] = 0.2;
mat_col[2] = 0.2;
break;
}
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
}
glBegin (GL_TRIANGLES);
int ntriangles = triangulation -> NbTriangles();
for (j = 1; j <= ntriangles; j++)
{
Poly_Triangle triangle = (triangulation -> Triangles())(j);
for (k = 1; k <= 3; k++)
{
gp_Pnt2d uv = (triangulation -> UVNodes())(triangle(k));
gp_Pnt pnt;
gp_Vec du, dv;
prop.SetParameters (uv.X(), uv.Y());
surf->D0 (uv.X(), uv.Y(), pnt);
gp_Vec n;
if (prop.IsNormalDefined())
n = prop.Normal();
else
n = gp_Vec (0,0,0);
if (face.Orientation() == TopAbs_REVERSED) n *= -1;
glNormal3f (n.X(), n.Y(), n.Z());
glVertex3f (pnt.X(), pnt.Y(), pnt.Z());
}
}
glEnd ();
}
}
glEndList ();
}
*/
void VisualSceneOCCGeometry :: BuildScene (int zoomall)
{
if (occgeometry -> changed == OCCGEOMETRYVISUALIZATIONFULLCHANGE)
{
occgeometry -> BuildVisualizationMesh (vispar.occdeflection);
center = occgeometry -> Center();
rad = occgeometry -> GetBoundingBox().Diam() / 2;
if (vispar.occzoomtohighlightedentity)
{
bool hilite = false;
bool hiliteonepoint = false;
Bnd_Box bb;
for (int i = 1; i <= occgeometry->fmap.Extent(); i++)
if (occgeometry->fvispar[i-1].IsHighlighted())
{
hilite = true;
BRepBndLib::Add (occgeometry->fmap(i), bb);
}
for (int i = 1; i <= occgeometry->emap.Extent(); i++)
if (occgeometry->evispar[i-1].IsHighlighted())
{
hilite = true;
BRepBndLib::Add (occgeometry->emap(i), bb);
}
for (int i = 1; i <= occgeometry->vmap.Extent(); i++)
if (occgeometry->vvispar[i-1].IsHighlighted())
{
hiliteonepoint = true;
BRepBndLib::Add (occgeometry->vmap(i), bb);
}
if (hilite || hiliteonepoint)
{
double x1,y1,z1,x2,y2,z2;
bb.Get (x1,y1,z1,x2,y2,z2);
Point<3> p1 = Point<3> (x1,y1,z1);
Point<3> p2 = Point<3> (x2,y2,z2);
Box<3> boundingbox(p1,p2);
center = boundingbox.Center();
if (hiliteonepoint)
rad = occgeometry -> GetBoundingBox().Diam() / 100;
else
rad = boundingbox.Diam() / 2;
}
}
CalcTransformationMatrices();
}
// Clear lists
for (int i = 1; i <= linelists.Size(); i++)
glDeleteLists (linelists.Elem(i), 1);
linelists.SetSize(0);
for (int i = 1; i <= trilists.Size(); i++)
glDeleteLists (trilists.Elem(i), 1);
trilists.SetSize(0);
// Total wireframe
linelists.Append (glGenLists (1));
glNewList (linelists.Last(), GL_COMPILE);
for (int i = 1; i <= occgeometry->emap.Extent(); i++)
{
TopoDS_Edge edge = TopoDS::Edge(occgeometry->emap(i));
if (BRep_Tool::Degenerated(edge)) continue;
if (occgeometry->evispar[i-1].IsHighlighted()) continue;
Handle(Poly_PolygonOnTriangulation) aEdgePoly;
Handle(Poly_Triangulation) T;
TopLoc_Location aEdgeLoc;
BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc);
if(aEdgePoly.IsNull())
{
(*testout) << "visualizing edge " << occgeometry->emap.FindIndex (edge)
<< " without using the occ visualization triangulation" << endl;
double s0, s1;
Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
glBegin (GL_LINE_STRIP);
for (int i = 0; i<=50; i++)
{
gp_Pnt p = c->Value (s0 + i*(s1-s0)/50.0);
glVertex3f (p.X(),p.Y(),p.Z());
}
glEnd ();
continue;
}
int nbnodes = aEdgePoly -> NbNodes();
glBegin (GL_LINE_STRIP);
for (int j = 1; j <= nbnodes; j++)
{
gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc);
glVertex3f (p.X(), p.Y(), p.Z());
}
glEnd ();
}
glEndList ();
// Highlighted edge list
linelists.Append (glGenLists (1));
glNewList (linelists.Last(), GL_COMPILE);
for (int i = 1; i <= occgeometry->emap.Extent(); i++)
if (occgeometry->evispar[i-1].IsHighlighted())
{
TopoDS_Edge edge = TopoDS::Edge(occgeometry->emap(i));
if (BRep_Tool::Degenerated(edge)) continue;
Handle(Poly_PolygonOnTriangulation) aEdgePoly;
Handle(Poly_Triangulation) T;
TopLoc_Location aEdgeLoc;
BRep_Tool::PolygonOnTriangulation(edge, aEdgePoly, T, aEdgeLoc);
if(aEdgePoly.IsNull())
{
(*testout) << "visualizing edge " << occgeometry->emap.FindIndex (edge)
<< " without using the occ visualization triangulation" << endl;
double s0, s1;
Handle(Geom_Curve) c = BRep_Tool::Curve(edge, s0, s1);
glBegin (GL_LINE_STRIP);
for (int i = 0; i<=50; i++)
{
gp_Pnt p = c->Value (s0 + i*(s1-s0)/50.0);
glVertex3f (p.X(),p.Y(),p.Z());
}
glEnd ();
continue;
}
int nbnodes = aEdgePoly -> NbNodes();
glBegin (GL_LINE_STRIP);
for (int j = 1; j <= nbnodes; j++)
{
gp_Pnt p = (T -> Nodes())(aEdgePoly->Nodes()(j)).Transformed(aEdgeLoc);
glVertex3f (p.X(), p.Y(), p.Z());
}
glEnd ();
}
glEndList ();
// display faces
trilists.Append (glGenLists (1));
glNewList (trilists.Last(), GL_COMPILE);
for (int i = 1; i <= occgeometry->fmap.Extent(); i++)
{
if (!occgeometry->fvispar[i-1].IsVisible()) continue;
glLoadName (i);
float mat_col[4];
mat_col[3] = 1;
TopoDS_Face face = TopoDS::Face(occgeometry->fmap(i));
if (!occgeometry->fvispar[i-1].IsHighlighted())
{
// Philippose - 30/01/2009
// OpenCascade XDE Support
Quantity_Color face_colour;
// Philippose - 23/02/2009
// Check to see if colours have been extracted first!!
// Forum bug-fox (Jean-Yves - 23/02/2009)
if(!(occgeometry->face_colours.IsNull())
&& (occgeometry->face_colours->GetColor(face,XCAFDoc_ColorSurf,face_colour)))
{
mat_col[0] = face_colour.Red();
mat_col[1] = face_colour.Green();
mat_col[2] = face_colour.Blue();
}
else
{
mat_col[0] = 0.0;
mat_col[1] = 1.0;
mat_col[2] = 0.0;
}
}
else
{
mat_col[0] = 0.8;
mat_col[1] = 0.2;
mat_col[2] = 0.2;
}
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
TopLoc_Location loc;
Handle(Geom_Surface) surf = BRep_Tool::Surface (face);
BRepAdaptor_Surface sf(face, Standard_False);
BRepLProp_SLProps prop(sf, 1, 1e-5);
Handle(Poly_Triangulation) triangulation = BRep_Tool::Triangulation (face, loc);
if (triangulation.IsNull())
{
cout << "cannot visualize face " << i << endl;
occgeometry->fvispar[i-1].SetNotDrawable();
continue;
}
gp_Pnt2d uv;
gp_Pnt pnt;
gp_Vec n;
glBegin (GL_TRIANGLES);
int ntriangles = triangulation -> NbTriangles();
for (int j = 1; j <= ntriangles; j++)
{
Poly_Triangle triangle = (triangulation -> Triangles())(j);
gp_Pnt p[3];
for (int k = 1; k <= 3; k++)
p[k-1] = (triangulation -> Nodes())(triangle(k)).Transformed(loc);
for (int k = 1; k <= 3; k++)
{
uv = (triangulation -> UVNodes())(triangle(k));
prop.SetParameters (uv.X(), uv.Y());
// surf->D0 (uv.X(), uv.Y(), pnt);
if (prop.IsNormalDefined())
n = prop.Normal();
else
{
(*testout) << "Visualization of face " << i
<< ": Normal vector not defined" << endl;
// n = gp_Vec (0,0,0);
gp_Vec a(p[0],p[1]);
gp_Vec b(p[0],p[2]);
n = b^a;
}
if (face.Orientation() == TopAbs_REVERSED) n *= -1;
glNormal3f (n.X(), n.Y(), n.Z());
glVertex3f (p[k-1].X(), p[k-1].Y(), p[k-1].Z());
}
}
glEnd ();
}
glEndList ();
}
void SelectFaceInOCCDialogTree (int facenr);
void VisualSceneOCCGeometry :: MouseDblClick (int px, int py)
{
int hits;
// select surface triangle by mouse click
GLuint selbuf[10000];
glSelectBuffer (10000, selbuf);
glRenderMode (GL_SELECT);
GLint viewport[4];
glGetIntegerv (GL_VIEWPORT, viewport);
glMatrixMode (GL_PROJECTION);
glPushMatrix();
GLdouble projmat[16];
glGetDoublev (GL_PROJECTION_MATRIX, projmat);
glLoadIdentity();
gluPickMatrix (px, viewport[3] - py, 1, 1, viewport);
glMultMatrixd (projmat);
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode (GL_MODELVIEW);
glPushMatrix();
glMultMatrixf (transformationmat);
glInitNames();
glPushName (1);
glPolygonOffset (1, 1);
glEnable (GL_POLYGON_OFFSET_FILL);
glDisable(GL_CLIP_PLANE0);
// Philippose - 30/01/2009
// Enable clipping planes for Selection mode in OCC Geometry
if (vispar.clipenable)
{
Vec<3> n(clipplane[0], clipplane[1], clipplane[2]);
double len = Abs(n);
double mu = -clipplane[3] / (len*len);
Point<3> p (mu * n);
n /= len;
Vec<3> t1 = n.GetNormal ();
Vec<3> t2 = Cross (n, t1);
double xi1mid = (center - p) * t1;
double xi2mid = (center - p) * t2;
glLoadName (0);
glBegin (GL_QUADS);
glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid-rad) * t2);
glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid-rad) * t2);
glVertex3dv (p + (xi1mid+rad) * t1 + (xi2mid+rad) * t2);
glVertex3dv (p + (xi1mid-rad) * t1 + (xi2mid+rad) * t2);
glEnd ();
}
glCallList (trilists.Get(1));
glDisable (GL_POLYGON_OFFSET_FILL);
glPopName();
glMatrixMode (GL_PROJECTION);
glPopMatrix();
glMatrixMode (GL_MODELVIEW);
glPopMatrix();
glFlush();
hits = glRenderMode (GL_RENDER);
int minname = 0;
GLuint mindepth = 0;
// find clippingplane
GLuint clipdepth = 0; // GLuint(-1);
for (int i = 0; i < hits; i++)
{
int curname = selbuf[4*i+3];
if (!curname) clipdepth = selbuf[4*i+1];
}
for (int i = 0; i < hits; i++)
{
int curname = selbuf[4*i+3];
GLuint curdepth = selbuf[4*i+1];
if (curname && (curdepth> clipdepth) &&
(curdepth < mindepth || !minname))
{
mindepth = curdepth;
minname = curname;
}
}
occgeometry->LowLightAll();
if (minname)
{
occgeometry->fvispar[minname-1].Highlight();
if (vispar.occzoomtohighlightedentity)
occgeometry->changed = OCCGEOMETRYVISUALIZATIONFULLCHANGE;
else
occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
cout << "Selected face: " << minname << endl;
}
else
{
occgeometry->changed = OCCGEOMETRYVISUALIZATIONHALFCHANGE;
}
glDisable(GL_CLIP_PLANE0);
SelectFaceInOCCDialogTree (minname);
// Philippose - 30/01/2009
// Set the currently selected face in the array
// for local face mesh size definition
occgeometry->SetSelectedFace(minname);
// selecttimestamp = NextTimeStamp();
}
}
#endif
#endif // NOTCL

33
libsrc/occ/vsocc.hpp Normal file
View File

@ -0,0 +1,33 @@
#ifndef FILE_VSOCC
#define FILE_VSOCC
/**************************************************************************/
/* File: vsocc.hpp */
/* Author: Joachim Schoeberl */
/* Date: 05. Jan. 2011 */
/**************************************************************************/
namespace netgen
{
class VisualSceneOCCGeometry : public VisualScene
{
Array<int> trilists;
Array<int> linelists;
int selsurf;
class OCCGeometry * occgeometry;
public:
VisualSceneOCCGeometry ();
virtual ~VisualSceneOCCGeometry ();
void SetGeometry (class OCCGeometry * ageom) { occgeometry = ageom; }
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
virtual void MouseDblClick (int px, int py);
};
}
#endif

View File

@ -3,6 +3,13 @@ stltool.hpp stltopology.hpp
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include
METASOURCES = AUTO METASOURCES = AUTO
noinst_LTLIBRARIES = libstl.la
noinst_LTLIBRARIES = libstl.la libstlvis.la
libstl_la_SOURCES = meshstlsurface.cpp stlgeom.cpp stlgeomchart.cpp \ libstl_la_SOURCES = meshstlsurface.cpp stlgeom.cpp stlgeomchart.cpp \
stlgeommesh.cpp stlline.cpp stltool.cpp stltopology.cpp stlgeommesh.cpp stlline.cpp stltool.cpp stltopology.cpp
libstlvis_la_SOURCES = stlpkg.cpp vsstl.cpp

View File

@ -1024,7 +1024,7 @@ PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi) Point<3> & newp, PointGeomInfo & newgi) const
{ {
newp = p1+secpoint*(p2-p1); newp = p1+secpoint*(p2-p1);
@ -1087,7 +1087,7 @@ PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & gi1, const EdgePointGeomInfo & gi1,
const EdgePointGeomInfo & gi2, const EdgePointGeomInfo & gi2,
Point<3> & newp, EdgePointGeomInfo & newgi) Point<3> & newp, EdgePointGeomInfo & newgi) const
{ {
/* /*
(*testout) << "edge-between: p1 = " << p1 << ", p2 = " << p2 (*testout) << "edge-between: p1 = " << p1 << ", p2 = " << p2
@ -1113,14 +1113,14 @@ PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
} }
void RefinementSTLGeometry :: ProjectToSurface (Point<3> & p, int surfi) void RefinementSTLGeometry :: ProjectToSurface (Point<3> & p, int surfi) const
{ {
cout << "RefinementSTLGeometry :: ProjectToSurface not implemented!" << endl; cout << "RefinementSTLGeometry :: ProjectToSurface not implemented!" << endl;
}; };
void RefinementSTLGeometry :: ProjectToSurface (Point<3> & p, int surfi, void RefinementSTLGeometry :: ProjectToSurface (Point<3> & p, int surfi,
PointGeomInfo & gi) PointGeomInfo & gi) const
{ {
((STLGeometry&)geom).SelectChartOfTriangle (gi.trignum); ((STLGeometry&)geom).SelectChartOfTriangle (gi.trignum);
gi.trignum = geom.Project (p); gi.trignum = geom.Project (p);

View File

@ -103,16 +103,16 @@ public:
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi); Point<3> & newp, PointGeomInfo & newgi) const;
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi); Point<3> & newp, EdgePointGeomInfo & newgi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi); virtual void ProjectToSurface (Point<3> & p, int surfi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi); virtual void ProjectToSurface (Point<3> & p, int surfi, PointGeomInfo & gi) const;
}; };

View File

@ -67,16 +67,42 @@ STLGeometry :: ~STLGeometry()
delete edgedata; delete edgedata;
} }
int STLGeometry :: GenerateMesh (Mesh*& mesh, void STLGeometry :: Save (string filename) const
int perfstepsstart, int perfstepsend, char* optstring)
{ {
return STLMeshingDummy (this, mesh, perfstepsstart, perfstepsend, optstring); const char * cfilename = filename.c_str();
if (strlen(cfilename) < 4)
throw NgException ("illegal filename");
if (strlen(cfilename) > 3 &&
strcmp (&cfilename[strlen(cfilename)-3], "stl") == 0)
{
STLTopology::Save (cfilename);
}
else if (strlen(cfilename) > 4 &&
strcmp (&cfilename[strlen(cfilename)-4], "stlb") == 0)
{
SaveBinary (cfilename,"Binary STL Geometry");
}
else if (strlen(cfilename) > 4 &&
strcmp (&cfilename[strlen(cfilename)-4], "stle") == 0)
{
SaveSTLE (cfilename);
}
}
int STLGeometry :: GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend)
{
return STLMeshingDummy (this, mesh, mparam, perfstepsstart, perfstepsend);
} }
const Refinement & STLGeometry :: GetRefinement () const const Refinement & STLGeometry :: GetRefinement () const
{ {
return * new RefinementSTLGeometry (*this); return RefinementSTLGeometry (*this);
} }

View File

@ -172,6 +172,7 @@ namespace netgen
void Clear(); void Clear();
virtual void Save (string filename) const;
void STLInfo(double* data); void STLInfo(double* data);
@ -438,8 +439,8 @@ namespace netgen
friend class MeshingSTLSurface; friend class MeshingSTLSurface;
virtual int GenerateMesh (Mesh*& mesh, virtual int GenerateMesh (Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring); int perfstepsstart, int perfstepsend);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;
}; };
@ -449,8 +450,8 @@ namespace netgen
extern int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, extern int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, MeshingParameters & mparam,
int perfstepsstart, int perfstepsend, char* optstring); int perfstepsstart, int perfstepsend);
} }

View File

@ -1329,9 +1329,8 @@ void STLGeometry :: RestrictHChartDistOneChart(int chartnum, Array<int>& acttrig
} }
//void * STLMeshingDummy (void *) int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, MeshingParameters & mparam,
int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh, int perfstepsstart, int perfstepsend)
int perfstepsstart, int perfstepsend, char* optstring)
{ {
if (perfstepsstart > perfstepsend) return 0; if (perfstepsstart > perfstepsend) return 0;
@ -1433,6 +1432,7 @@ int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh,
PrintWarning("Surface optimization with meshed volume is dangerous!!!"); PrintWarning("Surface optimization with meshed volume is dangerous!!!");
} }
/*
if (!optstring || strlen(optstring) == 0) if (!optstring || strlen(optstring) == 0)
{ {
mparam.optimize2d = "smcm"; mparam.optimize2d = "smcm";
@ -1441,6 +1441,7 @@ int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh,
{ {
mparam.optimize2d = optstring; mparam.optimize2d = optstring;
} }
*/
STLSurfaceOptimization (*stlgeometry, *mesh, mparam); STLSurfaceOptimization (*stlgeometry, *mesh, mparam);
@ -1555,6 +1556,7 @@ int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh,
return 0; return 0;
} }
/*
if (!optstring || strlen(optstring) == 0) if (!optstring || strlen(optstring) == 0)
{ {
mparam.optimize3d = "cmdmstm"; mparam.optimize3d = "cmdmstm";
@ -1563,7 +1565,7 @@ int STLMeshingDummy (STLGeometry* stlgeometry, Mesh*& mesh,
{ {
mparam.optimize3d = optstring; mparam.optimize3d = optstring;
} }
*/
OptimizeVolume (mparam, *mesh); OptimizeVolume (mparam, *mesh);

621
libsrc/stlgeom/stlpkg.cpp Normal file
View File

@ -0,0 +1,621 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <csg.hpp>
#include <meshing.hpp>
#include <incvis.hpp>
#include <visual.hpp>
#include <stlgeom.hpp>
#include "vsstl.hpp"
extern "C" int Ng_STL_Init (Tcl_Interp * interp);
namespace netgen
{
extern NetgenGeometry * ng_geometry;
extern AutoPtr<Mesh> mesh;
static VisualSceneSTLGeometry vsstlgeom;
static VisualSceneSTLMeshing vsstlmeshing;
char * err_needsstlgeometry = (char*) "This operation needs an STL geometry";
class STLGeometryRegister : public GeometryRegister
{
public:
virtual NetgenGeometry * Load (string filename) const;
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
virtual void SetParameters (Tcl_Interp * interp)
{
stlparam.yangle =
atof (Tcl_GetVar (interp, "::stloptions.yangle", 0));
stlparam.contyangle =
atof (Tcl_GetVar (interp, "::stloptions.contyangle", 0));
stlparam.edgecornerangle =
atof (Tcl_GetVar (interp, "::stloptions.edgecornerangle", 0));
stlparam.chartangle =
atof (Tcl_GetVar (interp, "::stloptions.chartangle", 0));
stlparam.outerchartangle =
atof (Tcl_GetVar (interp, "::stloptions.outerchartangle", 0));
stlparam.usesearchtree =
atoi (Tcl_GetVar (interp, "::stloptions.usesearchtree", 0));
stlparam.atlasminh =
atof (Tcl_GetVar (interp, "::stloptions.atlasminh", 0));
stlparam.resthsurfcurvfac =
atof (Tcl_GetVar (interp, "::stloptions.resthsurfcurvfac", 0));
stlparam.resthsurfcurvenable =
atoi (Tcl_GetVar (interp, "::stloptions.resthsurfcurvenable", 0));
stlparam.resthatlasfac =
atof (Tcl_GetVar (interp, "::stloptions.resthatlasfac", 0));
stlparam.resthatlasenable =
atoi (Tcl_GetVar (interp, "::stloptions.resthatlasenable", 0));
stlparam.resthchartdistfac =
atof (Tcl_GetVar (interp, "::stloptions.resthchartdistfac", 0));
stlparam.resthchartdistenable =
atoi (Tcl_GetVar (interp, "::stloptions.resthchartdistenable", 0));
stlparam.resthlinelengthfac =
atof (Tcl_GetVar (interp, "::stloptions.resthlinelengthfac", 0));
stlparam.resthlinelengthenable =
atoi (Tcl_GetVar (interp, "::stloptions.resthlinelengthenable", 0));
stlparam.resthcloseedgefac =
atof (Tcl_GetVar (interp, "::stloptions.resthcloseedgefac", 0));
stlparam.resthcloseedgeenable =
atoi (Tcl_GetVar (interp, "::stloptions.resthcloseedgeenable", 0));
stlparam.resthedgeanglefac =
atof (Tcl_GetVar (interp, "::stloptions.resthedgeanglefac", 0));
stlparam.resthedgeangleenable =
atoi (Tcl_GetVar (interp, "::stloptions.resthedgeangleenable", 0));
stlparam.resthsurfmeshcurvfac =
atof (Tcl_GetVar (interp, "::stloptions.resthsurfmeshcurvfac", 0));
stlparam.resthsurfmeshcurvenable =
atoi (Tcl_GetVar (interp, "::stloptions.resthsurfmeshcurvenable", 0));
stlparam.recalc_h_opt =
atoi (Tcl_GetVar (interp, "::stloptions.recalchopt", 0));
// stlparam.Print (cout);
}
};
int Ng_SetSTLParameters (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
STLGeometryRegister reg;
reg.SetParameters (interp);
return TCL_OK;
}
int Ng_STLDoctor (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
//cout << "STL doctor" << endl;
STLGeometry * stlgeometry =
dynamic_cast<STLGeometry*> (ng_geometry);
stldoctor.drawmeshededges =
atoi (Tcl_GetVar (interp, "::stldoctor.drawmeshededges", 0));
stldoctor.geom_tol_fact =
atof (Tcl_GetVar (interp, "::stldoctor.geom_tol_fact", 0));
stldoctor.useexternaledges =
atoi (Tcl_GetVar (interp, "::stldoctor.useexternaledges", 0));
stldoctor.showfaces =
atoi (Tcl_GetVar (interp, "::stldoctor.showfaces", 0));
stldoctor.conecheck =
atoi (Tcl_GetVar (interp, "::stldoctor.conecheck", 0));
stldoctor.spiralcheck =
atoi (Tcl_GetVar (interp, "::stldoctor.spiralcheck", 0));
stldoctor.selectwithmouse =
atoi (Tcl_GetVar (interp, "::stldoctor.selectwithmouse", 0));
stldoctor.showedgecornerpoints =
atoi (Tcl_GetVar (interp, "::stldoctor.showedgecornerpoints", 0));
stldoctor.showmarkedtrigs =
atoi (Tcl_GetVar (interp, "::stldoctor.showmarkedtrigs", 0));
stldoctor.showtouchedtrigchart =
atoi (Tcl_GetVar (interp, "::stldoctor.showtouchedtrigchart", 0));
//cout << "smt=" << stldoctor.showmarkedtrigs << endl;
stldoctor.dirtytrigfact =
atof (Tcl_GetVar (interp, "::stldoctor.dirtytrigfact", 0));
stldoctor.smoothnormalsweight =
atof (Tcl_GetVar (interp, "::stldoctor.smoothnormalsweight", 0));
stldoctor.smoothangle =
atof (Tcl_GetVar (interp, "::stldoctor.smoothangle", 0));
stldoctor.selectmode =
atoi (Tcl_GetVar (interp, "::stldoctor.selectmode", 0));
stldoctor.edgeselectmode =
atoi (Tcl_GetVar (interp, "::stldoctor.edgeselectmode", 0));
stldoctor.longlinefact =
atoi (Tcl_GetVar (interp, "::stldoctor.longlinefact", 0));
stldoctor.showexcluded =
atoi (Tcl_GetVar (interp, "::stldoctor.showexcluded", 0));
if (!stldoctor.selectwithmouse)
{
stldoctor.selecttrig =
atoi (Tcl_GetVar (interp, "::stldoctor.selecttrig", 0));
stldoctor.nodeofseltrig =
atoi (Tcl_GetVar (interp, "::stldoctor.nodeofseltrig", 0));
}
stldoctor.showvicinity =
atoi (Tcl_GetVar (interp, "::stldoctor.showvicinity", 0));
stldoctor.vicinity =
atoi (Tcl_GetVar (interp, "::stldoctor.vicinity", 0));
if (argc >= 2)
{
if (!stlgeometry)
{
Tcl_SetResult (interp, err_needsstlgeometry, TCL_STATIC);
return TCL_ERROR;
}
if (strcmp (argv[1], "destroy0trigs") == 0)
{
stlgeometry->DestroyDirtyTrigs();
}
else if (strcmp (argv[1], "movepointtomiddle") == 0)
{
stlgeometry->MoveSelectedPointToMiddle();
}
else if (strcmp (argv[1], "calcnormals") == 0)
{
stlgeometry->CalcNormalsFromGeometry();
}
else if (strcmp (argv[1], "showchartnum") == 0)
{
stlgeometry->ShowSelectedTrigChartnum();
}
else if (strcmp (argv[1], "showcoords") == 0)
{
stlgeometry->ShowSelectedTrigCoords();
}
else if (strcmp (argv[1], "loadmarkedtrigs") == 0)
{
stlgeometry->LoadMarkedTrigs();
}
else if (strcmp (argv[1], "savemarkedtrigs") == 0)
{
stlgeometry->SaveMarkedTrigs();
}
else if (strcmp (argv[1], "neighbourangles") == 0)
{
stlgeometry->NeighbourAnglesOfSelectedTrig();
}
else if (strcmp (argv[1], "vicinity") == 0)
{
stlgeometry->CalcVicinity(stldoctor.selecttrig);
}
else if (strcmp (argv[1], "markdirtytrigs") == 0)
{
stlgeometry->MarkDirtyTrigs();
}
else if (strcmp (argv[1], "smoothdirtytrigs") == 0)
{
stlgeometry->SmoothDirtyTrigs();
}
else if (strcmp (argv[1], "smoothrevertedtrigs") == 0)
{
stlgeometry->GeomSmoothRevertedTrigs();
}
else if (strcmp (argv[1], "invertselectedtrig") == 0)
{
stlgeometry->InvertTrig(stlgeometry->GetSelectTrig());
}
else if (strcmp (argv[1], "deleteselectedtrig") == 0)
{
stlgeometry->DeleteTrig(stlgeometry->GetSelectTrig());
}
else if (strcmp (argv[1], "smoothgeometry") == 0)
{
stlgeometry->SmoothGeometry();
}
else if (strcmp (argv[1], "orientafterselectedtrig") == 0)
{
stlgeometry->OrientAfterTrig(stlgeometry->GetSelectTrig());
}
else if (strcmp (argv[1], "marktoperrortrigs") == 0)
{
stlgeometry->MarkTopErrorTrigs();
}
else if (strcmp (argv[1], "exportedges") == 0)
{
stlgeometry->ExportEdges();
}
else if (strcmp (argv[1], "importedges") == 0)
{
stlgeometry->ImportEdges();
}
else if (strcmp (argv[1], "importexternaledges") == 0)
{
stlgeometry->ImportExternalEdges(argv[2]);
}
else if (strcmp (argv[1], "loadedgedata") == 0)
{
if (argc >= 3)
{
stlgeometry->LoadEdgeData(argv[2]);
}
}
else if (strcmp (argv[1], "saveedgedata") == 0)
{
if (argc >= 3)
{
stlgeometry->SaveEdgeData(argv[2]);
}
}
else if (strcmp (argv[1], "buildexternaledges") == 0)
{
stlgeometry->BuildExternalEdgesFromEdges();
}
else if (strcmp (argv[1], "smoothnormals") == 0)
{
stlgeometry->SmoothNormals();
}
else if (strcmp (argv[1], "marknonsmoothnormals") == 0)
{
stlgeometry->MarkNonSmoothNormals();
}
else if (strcmp (argv[1], "addexternaledge") == 0)
{
stlgeometry->AddExternalEdgeAtSelected();
}
else if (strcmp (argv[1], "addgeomline") == 0)
{
stlgeometry->AddExternalEdgesFromGeomLine();
}
else if (strcmp (argv[1], "addlonglines") == 0)
{
stlgeometry->AddLongLinesToExternalEdges();
}
else if (strcmp (argv[1], "addclosedlines") == 0)
{
stlgeometry->AddClosedLinesToExternalEdges();
}
else if (strcmp (argv[1], "addnotsinglelines") == 0)
{
stlgeometry->AddAllNotSingleLinesToExternalEdges();
}
else if (strcmp (argv[1], "deletedirtyexternaledges") == 0)
{
stlgeometry->DeleteDirtyExternalEdges();
}
else if (strcmp (argv[1], "deleteexternaledge") == 0)
{
stlgeometry->DeleteExternalEdgeAtSelected();
}
else if (strcmp (argv[1], "deletevicexternaledge") == 0)
{
stlgeometry->DeleteExternalEdgeInVicinity();
}
else if (strcmp (argv[1], "addlonglines") == 0)
{
stlgeometry->STLDoctorLongLinesToCandidates();
}
else if (strcmp (argv[1], "deletedirtyedges") == 0)
{
stlgeometry->STLDoctorDirtyEdgesToCandidates();
}
else if (strcmp (argv[1], "undoedgechange") == 0)
{
stlgeometry->UndoEdgeChange();
}
else if (strcmp (argv[1], "buildedges") == 0)
{
stlgeometry->STLDoctorBuildEdges();
}
else if (strcmp (argv[1], "confirmedge") == 0)
{
stlgeometry->STLDoctorConfirmEdge();
}
else if (strcmp (argv[1], "candidateedge") == 0)
{
stlgeometry->STLDoctorCandidateEdge();
}
else if (strcmp (argv[1], "excludeedge") == 0)
{
stlgeometry->STLDoctorExcludeEdge();
}
else if (strcmp (argv[1], "undefinededge") == 0)
{
stlgeometry->STLDoctorUndefinedEdge();
}
else if (strcmp (argv[1], "setallundefinededges") == 0)
{
stlgeometry->STLDoctorSetAllUndefinedEdges();
}
else if (strcmp (argv[1], "erasecandidateedges") == 0)
{
stlgeometry->STLDoctorEraseCandidateEdges();
}
else if (strcmp (argv[1], "confirmcandidateedges") == 0)
{
stlgeometry->STLDoctorConfirmCandidateEdges();
}
else if (strcmp (argv[1], "confirmedtocandidateedges") == 0)
{
stlgeometry->STLDoctorConfirmedToCandidateEdges();
}
}
return TCL_OK;
}
NetgenGeometry * STLGeometryRegister :: Load (string filename) const
{
const char * cfilename = filename.c_str();
if (strcmp (&cfilename[strlen(cfilename)-3], "stl") == 0)
{
PrintMessage (1, "Load STL geometry file ", cfilename);
ifstream infile(cfilename);
STLGeometry * hgeom = STLGeometry :: Load (infile);
hgeom -> edgesfound = 0;
return hgeom;
}
else if (strcmp (&cfilename[strlen(cfilename)-4], "stlb") == 0)
{
PrintMessage (1, "Load STL binary geometry file ", cfilename);
ifstream infile(cfilename);
STLGeometry * hgeom = STLGeometry :: LoadBinary (infile);
hgeom -> edgesfound = 0;
return hgeom;
}
else if (strcmp (&cfilename[strlen(cfilename)-3], "nao") == 0)
{
PrintMessage (1, "Load naomi (F. Kickinger) geometry file ", cfilename);
ifstream infile(cfilename);
STLGeometry * hgeom = STLGeometry :: LoadNaomi (infile);
hgeom -> edgesfound = 0;
return hgeom;
}
return NULL;
}
int Ng_STLInfo (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
double data[10];
static char buf[20];
STLGeometry * stlgeometry = dynamic_cast<STLGeometry*> (ng_geometry);
if (!stlgeometry)
{
Tcl_SetResult (interp, err_needsstlgeometry, TCL_STATIC);
return TCL_ERROR;
}
if (stlgeometry)
{
stlgeometry->STLInfo(data);
// cout << "NT=" << data[0] << endl;
if (argc == 2)
{
if (strcmp (argv[1], "status") == 0)
{
switch (stlgeometry->GetStatus())
{
case STLGeometry::STL_GOOD:
strcpy (buf, "GOOD"); break;
case STLGeometry::STL_WARNING:
strcpy (buf, "WARNING"); break;
case STLGeometry::STL_ERROR:
strcpy (buf, "ERROR"); break;
}
Tcl_SetResult (interp, buf, TCL_STATIC);
return TCL_OK;
}
if (strcmp (argv[1], "statustext") == 0)
{
Tcl_SetResult (interp, (char*)stlgeometry->GetStatusText().c_str(), TCL_STATIC);
return TCL_OK;
}
if (strcmp (argv[1], "topology_ok") == 0)
{
sprintf (buf, "%d", stlgeometry->Topology_Ok());
Tcl_SetResult (interp, buf, TCL_STATIC);
}
if (strcmp (argv[1], "orientation_ok") == 0)
{
sprintf (buf, "%d", stlgeometry->Orientation_Ok());
Tcl_SetResult (interp, buf, TCL_STATIC);
}
}
}
else
{
data[0] = 0;
data[1] = 0;
data[2] = 0;
data[3] = 0;
data[4] = 0;
data[5] = 0;
data[6] = 0;
data[7] = 0;
}
sprintf (buf, "%i", (int)data[0]);
Tcl_SetVar (interp, argv[1], buf, 0);
sprintf (buf, "%5.3g", data[1]);
Tcl_SetVar (interp, argv[2], buf, 0);
sprintf (buf, "%5.3g", data[2]);
Tcl_SetVar (interp, argv[3], buf, 0);
sprintf (buf, "%5.3g", data[3]);
Tcl_SetVar (interp, argv[4], buf, 0);
sprintf (buf, "%5.3g", data[4]);
Tcl_SetVar (interp, argv[5], buf, 0);
sprintf (buf, "%5.3g", data[5]);
Tcl_SetVar (interp, argv[6], buf, 0);
sprintf (buf, "%5.3g", data[6]);
Tcl_SetVar (interp, argv[7], buf, 0);
sprintf (buf, "%i", (int)data[7]);
Tcl_SetVar (interp, argv[8], buf, 0);
return TCL_OK;
}
extern int Ng_SetMeshingParameters (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[]);
int Ng_STLCalcLocalH (ClientData clientData,
Tcl_Interp * interp,
int argc, tcl_const char *argv[])
{
for (int i = 0; i < geometryregister.Size(); i++)
geometryregister[i] -> SetParameters (interp);
Ng_SetMeshingParameters (clientData, interp, argc, argv);
STLGeometry * stlgeometry = dynamic_cast<STLGeometry*> (ng_geometry);
if (mesh.Ptr() && stlgeometry)
{
mesh -> SetLocalH (stlgeometry->GetBoundingBox().PMin() - Vec3d(10, 10, 10),
stlgeometry->GetBoundingBox().PMax() + Vec3d(10, 10, 10),
mparam.grading);
stlgeometry -> RestrictLocalH(*mesh, mparam.maxh);
if (stlparam.resthsurfmeshcurvenable)
mesh -> CalcLocalHFromSurfaceCurvature (stlparam.resthsurfmeshcurvfac);
}
return TCL_OK;
}
VisualScene * STLGeometryRegister :: GetVisualScene (const NetgenGeometry * geom) const
{
STLGeometry * geometry = dynamic_cast<STLGeometry*> (ng_geometry);
if (geometry)
{
vsstlmeshing.SetGeometry (geometry);
return &vsstlmeshing;
}
return NULL;
}
}
using namespace netgen;
extern "C" int Ng_STL_Init (Tcl_Interp * interp);
int Ng_STL_Init (Tcl_Interp * interp)
{
geometryregister.Append (new STLGeometryRegister);
Tcl_CreateCommand (interp, "Ng_SetSTLParameters", Ng_SetSTLParameters,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_STLDoctor", Ng_STLDoctor,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_STLInfo", Ng_STLInfo,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
Tcl_CreateCommand (interp, "Ng_STLCalcLocalH", Ng_STLCalcLocalH,
(ClientData)NULL,
(Tcl_CmdDeleteProc*) NULL);
return TCL_OK;
}

View File

@ -87,7 +87,7 @@ STLGeometry * STLTopology :: LoadBinary (istream & ist)
} }
void STLTopology :: SaveBinary (const char* filename, const char* aname) void STLTopology :: SaveBinary (const char* filename, const char* aname) const
{ {
ofstream ost(filename); ofstream ost(filename);
PrintFnStart("Write STL binary file '",filename,"'"); PrintFnStart("Write STL binary file '",filename,"'");
@ -146,7 +146,7 @@ void STLTopology :: SaveBinary (const char* filename, const char* aname)
} }
void STLTopology :: SaveSTLE (const char* filename) void STLTopology :: SaveSTLE (const char* filename) const
{ {
ofstream outf (filename); ofstream outf (filename);
int i, j; int i, j;
@ -263,7 +263,7 @@ STLGeometry * STLTopology :: LoadNaomi (istream & ist)
return geom; return geom;
} }
void STLTopology :: Save (const char* filename) void STLTopology :: Save (const char* filename) const
{ {
PrintFnStart("Write stl-file '",filename, "'"); PrintFnStart("Write stl-file '",filename, "'");

View File

@ -276,9 +276,9 @@ public:
static STLGeometry * Load (istream & ist); static STLGeometry * Load (istream & ist);
static STLGeometry * LoadBinary (istream & ist); static STLGeometry * LoadBinary (istream & ist);
void Save (const char* filename); void Save (const char* filename) const;
void SaveBinary (const char* filename, const char* aname); void SaveBinary (const char* filename, const char* aname) const;
void SaveSTLE (const char * filename); // stores trigs and edges void SaveSTLE (const char * filename) const; // stores trigs and edges
virtual void InitSTLGeometry (const Array<STLReadTriangle> & readtrigs); virtual void InitSTLGeometry (const Array<STLReadTriangle> & readtrigs);

1212
libsrc/stlgeom/vsstl.cpp Normal file

File diff suppressed because it is too large Load Diff

53
libsrc/stlgeom/vsstl.hpp Normal file
View File

@ -0,0 +1,53 @@
#ifndef FILE_VSSTL
#define FILE_VSSTL
/**************************************************************************/
/* File: vsstl.hpp */
/* Author: Joachim Schoeberl */
/* Date: 05. Jan. 2011 */
/**************************************************************************/
namespace netgen
{
class VisualSceneSTLGeometry : public VisualScene
{
Array<int> trilists;
class STLGeometry * stlgeometry;
public:
VisualSceneSTLGeometry ();
virtual ~VisualSceneSTLGeometry ();
void SetGeometry (class STLGeometry * astlgeometry) { stlgeometry = astlgeometry; }
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
};
class VisualSceneSTLMeshing : public VisualScene
{
Array<int> trilists;
int selecttrig, nodeofseltrig;
class STLGeometry * stlgeometry;
public:
VisualSceneSTLMeshing ();
virtual ~VisualSceneSTLMeshing ();
void SetGeometry (class STLGeometry * astlgeometry) { stlgeometry = astlgeometry; }
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
virtual void MouseDblClick (int px, int py);
int seltria;
};
}
#endif

View File

@ -6,6 +6,6 @@ include_HEADERS = soldata.hpp
AM_CPPFLAGS = $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) AM_CPPFLAGS = $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES)
METASOURCES = AUTO METASOURCES = AUTO
noinst_LIBRARIES = libvisual.a noinst_LIBRARIES = libvisual.a
libvisual_a_SOURCES = meshdoc.cpp mvdraw.cpp stlmeshing.cpp vscsg.cpp \ libvisual_a_SOURCES = meshdoc.cpp mvdraw.cpp \
vsfieldlines.cpp vsmesh.cpp vsocc.cpp vssolution.cpp importsolution.cpp vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp
AM_CXXFLAGS = -DOPENGL AM_CXXFLAGS = -DOPENGL

View File

@ -1,16 +1,12 @@
#include <mystdlib.h> #include <mystdlib.h>
#include <myadt.hpp> #include <myadt.hpp>
#include <meshing.hpp> #include <meshing.hpp>
#include <csg.hpp>
#include <geometry2d.hpp>
#include <stlgeom.hpp>
#include <visual.hpp> #include <visual.hpp>
// #include <parallel.hpp> // #include <parallel.hpp>
#ifndef WIN32 #ifndef WIN32
#define GLX_GLXEXT_LEGACY #define GLX_GLXEXT_LEGACY
@ -83,17 +79,11 @@ namespace netgen
double dist = 0; double dist = 0;
// double dist = 6; // double dist = 6;
// vorher: pnear = 2; // vorher: pnear = 2;
double pnear = 0.1; // double pnear = 0.1;
double pfar = 10; // double pfar = 10;
extern STLGeometry * stlgeometry;
extern AutoPtr<SplineGeometry2d> geometry2d;
extern AutoPtr<Mesh> mesh;
extern Array<SpecialPoint> specpoints;
extern Array<Box<3> > boxes;
VisualScene :: VisualScene () VisualScene :: VisualScene ()
{ {
changeval = -1; changeval = -1;
@ -107,6 +97,7 @@ namespace netgen
} }
extern void Render();
void Render () void Render ()
{ {
multithread.redraw = 1; multithread.redraw = 1;
@ -469,79 +460,6 @@ namespace netgen
} }
/*
void VisualScene :: CreateTexture (int ncols, int linear, int typ)
{
static const double colp[][3] =
{
{ 1, 0, 0 },
{ 1, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 1 },
{ 0, 0, 1 },
};
if (ntexcols != 1024)
{
ntexcols = 1024;
// glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glGenTextures (1, &coltexname);
glBindTexture (GL_TEXTURE_1D, coltexname);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
for (int level = 0; level <= 11; level++)
{
ncols = 2048 >> level;
cout << "ncols = " << ncols << endl;
colortexture = new GLubyte[4*ncols+12];
for (int i = 0; i < ncols; i++)
{
double value = 4.0 * i / (ncols-1);
int iv = int(value);
double r = value - iv;
GLdouble col[3];
for (int j = 0; j < 3; j++)
col[j] = (1-r) * colp[iv][j] + r * colp[iv+1][j];
colortexture[4*i] = GLubyte (255 * col[0]);
colortexture[4*i+1] = GLubyte (255 * col[1]);
colortexture[4*i+2] = GLubyte (255 * col[2]);
colortexture[4*i+3] = GLubyte(255);
if (ncols > 20)
if ( i % (ncols / 10) == 0)
{
colortexture[4*i] = GLubyte (0);
colortexture[4*i+1] = GLubyte (0);
colortexture[4*i+2] = GLubyte (0);
colortexture[4*i+4] = GLubyte (0);
colortexture[4*i+5] = GLubyte (0);
colortexture[4*i+6] = GLubyte (0);
}
}
glTexImage1D (GL_TEXTURE_1D, level, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture);
}
}
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE
glBindTexture (GL_TEXTURE_1D, coltexname);
}
*/
void VisualScene :: CreateTexture (int ncols, int linear, int typ) void VisualScene :: CreateTexture (int ncols, int linear, int typ)
{ {
@ -624,92 +542,6 @@ namespace netgen
/*
void VisualScene :: CreateTexture (int ncols, int linear, int typ)
{
if (ncols < 2) ncols = 2;
if (linear) ncols = 32;
else ncols = 8;
if (ntexcols != ncols)
{
if (colortexture)
{
glDeleteTextures (1, &coltexname);
delete colortexture;
}
ntexcols = ncols;
colortexture = new GLubyte[4*ncols+12];
const double colp[][3] =
{
{ 1, 0, 0 },
{ 1, 1, 0 },
{ 0, 1, 0 },
{ 0, 1, 1 },
{ 0, 0, 1 },
};
for (int i = 0; i < ncols; i++)
{
double value = 4.0 * i / (ncols-1);
int iv = int(value);
double r = value - iv;
GLdouble col[3];
for (int j = 0; j < 3; j++)
col[j] = (1-r) * colp[iv][j] + r * colp[iv+1][j];
colortexture[4*i+4] = GLubyte (255 * col[0]);
colortexture[4*i+5] = GLubyte (255 * col[1]);
colortexture[4*i+6] = GLubyte (255 * col[2]);
colortexture[4*i+7] = GLubyte(255);
}
for (int j = 0; j < 4; j++)
{
colortexture[j] = colortexture[4+j];
colortexture[ncols*4+4+j] = colortexture[ncols*4+j];
}
// glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glGenTextures (1, &coltexname);
glBindTexture (GL_TEXTURE_1D, coltexname);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage1D (GL_TEXTURE_1D, 0, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture+4);
int bcol[] = { 0, 0, -1, -1 };
glTexParameteriv (GL_TEXTURE_1D, GL_TEXTURE_BORDER_COLOR, bcol);
}
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE
glBindTexture (GL_TEXTURE_1D, coltexname);
if (linear)
{
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
{
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
}
*/
void VisualScene :: DrawColorBar (double minval, double maxval, int logscale, bool linear) void VisualScene :: DrawColorBar (double minval, double maxval, int logscale, bool linear)
{ {
if (!vispar.drawcolorbar) return; if (!vispar.drawcolorbar) return;
@ -979,499 +811,8 @@ 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++)
{
geometry2d->GetSplines().Get(i)->GetPoints (20, points);
glBegin (GL_LINE_STRIP);
for (int j = 0; j < points.Size(); j++)
glVertex3f (points[j](0), points[j](1), 0);
glEnd();
}
glColor3f (1, 0, 0);
for (int i = 1; i <= geometry2d->GetSplines().Size(); i++)
{
int other = geometry2d->GetSplines().Get(i)->copyfrom;
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++)
{
glVertex3f (points[j](0), points[j](1), 0);
glVertex3f (otherpoints[j](0), otherpoints[j](1), 0);
}
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();
}
/* *********************** Draw STL Geometry **************** */
VisualSceneSTLGeometry :: VisualSceneSTLGeometry ()
: VisualScene()
{
;
}
VisualSceneSTLGeometry :: ~VisualSceneSTLGeometry ()
{
;
}
void VisualSceneSTLGeometry :: DrawScene ()
{
if (changeval != stlgeometry->GetNT())
BuildScene();
changeval = stlgeometry->GetNT();
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
SetLight();
glPushMatrix();
glMultMatrixf (transformationmat);
glShadeModel (GL_SMOOTH);
glDisable (GL_COLOR_MATERIAL);
glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
double shine = vispar.shininess;
// double transp = vispar.transp;
glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, shine);
glLogicOp (GL_COPY);
float mat_col[] = { 0.2f, 0.2f, 0.8f, 1.0f};
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_col);
glPolygonOffset (1, 1);
glEnable (GL_POLYGON_OFFSET_FILL);
glCallList (trilists.Get(1));
glDisable (GL_POLYGON_OFFSET_FILL);
int showtrias = vispar.showstltrias;
if (showtrias)
{
float mat_coll[] = { 0.2f, 0.2f, 0.2f, 1.0f };
glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_coll);
glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
glCallList (trilists.Get(1));
}
/*
glBegin (GL_TRIANGLES);
for (j = 1; j <= stlgeometry -> GetNT(); j++)
{
const STLTriangle & tria = stlgeometry -> GetTriangle(j);
glNormal3f (tria.normal.X(),
tria.normal.Y(),
tria.normal.Z());
for (k = 0; k < 3; k++)
{
glVertex3f (tria.pts[k].X(),
tria.pts[k].Y(),
tria.pts[k].Z());
}
}
glEnd ();
*/
glPopMatrix();
glFinish();
}
void VisualSceneSTLGeometry :: BuildScene (int zoomall)
{
// cout << "rebuild stl geometry scene" << endl;
center = stlgeometry -> GetBoundingBox().Center();
rad = stlgeometry -> GetBoundingBox().Diam() / 2;
CalcTransformationMatrices();
for (int i = 1; i <= trilists.Size(); i++)
glDeleteLists (trilists.Elem(i), 1);
trilists.SetSize(0);
trilists.Append (glGenLists (1));
glNewList (trilists.Last(), GL_COMPILE);
glEnable (GL_NORMALIZE);
glBegin (GL_TRIANGLES);
for (int j = 1; j <= stlgeometry -> GetNT(); j++)
{
const Vec3d & n = stlgeometry->GetTriangle(j).Normal();
glNormal3f (n.X(), n.Y(), n.Z());
for (int k = 1; k <= 3; k++)
{
const Point3d & p =
stlgeometry->GetPoint (stlgeometry -> GetTriangle(j).PNum(k));
glVertex3f (p.X(),p.Y(), p.Z());
}
}
glEnd ();
glEndList ();
}
VisualSceneSpecPoints :: VisualSceneSpecPoints ()
: VisualScene()
{
;
}
VisualSceneSpecPoints :: ~VisualSceneSpecPoints ()
{
;
}
void VisualSceneSpecPoints :: DrawScene ()
{
if (!mesh)
{
VisualScene::DrawScene();
return;
}
if (changeval != specpoints.Size())
BuildScene();
changeval = specpoints.Size();
glClearColor(backcolor, backcolor, backcolor, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable (GL_COLOR_MATERIAL);
glColor3f (1.0f, 1.0f, 1.0f);
glLineWidth (1.0f);
glPushMatrix();
glMultMatrixf (transformationmat);
// glEnable (GL_COLOR);
// glDisable (GL_COLOR_MATERIAL);
if (vispar.drawedtangents)
{
glColor3d (1, 0, 0);
glBegin (GL_LINES);
for (int i = 1; i <= specpoints.Size(); i++)
{
const Point3d p1 = specpoints.Get(i).p;
const Point3d p2 = specpoints.Get(i).p + len * specpoints.Get(i).v;
glVertex3d (p1.X(), p1.Y(), p1.Z());
glVertex3d (p2.X(), p2.Y(), p2.Z());
}
glEnd();
}
if (vispar.drawededges)
{
glColor3d (1, 0, 0);
glBegin (GL_LINES);
for (int i = 1; i <= mesh->GetNSeg(); i++)
{
const Segment & seg = mesh -> LineSegment (i);
glVertex3dv ( (*mesh)[seg[0]] );
glVertex3dv ( (*mesh)[seg[1]] );
// glVertex3dv ( &(*mesh)[seg[0]].X() );
// glVertex3dv ( &(*mesh)[seg[1]].X() );
}
glEnd();
}
glColor3d (1, 0, 0);
glBegin (GL_LINES);
for (int i = 0; i < boxes.Size(); i++)
{
glVertex3dv ( boxes[i].PMin() );
glVertex3dv ( boxes[i].PMax() );
}
glEnd();
if (vispar.drawededgenrs)
{
glEnable (GL_COLOR_MATERIAL);
GLfloat textcol[3] = { 1 - backcolor,
1 - backcolor,
1 - backcolor };
glColor3fv (textcol);
glNormal3d (0, 0, 1);
glPushAttrib (GL_LIST_BIT);
// glListBase (fontbase);
char buf[20];
for (int i = 1; i <= mesh->GetNSeg(); i++)
{
const Segment & seg = mesh -> LineSegment (i);
const Point3d p1 = mesh -> Point (seg[0]);
const Point3d p2 = mesh -> Point (seg[1]);
const Point3d p = Center (p1, p2);
glRasterPos3d (p.X(), p.Y(), p.Z());
sprintf (buf, "%d", seg.edgenr);
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf);
}
glPopAttrib ();
glDisable (GL_COLOR_MATERIAL);
}
if (vispar.drawedpoints)
{
glColor3d (0, 0, 1);
/*
glPointSize( 3.0 );
float range[2];
glGetFloatv(GL_POINT_SIZE_RANGE, &range[0]);
cout << "max ptsize = " << range[0] << "-" << range[1] << endl;
glBegin( GL_POINTS );
for (int i = 1; i <= mesh -> GetNP(); i++)
{
const Point3d & p = mesh -> Point(i);
if (i % 2)
glVertex3f( p.X(), p.Y(), p.Z());
}
glEnd();
*/
static GLubyte knoedel[] =
{
0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
};
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glDisable (GL_COLOR_MATERIAL);
glDisable (GL_LIGHTING);
glDisable (GL_CLIP_PLANE0);
for (int i = 1; i <= mesh -> GetNP(); i++)
{
const Point3d & p = mesh -> Point(i);
glRasterPos3d (p.X(), p.Y(), p.Z());
glBitmap (7, 7, 3, 3, 0, 0, &knoedel[0]);
}
}
if (vispar.drawedpointnrs)
{
glEnable (GL_COLOR_MATERIAL);
GLfloat textcol[3] = { 1 - backcolor,
1 - backcolor,
1 - backcolor };
glColor3fv (textcol);
glNormal3d (0, 0, 1);
glPushAttrib (GL_LIST_BIT);
// glListBase (fontbase);
char buf[20];
for (int i = 1; i <= mesh->GetNP(); i++)
{
const Point3d & p = mesh->Point(i);
glRasterPos3d (p.X(), p.Y(), p.Z());
sprintf (buf, "%d", i);
// glCallLists (GLsizei(strlen (buf)), GL_UNSIGNED_BYTE, buf);
MyOpenGLText (buf);
}
glPopAttrib ();
glDisable (GL_COLOR_MATERIAL);
}
glPopMatrix();
if (vispar.drawcoordinatecross)
DrawCoordinateCross ();
DrawNetgenLogo ();
glFinish();
}
void VisualSceneSpecPoints :: BuildScene (int zoomall)
{
if (!mesh)
{
VisualScene::BuildScene(zoomall);
return;
}
Box3d box;
if (mesh->GetNSeg())
{
box.SetPoint (mesh->Point (mesh->LineSegment(1)[0]));
for (int i = 1; i <= mesh->GetNSeg(); i++)
{
box.AddPoint (mesh->Point (mesh->LineSegment(i)[0]));
box.AddPoint (mesh->Point (mesh->LineSegment(i)[1]));
}
}
else if (specpoints.Size() >= 2)
{
box.SetPoint (specpoints.Get(1).p);
for (int i = 2; i <= specpoints.Size(); i++)
box.AddPoint (specpoints.Get(i).p);
}
else
{
box = Box3d (Point3d (0,0,0), Point3d (1,1,1));
}
if (zoomall == 2 && ((vispar.centerpoint >= 1 && vispar.centerpoint <= mesh->GetNP()) ||
vispar.use_center_coords))
{
if (vispar.use_center_coords)
{
center.X() = vispar.centerx; center.Y() = vispar.centery; center.Z() = vispar.centerz;
}
else
center = mesh->Point (vispar.centerpoint);
}
else
center = Center (box.PMin(), box.PMax());
rad = 0.5 * Dist (box.PMin(), box.PMax());
CalcTransformationMatrices();
}
} }

View File

@ -5,7 +5,7 @@
namespace netgen namespace netgen
{ {
/*
extern void InitDrawMesh (); extern void InitDrawMesh ();
extern void DrawMesh (); extern void DrawMesh ();
extern void MouseMove(int oldx, int oldy, extern void MouseMove(int oldx, int oldy,
@ -13,8 +13,7 @@ namespace netgen
char mode); char mode);
extern void Render (); extern void Render ();
*/
class VisualScene class VisualScene
@ -97,60 +96,6 @@ namespace netgen
class VisualSceneGeometry : public VisualScene
{
Array<int> trilists;
int selsurf;
public:
VisualSceneGeometry ();
virtual ~VisualSceneGeometry ();
virtual void SelectSurface (int aselsurf);
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
};
class VisualSceneSTLGeometry : public VisualScene
{
Array<int> trilists;
public:
VisualSceneSTLGeometry ();
virtual ~VisualSceneSTLGeometry ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
};
class VisualSceneGeometry2d : public VisualScene
{
public:
VisualSceneGeometry2d ();
virtual ~VisualSceneGeometry2d ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
};
#ifdef OCCGEOMETRY
class VisualSceneOCCGeometry : public VisualScene
{
Array<int> trilists;
Array<int> linelists;
int selsurf;
public:
VisualSceneOCCGeometry ();
virtual ~VisualSceneOCCGeometry ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
virtual void MouseDblClick (int px, int py);
};
#endif
@ -159,42 +104,6 @@ namespace netgen
#ifdef STEP
class VisualSceneSTEPGeometry : public VisualScene
{
Array<int> gllists;
public:
VisualSceneSTEPGeometry ();
virtual ~VisualSceneSTEPGeometry ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
};
#endif
class VisualSceneSTLMeshing : public VisualScene
{
Array<int> trilists;
int selecttrig, nodeofseltrig;
public:
VisualSceneSTLMeshing ();
virtual ~VisualSceneSTLMeshing ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
virtual void MouseDblClick (int px, int py);
int seltria;
};
class VisualSceneSurfaceMeshing : public VisualScene class VisualSceneSurfaceMeshing : public VisualScene
{ {
public: public:
@ -294,10 +203,6 @@ namespace netgen
class VisualSceneSpecPoints : public VisualScene class VisualSceneSpecPoints : public VisualScene
{ {
public: public:
@ -310,6 +215,12 @@ namespace netgen
double len; double len;
}; };
// extern struct Tcl_Interp * hinterp; // extern struct Tcl_Interp * hinterp;

File diff suppressed because it is too large Load Diff

View File

@ -29,32 +29,6 @@ namespace netgen
delete solclass; delete solclass;
} }
/*
bool SolutionData :: GetMultiValue (int elnr, int npts,
const double * xref, int sxref,
const double * x, int sx,
const double * dxdxref, int sdxdxref,
double * values, int svalues)
{
bool res = false;
for (int i = 0; i < npts; i++)
res = GetValue (elnr, &xref[i*sxref], &x[i*sx], &dxdxref[i*sdxdxref], &values[i*svalues]);
return res;
}
bool SolutionData :: GetMultiSurfValue (int selnr, int npts,
const double * xref, int sxref,
const double * x, int sx,
const double * dxdxref, int sdxdxref,
double * values, int svalues)
{
bool res = false;
for (int i = 0; i < npts; i++)
res = GetSurfValue (selnr, &xref[i*sxref], &x[i*sx], &dxdxref[i*sdxdxref], &values[i*svalues]);
return res;
}
*/
VisualSceneSolution :: VisualSceneSolution () VisualSceneSolution :: VisualSceneSolution ()
: VisualScene() : VisualScene()
@ -231,9 +205,9 @@ namespace netgen
ofstream surf_ost(surf_fn.c_str()); ofstream surf_ost(surf_fn.c_str());
surf_ost << "# vtk DataFile Version 1.0\n" surf_ost << "# vtk DataFile Version 1.0\n"
<< "NGSolve surface mesh\n" << "NGSolve surface mesh\n"
<< "ASCII\n" << "ASCII\n"
<< "DATASET UNSTRUCTURED_GRID\n\n"; << "DATASET UNSTRUCTURED_GRID\n\n";
surf_ost << "POINTS " << mesh->GetNP() << " float\n"; surf_ost << "POINTS " << mesh->GetNP() << " float\n";
for (PointIndex pi = PointIndex::BASE; pi < mesh->GetNP()+PointIndex::BASE; pi++) for (PointIndex pi = PointIndex::BASE; pi < mesh->GetNP()+PointIndex::BASE; pi++)
@ -327,30 +301,30 @@ namespace netgen
} }
/* /*
ost << "POINT_DATA " << mesh->GetNP() << "\n"; ost << "POINT_DATA " << mesh->GetNP() << "\n";
for (int i = 0; i < soldata.Size(); i++) for (int i = 0; i < soldata.Size(); i++)
{ {
ost << "VECTORS bfield float\n"; ost << "VECTORS bfield float\n";
SolutionData & sol = *(soldata[i] -> solclass); SolutionData & sol = *(soldata[i] -> solclass);
for (PointIndex pi = PointIndex::BASE; for (PointIndex pi = PointIndex::BASE;
pi < mesh->GetNP()+PointIndex::BASE; pi++) pi < mesh->GetNP()+PointIndex::BASE; pi++)
{ {
double values[3], sumvalues[3] = { 0, 0, 0 }; double values[3], sumvalues[3] = { 0, 0, 0 };
FlatArray<int> els = mesh->GetTopology().GetVertexElements(pi); FlatArray<int> els = mesh->GetTopology().GetVertexElements(pi);
for (int j = 0; j < els.Size(); j++) for (int j = 0; j < els.Size(); j++)
{ {
sol.GetValue (els[j]-1, 0.25, 0.25, 0.25, values); sol.GetValue (els[j]-1, 0.25, 0.25, 0.25, values);
for (int k = 0; k < 3; k++) for (int k = 0; k < 3; k++)
sumvalues[k] += values[k]; sumvalues[k] += values[k];
} }
for (int k = 0; k < 3; k++) for (int k = 0; k < 3; k++)
sumvalues[k] /= els.Size(); sumvalues[k] /= els.Size();
ost << sumvalues[0] << " " << sumvalues[1] << " " << sumvalues[2] << "\n"; ost << sumvalues[0] << " " << sumvalues[1] << " " << sumvalues[2] << "\n";
} }
} }
*/ */
} }
@ -586,12 +560,12 @@ namespace netgen
} }
/* /*
if (!cone_list) if (!cone_list)
{ {
cone_list = glGenLists (1); cone_list = glGenLists (1);
glNewList (cone_list, GL_COMPILE); glNewList (cone_list, GL_COMPILE);
DrawCone (Point<3> (0,0,0), Point<3> (0,0,1), 0.4); DrawCone (Point<3> (0,0,0), Point<3> (0,0,1), 0.4);
glEndList(); glEndList();
} }
*/ */
@ -919,11 +893,10 @@ namespace netgen
DrawIsoLines (points[index[0]], points[index[1]], points[index[2]], DrawIsoLines (points[index[0]], points[index[1]], points[index[2]],
values[index[0]], values[index[1]], values[index[2]]); values[index[0]], values[index[1]], values[index[2]]);
// minval, maxval, numisolines);
if (ix < n-iy-1) if (ix < n-iy-1)
DrawIsoLines (points[index[3]], points[index[4]], points[index[5]], DrawIsoLines (points[index[3]], points[index[4]], points[index[5]],
values[index[3]], values[index[4]], values[index[5]]); values[index[3]], values[index[4]], values[index[5]]);
// minval, maxval, numisolines);
} }
} }
@ -969,10 +942,8 @@ namespace netgen
{ {
DrawIsoLines (points[ii], points[ii+1], points[ii+n+1], DrawIsoLines (points[ii], points[ii+1], points[ii+n+1],
values[ii], values[ii+1], values[ii+n+1]); values[ii], values[ii+1], values[ii+n+1]);
// minval, maxval, numisolines);
DrawIsoLines (points[ii+1], points[ii+n+2], points[ii+n+1], DrawIsoLines (points[ii+1], points[ii+n+2], points[ii+n+1],
values[ii+1], values[ii+n+2], values[ii+n+1]); values[ii+1], values[ii+n+2], values[ii+n+1]);
// minval, maxval, numisolines);
} }
} }
} }
@ -1011,7 +982,7 @@ namespace netgen
pts[trig.points[2].pnr].p, pts[trig.points[2].pnr].p,
// trig.points[1].p, // trig.points[1].p,
// trig.points[2].p, // trig.points[2].p,
vali[0], vali[1], vali[2]); // , minval, maxval, numisolines); vali[0], vali[1], vali[2]);
} }
glEndList (); glEndList ();
} }
@ -1136,22 +1107,6 @@ namespace netgen
{ {
bool curved = curv.IsSurfaceElementCurved (sei); bool curved = curv.IsSurfaceElementCurved (sei);
Point<3> lpi[4];
Vec<3> vx, vy, vtwist;
if (! curved)
{
for (int k = 0; k < 4; k++)
GetPointDeformation (el[k]-1, lpi[k]);
vx = lpi[1]-lpi[0];
vy = lpi[3]-lpi[0];
vtwist = (lpi[0]-lpi[1]) + (lpi[2]-lpi[3]);
}
// Vec<3> nv = Cross (lpi[1]-lpi[0], Center (lpi[2],lpi[3]) - lpi[0]);
// nv.Normalize();
// glNormal3dv (nv);
for (int iy = 0, ii = 0; iy <= n; iy++) for (int iy = 0, ii = 0; iy <= n; iy++)
for (int ix = 0; ix <= n; ix++, ii++) for (int ix = 0; ix <= n; ix++, ii++)
@ -1171,6 +1126,16 @@ namespace netgen
} }
else else
{ {
Point<3> lpi[4];
Vec<3> vx, vy, vtwist;
for (int k = 0; k < 4; k++)
GetPointDeformation (el[k]-1, lpi[k]);
vx = lpi[1]-lpi[0];
vy = lpi[3]-lpi[0];
vtwist = (lpi[0]-lpi[1]) + (lpi[2]-lpi[3]);
for (int ii = 0; ii < npt; ii++) for (int ii = 0; ii < npt; ii++)
{ {
double x = pref[ii](0); double x = pref[ii](0);
@ -1407,7 +1372,7 @@ namespace netgen
bool curved = curv.IsSurfaceElementCurved (sei); bool curved = curv.IsSurfaceElementCurved (sei);
int nv = (el.GetType() == TRIG || el.GetType() == TRIG6) ? 3 : 4; int nv = (el.GetType() == TRIG || el.GetType() == TRIG6) ? 3 : 4;
/*
Point<3> p1, p2, p3, p4; Point<3> p1, p2, p3, p4;
if (!curved) if (!curved)
{ {
@ -1416,6 +1381,7 @@ namespace netgen
p3 = (*mesh)[el[2]]; p3 = (*mesh)[el[2]];
if (nv == 4) p4 = (*mesh)[el[3]]; if (nv == 4) p4 = (*mesh)[el[3]];
} }
*/
for (int k = 0; k < nv; k++) for (int k = 0; k < nv; k++)
{ {
@ -1434,12 +1400,12 @@ namespace netgen
glBegin (GL_LINE_STRIP); glBegin (GL_LINE_STRIP);
if (curved) // if (curved)
{ {
for (int ix = 0; ix <= n; ix++) for (int ix = 0; ix <= n; ix++)
ptsloc[ix] = p0 + (double(ix) / n) * vtau; ptsloc[ix] = p0 + (double(ix) / n) * vtau;
mesh->GetCurvedElements(). mesh->GetCurvedElements().
CalcMultiPointSurfaceTransformation (&ptsloc, sei, &ptsglob, 0); CalcMultiPointSurfaceTransformation (&ptsloc, sei, &ptsglob, 0);
for (int ix = 0; ix <= n; ix++) for (int ix = 0; ix <= n; ix++)
@ -1449,6 +1415,7 @@ namespace netgen
glVertex3dv (ptsglob[ix]); glVertex3dv (ptsglob[ix]);
} }
} }
/*
else else
{ {
for (int ix = 0; ix <= n; ix++) for (int ix = 0; ix <= n; ix++)
@ -1468,6 +1435,7 @@ namespace netgen
glVertex3dv (pnt); glVertex3dv (pnt);
} }
} }
*/
glEnd (); glEnd ();
} }
} }
@ -1697,7 +1665,6 @@ namespace netgen
points[1] = edgep[cpe2]; points[1] = edgep[cpe2];
points[2] = edgep[cpe3]; points[2] = edgep[cpe3];
Vec<3> normal = Cross (points[2]-points[0], points[1]-points[0]); Vec<3> normal = Cross (points[2]-points[0], points[1]-points[0]);
if ( ( (normal * (p2-p1)) > 0 ) == ( nodevali[lpi1] < 0) ) if ( ( (normal * (p2-p1)) > 0 ) == ( nodevali[lpi1] < 0) )
normal *= -1; normal *= -1;
@ -1709,8 +1676,6 @@ namespace netgen
} }
else else
{ {
// glNormal3dv (grads[teti[0]]);
glNormal3dv (normp[cpe1]); glNormal3dv (normp[cpe1]);
glVertex3dv (edgep[cpe1]); glVertex3dv (edgep[cpe1]);
glNormal3dv (normp[cpe2]); glNormal3dv (normp[cpe2]);
@ -1989,19 +1954,19 @@ namespace netgen
else if (el.GetType() == QUAD) else if (el.GetType() == QUAD)
{ {
/* /*
Array < Point<3> > lp(3); Array < Point<3> > lp(3);
lp[0] = mesh->Point(el[0]); lp[0] = mesh->Point(el[0]);
lp[1] = mesh->Point(el[1]); lp[1] = mesh->Point(el[1]);
lp[2] = mesh->Point(el[2]); lp[2] = mesh->Point(el[2]);
DrawTrigSurfaceVectors(lp,pmin,pmax,sei,vsol); DrawTrigSurfaceVectors(lp,pmin,pmax,sei,vsol);
lp[0] = mesh->Point(el[0]); lp[0] = mesh->Point(el[0]);
lp[1] = mesh->Point(el[2]); lp[1] = mesh->Point(el[2]);
lp[2] = mesh->Point(el[3]); lp[2] = mesh->Point(el[3]);
DrawTrigSurfaceVectors(lp,pmin,pmax,sei,vsol); DrawTrigSurfaceVectors(lp,pmin,pmax,sei,vsol);
*/ */
Point<3> lp[4]; Point<3> lp[4];
@ -2303,91 +2268,8 @@ namespace netgen
ArrayMem<double,20> values(data->components); ArrayMem<double,20> values(data->components);
ok = GetValues (data, elnr, xref, x, dxdxref, &values[0]); ok = GetValues (data, elnr, xref, x, dxdxref, &values[0]);
switch (evalfunc) val = ExtractValue (data, 0, &values[0]);
{ return ok;
case FUNC_ABS:
{
for (int ci = 0; ci < data->components; ci++)
val += sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_ABS_TENSOR:
{
int d = 0;
switch (data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]);
for (ci = d; ci < data->components; ci++)
val += 2*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MISES:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
double trace = 0.;
for (ci = 0; ci < d; ci++)
trace += 1./3.*(values[ci]);
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]-trace);
for (ci = d; ci < data->components; ci++)
val += 2.*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MAIN:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
Mat<3,3> m ;
Vec<3> ev;
int ci;
for (ci = 0; ci < d; ci++)
m(ci,ci) = (values[ci]);
m(0,1) = m(1,0) = values[3];
m(0,2) = m(2,0) = values[4];
m(1,2) = m(2,1) = values[5];
EigenValues (m, ev);
double help;
for (int i=0; i<d; i++)
{
for (int j=d-1; i<j; j--)
{
if ( abs(ev(j)) > abs(ev(j-1)) )
{
help = ev(j);
ev(j) = ev(j-1);
ev(j-1) = help;
}
}
}
val = (ev(0));
break;
}
}
return ok;
} }
@ -2552,92 +2434,8 @@ namespace netgen
{ {
ArrayMem<double,20> values(data->components); ArrayMem<double,20> values(data->components);
ok = GetValues (data, elnr, lam1, lam2, lam3, &values[0]); ok = GetValues (data, elnr, lam1, lam2, lam3, &values[0]);
val = ExtractValue (data, 0, &values[0]);
switch (evalfunc) return ok;
{
case FUNC_ABS:
{
for (int ci = 0; ci < data->components; ci++)
val += sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_ABS_TENSOR:
{
int d = 0;
switch (data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]);
for (ci = d; ci < data->components; ci++)
val += 2*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MISES:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
double trace = 0.;
for (ci = 0; ci < d; ci++)
trace += 1./3.*(values[ci]);
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]-trace);
for (ci = d; ci < data->components; ci++)
val += 2.*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MAIN:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
Mat<3,3> m ;
Vec<3> ev;
int ci;
for (ci = 0; ci < d; ci++)
m(ci,ci) = (values[ci]);
m(0,1) = m(1,0) = values[3];
m(0,2) = m(2,0) = values[4];
m(1,2) = m(2,1) = values[5];
EigenValues (m, ev);
double help;
for (int i=0; i<d; i++)
{
for (int j=d-1; i<j; j--)
{
if ( abs(ev(j)) > abs(ev(j-1)) )
{
help = ev(j);
ev(j) = ev(j-1);
ev(j-1) = help;
}
}
}
val = (ev(0));
break;
}
}
return ok;
} }
@ -3046,103 +2844,8 @@ namespace netgen
val = 0; val = 0;
ArrayMem<double,20> values(data->components); ArrayMem<double,20> values(data->components);
ok = GetSurfValues (data, selnr, lam1, lam2, &values[0]); ok = GetSurfValues (data, selnr, lam1, lam2, &values[0]);
// ok = 1; val = ExtractValue (data, 0, &values[0]);
// values[0] = 1.0; return ok;
switch (evalfunc)
{
case FUNC_ABS:
{
for (int ci = 0; ci < data->components; ci++)
val += sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_ABS_TENSOR:
{
int d = 0;
switch (data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]);
for (ci = d; ci < data->components; ci++)
val += 2*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MISES:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
double trace = 0.;
for (ci = 0; ci < d; ci++)
trace += 1./3.*(values[ci]);
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]-trace);
for (ci = d; ci < data->components; ci++)
val += 2.*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MAIN:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
Mat<3,3> m ;
Vec<3> ev;
int ci;
for (ci = 0; ci < d; ci++)
m(ci,ci) = (values[ci]);
m(0,1) = m(1,0) = values[3];
m(0,2) = m(2,0) = values[4];
m(1,2) = m(2,1) = values[5];
EigenValues (m, ev);
double help;
for (int i=0; i<d; i++)
{
for (int j=d-1; i<j; j--)
{
if ( abs(ev(j)) > abs(ev(j-1)) )
{
help = ev(j);
ev(j) = ev(j-1);
ev(j-1) = help;
}
}
}
val = (ev(0));
break;
}
}
return ok;
/*
int ci;
double val = 0;
for (ci = 1; ci <= data->components; ci++)
val += sqr (GetSurfValue (data, selnr, lam1, lam2, ci));
return sqrt (val);
*/
} }
@ -3375,101 +3078,8 @@ namespace netgen
val = 0; val = 0;
ArrayMem<double,20> values(data->components); ArrayMem<double,20> values(data->components);
ok = GetSurfValues (data, selnr, xref, x, dxdxref, &values[0]); ok = GetSurfValues (data, selnr, xref, x, dxdxref, &values[0]);
val = ExtractValue (data, 0, &values[0]);
switch (evalfunc) return ok;
{
case FUNC_ABS:
{
for (int ci = 0; ci < data->components; ci++)
val += sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_ABS_TENSOR:
{
int d = 0;
switch (data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]);
for (ci = d; ci < data->components; ci++)
val += 2*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MISES:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
int ci;
double trace = 0.;
for (ci = 0; ci < d; ci++)
trace += 1./3.*(values[ci]);
for (ci = 0; ci < d; ci++)
val += sqr (values[ci]-trace);
for (ci = d; ci < data->components; ci++)
val += 2.*sqr (values[ci]);
val = sqrt (val);
break;
}
case FUNC_MAIN:
{
int d = 0;
switch(data->components)
{
case 1: d = 1; break;
case 3: d = 2; break;
case 6: d = 3; break;
}
Mat<3,3> m ;
Vec<3> ev;
int ci;
for (ci = 0; ci < d; ci++)
m(ci,ci) = (values[ci]);
m(0,1) = m(1,0) = values[3];
m(0,2) = m(2,0) = values[4];
m(1,2) = m(2,1) = values[5];
EigenValues (m, ev);
double help;
for (int i=0; i<d; i++)
{
for (int j=d-1; i<j; j--)
{
if ( abs(ev(j)) > abs(ev(j-1)) )
{
help = ev(j);
ev(j) = ev(j-1);
ev(j-1) = help;
}
}
}
val = (ev(0));
break;
}
}
return ok;
/*
int ci;
double val = 0;
for (ci = 1; ci <= data->components; ci++)
val += sqr (GetSurfValue (data, selnr, lam1, lam2, ci));
return sqrt (val);
*/
} }
@ -4174,13 +3784,7 @@ namespace netgen
&mvalues[0], sol->components); &mvalues[0], sol->components);
if (!drawelem) ok = false; if (!drawelem) ok = false;
if (usetexture == 2) if (usetexture != 2)
{
;
// for (int ii = 0; ii < nlp; ii++)
// valuesc[ii] = ExtractValueComplex(sol, scalcomp, &mvalues[ii*sol->components]);
}
else
for (int ii = 0; ii < nlp; ii++) for (int ii = 0; ii < nlp; ii++)
vals[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]); vals[ii] = ExtractValue(sol, scalcomp, &mvalues[ii*sol->components]);
} }
@ -4189,35 +3793,14 @@ namespace netgen
{ {
p[j] = points[trig.points[j].pnr].p; p[j] = points[trig.points[j].pnr].p;
Point<3> ploc = points[trig.points[j].pnr].lami; Point<3> ploc = points[trig.points[j].pnr].lami;
int locpnr = trig.points[j].locpnr;
if (deform) if (deform)
p[j] += GetDeformation (trig.elnr, ploc); p[j] += GetDeformation (trig.elnr, ploc);
if (usetexture != 2 || !sol->iscomplex) if (usetexture == 2 && sol->iscomplex)
{
;
/*
if (elnrs[trig.points[j].locpnr] != trig.elnr)
{
elnrs[trig.points[j].locpnr] = trig.elnr;
ok = GetValue (sol, trig.elnr, &locpoints[locpnr](0),
&globpoints[locpnr](0), &jacobi[locpnr](0,0), scalcomp, vals[locpnr]);
trigok[trig.points[j].locpnr] = ok;
}
else
{
ok = trigok[trig.points[j].locpnr];
}
*/
}
else
{ {
ok = GetValueComplex (sol, trig.elnr, ploc(0), ploc(1), ploc(2), ok = GetValueComplex (sol, trig.elnr, ploc(0), ploc(1), ploc(2),
scalcomp, valc[j]); scalcomp, valc[j]);
} }
} }
@ -4485,7 +4068,6 @@ namespace netgen
int argc, tcl_const char *argv[]) int argc, tcl_const char *argv[])
{ {
int i;
if (argc >= 2) if (argc >= 2)
{ {
if (strcmp (argv[1], "parameters") == 0) if (strcmp (argv[1], "parameters") == 0)
@ -4525,7 +4107,7 @@ namespace netgen
const char * pch = strchr(scalname,'.'); const char * pch = strchr(scalname,'.');
pointpos = int(pch-scalname+1); pointpos = int(pch-scalname+1);
for (i = 0; i < vssolution.soldata.Size(); i++) for (int i = 0; i < vssolution.soldata.Size(); i++)
{ {
if ( (strlen (vssolution.soldata[i]->name) == pointpos-1) && if ( (strlen (vssolution.soldata[i]->name) == pointpos-1) &&
(strncmp (vssolution.soldata[i]->name, scalname, pointpos-1) == 0) ) (strncmp (vssolution.soldata[i]->name, scalname, pointpos-1) == 0) )

View File

@ -290,7 +290,6 @@ public:
const Point<3> & p2, const Point<3> & p2,
const Point<3> & p3, const Point<3> & p3,
double val1, double val2, double val3); double val1, double val2, double val3);
// double minval, double maxval, int n);
// draw isolines between lines (p1,p2) and (p3,p4) // draw isolines between lines (p1,p2) and (p3,p4)
void DrawIsoLines2 (const Point<3> & p1, void DrawIsoLines2 (const Point<3> & p1,
@ -299,15 +298,11 @@ public:
const Point<3> & p4, const Point<3> & p4,
double val1, double val2, double val3, double val4); double val1, double val2, double val3, double val4);
// double minval, double maxval, int n);
void DrawClipPlaneTrigs (const SolData * sol, int comp, void DrawClipPlaneTrigs (const SolData * sol, int comp,
const Array<ClipPlaneTrig> & trigs, const Array<ClipPlaneTrig> & trigs,
const Array<ClipPlanePoint> & points); const Array<ClipPlanePoint> & points);
// void SetOpenGlColor(double val, double valmin, double valmax, int logscale = 0);
void SetOpenGlColor(double val); void SetOpenGlColor(double val);
// 0 .. non, 1 .. scalar, 2 .. complex // 0 .. non, 1 .. scalar, 2 .. complex

View File

@ -3,15 +3,19 @@ include_HEADERS =
AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES) AM_CPPFLAGS = -I$(top_srcdir)/libsrc/include -I$(top_srcdir)/libsrc/interface -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES) $(MPI_INCLUDES) $(FFMPEG_INCLUDES) $(JPEGLIB_INCLUDES)
bin_PROGRAMS = netgen 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 ngpkg.cpp onetcl.cpp nginterface.cpp nginterface_v2.cpp parallelfunc.cpp parallelinterface.cpp demoview.hpp parallelfunc.hpp togl_1_7.h ng_occ.hpp ng_stl.hpp
netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \ netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \
$(top_builddir)/libsrc/csg/libcsgvis.la \
$(top_builddir)/libsrc/csg/libcsg.la \ $(top_builddir)/libsrc/csg/libcsg.la \
$(top_builddir)/libsrc/geom2d/libgeom2dvis.la \
$(top_builddir)/libsrc/geom2d/libgeom2d.la \ $(top_builddir)/libsrc/geom2d/libgeom2d.la \
$(top_builddir)/libsrc/interface/libinterface.la \ $(top_builddir)/libsrc/interface/libinterface.la \
$(top_builddir)/libsrc/stlgeom/libstl.la \ $(top_builddir)/libsrc/occ/liboccvis.la \
$(top_builddir)/libsrc/occ/libocc.la \ $(top_builddir)/libsrc/occ/libocc.la \
$(top_builddir)/libsrc/stlgeom/libstlvis.la \
$(top_builddir)/libsrc/stlgeom/libstl.la \
$(top_builddir)/libsrc/meshing/libmesh.la \ $(top_builddir)/libsrc/meshing/libmesh.la \
$(top_builddir)/libsrc/gprim/libgprim.la \ $(top_builddir)/libsrc/gprim/libgprim.la \
$(top_builddir)/libsrc/linalg/libla.la \ $(top_builddir)/libsrc/linalg/libla.la \
@ -23,9 +27,10 @@ netgen_LDADD = $(top_builddir)/libsrc/visualization/libvisual.a \
# #
# #
dist_bin_SCRIPTS = dialog.tcl menustat.tcl ngicon.tcl ng.tcl \ dist_bin_SCRIPTS = dialog.tcl menustat.tcl ngicon.tcl ng.tcl \
ngvisual.tcl sockets.tcl drawing.tcl nghelp.tcl ngshell.tcl \ ngvisual.tcl sockets.tcl drawing.tcl nghelp.tcl ngshell.tcl \
ngtesting.tcl parameters.tcl variables.tcl netgen.ocf ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl \
occgeom.tcl acisgeom.tcl netgen.ocf
netgen_LDFLAGS = -rdynamic -static netgen_LDFLAGS = -rdynamic -static

File diff suppressed because it is too large Load Diff

View File

@ -412,10 +412,10 @@ set videoactive 0
menu .ngmenu.mesh menu .ngmenu.mesh
.ngmenu.mesh add command -label "Generate Mesh" -accelerator "<g><m>" \ .ngmenu.mesh add command -label "Generate Mesh" -accelerator "<g><m>" \
-command { -command {
Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}
Ng_ReadStatus
set selectvisual mesh set selectvisual mesh
Ng_SetVisParameters Ng_SetVisParameters
Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}
Ng_ReadStatus
redraw redraw
} }
@ -526,67 +526,8 @@ menu .ngmenu.mesh.surfoptstep
##################################################### #####################################################
menu .ngmenu.geometry menu .ngmenu.geometry
.ngmenu.geometry add command -label "Scan CSG Geometry" -command { Ng_ParseGeometry }
.ngmenu.geometry add command -label "CSG Options..." -command geometryoptionsdialog
# only intern version !
# .ngmenu.geometry add separator
# .ngmenu.geometry add command -label "New Primitive" \
# -command newprimitivedialog -accelerator "<n><p>"
# .ngmenu.geometry add command -label "Edit Primitive" \
# -command editprimitivedialog -accelerator "<e><p>"
# .ngmenu.geometry add command -label "Edit Solid" \
# -command newsoliddialog -accelerator "<e><s>"
# .ngmenu.geometry add command -label "Choose Top Level " \
# -command topleveldialog
# .ngmenu.geometry add command -label "Identify" \
# -command identifydialog
.ngmenu.geometry add command -label "CSG Properties..." \
-command topleveldialog2
.ngmenu.geometry add separator
.ngmenu.geometry add command -label "STL Doctor..." \
-command { stldoctordialog; }
.ngmenu.geometry add command -label "STL Info" \
-command {
set notriangles 0
set minx 0
set maxx 0
set miny 0
set maxy 0
set minz 0
set maxz 0
set trigscons 0
Ng_STLInfo notriangles minx maxx miny maxy minz maxz trigscons
set msgtext "NO STL-Triangles : $notriangles\nGeometry:\nX = $minx - $maxx\nY = $miny - $maxy\nZ = $minz - $maxz\nConsistency Check = $trigscons\n"
set msgtext "$msgtext Status: [Ng_STLInfo status]"
tk_messageBox -title "STL Info" -message $msgtext -type ok
}
.ngmenu.geometry add separator
.ngmenu.geometry add command -label "IGES/STEP Topology Explorer/Doctor..." \
-command { occdialog; }
# Philippose - 30/01/2009
# Add menu item for local face mesh size definition in the
# TCL Gui
.ngmenu.geometry add command -label "Edit Face Mesh Size..." \
-command { surfacemeshsizedialog }
.ngmenu.geometry add command -label "OCC Construction" \
-command { Ng_OCCConstruction; }
if { [Ng_ACISCommand isACISavailable] == "yes" } {
.ngmenu.geometry add command -label "ACIS Topology Explorer..." \
-command { acisdialog; }
.ngmenu.geometry add command -label "ACIS combine all" \
-command { Ng_ACISCommand combineall }
.ngmenu.geometry add command -label "ACIS Create CT" \
-command { Ng_ACISCommand createct }
}
@ -864,13 +805,19 @@ pack .bubar -side top -fill x
button .bubar.testb -text "Test" -command { Ng_SaveGeometry } button .bubar.testb -text "Test" -command { Ng_SaveGeometry }
button .bubar.surfm -text "Generate Mesh" -command \ button .bubar.surfm -text "Generate Mesh" -command \
{ set selectvisual mesh; {
Ng_SetVisParameters; .ngmenu.mesh invoke "Generate Mesh";
Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep} # set selectvisual mesh;
redraw # Ng_SetVisParameters;
# Ng_GenerateMesh ${meshoptions.firststep} ${meshoptions.laststep}
# redraw
} }
button .bubar.stopm -text "Stop" -command \ button .bubar.stopm -text "Stop" -command \
{ Ng_StopMeshing; set stopdemo 1 } {
# Ng_StopMeshing;
set multithread_terminate 1;
set stopdemo 1;
}
button .bubar.exitb -text "Quit" \ button .bubar.exitb -text "Quit" \
-command { -command {
set ans [tk_messageBox -title "Quit Netgen?" -message "Do you really want to quit Netgen?" -type yesno -default "no" -icon question] set ans [tk_messageBox -title "Quit Netgen?" -message "Do you really want to quit Netgen?" -type yesno -default "no" -icon question]

View File

@ -82,6 +82,13 @@ catch {
source ${ngdir}/drawing.tcl source ${ngdir}/drawing.tcl
} }
source ${ngdir}/csgeom.tcl
source ${ngdir}/stlgeom.tcl
source ${ngdir}/occgeom.tcl
source ${ngdir}/acisgeom.tcl
catch { catch {
source ${ngdir}/nghelp.tcl source ${ngdir}/nghelp.tcl
} }

View File

@ -36,6 +36,7 @@ namespace netgen
{ {
#include "writeuser.hpp" #include "writeuser.hpp"
extern string ngdir; extern string ngdir;
Flags parameters;
} }
@ -99,9 +100,10 @@ int main(int argc, char ** argv)
{ {
cout << "NETGEN-" << PACKAGE_VERSION << endl; cout << "NETGEN-" << PACKAGE_VERSION << endl;
cout << "Developed at RWTH Aachen University, Germany" << endl cout << "Developed by Joachim Schoeberl at" << endl
<< "and Johannes Kepler University Linz, Austria" << endl; << "2010-xxxx Vienna UT" << endl
<< "2006-2010 RWTH Aachen University" << endl
<< "1996-2006 Johannes Kepler University Linz" << endl;
#ifdef OCCGEOMETRY #ifdef OCCGEOMETRY
cout << "Including OpenCascade geometry kernel" << endl; cout << "Including OpenCascade geometry kernel" << endl;

View File

@ -3,18 +3,8 @@
#include <meshing.hpp> #include <meshing.hpp>
#include <csg.hpp> #include <csg.hpp>
#include <geometry2d.hpp>
#include <stlgeom.hpp>
#ifdef OCCGEOMETRY
#include <occgeom.hpp>
#endif
#ifdef ACIS
#include <acisgeom.hpp>
#endif
#ifdef SOCKETS #ifdef SOCKETS
#include "../sockets/sockets.hpp" #include "../sockets/sockets.hpp"
#endif #endif
@ -32,19 +22,14 @@ namespace netgen
{ {
#include "writeuser.hpp" #include "writeuser.hpp"
extern AutoPtr<Mesh> mesh; extern NetgenGeometry * ng_geometry;
extern AutoPtr<Mesh> mesh;
#ifndef NOTCL #ifndef NOTCL
extern VisualSceneMesh vsmesh;
extern Tcl_Interp * tcl_interp; extern Tcl_Interp * tcl_interp;
#endif #endif
extern AutoPtr<SplineGeometry2d> geometry2d;
extern AutoPtr<CSGeometry> geometry;
extern STLGeometry * stlgeometry;
#ifdef OCCGEOMETRY
extern OCCGeometry * occgeometry;
#endif
#ifdef ACIS #ifdef ACIS
extern ACISGeometry * acisgeometry; extern ACISGeometry * acisgeometry;
#endif #endif
@ -59,6 +44,9 @@ namespace netgen
//extern Array< AutoPtr < ServerInfo > > servers; //extern Array< AutoPtr < ServerInfo > > servers;
extern Array< ServerInfo* > servers; extern Array< ServerInfo* > servers;
#endif #endif
extern void Render ();
} }
@ -145,130 +133,30 @@ using namespace netgen;
void Ng_LoadGeometry (const char * filename) void Ng_LoadGeometry (const char * filename)
{ {
// if (printmessage_importance>0)
// cout << "CALLED NG LOAD GEOMETRY" << endl;
geometry.Reset (new CSGeometry ());
geometry2d.Reset ();
#ifdef OCCGEOMETRY for (int i = 0; i < geometryregister.Size(); i++)
delete occgeometry; {
occgeometry = 0; NetgenGeometry * hgeom = geometryregister[i]->Load (filename);
#endif if (hgeom)
#ifdef ACIS {
delete acisgeometry; delete ng_geometry;
acisgeometry = 0; ng_geometry = hgeom;
#endif
mesh.Reset();
return;
}
}
// he: if filename is empty, return // he: if filename is empty, return
// can be used to reset geometry // can be used to reset geometry
if (strcmp(filename,"")==0) if (strcmp(filename,"")==0)
return;
PrintMessage (1, "Load geometry from file ", filename);
ifstream infile (filename);
if ((strcmp (&filename[strlen(filename)-3], "geo") == 0) ||
(strcmp (&filename[strlen(filename)-3], "GEO") == 0) ||
(strcmp (&filename[strlen(filename)-3], "Geo") == 0))
{ {
delete ng_geometry;
ng_geometry = new NetgenGeometry();
geometry.Reset( netgen::ParseCSG(infile) ); return;
if (!geometry)
{
geometry.Reset (new CSGeometry ());
//throw NgException ("input file not found");
cerr << "Error: input file \"" << filename << "\" not found" << endl;
}
geometry -> FindIdenticSurfaces(1e-6);
#ifdef PARALLEL
int id, rc, ntasks;
MPI_Comm_size(MPI_COMM_WORLD, &ntasks);
MPI_Comm_rank(MPI_COMM_WORLD, &id);
if ( id > 0 )
{
geometry->CalcTriangleApproximation ( geometry->BoundingBox(), 0.001, 20 );
return;
}
#endif
Box<3> box (geometry->BoundingBox());
#ifdef NOTCL
double detail = 0.001;
double facets = 20;
geometry->CalcTriangleApproximation(box, detail, facets);
#else
double detail = atof (Tcl_GetVar (tcl_interp, "::geooptions.detail", 0));
double facets = atof (Tcl_GetVar (tcl_interp, "::geooptions.facets", 0));
if (atoi (Tcl_GetVar (tcl_interp, "::geooptions.drawcsg", 0)))
geometry->CalcTriangleApproximation(box, detail, facets);
#endif
} }
else if (strcmp (&filename[strlen(filename)-4], "in2d") == 0) cerr << "cannot load geometry '" << filename << "'" << endl;
{
geometry2d.Reset (new SplineGeometry2d());
geometry2d -> Load (filename);
}
else if ((strcmp (&filename[strlen(filename)-3], "stl") == 0) ||
(strcmp (&filename[strlen(filename)-3], "STL") == 0) ||
(strcmp (&filename[strlen(filename)-3], "Stl") == 0))
{
stlgeometry = STLGeometry :: Load (infile);
stlgeometry->edgesfound = 0;
Mesh meshdummy;
stlgeometry->Clear();
stlgeometry->BuildEdges();
stlgeometry->MakeAtlas(meshdummy);
stlgeometry->CalcFaceNums();
stlgeometry->AddFaceEdges();
stlgeometry->LinkEdges();
}
#ifdef OCCGEOMETRY
else if ((strcmp (&filename[strlen(filename)-4], "iges") == 0) ||
(strcmp (&filename[strlen(filename)-3], "igs") == 0) ||
(strcmp (&filename[strlen(filename)-3], "IGS") == 0) ||
(strcmp (&filename[strlen(filename)-4], "IGES") == 0))
{
PrintMessage (1, "Load IGES geometry file ", filename);
occgeometry = LoadOCC_IGES (filename);
}
else if ((strcmp (&filename[strlen(filename)-4], "step") == 0) ||
(strcmp (&filename[strlen(filename)-3], "stp") == 0) ||
(strcmp (&filename[strlen(filename)-3], "STP") == 0) ||
(strcmp (&filename[strlen(filename)-4], "STEP") == 0))
{
PrintMessage (1, "Load STEP geometry file ", filename);
occgeometry = LoadOCC_STEP (filename);
}
#endif
#ifdef ACIS
else if (
strcmp (&filename[strlen(filename)-3], "sat") == 0 ||
( strlen(filename) >= 7 && strcmp ( &filename[ strlen( filename)-7 ], "sat.tet" ) == 0 )
)
{
PrintMessage (1, "Load ACIS geometry file ", filename);
acisgeometry = LoadACIS_SAT (filename);
}
#endif
else
{
//throw NgException("Unknown geometry extension");
cerr << "Error: Unknown geometry extension \"" << filename[strlen(filename)-3] << "\"" << endl;
}
} }
@ -276,12 +164,27 @@ void Ng_LoadMeshFromStream ( istream & input )
{ {
mesh.Reset (new Mesh()); mesh.Reset (new Mesh());
mesh -> Load(input); mesh -> Load(input);
for (int i = 0; i < geometryregister.Size(); i++)
{
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (input);
if (hgeom)
{
delete ng_geometry;
ng_geometry = hgeom;
break;
}
}
#ifdef LOADOLD
if(input.good()) if(input.good())
{ {
string auxstring; string auxstring;
input >> auxstring; input >> auxstring;
if(auxstring == "csgsurfaces") if(auxstring == "csgsurfaces")
{ {
/*
if (geometry) if (geometry)
{ {
geometry.Reset (new CSGeometry ("")); geometry.Reset (new CSGeometry (""));
@ -306,11 +209,16 @@ void Ng_LoadMeshFromStream ( istream & input )
} }
#endif #endif
geometry2d.Reset (0); geometry2d.Reset (0);
*/
geometry -> LoadSurfaces(input); // geometry -> LoadSurfaces(input);
CSGeometry * geometry = new CSGeometry ("");
geometry -> LoadSurfaces(input);
delete ng_geometry;
ng_geometry = geometry;
} }
} }
#endif
} }
@ -681,9 +589,10 @@ void Ng_GetNormalVector (int sei, int locpi, double * nv)
p = mesh->Point (mesh->SurfaceElement(sei).PNum(locpi)); p = mesh->Point (mesh->SurfaceElement(sei).PNum(locpi));
int surfi = mesh->GetFaceDescriptor(mesh->SurfaceElement(sei).GetIndex()).SurfNr(); int surfi = mesh->GetFaceDescriptor(mesh->SurfaceElement(sei).GetIndex()).SurfNr();
(*testout) << "surfi = " << surfi << endl; (*testout) << "surfi = " << surfi << endl;
#ifdef OCCGEOMETRY #ifdef OCCGEOMETRYxxx
OCCGeometry * occgeometry = dynamic_cast<OCCGeometry*> (ng_geometry);
if (occgeometry) if (occgeometry)
{ {
PointGeomInfo gi = mesh->SurfaceElement(sei).GeomInfoPi(locpi); PointGeomInfo gi = mesh->SurfaceElement(sei).GeomInfoPi(locpi);
@ -692,8 +601,8 @@ void Ng_GetNormalVector (int sei, int locpi, double * nv)
nv[1] = n(1); nv[1] = n(1);
nv[2] = n(2); nv[2] = n(2);
} }
else
#endif #endif
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (geometry) if (geometry)
{ {
(*testout) << "geometry defined" << endl; (*testout) << "geometry defined" << endl;
@ -843,7 +752,6 @@ void Ng_GetElementTransformation (int ei, const double * xi,
mesh->GetCurvedElements().CalcElementTransformation (xl, ei-1, xg, dx); mesh->GetCurvedElements().CalcElementTransformation (xl, ei-1, xg, dx);
// still 1-based arrays
if (x) if (x)
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
@ -1122,9 +1030,13 @@ void Ng_Refine (NG_REFINEMENT_TYPE reftype)
biopt.refine_p = 1; biopt.refine_p = 1;
if (reftype == NG_REFINE_HP) if (reftype == NG_REFINE_HP)
biopt.refine_hp = 1; biopt.refine_hp = 1;
Refinement * ref;
const Refinement & ref = ng_geometry->GetRefinement();
// Refinement * ref;
MeshOptimize2d * opt = NULL; MeshOptimize2d * opt = NULL;
/*
if (geometry2d) if (geometry2d)
ref = new Refinement2d(*geometry2d); ref = new Refinement2d(*geometry2d);
else if (stlgeometry) else if (stlgeometry)
@ -1151,20 +1063,22 @@ void Ng_Refine (NG_REFINEMENT_TYPE reftype)
{ {
ref = new Refinement(); ref = new Refinement();
} }
*/
ref.Bisect (*mesh, biopt);
ref -> Bisect (*mesh, biopt);
mesh -> UpdateTopology(); mesh -> UpdateTopology();
mesh -> GetCurvedElements().SetIsHighOrder (false); mesh -> GetCurvedElements().SetIsHighOrder (false);
// mesh -> GetCurvedElements().BuildCurvedElements (ref, mparam.elementorder); // mesh -> GetCurvedElements().BuildCurvedElements (ref, mparam.elementorder);
delete ref; // delete ref;
delete opt; delete opt;
} }
void Ng_SecondOrder () void Ng_SecondOrder ()
{ {
const_cast<Refinement&> (ng_geometry->GetRefinement()).MakeSecondOrder(*mesh);
/*
if (stlgeometry) if (stlgeometry)
{ {
RefinementSTLGeometry ref (*stlgeometry); RefinementSTLGeometry ref (*stlgeometry);
@ -1190,7 +1104,7 @@ void Ng_SecondOrder ()
Refinement ref; Refinement ref;
ref.MakeSecondOrder (*mesh); ref.MakeSecondOrder (*mesh);
} }
*/
mesh -> UpdateTopology(); mesh -> UpdateTopology();
} }
@ -1229,6 +1143,9 @@ void Ng_HPRefinement (int levels, double parameter)
void Ng_HPRefinement (int levels, double parameter, bool setorders, void Ng_HPRefinement (int levels, double parameter, bool setorders,
bool ref_level) bool ref_level)
{ {
Refinement & ref = const_cast<Refinement&> (ng_geometry -> GetRefinement());
HPRefinement (*mesh, &ref, levels);
/*
Refinement * ref; Refinement * ref;
if (stlgeometry) if (stlgeometry)
@ -1238,15 +1155,15 @@ void Ng_HPRefinement (int levels, double parameter, bool setorders,
else else
ref = new RefinementSurfaces (*geometry); ref = new RefinementSurfaces (*geometry);
HPRefinement (*mesh, ref, levels, parameter, setorders, ref_level); HPRefinement (*mesh, ref, levels, parameter, setorders, ref_level);
*/
} }
void Ng_HighOrder (int order, bool rational) void Ng_HighOrder (int order, bool rational)
{ {
NgLock meshlock (mesh->MajorMutex(), true); NgLock meshlock (mesh->MajorMutex(), true);
/*
Refinement * ref; Refinement * ref;
if (stlgeometry) if (stlgeometry)
@ -1267,11 +1184,12 @@ void Ng_HighOrder (int order, bool rational)
{ {
ref = new RefinementSurfaces (*geometry); ref = new RefinementSurfaces (*geometry);
} }
*/
// cout << "parameter 1: " << argv[1] << " (conversion to int = " << atoi(argv[1]) << ")" << endl; // cout << "parameter 1: " << argv[1] << " (conversion to int = " << atoi(argv[1]) << ")" << endl;
mesh -> GetCurvedElements().BuildCurvedElements (ref, order, rational); mesh -> GetCurvedElements().BuildCurvedElements (&const_cast<Refinement&> (ng_geometry -> GetRefinement()),
order, rational);
mesh -> SetNextMajorTimeStamp(); mesh -> SetNextMajorTimeStamp();
/* /*
@ -1279,7 +1197,7 @@ void Ng_HighOrder (int order, bool rational)
mesh -> GetCurvedElements().BuildCurvedElements (ref, order, rational); mesh -> GetCurvedElements().BuildCurvedElements (ref, order, rational);
*/ */
delete ref; // delete ref;
} }
@ -2289,8 +2207,9 @@ int Ng_Bisect_WithInfo ( const char * refinementfile, double ** qualityloss, int
biopt.femcode = "fepp"; biopt.femcode = "fepp";
biopt.refinementfilename = refinementfile; biopt.refinementfilename = refinementfile;
Refinement * ref; Refinement * ref = const_cast<Refinement*> (&ng_geometry -> GetRefinement());
MeshOptimize2d * opt = NULL; MeshOptimize2d * opt = NULL;
/*
if (stlgeometry) if (stlgeometry)
ref = new RefinementSTLGeometry(*stlgeometry); ref = new RefinementSTLGeometry(*stlgeometry);
#ifdef OCCGEOMETRY #ifdef OCCGEOMETRY
@ -2311,7 +2230,26 @@ int Ng_Bisect_WithInfo ( const char * refinementfile, double ** qualityloss, int
opt = new MeshOptimize2dSurfaces(*geometry); opt = new MeshOptimize2dSurfaces(*geometry);
ref->Set2dOptimizer(opt); ref->Set2dOptimizer(opt);
} }
*/
#ifdef ACIS
if (acisgeometry)
{
// ref = new ACISRefinementSurfaces(*acisgeometry);
opt = new ACISMeshOptimize2dSurfaces(*acisgeometry);
ref->Set2dOptimizer(opt);
}
else
#endif
{
// ref = new RefinementSurfaces(*geometry);
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
if (geometry)
{
opt = new MeshOptimize2dSurfaces(*geometry);
ref->Set2dOptimizer(opt);
}
}
if(!mesh->LocalHFunctionGenerated()) if(!mesh->LocalHFunctionGenerated())
mesh->CalcLocalH(); mesh->CalcLocalH();

File diff suppressed because it is too large Load Diff