From: apo Date: Sun, 25 Nov 2007 14:09:34 +0000 (+0000) Subject: Fix for Bug IPAL17640 X-Git-Tag: mergefrom_MERGE_MULTIPR_EVOLUTION_07-Dec-07~23 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=90e16bf1a78ce772bd4a981cdd8912448612bc40;p=modules%2Fvisu.git Fix for Bug IPAL17640 4.x: option "IJK (Structured)" disabled for clipping planes. --- diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 1f67c736..3bc4f8f3 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -1455,45 +1455,44 @@ VISU::Result_i return components; } - if(!theMesh->IsStructured() || theMesh->myType){ + if ( !theMesh->IsStructured() || theMesh->myType ) { // define axis directions and min cell size in each direction const int nbAxes = 3; int iAx; gp_Vec axDirs[ nbAxes ]; float minSize[3] = { FLT_MAX, FLT_MAX, FLT_MAX }; bool axesComputed = false; - for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell ) - { - vtkCell* cell = aMesh->GetCell( iCell ); - int nbPnt = cell->GetNumberOfPoints(); - if ( nbPnt != 8 ) - continue; - vtkPoints * points = cell->GetPoints(); - vtkFloatingPointType* coords[ 4 ]; - coords[0] = points->GetPoint( 0 ); - coords[1] = points->GetPoint( 1 ); - coords[2] = points->GetPoint( 3 ); - coords[3] = points->GetPoint( 4 ); - gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] ); - for ( iAx = 0; iAx < nbAxes; ++iAx ) - { - vtkFloatingPointType* coo = coords[ iAx + 1 ]; - gp_Pnt p( coo[0], coo[1], coo[2] ); - // min size - vtkFloatingPointType size = p0.SquareDistance( p ); - if ( size > FLT_MIN && size < minSize[ iAx ] ) - minSize[ iAx ] = size; - // axis direction - if ( !axesComputed ) { - gp_Vec dir( p0, p ); - if ( dir.SquareMagnitude() <= DBL_MIN ) - break; - axDirs[ iAx ] = dir; - } + for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell ) { + vtkCell* cell = aMesh->GetCell( iCell ); + int nbPnt = cell->GetNumberOfPoints(); + if ( nbPnt != 8 ) + continue; + vtkPoints * points = cell->GetPoints(); + vtkFloatingPointType coords[ 4 ][3]; + points->GetPoint( 0, coords[0] ); + points->GetPoint( 1, coords[1] ); + points->GetPoint( 3, coords[2] ); + points->GetPoint( 4, coords[4] ); + gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] ); + for ( iAx = 0; iAx < nbAxes; ++iAx ) { + vtkFloatingPointType* coo = coords[ iAx + 1 ]; + gp_Pnt p( coo[0], coo[1], coo[2] ); + // min size + vtkFloatingPointType size = p0.SquareDistance( p ); + if ( size > FLT_MIN && size < minSize[ iAx ] ) + minSize[ iAx ] = size; + // axis direction + if ( !axesComputed ) { + gp_Vec dir( p0, p ); + if ( dir.SquareMagnitude() <= DBL_MIN ) { + break; } - if ( iAx == nbAxes ) - axesComputed = true; + axDirs[ iAx ] = dir; + } } + if ( iAx == nbAxes ) + axesComputed = true; + } if ( !axesComputed ) { MESSAGE("No good hexahedrons in the mesh: " << theMeshName ); return components; @@ -1501,12 +1500,11 @@ VISU::Result_i // compute axes dirs gInfo = & myMeshName2GridInfoMap[ theMeshName ]; - for ( iAx = 0; iAx < nbAxes; ++iAx ) - { - int iPrev = ( iAx == 0 ) ? 2 : iAx - 1; - int iNext = ( iAx == 2 ) ? 0 : iAx + 1; - gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ]; - } + for ( iAx = 0; iAx < nbAxes; ++iAx ) { + int iPrev = ( iAx == 0 ) ? 2 : iAx - 1; + int iNext = ( iAx == 2 ) ? 0 : iAx + 1; + gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ]; + } // get and sort intermediate component values - projections of nodes // on axis direction; define bnd box @@ -1514,17 +1512,16 @@ VISU::Result_i Bnd_Box box; vtkPoints * points = aMesh->GetPoints(); vtkIdType iP, nbP = aMesh->GetNumberOfPoints(); - for ( iP = 0; iP < nbP; ++iP ) - { - vtkFloatingPointType* coo = points->GetPoint( iP ); - gp_Pnt p( coo[0], coo[1], coo[2] ); - box.Add( p ); - for ( iAx = 0; iAx < nbAxes; ++iAx ) { - const gp_Dir& dir = gInfo->myAxis[ iAx ]; - vtkFloatingPointType dot = dir.XYZ() * p.XYZ(); - comps[ iAx ].insert( dot ); - } + for ( iP = 0; iP < nbP; ++iP ) { + vtkFloatingPointType* coo = points->GetPoint( iP ); + gp_Pnt p( coo[0], coo[1], coo[2] ); + box.Add( p ); + for ( iAx = 0; iAx < nbAxes; ++iAx ) { + const gp_Dir& dir = gInfo->myAxis[ iAx ]; + vtkFloatingPointType dot = dir.XYZ() * p.XYZ(); + comps[ iAx ].insert( dot ); } + } // find a range of projections of bnd box corners on each axis vtkFloatingPointType range[3], firstValue[3]; @@ -1547,30 +1544,29 @@ VISU::Result_i } // compute component values - for ( iAx = 0; iAx < nbAxes; ++iAx ) - { - list< vtkFloatingPointType > values; - int nbVals = 0; - set< vtkFloatingPointType >& comp = comps[ iAx ]; - set< vtkFloatingPointType >::iterator val = comp.begin(); - vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ]; - vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng; - for ( ; val != comp.end(); ++val ) { - vtkFloatingPointType value = ( *val - first ) / rng; - if ( value > bnd ) { - values.push_back( value ); - bnd = value + tol; - nbVals++; - } - } - // store values in gInfo - vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ]; - myComp.resize( nbVals ); - list< vtkFloatingPointType >::iterator v = values.begin(); - for ( int i = 0; v != values.end(); ++v ){ - myComp[ i++ ] = *v; + for ( iAx = 0; iAx < nbAxes; ++iAx ) { + list< vtkFloatingPointType > values; + int nbVals = 0; + set< vtkFloatingPointType >& comp = comps[ iAx ]; + set< vtkFloatingPointType >::iterator val = comp.begin(); + vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ]; + vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng; + for ( ; val != comp.end(); ++val ) { + vtkFloatingPointType value = ( *val - first ) / rng; + if ( value > bnd ) { + values.push_back( value ); + bnd = value + tol; + nbVals++; } } + // store values in gInfo + vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ]; + myComp.resize( nbVals ); + list< vtkFloatingPointType >::iterator v = values.begin(); + for ( int i = 0; v != values.end(); ++v ){ + myComp[ i++ ] = *v; + } + } } else { //ENK: 23.11.2006 - PAL13176 - EDF228 VISU : Enhancement of structured datas processing @@ -1578,73 +1574,65 @@ VISU::Result_i gInfo = & myMeshName2GridInfoMap[ theMeshName ]; switch(aIndexes.size()){ - case 3: - { - gp_Dir aDir(0.0,0.0,1.0); - gInfo->myAxis[ 2 ] = aDir; - } - case 2: - { - gp_Dir aDir(0.0,1.0,0.0); - gInfo->myAxis[ 1 ] = aDir; - } - case 1: - { - gp_Dir aDir(1.0,0.0,0.0); - gInfo->myAxis[ 0 ] = aDir; - } + case 3: { + gp_Dir aDir(0.0,0.0,1.0); + gInfo->myAxis[ 2 ] = aDir; + } + case 2: { + gp_Dir aDir(0.0,1.0,0.0); + gInfo->myAxis[ 1 ] = aDir; } + case 1: { + gp_Dir aDir(1.0,0.0,0.0); + gInfo->myAxis[ 0 ] = aDir; + }} int nbPoints = aMesh->GetNumberOfPoints(); vtkFloatingPointType* coords[ 2 ]; - if(nbPoints>1){ + if ( nbPoints > 1 ) { coords[0] = aMesh->GetPoints()->GetPoint(0); coords[1] = aMesh->GetPoints()->GetPoint(nbPoints-1); } vector PointsCoords[3]; TIdTypeVector aCoordIJK; - switch(aIndexes.size()){ - case 3: - { - vtkIdType nbZ = aIndexes[2]; - aCoordIJK.clear(); - aCoordIJK.resize(aIndexes.size(),1); - for(int i=0;iGetObjectIDByIndexes(aCoordIJK); - vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID); - vtkFloatingPointType* aPCoord = aMesh->GetPoints()->GetPoint(aVTKID); - PointsCoords[2].push_back(aPCoord[2]); - } + switch ( aIndexes.size() ) { + case 3: { + vtkIdType nbZ = aIndexes[2]; + aCoordIJK.clear(); + aCoordIJK.resize(aIndexes.size(),1); + for(int i=0;iGetObjectIDByIndexes(aCoordIJK); + vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID); + vtkFloatingPointType* aPCoord = aMesh->GetPoints()->GetPoint(aVTKID); + PointsCoords[2].push_back(aPCoord[2]); } - case 2: - { - vtkIdType nbJ = aIndexes[1]; - aCoordIJK.clear(); - aCoordIJK.resize(aIndexes.size(),1); - for(int i=0;iGetObjectIDByIndexes(aCoordIJK); - vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID); - vtkFloatingPointType* aPCoord = aMesh->GetPoints()->GetPoint(aVTKID); - PointsCoords[1].push_back(aPCoord[1]); - } - } - case 1: - { - vtkIdType nbI = aIndexes[0]; - aCoordIJK.clear(); - aCoordIJK.resize(aIndexes.size(),1); - for(int i=0;iGetObjectIDByIndexes(aCoordIJK); - vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID); - vtkFloatingPointType* aPCoord = aMesh->GetPoints()->GetPoint(aVTKID); - PointsCoords[0].push_back(aPCoord[0]); - } + } + case 2: { + vtkIdType nbJ = aIndexes[1]; + aCoordIJK.clear(); + aCoordIJK.resize(aIndexes.size(),1); + for(int i=0;iGetObjectIDByIndexes(aCoordIJK); + vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID); + vtkFloatingPointType* aPCoord = aMesh->GetPoints()->GetPoint(aVTKID); + PointsCoords[1].push_back(aPCoord[1]); } } + case 1: { + vtkIdType nbI = aIndexes[0]; + aCoordIJK.clear(); + aCoordIJK.resize(aIndexes.size(),1); + for(int i=0;iGetObjectIDByIndexes(aCoordIJK); + vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID); + vtkFloatingPointType* aPCoord = aMesh->GetPoints()->GetPoint(aVTKID); + PointsCoords[0].push_back(aPCoord[0]); + } + }} for(int i=0;i& myComp = gInfo->myComponets[ i ]; int aSize = PointsCoords[i].size(); @@ -1663,8 +1651,7 @@ VISU::Result_i } // set return values - if ( gInfo ) - { + if ( gInfo ) { thePlaneNormal = gInfo->myAxis[ theAxis ]; components = & gInfo->myComponets[ theAxis ]; }