mesh has geometry-ptr

This commit is contained in:
Joachim Schoeberl 2015-08-08 19:10:48 +02:00
parent 714385724c
commit 004902c62f
6 changed files with 43 additions and 34 deletions

View File

@ -252,7 +252,7 @@ DLL_HEADER void ExportCSG()
}));
bp::class_<CSGeometry, boost::noncopyable> ("CSGeometry")
bp::class_<CSGeometry,shared_ptr<CSGeometry>, boost::noncopyable> ("CSGeometry")
.def("__init__", bp::make_constructor (FunctionPointer
([](const string & filename)
{
@ -352,13 +352,13 @@ DLL_HEADER void ExportCSG()
;
bp::def("GenerateMesh", FunctionPointer
([](CSGeometry & geo, MeshingParameters & param)
([](shared_ptr<CSGeometry> geo, MeshingParameters & param)
{
// testout = new ofstream ("test.out");
shared_ptr<Mesh> dummy;
geo.FindIdenticSurfaces(1e-8 * geo.MaxSize());
geo.GenerateMesh (dummy, param, 0, 6);
ng_geometry.reset (&geo, NOOP_Deleter);
auto dummy = make_shared<Mesh>();
dummy->SetGeometry(geo);
ng_geometry = geo;
geo->FindIdenticSurfaces(1e-8 * geo->MaxSize());
geo->GenerateMesh (dummy, param, 0, 6);
return dummy;
}))
;

View File

@ -221,6 +221,7 @@ DLL_HEADER void ExportGeom2d()
.def("GenerateMesh", FunctionPointer([](shared_ptr<SplineGeometry2d> self, MeshingParameters & mparam)
{
shared_ptr<Mesh> mesh = make_shared<Mesh> ();
mesh->SetGeometry(self);
ng_geometry = self;
self->GenerateMesh(mesh, mparam, 0, 0);
return mesh;

View File

@ -158,10 +158,7 @@ void Ng_LoadMeshFromStream ( istream & input )
{
mesh.reset (new Mesh());
mesh -> Load(input);
/*
vssolution.SetMesh(mesh);
vsmesh.SetMesh(mesh);
*/
SetGlobalMesh (mesh);
for (int i = 0; i < geometryregister.Size(); i++)
{
@ -172,6 +169,8 @@ void Ng_LoadMeshFromStream ( istream & input )
break;
}
}
mesh->SetGeometry (ng_geometry);
}
@ -1017,7 +1016,7 @@ void Ng_Refine (NG_REFINEMENT_TYPE reftype)
if (reftype == NG_REFINE_HP)
biopt.refine_hp = 1;
const Refinement & ref = ng_geometry->GetRefinement();
const Refinement & ref = mesh->GetGeometry()->GetRefinement();
// Refinement * ref;
MeshOptimize2d * opt = NULL;
@ -1063,7 +1062,7 @@ void Ng_Refine (NG_REFINEMENT_TYPE reftype)
void Ng_SecondOrder ()
{
const_cast<Refinement&> (ng_geometry->GetRefinement()).MakeSecondOrder(*mesh);
const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder(*mesh);
/*
if (stlgeometry)
{
@ -1130,7 +1129,7 @@ void Ng_HPRefinement (int levels, double parameter, bool setorders,
bool ref_level)
{
NgLock meshlock (mesh->MajorMutex(), true);
Refinement & ref = const_cast<Refinement&> (ng_geometry -> GetRefinement());
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
HPRefinement (*mesh, &ref, levels, parameter, setorders, ref_level);
/*
Refinement * ref;
@ -1156,7 +1155,7 @@ void Ng_HighOrder (int order, bool rational)
order, rational);
*/
mesh->BuildCurvedElements
(&const_cast<Refinement&> (ng_geometry -> GetRefinement()),
(&const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()),
order, rational);
mesh -> SetNextMajorTimeStamp();
@ -2105,7 +2104,7 @@ int Ng_Bisect_WithInfo ( const char * refinementfile, double ** qualityloss, int
biopt.femcode = "fepp";
biopt.refinementfilename = refinementfile;
Refinement * ref = const_cast<Refinement*> (&ng_geometry -> GetRefinement());
Refinement * ref = const_cast<Refinement*> (&mesh->GetGeometry()->GetRefinement());
MeshOptimize2d * opt = NULL;
/*
if (stlgeometry)

View File

@ -139,6 +139,8 @@ namespace netgen
#endif
shared_ptr<NetgenGeometry> geometry;
private:
void BuildBoundaryEdges(void);
@ -722,6 +724,15 @@ namespace netgen
NgMutex & MajorMutex () { return majormutex; }
shared_ptr<NetgenGeometry> GetGeometry() const
{
return geometry;
}
void SetGeometry (shared_ptr<NetgenGeometry> geom)
{
geometry = geom;
}
///
void SetUserData(const char * id, Array<int> & data);
///

View File

@ -859,12 +859,13 @@ namespace netgen
else
#endif
{
ng_geometry -> GetRefinement().Refine(*mesh);
// ng_geometry -> GetRefinement().Refine(*mesh);
mesh->GetGeometry()->GetRefinement().Refine(*mesh);
}
//redo second order refinement if desired
if (mparam.secondorder)
const_cast<Refinement&> (ng_geometry->GetRefinement()).MakeSecondOrder(*mesh);
const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder(*mesh);
return TCL_OK;
}
@ -884,7 +885,7 @@ namespace netgen
return TCL_ERROR;
}
const_cast<Refinement&> (ng_geometry -> GetRefinement()).MakeSecondOrder (*mesh);
const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder (*mesh);
return TCL_OK;
}
@ -895,7 +896,7 @@ namespace netgen
// mparam.elementorder = atoi (Tcl_GetVar (interp, "options.elementorder", 0));
const char * savetask = multithread.task;
Refinement & ref = const_cast<Refinement&> (ng_geometry -> GetRefinement());
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
mesh -> GetCurvedElements().BuildCurvedElements (&ref, mparam.elementorder);
multithread.task = savetask;
@ -936,7 +937,7 @@ namespace netgen
void * ValidateDummy (void *)
{
Refinement & ref = const_cast<Refinement&> (ng_geometry -> GetRefinement());
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
ref.ValidateSecondOrder (*mesh);
multithread.running = 0;
@ -1010,7 +1011,7 @@ namespace netgen
int levels = atoi (argv[1]);
Refinement & ref = const_cast<Refinement&> (ng_geometry -> GetRefinement());
Refinement & ref = const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement());
HPRefinement (*mesh, &ref, levels);
return TCL_OK;
}
@ -1334,6 +1335,7 @@ namespace netgen
mesh = make_shared<Mesh> ();
// vsmesh.SetMesh (mesh);
SetGlobalMesh (mesh);
mesh -> SetGeometry(ng_geometry);
int res = ng_geometry -> GenerateMesh (mesh, mparam, perfstepsstart, perfstepsend);
// int res = ng_geometry -> GenerateMesh (mesh.Ptr(), mparam, perfstepsstart, perfstepsend);
@ -1355,13 +1357,13 @@ namespace netgen
if (mparam.secondorder)
{
const_cast<Refinement&> (ng_geometry -> GetRefinement()).MakeSecondOrder (*mesh);
const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()).MakeSecondOrder (*mesh);
mesh -> SetNextMajorTimeStamp();
}
if (mparam.elementorder > 1)
{
mesh -> GetCurvedElements().BuildCurvedElements (&const_cast<Refinement&> (ng_geometry -> GetRefinement()),
mesh -> GetCurvedElements().BuildCurvedElements (&const_cast<Refinement&> (mesh->GetGeometry()->GetRefinement()),
mparam.elementorder);
mesh -> SetNextMajorTimeStamp();
@ -1709,7 +1711,7 @@ namespace netgen
void * BisectDummy (void *)
{
const Refinement & ref = ng_geometry->GetRefinement();
const Refinement & ref = mesh->GetGeometry()->GetRefinement();
MeshOptimize2d * opt = NULL;
/*

View File

@ -16,15 +16,11 @@ if __platform.startswith('win'):
unit_square = SplineGeometry()
pi1 = unit_square.AppendPoint(0,0)
pi2 = unit_square.AppendPoint(1,0)
pi3 = unit_square.AppendPoint(1,1)
pi4 = unit_square.AppendPoint(0,1)
unit_square.Append(["line",pi1,pi2], bc=1)
unit_square.Append(["line",pi2,pi3], bc=2)
unit_square.Append(["line",pi3,pi4], bc=3)
unit_square.Append(["line",pi4,pi1], bc=4)
pnts = [ (0,0), (1,0), (1,1), (0,1) ]
lines = [ (0,1,1), (1,2,2), (2,3,3), (3,0,4) ]
pnums = [unit_square.AppendPoint(*p) for p in pnts]
for l1,l2,bc in lines:
unit_square.Append( ["line", pnums[l1], pnums[l2]], bc=bc)
all = ['SplineGeometry', 'unit_square']