From: rnv Date: Mon, 28 Apr 2008 09:56:39 +0000 (+0000) Subject: Visualization of ELNO fields development. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fcf5d35f2d1d6b2330119de1196a152ddd3f344f;p=modules%2Fvisu.git Visualization of ELNO fields development. --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 67d4485b..1fcb6152 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -76,6 +76,7 @@ module VISU { TCONTAINER, /*!< Container object used for storing a set of curve lines */ TMESH, /*!< Meshing object */ TSCALARMAP, /*!< Scalarmap 3D presentation object */ + TELNOSCALARMAP, /*!< 3D Scalarmap by points presentation object */ TISOSURFACES, /*!< Iso surface 3D presentation object */ TDEFORMEDSHAPE, /*!< Deformed shape 3D presentation object */ TSCALARMAPONDEFORMEDSHAPE, /*!< Scalar map on deformed shape 3D presentation object */ @@ -673,6 +674,18 @@ module VISU { }; + //------------------------------------------------------- + /*! \brief Elno Scalar Map presentation interface + * + * This interface is responsable for coloring of 3D field presentations + * according the scalar values applied to different points of cells. + */ + //------------------------------------------------------- + + interface ElnoScalarMap : ColoredPrs3d, ScaledPrs3d { + + }; + //------------------------------------------------------- /*! \brief Gauss Points presentation interface * diff --git a/src/PIPELINE/Makefile.am b/src/PIPELINE/Makefile.am index ec469cc7..7a26914c 100644 --- a/src/PIPELINE/Makefile.am +++ b/src/PIPELINE/Makefile.am @@ -66,7 +66,9 @@ salomeinclude_HEADERS= \ VISU_ScalarMapOnDeformedShapePL.hxx \ VISU_OpenGLElnoMapper.hxx \ VISUPipeline.hxx \ - VISU_ElnoGeometryFilter.hxx + VISU_ElnoGeometryFilter.hxx \ + VISU_ElnoMapperHolder.hxx \ + VISU_ElnoScalarMapPL.hxx dist_libVisuPipeLine_la_SOURCES= \ VISU_MapperHolder.cxx \ @@ -105,7 +107,9 @@ dist_libVisuPipeLine_la_SOURCES= \ VISU_ScalarBarCtrl.cxx \ VISU_ScalarMapOnDeformedShapePL.cxx \ VISU_OpenGLElnoMapper.cxx \ - VISU_ElnoGeometryFilter.cxx + VISU_ElnoGeometryFilter.cxx \ + VISU_ElnoMapperHolder.cxx \ + VISU_ElnoScalarMapPL.cxx libVisuPipeLine_la_CPPFLAGS= \ diff --git a/src/PIPELINE/VISUPipeLine.cxx b/src/PIPELINE/VISUPipeLine.cxx index 80384b76..befed7be 100644 --- a/src/PIPELINE/VISUPipeLine.cxx +++ b/src/PIPELINE/VISUPipeLine.cxx @@ -241,8 +241,6 @@ main(int argc, char** argv) aMapper->SetInput( aGeometryFilter->GetOutput() ); - double* range = aGeometryFilter->GetRange(); - VISU_LookupTable* aMapperTable( VISU_LookupTable::New() ); aMapperTable->SetHueRange(0.667, 0.0); aMapperTable->SetRange( aGeometryFilter->GetRange() ); diff --git a/src/PIPELINE/VISU_ElnoGeometryFilter.cxx b/src/PIPELINE/VISU_ElnoGeometryFilter.cxx index f9f01b0c..dc8c48f5 100755 --- a/src/PIPELINE/VISU_ElnoGeometryFilter.cxx +++ b/src/PIPELINE/VISU_ElnoGeometryFilter.cxx @@ -102,11 +102,21 @@ int VISU_ElnoGeometryFilter::RequestData(vtkInformation *request, } //---------------------------------------------------------------------------------------------- template -void CopyArray(TValueType *outputPtr, TValueType* inputPtr,const vtkIdType& theDataSize){ +void BuildMinMax(TValueType* inputPtr, double *outres, const vtkIdType& theDataSize){ + double s; + outres[0] = static_cast(*inputPtr); //Min + outres[1] = static_cast(*inputPtr); //Max for(vtkIdType iData =0;iData < theDataSize;iData++){ - *outputPtr = *inputPtr; - outputPtr++;inputPtr++; - } + s = static_cast(*inputPtr); + if(s < outres[0]){ + outres[0] = s; + } + else if(s > outres[1]) + { + outres[1] = s; + } + inputPtr++; + } } //---------------------------------------------------------------------------------------------- void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, @@ -120,9 +130,6 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, return; } - //Create data array - vtkDataArray * aElnoScalars = vtkDataArray::CreateDataArray(myElnoData->GetDataType()); - vtkIdType cellId; int i; int allVisible; @@ -205,6 +212,7 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, Polys->Allocate(numCells/4+1,numCells); Strips = vtkCellArray::New(); Strips->Allocate(numCells/4+1,numCells); + // Loop over the cells determining what's visible if (!allVisible) @@ -242,13 +250,37 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, // Loop over all cells now that visibility is known // (Have to compute visibility first for 3D cell boundarys) int progressInterval = numCells/20 + 1; + int info[2]; + this->GetInfoOnVisibleElements(Connectivity,input, + allVisible, + cellVis, + cellGhostLevels, + updateLevel, + info); + int aNbVisibleCells = info[0]; + int aNbVisiblePointsOnCells = info[1]; + - vtkDataArray *aTmpElnoComponents = vtkDataArray::CreateDataArray(myElnoData->GetDataType()); - aTmpElnoComponents->SetNumberOfComponents(1); + //Re-create "ELNO_FIELD" + vtkDataArray *aElnoVectors = vtkDataArray::CreateDataArray(myElnoData->GetDataType()); + int aNbElnoComponents = VISU_ElnoGeometryFilter::GetNbOfElnoComponents(cd); + int aNbEffectiveVectorComponents = (aNbVisiblePointsOnCells*aNbElnoComponents/aNbVisibleCells) + 1; + aElnoVectors->SetNumberOfComponents(aNbEffectiveVectorComponents); + aElnoVectors->SetNumberOfTuples(aNbVisibleCells); + aElnoVectors->SetName("ELNO_FIELD"); - vtkDataArray *aTmpElnoScalars = vtkDataArray::CreateDataArray(myElnoData->GetDataType()); - aTmpElnoScalars->SetNumberOfComponents(1); + vtkDataArray *aElnoScalars = vtkDataArray::CreateDataArray(myElnoData->GetDataType()); + int aNbEffectiveScalarsComponents = (aNbVisiblePointsOnCells/aNbVisibleCells) + 1; + aElnoScalars->SetNumberOfComponents(aNbEffectiveScalarsComponents); + aElnoScalars->SetNumberOfTuples(aNbVisibleCells); + aElnoScalars->SetName("ELNO_PSEUDO_SCALARS"); + + vtkIntArray *aElnoMapper = vtkIntArray::New(); + aElnoMapper->SetNumberOfTuples(aNbVisibleCells); + aElnoMapper->SetNumberOfComponents(3); + aElnoMapper->SetName("ELNO_COMPONENT_MAPPER"); + vtkIdType aPosition = 0; for (cellId=0, Connectivity->InitTraversal(); @@ -299,9 +331,10 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, newCellId = Polys->InsertNextCell(npts,pts); outputCD->CopyData(cd,cellId,newCellId); - //Copy Elno Data - this->GetElementData(cellId, aComponents); - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition); + //Copy Elno Data + this->GetElementData(cellId, aComponents); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition); + this->WriteElnoMapperInfo(aElnoMapper,npts,aNbElnoComponents,newCellId); break; case VTK_TRIANGLE_STRIP: @@ -318,8 +351,9 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[PixelConvert[i]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,PixelConvert[i]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,PixelConvert[i]); } + this->WriteElnoMapperInfo(aElnoMapper,npts,aNbElnoComponents,newCellId); outputCD->CopyData(cd,cellId,newCellId); break; @@ -343,9 +377,10 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[faceVerts[i]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,faceVerts[i]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,faceVerts[i]); } outputCD->CopyData(cd,cellId,newCellId); + this->WriteElnoMapperInfo(aElnoMapper,numFacePts,aNbElnoComponents,newCellId); } } break; @@ -370,7 +405,8 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[faceVerts[PixelConvert[i]]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,faceVerts[PixelConvert[i]]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,faceVerts[PixelConvert[i]]); + this->WriteElnoMapperInfo(aElnoMapper,numFacePts,aNbElnoComponents,newCellId); } outputCD->CopyData(cd,cellId,newCellId); } @@ -398,8 +434,9 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[faceVerts[i]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,faceVerts[i]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,faceVerts[i]); } + this->WriteElnoMapperInfo(aElnoMapper,numFacePts,aNbElnoComponents,newCellId); outputCD->CopyData(cd,cellId,newCellId); } } @@ -430,8 +467,9 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[faceVerts[i]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,faceVerts[i]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,faceVerts[i]); } + this->WriteElnoMapperInfo(aElnoMapper,numFacePts,aNbElnoComponents,newCellId); outputCD->CopyData(cd,cellId,newCellId); } } @@ -462,8 +500,9 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[faceVerts[i]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,faceVerts[i]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,faceVerts[i]); } + this->WriteElnoMapperInfo(aElnoMapper,numFacePts,aNbElnoComponents,newCellId); outputCD->CopyData(cd,cellId,newCellId); } } @@ -495,8 +534,9 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[faceVerts[i]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,faceVerts[i]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,faceVerts[i]); } + this->WriteElnoMapperInfo(aElnoMapper,numFacePts,aNbElnoComponents,newCellId); outputCD->CopyData(cd,cellId,newCellId); } } @@ -529,8 +569,9 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, { Polys->InsertCellPoint(pts[faceVerts[i]]); //Copy Elno Data - this->CopyElementData(aTmpElnoComponents,aTmpElnoScalars,aComponents,aPosition,faceVerts[i]); + this->CopyElementData(aElnoVectors,aElnoScalars,aComponents,aPosition,faceVerts[i]); } + this->WriteElnoMapperInfo(aElnoMapper,numFacePts,aNbElnoComponents,newCellId); outputCD->CopyData(cd,cellId,newCellId); } } @@ -619,46 +660,23 @@ void VISU_ElnoGeometryFilter::UnstructuredGridExecute(vtkDataSet *dataSetInput, output->SetStrips(Strips); Strips->Delete(); - - myMinMax[0] = *(aTmpElnoScalars->GetTuple(0)); - myMinMax[1] = *(aTmpElnoScalars->GetTuple(0)); - - //Build Min and Max - for(vtkIdType count = 0;count < aTmpElnoScalars->GetSize();count++){ - double s = *(aTmpElnoScalars->GetTuple(count)); - if(s < myMinMax[0]){ - myMinMax[0] = s; - } - else if(s > myMinMax[1]) - { - myMinMax[1] = s; - } - } - - vtkIdType aNbEffectiveComponents = (aTmpElnoScalars->GetSize()/output->GetNumberOfCells())+1; - - vtkDataArray *aElnoPseudoScalars = vtkDataArray::CreateDataArray(this->myElnoData->GetDataType()); - aElnoPseudoScalars->SetName("ELNO_PSEUDO_SCALARS"); - aElnoPseudoScalars->SetNumberOfTuples(aTmpElnoComponents->GetSize()); - aElnoPseudoScalars->SetNumberOfComponents(1); - - - switch(this->myElnoData->GetDataType()){ - - vtkTemplateMacro3(CopyArray, - static_cast(aElnoPseudoScalars->GetVoidPointer(0)), - static_cast(aTmpElnoScalars->GetVoidPointer(0)), - aTmpElnoScalars->GetSize()); - default: - break; + //Compute Min and Max + switch(myElnoData->GetDataType()){ + vtkTemplateMacro3(BuildMinMax, + static_cast(aElnoScalars->GetVoidPointer(0)), + this->myMinMax, + aNbVisiblePointsOnCells); + default: + break; } - - output->GetCellData()->AddArray(aElnoPseudoScalars); + + output->GetCellData()->AddArray(aElnoScalars); + output->GetCellData()->AddArray(aElnoMapper); output->Squeeze(); - aElnoPseudoScalars->Delete(); - - aTmpElnoComponents->Delete(); + aElnoScalars->Delete(); + aElnoVectors->Delete(); + aElnoMapper->Delete(); vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points," << output->GetNumberOfCells() << " cells."); @@ -792,19 +810,10 @@ VISU_ElnoGeometryFilter::CopyElementData(vtkDataArray *toComponents, { //Optimize needed vtkIdType aNbComponents = from->GetNumberOfComponents(); - - vtkDataArray *tmpComponents = vtkDataArray::CreateDataArray(this->myElnoData->GetDataType()); - tmpComponents->SetNumberOfTuples(toComponents->GetNumberOfTuples()); - tmpComponents->DeepCopy(toComponents); - - vtkDataArray *tmpScalars = vtkDataArray::CreateDataArray(this->myElnoData->GetDataType()); - tmpScalars->SetNumberOfTuples(toScalars->GetNumberOfTuples()); - tmpScalars->DeepCopy(toScalars); vtkIdType aDataSize = 0; void *inputPtr = NULL; - - + if(PntId == -2){ aDataSize = from->GetNumberOfTuples(); inputPtr = from->GetVoidPointer(0); @@ -814,31 +823,6 @@ VISU_ElnoGeometryFilter::CopyElementData(vtkDataArray *toComponents, inputPtr = from->GetVoidPointer(PntId*aNbComponents); } - toComponents->Allocate(position*aNbComponents + aDataSize*aNbComponents); - toScalars->Allocate(position+aDataSize); - - switch(this->myElnoData->GetDataType()){ - vtkTemplateMacro4(CopyArray1, - static_cast(tmpComponents->GetVoidPointer(0)), - static_cast(toComponents->GetVoidPointer(0)), - position*aNbComponents, - 1); - default: - break; - } - - switch(this->myElnoData->GetDataType()){ - vtkTemplateMacro4(CopyArray1, - static_cast(tmpScalars->GetVoidPointer(0)), - static_cast(toScalars->GetVoidPointer(0)), - position, - 1); - default: - break; - } - - //Optimize needed - //Fill Elno Field void *outputComponentsPtr = toComponents->GetVoidPointer(position*aNbComponents); switch(this->myElnoData->GetDataType()){ @@ -851,8 +835,6 @@ VISU_ElnoGeometryFilter::CopyElementData(vtkDataArray *toComponents, break; } - - //Fill Scalars array void *outputScalarasPtr = toScalars->GetVoidPointer(position); if( !myScalarMode ) { @@ -879,8 +861,6 @@ VISU_ElnoGeometryFilter::CopyElementData(vtkDataArray *toComponents, } } position+=aDataSize; - tmpComponents->Delete(); - tmpScalars->Delete(); } //---------------------------------------------------------------------------------------------- @@ -922,3 +902,258 @@ vtkIdType VISU_ElnoGeometryFilter::GetNbOfElnoTuples(vtkCellData *theInputData) return -1; } //---------------------------------------------------------------------------------------------- + +void VISU_ElnoGeometryFilter::WriteElnoMapperInfo(vtkIntArray *theMapperArray, + const vtkIdType &theNbPoints, + const vtkIdType &theNbComponents, + const vtkIdType &theCellId){ + int aCellInfo[3] = {0,theNbComponents,theNbPoints}; + if(theCellId){ + int aPrevCellInfo[3]; + theMapperArray->GetTupleValue(theCellId - 1, aPrevCellInfo); + aCellInfo[0] = aPrevCellInfo[1]*aPrevCellInfo[2]+aPrevCellInfo[0]; + } + + theMapperArray->InsertTupleValue(theCellId,aCellInfo); +} + +//---------------------------------------------------------------------------------------------- + +void VISU_ElnoGeometryFilter::GetInfoOnVisibleElements(vtkCellArray *Connectivity, + vtkUnstructuredGrid *input, + const bool allVisible, + const char *cellVis, + const unsigned char *cellGhostLevels, + const unsigned char updateLevel, + int *outres){ + + vtkIdType npts = 0; + vtkIdType *pts = 0; + vtkIdList *faceIds = vtkIdList::New(); + vtkIdList *cellIds = vtkIdList::New(); + int faceId, *faceVerts, numFacePts; + vtkIdType cellId; + + vtkIdType aNbVisibleCells = 0; + vtkIdType aNbPointOnVisibleCells = 0; + + for (cellId=0, Connectivity->InitTraversal(); + Connectivity->GetNextCell(npts,pts); + cellId++) + { + + // Handle ghost cells here. Another option was used cellVis array. + if (cellGhostLevels && cellGhostLevels[cellId] > updateLevel) + { // Do not create surfaces in outer ghost cells. + continue; + } + + if (allVisible || cellVis[cellId]) //now if visible extract geometry + { + //special code for nonlinear cells - rarely occurs, so right now it + //is slow. + //Create temporary data array + switch (input->GetCellType(cellId)) + { + case VTK_EMPTY_CELL: + break; + + case VTK_VERTEX: + case VTK_POLY_VERTEX: + break; + + case VTK_LINE: + case VTK_POLY_LINE: + break; + + case VTK_TRIANGLE: + case VTK_QUAD: + case VTK_POLYGON: + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=npts; + break; + + case VTK_TRIANGLE_STRIP: + break; + + case VTK_PIXEL: + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=npts; + break; + + case VTK_TETRA: + //Get Elno Data + for (faceId = 0; faceId < 4; faceId++) + { + faceIds->Reset(); + faceVerts = vtkTetra::GetFaceArray(faceId); + faceIds->InsertNextId(pts[faceVerts[0]]); + faceIds->InsertNextId(pts[faceVerts[1]]); + faceIds->InsertNextId(pts[faceVerts[2]]); + numFacePts = 3; + input->GetCellNeighbors(cellId, faceIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || + (!allVisible && !cellVis[cellIds->GetId(0)]) ) + { + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=numFacePts; + } + } + break; + + case VTK_VOXEL: + for (faceId = 0; faceId < 6; faceId++) + { + faceIds->Reset(); + faceVerts = vtkVoxel::GetFaceArray(faceId); + faceIds->InsertNextId(pts[faceVerts[0]]); + faceIds->InsertNextId(pts[faceVerts[1]]); + faceIds->InsertNextId(pts[faceVerts[2]]); + faceIds->InsertNextId(pts[faceVerts[3]]); + numFacePts = 4; + input->GetCellNeighbors(cellId, faceIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || + (!allVisible && !cellVis[cellIds->GetId(0)]) ) + { + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=numFacePts; + } + } + break; + + case VTK_HEXAHEDRON: + for (faceId = 0; faceId < 6; faceId++) + { + faceIds->Reset(); + faceVerts = vtkHexahedron::GetFaceArray(faceId); + faceIds->InsertNextId(pts[faceVerts[0]]); + faceIds->InsertNextId(pts[faceVerts[1]]); + faceIds->InsertNextId(pts[faceVerts[2]]); + faceIds->InsertNextId(pts[faceVerts[3]]); + numFacePts = 4; + input->GetCellNeighbors(cellId, faceIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || + (!allVisible && !cellVis[cellIds->GetId(0)]) ) + { + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=numFacePts; + } + } + break; + + case VTK_WEDGE: + for (faceId = 0; faceId < 5; faceId++) + { + faceIds->Reset(); + faceVerts = vtkWedge::GetFaceArray(faceId); + faceIds->InsertNextId(pts[faceVerts[0]]); + faceIds->InsertNextId(pts[faceVerts[1]]); + faceIds->InsertNextId(pts[faceVerts[2]]); + numFacePts = 3; + if (faceVerts[3] >= 0) + { + faceIds->InsertNextId(pts[faceVerts[3]]); + numFacePts = 4; + } + input->GetCellNeighbors(cellId, faceIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || + (!allVisible && !cellVis[cellIds->GetId(0)]) ) + { + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=numFacePts; + } + } + break; + + case VTK_PYRAMID: + for (faceId = 0; faceId < 5; faceId++) + { + faceIds->Reset(); + faceVerts = vtkPyramid::GetFaceArray(faceId); + faceIds->InsertNextId(pts[faceVerts[0]]); + faceIds->InsertNextId(pts[faceVerts[1]]); + faceIds->InsertNextId(pts[faceVerts[2]]); + numFacePts = 3; + if (faceVerts[3] >= 0) + { + faceIds->InsertNextId(pts[faceVerts[3]]); + numFacePts = 4; + } + input->GetCellNeighbors(cellId, faceIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || + (!allVisible && !cellVis[cellIds->GetId(0)]) ) + { + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=numFacePts; + } + } + break; + + case VTK_PENTAGONAL_PRISM: + for (faceId = 0; faceId < 7; faceId++) + { + faceIds->Reset(); + faceVerts = vtkPentagonalPrism::GetFaceArray(faceId); + faceIds->InsertNextId(pts[faceVerts[0]]); + faceIds->InsertNextId(pts[faceVerts[1]]); + faceIds->InsertNextId(pts[faceVerts[2]]); + faceIds->InsertNextId(pts[faceVerts[3]]); + numFacePts = 4; + if (faceVerts[4] >= 0) + { + faceIds->InsertNextId(pts[faceVerts[4]]); + numFacePts = 5; + } + input->GetCellNeighbors(cellId, faceIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || + (!allVisible && !cellVis[cellIds->GetId(0)]) ) + { + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=numFacePts; + } + } + break; + + case VTK_HEXAGONAL_PRISM: + for (faceId = 0; faceId < 8; faceId++) + { + faceIds->Reset(); + faceVerts = vtkHexagonalPrism::GetFaceArray(faceId); + faceIds->InsertNextId(pts[faceVerts[0]]); + faceIds->InsertNextId(pts[faceVerts[1]]); + faceIds->InsertNextId(pts[faceVerts[2]]); + faceIds->InsertNextId(pts[faceVerts[3]]); + numFacePts = 4; + if (faceVerts[4] >= 0) + { + faceIds->InsertNextId(pts[faceVerts[4]]); + faceIds->InsertNextId(pts[faceVerts[5]]); + numFacePts = 6; + } + input->GetCellNeighbors(cellId, faceIds, cellIds); + if ( cellIds->GetNumberOfIds() <= 0 || + (!allVisible && !cellVis[cellIds->GetId(0)]) ) + { + aNbVisibleCells+=1; + aNbPointOnVisibleCells+=numFacePts; + } + } + break; + + //Quadratic cells + case VTK_QUADRATIC_EDGE: + case VTK_QUADRATIC_TRIANGLE: + case VTK_QUADRATIC_QUAD: + case VTK_QUADRATIC_TETRA: + case VTK_QUADRATIC_HEXAHEDRON: + case VTK_QUADRATIC_WEDGE: + case VTK_QUADRATIC_PYRAMID: + break; + + } //switch + } //if visible + } + + outres[0] = aNbVisibleCells; + outres[1] = aNbPointOnVisibleCells; +} diff --git a/src/PIPELINE/VISU_ElnoGeometryFilter.hxx b/src/PIPELINE/VISU_ElnoGeometryFilter.hxx index 11758399..aab58854 100755 --- a/src/PIPELINE/VISU_ElnoGeometryFilter.hxx +++ b/src/PIPELINE/VISU_ElnoGeometryFilter.hxx @@ -4,6 +4,8 @@ #include +class vtkUnstructuredGrid; + class VISU_ElnoGeometryFilter : public vtkGeometryFilter { public: @@ -44,6 +46,19 @@ private: vtkIdType& position, const vtkIdType& PntId = -2 ) const; + void GetInfoOnVisibleElements(vtkCellArray *Connectivity, + vtkUnstructuredGrid *input, + const bool allVisible, + const char *cellVis, + const unsigned char *cellGhostLevels, + const unsigned char updateLevel, + int* outres); + + void WriteElnoMapperInfo(vtkIntArray *theMapperArray, + const vtkIdType &theNbPoints, + const vtkIdType &theNbComponents, + const vtkIdType &theCellId); + private: double myMinMax[2]; // myMinMax[0] - Min // myMinMax[1] - Max diff --git a/src/PIPELINE/VISU_ElnoMapperHolder.cxx b/src/PIPELINE/VISU_ElnoMapperHolder.cxx new file mode 100644 index 00000000..7e8f5105 --- /dev/null +++ b/src/PIPELINE/VISU_ElnoMapperHolder.cxx @@ -0,0 +1,167 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_ElnoMapperHolder.cxx +// Author: Roman NIKOLAEV +// Module : VISU + + +#include "VISU_ElnoMapperHolder.hxx" +#include "VISU_OpenGLElnoMapper.hxx" +#include "VISU_ElnoGeometryFilter.hxx" +#include "VISU_PipeLineUtils.hxx" +#include "VISU_LookupTable.hxx" + +#include +#include +#include +#include +#include +#include + + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_ElnoMapperHolder); + + +//---------------------------------------------------------------------------- +VISU_ElnoMapperHolder +::VISU_ElnoMapperHolder() : + myPolyDataFilter(VISU_ElnoGeometryFilter::New()) +{ +} + + +//---------------------------------------------------------------------------- +VISU_ElnoMapperHolder +::~VISU_ElnoMapperHolder() +{ +} + +//---------------------------------------------------------------------------- +unsigned long int +VISU_ElnoMapperHolder::GetMemorySize(){ + unsigned long int aSize = Superclass::GetMemorySize(); + + if(myPolyDataFilter->GetInput()) + if(vtkDataSet* aDataSet = myPolyDataFilter->GetOutput()) + aSize = aDataSet->GetActualMemorySize() * 1024; + return aSize; +} + +//---------------------------------------------------------------------------- +void +VISU_ElnoMapperHolder::SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper) +{ + myPolyDataFilter->SetInput(theIDMapper->GetUnstructuredGridOutput()); + myUnstructuredGridIDMapper = theIDMapper; + SetIDMapper(theIDMapper); +} + +const VISU::PUnstructuredGridIDMapper& +VISU_ElnoMapperHolder::GetUnstructuredGridIDMapper() +{ + return myUnstructuredGridIDMapper; +} + +//---------------------------------------------------------------------------- +vtkPointSet* VISU_ElnoMapperHolder::GetClippedInput() +{ + if(myPolyDataFilter->GetInput()) + myPolyDataFilter->Update(); + return myPolyDataFilter->GetOutput(); +} + +//---------------------------------------------------------------------------- +void VISU_ElnoMapperHolder::OnCreateMapper(){ + + myElnoMapper = VISU_OpenGLElnoMapper::New(); + myElnoMapper->Delete(); + SetMapper(myElnoMapper.GetPointer()); +} + +//---------------------------------------------------------------------------- +void VISU_ElnoMapperHolder::SetExtractInside(bool theMode){ + //temporary it is stub +} + +void VISU_ElnoMapperHolder::SetExtractBoundaryCells(bool theMode){ + //temporary it is stub +} + +//---------------------------------------------------------------------------- +void VISU_ElnoMapperHolder::SetLookupTable(VISU_LookupTable* theLookupTable){ + myElnoMapper->SetLookupTable(theLookupTable); +} + + +//---------------------------------------------------------------------------- +bool VISU_ElnoMapperHolder::AddClippingPlane(vtkPlane* thePlane) +{ + /*if (thePlane) { + if (vtkImplicitBoolean* aBoolean = myPolyDataFilter->GetImplicitBoolean()) { + vtkImplicitFunctionCollection* aFunction = aBoolean->GetFunction(); + aFunction->AddItem(thePlane); + vtkDataSet* aClippedDataSet = GetClippedInput(); + if(aClippedDataSet->GetNumberOfCells() < 1) + return false; + } + } + return true; + */ + //temporary it is stub + return false; +} + +//---------------------------------------------------------------------------- +vtkPlane* VISU_ElnoMapperHolder::GetClippingPlane(vtkIdType theID){ + vtkPlane* aPlane = NULL; + //temporary it is stub + return aPlane; +} + +//---------------------------------------------------------------------------- +void VISU_ElnoMapperHolder::RemoveAllClippingPlanes(){ + //temporary it is stub +} + + +//---------------------------------------------------------------------------- +vtkIdType VISU_ElnoMapperHolder::GetNumberOfClippingPlanes(){ + //temporary it is stub + return 0; +} + + +//---------------------------------------------------------------------------- +vtkImplicitFunction* VISU_ElnoMapperHolder::GetImplicitFunction() +{ + //temporary it is stub + return NULL; +} + +//---------------------------------------------------------------------------- + +void +VISU_ElnoMapperHolder::SetImplicitFunction(vtkImplicitFunction *theFunction) +{ + //temporary it is stub +} diff --git a/src/PIPELINE/VISU_ElnoMapperHolder.hxx b/src/PIPELINE/VISU_ElnoMapperHolder.hxx new file mode 100644 index 00000000..725d1402 --- /dev/null +++ b/src/PIPELINE/VISU_ElnoMapperHolder.hxx @@ -0,0 +1,129 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// File: VISU_ElnoMapperHolder.hxx +// Author: Roman NIKOLAEV +// Module : VISU + +#ifndef VISU_ElnoMapperHolder_HeaderFile +#define VISU_ElnoMapperHolder_HeaderFile + +#include "VISU_MapperHolder.hxx" + +class vtkUnstructuredGrid; +class VISU_OpenGLElnoMapper; +class VISU_ElnoGeometryFilter; + +class VISU_ElnoMapperHolder : public VISU_MapperHolder +{ +public: + vtkTypeMacro(VISU_ElnoMapperHolder, VISU_MapperHolder); + + static + VISU_ElnoMapperHolder* + New(); + + //---------------------------------------------------------------------------- + //virtual + //void + //ShallowCopy(VISU_MapperHolder *theMapperHolder, + // bool theIsCopyInput); + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); + + //---------------------------------------------------------------------------- + void + SetUnstructuredGridIDMapper(const VISU::PUnstructuredGridIDMapper& theIDMapper); + + const VISU::PUnstructuredGridIDMapper& + GetUnstructuredGridIDMapper(); + + + //---------------------------------------------------------------------------- + virtual + void + SetImplicitFunction(vtkImplicitFunction *theFunction); + + virtual + vtkImplicitFunction* + GetImplicitFunction(); + + //---------------------------------------------------------------------------- + // Clipping planes + virtual + void + RemoveAllClippingPlanes(); + + virtual + vtkIdType + GetNumberOfClippingPlanes(); + + virtual + bool + AddClippingPlane(vtkPlane* thePlane); + + virtual + vtkPlane* + GetClippingPlane(vtkIdType theID); + + //---------------------------------------------------------------------------- + virtual + void + SetLookupTable(VISU_LookupTable* theLookupTable); + + virtual + vtkPointSet* + GetClippedInput(); + + //---------------------------------------------------------------------------- + virtual + void + SetExtractInside(bool theMode); + + virtual + void + SetExtractBoundaryCells(bool theMode); + + + +protected: + //---------------------------------------------------------------------------- + VISU_ElnoMapperHolder(); + VISU_ElnoMapperHolder(const VISU_ElnoMapperHolder&); + + virtual + ~VISU_ElnoMapperHolder(); + + //---------------------------------------------------------------------------- + virtual + void + OnCreateMapper(); + +private: + //---------------------------------------------------------------------------- + VISU::PUnstructuredGridIDMapper myUnstructuredGridIDMapper; + vtkSmartPointer myElnoMapper; + vtkSmartPointer myPolyDataFilter; +}; + +#endif diff --git a/src/PIPELINE/VISU_ElnoScalarMapPL.cxx b/src/PIPELINE/VISU_ElnoScalarMapPL.cxx new file mode 100644 index 00000000..ed1d38ba --- /dev/null +++ b/src/PIPELINE/VISU_ElnoScalarMapPL.cxx @@ -0,0 +1,73 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_ElnoScalarMapPL.cxx +// Author: Roman NIKOLAEV +// Module : VISU + + +#include "VISU_ElnoScalarMapPL.hxx" +#include "VISU_ElnoMapperHolder.hxx" + + +#include +#include +#include + +//---------------------------------------------------------------------------- +vtkStandardNewMacro(VISU_ElnoScalarMapPL); + + +//---------------------------------------------------------------------------- +//Constructor +VISU_ElnoScalarMapPL::VISU_ElnoScalarMapPL(){ + SetIsShrinkable(true); +} + +//---------------------------------------------------------------------------- +VISU_ElnoScalarMapPL::~VISU_ElnoScalarMapPL() +{} + +//---------------------------------------------------------------------------- +unsigned long int VISU_ElnoScalarMapPL::GetMTime(){ + + unsigned long int aTime = Superclass::GetMTime(); + return aTime; +} + + +//---------------------------------------------------------------------------- +void VISU_ElnoScalarMapPL::OnCreateMapperHolder(){ + + myElnoMapperHolder = VISU_ElnoMapperHolder::New(); + myElnoMapperHolder->Delete(); + SetMapperHolder(myElnoMapperHolder.GetPointer()); +} + +//---------------------------------------------------------------------------- +void VISU_ElnoScalarMapPL::Build() +{ + + GetMapperHolder()->SetLookupTable(GetMapperTable()); + GetMapper()->SetUseLookupTableScalarRange(true); + GetMapper()->SetColorModeToMapScalars(); + GetMapper()->ScalarVisibilityOn(); +} diff --git a/src/PIPELINE/VISU_ElnoScalarMapPL.hxx b/src/PIPELINE/VISU_ElnoScalarMapPL.hxx new file mode 100644 index 00000000..91529f4e --- /dev/null +++ b/src/PIPELINE/VISU_ElnoScalarMapPL.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File: VISU_ElnoScalarMapPL.hxx +// Author: Roman NIKOLAEV +// Module : VISU + +#ifndef VISU_ElnoScalarMapPL_HeaderFile +#define VISU_ElnoScalarMapPL_HeaderFile + +#include "VISUPipeline.hxx" +#include "VISU_ColoredPL.hxx" + +class VISU_ElnoMapperHolder; + +class VISU_PIPELINE_EXPORT VISU_ElnoScalarMapPL : public VISU_ColoredPL +{ +public: + vtkTypeMacro(VISU_ElnoScalarMapPL, VISU_ColoredPL); + + static + VISU_ElnoScalarMapPL* New(); + + //---------------------------------------------------------------------------- + virtual unsigned long int GetMTime(); + +protected: + + //---------------------------------------------------------------------------- + VISU_ElnoScalarMapPL(); + + virtual ~VISU_ElnoScalarMapPL(); + + //---------------------------------------------------------------------------- + virtual void Build(); + + //---------------------------------------------------------------------------- + virtual void OnCreateMapperHolder(); + +private: + vtkSmartPointer myElnoMapperHolder; + + +private: + VISU_ElnoScalarMapPL(const VISU_ElnoScalarMapPL&); // Not implemented. + void operator=(const VISU_ElnoScalarMapPL&); // Not implemented. + +}; + + +#endif diff --git a/src/PIPELINE/VISU_OpenGLElnoMapper.cxx b/src/PIPELINE/VISU_OpenGLElnoMapper.cxx index ea210ae9..c6e14a24 100755 --- a/src/PIPELINE/VISU_OpenGLElnoMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLElnoMapper.cxx @@ -1,4 +1,5 @@ #include "VISU_OpenGLElnoMapper.hxx" +#include "VISU_ElnoGeometryFilter.hxx" #include "vtkCellArray.h" #include "vtkCellData.h" @@ -1920,7 +1921,7 @@ void VISU_OpenGLElnoMapper::PrintSelf(ostream& os, vtkIndent indent) //----------------------------------------------------------------------------- -/*template +template void CopyArray(TValueType* input,TValueType* output,vtkIdType theNbElem){ for(vtkIdType iTuple = 0; iTuple < theNbElem ; iTuple++){ @@ -1930,16 +1931,17 @@ void CopyArray(TValueType* input,TValueType* output,vtkIdType theNbElem){ } } -vtkDataArray* VISU_OpenGLElnoMapper::GetElnoScalars(int cellFlag){ +vtkDataArray* VISU_OpenGLElnoMapper::GetElnoScalars(){ - vtkDataArray *scalars = vtkAbstractMapper:: - GetScalars(this->GetInput(), this->ScalarMode, this->ArrayAccessMode, - this->ArrayId, this->ArrayName, cellFlag); + vtkDataArray *scalars = this->GetInput()->GetCellData()->GetArray("ELNO_PSEUDO_SCALARS"); + if(!scalars) + return NULL; + vtkIdType anInputDataType = scalars->GetDataType(); vtkDataArray *elnoScalars = vtkDataArray::CreateDataArray(anInputDataType); - vtkIdType aNbElnoTuples = VISU_ElnoExtractor::GetNbOfElnoTuples(this->GetInput()->GetCellData()); + vtkIdType aNbElnoTuples = VISU_ElnoGeometryFilter::GetNbOfElnoTuples(this->GetInput()->GetCellData()); elnoScalars->SetNumberOfComponents(1); elnoScalars->SetNumberOfTuples(aNbElnoTuples); @@ -1956,13 +1958,13 @@ vtkDataArray* VISU_OpenGLElnoMapper::GetElnoScalars(int cellFlag){ } return elnoScalars; - }*/ +} vtkUnsignedCharArray *VISU_OpenGLElnoMapper::MapScalars(double alpha) { int cellFlag = 0; - vtkDataArray *scalars = this->GetInput()->GetCellData()->GetArray("ELNO_PSEUDO_SCALARS"); + vtkDataArray *scalars = this->GetElnoScalars(); if(!scalars) return NULL; // This is for a legacy feature: selection of the array component to color by diff --git a/src/PIPELINE/VISU_OpenGLElnoMapper.hxx b/src/PIPELINE/VISU_OpenGLElnoMapper.hxx index be53c38d..b3de2999 100755 --- a/src/PIPELINE/VISU_OpenGLElnoMapper.hxx +++ b/src/PIPELINE/VISU_OpenGLElnoMapper.hxx @@ -92,8 +92,9 @@ protected: int ListId; vtkOpenGLTexture* InternalColorTexture; - // vtkDataArray* GetElnoScalars(int cellFlag); + vtkDataArray* GetElnoScalars(); vtkUnsignedCharArray* MapScalars(double alpha); + /*private: diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 64bab830..45ae809c 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -656,6 +656,11 @@ VisuGUI } +void VisuGUI::OnCreateElnoScalarMap() +{ + +} + void VisuGUI ::OnCreateDeformedShape() @@ -2080,6 +2085,11 @@ VisuGUI tr("MEN_SCALAR_MAP"), "", 0, aParent, false, this, SLOT(OnCreateScalarMap())); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ELNO_SCALARMAP")); + createAction( VISU_ELNO_SCALARMAP, tr("MEN_ELNO_SCALARMAP"),QIconSet(aPixmap), + tr("MEN_ELNO_SCALARMAP"), "", 0, aParent, false, + this, SLOT(OnCreateElnoScararMap())); + aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE")); createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap), tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false, diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 2d6370b6..146f77f6 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -95,6 +95,7 @@ protected slots: void OnCreateMesh(); void OnCreateScalarMap(); + void OnCreateElnoScalarMap(); void OnCreateDeformedShape(); void OnCreateVectors(); void OnCreateIsoSurfaces(); diff --git a/src/VISUGUI/VisuGUI_ActionsDef.h b/src/VISUGUI/VisuGUI_ActionsDef.h index d69d1c46..41cbfef0 100644 --- a/src/VISUGUI/VisuGUI_ActionsDef.h +++ b/src/VISUGUI/VisuGUI_ActionsDef.h @@ -40,6 +40,7 @@ #define VISU_PLOT2D 4018 #define VISU_PLOT_3D 4019 #define VISU_SCALAR_MAP_ON_DEFORMED_SHAPE 40110 +#define VISU_ELNO_SCALARMAP 40111 //#define VISU_DELETE 4021 #define VISU_DELETE_OBJS 4022 @@ -93,6 +94,7 @@ #define VISU_EDIT_STREAMLINES 40626 #define VISU_EDIT_PLOT3D 40627 #define VISU_EDIT_SCALARMAPONDEFORMEDSHAPE 40628 +#define VISU_EDIT_ELNOSCALAR_MAP 40629 #define VISU_EDIT_PRS 4062 #define VISU_CREATE_TABLE 4063