Back to index

salome-smesh  6.5.0
Functions
SMESH_Measurements_i.cxx File Reference
#include "SMESH_Measurements_i.hxx"
#include "SMESH_Gen_i.hxx"
#include "SMESH_PythonDump.hxx"
#include "SMDS_Mesh.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_MeshElement.hxx"
#include "SMDS_ElemIterator.hxx"
#include "SMESHDS_Mesh.hxx"

Go to the source code of this file.

Functions

static void initMeasure (SMESH::Measure &theMeasure)
 this local function to avoid uninitialized fields
static bool getNodeNodeDistance (SMESH::Measure &theMeasure, const SMDS_MeshNode *theNode1, const SMDS_MeshNode *theNode2=0)
static SMESHDS_Mesh * getMesh (SMESH::SMESH_IDSource_ptr theSource)
static bool isNodeType (SMESH::array_of_ElementType_var theTypes)
static void enlargeBoundingBox (const SMDS_MeshNode *theNode, SMESH::Measure &theMeasure)
static void enlargeBoundingBox (const SMESH::SMESH_IDSource_ptr theObject, SMESH::Measure &theMeasure)

Function Documentation

static void enlargeBoundingBox ( const SMDS_MeshNode *  theNode,
SMESH::Measure theMeasure 
) [static]

Definition at line 191 of file SMESH_Measurements_i.cxx.

{
  if (!theNode)
    return;
  if ( theMeasure.node1 == -1 ) {
    // we use this attribute as a flag that it is the first node added to the bnd box 
    theMeasure.minX = theMeasure.maxX = theNode->X();
    theMeasure.minY = theMeasure.maxY = theNode->Y();
    theMeasure.minZ = theMeasure.maxZ = theNode->Z();
    theMeasure.node1 = theNode->GetID();
  }
  else {
    theMeasure.minX = min( theMeasure.minX, theNode->X() );
    theMeasure.maxX = max( theMeasure.maxX, theNode->X() );
    theMeasure.minY = min( theMeasure.minY, theNode->Y() );
    theMeasure.maxY = max( theMeasure.maxY, theNode->Y() );
    theMeasure.minZ = min( theMeasure.minZ, theNode->Z() );
    theMeasure.maxZ = max( theMeasure.maxZ, theNode->Z() );
  }
}

Here is the caller graph for this function:

static void enlargeBoundingBox ( const SMESH::SMESH_IDSource_ptr  theObject,
SMESH::Measure theMeasure 
) [static]

Definition at line 217 of file SMESH_Measurements_i.cxx.

{
  if ( CORBA::is_nil( theObject ) )
    return;
  const SMESHDS_Mesh* aMesh = getMesh( theObject );
  if ( !aMesh )
    return;
  SMESH::array_of_ElementType_var types = theObject->GetTypes();
  SMESH::long_array_var     aElementsId = theObject->GetIDs();
  // here we assume that type of all IDs defined by first type in array
  const bool isNode = isNodeType( types );
  for(int i = 0, n = aElementsId->length(); i < n; i++)
  {
    if (isNode)
      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<const SMDS_MeshNode*>( aNodeIter->next() ), theMeasure);
    }
  }
}

Here is the call graph for this function:

static SMESHDS_Mesh* getMesh ( SMESH::SMESH_IDSource_ptr  theSource) [static]

Definition at line 118 of file SMESH_Measurements_i.cxx.

{
  if (!CORBA::is_nil( theSource ))
  {
    SMESH_Mesh_i* anImplPtr = DownCast<SMESH_Mesh_i*>(theSource->GetMesh());
    if (anImplPtr)
      return anImplPtr->GetImpl().GetMeshDS();
  }
  return 0;
}

Here is the caller graph for this function:

static bool getNodeNodeDistance ( SMESH::Measure theMeasure,
const SMDS_MeshNode *  theNode1,
const SMDS_MeshNode *  theNode2 = 0 
) [static]

Definition at line 95 of file SMESH_Measurements_i.cxx.

{
  double dist = 0., dd = 0.;

  if (!theNode1)
    return false;

  dd = theNode1->X(); if (theNode2) dd -= theNode2->X(); theMeasure.minX = dd; dd *= dd; dist += dd;
  dd = theNode1->Y(); if (theNode2) dd -= theNode2->Y(); theMeasure.minY = dd; dd *= dd; dist += dd;
  dd = theNode1->Z(); if (theNode2) dd -= theNode2->Z(); theMeasure.minZ = dd; dd *= dd; dist += dd;

  if (dist < 0)
    return false;
  
  theMeasure.value = sqrt(dist);
  theMeasure.node1 = theNode1->GetID();
  theMeasure.node2 = theNode2 ? theNode2->GetID() : 0;

  return true;
}
static void initMeasure ( SMESH::Measure theMeasure) [static]

this local function to avoid uninitialized fields

Definition at line 43 of file SMESH_Measurements_i.cxx.

{

  theMeasure.minX = theMeasure.minY = theMeasure.minZ = 0.;
  theMeasure.maxX = theMeasure.maxY = theMeasure.maxZ = 0.;
  theMeasure.node1 = theMeasure.node2 = -1;
  theMeasure.elem1 = theMeasure.elem2 = -1;
  theMeasure.value = 0.;
}
static bool isNodeType ( SMESH::array_of_ElementType_var  theTypes) [static]

Definition at line 129 of file SMESH_Measurements_i.cxx.

{
  return theTypes->length() > 0 && theTypes[0] == SMESH::NODE;
}

Here is the caller graph for this function: