X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_RadialPrism_3D.cxx;h=cc1b4f89e4be741559018d6601ecad5745423b9a;hb=42e8757bfcaefe3c43310a911ba62662265573db;hp=4564000325e6691c2f26480c41ea41f2cf06171f;hpb=9d11375af40826e967ab2c3bcb77d1f9d439c90c;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx b/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx index 456400032..cc1b4f89e 100644 --- a/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx +++ b/src/StdMeshers/StdMeshers_RadialPrism_3D.cxx @@ -45,18 +45,20 @@ #include "utilities.h" -#include -#include -#include -#include +#include #include +#include +#include +#include +#include +#include #include #include using namespace std; -#define RETURN_BAD_RESULT(msg) { MESSAGE(msg); return false; } +#define RETURN_BAD_RESULT(msg) { MESSAGE(")-: Error: " << msg); return false; } #define gpXYZ(n) gp_XYZ(n->X(),n->Y(),n->Z()) typedef StdMeshers_ProjectionUtils TAssocTool; @@ -97,13 +99,14 @@ bool StdMeshers_RadialPrism_3D::CheckHypothesis(SMESH_Mesh& SMESH_Hypothesis::Hypothesis_Status& aStatus) { // check aShape that must have 2 shells +/* PAL16229 if ( TAssocTool::Count( aShape, TopAbs_SOLID, 0 ) != 1 || TAssocTool::Count( aShape, TopAbs_SHELL, 0 ) != 2 ) { aStatus = HYP_BAD_GEOMETRY; return false; } - +*/ myNbLayerHypo = 0; myDistributionHypo = 0; @@ -166,7 +169,7 @@ bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& a if ( !outerShell.IsSame( It.Value() )) innerShell = It.Value(); if ( nbShells != 2 ) - RETURN_BAD_RESULT("Must be 2 shells"); + return error(COMPERR_BAD_SHAPE, SMESH_Comment("Must be 2 shells but not ")<ShapeToIndex( outFace )); + return error(SMESH_Comment("Corresponding inner face not found for face #" ) + << meshDS->ShapeToIndex( outFace )); } else { inFace = TopoDS::Face( shape2ShapeMap( outFace )); } @@ -200,9 +204,10 @@ bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& a TNodeNodeMap nodeIn2OutMap; if ( ! TAssocTool::FindMatchingNodesOnFaces( inFace, &aMesh, outFace, &aMesh, shape2ShapeMap, nodeIn2OutMap )) - RETURN_BAD_RESULT("Different mesh on corresponding out and in faces: " - << meshDS->ShapeToIndex( outFace ) << " and " - << meshDS->ShapeToIndex( inFace )); + return error(COMPERR_BAD_INPUT_MESH,SMESH_Comment("Mesh on faces #") + << meshDS->ShapeToIndex( outFace ) << " and " + << meshDS->ShapeToIndex( inFace ) << " seems different" ); + // Create volumes SMDS_ElemIteratorPtr faceIt = meshDS->MeshElements( inFace )->GetElements(); @@ -219,12 +224,18 @@ bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& a vector< const TNodeColumn* > columns( nbNodes ); for ( int i = 0; i < nbNodes; ++i ) { - const SMDS_MeshNode* n = face->GetNode( i ); - TNode2ColumnMap::iterator n_col = node2columnMap.find( n ); - if ( n_col != node2columnMap.end() ) + const SMDS_MeshNode* nIn = face->GetNode( i ); + TNode2ColumnMap::iterator n_col = node2columnMap.find( nIn ); + if ( n_col != node2columnMap.end() ) { columns[ i ] = & n_col->second; - else - columns[ i ] = makeNodeColumn( node2columnMap, n, nodeIn2OutMap[ n ] ); + } + else { + TNodeNodeMap::iterator nInOut = nodeIn2OutMap.find( nIn ); + if ( nInOut == nodeIn2OutMap.end() ) + RETURN_BAD_RESULT("No matching node for "<< nIn->GetID() << + " in face "<< face->GetID()); + columns[ i ] = makeNodeColumn( node2columnMap, nIn, nInOut->second ); + } } StdMeshers_Prism_3D::AddPrisms( columns, myHelper ); @@ -251,9 +262,10 @@ TNodeColumn* StdMeshers_RadialPrism_3D::makeNodeColumn( TNode2ColumnMap& n2C SMESHDS_Mesh * meshDS = myHelper->GetMeshDS(); int shapeID = myHelper->GetSubShapeID(); - if ( myLayerPositions.empty() ) - computeLayerPositions( gpXYZ( inNode ), gpXYZ( outNode )); - + if ( myLayerPositions.empty() ) { + gp_Pnt pIn = gpXYZ( inNode ), pOut = gpXYZ( outNode ); + computeLayerPositions( pIn, pOut ); + } int nbSegments = myLayerPositions.size() + 1; TNode2ColumnMap::iterator n_col = @@ -286,7 +298,7 @@ TNodeColumn* StdMeshers_RadialPrism_3D::makeNodeColumn( TNode2ColumnMap& n2C //================================================================================ //================================================================================ -class TNodeDistributor: private StdMeshers_Regular_1D +class TNodeDistributor: public StdMeshers_Regular_1D { list myUsedHyps; public: @@ -308,22 +320,24 @@ public: const StdMeshers_LayerDistribution* hyp) { double len = pIn.Distance( pOut ); - if ( len <= DBL_MIN ) RETURN_BAD_RESULT("Bad points"); + if ( len <= DBL_MIN ) return error("Too close points of inner and outer shells"); if ( !hyp || !hyp->GetLayerDistribution() ) - RETURN_BAD_RESULT("Bad StdMeshers_LayerDistribution hypothesis"); + return error( "Invalid LayerDistribution hypothesis"); myUsedHyps.clear(); myUsedHyps.push_back( hyp->GetLayerDistribution() ); TopoDS_Edge edge = BRepBuilderAPI_MakeEdge( pIn, pOut ); - SMESH_Hypothesis::Hypothesis_Status aStatus; if ( !StdMeshers_Regular_1D::CheckHypothesis( aMesh, edge, aStatus )) - RETURN_BAD_RESULT("StdMeshers_Regular_1D::CheckHypothesis() failed with status "< params; - if ( !StdMeshers_Regular_1D::computeInternalParameters( edge, params, false )) - RETURN_BAD_RESULT("StdMeshers_Regular_1D::computeInternalParameters() failed"); + if ( !StdMeshers_Regular_1D::computeInternalParameters( C3D, len, f, l, params, false )) + return error("StdMeshers_Regular_1D failed to compute layers distribution"); positions.clear(); positions.reserve( params.size() ); @@ -353,7 +367,8 @@ protected: */ //================================================================================ -bool StdMeshers_RadialPrism_3D::computeLayerPositions(gp_Pnt pIn, gp_Pnt pOut) +bool StdMeshers_RadialPrism_3D::computeLayerPositions(const gp_Pnt& pIn, + const gp_Pnt& pOut) { if ( myNbLayerHypo ) { @@ -365,8 +380,12 @@ bool StdMeshers_RadialPrism_3D::computeLayerPositions(gp_Pnt pIn, gp_Pnt pOut) } if ( myDistributionHypo ) { SMESH_Mesh * mesh = myHelper->GetMesh(); - return TNodeDistributor::GetDistributor(*mesh)->Compute( myLayerPositions, pIn, pOut, - *mesh, myDistributionHypo ); + if ( !TNodeDistributor::GetDistributor(*mesh)->Compute( myLayerPositions, pIn, pOut, + *mesh, myDistributionHypo )) + { + error( TNodeDistributor::GetDistributor(*mesh)->GetComputeError() ); + return false; + } } - RETURN_BAD_RESULT("Bad hypothesis"); + RETURN_BAD_RESULT("Bad hypothesis"); }