Subject: CGAL users discussion list
List archive
- From: Richard Downe <>
- To: <>
- Subject: Re: [cgal-discuss] Re: .off To .stl coverter
- Date: Tue, 26 Mar 2013 13:41:14 -0500
I've attached a perl script for converting .off to .stl, and also a chunk of CGAL based code I currently use to write c2t3 complexes as an STL. It could be adapted to polyhedra fairly trivially. You can obviously ignore the chunk in the middle that I use for slicing off endcaps in order to accommodate CFD analysis...
-rd
On 03/25/2013 10:28 AM, mario wrote:
thanks, but i'd like to do it programmatically
--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/off-To-stl-coverter-tp4657020p4657023.html
Sent from the cgal-discuss mailing list archive at Nabble.com.
Attachment:
stlBuilder.pl
Description: Perl program
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] .off To .stl coverter, mario, 03/25/2013
- Re: [cgal-discuss] .off To .stl coverter, Tomislav Maric, 03/25/2013
- [cgal-discuss] Re: .off To .stl coverter, mario, 03/25/2013
- Re: [cgal-discuss] Re: .off To .stl coverter, Richard Downe, 03/26/2013
- [cgal-discuss] Re: .off To .stl coverter, mario, 03/29/2013
- Re: [cgal-discuss] Re: .off To .stl coverter, Richard Downe, 03/29/2013
- Re: [cgal-discuss] Re: .off To .stl coverter, Richard Downe, 03/29/2013
- Re: [cgal-discuss] Re: .off To .stl coverter, Richard Downe, 03/29/2013
- [cgal-discuss] Re: .off To .stl coverter, mario, 03/29/2013
- Re: [cgal-discuss] Re: .off To .stl coverter, Richard Downe, 03/26/2013
- [cgal-discuss] Re: .off To .stl coverter, mario, 03/25/2013
- Re: [cgal-discuss] .off To .stl coverter, Tomislav Maric, 03/25/2013
Archive powered by MHonArc 2.6.18.