1 // Copyright (C) 2007-2010 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);
141 myProperty->Delete();
145 myShrinkFilter->Delete();
147 myExtractUnstructuredGrid->Delete();
149 myMergeFilter->Delete();
151 myGeomFilter->Delete();
153 myExtractGeometry->Delete();
155 myTransformFilter->Delete();
157 for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
158 myPassFilter[i]->Delete();
161 // Orientation of faces
162 myFaceOrientationFilter->Delete();
164 myFaceOrientationDataMapper->RemoveAllInputs();
165 myFaceOrientationDataMapper->Delete();
167 myFaceOrientation->Delete();
173 ::SetStoreGemetryMapping(bool theStoreMapping)
175 myGeomFilter->SetStoreMapping(theStoreMapping);
176 SetStoreClippingMapping(theStoreMapping);
182 ::SetStoreClippingMapping(bool theStoreMapping)
184 myStoreClippingMapping = theStoreMapping;
185 myExtractGeometry->SetStoreMapping(theStoreMapping && myIsImplicitFunctionUsed);
186 SetStoreIDMapping(theStoreMapping);
192 ::SetStoreIDMapping(bool theStoreMapping)
194 myExtractUnstructuredGrid->SetStoreMapping(theStoreMapping);
200 ::Init(TVisualObjPtr theVisualObj,
201 vtkImplicitBoolean* theImplicitBoolean)
203 myVisualObj = theVisualObj;
204 myExtractGeometry->SetImplicitFunction(theImplicitBoolean);
205 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
211 ::SetImplicitFunctionUsed(bool theIsImplicitFunctionUsed)
214 if(theIsImplicitFunctionUsed)
215 myPassFilter[ anId ]->SetInput( myExtractGeometry->GetOutput() );
217 myPassFilter[ anId ]->SetInput( myMergeFilter->GetOutput() );
219 myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
220 SetStoreClippingMapping(myStoreClippingMapping);
226 ::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
229 //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
230 myIsShrinkable = true;
232 myExtractUnstructuredGrid->SetInput(theGrid);
234 myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput());
236 myExtractGeometry->SetInput(myMergeFilter->GetOutput());
239 SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
240 myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
243 myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
246 myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() );
247 myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
250 myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
253 myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
254 myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
257 myMapper->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
259 vtkLODActor::SetMapper( myMapper );
265 VTKViewer_ExtractUnstructuredGrid*
267 ::GetExtractUnstructuredGrid()
269 return myExtractUnstructuredGrid;
275 ::GetUnstructuredGrid()
277 myExtractUnstructuredGrid->Update();
278 return myExtractUnstructuredGrid->GetOutput();
284 ::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
285 SMESH_ScalarBarActor* theScalarBarActor,
286 vtkLookupTable* theLookupTable)
288 bool anIsInitialized = theFunctor;
290 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
292 SetStoreIDMapping(true);
293 myExtractUnstructuredGrid->Update();
294 vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
296 aDataSet->ShallowCopy(aGrid);
298 vtkDoubleArray *aScalars = vtkDoubleArray::New();
299 vtkIdType aNbCells = aGrid->GetNumberOfCells();
300 aScalars->SetNumberOfComponents(1);
301 aScalars->SetNumberOfTuples(aNbCells);
303 myVisualObj->UpdateFunctor(theFunctor);
305 using namespace SMESH::Controls;
306 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){
307 for(vtkIdType i = 0; i < aNbCells; i++){
308 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
309 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
310 double aValue = aNumericalFunctor->GetValue(anObjId);
311 aScalars->SetValue(i,aValue);
313 int nbIntervals = theScalarBarActor->GetMaximumNumberOfColors();
314 std::vector<int> nbEvents;
315 std::vector<double> funValues;
316 aNumericalFunctor->GetHistogram(nbIntervals, nbEvents, funValues);
317 theScalarBarActor->SetDistribution(nbEvents);
319 }else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get())){
320 for(vtkIdType i = 0; i < aNbCells; i++){
321 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
322 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
323 bool aValue = aPredicate->IsSatisfy(anObjId);
324 aScalars->SetValue(i,aValue);
328 aDataSet->GetCellData()->SetScalars(aScalars);
331 theLookupTable->SetRange(aScalars->GetRange());
332 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
333 theLookupTable->Build();
335 myMergeFilter->SetScalars(aDataSet);
338 GetMapper()->SetScalarVisibility(anIsInitialized);
339 theScalarBarActor->SetVisibility(anIsInitialized);
344 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
345 SMESH_ScalarBarActor* theScalarBarActor,
346 vtkLookupTable* theLookupTable)
348 bool anIsInitialized = theFunctor;
349 myExtractUnstructuredGrid->ClearRegisteredCells();
350 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
351 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
352 myVisualObj->UpdateFunctor(theFunctor);
354 using namespace SMESH::Controls;
355 if (anIsInitialized){
356 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
357 SMESH::Controls::Length2D::TValues aValues;
359 aLength2D->GetValues(aValues);
360 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
361 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
363 aDataSet->SetPoints(aGrid->GetPoints());
365 vtkIdType aNbCells = aValues.size();
367 vtkDoubleArray *aScalars = vtkDoubleArray::New();
368 aScalars->SetNumberOfComponents(1);
369 aScalars->SetNumberOfTuples(aNbCells);
371 vtkIdType aCellsSize = 3*aNbCells;
372 vtkCellArray* aConnectivity = vtkCellArray::New();
373 aConnectivity->Allocate( aCellsSize, 0 );
375 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
376 aCellTypesArray->SetNumberOfComponents( 1 );
377 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
379 vtkIdList *anIdList = vtkIdList::New();
380 anIdList->SetNumberOfIds(2);
382 Length2D::TValues::const_iterator anIter = aValues.begin();
383 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
384 const Length2D::Value& aValue = *anIter;
386 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
387 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
389 if(aNode[0] >= 0 && aNode[1] >= 0){
390 anIdList->SetId( 0, aNode[0] );
391 anIdList->SetId( 1, aNode[1] );
392 aConnectivity->InsertNextCell( anIdList );
393 aCellTypesArray->InsertNextValue( VTK_LINE );
394 aScalars->SetValue(aVtkId,aValue.myLength);
398 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
399 aCellLocationsArray->SetNumberOfComponents( 1 );
400 aCellLocationsArray->SetNumberOfTuples( aNbCells );
402 aConnectivity->InitTraversal();
403 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
404 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
406 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
407 SetUnstructuredGrid(aDataSet);
409 aDataSet->GetCellData()->SetScalars(aScalars);
412 theLookupTable->SetRange(aScalars->GetRange());
413 theLookupTable->Build();
415 myMergeFilter->SetScalars(aDataSet);
418 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
419 SMESH::Controls::MultiConnection2D::MValues aValues;
421 aMultiConnection2D->GetValues(aValues);
422 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
423 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
424 aDataSet->SetPoints(aGrid->GetPoints());
426 vtkIdType aNbCells = aValues.size();
427 vtkDoubleArray *aScalars = vtkDoubleArray::New();
428 aScalars->SetNumberOfComponents(1);
429 aScalars->SetNumberOfTuples(aNbCells);
431 vtkIdType aCellsSize = 3*aNbCells;
432 vtkCellArray* aConnectivity = vtkCellArray::New();
433 aConnectivity->Allocate( aCellsSize, 0 );
435 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
436 aCellTypesArray->SetNumberOfComponents( 1 );
437 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
439 vtkIdList *anIdList = vtkIdList::New();
440 anIdList->SetNumberOfIds(2);
442 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
443 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
444 const MultiConnection2D::Value& aValue = (*anIter).first;
446 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
447 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
449 if(aNode[0] >= 0 && aNode[1] >= 0){
450 anIdList->SetId( 0, aNode[0] );
451 anIdList->SetId( 1, aNode[1] );
452 aConnectivity->InsertNextCell( anIdList );
453 aCellTypesArray->InsertNextValue( VTK_LINE );
454 aScalars->SetValue(aVtkId,(*anIter).second);
458 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
459 aCellLocationsArray->SetNumberOfComponents( 1 );
460 aCellLocationsArray->SetNumberOfTuples( aNbCells );
462 aConnectivity->InitTraversal();
463 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
464 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
466 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
467 SetUnstructuredGrid(aDataSet);
469 aDataSet->GetCellData()->SetScalars(aScalars);
472 theLookupTable->SetRange(aScalars->GetRange());
473 theLookupTable->Build();
475 myMergeFilter->SetScalars(aDataSet);
480 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){
481 int nbIntervals = theScalarBarActor->GetMaximumNumberOfColors();
482 std::vector<int> nbEvents;
483 std::vector<double> funValues;
484 aNumericalFunctor->GetHistogram(nbIntervals, nbEvents, funValues);
485 theScalarBarActor->SetDistribution(nbEvents);
489 GetMapper()->SetScalarVisibility(anIsInitialized);
490 theScalarBarActor->SetVisibility(anIsInitialized);
495 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
497 myExtractUnstructuredGrid->ClearRegisteredCells();
498 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
499 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
500 myVisualObj->UpdateFunctor(theFunctor);
502 using namespace SMESH::Controls;
503 if ( dynamic_cast<FreeBorders*>(theFunctor.get()) ||
504 dynamic_cast<FreeFaces*>(theFunctor.get()) ) {
505 Predicate* aFreePredicate = dynamic_cast<Predicate*>(theFunctor.get());
506 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
507 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
508 vtkIdType aNbCells = aGrid->GetNumberOfCells();
509 for( vtkIdType i = 0; i < aNbCells; i++ ){
510 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
511 if(aFreePredicate->IsSatisfy(anObjId))
512 myExtractUnstructuredGrid->RegisterCell(i);
514 if(!myExtractUnstructuredGrid->IsCellsRegistered())
515 myExtractUnstructuredGrid->RegisterCell(-1);
516 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
517 }else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get())){
518 SMESH::Controls::FreeEdges::TBorders aBorders;
519 aFreeEdges->GetBoreders(aBorders);
520 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
521 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
522 aDataSet->SetPoints(aGrid->GetPoints());
524 vtkIdType aNbCells = aBorders.size();
525 vtkIdType aCellsSize = 3*aNbCells;
526 vtkCellArray* aConnectivity = vtkCellArray::New();
527 aConnectivity->Allocate( aCellsSize, 0 );
529 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
530 aCellTypesArray->SetNumberOfComponents( 1 );
531 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
533 vtkIdList *anIdList = vtkIdList::New();
534 anIdList->SetNumberOfIds(2);
536 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
537 for(; anIter != aBorders.end(); anIter++){
538 const FreeEdges::Border& aBorder = *anIter;
540 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
541 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
543 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
544 if(aNode[0] >= 0 && aNode[1] >= 0){
545 anIdList->SetId( 0, aNode[0] );
546 anIdList->SetId( 1, aNode[1] );
547 aConnectivity->InsertNextCell( anIdList );
548 aCellTypesArray->InsertNextValue( VTK_LINE );
552 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
553 aCellLocationsArray->SetNumberOfComponents( 1 );
554 aCellLocationsArray->SetNumberOfTuples( aNbCells );
556 aConnectivity->InitTraversal();
557 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
558 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
560 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
562 SetUnstructuredGrid(aDataSet);
564 }else if(FreeNodes* aFreeNodes = dynamic_cast<FreeNodes*>(theFunctor.get())){
565 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
566 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
567 for( vtkIdType i = 0; i < aNbNodes; i++ ){
568 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
569 if(aFreeNodes->IsSatisfy(anObjId))
570 myExtractUnstructuredGrid->RegisterCell(i);
572 if(!myExtractUnstructuredGrid->IsCellsRegistered())
573 myExtractUnstructuredGrid->RegisterCell(-1);
574 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
585 unsigned long mTime = this->Superclass::GetMTime();
586 mTime = max(mTime,myExtractGeometry->GetMTime());
587 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
588 mTime = max(mTime,myMergeFilter->GetMTime());
589 mTime = max(mTime,myGeomFilter->GetMTime());
590 mTime = max(mTime,myTransformFilter->GetMTime());
591 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
598 ::SetTransform(VTKViewer_Transform* theTransform)
600 myTransformFilter->SetTransform(theTransform);
608 if ( !myIsShrinkable ) return;
609 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
611 myShrinkFilter->SetInput( aDataSet );
612 myPassFilter[ 1 ]->SetInput( myShrinkFilter->GetOutput() );
621 if ( !myIsShrunk ) return;
622 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
624 myPassFilter[ 1 ]->SetInput( aDataSet );
625 myPassFilter[ 1 ]->Modified();
634 ::SetFacesOriented(bool theIsFacesOriented)
636 if ( vtkDataSet* aDataSet = myPassFilter[ 1 ]->GetOutput() )
638 myIsFacesOriented = theIsFacesOriented;
639 if( theIsFacesOriented )
640 myFaceOrientationFilter->SetInput( aDataSet );
641 UpdateFaceOrientation();
647 ::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
649 myFaceOrientation->GetProperty()->SetColor( theColor );
654 ::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
656 myFaceOrientation->GetProperty()->GetColor( theColor );
661 ::SetFacesOrientationScale(vtkFloatingPointType theScale)
663 myFaceOrientationFilter->SetOrientationScale( theScale );
668 ::GetFacesOrientationScale()
670 return myFaceOrientationFilter->GetOrientationScale();
675 ::SetFacesOrientation3DVectors(bool theState)
677 myFaceOrientationFilter->Set3dVectors( theState );
682 ::GetFacesOrientation3DVectors()
684 return myFaceOrientationFilter->Get3dVectors();
689 ::UpdateFaceOrientation()
691 bool aShowFaceOrientation = myIsFacesOriented;
692 aShowFaceOrientation &= GetVisibility();
693 aShowFaceOrientation &= myRepresentation == eSurface;
694 myFaceOrientation->SetVisibility(aShowFaceOrientation);
700 ::SetRepresentation(EReperesent theMode)
704 myGeomFilter->SetInside(true);
705 myGeomFilter->SetWireframeMode(false);
706 GetProperty()->SetRepresentation(0);
709 myGeomFilter->SetInside(false);
710 myGeomFilter->SetWireframeMode(true);
711 GetProperty()->SetRepresentation(theMode);
714 myGeomFilter->SetInside(true);
715 myGeomFilter->SetWireframeMode(true);
716 GetProperty()->SetRepresentation(1);
719 myGeomFilter->SetInside(false);
720 myGeomFilter->SetWireframeMode(false);
721 GetProperty()->SetRepresentation(theMode);
723 SetMarkerEnabled(theMode == ePoint);
724 myRepresentation = theMode;
725 UpdateFaceOrientation();
726 GetProperty()->Modified();
727 myMapper->Modified();
734 ::SetVisibility(int theMode)
736 if(!myExtractUnstructuredGrid->GetInput() ||
737 GetUnstructuredGrid()->GetNumberOfCells())
739 vtkLODActor::SetVisibility(theMode);
741 vtkLODActor::SetVisibility(false);
743 UpdateFaceOrientation();
751 if(!GetUnstructuredGrid()->GetNumberOfCells()){
752 vtkLODActor::SetVisibility(false);
754 return vtkLODActor::GetVisibility();
760 ::AddToRender(vtkRenderer* theRenderer)
762 theRenderer->AddActor(this);
763 theRenderer->AddActor(myFaceOrientation);
768 ::RemoveFromRender(vtkRenderer* theRenderer)
770 theRenderer->RemoveActor(this);
771 theRenderer->RemoveActor(myFaceOrientation);
777 ::GetNodeObjId(int theVtkID)
779 vtkIdType anID = theVtkID;
781 if(IsImplicitFunctionUsed())
782 anID = myExtractGeometry->GetNodeObjId(theVtkID);
784 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
785 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
789 vtkFloatingPointType*
791 ::GetNodeCoord(int theObjID)
793 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
794 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
795 vtkFloatingPointType* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
796 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
803 ::GetElemObjId(int theVtkID)
805 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
809 vtkIdType anId2 = anId;
810 if(IsImplicitFunctionUsed())
811 anId2 = myExtractGeometry->GetElemObjId(anId);
815 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
819 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
821 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
827 ::GetElemCell(int theObjID)
829 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
830 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
831 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
833 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
842 return myShrinkFilter->GetShrinkFactor();
847 ::SetShrinkFactor(vtkFloatingPointType theValue)
849 theValue = theValue > 0.1? theValue: 0.8;
850 myShrinkFilter->SetShrinkFactor(theValue);
857 ::SetHighlited(bool theIsHighlited)
859 if ( myIsHighlited == theIsHighlited )
861 myIsHighlited = theIsHighlited;
867 ::Render(vtkRenderer *ren, vtkMapper* m)
869 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
870 vtkFloatingPointType aStoredFactor, aStoredUnit;
871 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
873 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
874 vtkFloatingPointType aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
876 static vtkFloatingPointType EPS = .01;
879 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
880 vtkLODActor::Render(ren,m);
882 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
883 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
889 ::SetPolygonOffsetParameters(vtkFloatingPointType factor,
890 vtkFloatingPointType units)
892 myPolygonOffsetFactor = factor;
893 myPolygonOffsetUnits = units;
897 * On/Off representation 2D quadratic element as arked polygon
899 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
900 myGeomFilter->SetQuadraticArcMode(theFlag);
904 * Return true if 2D quadratic element displayed as arked polygon
906 bool SMESH_DeviceActor::GetQuadraticArcMode(){
907 return myGeomFilter->GetQuadraticArcMode();
910 * Set Max angle for representation 2D quadratic element as arked polygon
912 void SMESH_DeviceActor::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle){
913 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
917 * Return Max angle of the representation 2D quadratic element as arked polygon
919 vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle(){
920 return myGeomFilter->GetQuadraticArcAngle();
924 * Set point marker enabled
925 * \param theMarkerEnabled flag to enable/disable point marker
927 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
929 myMapper->SetMarkerEnabled( theMarkerEnabled );
933 * Set standard point marker
934 * \param theMarkerType type of the marker
936 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
938 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
942 * Set custom point marker
943 * \param theMarkerId id of the marker texture
944 * \param theMarkerTexture marker texture
946 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
948 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
952 * Get type of the point marker
953 * \return type of the point marker
955 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
957 return myMapper->GetMarkerType();
961 Get scale of the point marker
962 \return scale of the point marker
964 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
966 return myMapper->GetMarkerScale();
970 * Get texture identifier of the point marker
971 * \return texture identifier of the point marker
973 int SMESH_DeviceActor::GetMarkerTexture()
975 return myMapper->GetMarkerTexture();