X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Algo.cxx;h=184b003986580bf34917ae523a8866b461920145;hb=3cff0381cce57e73b053a2f0d455abc15fb89856;hp=f1d3fad659d984b9f8912471f98850eb5455503d;hpb=493747e8ea338a2d88204a5f12ba924d72ecbb5b;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index f1d3fad65..184b00398 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 @@ -18,6 +18,7 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// // SMESH SMESH : implementaion of SMESH idl descriptions // File : SMESH_Algo.cxx @@ -38,6 +39,7 @@ #include "SMESH_HypoFilter.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_TypeDefs.hxx" +#include "SMESH_subMesh.hxx" #include @@ -48,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -55,6 +58,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +84,7 @@ 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; } @@ -95,6 +99,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 @@ -500,13 +539,19 @@ 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 ); @@ -681,11 +726,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 //================================================================================ /*! @@ -747,6 +798,8 @@ void SMESH_Algo::InitComputeError() if ( (*elem)->GetID() < 1 ) delete *elem; _badInputElements.clear(); + + _computeCanceled = false; } //================================================================================ @@ -762,3 +815,38 @@ void SMESH_Algo::addBadInputElement(const SMDS_MeshElement* elem) if ( elem ) _badInputElements.push_back( elem ); } + +//============================================================================= +/*! + * + */ +//============================================================================= + +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; +} + +