mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-26 21:00:34 +05:00
clean up geometry
This commit is contained in:
parent
12ab3d7cce
commit
71f5a34c74
@ -69,6 +69,7 @@ namespace netgen
|
||||
|
||||
CSGeometry :: ~CSGeometry ()
|
||||
{
|
||||
cout << "delete geometry" << endl;
|
||||
Clean();
|
||||
}
|
||||
|
||||
@ -83,16 +84,10 @@ namespace netgen
|
||||
for (int i = 0; i < solids.Size(); i++)
|
||||
if(!to_delete.Contains(solids[i]))
|
||||
to_delete.Append(solids[i]);
|
||||
|
||||
for(int i = 0; i < to_delete.Size(); i++)
|
||||
delete to_delete[i];
|
||||
|
||||
/*
|
||||
for (int i = 0; i < solids.Size(); i++)
|
||||
delete solids[i]->S1();
|
||||
for (int i = 0; i < solids.Size(); i++)
|
||||
delete solids[i];
|
||||
*/
|
||||
|
||||
solids.DeleteAll ();
|
||||
|
||||
for (int i = 0; i < splinecurves2d.Size(); i++)
|
||||
@ -108,7 +103,7 @@ namespace netgen
|
||||
delete delete_them[i];
|
||||
delete_them.DeleteAll();
|
||||
surfaces.DeleteAll();
|
||||
|
||||
|
||||
for (int i = 0; i < toplevelobjects.Size(); i++)
|
||||
delete toplevelobjects[i];
|
||||
toplevelobjects.DeleteAll ();
|
||||
|
@ -8,12 +8,6 @@
|
||||
#include "../sockets/sockets.hpp"
|
||||
#endif
|
||||
|
||||
/*
|
||||
#ifndef NOTCL
|
||||
#include <visual.hpp>
|
||||
#endif
|
||||
*/
|
||||
|
||||
#include "nginterface.h"
|
||||
#include "../visualization/soldata.hpp"
|
||||
|
||||
@ -120,11 +114,6 @@ namespace netgen
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef OPENGL
|
||||
// extern VisualSceneSolution vssolution;
|
||||
#endif
|
||||
// extern CSGeometry * ParseCSG (istream & istr);
|
||||
|
||||
#ifdef SOCKETS
|
||||
extern AutoPtr<ClientSocket> clientsocket;
|
||||
//extern Array< AutoPtr < ServerInfo > > servers;
|
||||
@ -140,34 +129,25 @@ using namespace netgen;
|
||||
|
||||
void Ng_LoadGeometry (const char * filename)
|
||||
{
|
||||
// he: if filename is empty, return
|
||||
// can be used to reset geometry
|
||||
if (!filename || strcmp(filename,"")==0)
|
||||
{
|
||||
ng_geometry.Reset (new NetgenGeometry());
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < geometryregister.Size(); i++)
|
||||
{
|
||||
NetgenGeometry * hgeom = geometryregister[i]->Load (filename);
|
||||
if (hgeom)
|
||||
{
|
||||
/*
|
||||
delete ng_geometry;
|
||||
ng_geometry = hgeom;
|
||||
*/
|
||||
ng_geometry.Reset (hgeom);
|
||||
|
||||
mesh.Reset();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// he: if filename is empty, return
|
||||
// can be used to reset geometry
|
||||
if (strcmp(filename,"")==0)
|
||||
{
|
||||
/*
|
||||
delete ng_geometry;
|
||||
ng_geometry = new NetgenGeometry();
|
||||
*/
|
||||
ng_geometry.Reset (new NetgenGeometry());
|
||||
return;
|
||||
}
|
||||
|
||||
// if (id == 0)
|
||||
cerr << "cannot load geometry '" << filename << "'" << ", id = " << id << endl;
|
||||
@ -184,10 +164,6 @@ void Ng_LoadMeshFromStream ( istream & input )
|
||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (input);
|
||||
if (hgeom)
|
||||
{
|
||||
/*
|
||||
delete ng_geometry;
|
||||
ng_geometry = hgeom;
|
||||
*/
|
||||
ng_geometry.Reset (hgeom);
|
||||
break;
|
||||
}
|
||||
@ -415,21 +391,12 @@ NG_ELEMENT_TYPE Ng_GetElement (int ei, int * epi, int * np)
|
||||
}
|
||||
else
|
||||
{
|
||||
int i;
|
||||
const Element2d & el = mesh->SurfaceElement (ei);
|
||||
for (i = 0; i < el.GetNP(); i++)
|
||||
for (int i = 0; i < el.GetNP(); i++)
|
||||
epi[i] = el.PNum(i+1);
|
||||
|
||||
if (np) *np = el.GetNP();
|
||||
return NG_ELEMENT_TYPE (el.GetType());
|
||||
/*
|
||||
switch (el.GetNP())
|
||||
{
|
||||
case 3: return NG_TRIG;
|
||||
case 4: return NG_QUAD;
|
||||
case 6: return NG_TRIG6;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// should not occur
|
||||
@ -823,56 +790,6 @@ void Ng_GetElementTransformation (int ei, const double * xi,
|
||||
}
|
||||
|
||||
|
||||
#ifdef OLD
|
||||
void Ng_GetBufferedElementTransformation (int ei, const double * xi,
|
||||
double * x, double * dxdxi,
|
||||
void * buffer, int buffervalid)
|
||||
{
|
||||
// buffer = 0;
|
||||
// buffervalid = 0;
|
||||
if (mesh->GetDimension() == 2)
|
||||
{
|
||||
return Ng_GetElementTransformation (ei, xi, x, dxdxi);
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh->GetCurvedElements().CalcElementTransformation (reinterpret_cast<const Point<3> &> (*xi),
|
||||
ei-1,
|
||||
reinterpret_cast<Point<3> &> (*x),
|
||||
reinterpret_cast<Mat<3,3> &> (*dxdxi),
|
||||
buffer, (buffervalid != 0));
|
||||
|
||||
/*
|
||||
Point<3> xl(xi[0], xi[1], xi[2]);
|
||||
Point<3> xg;
|
||||
Mat<3,3> dx;
|
||||
// buffervalid = 0;
|
||||
mesh->GetCurvedElements().CalcElementTransformation (xl, ei-1, xg, dx, buffer, buffervalid);
|
||||
|
||||
// still 1-based arrays
|
||||
if (x)
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
x[i] = xg(i);
|
||||
}
|
||||
|
||||
if (dxdxi)
|
||||
{
|
||||
for (int i=0; i<3; i++)
|
||||
{
|
||||
dxdxi[3*i] = dx(i,0);
|
||||
dxdxi[3*i+1] = dx(i,1);
|
||||
dxdxi[3*i+2] = dx(i,2);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Ng_GetMultiElementTransformation (int ei, int n,
|
||||
|
29
ng/ngpkg.cpp
29
ng/ngpkg.cpp
@ -92,7 +92,7 @@ namespace netgen
|
||||
}
|
||||
*/
|
||||
|
||||
extern NetgenGeometry * ng_geometry;
|
||||
extern AutoPtr<NetgenGeometry> ng_geometry;
|
||||
extern AutoPtr<Mesh> mesh;
|
||||
Tcl_Interp * tcl_interp;
|
||||
|
||||
@ -190,8 +190,11 @@ namespace netgen
|
||||
|
||||
if (strcmp (argv[1], "geom") == 0)
|
||||
{
|
||||
/*
|
||||
delete ng_geometry;
|
||||
ng_geometry = new NetgenGeometry;
|
||||
*/
|
||||
ng_geometry.Reset (new NetgenGeometry);
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
@ -219,7 +222,6 @@ namespace netgen
|
||||
PrintMessage (1, "load mesh from file ", filename);
|
||||
|
||||
mesh.Reset (new Mesh());
|
||||
|
||||
try
|
||||
{
|
||||
ifstream infile(filename.c_str());
|
||||
@ -235,8 +237,9 @@ namespace netgen
|
||||
NetgenGeometry * hgeom = geometryregister[i]->LoadFromMeshFile (infile);
|
||||
if (hgeom)
|
||||
{
|
||||
delete ng_geometry;
|
||||
ng_geometry = hgeom;
|
||||
// delete ng_geometry;
|
||||
// ng_geometry = hgeom;
|
||||
ng_geometry.Reset (hgeom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -286,8 +289,8 @@ namespace netgen
|
||||
const string filename (argv[1]);
|
||||
PrintMessage (1, "Save mesh to file ", filename, ".... Please Wait!");
|
||||
|
||||
ofstream outfile(filename.c_str());
|
||||
//ogzstream outfile( (filename+".gz").c_str());
|
||||
// ofstream outfile(filename.c_str());
|
||||
ogzstream outfile( (filename+".gz").c_str());
|
||||
mesh -> Save (outfile);
|
||||
|
||||
outfile << endl << endl << "endmesh" << endl << endl;
|
||||
@ -317,7 +320,7 @@ namespace netgen
|
||||
|
||||
try
|
||||
{
|
||||
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry);
|
||||
CSGeometry * geometry = dynamic_cast<CSGeometry*> (ng_geometry.Ptr());
|
||||
|
||||
//mesh -> Merge (filename);
|
||||
ifstream infile(filename.c_str());
|
||||
@ -518,8 +521,9 @@ namespace netgen
|
||||
NetgenGeometry * hgeom = geometryregister[i]->Load (lgfilename);
|
||||
if (hgeom)
|
||||
{
|
||||
delete ng_geometry;
|
||||
ng_geometry = hgeom;
|
||||
// delete ng_geometry;
|
||||
// ng_geometry = hgeom;
|
||||
ng_geometry.Reset (hgeom);
|
||||
|
||||
mesh.Reset();
|
||||
return TCL_OK;
|
||||
@ -970,7 +974,7 @@ namespace netgen
|
||||
|
||||
if (argc >= 2) opt.minref = atoi (argv[1]);
|
||||
|
||||
ZRefinement (*mesh, ng_geometry, opt);
|
||||
ZRefinement (*mesh, ng_geometry.Ptr(), opt);
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
@ -1277,7 +1281,7 @@ namespace netgen
|
||||
{
|
||||
ZRefinementOptions opt;
|
||||
opt.minref = 5;
|
||||
ZRefinement (*mesh, ng_geometry, opt);
|
||||
ZRefinement (*mesh, ng_geometry.Ptr(), opt);
|
||||
mesh -> SetNextMajorTimeStamp();
|
||||
}
|
||||
|
||||
@ -1801,7 +1805,7 @@ namespace netgen
|
||||
{
|
||||
for (int i = 0; i < geometryregister.Size(); i++)
|
||||
{
|
||||
VisualScene * hvs = geometryregister[i]->GetVisualScene (ng_geometry);
|
||||
VisualScene * hvs = geometryregister[i]->GetVisualScene (ng_geometry.Ptr());
|
||||
if (hvs)
|
||||
{
|
||||
vs = hvs;
|
||||
@ -3067,6 +3071,7 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
|
||||
#endif
|
||||
|
||||
mesh.Reset (NULL);
|
||||
ng_geometry.Reset (NULL);
|
||||
|
||||
if (testout != &cout)
|
||||
delete testout;
|
||||
|
Loading…
Reference in New Issue
Block a user