1 // Copyright (C) 2004-2019 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_HYBRID_API.hxx"
22 #include <SMESH_Comment.hxx>
23 #include <SMESH_File.hxx>
24 #include <Utils_SALOME_Exception.hxx>
33 #include <meshgems/meshgems.h>
34 #include <meshgems/hybrid.h>
37 struct MG_HYBRID_API::LibData
41 hybrid_session_t *_session;
44 mesh_t * _hybrid_mesh;
47 std::vector<double> _xyz;
48 std::vector<double> _nodeSize; // required nodes
49 std::vector<int> _edgeNodesTags;
51 std::vector<int> _triaNodesTags;
53 std::vector<int> _quadNodes;
54 std::vector<int> _corners;
57 volatile bool& _cancelled_flag;
58 std::string _errorStr;
63 LibData( volatile bool & cancelled_flag, double& progress )
64 : _context(0), _session(0), _surf_mesh(0), _sizemap(0), _hybrid_mesh(0),
65 _nbRequiredEdges(0), _nbRequiredTria(0),
66 _cancelled_flag( cancelled_flag ), _progress( progress ), _msgCost( 0.00015 )
69 // methods setting callbacks implemented after callback definitions
76 hybrid_regain_mesh( _session, _hybrid_mesh );
78 hybrid_session_delete( _session );
80 mesh_delete( _surf_mesh );
82 sizemap_delete( _sizemap );
84 context_delete( _context );
93 void AddError( const char *txt )
101 const std::string& GetErrors()
106 void MG_Error(const char* txt="")
108 SMESH_Comment msg("\nMeshGems error. ");
110 AddError( msg.c_str() );
113 bool SetParam( const std::string& param, const std::string& value )
115 status_t ret = hybrid_set_param( _session, param.c_str(), value.c_str() );
117 //std::cout << param << " = " << value << std::endl;
119 return ( ret == STATUS_OK );
124 return _cancelled_flag;
127 int ReadNbSubDomains()
130 status_t ret = mesh_get_subdomain_count( _hybrid_mesh, & nb );
132 if ( ret != STATUS_OK ) MG_Error("mesh_get_subdomain_count problem");
141 status_t ret = mesh_get_vertex_count( _hybrid_mesh, & nb );
143 if ( ret != STATUS_OK ) MG_Error("mesh_get_vertex_count problem");
150 status_t ret = mesh_get_edge_count( _hybrid_mesh, & nb );
152 if ( ret != STATUS_OK ) MG_Error("mesh_get_edge_count problem");
159 status_t ret = mesh_get_triangle_count( _hybrid_mesh, & nb );
161 if ( ret != STATUS_OK ) MG_Error("mesh_get_triangle_count problem");
168 status_t ret = mesh_get_quadrangle_count( _hybrid_mesh, & nb );
170 if ( ret != STATUS_OK ) MG_Error("mesh_get_quadrangle_count problem");
177 status_t ret = mesh_get_tetrahedron_count( _hybrid_mesh, & nb );
179 if ( ret != STATUS_OK ) MG_Error("mesh_get_tetrahedron_count problem");
186 status_t ret = mesh_get_hexahedron_count( _hybrid_mesh, & nb );
188 if ( ret != STATUS_OK ) MG_Error("mesh_get_hexahedron_count problem");
195 status_t ret = mesh_get_prism_count( _hybrid_mesh, & nb );
197 if ( ret != STATUS_OK ) MG_Error("mesh_get_prism_count problem");
203 return _corners.size();
211 void ReadSubDomain( int* nbNodes, int* faceInd, int* ori, int* domain )
213 integer tag, seed_type, seed_idx, seed_orientation;
214 status_t ret = mesh_get_subdomain_description( _hybrid_mesh, _count,
215 &tag, &seed_type, &seed_idx, &seed_orientation);
217 if ( ret != STATUS_OK ) MG_Error( "unable to get a sub-domain description");
222 *ori = seed_orientation;
226 void ReadNodeXYZ( double* x, double* y, double *z, int* /*domain*/ )
229 status_t ret = mesh_get_vertex_coordinates( _hybrid_mesh, _count, coo );
230 if ( ret != STATUS_OK ) MG_Error( "unable to get resulting vertices" );
236 integer isCorner = 0;
237 ret = mesh_get_vertex_corner_property( _hybrid_mesh, _count, &isCorner);
238 if (ret != STATUS_OK) MG_Error( "unable to get resulting vertex property" );
240 _corners.push_back( _count );
245 void ReadEdgeNodes( int* node1, int* node2, int* domain )
248 status_t ret = mesh_get_edge_vertices( _hybrid_mesh, _count, vtx);
249 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge" );
254 ret = mesh_get_edge_tag( _hybrid_mesh, _count, &tag );
255 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge tag" );
262 void ReadTriaNodes( int* node1, int* node2, int* node3, int* domain )
265 status_t ret = mesh_get_triangle_vertices( _hybrid_mesh, _count, vtx);
266 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle" );
272 ret = mesh_get_triangle_tag( _hybrid_mesh, _count, &tag );
273 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle tag" );
280 void ReadQuadNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
283 status_t ret = mesh_get_quadrangle_vertices( _hybrid_mesh, _count, vtx);
284 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle" );
291 ret = mesh_get_quadrangle_tag( _hybrid_mesh, _count, &tag );
292 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle tag" );
299 void ReadTetraNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
302 status_t ret = mesh_get_tetrahedron_vertices( _hybrid_mesh, _count, vtx);
303 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron" );
310 ret = mesh_get_tetrahedron_tag( _hybrid_mesh, _count, &tag );
311 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron tag" );
318 void ReadHexaNodes( int* node1, int* node2, int* node3, int* node4,
319 int* node5, int* node6, int* node7, int* node8, int* domain )
322 status_t ret = mesh_get_hexahedron_vertices( _hybrid_mesh, _count, vtx);
323 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron" );
334 ret = mesh_get_hexahedron_tag( _hybrid_mesh, _count, &tag );
335 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron tag" );
342 void ReadPrismNodes( int* node1, int* node2, int* node3, int* node4,
343 int* node5, int* node6, int* domain )
346 status_t ret = mesh_get_prism_vertices( _hybrid_mesh, _count, vtx);
347 if (ret != STATUS_OK) MG_Error( "unable to get resulting prism" );
357 // ret = mesh_get_hexahedron_tag( _hybrid_mesh, _count, &tag );
358 // if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron tag" );
365 void ReadCorner( int* node )
367 if ( _count <= ReadNbCorners() )
368 *node = _corners[ _count - 1 ];
375 void SetNbVertices( int nb )
377 _xyz.reserve( _xyz.capacity() + nb );
380 void SetNbEdges( int nb )
382 _edgeNodesTags.reserve( nb * 3 );
385 void SetNbTria( int nb )
387 _triaNodesTags.reserve( nb * 4 );
390 void SetNbQuads( int nb )
392 _quadNodes.reserve( nb * 4 );
395 void SetNbReqVertices( int nb )
397 _nodeSize.reserve( nb );
400 void SetNbReqEdges( int nb )
402 _nbRequiredEdges = nb;
405 void SetNbReqTria( int nb )
407 _nbRequiredTria = nb;
410 void AddNode( double x, double y, double z, int domain )
417 void AddSizeAtNode( double size )
419 _nodeSize.push_back( size );
422 void AddEdgeNodes( int node1, int node2, int domain )
424 _edgeNodesTags.push_back( node1 );
425 _edgeNodesTags.push_back( node2 );
426 _edgeNodesTags.push_back( domain );
429 void AddTriaNodes( int node1, int node2, int node3, int domain )
431 _triaNodesTags.push_back( node1 );
432 _triaNodesTags.push_back( node2 );
433 _triaNodesTags.push_back( node3 );
434 _triaNodesTags.push_back( domain );
437 void AddQuadNodes( int node1, int node2, int node3, int node4 )
439 _quadNodes.push_back( node1 );
440 _quadNodes.push_back( node2 );
441 _quadNodes.push_back( node3 );
442 _quadNodes.push_back( node4 );
447 return _xyz.size() / 3;
450 double* NodeCoord( int iNode )
452 return & _xyz[ iNode * 3 ];
457 return _edgeNodesTags.size() / 3;
460 int* GetEdgeNodes( int iEdge )
462 return & _edgeNodesTags[ iEdge * 3 ];
465 int GetEdgeTag( int iEdge )
467 return _edgeNodesTags[ iEdge * 3 + 2 ];
472 return _triaNodesTags.size() / 4;
475 int * GetTriaNodes( int iTria )
477 return & _triaNodesTags[ iTria * 4 ];
480 int GetTriaTag( int iTria )
482 return _triaNodesTags[ iTria * 4 + 3 ];
487 return _quadNodes.size() / 4;
490 int * GetQuadNodes( int iQ )
492 return & _quadNodes[ iQ * 4 ];
495 int IsVertexRequired( int iNode )
497 return ! ( iNode < int( NbNodes() - _nodeSize.size() ));
500 double GetSizeAtVertex( int iNode )
502 return IsVertexRequired( iNode ) ? _nodeSize[ iNode - NbNodes() + _nodeSize.size() ] : 0.;
506 namespace // functions called by MG library to exchange with the application
508 status_t get_vertex_count(integer * nbvtx, void *user_data)
510 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
511 *nbvtx = data->NbNodes();
516 status_t get_vertex_coordinates(integer ivtx, real * xyz, void *user_data)
518 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
519 double* coord = data->NodeCoord( ivtx-1 );
520 for (int j = 0; j < 3; j++)
525 status_t get_edge_count(integer * nbedge, void *user_data)
527 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
528 *nbedge = data->NbEdges();
533 status_t get_edge_vertices(integer iedge, integer * vedge, void *user_data)
535 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
536 int* nodes = data->GetEdgeNodes( iedge-1 );
543 status_t get_edge_tag(integer iedge, integer * tag, void *user_data)
545 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
546 * tag = data->GetEdgeTag( iedge-1 );
551 status_t get_triangle_count(integer * nbtri, void *user_data)
553 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
554 *nbtri = data->NbTriangles();
559 status_t get_triangle_vertices(integer itri, integer * vtri, void *user_data)
561 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
562 int* nodes = data->GetTriaNodes( itri-1 );
570 status_t get_triangle_tag(integer itri, integer * tag, void *user_data)
572 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
573 * tag = data->GetTriaTag( itri-1 );
578 status_t get_quadrangle_count(integer * nbq, void *user_data)
580 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
581 *nbq = data->NbQuads();
586 status_t get_quadrangle_vertices(integer iq, integer * vq, void *user_data)
588 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
589 int* nodes = data->GetQuadNodes( iq-1 );
598 status_t get_vertex_required_property(integer ivtx, integer * rvtx, void *user_data)
600 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
601 *rvtx = data->IsVertexRequired( ivtx - 1 );
606 status_t get_vertex_weight(integer ivtx, real * wvtx, void *user_data)
608 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
609 *wvtx = data->GetSizeAtVertex( ivtx - 1 );
614 status_t my_message_cb(message_t * msg, void *user_data)
617 message_get_description(msg, &desc);
619 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
620 data->AddError( desc );
625 status_t my_interrupt_callback(integer *interrupt_status, void *user_data)
627 MG_HYBRID_API::LibData* data = (MG_HYBRID_API::LibData *) user_data;
628 *interrupt_status = ( data->Cancelled() ? INTERRUPT_STOP : INTERRUPT_CONTINUE );
636 void MG_HYBRID_API::LibData::Init()
640 // Create the meshgems working context
641 _context = context_new();
642 if ( !_context ) MG_Error( "unable to create a new context" );
644 // Set the message callback for the _context.
645 ret = context_set_message_callback( _context, my_message_cb, this );
646 if ( ret != STATUS_OK ) MG_Error("in context_set_message_callback");
648 // Create the structure holding the callbacks giving access to triangle mesh
649 _surf_mesh = mesh_new( _context );
650 if ( !_surf_mesh ) MG_Error("unable to create a new mesh");
652 // Set callbacks to provide triangle mesh data
653 mesh_set_get_vertex_count( _surf_mesh, get_vertex_count, this );
654 mesh_set_get_vertex_coordinates( _surf_mesh, get_vertex_coordinates, this );
655 mesh_set_get_vertex_required_property( _surf_mesh, get_vertex_required_property, this );
656 mesh_set_get_edge_count( _surf_mesh, get_edge_count, this);
657 mesh_set_get_edge_vertices( _surf_mesh, get_edge_vertices, this );
658 mesh_set_get_edge_tag( _surf_mesh, get_edge_tag, this );
659 mesh_set_get_triangle_count( _surf_mesh, get_triangle_count, this );
660 mesh_set_get_triangle_vertices( _surf_mesh, get_triangle_vertices, this );
661 mesh_set_get_triangle_tag( _surf_mesh, get_triangle_tag, this );
662 mesh_set_get_quadrangle_count( _surf_mesh, get_quadrangle_count, this );
663 mesh_set_get_quadrangle_vertices( _surf_mesh, get_quadrangle_vertices, this );
665 // Create a hybrid session
666 _session = hybrid_session_new( _context );
667 if ( !_session ) MG_Error( "unable to create a new hybrid session");
669 ret = hybrid_set_interrupt_callback( _session, my_interrupt_callback, this );
670 if ( ret != STATUS_OK ) MG_Error("in hybrid_set_interrupt_callback");
674 bool MG_HYBRID_API::LibData::Compute()
677 status_t ret = hybrid_set_surface_mesh( _session, _surf_mesh );
678 if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh");
682 if ( !_nodeSize.empty() )
684 _sizemap = meshgems_sizemap_new( _surf_mesh, meshgems_sizemap_type_iso_mesh_vertex,
685 (void*) &get_vertex_weight, this );
686 if ( !_sizemap ) MG_Error("unable to create a new sizemap");
688 ret = hybrid_set_sizemap( _session, _sizemap );
689 if ( ret != STATUS_OK ) MG_Error( "unable to set sizemap");
693 //////////////////////////////////////////////////////////////////////////////////////////
694 // const char* file = "/tmp/ghs3d_IN.mesh";
695 // mesh_write_mesh( _surf_mesh,file);
696 // std::cout << std::endl << std::endl << "Write " << file << std::endl << std::endl << std::endl;
698 ret = hybrid_compute_mesh( _session );
699 if ( ret != STATUS_OK ) return false;
701 ret = hybrid_get_mesh( _session, &_hybrid_mesh);
702 if (ret != STATUS_OK) MG_Error( "unable to get resulting mesh");
704 //////////////////////////////////////////////////////////////////////////////////////////
705 // file = "/tmp/ghs3d_OUT.mesh";
706 // mesh_write_mesh( _hybrid_mesh,file);
707 // std::cout << std::endl << std::endl << "Write " << file << std::endl << std::endl << std::endl;
713 #endif // ifdef USE_MG_LIBS
716 //================================================================================
720 //================================================================================
722 MG_HYBRID_API::MG_HYBRID_API(volatile bool& cancelled_flag, double& progress)
727 _libData = new LibData( cancelled_flag, progress );
729 if ( getenv("MG_HYBRID_USE_EXE"))
734 //================================================================================
738 //================================================================================
740 MG_HYBRID_API::~MG_HYBRID_API()
746 std::set<int>::iterator id = _openFiles.begin();
747 for ( ; id != _openFiles.end(); ++id )
748 ::GmfCloseMesh( *id );
752 //================================================================================
754 * \brief Return the way of MG usage
756 //================================================================================
758 bool MG_HYBRID_API::IsLibrary()
763 //================================================================================
765 * \brief Switch to usage of MG-HYBRID executable
767 //================================================================================
769 void MG_HYBRID_API::SetUseExecutable()
774 //================================================================================
776 * \brief Compute the hybrid mesh
777 * \param [in] cmdLine - a command to run mg_hybrid.exe
778 * \return bool - Ok or not
780 //================================================================================
782 bool MG_HYBRID_API::Compute( const std::string& cmdLine, std::string& errStr )
788 std::istringstream strm( cmdLine );
789 std::istream_iterator<std::string> sIt( strm ), sEnd;
790 std::vector< std::string > args( sIt, sEnd );
793 std::string param, value;
794 for ( size_t i = 1; i < args.size(); ++i )
796 // look for a param name; it starts from "-"
798 if ( param.size() < 2 || param[0] != '-')
800 while ( param[0] == '-')
801 param = param.substr( 1 );
804 while ( i+1 < args.size() && args[i+1][0] != '-' )
806 if ( strncmp( "1>", args[i+1].c_str(), 2 ) == 0 )
808 if ( !value.empty() ) value += " ";
811 if ( !_libData->SetParam( param, value ))
812 std::cout << "Warning: wrong param: '" << param <<"' = '" << value << "'" << std::endl;
816 bool ok = _libData->Compute();
818 GetLog(); // write a log file
819 _logFile = ""; // not to write it again
825 int err = system( cmdLine.c_str() ); // run
828 errStr = SMESH_Comment("system(mg-hybrid.exe ...) command failed with error: ")
829 << strerror( errno );
835 //================================================================================
837 * \brief Prepare for reading a mesh data
839 //================================================================================
841 int MG_HYBRID_API::GmfOpenMesh(const char* theFile, int rdOrWr, int * ver, int * dim)
848 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim );
849 _openFiles.insert( id );
853 //================================================================================
855 * \brief Return nb of entities
857 //================================================================================
859 int MG_HYBRID_API::GmfStatKwd( int iMesh, GmfKwdCod what )
865 case GmfSubDomainFromGeom: return _libData->ReadNbSubDomains();
866 case GmfVertices: return _libData->ReadNbNodes();
867 case GmfEdges: return _libData->ReadNbEdges();
868 case GmfTriangles: return _libData->ReadNbTria();
869 case GmfQuadrilaterals: return _libData->ReadNbQuads();
870 case GmfTetrahedra: return _libData->ReadNbTetra();
871 case GmfPrisms: return _libData->ReadNbPrisms();
872 case GmfHexahedra: return _libData->ReadNbHexa();
873 case GmfCorners: return _libData->ReadNbCorners();
879 return ::GmfStatKwd( iMesh, what );
882 //================================================================================
884 * \brief Prepare for reading some data
886 //================================================================================
888 void MG_HYBRID_API::GmfGotoKwd( int iMesh, GmfKwdCod what )
892 _libData->ResetCounter();
896 ::GmfGotoKwd( iMesh, what );
899 //================================================================================
901 * \brief Return index of a domain identified by a triangle normal
902 * \param [in] iMesh - mesh file index
903 * \param [in] what - must be GmfSubDomainFromGeom
904 * \param [out] nbNodes - nb nodes in a face
905 * \param [out] faceInd - face index
906 * \param [out] ori - face orientation
907 * \param [out] domain - domain index
908 * \param [in] dummy - an artificial param used to discriminate from GmfGetLin() reading
911 //================================================================================
913 void MG_HYBRID_API::GmfGetLin( int iMesh, GmfKwdCod what, int* nbNodes, int* faceInd, int* ori, int* domain, int dummy )
917 _libData->ReadSubDomain( nbNodes, faceInd, ori, domain );
921 ::GmfGetLin( iMesh, what, nbNodes, faceInd, ori, domain );
924 //================================================================================
926 * \brief Return coordinates of a next node
928 //================================================================================
930 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what,
931 double* x, double* y, double *z, int* domain )
935 _libData->ReadNodeXYZ( x, y, z, domain );
939 ::GmfGetLin(iMesh, what, x, y, z, domain );
942 //================================================================================
944 * \brief Return coordinates of a next node
946 //================================================================================
948 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what,
949 float* x, float* y, float *z, int* domain )
954 _libData->ReadNodeXYZ( &X, &Y, &Z, domain );
961 ::GmfGetLin(iMesh, what, x, y, z, domain );
964 //================================================================================
966 * \brief Return node index of a next corner
968 //================================================================================
970 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node )
974 _libData->ReadCorner( node );
978 ::GmfGetLin(iMesh, what, node );
981 //================================================================================
983 * \brief Return node indices of a next edge
985 //================================================================================
987 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node1, int* node2, int* domain )
991 _libData->ReadEdgeNodes( node1, node2, domain );
995 ::GmfGetLin( iMesh, what, node1, node2, domain );
998 //================================================================================
1000 * \brief Return node indices of a next triangle
1002 //================================================================================
1004 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what,
1005 int* node1, int* node2, int* node3, int* domain )
1009 _libData->ReadTriaNodes( node1, node2, node3, domain );
1013 ::GmfGetLin(iMesh, what, node1, node2, node3, domain );
1016 //================================================================================
1018 * \brief Return node indices of a next tetrahedron or quadrangle
1020 //================================================================================
1022 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what,
1023 int* node1, int* node2, int* node3, int* node4, int* domain )
1027 if ( what == GmfQuadrilaterals )
1028 _libData->ReadQuadNodes( node1, node2, node3, node4, domain );
1030 _libData->ReadTetraNodes( node1, node2, node3, node4, domain );
1034 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, domain );
1037 //================================================================================
1039 * \brief Return node indices of a next hexahedron
1041 //================================================================================
1043 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what,
1044 int* node1, int* node2, int* node3, int* node4,
1045 int* node5, int* node6, int* node7, int* node8,
1050 _libData->ReadHexaNodes( node1, node2, node3, node4, node5, node6, node7, node8, domain );
1054 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, node5, node6, node7, node8, domain );
1057 //================================================================================
1059 * \brief Return node indices of a next pyramid
1061 //================================================================================
1063 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what,
1064 int* node1, int* node2, int* node3, int* node4,
1065 int* node5, int* domain )
1069 _libData->ReadPyramidNodes( node1, node2, node3, node4, node5, domain );
1073 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, node5, domain );
1076 //================================================================================
1078 * \brief Return node indices of a next prism
1080 //================================================================================
1082 void MG_HYBRID_API::GmfGetLin(int iMesh, GmfKwdCod what,
1083 int* node1, int* node2, int* node3, int* node4,
1084 int* node5, int* node6, int* domain )
1088 _libData->ReadPrismNodes( node1, node2, node3, node4, node5, node6, domain );
1092 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, node5, node6, domain );
1095 //================================================================================
1097 * \brief Prepare for passing data to MeshGems
1099 //================================================================================
1101 int MG_HYBRID_API::GmfOpenMesh(const char* theFile, int rdOrWr, int ver, int dim)
1108 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim);
1109 _openFiles.insert( id );
1113 //================================================================================
1115 * \brief Set number of entities
1117 //================================================================================
1119 void MG_HYBRID_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb )
1124 case GmfVertices: _libData->SetNbVertices( nb ); break;
1125 case GmfEdges: _libData->SetNbEdges ( nb ); break;
1126 case GmfRequiredEdges: _libData->SetNbReqEdges( nb ); break;
1127 case GmfTriangles: _libData->SetNbTria ( nb ); break;
1128 case GmfRequiredTriangles: _libData->SetNbReqTria ( nb ); break;
1134 ::GmfSetKwd(iMesh, what, nb );
1137 //================================================================================
1139 * \brief Add coordinates of a node
1141 //================================================================================
1143 void MG_HYBRID_API::GmfSetLin(int iMesh, GmfKwdCod what, double x, double y, double z, int domain)
1147 _libData->AddNode( x, y, z, domain );
1151 ::GmfSetLin(iMesh, what, x, y, z, domain);
1154 //================================================================================
1156 * \brief Set number of field entities
1157 * \param [in] iMesh - solution file index
1158 * \param [in] what - solution type
1159 * \param [in] nbNodes - nb of entities
1160 * \param [in] nbTypes - nb of data entries in each entity
1161 * \param [in] type - types of the data entries
1163 * Used to prepare to storing size at nodes
1165 //================================================================================
1167 void MG_HYBRID_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nbNodes, int dummy, int type[] )
1171 if ( what == GmfSolAtVertices ) _libData->SetNbReqVertices( nbNodes );
1175 ::GmfSetKwd(iMesh, what, nbNodes, dummy, type );
1178 //================================================================================
1180 * \brief Add solution data
1182 //================================================================================
1184 void MG_HYBRID_API::GmfSetLin(int iMesh, GmfKwdCod what, double vals[])
1188 _libData->AddSizeAtNode( vals[0] );
1192 ::GmfSetLin(iMesh, what, vals);
1195 //================================================================================
1197 * \brief Add edge nodes
1199 //================================================================================
1201 void MG_HYBRID_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int domain )
1205 _libData->AddEdgeNodes( node1, node2, domain );
1209 ::GmfSetLin(iMesh, what, node1, node2, domain );
1212 //================================================================================
1214 * \brief Add a 'required' flag
1216 //================================================================================
1218 void MG_HYBRID_API::GmfSetLin(int iMesh, GmfKwdCod what, int id )
1225 ::GmfSetLin(iMesh, what, id );
1228 //================================================================================
1230 * \brief Add triangle nodes
1232 //================================================================================
1234 void MG_HYBRID_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int node3, int domain )
1238 _libData->AddTriaNodes( node1, node2, node3, domain );
1242 ::GmfSetLin(iMesh, what, node1, node2, node3, domain );
1245 //================================================================================
1247 * \brief Add quadrangle nodes
1249 //================================================================================
1251 void MG_HYBRID_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int node3, int node4, int domain )
1255 _libData->AddQuadNodes( node1, node2, node3, node4 );
1259 ::GmfSetLin(iMesh, what, node1, node2, node3, node4, domain );
1262 //================================================================================
1264 * \brief Close a file
1266 //================================================================================
1268 void MG_HYBRID_API::GmfCloseMesh( int iMesh )
1275 ::GmfCloseMesh( iMesh );
1276 _openFiles.erase( iMesh );
1279 //================================================================================
1281 * \brief Return true if the log is not empty
1283 //================================================================================
1285 bool MG_HYBRID_API::HasLog()
1289 return !_libData->GetErrors().empty();
1292 SMESH_File file( _logFile );
1293 return file.size() > 0;
1296 //================================================================================
1298 * \brief Return log contents
1300 //================================================================================
1302 std::string MG_HYBRID_API::GetLog()
1306 const std::string& err = _libData->GetErrors();
1307 if ( !_logFile.empty() && !err.empty() )
1309 SMESH_File file( _logFile, /*openForReading=*/false );
1310 file.openForWriting();
1311 file.write( err.c_str(), err.size() );
1316 SMESH_File file( _logFile );
1317 return file.getPos();