1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH OBJECT : interactive object for SMESH visualization
24 // File : SMESH_DeviceActor.cxx
28 #include "SMESH_DeviceActor.h"
29 #include "SMESH_ScalarBarActor.h"
30 #include "SMESH_ExtractGeometry.h"
31 #include "SMESH_ControlsDef.hxx"
32 #include "SMESH_ActorUtils.h"
33 #include "SMESH_FaceOrientationFilter.h"
34 #include "VTKViewer_CellLocationsArray.h"
35 #include "VTKViewer_PolyDataMapper.h"
37 #include <VTKViewer_Transform.h>
38 #include <VTKViewer_TransformFilter.h>
39 #include <VTKViewer_ExtractUnstructuredGrid.h>
42 #include <vtkObjectFactory.h>
43 #include <vtkShrinkFilter.h>
44 #include <vtkShrinkPolyData.h>
46 #include <vtkProperty.h>
47 #include <vtkPolyData.h>
48 #include <vtkMergeFilter.h>
49 #include <vtkPolyDataMapper.h>
50 #include <vtkUnstructuredGrid.h>
52 #include <vtkLookupTable.h>
53 #include <vtkDoubleArray.h>
54 #include <vtkCellData.h>
57 #include <vtkIdList.h>
58 #include <vtkCellArray.h>
59 #include <vtkUnsignedCharArray.h>
61 #include <vtkImplicitBoolean.h>
62 #include <vtkPassThroughFilter.h>
64 #include <vtkRenderer.h>
66 #include "utilities.h"
69 static int MYDEBUG = 0;
71 static int MYDEBUG = 0;
77 vtkStandardNewMacro(SMESH_DeviceActor);
83 if(MYDEBUG) MESSAGE("SMESH_DeviceActor - "<<this);
85 myIsShrinkable = false;
87 myIsHighlited = false;
89 myRepresentation = eSurface;
91 myProperty = vtkProperty::New();
92 myMapper = VTKViewer_PolyDataMapper::New();
94 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
95 myPolygonOffsetUnits);
97 myMapper->UseLookupTableScalarRangeOn();
98 myMapper->SetColorModeToMapScalars();
100 myShrinkFilter = vtkShrinkFilter::New();
102 myStoreClippingMapping = false;
104 myExtractGeometry = SMESH_ExtractGeometry::New();
105 myExtractGeometry->SetReleaseDataFlag(true);
106 myIsImplicitFunctionUsed = false;
108 myExtractUnstructuredGrid = VTKViewer_ExtractUnstructuredGrid::New();
110 myMergeFilter = vtkMergeFilter::New();
112 myGeomFilter = VTKViewer_GeometryFilter::New();
114 myTransformFilter = VTKViewer_TransformFilter::New();
116 for(int i = 0; i < 6; i++)
117 myPassFilter.push_back(vtkPassThroughFilter::New());
119 // Orientation of faces
120 myIsFacesOriented = false;
122 vtkFloatingPointType anRGB[3] = { 1, 1, 1 };
123 SMESH::GetColor( "SMESH", "orientation_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) );
125 myFaceOrientationFilter = SMESH_FaceOrientationFilter::New();
127 myFaceOrientationDataMapper = vtkPolyDataMapper::New();
128 myFaceOrientationDataMapper->SetInput(myFaceOrientationFilter->GetOutput());
130 myFaceOrientation = vtkActor::New();
131 myFaceOrientation->SetMapper(myFaceOrientationDataMapper);
132 myFaceOrientation->GetProperty()->SetColor(anRGB[0], anRGB[1], anRGB[2]);
137 ::~SMESH_DeviceActor()
139 if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
143 myProperty->Delete();
145 myExtractGeometry->Delete();
147 myMergeFilter->Delete();
148 myExtractUnstructuredGrid->Delete();
150 // Orientation of faces
151 myFaceOrientationFilter->Delete();
152 myFaceOrientationDataMapper->RemoveAllInputs();
153 myFaceOrientationDataMapper->Delete();
154 myFaceOrientation->Delete();
156 myGeomFilter->Delete();
158 myTransformFilter->Delete();
160 for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
161 myPassFilter[i]->Delete();
163 myShrinkFilter->Delete();
169 ::SetStoreGemetryMapping(bool theStoreMapping)
171 myGeomFilter->SetStoreMapping(theStoreMapping);
172 SetStoreClippingMapping(theStoreMapping);
178 ::SetStoreClippingMapping(bool theStoreMapping)
180 myStoreClippingMapping = theStoreMapping;
181 myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
182 SetStoreIDMapping(theStoreMapping);
188 ::SetStoreIDMapping(bool theStoreMapping)
190 myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
196 ::Init(TVisualObjPtr theVisualObj,
197 vtkImplicitBoolean* theImplicitBoolean)
199 myVisualObj = theVisualObj;
200 myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
201 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
207 ::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
210 if(theIsImplicitFunctionUsed)
211 myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
213 myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
215 myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
216 SetStoreClippingMapping(myStoreClippingMapping);
222 ::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
225 //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
226 myIsShrinkable = true;
228 myExtractUnstructuredGrid->SetInput(theGrid);
230 myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());
232 myExtractGeometry->SetInput(myMergeFilter->GetOutput());
235 SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
236 myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
239 myTransformFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
242 myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
243 myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
246 myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
249 myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() );
250 myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
253 myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
255 vtkLODActor::SetMapper( myMapper );
261 VTKViewer_ExtractUnstructuredGrid*
263 ::GetExtractUnstructuredGrid()
265 return myExtractUnstructuredGrid;
271 ::GetUnstructuredGrid()
273 myExtractUnstructuredGrid->Update();
274 return myExtractUnstructuredGrid->GetOutput();
280 ::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
281 SMESH_ScalarBarActor* theScalarBarActor,
282 vtkLookupTable* theLookupTable)
284 bool anIsInitialized = theFunctor;
286 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
288 SetStoreIDMapping(true);
289 myExtractUnstructuredGrid->Update();
290 vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
292 aDataSet->ShallowCopy(aGrid);
294 vtkDoubleArray *aScalars = vtkDoubleArray::New();
295 vtkIdType aNbCells = aGrid->GetNumberOfCells();
296 aScalars->SetNumberOfComponents(1);
297 aScalars->SetNumberOfTuples(aNbCells);
299 myVisualObj->UpdateFunctor(theFunctor);
301 using namespace SMESH::Controls;
302 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){
303 for(vtkIdType i = 0; i < aNbCells; i++){
304 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
305 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
306 double aValue = aNumericalFunctor->GetValue(anObjId);
307 aScalars->SetValue(i,aValue);
309 }else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get())){
310 for(vtkIdType i = 0; i < aNbCells; i++){
311 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
312 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
313 bool aValue = aPredicate->IsSatisfy(anObjId);
314 aScalars->SetValue(i,aValue);
318 aDataSet->GetCellData()->SetScalars(aScalars);
321 theLookupTable->SetRange(aScalars->GetRange());
322 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
323 theLookupTable->Build();
325 myMergeFilter->SetScalars(aDataSet);
328 GetMapper()->SetScalarVisibility(anIsInitialized);
329 theScalarBarActor->SetVisibility(anIsInitialized);
334 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
335 SMESH_ScalarBarActor* theScalarBarActor,
336 vtkLookupTable* theLookupTable)
338 bool anIsInitialized = theFunctor;
339 myExtractUnstructuredGrid->ClearRegisteredCells();
340 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
341 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
342 myVisualObj->UpdateFunctor(theFunctor);
344 using namespace SMESH::Controls;
345 if (anIsInitialized){
346 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
347 SMESH::Controls::Length2D::TValues aValues;
349 aLength2D->GetValues(aValues);
350 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
351 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
353 aDataSet->SetPoints(aGrid->GetPoints());
355 vtkIdType aNbCells = aValues.size();
357 vtkDoubleArray *aScalars = vtkDoubleArray::New();
358 aScalars->SetNumberOfComponents(1);
359 aScalars->SetNumberOfTuples(aNbCells);
361 vtkIdType aCellsSize = 3*aNbCells;
362 vtkCellArray* aConnectivity = vtkCellArray::New();
363 aConnectivity->Allocate( aCellsSize, 0 );
365 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
366 aCellTypesArray->SetNumberOfComponents( 1 );
367 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
369 vtkIdList *anIdList = vtkIdList::New();
370 anIdList->SetNumberOfIds(2);
372 Length2D::TValues::const_iterator anIter = aValues.begin();
373 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
374 const Length2D::Value& aValue = *anIter;
376 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
377 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
379 if(aNode[0] >= 0 && aNode[1] >= 0){
380 anIdList->SetId( 0, aNode[0] );
381 anIdList->SetId( 1, aNode[1] );
382 aConnectivity->InsertNextCell( anIdList );
383 aCellTypesArray->InsertNextValue( VTK_LINE );
384 aScalars->SetValue(aVtkId,aValue.myLength);
388 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
389 aCellLocationsArray->SetNumberOfComponents( 1 );
390 aCellLocationsArray->SetNumberOfTuples( aNbCells );
392 aConnectivity->InitTraversal();
393 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
394 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
396 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
397 SetUnstructuredGrid(aDataSet);
399 aDataSet->GetCellData()->SetScalars(aScalars);
402 theLookupTable->SetRange(aScalars->GetRange());
403 theLookupTable->Build();
405 myMergeFilter->SetScalars(aDataSet);
408 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
409 SMESH::Controls::MultiConnection2D::MValues aValues;
411 aMultiConnection2D->GetValues(aValues);
412 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
413 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
414 aDataSet->SetPoints(aGrid->GetPoints());
416 vtkIdType aNbCells = aValues.size();
417 vtkDoubleArray *aScalars = vtkDoubleArray::New();
418 aScalars->SetNumberOfComponents(1);
419 aScalars->SetNumberOfTuples(aNbCells);
421 vtkIdType aCellsSize = 3*aNbCells;
422 vtkCellArray* aConnectivity = vtkCellArray::New();
423 aConnectivity->Allocate( aCellsSize, 0 );
425 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
426 aCellTypesArray->SetNumberOfComponents( 1 );
427 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
429 vtkIdList *anIdList = vtkIdList::New();
430 anIdList->SetNumberOfIds(2);
432 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
433 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
434 const MultiConnection2D::Value& aValue = (*anIter).first;
436 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
437 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
439 if(aNode[0] >= 0 && aNode[1] >= 0){
440 anIdList->SetId( 0, aNode[0] );
441 anIdList->SetId( 1, aNode[1] );
442 aConnectivity->InsertNextCell( anIdList );
443 aCellTypesArray->InsertNextValue( VTK_LINE );
444 aScalars->SetValue(aVtkId,(*anIter).second);
448 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
449 aCellLocationsArray->SetNumberOfComponents( 1 );
450 aCellLocationsArray->SetNumberOfTuples( aNbCells );
452 aConnectivity->InitTraversal();
453 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
454 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
456 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
457 SetUnstructuredGrid(aDataSet);
459 aDataSet->GetCellData()->SetScalars(aScalars);
462 theLookupTable->SetRange(aScalars->GetRange());
463 theLookupTable->Build();
465 myMergeFilter->SetScalars(aDataSet);
469 GetMapper()->SetScalarVisibility(anIsInitialized);
470 theScalarBarActor->SetVisibility(anIsInitialized);
475 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
477 myExtractUnstructuredGrid->ClearRegisteredCells();
478 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
479 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
480 myVisualObj->UpdateFunctor(theFunctor);
482 using namespace SMESH::Controls;
483 if ( dynamic_cast<FreeBorders *>(theFunctor.get()) ||
484 dynamic_cast<FreeFaces *>(theFunctor.get()) ||
485 dynamic_cast<BareBorderVolume *>(theFunctor.get()) ||
486 dynamic_cast<BareBorderFace *>(theFunctor.get()) ||
487 dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
488 dynamic_cast<CoincidentElements1D *>(theFunctor.get()) ||
489 dynamic_cast<CoincidentElements2D *>(theFunctor.get()) ||
490 dynamic_cast<CoincidentElements3D *>(theFunctor.get()) ||
491 dynamic_cast<OverConstrainedFace *>(theFunctor.get()))
493 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
494 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
495 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
496 vtkIdType aNbCells = aGrid->GetNumberOfCells();
497 for( vtkIdType i = 0; i < aNbCells; i++ ){
498 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
499 if(aPredicate->IsSatisfy(anObjId))
500 myExtractUnstructuredGrid->RegisterCell(i);
502 if(!myExtractUnstructuredGrid->IsCellsRegistered())
503 myExtractUnstructuredGrid->RegisterCell(-1);
504 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
506 else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
508 SMESH::Controls::FreeEdges::TBorders aBorders;
509 aFreeEdges->GetBoreders(aBorders);
510 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
511 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
512 aDataSet->SetPoints(aGrid->GetPoints());
514 vtkIdType aNbCells = aBorders.size();
515 vtkIdType aCellsSize = 3*aNbCells;
516 vtkCellArray* aConnectivity = vtkCellArray::New();
517 aConnectivity->Allocate( aCellsSize, 0 );
519 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
520 aCellTypesArray->SetNumberOfComponents( 1 );
521 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
523 vtkIdList *anIdList = vtkIdList::New();
524 anIdList->SetNumberOfIds(2);
526 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
527 for(; anIter != aBorders.end(); anIter++){
528 const FreeEdges::Border& aBorder = *anIter;
530 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
531 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
533 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
534 if(aNode[0] >= 0 && aNode[1] >= 0){
535 anIdList->SetId( 0, aNode[0] );
536 anIdList->SetId( 1, aNode[1] );
537 aConnectivity->InsertNextCell( anIdList );
538 aCellTypesArray->InsertNextValue( VTK_LINE );
542 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
543 aCellLocationsArray->SetNumberOfComponents( 1 );
544 aCellLocationsArray->SetNumberOfTuples( aNbCells );
546 aConnectivity->InitTraversal();
547 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
548 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
550 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
552 SetUnstructuredGrid(aDataSet);
555 else if(dynamic_cast<FreeNodes *>(theFunctor.get()) ||
556 dynamic_cast<CoincidentNodes*>(theFunctor.get()))
558 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
559 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
560 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
561 for( vtkIdType i = 0; i < aNbNodes; i++ ){
562 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
563 if(aPredicate->IsSatisfy(anObjId))
564 myExtractUnstructuredGrid->RegisterCell(i);
566 if(!myExtractUnstructuredGrid->IsCellsRegistered())
567 myExtractUnstructuredGrid->RegisterCell(-1);
568 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
579 unsigned long mTime = this->Superclass::GetMTime();
580 mTime = max(mTime,myExtractGeometry->GetMTime());
581 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
582 mTime = max(mTime,myMergeFilter->GetMTime());
583 mTime = max(mTime,myGeomFilter->GetMTime());
584 mTime = max(mTime,myTransformFilter->GetMTime());
585 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
592 ::SetTransform(VTKViewer_Transform* theTransform)
594 myTransformFilter->SetTransform(theTransform);
602 if ( !myIsShrinkable ) return;
603 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
605 myShrinkFilter->SetInput( aDataSet );
606 myPassFilter[ 1 ]->SetInput( myShrinkFilter->GetOutput() );
615 if ( !myIsShrunk ) return;
616 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
618 myPassFilter[ 1 ]->SetInput( aDataSet );
619 myPassFilter[ 1 ]->Modified();
628 ::SetFacesOriented(bool theIsFacesOriented)
630 if ( vtkDataSet* aDataSet = myTransformFilter->GetOutput() )
632 myIsFacesOriented = theIsFacesOriented;
633 if( theIsFacesOriented )
634 myFaceOrientationFilter->SetInput( aDataSet );
635 UpdateFaceOrientation();
641 ::SetFacesOrientationColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
643 myFaceOrientation->GetProperty()->SetColor( r, g, b );
648 ::GetFacesOrientationColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
650 myFaceOrientation->GetProperty()->GetColor( r, g, b );
655 ::SetFacesOrientationScale(vtkFloatingPointType theScale)
657 myFaceOrientationFilter->SetOrientationScale( theScale );
662 ::GetFacesOrientationScale()
664 return myFaceOrientationFilter->GetOrientationScale();
669 ::SetFacesOrientation3DVectors(bool theState)
671 myFaceOrientationFilter->Set3dVectors( theState );
676 ::GetFacesOrientation3DVectors()
678 return myFaceOrientationFilter->Get3dVectors();
683 ::UpdateFaceOrientation()
685 bool aShowFaceOrientation = myIsFacesOriented;
686 aShowFaceOrientation &= GetVisibility();
687 aShowFaceOrientation &= myRepresentation == eSurface;
688 myFaceOrientation->SetVisibility(aShowFaceOrientation);
694 ::SetRepresentation(EReperesent theMode)
698 myGeomFilter->SetInside(true);
699 myGeomFilter->SetWireframeMode(false);
700 GetProperty()->SetRepresentation(0);
703 myGeomFilter->SetInside(false);
704 myGeomFilter->SetWireframeMode(true);
705 GetProperty()->SetRepresentation(theMode);
708 myGeomFilter->SetInside(true);
709 myGeomFilter->SetWireframeMode(true);
710 GetProperty()->SetRepresentation(1);
713 myGeomFilter->SetInside(false);
714 myGeomFilter->SetWireframeMode(false);
715 GetProperty()->SetRepresentation(theMode);
717 SetMarkerEnabled(theMode == ePoint);
718 myRepresentation = theMode;
719 UpdateFaceOrientation();
720 GetProperty()->Modified();
721 myMapper->Modified();
728 ::SetVisibility(int theMode)
730 if(!myExtractUnstructuredGrid->GetInput() ||
731 GetUnstructuredGrid()->GetNumberOfCells())
733 vtkLODActor::SetVisibility(theMode);
735 vtkLODActor::SetVisibility(false);
737 UpdateFaceOrientation();
745 if(!GetUnstructuredGrid()->GetNumberOfCells()){
746 vtkLODActor::SetVisibility(false);
748 return vtkLODActor::GetVisibility();
754 ::AddToRender(vtkRenderer* theRenderer)
756 theRenderer->AddActor(this);
757 theRenderer->AddActor(myFaceOrientation);
762 ::RemoveFromRender(vtkRenderer* theRenderer)
764 theRenderer->RemoveActor(this);
765 theRenderer->RemoveActor(myFaceOrientation);
771 ::GetNodeObjId(int theVtkID)
773 vtkIdType anID = theVtkID;
775 if(IsImplicitFunctionUsed())
776 anID = myExtractGeometry->GetNodeObjId(theVtkID);
778 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
779 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
783 vtkFloatingPointType*
785 ::GetNodeCoord(int theObjID)
787 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
788 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
789 vtkFloatingPointType* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
790 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
797 ::GetElemObjId(int theVtkID)
799 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
803 vtkIdType anId2 = anId;
804 if(IsImplicitFunctionUsed())
805 anId2 = myExtractGeometry->GetElemObjId(anId);
809 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
813 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
815 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
821 ::GetElemCell(int theObjID)
823 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
824 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
825 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
827 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
836 return myShrinkFilter->GetShrinkFactor();
841 ::SetShrinkFactor(vtkFloatingPointType theValue)
843 theValue = theValue > 0.1? theValue: 0.8;
844 myShrinkFilter->SetShrinkFactor(theValue);
851 ::SetHighlited(bool theIsHighlited)
853 if ( myIsHighlited == theIsHighlited )
855 myIsHighlited = theIsHighlited;
861 ::Render(vtkRenderer *ren, vtkMapper* m)
863 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
864 vtkFloatingPointType aStoredFactor, aStoredUnit;
865 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
867 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
868 vtkFloatingPointType aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
870 static vtkFloatingPointType EPS = .01;
873 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
874 vtkLODActor::Render(ren,m);
876 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
877 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
883 ::SetPolygonOffsetParameters(vtkFloatingPointType factor,
884 vtkFloatingPointType units)
886 myPolygonOffsetFactor = factor;
887 myPolygonOffsetUnits = units;
891 * On/Off representation 2D quadratic element as arked polygon
893 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
894 myGeomFilter->SetQuadraticArcMode(theFlag);
898 * Return true if 2D quadratic element displayed as arked polygon
900 bool SMESH_DeviceActor::GetQuadraticArcMode(){
901 return myGeomFilter->GetQuadraticArcMode();
904 * Set Max angle for representation 2D quadratic element as arked polygon
906 void SMESH_DeviceActor::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle){
907 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
911 * Return Max angle of the representation 2D quadratic element as arked polygon
913 vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle(){
914 return myGeomFilter->GetQuadraticArcAngle();
918 * Set point marker enabled
919 * \param theMarkerEnabled flag to enable/disable point marker
921 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
923 myMapper->SetMarkerEnabled( theMarkerEnabled );
927 * Set standard point marker
928 * \param theMarkerType type of the marker
930 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
932 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
936 * Set custom point marker
937 * \param theMarkerId id of the marker texture
938 * \param theMarkerTexture marker texture
940 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
942 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
946 * Get type of the point marker
947 * \return type of the point marker
949 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
951 return myMapper->GetMarkerType();
955 Get scale of the point marker
956 \return scale of the point marker
958 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
960 return myMapper->GetMarkerScale();
964 * Get texture identifier of the point marker
965 * \return texture identifier of the point marker
967 int SMESH_DeviceActor::GetMarkerTexture()
969 return myMapper->GetMarkerTexture();
972 void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
973 myGeomFilter->SetAppendCoincident3D(theFlag);
976 bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
977 return myGeomFilter->GetAppendCoincident3D();