2020-04-15 19:49:00 +05:00
|
|
|
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
|
2012-10-08 17:56:59 +06:00
|
|
|
//
|
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
2014-02-20 18:25:37 +06:00
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
2012-10-08 17:56:59 +06:00
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
|
|
|
//
|
|
|
|
// File : DriverGMF_Write.cxx
|
|
|
|
// Created : Mon Sep 17 17:03:02 2012
|
|
|
|
// Author : Edward AGAPOV (eap)
|
|
|
|
|
|
|
|
#include "DriverGMF_Write.hxx"
|
2012-12-13 17:41:29 +06:00
|
|
|
#include "DriverGMF.hxx"
|
2012-10-08 17:56:59 +06:00
|
|
|
|
|
|
|
#include "SMESHDS_GroupBase.hxx"
|
|
|
|
#include "SMESHDS_Mesh.hxx"
|
|
|
|
#include "SMESH_Comment.hxx"
|
|
|
|
|
2012-12-13 17:41:29 +06:00
|
|
|
#include <Basics_Utils.hxx>
|
|
|
|
|
2013-08-22 17:45:25 +06:00
|
|
|
#include "utilities.h"
|
|
|
|
|
2016-08-24 19:04:22 +05:00
|
|
|
using SMESHUtils::ControlPnt;
|
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include "libmesh5.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#define BEGIN_ELEM_WRITE( SMDSEntity, GmfKwd, elem ) \
|
2013-03-06 19:57:01 +06:00
|
|
|
elemIt = elementIterator( SMDSEntity ); \
|
2012-10-08 17:56:59 +06:00
|
|
|
if ( elemIt->more() ) \
|
|
|
|
{ \
|
2013-03-06 19:57:01 +06:00
|
|
|
GmfSetKwd(meshID, GmfKwd, myMesh->GetMeshInfo().NbElements( SMDSEntity )); \
|
2012-10-08 17:56:59 +06:00
|
|
|
for ( int gmfID = 1; elemIt->more(); ++gmfID ) \
|
|
|
|
{ \
|
|
|
|
const SMDS_MeshElement* elem = elemIt->next(); \
|
|
|
|
GmfSetLin(meshID, GmfKwd,
|
|
|
|
|
2013-03-06 19:57:01 +06:00
|
|
|
#define BEGIN_EXTRA_VERTICES_WRITE( SMDSGeom, LinType, GmfKwd, elem ) \
|
|
|
|
elemIt = elementIterator( SMDSGeom ); \
|
2013-02-28 21:07:35 +06:00
|
|
|
if ( elemIt->more() ) \
|
|
|
|
{ \
|
2013-03-06 19:57:01 +06:00
|
|
|
int totalNbElems = myMesh->GetMeshInfo().NbElements( SMDSGeom ); \
|
|
|
|
int nbLinearElems = myMesh->GetMeshInfo().NbElements( LinType ); \
|
|
|
|
if ( totalNbElems - nbLinearElems > 0 ) \
|
|
|
|
{ \
|
|
|
|
GmfSetKwd(meshID, GmfKwd, totalNbElems - nbLinearElems); \
|
2013-02-28 21:07:35 +06:00
|
|
|
for ( int gmfID = 1; elemIt->more(); ++gmfID ) \
|
|
|
|
{ \
|
|
|
|
const SMDS_MeshElement* elem = elemIt->next(); \
|
2013-03-06 19:57:01 +06:00
|
|
|
if ( elem->IsQuadratic() ) { \
|
|
|
|
GmfSetLin(meshID, GmfKwd, gmfID, elem->NbNodes() - elem->NbCornerNodes(),
|
2013-02-28 21:07:35 +06:00
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
#define END_ELEM_WRITE( elem ) \
|
|
|
|
elem->getshapeId() ); \
|
2013-03-06 19:57:01 +06:00
|
|
|
}}
|
2012-10-08 17:56:59 +06:00
|
|
|
|
2016-02-15 17:08:20 +05:00
|
|
|
#define END_ELEM_WRITE_ADD_TO_MAP( elem, e2id ) \
|
|
|
|
elem->getshapeId() ); \
|
|
|
|
e2id.insert( e2id.end(), std::make_pair( elem, gmfID )); \
|
2013-03-06 19:57:01 +06:00
|
|
|
}}
|
2012-10-08 17:56:59 +06:00
|
|
|
|
2013-02-28 21:07:35 +06:00
|
|
|
#define END_EXTRA_VERTICES_WRITE() \
|
|
|
|
); \
|
2013-03-06 19:57:01 +06:00
|
|
|
}}}}
|
2013-08-22 17:45:25 +06:00
|
|
|
|
2013-02-28 21:07:35 +06:00
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
DriverGMF_Write::DriverGMF_Write():
|
2012-12-13 17:41:29 +06:00
|
|
|
Driver_SMESHDS_Mesh(), _exportRequiredGroups( true )
|
2012-10-08 17:56:59 +06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
DriverGMF_Write::~DriverGMF_Write()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-02-28 21:07:35 +06:00
|
|
|
//================================================================================
|
|
|
|
/*!
|
|
|
|
* \brief Reads a GMF file
|
|
|
|
*/
|
|
|
|
//================================================================================
|
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
Driver_Mesh::Status DriverGMF_Write::Perform()
|
|
|
|
{
|
2012-12-13 17:41:29 +06:00
|
|
|
Kernel_Utils::Localizer loc;
|
|
|
|
|
2015-04-02 19:48:04 +05:00
|
|
|
const int dim = 3, version = sizeof(double) < 8 ? 1 : 2;
|
2012-10-08 17:56:59 +06:00
|
|
|
|
|
|
|
int meshID = GmfOpenMesh( myFile.c_str(), GmfWrite, version, dim );
|
|
|
|
if ( !meshID )
|
2012-12-13 17:41:29 +06:00
|
|
|
{
|
|
|
|
if ( DriverGMF::isExtensionCorrect( myFile ))
|
|
|
|
return addMessage( SMESH_Comment("Can't open for writing ") << myFile, /*fatal=*/true );
|
|
|
|
else
|
|
|
|
return addMessage( SMESH_Comment("Not '.mesh' or '.meshb' extension of file ") << myFile, /*fatal=*/true );
|
|
|
|
}
|
2012-10-08 17:56:59 +06:00
|
|
|
|
2012-12-13 17:41:29 +06:00
|
|
|
DriverGMF::MeshCloser aMeshCloser( meshID ); // An object closing GMF mesh at destruction
|
2012-10-08 17:56:59 +06:00
|
|
|
|
|
|
|
// nodes
|
|
|
|
std::map< const SMDS_MeshNode* , int > node2IdMap;
|
|
|
|
int iN = 0, nbNodes = myMesh->NbNodes();
|
|
|
|
GmfSetKwd( meshID, GmfVertices, nbNodes );
|
|
|
|
double xyz[3];
|
|
|
|
SMDS_NodeIteratorPtr nodeIt = myMesh->nodesIterator();
|
|
|
|
while ( nodeIt->more() )
|
|
|
|
{
|
|
|
|
const SMDS_MeshNode* n = nodeIt->next();
|
|
|
|
n->GetXYZ( xyz );
|
|
|
|
GmfSetLin( meshID, GmfVertices, xyz[0], xyz[1], xyz[2], n->getshapeId() );
|
2016-02-15 17:08:20 +05:00
|
|
|
node2IdMap.insert( node2IdMap.end(), std::make_pair( n, ++iN ));
|
2012-10-08 17:56:59 +06:00
|
|
|
}
|
|
|
|
if ( iN != nbNodes )
|
|
|
|
return addMessage("Wrong nb of nodes returned by nodesIterator", /*fatal=*/true);
|
|
|
|
|
|
|
|
|
|
|
|
SMDS_ElemIteratorPtr elemIt;
|
|
|
|
typedef std::map< const SMDS_MeshElement*, size_t, TIDCompare > TElem2IDMap;
|
|
|
|
|
|
|
|
// edges
|
|
|
|
TElem2IDMap edge2IDMap;
|
2013-03-06 19:57:01 +06:00
|
|
|
BEGIN_ELEM_WRITE( SMDSGeom_EDGE, GmfEdges, edge )
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ edge->GetNode( 0 )],
|
|
|
|
node2IdMap[ edge->GetNode( 1 )],
|
|
|
|
END_ELEM_WRITE_ADD_TO_MAP( edge, edge2IDMap );
|
2013-02-28 21:07:35 +06:00
|
|
|
|
2013-03-06 19:57:01 +06:00
|
|
|
// nodes of quadratic edges
|
|
|
|
BEGIN_EXTRA_VERTICES_WRITE( SMDSGeom_EDGE, SMDSEntity_Edge,
|
|
|
|
GmfExtraVerticesAtEdges, edge )
|
2013-02-28 21:07:35 +06:00
|
|
|
node2IdMap[ edge->GetNode( 2 )]
|
|
|
|
END_EXTRA_VERTICES_WRITE();
|
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
// triangles
|
|
|
|
TElem2IDMap tria2IDMap;
|
2013-03-06 19:57:01 +06:00
|
|
|
BEGIN_ELEM_WRITE( SMDSGeom_TRIANGLE, GmfTriangles, tria )
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ tria->GetNode( 0 )],
|
|
|
|
node2IdMap[ tria->GetNode( 1 )],
|
|
|
|
node2IdMap[ tria->GetNode( 2 )],
|
|
|
|
END_ELEM_WRITE_ADD_TO_MAP( tria, tria2IDMap );
|
2013-02-28 21:07:35 +06:00
|
|
|
|
2013-03-06 19:57:01 +06:00
|
|
|
// nodes of quadratic triangles
|
|
|
|
BEGIN_EXTRA_VERTICES_WRITE( SMDSGeom_TRIANGLE, SMDSEntity_Triangle,
|
|
|
|
GmfExtraVerticesAtTriangles, tria )
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ tria->GetNode( 3 )],
|
|
|
|
node2IdMap[ tria->GetNode( 4 )],
|
2013-05-16 22:38:48 +06:00
|
|
|
node2IdMap[ tria->GetNode( 5 )],
|
|
|
|
node2IdMap[ tria->GetNodeWrap( 6 )] // for TRIA7
|
2013-02-28 21:07:35 +06:00
|
|
|
END_EXTRA_VERTICES_WRITE();
|
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
// quadrangles
|
|
|
|
TElem2IDMap quad2IDMap;
|
2013-03-06 19:57:01 +06:00
|
|
|
BEGIN_ELEM_WRITE( SMDSGeom_QUADRANGLE, GmfQuadrilaterals, quad )
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ quad->GetNode( 0 )],
|
|
|
|
node2IdMap[ quad->GetNode( 1 )],
|
|
|
|
node2IdMap[ quad->GetNode( 2 )],
|
|
|
|
node2IdMap[ quad->GetNode( 3 )],
|
|
|
|
END_ELEM_WRITE_ADD_TO_MAP( quad, quad2IDMap );
|
|
|
|
|
2013-03-06 19:57:01 +06:00
|
|
|
// nodes of quadratic quadrangles
|
|
|
|
BEGIN_EXTRA_VERTICES_WRITE( SMDSGeom_QUADRANGLE, SMDSEntity_Quadrangle,
|
|
|
|
GmfExtraVerticesAtQuadrilaterals, quad )
|
2013-02-28 21:07:35 +06:00
|
|
|
node2IdMap[ quad->GetNode( 4 )],
|
|
|
|
node2IdMap[ quad->GetNode( 5 )],
|
|
|
|
node2IdMap[ quad->GetNode( 6 )],
|
|
|
|
node2IdMap[ quad->GetNode( 7 )],
|
2013-03-06 19:57:01 +06:00
|
|
|
node2IdMap[ quad->GetNodeWrap( 8 )] // for QUAD9
|
2013-02-28 21:07:35 +06:00
|
|
|
END_EXTRA_VERTICES_WRITE();
|
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
// terahedra
|
2013-03-06 19:57:01 +06:00
|
|
|
BEGIN_ELEM_WRITE( SMDSGeom_TETRA, GmfTetrahedra, tetra )
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ tetra->GetNode( 0 )],
|
|
|
|
node2IdMap[ tetra->GetNode( 2 )],
|
|
|
|
node2IdMap[ tetra->GetNode( 1 )],
|
|
|
|
node2IdMap[ tetra->GetNode( 3 )],
|
|
|
|
END_ELEM_WRITE( tetra );
|
2013-02-28 21:07:35 +06:00
|
|
|
|
2013-03-06 19:57:01 +06:00
|
|
|
// nodes of quadratic terahedra
|
|
|
|
BEGIN_EXTRA_VERTICES_WRITE( SMDSGeom_TETRA, SMDSEntity_Tetra,
|
|
|
|
GmfExtraVerticesAtTetrahedra, tetra )
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ tetra->GetNode( 6 )],
|
|
|
|
node2IdMap[ tetra->GetNode( 5 )],
|
|
|
|
node2IdMap[ tetra->GetNode( 4 )],
|
|
|
|
node2IdMap[ tetra->GetNode( 7 )],
|
|
|
|
node2IdMap[ tetra->GetNode( 9 )],
|
2013-02-28 21:07:35 +06:00
|
|
|
node2IdMap[ tetra->GetNode( 8 )]
|
2013-03-06 19:57:01 +06:00
|
|
|
//node2IdMap[ tetra->GetNodeWrap( 10 )], // for TETRA11
|
2013-02-28 21:07:35 +06:00
|
|
|
END_EXTRA_VERTICES_WRITE();
|
2013-03-06 19:57:01 +06:00
|
|
|
|
2012-10-08 17:56:59 +06:00
|
|
|
// pyramids
|
|
|
|
BEGIN_ELEM_WRITE( SMDSEntity_Pyramid, GmfPyramids, pyra )
|
2016-11-24 12:39:01 +05:00
|
|
|
node2IdMap[ pyra->GetNode( 3 )],
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ pyra->GetNode( 2 )],
|
|
|
|
node2IdMap[ pyra->GetNode( 1 )],
|
2016-11-24 12:39:01 +05:00
|
|
|
node2IdMap[ pyra->GetNode( 0 )],
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ pyra->GetNode( 4 )],
|
|
|
|
END_ELEM_WRITE( pyra );
|
|
|
|
|
|
|
|
// hexahedra
|
2013-03-06 19:57:01 +06:00
|
|
|
BEGIN_ELEM_WRITE( SMDSGeom_HEXA, GmfHexahedra, hexa )
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ hexa->GetNode( 0 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 3 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 2 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 1 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 4 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 7 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 6 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 5 )],
|
|
|
|
END_ELEM_WRITE( hexa );
|
|
|
|
|
2013-03-06 19:57:01 +06:00
|
|
|
// nodes of quadratic hexahedra
|
|
|
|
BEGIN_EXTRA_VERTICES_WRITE( SMDSGeom_HEXA, SMDSEntity_Hexa,
|
|
|
|
GmfExtraVerticesAtHexahedra, hexa )
|
|
|
|
node2IdMap[ hexa->GetNode( 11 )], // HEXA20
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ hexa->GetNode( 10 )],
|
2013-03-06 19:57:01 +06:00
|
|
|
node2IdMap[ hexa->GetNode( 9 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 8 )],
|
2013-02-28 21:07:35 +06:00
|
|
|
node2IdMap[ hexa->GetNode( 15 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 14 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 13 )],
|
2012-10-08 17:56:59 +06:00
|
|
|
node2IdMap[ hexa->GetNode( 12 )],
|
2013-02-28 21:07:35 +06:00
|
|
|
node2IdMap[ hexa->GetNode( 16 )],
|
|
|
|
node2IdMap[ hexa->GetNode( 19 )],
|
2013-03-06 19:57:01 +06:00
|
|
|
node2IdMap[ hexa->GetNodeWrap( 18 )], // + HEXA27
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 17 )],
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 20 )],
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 24 )],
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 23 )],
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 22 )],
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 21 )],
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 25 )],
|
|
|
|
node2IdMap[ hexa->GetNodeWrap( 26 )]
|
2013-02-28 21:07:35 +06:00
|
|
|
END_EXTRA_VERTICES_WRITE();
|
2012-10-08 17:56:59 +06:00
|
|
|
|
|
|
|
// prism
|
|
|
|
BEGIN_ELEM_WRITE( SMDSEntity_Penta, GmfPrisms, prism )
|
|
|
|
node2IdMap[ prism->GetNode( 0 )],
|
|
|
|
node2IdMap[ prism->GetNode( 2 )],
|
|
|
|
node2IdMap[ prism->GetNode( 1 )],
|
|
|
|
node2IdMap[ prism->GetNode( 3 )],
|
|
|
|
node2IdMap[ prism->GetNode( 5 )],
|
|
|
|
node2IdMap[ prism->GetNode( 4 )],
|
|
|
|
END_ELEM_WRITE( prism );
|
|
|
|
|
|
|
|
|
2012-12-13 17:41:29 +06:00
|
|
|
if ( _exportRequiredGroups )
|
2012-10-08 17:56:59 +06:00
|
|
|
{
|
2012-12-13 17:41:29 +06:00
|
|
|
// required entities
|
|
|
|
SMESH_Comment badGroups;
|
|
|
|
const std::set<SMESHDS_GroupBase*>& groupSet = myMesh->GetGroups();
|
|
|
|
std::set<SMESHDS_GroupBase*>::const_iterator grIt = groupSet.begin();
|
|
|
|
for ( ; grIt != groupSet.end(); ++grIt )
|
2012-10-08 17:56:59 +06:00
|
|
|
{
|
2012-12-13 17:41:29 +06:00
|
|
|
const SMESHDS_GroupBase* group = *grIt;
|
|
|
|
std::string groupName = group->GetStoreName();
|
|
|
|
std::string::size_type pos = groupName.find( "_required_" );
|
|
|
|
if ( pos == std::string::npos ) continue;
|
|
|
|
|
|
|
|
int gmfKwd;
|
|
|
|
SMDSAbs_EntityType smdsEntity;
|
|
|
|
std::string entity = groupName.substr( pos + strlen("_required_"));
|
|
|
|
if ( entity == "Vertices" ) {
|
2015-11-19 16:29:23 +05:00
|
|
|
gmfKwd = GmfRequiredVertices;
|
2012-12-13 17:41:29 +06:00
|
|
|
smdsEntity = SMDSEntity_Node;
|
2012-10-08 17:56:59 +06:00
|
|
|
}
|
2012-12-13 17:41:29 +06:00
|
|
|
else if ( entity == "Edges" ) {
|
2015-11-19 16:29:23 +05:00
|
|
|
gmfKwd = GmfRequiredEdges;
|
2012-12-13 17:41:29 +06:00
|
|
|
smdsEntity = SMDSEntity_Edge;
|
|
|
|
}
|
|
|
|
else if ( entity == "Triangles" ) {
|
2015-11-19 16:29:23 +05:00
|
|
|
gmfKwd = GmfRequiredTriangles;
|
2012-12-13 17:41:29 +06:00
|
|
|
smdsEntity = SMDSEntity_Triangle;
|
|
|
|
}
|
|
|
|
else if ( entity == "Quadrilaterals" ) {
|
2015-11-19 16:29:23 +05:00
|
|
|
gmfKwd = GmfRequiredQuadrilaterals;
|
2012-12-13 17:41:29 +06:00
|
|
|
smdsEntity = SMDSEntity_Quadrangle;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
addMessage( SMESH_Comment("Invalig gmf entity name: ") << entity, /*fatal=*/false );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check elem type in the group
|
|
|
|
int nbOkElems = 0;
|
|
|
|
SMDS_ElemIteratorPtr elemIt = group->GetElements();
|
|
|
|
while ( elemIt->more() )
|
|
|
|
nbOkElems += ( elemIt->next()->GetEntityType() == smdsEntity );
|
|
|
|
|
|
|
|
if ( nbOkElems != group->Extent() && nbOkElems == 0 )
|
2012-10-08 17:56:59 +06:00
|
|
|
{
|
2012-12-13 17:41:29 +06:00
|
|
|
badGroups << " " << groupName;
|
|
|
|
continue;
|
2012-10-08 17:56:59 +06:00
|
|
|
}
|
|
|
|
|
2012-12-13 17:41:29 +06:00
|
|
|
// choose a TElem2IDMap
|
|
|
|
TElem2IDMap* elem2IDMap = 0;
|
2015-11-19 16:29:23 +05:00
|
|
|
if ( smdsEntity == SMDSEntity_Quadrangle && nbOkElems != myMesh->NbFaces() )
|
2012-12-13 17:41:29 +06:00
|
|
|
elem2IDMap = & quad2IDMap;
|
|
|
|
else if ( smdsEntity == SMDSEntity_Triangle && nbOkElems != myMesh->NbFaces() )
|
|
|
|
elem2IDMap = & tria2IDMap;
|
2015-11-19 16:29:23 +05:00
|
|
|
else if ( smdsEntity == SMDSEntity_Edge && nbOkElems != myMesh->NbEdges() )
|
2012-12-13 17:41:29 +06:00
|
|
|
elem2IDMap = & edge2IDMap;
|
|
|
|
|
|
|
|
// write the group
|
|
|
|
GmfSetKwd( meshID, gmfKwd, nbOkElems );
|
|
|
|
elemIt = group->GetElements();
|
|
|
|
if ( elem2IDMap )
|
|
|
|
for ( ; elemIt->more(); )
|
|
|
|
{
|
|
|
|
const SMDS_MeshElement* elem = elemIt->next();
|
|
|
|
if ( elem->GetEntityType() == smdsEntity )
|
|
|
|
GmfSetLin( meshID, gmfKwd, (*elem2IDMap)[ elem ] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
for ( int gmfID = 1; elemIt->more(); ++gmfID)
|
|
|
|
{
|
|
|
|
const SMDS_MeshElement* elem = elemIt->next();
|
|
|
|
if ( elem->GetEntityType() == smdsEntity )
|
|
|
|
GmfSetLin( meshID, gmfKwd, gmfID );
|
|
|
|
}
|
2012-10-08 17:56:59 +06:00
|
|
|
|
2012-12-13 17:41:29 +06:00
|
|
|
} // loop on groups
|
|
|
|
|
|
|
|
if ( !badGroups.empty() )
|
|
|
|
addMessage( SMESH_Comment("Groups of elements of inappropriate geometry:")
|
|
|
|
<< badGroups, /*fatal=*/false );
|
|
|
|
}
|
2012-10-08 17:56:59 +06:00
|
|
|
|
|
|
|
return DRS_OK;
|
|
|
|
}
|
2013-03-06 19:57:01 +06:00
|
|
|
|
2016-08-24 19:04:22 +05:00
|
|
|
Driver_Mesh::Status DriverGMF_Write::PerformSizeMap( const std::vector<ControlPnt>& points )
|
2013-08-22 17:45:25 +06:00
|
|
|
{
|
|
|
|
// const int dim = 3, version = sizeof(long) == 4 ? 2 : 3;
|
|
|
|
const int dim = 3, version = 2; // Version 3 not supported by mg-hexa
|
|
|
|
|
|
|
|
// Open files
|
|
|
|
int verticesFileID = GmfOpenMesh( myVerticesFile.c_str(), GmfWrite, version, dim );
|
|
|
|
int solFileID = GmfOpenMesh( mySolFile.c_str(), GmfWrite, version, dim );
|
|
|
|
|
|
|
|
int pointsNumber = points.size();
|
|
|
|
|
|
|
|
// Vertices Keyword
|
|
|
|
GmfSetKwd( verticesFileID, GmfVertices, pointsNumber );
|
|
|
|
// SolAtVertices Keyword
|
|
|
|
int TypTab[] = {GmfSca};
|
|
|
|
GmfSetKwd(solFileID, GmfSolAtVertices, pointsNumber, 1, TypTab);
|
|
|
|
|
|
|
|
// Read the control points information from the vector and write it into the files
|
2016-08-24 19:04:22 +05:00
|
|
|
std::vector<ControlPnt>::const_iterator points_it;
|
2013-08-22 17:45:25 +06:00
|
|
|
for (points_it = points.begin(); points_it != points.end(); points_it++ )
|
|
|
|
{
|
|
|
|
GmfSetLin( verticesFileID, GmfVertices, points_it->X(), points_it->Y(), points_it->Z(), 0 );
|
|
|
|
double ValTab[] = {points_it->Size()};
|
|
|
|
GmfSetLin( solFileID, GmfSolAtVertices, ValTab);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close Files
|
|
|
|
GmfCloseMesh( verticesFileID );
|
|
|
|
GmfCloseMesh( solFileID );
|
2013-09-27 13:51:07 +06:00
|
|
|
|
|
|
|
return DRS_OK;
|
2013-08-22 17:45:25 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> DriverGMF_Write::GetSizeMapFiles()
|
|
|
|
{
|
|
|
|
std::vector<std::string> files;
|
|
|
|
files.push_back(myVerticesFile);
|
|
|
|
files.push_back(mySolFile);
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2013-03-06 19:57:01 +06:00
|
|
|
//================================================================================
|
|
|
|
/*!
|
|
|
|
* \brief Returns an iterator on elements of a certain type
|
|
|
|
*/
|
|
|
|
//================================================================================
|
|
|
|
|
|
|
|
SMDS_ElemIteratorPtr DriverGMF_Write::elementIterator(SMDSAbs_ElementType type)
|
|
|
|
{
|
|
|
|
return myMesh->elementsIterator(type);
|
|
|
|
}
|
|
|
|
SMDS_ElemIteratorPtr DriverGMF_Write::elementIterator(SMDSAbs_EntityType type)
|
|
|
|
{
|
|
|
|
return myMesh->elementEntityIterator(type);
|
|
|
|
}
|
|
|
|
SMDS_ElemIteratorPtr DriverGMF_Write::elementIterator(SMDSAbs_GeometryType type)
|
|
|
|
{
|
|
|
|
return myMesh->elementGeomIterator(type);
|
|
|
|
}
|