X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Projection_3D.cxx;h=5c6e5d01492c890e9b36f7cee05962cdea51c2f6;hb=HEAD;hp=ed22742f75124308d1ad897b30ce204fee884a11;hpb=f5016d85b7b4b88623723027a1585c6414c4dc66;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_Projection_3D.cxx b/src/StdMeshers/StdMeshers_Projection_3D.cxx index ed22742f7..5c6e5d014 100644 --- a/src/StdMeshers/StdMeshers_Projection_3D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_3D.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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 -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SMESH SMESH : implementaion of SMESH idl descriptions +// SMESH SMESH : implementation of SMESH idl descriptions // File : StdMeshers_Projection_3D.cxx // Module : SMESH // Created : Fri Oct 20 11:37:07 2006 @@ -31,9 +31,9 @@ #include "StdMeshers_ProjectionUtils.hxx" -#include "SMDS_PolyhedralVolumeOfNodes.hxx" #include "SMDS_VolumeTool.hxx" #include "SMESHDS_Hypothesis.hxx" +#include "SMESHDS_Mesh.hxx" #include "SMESHDS_SubMesh.hxx" #include "SMESH_Block.hxx" #include "SMESH_Comment.hxx" @@ -52,21 +52,20 @@ #define RETURN_BAD_RESULT(msg) { MESSAGE(")-: Error: " << msg); return false; } #define gpXYZ(n) gp_XYZ(n->X(),n->Y(),n->Z()) -#define SHOWYXZ(msg, xyz) // {\ -// gp_Pnt p (xyz); \ -// cout << msg << " ("<< p.X() << "; " <GetSubMesh( _sourceHypo->GetSource3DShape() ); //SMESH_subMesh* tgtSubMesh = tgtMesh->GetSubMesh( aShape ); - if ( tgtMesh == srcMesh && !aShape.IsSame( _sourceHypo->GetSource3DShape() )) { + string srcMeshError; + if ( tgtMesh == srcMesh && !aShape.IsSame( _sourceHypo->GetSource3DShape() )) { if ( !TAssocTool::MakeComputed( srcSubMesh )) - return error(COMPERR_BAD_INPUT_MESH,"Source mesh not computed"); + srcMeshError = TAssocTool::SourceNotComputedError( srcSubMesh, this ); } else { if ( !srcSubMesh->IsMeshComputed() ) - return error(COMPERR_BAD_INPUT_MESH,"Source mesh not computed"); + srcMeshError = TAssocTool::SourceNotComputedError(); } // Find 2 pairs of corresponding vertices @@ -294,7 +294,7 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS shape2ShapeMap.Clear(); vector< int > edgeIdVec; SMESH_Block::GetFaceEdgesIDs( fId, edgeIdVec ); - for ( int i = 0; i < edgeIdVec.size(); ++i ) { + for ( size_t i = 0; i < edgeIdVec.size(); ++i ) { int eID = edgeIdVec[ i ]; shape2ShapeMap.Bind( scrShapes( eID ), tgtShapes( eID )); if ( i < 2 ) { @@ -306,7 +306,7 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS } } // Find matching nodes of tgt and src faces - TNodeNodeMap faceMatchingNodes; + TAssocTool::TNodeNodeMap faceMatchingNodes; if ( ! TAssocTool::FindMatchingNodesOnFaces( srcFace, srcMesh, tgtFace, tgtMesh, shape2ShapeMap, faceMatchingNodes )) return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #") @@ -407,8 +407,7 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS nodes[6], nodes[7], id, force3d); break; default: // polyhedron - const SMDS_VtkVolume * poly = - dynamic_cast( srcVol ); + const SMDS_MeshVolume * poly = tgtMeshDS->DownCast( srcVol ); if ( !poly ) RETURN_BAD_RESULT("Unexpected volume type"); if ( !poly->IsPoly()) @@ -459,13 +458,13 @@ bool StdMeshers_Projection_3D::Evaluate(SMESH_Mesh& aMesh, SMESH_Comment("Target shape must have 1 shell but not ") << nbShell); // Check that shapes are blocks - if ( TAssocTool::Count( tgtShell, TopAbs_FACE , 1 ) != 6 || - TAssocTool::Count( tgtShell, TopAbs_EDGE , 1 ) != 12 || - TAssocTool::Count( tgtShell, TopAbs_WIRE , 1 ) != 6 ) + if ( SMESH_MesherHelper::Count( tgtShell, TopAbs_FACE , 1 ) != 6 || + SMESH_MesherHelper::Count( tgtShell, TopAbs_EDGE , 1 ) != 12 || + SMESH_MesherHelper::Count( tgtShell, TopAbs_WIRE , 1 ) != 6 ) return error(COMPERR_BAD_SHAPE, "Target shape is not a block"); - if ( TAssocTool::Count( srcShell, TopAbs_FACE , 1 ) != 6 || - TAssocTool::Count( srcShell, TopAbs_EDGE , 1 ) != 12 || - TAssocTool::Count( srcShell, TopAbs_WIRE , 1 ) != 6 ) + if ( SMESH_MesherHelper::Count( srcShell, TopAbs_FACE , 1 ) != 6 || + SMESH_MesherHelper::Count( srcShell, TopAbs_EDGE , 1 ) != 12 || + SMESH_MesherHelper::Count( srcShell, TopAbs_WIRE , 1 ) != 6 ) return error(COMPERR_BAD_SHAPE, "Source shape is not a block"); // Assure that mesh on a source shape is computed @@ -476,7 +475,7 @@ bool StdMeshers_Projection_3D::Evaluate(SMESH_Mesh& aMesh, return error(COMPERR_BAD_INPUT_MESH,"Source mesh not computed"); - std::vector aVec(SMDSEntity_Last); + std::vector aVec(SMDSEntity_Last); for(int i=SMDSEntity_Node; iGetSubMeshDS()->NbNodes(); @@ -540,3 +539,39 @@ void StdMeshers_Projection_3D::SetEventListener(SMESH_subMesh* subMesh) _sourceHypo->GetSourceMesh() ); } +//================================================================================ +/*! + * \brief Return true if the algorithm can mesh this shape + * \param [in] aShape - shape to check + * \param [in] toCheckAll - if true, this check returns OK if all shapes are OK, + * else, returns OK if at least one shape is OK + */ +//================================================================================ + +bool StdMeshers_Projection_3D::IsApplicable(const TopoDS_Shape & aShape, bool toCheckAll) +{ + TopExp_Explorer exp0( aShape, TopAbs_SOLID ); + if ( !exp0.More() ) return false; + + TopTools_IndexedMapOfOrientedShape blockShapes; + TopoDS_Vertex v; + TopoDS_Shell shell; + for ( ; exp0.More(); exp0.Next() ) + { + int nbFoundShells = 0; + TopExp_Explorer exp1( exp0.Current(), TopAbs_SHELL ); + for ( ; exp1.More(); exp1.Next(), ++nbFoundShells ) + { + shell = TopoDS::Shell( exp1.Current() ); + if ( nbFoundShells == 2 ) break; + } + if ( nbFoundShells != 1 ) { + if ( toCheckAll ) return false; + continue; + } + bool isBlock = SMESH_Block::FindBlockShapes( shell, v, v, blockShapes ); + if ( toCheckAll && !isBlock ) return false; + if ( !toCheckAll && isBlock ) return true; + } + return toCheckAll; +}