1 // Copyright (C) 2007-2013 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 myMapper->SetInputConnection( myPassFilter[ anId ]->GetOutputPort() );
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);
298 double* range;// = aScalars->GetRange();
300 myVisualObj->UpdateFunctor(theFunctor);
302 using namespace SMESH::Controls;
303 if(NumericalFunctor* aNumericalFunctor = dynamic_cast<NumericalFunctor*>(theFunctor.get()))
305 for(vtkIdType i = 0; i < aNbCells; i++){
306 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
307 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
308 double aValue = aNumericalFunctor->GetValue(anObjId);
309 aScalars->SetValue(i,aValue);
311 range = aScalars->GetRange();
312 if ( range[1] - range[0] < ( qMax(qAbs(range[0]),qAbs(range[1])) + 1e-100 ) * 1e-6 )
315 for(vtkIdType i = 0; i < aNbCells; i++)
316 aScalars->SetValue(i,range[0]);
319 else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get()))
321 for(vtkIdType i = 0; i < aNbCells; i++){
322 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
323 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
324 bool aValue = aPredicate->IsSatisfy(anObjId);
325 aScalars->SetValue(i,aValue);
327 range = aScalars->GetRange();
330 aDataSet->GetCellData()->SetScalars(aScalars);
333 theLookupTable->SetRange( range );
334 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
335 theLookupTable->Build();
337 myMergeFilter->SetScalarsData(aDataSet);
340 GetMapper()->SetScalarVisibility(anIsInitialized);
341 theScalarBarActor->SetVisibility(anIsInitialized);
346 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
347 SMESH_ScalarBarActor* theScalarBarActor,
348 vtkLookupTable* theLookupTable)
350 bool anIsInitialized = theFunctor;
351 myExtractUnstructuredGrid->ClearRegisteredCells();
352 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
353 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
354 myVisualObj->UpdateFunctor(theFunctor);
356 using namespace SMESH::Controls;
357 if (anIsInitialized){
358 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
359 SMESH::Controls::Length2D::TValues aValues;
361 aLength2D->GetValues(aValues);
362 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
363 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
365 aDataSet->SetPoints(aGrid->GetPoints());
367 vtkIdType aNbCells = aValues.size();
369 vtkDoubleArray *aScalars = vtkDoubleArray::New();
370 aScalars->SetNumberOfComponents(1);
371 aScalars->SetNumberOfTuples(aNbCells);
373 vtkIdType aCellsSize = 3*aNbCells;
374 vtkCellArray* aConnectivity = vtkCellArray::New();
375 aConnectivity->Allocate( aCellsSize, 0 );
377 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
378 aCellTypesArray->SetNumberOfComponents( 1 );
379 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
381 vtkIdList *anIdList = vtkIdList::New();
382 anIdList->SetNumberOfIds(2);
384 Length2D::TValues::const_iterator anIter = aValues.begin();
385 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
386 const Length2D::Value& aValue = *anIter;
388 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
389 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
391 if(aNode[0] >= 0 && aNode[1] >= 0){
392 anIdList->SetId( 0, aNode[0] );
393 anIdList->SetId( 1, aNode[1] );
394 aConnectivity->InsertNextCell( anIdList );
395 aCellTypesArray->InsertNextValue( VTK_LINE );
396 aScalars->SetValue(aVtkId,aValue.myLength);
400 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
401 aCellLocationsArray->SetNumberOfComponents( 1 );
402 aCellLocationsArray->SetNumberOfTuples( aNbCells );
404 aConnectivity->InitTraversal();
405 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
406 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
408 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
409 SetUnstructuredGrid(aDataSet);
411 aDataSet->GetCellData()->SetScalars(aScalars);
414 theLookupTable->SetRange(aScalars->GetRange());
415 theLookupTable->Build();
417 myMergeFilter->SetScalarsData(aDataSet);
420 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
421 SMESH::Controls::MultiConnection2D::MValues aValues;
423 aMultiConnection2D->GetValues(aValues);
424 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
425 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
426 aDataSet->SetPoints(aGrid->GetPoints());
428 vtkIdType aNbCells = aValues.size();
429 vtkDoubleArray *aScalars = vtkDoubleArray::New();
430 aScalars->SetNumberOfComponents(1);
431 aScalars->SetNumberOfTuples(aNbCells);
433 vtkIdType aCellsSize = 3*aNbCells;
434 vtkCellArray* aConnectivity = vtkCellArray::New();
435 aConnectivity->Allocate( aCellsSize, 0 );
437 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
438 aCellTypesArray->SetNumberOfComponents( 1 );
439 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
441 vtkIdList *anIdList = vtkIdList::New();
442 anIdList->SetNumberOfIds(2);
444 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
445 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
446 const MultiConnection2D::Value& aValue = (*anIter).first;
448 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
449 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
451 if(aNode[0] >= 0 && aNode[1] >= 0){
452 anIdList->SetId( 0, aNode[0] );
453 anIdList->SetId( 1, aNode[1] );
454 aConnectivity->InsertNextCell( anIdList );
455 aCellTypesArray->InsertNextValue( VTK_LINE );
456 aScalars->SetValue(aVtkId,(*anIter).second);
460 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
461 aCellLocationsArray->SetNumberOfComponents( 1 );
462 aCellLocationsArray->SetNumberOfTuples( aNbCells );
464 aConnectivity->InitTraversal();
465 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
466 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
468 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
469 SetUnstructuredGrid(aDataSet);
471 aDataSet->GetCellData()->SetScalars(aScalars);
474 theLookupTable->SetRange(aScalars->GetRange());
475 theLookupTable->Build();
477 myMergeFilter->SetScalarsData(aDataSet);
481 GetMapper()->SetScalarVisibility(anIsInitialized);
482 theScalarBarActor->SetVisibility(anIsInitialized);
487 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
489 myExtractUnstructuredGrid->ClearRegisteredCells();
490 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
491 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
492 myVisualObj->UpdateFunctor(theFunctor);
494 using namespace SMESH::Controls;
495 if ( dynamic_cast<FreeBorders *>(theFunctor.get()) ||
496 dynamic_cast<FreeFaces *>(theFunctor.get()) ||
497 dynamic_cast<BareBorderVolume *>(theFunctor.get()) ||
498 dynamic_cast<BareBorderFace *>(theFunctor.get()) ||
499 dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
500 dynamic_cast<CoincidentElements1D *>(theFunctor.get()) ||
501 dynamic_cast<CoincidentElements2D *>(theFunctor.get()) ||
502 dynamic_cast<CoincidentElements3D *>(theFunctor.get()) ||
503 dynamic_cast<OverConstrainedFace *>(theFunctor.get()))
505 Predicate* aPredicate = 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(aPredicate->IsSatisfy(anObjId))
512 myExtractUnstructuredGrid->RegisterCell(i);
514 if(!myExtractUnstructuredGrid->IsCellsRegistered())
515 myExtractUnstructuredGrid->RegisterCell(-1);
516 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
518 else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
520 SMESH::Controls::FreeEdges::TBorders aBorders;
521 aFreeEdges->GetBoreders(aBorders);
522 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
523 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
524 aDataSet->SetPoints(aGrid->GetPoints());
526 vtkIdType aNbCells = aBorders.size();
527 vtkIdType aCellsSize = 3*aNbCells;
528 vtkCellArray* aConnectivity = vtkCellArray::New();
529 aConnectivity->Allocate( aCellsSize, 0 );
531 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
532 aCellTypesArray->SetNumberOfComponents( 1 );
533 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
535 vtkIdList *anIdList = vtkIdList::New();
536 anIdList->SetNumberOfIds(2);
538 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
539 for(; anIter != aBorders.end(); anIter++){
540 const FreeEdges::Border& aBorder = *anIter;
542 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
543 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
545 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
546 if(aNode[0] >= 0 && aNode[1] >= 0){
547 anIdList->SetId( 0, aNode[0] );
548 anIdList->SetId( 1, aNode[1] );
549 aConnectivity->InsertNextCell( anIdList );
550 aCellTypesArray->InsertNextValue( VTK_LINE );
554 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
555 aCellLocationsArray->SetNumberOfComponents( 1 );
556 aCellLocationsArray->SetNumberOfTuples( aNbCells );
558 aConnectivity->InitTraversal();
559 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
560 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
562 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
564 SetUnstructuredGrid(aDataSet);
567 else if(dynamic_cast<FreeNodes *>(theFunctor.get()) ||
568 dynamic_cast<CoincidentNodes*>(theFunctor.get()))
570 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
571 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
572 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
573 for( vtkIdType i = 0; i < aNbNodes; i++ ){
574 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
575 if(aPredicate->IsSatisfy(anObjId))
576 myExtractUnstructuredGrid->RegisterCell(i);
578 if(!myExtractUnstructuredGrid->IsCellsRegistered())
579 myExtractUnstructuredGrid->RegisterCell(-1);
580 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
591 unsigned long mTime = this->Superclass::GetMTime();
592 mTime = max(mTime,myExtractGeometry->GetMTime());
593 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
594 mTime = max(mTime,myMergeFilter->GetMTime());
595 mTime = max(mTime,myGeomFilter->GetMTime());
596 mTime = max(mTime,myTransformFilter->GetMTime());
597 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
604 ::SetTransform(VTKViewer_Transform* theTransform)
606 myTransformFilter->SetTransform(theTransform);
614 if ( !myIsShrinkable ) return;
615 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
617 myShrinkFilter->SetInputConnection( aDataSet );
618 myPassFilter[ 1 ]->SetInputConnection( myShrinkFilter->GetOutputPort() );
627 if ( !myIsShrunk ) return;
628 if ( vtkAlgorithmOutput* aDataSet = myPassFilter[ 0 ]->GetOutputPort() )
630 myPassFilter[ 1 ]->SetInputConnection( aDataSet );
631 myPassFilter[ 1 ]->Modified();
640 ::SetFacesOriented(bool theIsFacesOriented)
642 if ( vtkAlgorithmOutput* aDataSet = myTransformFilter->GetOutputPort() )
644 myIsFacesOriented = theIsFacesOriented;
645 if( theIsFacesOriented )
646 myFaceOrientationFilter->SetInputConnection( aDataSet );
647 UpdateFaceOrientation();
653 ::SetFacesOrientationColor(double r,double g,double b)
655 myFaceOrientation->GetProperty()->SetColor( r, g, b );
660 ::GetFacesOrientationColor(double& r,double& g,double& b)
662 myFaceOrientation->GetProperty()->GetColor( r, g, b );
667 ::SetFacesOrientationScale(double theScale)
669 myFaceOrientationFilter->SetOrientationScale( theScale );
674 ::GetFacesOrientationScale()
676 return myFaceOrientationFilter->GetOrientationScale();
681 ::SetFacesOrientation3DVectors(bool theState)
683 myFaceOrientationFilter->Set3dVectors( theState );
688 ::GetFacesOrientation3DVectors()
690 return myFaceOrientationFilter->Get3dVectors();
695 ::UpdateFaceOrientation()
697 bool aShowFaceOrientation = myIsFacesOriented;
698 aShowFaceOrientation &= GetVisibility();
699 aShowFaceOrientation &= myRepresentation == eSurface;
700 myFaceOrientation->SetVisibility(aShowFaceOrientation);
706 ::SetRepresentation(EReperesent theMode)
710 myGeomFilter->SetInside(true);
711 myGeomFilter->SetWireframeMode(false);
712 GetProperty()->SetRepresentation(0);
715 myGeomFilter->SetInside(false);
716 myGeomFilter->SetWireframeMode(true);
717 GetProperty()->SetRepresentation(theMode);
720 myGeomFilter->SetInside(true);
721 myGeomFilter->SetWireframeMode(true);
722 GetProperty()->SetRepresentation(1);
725 myGeomFilter->SetInside(false);
726 myGeomFilter->SetWireframeMode(false);
727 GetProperty()->SetRepresentation(theMode);
729 SetMarkerEnabled(theMode == ePoint);
730 myRepresentation = theMode;
731 UpdateFaceOrientation();
732 GetProperty()->Modified();
733 myMapper->Modified();
740 ::SetVisibility(int theMode)
742 if(!myExtractUnstructuredGrid->GetInput() ||
743 GetUnstructuredGrid()->GetNumberOfCells())
745 vtkLODActor::SetVisibility(theMode);
747 vtkLODActor::SetVisibility(false);
749 UpdateFaceOrientation();
757 if(!GetUnstructuredGrid()->GetNumberOfCells()){
758 vtkLODActor::SetVisibility(false);
760 return vtkLODActor::GetVisibility();
766 ::AddToRender(vtkRenderer* theRenderer)
768 theRenderer->AddActor(this);
769 theRenderer->AddActor(myFaceOrientation);
774 ::RemoveFromRender(vtkRenderer* theRenderer)
776 theRenderer->RemoveActor(this);
777 theRenderer->RemoveActor(myFaceOrientation);
783 ::GetNodeObjId(int theVtkID)
785 vtkIdType anID = theVtkID;
787 if(IsImplicitFunctionUsed())
788 anID = myExtractGeometry->GetNodeObjId(theVtkID);
790 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
791 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
797 ::GetNodeCoord(int theObjID)
799 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
800 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
801 double* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
802 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
809 ::GetElemObjId(int theVtkID)
811 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
815 vtkIdType anId2 = anId;
816 if(IsImplicitFunctionUsed())
817 anId2 = myExtractGeometry->GetElemObjId(anId);
821 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
825 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
827 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
833 ::GetElemCell(int theObjID)
835 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
836 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
837 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
839 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
848 return myShrinkFilter->GetShrinkFactor();
853 ::SetShrinkFactor(double theValue)
855 theValue = theValue > 0.1? theValue: 0.8;
856 myShrinkFilter->SetShrinkFactor(theValue);
863 ::SetHighlited(bool theIsHighlited)
865 if ( myIsHighlited == theIsHighlited )
867 myIsHighlited = theIsHighlited;
873 ::Render(vtkRenderer *ren, vtkMapper* m)
875 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
876 double aStoredFactor, aStoredUnit;
877 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
879 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
880 double aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
882 static double EPS = .01;
885 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
886 vtkLODActor::Render(ren,m);
888 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
889 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
895 ::SetPolygonOffsetParameters(double factor,
898 myPolygonOffsetFactor = factor;
899 myPolygonOffsetUnits = units;
903 * On/Off representation 2D quadratic element as arked polygon
905 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
906 myGeomFilter->SetQuadraticArcMode(theFlag);
910 * Return true if 2D quadratic element displayed as arked polygon
912 bool SMESH_DeviceActor::GetQuadraticArcMode(){
913 return myGeomFilter->GetQuadraticArcMode();
916 * Set Max angle for representation 2D quadratic element as arked polygon
918 void SMESH_DeviceActor::SetQuadraticArcAngle(double theMaxAngle){
919 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
923 * Return Max angle of the representation 2D quadratic element as arked polygon
925 double SMESH_DeviceActor::GetQuadraticArcAngle(){
926 return myGeomFilter->GetQuadraticArcAngle();
930 * Set point marker enabled
931 * \param theMarkerEnabled flag to enable/disable point marker
933 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
935 myMapper->SetMarkerEnabled( theMarkerEnabled );
939 * Set standard point marker
940 * \param theMarkerType type of the marker
942 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
944 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
948 * Set custom point marker
949 * \param theMarkerId id of the marker texture
950 * \param theMarkerTexture marker texture
952 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
954 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
958 * Get type of the point marker
959 * \return type of the point marker
961 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
963 return myMapper->GetMarkerType();
967 Get scale of the point marker
968 \return scale of the point marker
970 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
972 return myMapper->GetMarkerScale();
976 * Get texture identifier of the point marker
977 * \return texture identifier of the point marker
979 int SMESH_DeviceActor::GetMarkerTexture()
981 return myMapper->GetMarkerTexture();
984 void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
985 myGeomFilter->SetAppendCoincident3D(theFlag);
988 bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
989 return myGeomFilter->GetAppendCoincident3D();