Subject: CGAL users discussion list
List archive
- From: Richard Downe <>
- To: <>
- Subject: Re: [cgal-discuss] Can CGAL deal with STL file format?
- Date: Wed, 5 Dec 2012 08:41:40 -0600
STL is stereolithography, used by 3D systems.
Huayi, I don't believe it does, but here's a function I wrote to write Polyhedron_3 surfaces out as STL, I hope it helps.
(The block around if (caps) { } is used for deleting endcaps, prior to generating CFD compatible tetrahedral volumes in downstream processing -- you can ignore that, it uses a struct I created with a bounding box and a normal to identify the flow extensions and endcaps correctly.)
-richard
On 12/05/2012 01:31 AM, 帝林 wrote:
什么是标准文件格式?
what is stl file format@_@
发自我的小米手机
魏华祎
<>编写:
Hi, Everyone,
Is CGAL able to read or write triangular surface mesh into STL file
format? I can't find it in CGAL Document.
Best
Huayi
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://sympa.inria.fr/sympa/info/cgal-discuss
template<class T> void fusCFDMesh::ExportLumenSTLSolid(const T& surf, const std::string& filename, std::vector< endCapStruct > *caps=NULL) { using namespace std; typedef typename T::Facet_iterator Facet_iterator; typedef typename T::Cell_handle Cell_handle; typedef typename T::Vertex_handle Vertex_handle; typedef EK::Point_3 EP; vector<endCapStruct>::iterator cIter; IK_to_EK to_exact; EK_to_IK to_inexact; ofstream stlFile(filename.c_str()); stlFile << "solid FUSSOLID stereolithography representation of angio/ivus fusion results" << endl; Facet_iterator f = surf.facets_begin(); for( ; f != surf.facets_end(); f++) { Cell_handle cHnd = f->first; Vertex_handle h[3]; h[0] = ( f->second==0 ? cHnd->vertex( 1 ) : cHnd->vertex( 0 ) ); h[1] = ( f->second < 2 ? cHnd->vertex( 2 ) : cHnd->vertex( 1 ) ); h[2] = ( f->second < 3 ? cHnd->vertex( 3 ) : cHnd->vertex( 2 ) ); bool render = true; bool out_of_bounds[3]; EP eP[3]; for (int i=0; i<3; i++) { eP[i] = to_exact(h[i]->point()); out_of_bounds[i] = false; } if (caps) { for (cIter = caps->begin(); cIter != caps->end(); cIter++) { for (int i=0; i<3; i++) { CGAL::Vector_3<EK> tmpVec = eP[i] - CGAL::ORIGIN; EP transposed = CGAL::ORIGIN + tmpVec.transform(cIter->bbTransform); if ((cIter->plane.oriented_side(eP[i])!=CGAL::ON_POSITIVE_SIDE) && (cIter->bb.bounded_side(transposed)==CGAL::ON_BOUNDED_SIDE)) { EP tmp = cIter->plane.projection(eP[i]); eP[i] = tmp; out_of_bounds[i] = true; } } } render = (!(out_of_bounds[0] && out_of_bounds[1] && out_of_bounds[2])); } if (render) { CGAL::Vector_3<IK> n = CGAL::normal( to_inexact(eP[0]), to_inexact(eP[1]), to_inexact(eP[2]) ); stlFile << " facet normal " << n.x() << " " << n.y() << " " << n.z() << endl; stlFile << " outer loop" << endl; for (int i=0; i<3; i++) stlFile << " vertex " << eP[i].x() << " " << eP[i].y() << " " << eP[i].z() << endl; stlFile << " endloop" << endl; stlFile << " endfacet" << endl; } } stlFile << "endsolid FUSSOLID" << endl; stlFile.close(); }
- [cgal-discuss] Can CGAL deal with STL file format?, 魏华祎, 12/05/2012
- [cgal-discuss] Re: Can CGAL deal with STL file format?, ayongwust_sjtu, 12/05/2012
- Re: [cgal-discuss] Re: Can CGAL deal with STL file format?, 魏华祎, 12/05/2012
- Re: Re: [cgal-discuss] Re: Can CGAL deal with STL file format?, areslp, 12/05/2012
- Re: [cgal-discuss] Re: Can CGAL deal with STL file format?, Andreas Fabri, 12/05/2012
- Re: Re: [cgal-discuss] Re: Can CGAL deal with STL file format?, areslp, 12/05/2012
- Re: [cgal-discuss] Re: Can CGAL deal with STL file format?, 魏华祎, 12/05/2012
- <Possible follow-up(s)>
- Re: [cgal-discuss] Can CGAL deal with STL file format?, 帝林, 12/05/2012
- Re: [cgal-discuss] Can CGAL deal with STL file format?, Richard Downe, 12/05/2012
- Re: [cgal-discuss] Can CGAL deal with STL file format?, 魏华祎, 12/06/2012
- Re: [cgal-discuss] Can CGAL deal with STL file format?, 魏华祎, 12/06/2012
- Re: [cgal-discuss] Can CGAL deal with STL file format?, Richard Downe, 12/05/2012
- [cgal-discuss] Re: Can CGAL deal with STL file format?, ayongwust_sjtu, 12/05/2012
Archive powered by MHonArc 2.6.18.