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;
// 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
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];
}
// 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
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<vtkFloatingPointType> PointsCoords[3];
TIdTypeVector aCoordIJK;
- switch(aIndexes.size()){
- case 3:
- {
- vtkIdType nbZ = aIndexes[2];
- aCoordIJK.clear();
- aCoordIJK.resize(aIndexes.size(),1);
- for(int i=0;i<nbZ;i++){
- aCoordIJK[2]=i+1;
- vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(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;i<nbZ;i++){
+ aCoordIJK[2]=i+1;
+ vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(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;i<nbJ;i++){
- aCoordIJK[1]=i+1;
- vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(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;i<nbI;i++){
- aCoordIJK[0]=i+1;
- vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(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;i<nbJ;i++){
+ aCoordIJK[1]=i+1;
+ vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(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;i<nbI;i++){
+ aCoordIJK[0]=i+1;
+ vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
+ vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
+ vtkFloatingPointType* aPCoord = aMesh->GetPoints()->GetPoint(aVTKID);
+ PointsCoords[0].push_back(aPCoord[0]);
+ }
+ }}
for(int i=0;i<aIndexes.size();i++){
vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ i ];
int aSize = PointsCoords[i].size();
}
// set return values
- if ( gInfo )
- {
+ if ( gInfo ) {
thePlaneNormal = gInfo->myAxis[ theAxis ];
components = & gInfo->myComponets[ theAxis ];
}