X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FSMESH%2FSMESH_Algo.cxx;h=ac294864b2a4bf35362f1a99e99488ea3ff33d17;hb=20c126bc220757c06b5576f71ed6f34ae85e3e40;hp=e509dd1b9fbe52afabc4d779c685b967b413d1ae;hpb=91c92cb54310225231438b4d3bafeb0d1643a7c0;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index e509dd1b9..ac294864b 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -24,7 +24,7 @@ // File : SMESH_Algo.cxx // Author : Paul RASCLE, EDF // Module : SMESH -// + #include "SMESH_Algo.hxx" #include "SMDS_EdgePosition.hxx" @@ -39,6 +39,9 @@ #include "SMESH_HypoFilter.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_TypeDefs.hxx" +#include "SMESH_subMesh.hxx" + +#include #include #include @@ -47,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -79,9 +84,11 @@ SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen) { gen->_mapAlgo[hypId] = this; - _onlyUnaryInput = _requireDescretBoundary = _requireShape = true; + _onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true; _quadraticMesh = _supportSubmeshes = false; _error = COMPERR_OK; + for ( int i = 0; i < 4; ++i ) + _neededLowerHyps[ i ] = false; } //============================================================================= @@ -94,6 +101,41 @@ SMESH_Algo::~SMESH_Algo() { } +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_0D_Algo::SMESH_0D_Algo(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Algo(hypId, studyId, gen) +{ + _shapeType = (1 << TopAbs_VERTEX); + _type = ALGO_0D; + gen->_map0D_Algo[hypId] = this; +} +SMESH_1D_Algo::SMESH_1D_Algo(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Algo(hypId, studyId, gen) +{ + _shapeType = (1 << TopAbs_EDGE); + _type = ALGO_1D; + gen->_map1D_Algo[hypId] = this; +} +SMESH_2D_Algo::SMESH_2D_Algo(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Algo(hypId, studyId, gen) +{ + _shapeType = (1 << TopAbs_FACE); + _type = ALGO_2D; + gen->_map2D_Algo[hypId] = this; +} +SMESH_3D_Algo::SMESH_3D_Algo(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Algo(hypId, studyId, gen) +{ + _shapeType = (1 << TopAbs_SOLID); + _type = ALGO_3D; + gen->_map3D_Algo[hypId] = this; +} + //============================================================================= /*! * Usually an algoritm has nothing to save @@ -307,7 +349,14 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace, // face normal at node position TopLoc_Location loc; Handle(Geom_Surface) surf = BRep_Tool::Surface( theFace, loc ); - if ( surf.IsNull() || surf->Continuity() < GeomAbs_C1 ) return isReversed; + // if ( surf.IsNull() || surf->Continuity() < GeomAbs_C1 ) + // some surfaces not detected as GeomAbs_C1 are nevertheless correct for meshing + if ( surf.IsNull() || surf->Continuity() < GeomAbs_C0 ) + { + if (!surf.IsNull()) + MESSAGE("surf->Continuity() < GeomAbs_C1 " << (surf->Continuity() < GeomAbs_C1)); + return isReversed; + } gp_Vec d1u, d1v; surf->D1( u, v, nPnt[0], d1u, d1v ); gp_Vec Nf = (d1u ^ d1v).Transformed( loc ); @@ -437,7 +486,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM return false; const SMDS_EdgePosition* epos = static_cast(node->GetPosition()); - theNodes.insert( make_pair( epos->GetUParameter(), node )); + theNodes.insert( theNodes.end(), make_pair( epos->GetUParameter(), node )); //MESSAGE("U " << epos->GetUParameter() << " ID " << node->GetID()); ++nbNodes; } @@ -499,20 +548,26 @@ GeomAbs_Shape SMESH_Algo::Continuity(TopoDS_Edge E1, { //E1.Orientation(TopAbs_FORWARD), E2.Orientation(TopAbs_FORWARD); // avoid pb with internal edges if (E1.Orientation() > TopAbs_REVERSED) // INTERNAL - E1.Orientation( TopAbs_FORWARD ); + E1.Orientation( TopAbs_FORWARD ); if (E2.Orientation() > TopAbs_REVERSED) // INTERNAL - E2.Orientation( TopAbs_FORWARD ); - TopoDS_Vertex V = TopExp::LastVertex (E1, true); - if ( !V.IsSame( TopExp::FirstVertex(E2, true ))) - if ( !TopExp::CommonVertex( E1, E2, V )) - return GeomAbs_C0; + E2.Orientation( TopAbs_FORWARD ); + + TopoDS_Vertex V, VV1[2], VV2[2]; + TopExp::Vertices( E1, VV1[0], VV1[1], true ); + TopExp::Vertices( E2, VV2[0], VV2[1], true ); + if ( VV1[1].IsSame( VV2[0] )) { V = VV1[1]; } + else if ( VV1[0].IsSame( VV2[1] )) { V = VV1[0]; } + else if ( VV1[1].IsSame( VV2[1] )) { V = VV1[1]; E1.Reverse(); } + else if ( VV1[0].IsSame( VV2[0] )) { V = VV1[0]; E1.Reverse(); } + else { return GeomAbs_C0; } + Standard_Real u1 = BRep_Tool::Parameter( V, E1 ); Standard_Real u2 = BRep_Tool::Parameter( V, E2 ); BRepAdaptor_Curve C1( E1 ), C2( E2 ); Standard_Real tol = BRep_Tool::Tolerance( V ); Standard_Real angTol = 2e-3; try { -#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100 +#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; #endif return BRepLProp::Continuity(C1, C2, u1, u2, tol, angTol); @@ -680,11 +735,17 @@ bool SMESH_Algo::Compute(SMESH_Mesh & /*aMesh*/, SMESH_MesherHelper* /*aHelper*/ return error( COMPERR_BAD_INPUT_MESH, "Mesh built on shape expected"); } -#ifdef WITH_SMESH_CANCEL_COMPUTE +//======================================================================= +//function : CancelCompute +//purpose : Sets _computeCanceled to true. It's usage depends on +// * implementation of a particular mesher. +//======================================================================= + void SMESH_Algo::CancelCompute() { + _computeCanceled = true; + _error = COMPERR_CANCELED; } -#endif //================================================================================ /*! @@ -746,6 +807,8 @@ void SMESH_Algo::InitComputeError() if ( (*elem)->GetID() < 1 ) delete *elem; _badInputElements.clear(); + + _computeCanceled = false; } //================================================================================ @@ -761,3 +824,61 @@ void SMESH_Algo::addBadInputElement(const SMDS_MeshElement* elem) if ( elem ) _badInputElements.push_back( elem ); } + +//======================================================================= +//function : addBadInputElements +//purpose : store a bad input elements or nodes preventing computation +//======================================================================= + +void SMESH_Algo::addBadInputElements(const SMESHDS_SubMesh* sm, + const bool addNodes) +{ + if ( sm ) + { + if ( addNodes ) + { + SMDS_NodeIteratorPtr nIt = sm->GetNodes(); + while ( nIt->more() ) addBadInputElement( nIt->next() ); + } + else + { + SMDS_ElemIteratorPtr eIt = sm->GetElements(); + while ( eIt->more() ) addBadInputElement( eIt->next() ); + } + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +// int SMESH_Algo::NumberOfWires(const TopoDS_Shape& S) +// { +// int i = 0; +// for (TopExp_Explorer exp(S,TopAbs_WIRE); exp.More(); exp.Next()) +// i++; +// return i; +// } + +//============================================================================= +/*! + * + */ +//============================================================================= + +int SMESH_Algo::NumberOfPoints(SMESH_Mesh& aMesh, const TopoDS_Wire& W) +{ + int nbPoints = 0; + for (TopExp_Explorer exp(W,TopAbs_EDGE); exp.More(); exp.Next()) { + const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); + int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + if(_quadraticMesh) + nb = nb/2; + nbPoints += nb + 1; // internal points plus 1 vertex of 2 (last point ?) + } + return nbPoints; +} + +