+void
+SMESH_DeviceActor
+::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
+ SMESH_ScalarBarActor* theScalarBarActor,
+ vtkLookupTable* theLookupTable)
+{
+ bool anIsInitialized = theFunctor;
+ myExtractUnstructuredGrid->ClearRegisteredCells();
+ myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
+ myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
+ myVisualObj->UpdateFunctor(theFunctor);
+
+ using namespace SMESH::Controls;
+ if (anIsInitialized){
+ if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
+ SMESH::Controls::Length2D::TValues aValues;
+
+ aLength2D->GetValues(aValues);
+ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+ vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+
+ aDataSet->SetPoints(aGrid->GetPoints());
+
+ vtkIdType aNbCells = aValues.size();
+
+ vtkDoubleArray *aScalars = vtkDoubleArray::New();
+ aScalars->SetNumberOfComponents(1);
+ aScalars->SetNumberOfTuples(aNbCells);
+
+ 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);
+
+ Length2D::TValues::const_iterator anIter = aValues.begin();
+ aNbCells = 0;
+ for(; anIter != aValues.end(); anIter++){
+ const Length2D::Value& aValue = *anIter;
+ int aNode[2] = {
+ myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
+ myVisualObj->GetNodeVTKId(aValue.myPntId[1])
+ };
+ if(aNode[0] >= 0 && aNode[1] >= 0){
+ anIdList->SetId( 0, aNode[0] );
+ anIdList->SetId( 1, aNode[1] );
+ aConnectivity->InsertNextCell( anIdList );
+ aCellTypesArray->InsertNextValue( VTK_LINE );
+ 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 );
+ SetUnstructuredGrid(aDataSet);
+
+ aDataSet->GetCellData()->SetScalars(aScalars);
+ aScalars->Delete();
+
+ theLookupTable->SetRange(aScalars->GetRange());
+ theLookupTable->Build();
+
+ myMergeFilter->SetScalarsData(aDataSet);
+ aDataSet->Delete();
+ }
+ else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
+ SMESH::Controls::MultiConnection2D::MValues aValues;
+
+ aMultiConnection2D->GetValues(aValues);
+ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+ vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+ aDataSet->SetPoints(aGrid->GetPoints());
+
+ vtkIdType aNbCells = aValues.size();
+ vtkDoubleArray *aScalars = vtkDoubleArray::New();
+ aScalars->SetNumberOfComponents(1);
+ aScalars->SetNumberOfTuples(aNbCells);
+
+ 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();
+ aNbCells = 0;
+ for(; anIter != aValues.end(); anIter++){
+ const MultiConnection2D::Value& aValue = (*anIter).first;
+ int aNode[2] = {
+ myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
+ myVisualObj->GetNodeVTKId(aValue.myPntId[1])
+ };
+ if(aNode[0] >= 0 && aNode[1] >= 0){
+ anIdList->SetId( 0, aNode[0] );
+ anIdList->SetId( 1, aNode[1] );
+ aConnectivity->InsertNextCell( anIdList );
+ aCellTypesArray->InsertNextValue( VTK_LINE );
+ 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();
+ }
+ }
+ GetMapper()->SetScalarVisibility(anIsInitialized);
+ theScalarBarActor->SetVisibility(anIsInitialized);
+}
+
+void
+SMESH_DeviceActor
+::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
+{
+ myExtractUnstructuredGrid->ClearRegisteredCells();
+ myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
+ myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
+ myVisualObj->UpdateFunctor(theFunctor);
+
+ using namespace SMESH::Controls;
+ Predicate* aPredicate = 0;
+ if (( aPredicate = dynamic_cast<FreeBorders *>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<FreeFaces *>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<BareBorderVolume *>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<BareBorderFace *>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<OverConstrainedVolume*>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<CoincidentElements1D *>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<CoincidentElements2D *>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<CoincidentElements3D *>(theFunctor.get())) ||
+ ( aPredicate = dynamic_cast<OverConstrainedFace *>(theFunctor.get())))
+ {
+ myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
+ vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+ vtkIdType aNbCells = aGrid->GetNumberOfCells();
+ for( vtkIdType i = 0; i < aNbCells; i++ ){
+ vtkIdType anObjId = myVisualObj->GetElemObjId(i);
+ if(aPredicate->IsSatisfy(anObjId))
+ myExtractUnstructuredGrid->RegisterCell(i);
+ }
+ if(!myExtractUnstructuredGrid->IsCellsRegistered())
+ myExtractUnstructuredGrid->RegisterCell(-1);
+ SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
+ }
+ else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
+ {
+ SMESH::Controls::FreeEdges::TBorders aBorders;
+ aFreeEdges->GetBoreders(aBorders);
+ vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
+ vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
+ aDataSet->SetPoints(aGrid->GetPoints());
+
+ vtkIdType aNbCells = aBorders.size();
+ 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);
+
+ FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
+ for(; anIter != aBorders.end(); anIter++){
+ const FreeEdges::Border& aBorder = *anIter;
+ int aNode[2] = {
+ myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
+ myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
+ };
+ //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
+ if(aNode[0] >= 0 && aNode[1] >= 0){
+ anIdList->SetId( 0, aNode[0] );
+ anIdList->SetId( 1, aNode[1] );
+ aConnectivity->InsertNextCell( anIdList );
+ aCellTypesArray->InsertNextValue( VTK_LINE );
+ }
+ }
+
+ 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 );