Home
Reply
Contributor
cqiang_nwpu
Posts: 8

How to save the mesh in a stl file use STL_MESH_MANAGER

Hello,everybody!

I want to facet all the faces of an entity, then save the mesh information as a stl format, I have to find a class STL_MESH_MANAGER,but  I do not now how to use it.

 

 codes:

 

  REFINEMENT * ref = 0;
  logical worked =process(api_create_refinement( ref ));   

 

 //EXCEPTION_BEGIN

 

 STL_MESH_MANAGER * MM = NULL;

 

  //EXCEPTION_TRY

  

   MM = ACIS_NEW STL_MESH_MANAGER;


  api_set_mesh_manager( MM );
  
  ENTITY_LIST face_list,bsface_list;


  if (grainBody)//ENTITY* grainBody
  {
   
   worked= process(api_get_faces((ENTITY*)grainBody, face_list));
   // Facet.
   worked =process(api_facet_entities(grainBody,&face_list) );   

 

   FILE *fp=fopen("D:\\all.stl","w");

   //here how to output the mesh?

  .......

  fclose(fp1);

   }

 

Thank you

Spatial Employee
vipull
Posts: 7

Re: How to save the mesh in a stl file use STL_MESH_MANAGER

Hi,

 

Following changes should help-

 

---------------------

 MM = ACIS_NEW STL_MESH_MANAGER;

  FILE *fp=fopen("D:\\all.stl","w");

  api_set_mesh_manager( MM );

 

  if(fp)
      MM->set_output_file(fp);


  ENTITY_LIST face_list,bsface_list;


  if (grainBody)//ENTITY* grainBody
  {
   
   worked= process(api_get_faces((ENTITY*)grainBody, face_list));
   // Facet.
   worked =process(api_facet_entities(grainBody,&face_list) );   

 

   //here how to output the mesh?

  .......

  fclose(fp);

   }

---------------------

 

I moved your fopen call to a location before facet_entities call and set it to mesh manager's output file.

I suggest that instead of fopen it would be a good idea to call fopen_s. fopen is deprecated now and fopen_s is the secured version of the same.

 

The call to api_facet_entities takes care of writing the facets to the output STL file right now.

 

Hope this helps.

 

cheers,

Vipul