mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
fix LoadGeometry in nglib (geom2d, stl)
This commit is contained in:
parent
7f4d9f485b
commit
3d7092e8b3
@ -10,42 +10,24 @@ namespace netgen
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
extern DLL_HEADER NetgenGeometry * ng_geometry;
|
// extern DLL_HEADER NetgenGeometry * ng_geometry;
|
||||||
static VisualSceneGeometry2d vsgeom2d;
|
static VisualSceneGeometry2d vsgeom2d;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SplineGeometryRegister : public GeometryRegister
|
|
||||||
|
|
||||||
|
class SplineGeometryVisRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
virtual NetgenGeometry * Load (string filename) const { return NULL; }
|
||||||
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
NetgenGeometry * SplineGeometryRegister :: Load (string filename) const
|
VisualScene * SplineGeometryVisRegister :: GetVisualScene (const NetgenGeometry * geom) const
|
||||||
{
|
{
|
||||||
const char * cfilename = filename.c_str();
|
const SplineGeometry2d * geometry = dynamic_cast<const SplineGeometry2d*> (geom);
|
||||||
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)
|
if (geometry)
|
||||||
{
|
{
|
||||||
vsgeom2d.SetGeometry (geometry);
|
vsgeom2d.SetGeometry (geometry);
|
||||||
@ -67,6 +49,6 @@ extern "C" int Ng_geom2d_Init (Tcl_Interp * interp);
|
|||||||
|
|
||||||
int Ng_geom2d_Init (Tcl_Interp * interp)
|
int Ng_geom2d_Init (Tcl_Interp * interp)
|
||||||
{
|
{
|
||||||
geometryregister.Append (new SplineGeometryRegister);
|
geometryregister.Append (new SplineGeometryVisRegister);
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
}
|
}
|
||||||
|
@ -945,4 +945,41 @@ namespace netgen
|
|||||||
return * new Refinement2d (*this);
|
return * new Refinement2d (*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SplineGeometryRegister : public GeometryRegister
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual NetgenGeometry * Load (string filename) 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SplineGeoInit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SplineGeoInit()
|
||||||
|
{
|
||||||
|
geometryregister.Append (new SplineGeometryRegister);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SplineGeoInit sginit;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3506,4 +3506,65 @@ void STLGeometry :: SmoothGeometry ()
|
|||||||
SetPoint (i, pi);
|
SetPoint (i, pi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class STLGeometryRegister : public GeometryRegister
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual NetgenGeometry * Load (string filename) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class STLInit
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
STLInit()
|
||||||
|
{
|
||||||
|
geometryregister.Append (new STLGeometryRegister);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
STLInit stlinit;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class STLGeometryRegister : public GeometryRegister
|
class STLGeometryVisRegister : public GeometryRegister
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual NetgenGeometry * Load (string filename) const;
|
virtual NetgenGeometry * Load (string filename) const { return NULL; }
|
||||||
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
virtual VisualScene * GetVisualScene (const NetgenGeometry * geom) const;
|
||||||
virtual void SetParameters (Tcl_Interp * interp)
|
virtual void SetParameters (Tcl_Interp * interp)
|
||||||
{
|
{
|
||||||
@ -103,7 +103,7 @@ namespace netgen
|
|||||||
Tcl_Interp * interp,
|
Tcl_Interp * interp,
|
||||||
int argc, tcl_const char *argv[])
|
int argc, tcl_const char *argv[])
|
||||||
{
|
{
|
||||||
STLGeometryRegister reg;
|
STLGeometryVisRegister reg;
|
||||||
reg.SetParameters (interp);
|
reg.SetParameters (interp);
|
||||||
|
|
||||||
return TCL_OK;
|
return TCL_OK;
|
||||||
@ -406,48 +406,6 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -581,12 +539,12 @@ namespace netgen
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
VisualScene * STLGeometryRegister :: GetVisualScene (const NetgenGeometry * geom) const
|
VisualScene * STLGeometryVisRegister :: GetVisualScene (const NetgenGeometry * geom) const
|
||||||
{
|
{
|
||||||
STLGeometry * geometry = dynamic_cast<STLGeometry*> (ng_geometry);
|
const STLGeometry * geometry = dynamic_cast<const STLGeometry*> (geom);
|
||||||
if (geometry)
|
if (geometry)
|
||||||
{
|
{
|
||||||
vsstlmeshing.SetGeometry (geometry);
|
vsstlmeshing.SetGeometry (const_cast<STLGeometry*> (geometry));
|
||||||
return &vsstlmeshing;
|
return &vsstlmeshing;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -599,7 +557,7 @@ using namespace netgen;
|
|||||||
extern "C" int Ng_stl_Init (Tcl_Interp * interp);
|
extern "C" int Ng_stl_Init (Tcl_Interp * interp);
|
||||||
int Ng_stl_Init (Tcl_Interp * interp)
|
int Ng_stl_Init (Tcl_Interp * interp)
|
||||||
{
|
{
|
||||||
geometryregister.Append (new STLGeometryRegister);
|
geometryregister.Append (new STLGeometryVisRegister);
|
||||||
|
|
||||||
Tcl_CreateCommand (interp, "Ng_SetSTLParameters", Ng_SetSTLParameters,
|
Tcl_CreateCommand (interp, "Ng_SetSTLParameters", Ng_SetSTLParameters,
|
||||||
(ClientData)NULL,
|
(ClientData)NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user