X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FOBJECT%2FSMESH_DeviceActor.cxx;h=aeba34ad97d1ed7c87277dc2227842e659864a2d;hp=a1d8edf752d5f87625bfacd09802efac143b308b;hb=7a65c9fad427b1ccba6b9ccae612296e5092a324;hpb=8608b2b5ca86779ae0b3c42239cb83f8eebf68e2 diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index a1d8edf75..aeba34ad9 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -297,7 +297,7 @@ SMESH_DeviceActor SMESH_ScalarBarActor* theScalarBarActor, vtkLookupTable* theLookupTable) { - bool anIsInitialized = theFunctor; + bool anIsInitialized = theFunctor != NULL; if(anIsInitialized){ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); @@ -363,7 +363,7 @@ SMESH_DeviceActor SMESH_ScalarBarActor* theScalarBarActor, vtkLookupTable* theLookupTable) { - bool anIsInitialized = theFunctor; + bool anIsInitialized = theFunctor != NULL; myExtractUnstructuredGrid->ClearRegisteredCells(); myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll); @@ -393,12 +393,13 @@ SMESH_DeviceActor vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); aCellTypesArray->SetNumberOfComponents( 1 ); aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); - + vtkIdList *anIdList = vtkIdList::New(); anIdList->SetNumberOfIds(2); - + Length2D::TValues::const_iterator anIter = aValues.begin(); - for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){ + aNbCells = 0; + for(; anIter != aValues.end(); anIter++){ const Length2D::Value& aValue = *anIter; int aNode[2] = { myVisualObj->GetNodeVTKId(aValue.myPntId[0]), @@ -409,27 +410,30 @@ SMESH_DeviceActor anIdList->SetId( 1, aNode[1] ); aConnectivity->InsertNextCell( anIdList ); aCellTypesArray->InsertNextValue( VTK_LINE ); - aScalars->SetValue(aVtkId,aValue.myLength); + aScalars->SetValue(aNbCells,aValue.myLength); + aNbCells++; } } - + aCellTypesArray->SetNumberOfTuples( aNbCells ); + aScalars->SetNumberOfTuples( aNbCells ); + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); aCellLocationsArray->SetNumberOfComponents( 1 ); aCellLocationsArray->SetNumberOfTuples( aNbCells ); - + aConnectivity->InitTraversal(); for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); - - aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); + + aDataSet->SetCells( aCellTypesArray, aCellLocationsArray, aConnectivity ); SetUnstructuredGrid(aDataSet); aDataSet->GetCellData()->SetScalars(aScalars); aScalars->Delete(); - + theLookupTable->SetRange(aScalars->GetRange()); theLookupTable->Build(); - + myMergeFilter->SetScalarsData(aDataSet); aDataSet->Delete(); } @@ -449,16 +453,17 @@ SMESH_DeviceActor vtkIdType aCellsSize = 3*aNbCells; vtkCellArray* aConnectivity = vtkCellArray::New(); aConnectivity->Allocate( aCellsSize, 0 ); - + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); aCellTypesArray->SetNumberOfComponents( 1 ); aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); - + vtkIdList *anIdList = vtkIdList::New(); anIdList->SetNumberOfIds(2); - + MultiConnection2D::MValues::const_iterator anIter = aValues.begin(); - for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){ + aNbCells = 0; + for(; anIter != aValues.end(); anIter++){ const MultiConnection2D::Value& aValue = (*anIter).first; int aNode[2] = { myVisualObj->GetNodeVTKId(aValue.myPntId[0]), @@ -469,27 +474,30 @@ SMESH_DeviceActor anIdList->SetId( 1, aNode[1] ); aConnectivity->InsertNextCell( anIdList ); aCellTypesArray->InsertNextValue( VTK_LINE ); - aScalars->SetValue(aVtkId,(*anIter).second); + aScalars->SetValue( aNbCells,(*anIter).second); + aNbCells++; } } - + aCellTypesArray->SetNumberOfTuples( aNbCells ); + aScalars->SetNumberOfTuples( aNbCells ); + VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New(); aCellLocationsArray->SetNumberOfComponents( 1 ); aCellLocationsArray->SetNumberOfTuples( aNbCells ); - + aConnectivity->InitTraversal(); for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); - + aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); SetUnstructuredGrid(aDataSet); aDataSet->GetCellData()->SetScalars(aScalars); aScalars->Delete(); - + theLookupTable->SetRange(aScalars->GetRange()); theLookupTable->Build(); - + myMergeFilter->SetScalarsData(aDataSet); aDataSet->Delete(); } @@ -508,17 +516,17 @@ SMESH_DeviceActor myVisualObj->UpdateFunctor(theFunctor); using namespace SMESH::Controls; - if ( dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get())) + Predicate* aPredicate = 0; + if (( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get()))) { - Predicate* aPredicate = dynamic_cast(theFunctor.get()); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); @@ -580,10 +588,9 @@ SMESH_DeviceActor SetUnstructuredGrid(aDataSet); aDataSet->Delete(); } - else if(dynamic_cast(theFunctor.get()) || - dynamic_cast(theFunctor.get())) + else if (( aPredicate = dynamic_cast(theFunctor.get())) || + ( aPredicate = dynamic_cast(theFunctor.get()))) { - Predicate* aPredicate = dynamic_cast(theFunctor.get()); myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding); vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node); for( vtkIdType i = 0; i < aNbNodes; i++ ){ @@ -961,9 +968,9 @@ void SMESH_DeviceActor::SetBallEnabled( bool theBallEnabled ) { /*! * Set point marker scale factor - * \param theBallScale integer value which specifies a scale factor of ball element + * \param theBallScale double value which specifies a scale factor of ball element */ -void SMESH_DeviceActor::SetBallScale( int theBallScale ) +void SMESH_DeviceActor::SetBallScale( double theBallScale ) { myMapper->SetBallScale( theBallScale ); myMapper->Modified(); @@ -1019,7 +1026,7 @@ int SMESH_DeviceActor::GetMarkerTexture() * Get scale factor of ball element * \return scale factor of ball element */ -int SMESH_DeviceActor::GetBallScale() +double SMESH_DeviceActor::GetBallScale() { return myMapper->GetBallScale(); }