X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Measurements_i.cxx;h=e6e5493fa14de37ac35ec6d9a981ff395eee220d;hp=ca0103c016e6cb9994a8eb21f1d0ef7c35dcb8cf;hb=2644464cc22b6d71605053f340fdab2ed976f969;hpb=7a3ecab720cc517ace17c5c4677fd3c20c0051ee diff --git a/src/SMESH_I/SMESH_Measurements_i.cxx b/src/SMESH_I/SMESH_Measurements_i.cxx index ca0103c01..e6e5493fa 100644 --- a/src/SMESH_I/SMESH_Measurements_i.cxx +++ b/src/SMESH_I/SMESH_Measurements_i.cxx @@ -38,6 +38,7 @@ #include "SMESH_MeshAlgos.hxx" #include "SMESH_PythonDump.hxx" +#include using namespace SMESH; @@ -255,16 +256,13 @@ static void enlargeBoundingBox(const SMESH::SMESH_IDSource_ptr theObject, enlargeBoundingBox( aMesh->FindNode( aElementsId[i] ), theMeasure); else { - const SMDS_MeshElement* elem = aMesh->FindElement( aElementsId[i] ); - if (!elem) - continue; - SMDS_ElemIteratorPtr aNodeIter = elem->nodesIterator(); - while( aNodeIter->more() ) - enlargeBoundingBox( dynamic_cast( aNodeIter->next() ), theMeasure); + if ( const SMDS_MeshElement* elem = aMesh->FindElement( aElementsId[i] )) + for (SMDS_NodeIteratorPtr aNodeIter = elem->nodeIterator(); aNodeIter->more(); ) + enlargeBoundingBox( aNodeIter->next(), theMeasure); } } } - + //======================================================================= // name : BoundingBox // Purpose : compute common bounding box of entities @@ -349,3 +347,30 @@ SMESH::PointStruct Measurements_i::GravityCenter(SMESH::SMESH_IDSource_ptr theSo return grCenter; } + +//======================================================================= +//function : Angle +//purpose : Return angle in radians defined by 3 points <(p1,p2,p3) +//======================================================================= + +CORBA::Double Measurements_i::Angle(const SMESH::PointStruct& p1, + const SMESH::PointStruct& p2, + const SMESH::PointStruct& p3 ) +{ + gp_Vec v1( p1.x - p2.x, p1.y - p2.y, p1.z - p2.z ); + gp_Vec v2( p3.x - p2.x, p3.y - p2.y, p3.z - p2.z ); + + double angle = -1; + + try + { + angle = v1.Angle( v2 ); + } + catch(...) + { + } + if ( std::isnan( angle )) + angle = -1; + + return angle; +}