1 // Copyright (C) 2004-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MG_Tetra_API.hxx"
25 #include <SMESH_Comment.hxx>
26 #include <SMESH_File.hxx>
27 #include <Utils_SALOME_Exception.hxx>
36 #include <meshgems/meshgems.h>
37 #include <meshgems/tetra.h>
40 struct MG_Tetra_API::LibData
44 tetra_session_t * _session;
50 std::vector<double> _xyz;
51 std::vector<double> _nodeSize; // required nodes
52 std::vector<int> _edgeNodes;
54 std::vector<int> _triaNodes;
58 volatile bool& _cancelled_flag;
59 std::string _errorStr;
62 LibData( volatile bool & cancelled_flag, double& progress )
63 : _context(0), _session(0), _tria_mesh(0), _sizemap(0), _tetra_mesh(0),
64 _nbRequiredEdges(0), _nbRequiredTria(0),
65 _cancelled_flag( cancelled_flag ), _progress( progress )
68 // methods setting callbacks implemented after callback definitions
75 tetra_regain_mesh( _session, _tetra_mesh );
77 tetra_session_delete( _session );
79 mesh_delete( _tria_mesh );
81 sizemap_delete( _sizemap );
83 context_delete( _context );
92 void AddError( const char *txt )
98 const std::string& GetErrors()
103 void MG_Error(const char* txt="")
105 SMESH_Comment msg("\nMeshGems error. ");
107 AddError( msg.c_str() );
110 bool SetParam( const std::string& param, const std::string& value )
112 status_t ret = tetra_set_param( _session, param.c_str(), value.c_str() );
114 //std::cout << param << " = " << value << std::endl;
116 return ( ret == STATUS_OK );
121 return _cancelled_flag;
124 int ReadNbSubDomains()
127 status_t ret = mesh_get_subdomain_count( _tetra_mesh, & nb );
129 if ( ret != STATUS_OK ) MG_Error("mesh_get_subdomain_count problem");
136 status_t ret = mesh_get_vertex_count( _tetra_mesh, & nb );
138 if ( ret != STATUS_OK ) MG_Error("mesh_get_vertex_count problem");
145 status_t ret = mesh_get_edge_count( _tetra_mesh, & nb );
147 if ( ret != STATUS_OK ) MG_Error("mesh_get_edge_count problem");
154 status_t ret = mesh_get_triangle_count( _tetra_mesh, & nb );
156 if ( ret != STATUS_OK ) MG_Error("mesh_get_triangle_count problem");
163 status_t ret = mesh_get_quadrangle_count( _tetra_mesh, & nb );
165 if ( ret != STATUS_OK ) MG_Error("mesh_get_quadrangle_count problem");
172 status_t ret = mesh_get_tetrahedron_count( _tetra_mesh, & nb );
174 if ( ret != STATUS_OK ) MG_Error("mesh_get_tetrahedron_count problem");
181 status_t ret = mesh_get_hexahedron_count( _tetra_mesh, & nb );
183 if ( ret != STATUS_OK ) MG_Error("mesh_get_hexahedron_count problem");
192 void ReadSubDomain( int* nbNodes, int* faceInd, int* ori, int* domain )
194 integer tag, seed_type, seed_idx, seed_orientation;
195 status_t ret = mesh_get_subdomain_description( _tetra_mesh, _count,
196 &tag, &seed_type, &seed_idx, &seed_orientation);
198 if ( ret != STATUS_OK ) MG_Error( "unable to get a sub-domain description");
203 *ori = seed_orientation;
207 void ReadNodeXYZ( double* x, double* y, double *z, int* /*domain*/ )
210 status_t ret = mesh_get_vertex_coordinates( _tetra_mesh, _count, coo );
211 if ( ret != STATUS_OK ) MG_Error( "unable to get resulting vertices" );
220 void ReadEdgeNodes( int* node1, int* node2, int* domain )
223 status_t ret = mesh_get_edge_vertices( _tetra_mesh, _count, vtx);
224 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge" );
229 ret = mesh_get_edge_tag( _tetra_mesh, _count, &tag );
230 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge tag" );
237 void ReadTriaNodes( int* node1, int* node2, int* node3, int* domain )
240 status_t ret = mesh_get_triangle_vertices( _tetra_mesh, _count, vtx);
241 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle" );
247 ret = mesh_get_triangle_tag( _tetra_mesh, _count, &tag );
248 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle tag" );
255 void ReadQuadNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
258 status_t ret = mesh_get_quadrangle_vertices( _tetra_mesh, _count, vtx);
259 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle" );
266 ret = mesh_get_quadrangle_tag( _tetra_mesh, _count, &tag );
267 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle tag" );
274 void ReadTetraNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
277 status_t ret = mesh_get_tetrahedron_vertices( _tetra_mesh, _count, vtx);
278 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron" );
285 ret = mesh_get_tetrahedron_tag( _tetra_mesh, _count, &tag );
286 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron tag" );
293 void ReadHexaNodes( int* node1, int* node2, int* node3, int* node4,
294 int* node5, int* node6, int* node7, int* node8, int* domain )
297 status_t ret = mesh_get_hexahedron_vertices( _tetra_mesh, _count, vtx);
298 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron" );
309 ret = mesh_get_hexahedron_tag( _tetra_mesh, _count, &tag );
310 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron tag" );
317 void SetNbVertices( int nb )
319 _xyz.reserve( _xyz.capacity() + nb );
322 void SetNbEdges( int nb )
324 _edgeNodes.reserve( nb * 2 );
327 void SetNbTria( int nb )
329 _triaNodes.reserve( nb * 3 );
332 void SetNbReqVertices( int nb )
334 _nodeSize.reserve( nb );
337 void SetNbReqEdges( int nb )
339 _nbRequiredEdges = nb;
342 void SetNbReqTria( int nb )
344 _nbRequiredTria = nb;
347 void AddNode( double x, double y, double z, int domain )
354 void AddSizeAtNode( double size )
356 _nodeSize.push_back( size );
359 void AddEdgeNodes( int node1, int node2, int domain )
361 _edgeNodes.push_back( node1 );
362 _edgeNodes.push_back( node2 );
365 void AddTriaNodes( int node1, int node2, int node3, int domain )
367 _triaNodes.push_back( node1 );
368 _triaNodes.push_back( node2 );
369 _triaNodes.push_back( node3 );
374 return _xyz.size() / 3;
377 double* NodeCoord( int iNode )
379 return & _xyz[ iNode * 3 ];
384 return _edgeNodes.size() / 2;
387 int* GetEdgeNodes( int iEdge )
389 return & _edgeNodes[ iEdge * 2 ];
394 return _triaNodes.size() / 3;
397 int * GetTriaNodes( int iTria )
399 return & _triaNodes[ iTria * 3 ];
402 int IsVertexRequired( int iNode )
404 return ! ( iNode < int( NbNodes() - _nodeSize.size() ));
407 double GetSizeAtVertex( int iNode )
409 return IsVertexRequired( iNode ) ? _nodeSize[ iNode - NbNodes() + _nodeSize.size() ] : 0.;
413 namespace // functions called by MG library to exchange with the application
415 status_t get_vertex_count(integer * nbvtx, void *user_data)
417 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
418 *nbvtx = data->NbNodes();
423 status_t get_vertex_coordinates(integer ivtx, real * xyz, void *user_data)
425 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
426 double* coord = data->NodeCoord( ivtx-1 );
427 for (int j = 0; j < 3; j++)
432 status_t get_edge_count(integer * nbedge, void *user_data)
434 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
435 *nbedge = data->NbEdges();
440 status_t get_edge_vertices(integer iedge, integer * vedge, void *user_data)
442 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
443 int* nodes = data->GetEdgeNodes( iedge-1 );
450 status_t get_triangle_count(integer * nbtri, void *user_data)
452 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
453 *nbtri = data->NbTriangles();
458 status_t get_triangle_vertices(integer itri, integer * vtri, void *user_data)
460 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
461 int* nodes = data->GetTriaNodes( itri-1 );
469 // status_t get_triangle_extra_vertices(integer itri, integer * typetri,
470 // integer * evtri, void *user_data)
473 // MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
476 // /* We want to describe a linear "3 nodes" triangle */
477 // *typetri = MESHGEMS_MESH_ELEMENT_TYPE_TRIA3;
479 // /* We want to describe a quadratic "6 nodes" triangle */
480 // *typetri = MESHGEMS_MESH_ELEMENT_TYPE_TRIA6;
481 // for (j = 0; j < 3; j++)
482 // evtri[j] = 0; /* the j'th quadratic vertex index of the itri'th triangle */
488 // status_t get_tetrahedron_count(integer * nbtetra, void *user_data)
490 // MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
492 // *nbtetra = 0; /* the number of tetra in your input mesh (0 if you describe a surface mesh) */
497 // status_t get_tetrahedron_vertices(integer itetra, integer * vtetra,
501 // MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
503 // for (j = 0; j < 4; j++)
504 // vtetra[j] = 0; /* the j'th vertex index of the itetra'th tetrahedron */
509 status_t get_vertex_required_property(integer ivtx, integer * rvtx, void *user_data)
511 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
512 *rvtx = data->IsVertexRequired( ivtx - 1 );
517 status_t get_vertex_weight(integer ivtx, real * wvtx, void *user_data)
519 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
520 *wvtx = data->GetSizeAtVertex( ivtx - 1 );
525 status_t my_message_cb(message_t * msg, void *user_data)
528 message_get_description(msg, &desc);
530 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
531 data->AddError( desc );
534 //std::cout << desc << std::endl;
538 // corresponding messages are:
539 // " -- PHASE 1 COMPLETED" => 10 %
540 // " -- PHASE 2 COMPLETED" => 25 %
541 // " ** ITERATION 1" => 25.* %
542 // " ** ITERATION 2" => 25.* %
543 // " -- PHASE 3 COMPLETED" => 70 %
544 // " -- PHASE 4 COMPLETED" => 98 %
546 if ( strncmp( "-- PHASE ", desc + 2, 9 ) == 0 && desc[ 13 ] == 'C' )
548 const double progress[] = { 10., 25., 70., 98., 100., 100., 100. };
549 int phase = atoi( desc + 11 );
550 data->_progress = std::max( data->_progress, progress[ phase - 1 ] / 100. );
552 else if ( strncmp( "** ITERATION ", desc + 5, 13 ) == 0 )
554 int iter = atoi( desc + 20 );
555 double percent = 25. + iter * ( 70 - 25 ) / 20.;
556 data->_progress = std::max( data->_progress, ( percent / 100. ));
562 status_t my_interrupt_callback(integer *interrupt_status, void *user_data)
564 MG_Tetra_API::LibData* data = (MG_Tetra_API::LibData *) user_data;
565 *interrupt_status = ( data->Cancelled() ? INTERRUPT_STOP : INTERRUPT_CONTINUE );
574 void MG_Tetra_API::LibData::Init()
578 // Create the meshgems working context
579 _context = context_new();
580 if ( !_context ) MG_Error( "unable to create a new context" );
582 // Set the message callback for the _context.
583 ret = context_set_message_callback( _context, my_message_cb, this );
584 if ( ret != STATUS_OK ) MG_Error("in context_set_message_callback");
586 // Create the structure holding the callbacks giving access to triangle mesh
587 _tria_mesh = mesh_new( _context );
588 if ( !_tria_mesh ) MG_Error("unable to create a new mesh");
590 // Set callbacks to provide triangle mesh data
591 mesh_set_get_vertex_count( _tria_mesh, get_vertex_count, this );
592 mesh_set_get_vertex_coordinates( _tria_mesh, get_vertex_coordinates, this );
593 mesh_set_get_vertex_required_property( _tria_mesh, get_vertex_required_property, this );
594 mesh_set_get_edge_count( _tria_mesh, get_edge_count, this);
595 mesh_set_get_edge_vertices( _tria_mesh, get_edge_vertices, this );
596 mesh_set_get_triangle_count( _tria_mesh, get_triangle_count, this );
597 mesh_set_get_triangle_vertices( _tria_mesh, get_triangle_vertices, this );
599 // Create a tetra session
600 _session = tetra_session_new( _context );
601 if ( !_session ) MG_Error( "unable to create a new tetra session");
603 ret = tetra_set_interrupt_callback( _session, my_interrupt_callback, this );
604 if ( ret != STATUS_OK ) MG_Error("in tetra_set_interrupt_callback");
608 bool MG_Tetra_API::LibData::Compute()
611 status_t ret = tetra_set_surface_mesh( _session, _tria_mesh );
612 if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh");
615 if ( !_nodeSize.empty() )
617 _sizemap = meshgems_sizemap_new( _tria_mesh, meshgems_sizemap_type_iso_mesh_vertex,
618 (void*) &get_vertex_weight, this );
619 if ( !_sizemap ) MG_Error("unable to create a new sizemap");
621 ret = tetra_set_sizemap( _session, _sizemap );
622 if ( ret != STATUS_OK ) MG_Error( "unable to set sizemap");
625 //////////////////////////////////////////////////////////////////////////////////////////
626 // const char* file = "/tmp/ghs3d_IN.mesh";
627 // mesh_write_mesh( _tria_mesh,file);
628 // std::cout << std::endl << std::endl << "Write " << file << std::endl << std::endl << std::endl;
630 ret = tetra_compute_mesh( _session );
631 if ( ret != STATUS_OK ) return false;
633 ret = tetra_get_mesh( _session, &_tetra_mesh);
634 if (ret != STATUS_OK) MG_Error( "unable to get resulting mesh");
636 //////////////////////////////////////////////////////////////////////////////////////////
637 // file = "/tmp/ghs3d_OUT.mesh";
638 // mesh_write_mesh( _tetra_mesh,file);
639 // std::cout << std::endl << std::endl << "Write " << file << std::endl << std::endl << std::endl;
645 #endif // ifdef USE_MG_LIBS
648 //================================================================================
652 //================================================================================
654 MG_Tetra_API::MG_Tetra_API(volatile bool& cancelled_flag, double& progress)
658 _libData = new LibData( cancelled_flag, progress );
661 if ( getenv("MG_TETRA_USE_EXE"))
665 //================================================================================
669 //================================================================================
671 MG_Tetra_API::~MG_Tetra_API()
677 std::set<int>::iterator id = _openFiles.begin();
678 for ( ; id != _openFiles.end(); ++id )
679 ::GmfCloseMesh( *id );
683 //================================================================================
685 * \brief Return the way of MG usage
687 //================================================================================
689 bool MG_Tetra_API::IsLibrary()
694 //================================================================================
696 * \brief Switch to usage of MG-Tetra executable
698 //================================================================================
700 void MG_Tetra_API::SetUseExecutable()
705 //================================================================================
707 * \brief Compute the tetra mesh
708 * \param [in] cmdLine - a command to run mg_tetra.exe
709 * \return bool - Ok or not
711 //================================================================================
713 bool MG_Tetra_API::Compute( const std::string& cmdLine, std::string& errStr )
719 std::istringstream strm( cmdLine );
720 std::istream_iterator<std::string> sIt( strm ), sEnd;
721 std::vector< std::string > args( sIt, sEnd );
724 std::string param, value;
725 for ( size_t i = 1; i < args.size(); ++i )
727 // look for a param name; it starts from "-"
729 if ( param.size() < 2 || param[0] != '-')
731 while ( param[0] == '-')
732 param = param.substr( 1 );
735 while ( i+1 < args.size() && args[i+1][0] != '-' )
737 if ( !value.empty() ) value += " ";
740 if ( !_libData->SetParam( param, value ))
741 std::cout << "Warning: wrong param: '" << param <<"' = '" << value << "'" << std::endl;
745 bool ok = _libData->Compute();
747 GetLog(); // write a log file
748 _logFile = ""; // not to write it again
754 int err = system( cmdLine.c_str() ); // run
757 errStr = SMESH_Comment("system(mg-tetra.exe ...) command failed with error: ")
758 << strerror( errno );
764 //================================================================================
766 * \brief Prepare for reading a mesh data
768 //================================================================================
770 int MG_Tetra_API::GmfOpenMesh(const char* theFile, int rdOrWr, int * ver, int * dim)
777 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim );
778 _openFiles.insert( id );
782 //================================================================================
784 * \brief Return nb of entities
786 //================================================================================
788 int MG_Tetra_API::GmfStatKwd( int iMesh, GmfKwdCod what )
794 case GmfSubDomainFromGeom: return _libData->ReadNbSubDomains();
795 case GmfVertices: return _libData->ReadNbNodes();
796 case GmfEdges: return _libData->ReadNbEdges();
797 case GmfTriangles: return _libData->ReadNbTria();
798 case GmfQuadrilaterals: return _libData->ReadNbQuads();
799 case GmfTetrahedra: return _libData->ReadNbTetra();
800 case GmfHexahedra: return _libData->ReadNbHexa();
806 return ::GmfStatKwd( iMesh, what );
809 //================================================================================
811 * \brief Prepare for reading some data
813 //================================================================================
815 void MG_Tetra_API::GmfGotoKwd( int iMesh, GmfKwdCod what )
819 _libData->ResetCounter();
823 ::GmfGotoKwd( iMesh, what );
826 //================================================================================
828 * \brief Return index of a domain identified by a triangle normal
829 * \param [in] iMesh - mesh file index
830 * \param [in] what - must be GmfSubDomainFromGeom
831 * \param [out] nbNodes - nb nodes in a face
832 * \param [out] faceInd - face index
833 * \param [out] ori - face orientation
834 * \param [out] domain - domain index
835 * \param [in] dummy - an artificial param used to discriminate from GmfGetLin() reading
838 //================================================================================
840 void MG_Tetra_API::GmfGetLin( int iMesh, GmfKwdCod what, int* nbNodes, int* faceInd, int* ori, int* domain, int dummy )
844 _libData->ReadSubDomain( nbNodes, faceInd, ori, domain );
848 ::GmfGetLin( iMesh, what, nbNodes, faceInd, ori, domain );
851 //================================================================================
853 * \brief Return coordinates of a next node
855 //================================================================================
857 void MG_Tetra_API::GmfGetLin(int iMesh, GmfKwdCod what,
858 double* x, double* y, double *z, int* domain )
862 _libData->ReadNodeXYZ( x, y, z, domain );
866 ::GmfGetLin(iMesh, what, x, y, z, domain );
869 //================================================================================
871 * \brief Return coordinates of a next node
873 //================================================================================
875 void MG_Tetra_API::GmfGetLin(int iMesh, GmfKwdCod what,
876 float* x, float* y, float *z, int* domain )
881 _libData->ReadNodeXYZ( &X, &Y, &Z, domain );
888 ::GmfGetLin(iMesh, what, x, y, z, domain );
891 //================================================================================
893 * \brief Return node index of a next corner
895 //================================================================================
897 void MG_Tetra_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node )
905 ::GmfGetLin(iMesh, what, node );
908 //================================================================================
910 * \brief Return node indices of a next edge
912 //================================================================================
914 void MG_Tetra_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node1, int* node2, int* domain )
918 _libData->ReadEdgeNodes( node1, node2, domain );
922 ::GmfGetLin( iMesh, what, node1, node2, domain );
925 //================================================================================
927 * \brief Return node indices of a next triangle
929 //================================================================================
931 void MG_Tetra_API::GmfGetLin(int iMesh, GmfKwdCod what,
932 int* node1, int* node2, int* node3, int* domain )
936 _libData->ReadTriaNodes( node1, node2, node3, domain );
940 ::GmfGetLin(iMesh, what, node1, node2, node3, domain );
943 //================================================================================
945 * \brief Return node indices of a next tetrahedron or quadrangle
947 //================================================================================
949 void MG_Tetra_API::GmfGetLin(int iMesh, GmfKwdCod what,
950 int* node1, int* node2, int* node3, int* node4, int* domain )
954 if ( what == GmfQuadrilaterals )
955 _libData->ReadQuadNodes( node1, node2, node3, node4, domain );
957 _libData->ReadTetraNodes( node1, node2, node3, node4, domain );
961 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, domain );
964 //================================================================================
966 * \brief Return node indices of a next hexahedron
968 //================================================================================
970 void MG_Tetra_API::GmfGetLin(int iMesh, GmfKwdCod what,
971 int* node1, int* node2, int* node3, int* node4,
972 int* node5, int* node6, int* node7, int* node8,
977 _libData->ReadHexaNodes( node1, node2, node3, node4,
978 node5, node6, node7, node8, domain );
982 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, node5, node6, node7, node8, domain );
985 //================================================================================
987 * \brief Prepare for passing data to MeshGems
989 //================================================================================
991 int MG_Tetra_API::GmfOpenMesh(const char* theFile, int rdOrWr, int ver, int dim)
998 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim);
999 _openFiles.insert( id );
1003 //================================================================================
1005 * \brief Set number of entities
1007 //================================================================================
1009 void MG_Tetra_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb )
1014 case GmfVertices: _libData->SetNbVertices( nb ); break;
1015 case GmfEdges: _libData->SetNbEdges ( nb ); break;
1016 case GmfRequiredEdges: _libData->SetNbReqEdges( nb ); break;
1017 case GmfTriangles: _libData->SetNbTria ( nb ); break;
1018 case GmfRequiredTriangles: _libData->SetNbReqTria ( nb ); break;
1024 ::GmfSetKwd(iMesh, what, nb );
1027 //================================================================================
1029 * \brief Add coordinates of a node
1031 //================================================================================
1033 void MG_Tetra_API::GmfSetLin(int iMesh, GmfKwdCod what, double x, double y, double z, int domain)
1037 _libData->AddNode( x, y, z, domain );
1041 ::GmfSetLin(iMesh, what, x, y, z, domain);
1044 //================================================================================
1046 * \brief Set number of field entities
1047 * \param [in] iMesh - solution file index
1048 * \param [in] what - solution type
1049 * \param [in] nbNodes - nb of entities
1050 * \param [in] nbTypes - nb of data entries in each entity
1051 * \param [in] type - types of the data entries
1053 * Used to prepare to storing size at nodes
1055 //================================================================================
1057 void MG_Tetra_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nbNodes, int dummy, int type[] )
1061 if ( what == GmfSolAtVertices ) _libData->SetNbReqVertices( nbNodes );
1065 ::GmfSetKwd(iMesh, what, nbNodes, dummy, type );
1068 //================================================================================
1070 * \brief Add solution data
1072 //================================================================================
1074 void MG_Tetra_API::GmfSetLin(int iMesh, GmfKwdCod what, double vals[])
1078 _libData->AddSizeAtNode( vals[0] );
1082 ::GmfSetLin(iMesh, what, vals);
1085 //================================================================================
1087 * \brief Add edge nodes
1089 //================================================================================
1091 void MG_Tetra_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int domain )
1095 _libData->AddEdgeNodes( node1, node2, domain );
1099 ::GmfSetLin(iMesh, what, node1, node2, domain );
1102 //================================================================================
1104 * \brief Add a 'required' flag
1106 //================================================================================
1108 void MG_Tetra_API::GmfSetLin(int iMesh, GmfKwdCod what, int id )
1115 ::GmfSetLin(iMesh, what, id );
1118 //================================================================================
1120 * \brief Add triangle nodes
1122 //================================================================================
1124 void MG_Tetra_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int node3, int domain )
1128 _libData->AddTriaNodes( node1, node2, node3, domain );
1132 ::GmfSetLin(iMesh, what, node1, node2, node3, domain );
1135 //================================================================================
1137 * \brief Close a file
1139 //================================================================================
1141 void MG_Tetra_API::GmfCloseMesh( int iMesh )
1148 ::GmfCloseMesh( iMesh );
1149 _openFiles.erase( iMesh );
1152 //================================================================================
1154 * \brief Return true if the log is not empty
1156 //================================================================================
1158 bool MG_Tetra_API::HasLog()
1162 return !_libData->GetErrors().empty();
1165 SMESH_File file( _logFile );
1166 return file.size() > 0;
1169 //================================================================================
1171 * \brief Return log contents
1173 //================================================================================
1175 std::string MG_Tetra_API::GetLog()
1179 const std::string& err = _libData->GetErrors();
1180 if ( !_logFile.empty() && !err.empty() )
1182 SMESH_File file( _logFile, /*openForReading=*/false );
1183 file.openForWriting();
1184 file.write( err.c_str(), err.size() );
1189 SMESH_File file( _logFile );
1190 return file.getPos();