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 double 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->SetInputConnection(myFaceOrientationFilter->GetOutputPort());
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 ]->SetInputConnection( myExtractGeometry->GetOutputPort() );
213 myPassFilter[ anId ]->SetInputConnection( myMergeFilter->GetOutputPort() );
215 myIsImplicitFunctionUsed = theIsImplicitFunctionUsed;
216 SetStoreClippingMapping(myStoreClippingMapping);
222 ::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid)
225 //myIsShrinkable = theGrid->GetNumberOfCells() > 10;
226 myIsShrinkable = true;
228 myExtractUnstructuredGrid->SetInputData(theGrid);
230 myMergeFilter->SetGeometryConnection(myExtractUnstructuredGrid->GetOutputPort());
232 myExtractGeometry->SetInputConnection(myMergeFilter->GetOutputPort());
235 SetImplicitFunctionUsed(myIsImplicitFunctionUsed);
236 myPassFilter[ anId + 1]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
239 myTransformFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
242 myPassFilter[ anId ]->SetInputConnection( myTransformFilter->GetOutputPort() );
243 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
246 myGeomFilter->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
249 myPassFilter[ anId ]->SetInputConnection( myGeomFilter->GetOutputPort() );
250 myPassFilter[ anId + 1 ]->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
253 // OUV_PORTING_VTK6: to check
254 myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
256 vtkLODActor::SetMapper( myMapper );
262 VTKViewer_ExtractUnstructuredGrid*
264 ::GetExtractUnstructuredGrid()
266 return myExtractUnstructuredGrid;
272 ::GetUnstructuredGrid()
274 myExtractUnstructuredGrid->Update();
275 return myExtractUnstructuredGrid->GetOutput();
281 ::SetControlMode(SMESH::Controls::FunctorPtr theFunctor,
282 SMESH_ScalarBarActor* theScalarBarActor,
283 vtkLookupTable* theLookupTable)
285 bool anIsInitialized = theFunctor;
287 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
289 SetStoreIDMapping(true);
290 myExtractUnstructuredGrid->Update();
291 vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput();
293 aDataSet->ShallowCopy(aGrid);
295 vtkDoubleArray *aScalars = vtkDoubleArray::New();
296 vtkIdType aNbCells = aGrid->GetNumberOfCells();
297 aScalars->SetNumberOfComponents(1);
298 aScalars->SetNumberOfTuples(aNbCells);
300 myVisualObj->UpdateFunctor(theFunctor);
302 using namespace SMESH::Controls;
303 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get())){
304 for(vtkIdType i = 0; i < aNbCells; i++){
305 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
306 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
307 double aValue = aNumericalFunctor->GetValue(anObjId);
308 aScalars->SetValue(i,aValue);
310 }else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get())){
311 for(vtkIdType i = 0; i < aNbCells; i++){
312 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
313 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
314 bool aValue = aPredicate->IsSatisfy(anObjId);
315 aScalars->SetValue(i,aValue);
319 aDataSet->GetCellData()->SetScalars(aScalars);
322 theLookupTable->SetRange(aScalars->GetRange());
323 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
324 theLookupTable->Build();
326 myMergeFilter->SetScalarsData(aDataSet);
329 GetMapper()->SetScalarVisibility(anIsInitialized);
330 theScalarBarActor->SetVisibility(anIsInitialized);
335 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
336 SMESH_ScalarBarActor* theScalarBarActor,
337 vtkLookupTable* theLookupTable)
339 bool anIsInitialized = theFunctor;
340 myExtractUnstructuredGrid->ClearRegisteredCells();
341 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
342 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
343 myVisualObj->UpdateFunctor(theFunctor);
345 using namespace SMESH::Controls;
346 if (anIsInitialized){
347 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
348 SMESH::Controls::Length2D::TValues aValues;
350 aLength2D->GetValues(aValues);
351 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
352 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
354 aDataSet->SetPoints(aGrid->GetPoints());
356 vtkIdType aNbCells = aValues.size();
358 vtkDoubleArray *aScalars = vtkDoubleArray::New();
359 aScalars->SetNumberOfComponents(1);
360 aScalars->SetNumberOfTuples(aNbCells);
362 vtkIdType aCellsSize = 3*aNbCells;
363 vtkCellArray* aConnectivity = vtkCellArray::New();
364 aConnectivity->Allocate( aCellsSize, 0 );
366 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
367 aCellTypesArray->SetNumberOfComponents( 1 );
368 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
370 vtkIdList *anIdList = vtkIdList::New();
371 anIdList->SetNumberOfIds(2);
373 Length2D::TValues::const_iterator anIter = aValues.begin();
374 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
375 const Length2D::Value& aValue = *anIter;
377 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
378 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
380 if(aNode[0] >= 0 && aNode[1] >= 0){
381 anIdList->SetId( 0, aNode[0] );
382 anIdList->SetId( 1, aNode[1] );
383 aConnectivity->InsertNextCell( anIdList );
384 aCellTypesArray->InsertNextValue( VTK_LINE );
385 aScalars->SetValue(aVtkId,aValue.myLength);
389 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
390 aCellLocationsArray->SetNumberOfComponents( 1 );
391 aCellLocationsArray->SetNumberOfTuples( aNbCells );
393 aConnectivity->InitTraversal();
394 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
395 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
397 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
398 SetUnstructuredGrid(aDataSet);
400 aDataSet->GetCellData()->SetScalars(aScalars);
403 theLookupTable->SetRange(aScalars->GetRange());
404 theLookupTable->Build();
406 myMergeFilter->SetScalarsData(aDataSet);
409 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
410 SMESH::Controls::MultiConnection2D::MValues aValues;
412 aMultiConnection2D->GetValues(aValues);
413 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
414 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
415 aDataSet->SetPoints(aGrid->GetPoints());
417 vtkIdType aNbCells = aValues.size();
418 vtkDoubleArray *aScalars = vtkDoubleArray::New();
419 aScalars->SetNumberOfComponents(1);
420 aScalars->SetNumberOfTuples(aNbCells);
422 vtkIdType aCellsSize = 3*aNbCells;
423 vtkCellArray* aConnectivity = vtkCellArray::New();
424 aConnectivity->Allocate( aCellsSize, 0 );
426 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
427 aCellTypesArray->SetNumberOfComponents( 1 );
428 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
430 vtkIdList *anIdList = vtkIdList::New();
431 anIdList->SetNumberOfIds(2);
433 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
434 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
435 const MultiConnection2D::Value& aValue = (*anIter).first;
437 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
438 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
440 if(aNode[0] >= 0 && aNode[1] >= 0){
441 anIdList->SetId( 0, aNode[0] );
442 anIdList->SetId( 1, aNode[1] );
443 aConnectivity->InsertNextCell( anIdList );
444 aCellTypesArray->InsertNextValue( VTK_LINE );
445 aScalars->SetValue(aVtkId,(*anIter).second);
449 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
450 aCellLocationsArray->SetNumberOfComponents( 1 );
451 aCellLocationsArray->SetNumberOfTuples( aNbCells );
453 aConnectivity->InitTraversal();
454 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
455 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
457 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
458 SetUnstructuredGrid(aDataSet);
460 aDataSet->GetCellData()->SetScalars(aScalars);
463 theLookupTable->SetRange(aScalars->GetRange());
464 theLookupTable->Build();
466 myMergeFilter->SetScalarsData(aDataSet);
470 GetMapper()->SetScalarVisibility(anIsInitialized);
471 theScalarBarActor->SetVisibility(anIsInitialized);
476 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
478 myExtractUnstructuredGrid->ClearRegisteredCells();
479 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
480 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
481 myVisualObj->UpdateFunctor(theFunctor);
483 using namespace SMESH::Controls;
484 if ( dynamic_cast<FreeBorders *>(theFunctor.get()) ||
485 dynamic_cast<FreeFaces *>(theFunctor.get()) ||
486 dynamic_cast<BareBorderVolume *>(theFunctor.get()) ||
487 dynamic_cast<BareBorderFace *>(theFunctor.get()) ||
488 dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
489 dynamic_cast<CoincidentElements1D *>(theFunctor.get()) ||
490 dynamic_cast<CoincidentElements2D *>(theFunctor.get()) ||
491 dynamic_cast<CoincidentElements3D *>(theFunctor.get()) ||
492 dynamic_cast<OverConstrainedFace *>(theFunctor.get()))
494 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
495 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
496 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
497 vtkIdType aNbCells = aGrid->GetNumberOfCells();
498 for( vtkIdType i = 0; i < aNbCells; i++ ){
499 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
500 if(aPredicate->IsSatisfy(anObjId))
501 myExtractUnstructuredGrid->RegisterCell(i);
503 if(!myExtractUnstructuredGrid->IsCellsRegistered())
504 myExtractUnstructuredGrid->RegisterCell(-1);
505 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
507 else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
509 SMESH::Controls::FreeEdges::TBorders aBorders;
510 aFreeEdges->GetBoreders(aBorders);
511 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
512 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
513 aDataSet->SetPoints(aGrid->GetPoints());
515 vtkIdType aNbCells = aBorders.size();
516 vtkIdType aCellsSize = 3*aNbCells;
517 vtkCellArray* aConnectivity = vtkCellArray::New();
518 aConnectivity->Allocate( aCellsSize, 0 );
520 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
521 aCellTypesArray->SetNumberOfComponents( 1 );
522 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
524 vtkIdList *anIdList = vtkIdList::New();
525 anIdList->SetNumberOfIds(2);
527 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
528 for(; anIter != aBorders.end(); anIter++){
529 const FreeEdges::Border& aBorder = *anIter;
531 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
532 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
534 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
535 if(aNode[0] >= 0 && aNode[1] >= 0){
536 anIdList->SetId( 0, aNode[0] );
537 anIdList->SetId( 1, aNode[1] );
538 aConnectivity->InsertNextCell( anIdList );
539 aCellTypesArray->InsertNextValue( VTK_LINE );
543 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
544 aCellLocationsArray->SetNumberOfComponents( 1 );
545 aCellLocationsArray->SetNumberOfTuples( aNbCells );
547 aConnectivity->InitTraversal();
548 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
549 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
551 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
553 SetUnstructuredGrid(aDataSet);
556 else if(dynamic_cast<FreeNodes *>(theFunctor.get()) ||
557 dynamic_cast<CoincidentNodes*>(theFunctor.get()))
559 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
560 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
561 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
562 for( vtkIdType i = 0; i < aNbNodes; i++ ){
563 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
564 if(aPredicate->IsSatisfy(anObjId))
565 myExtractUnstructuredGrid->RegisterCell(i);
567 if(!myExtractUnstructuredGrid->IsCellsRegistered())
568 myExtractUnstructuredGrid->RegisterCell(-1);
569 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
580 unsigned long mTime = this->Superclass::GetMTime();
581 mTime = max(mTime,myExtractGeometry->GetMTime());
582 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
583 mTime = max(mTime,myMergeFilter->GetMTime());
584 mTime = max(mTime,myGeomFilter->GetMTime());
585 mTime = max(mTime,myTransformFilter->GetMTime());
586 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
593 ::SetTransform(VTKViewer_Transform* theTransform)
595 myTransformFilter->SetTransform(theTransform);
603 if ( !myIsShrinkable ) return;
604 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
606 myShrinkFilter->SetInputConnection( aDataSet );
607 myPassFilter[ 1 ]->SetInputConnection( myShrinkFilter->GetOutputPort() );
616 if ( !myIsShrunk ) return;
617 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
619 myPassFilter[ 1 ]->SetInputConnection( aDataSet );
620 myPassFilter[ 1 ]->Modified();
629 ::SetFacesOriented(bool theIsFacesOriented)
631 if ( vtkAlgorithmOutput* aDataSet = myTransformFilter->GetOutputPort() )
633 myIsFacesOriented = theIsFacesOriented;
634 if( theIsFacesOriented )
635 myFaceOrientationFilter->SetInputConnection( aDataSet );
636 UpdateFaceOrientation();
642 ::SetFacesOrientationColor(double r,double g,double b)
644 myFaceOrientation->GetProperty()->SetColor( r, g, b );
649 ::GetFacesOrientationColor(double& r,double& g,double& b)
651 myFaceOrientation->GetProperty()->GetColor( r, g, b );
656 ::SetFacesOrientationScale(double theScale)
658 myFaceOrientationFilter->SetOrientationScale( theScale );
663 ::GetFacesOrientationScale()
665 return myFaceOrientationFilter->GetOrientationScale();
670 ::SetFacesOrientation3DVectors(bool theState)
672 myFaceOrientationFilter->Set3dVectors( theState );
677 ::GetFacesOrientation3DVectors()
679 return myFaceOrientationFilter->Get3dVectors();
684 ::UpdateFaceOrientation()
686 bool aShowFaceOrientation = myIsFacesOriented;
687 aShowFaceOrientation &= GetVisibility();
688 aShowFaceOrientation &= myRepresentation == eSurface;
689 myFaceOrientation->SetVisibility(aShowFaceOrientation);
695 ::SetRepresentation(EReperesent theMode)
699 myGeomFilter->SetInside(true);
700 myGeomFilter->SetWireframeMode(false);
701 GetProperty()->SetRepresentation(0);
704 myGeomFilter->SetInside(false);
705 myGeomFilter->SetWireframeMode(true);
706 GetProperty()->SetRepresentation(theMode);
709 myGeomFilter->SetInside(true);
710 myGeomFilter->SetWireframeMode(true);
711 GetProperty()->SetRepresentation(1);
714 myGeomFilter->SetInside(false);
715 myGeomFilter->SetWireframeMode(false);
716 GetProperty()->SetRepresentation(theMode);
718 SetMarkerEnabled(theMode == ePoint);
719 myRepresentation = theMode;
720 UpdateFaceOrientation();
721 GetProperty()->Modified();
722 myMapper->Modified();
729 ::SetVisibility(int theMode)
731 if(!myExtractUnstructuredGrid->GetInput() ||
732 GetUnstructuredGrid()->GetNumberOfCells())
734 vtkLODActor::SetVisibility(theMode);
736 vtkLODActor::SetVisibility(false);
738 UpdateFaceOrientation();
746 if(!GetUnstructuredGrid()->GetNumberOfCells()){
747 vtkLODActor::SetVisibility(false);
749 return vtkLODActor::GetVisibility();
755 ::AddToRender(vtkRenderer* theRenderer)
757 theRenderer->AddActor(this);
758 theRenderer->AddActor(myFaceOrientation);
763 ::RemoveFromRender(vtkRenderer* theRenderer)
765 theRenderer->RemoveActor(this);
766 theRenderer->RemoveActor(myFaceOrientation);
772 ::GetNodeObjId(int theVtkID)
774 vtkIdType anID = theVtkID;
776 if(IsImplicitFunctionUsed())
777 anID = myExtractGeometry->GetNodeObjId(theVtkID);
779 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
780 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
786 ::GetNodeCoord(int theObjID)
788 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
789 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
790 double* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
791 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
798 ::GetElemObjId(int theVtkID)
800 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
804 vtkIdType anId2 = anId;
805 if(IsImplicitFunctionUsed())
806 anId2 = myExtractGeometry->GetElemObjId(anId);
810 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
814 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
816 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
822 ::GetElemCell(int theObjID)
824 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
825 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
826 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
828 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
837 return myShrinkFilter->GetShrinkFactor();
842 ::SetShrinkFactor(double theValue)
844 theValue = theValue > 0.1? theValue: 0.8;
845 myShrinkFilter->SetShrinkFactor(theValue);
852 ::SetHighlited(bool theIsHighlited)
854 if ( myIsHighlited == theIsHighlited )
856 myIsHighlited = theIsHighlited;
862 ::Render(vtkRenderer *ren, vtkMapper* m)
864 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
865 double aStoredFactor, aStoredUnit;
866 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
868 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
869 double aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
871 static double EPS = .01;
874 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
875 vtkLODActor::Render(ren,m);
877 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
878 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
884 ::SetPolygonOffsetParameters(double factor,
887 myPolygonOffsetFactor = factor;
888 myPolygonOffsetUnits = units;
892 * On/Off representation 2D quadratic element as arked polygon
894 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
895 myGeomFilter->SetQuadraticArcMode(theFlag);
899 * Return true if 2D quadratic element displayed as arked polygon
901 bool SMESH_DeviceActor::GetQuadraticArcMode(){
902 return myGeomFilter->GetQuadraticArcMode();
905 * Set Max angle for representation 2D quadratic element as arked polygon
907 void SMESH_DeviceActor::SetQuadraticArcAngle(double theMaxAngle){
908 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
912 * Return Max angle of the representation 2D quadratic element as arked polygon
914 double SMESH_DeviceActor::GetQuadraticArcAngle(){
915 return myGeomFilter->GetQuadraticArcAngle();
919 * Set point marker enabled
920 * \param theMarkerEnabled flag to enable/disable point marker
922 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
924 myMapper->SetMarkerEnabled( theMarkerEnabled );
928 * Set standard point marker
929 * \param theMarkerType type of the marker
931 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
933 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
937 * Set custom point marker
938 * \param theMarkerId id of the marker texture
939 * \param theMarkerTexture marker texture
941 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
943 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
947 * Get type of the point marker
948 * \return type of the point marker
950 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
952 return myMapper->GetMarkerType();
956 Get scale of the point marker
957 \return scale of the point marker
959 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
961 return myMapper->GetMarkerScale();
965 * Get texture identifier of the point marker
966 * \return texture identifier of the point marker
968 int SMESH_DeviceActor::GetMarkerTexture()
970 return myMapper->GetMarkerTexture();
973 void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
974 myGeomFilter->SetAppendCoincident3D(theFlag);
977 bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
978 return myGeomFilter->GetAppendCoincident3D();