mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
Import STL as Mesh
This commit is contained in:
parent
ec40e605a3
commit
f6f4976402
@ -7,6 +7,7 @@
|
||||
#include <myadt.hpp>
|
||||
#include <linalg.hpp>
|
||||
#include <csg.hpp>
|
||||
#include <stlgeom.hpp>
|
||||
#include <meshing.hpp>
|
||||
|
||||
#include "writeuser.hpp"
|
||||
@ -648,6 +649,33 @@ namespace netgen
|
||||
ReadFNFFormat (mesh, filename);
|
||||
}
|
||||
|
||||
if ( ( (strlen (filename) > 4) && strcmp (&filename[strlen (filename)-4], ".stl") == 0 ) ||
|
||||
( (strlen (filename) > 5) && strcmp (&filename[strlen (filename)-5], ".stlb") == 0 ) )
|
||||
{
|
||||
ifstream ist{string{filename}};
|
||||
auto geom = shared_ptr<STLGeometry>(STLGeometry::Load(ist));
|
||||
|
||||
mesh.SetDimension (3);
|
||||
|
||||
auto & points = geom->GetPoints();
|
||||
|
||||
for (auto & p : points)
|
||||
mesh.AddPoint(MeshPoint(p));
|
||||
|
||||
mesh.AddFaceDescriptor (FaceDescriptor (1, 1, 0, 1));
|
||||
|
||||
for (auto ti : IntRange(geom->GetNT()))
|
||||
{
|
||||
auto & trig = geom->GetTriangle(ti);
|
||||
Element2d el(TRIG);
|
||||
for (auto i : IntRange(3))
|
||||
el[i] = (*geom)[STLTrigIndex(ti)][i];
|
||||
|
||||
el.SetIndex(1);
|
||||
|
||||
mesh.AddSurfaceElement(el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -231,6 +231,7 @@ loadmeshinifile;
|
||||
{"Universal format" {.unv} }
|
||||
{"Olaf format" {.emt} }
|
||||
{"TET format" {.tet} }
|
||||
{"STL format" {.stl .stlb} }
|
||||
{"Pro/ENGINEER neutral format" {.fnf} }
|
||||
}
|
||||
set file [tk_getOpenFile -filetypes $types ]
|
||||
|
@ -405,6 +405,7 @@ namespace netgen
|
||||
PrintMessage (2, mesh->GetNP(), " Points, ",
|
||||
mesh->GetNE(), " Elements.");
|
||||
|
||||
SetGlobalMesh (mesh);
|
||||
mesh->SetGlobalH (mparam.maxh);
|
||||
mesh->CalcLocalH(mparam.grading);
|
||||
|
||||
|
@ -861,6 +861,7 @@ const char * ngscript[] = {""
|
||||
,"{\"Universal format\" {.unv} }\n"
|
||||
,"{\"Olaf format\" {.emt} }\n"
|
||||
,"{\"TET format\" {.tet} }\n"
|
||||
,"{\"STL format\" {.stl .stlb} }\n"
|
||||
,"{\"Pro/ENGINEER neutral format\" {.fnf} }\n"
|
||||
,"}\n"
|
||||
,"set file [tk_getOpenFile -filetypes $types ]\n"
|
||||
|
Loading…
Reference in New Issue
Block a user