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);
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 myTransformFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
246 myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
247 myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
250 myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
253 myPassFilter[ anId ]->SetInput( myGeomFilter->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 }else if(Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get())){
314 for(vtkIdType i = 0; i < aNbCells; i++){
315 vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i);
316 vtkIdType anObjId = myVisualObj->GetElemObjId(anId);
317 bool aValue = aPredicate->IsSatisfy(anObjId);
318 aScalars->SetValue(i,aValue);
322 aDataSet->GetCellData()->SetScalars(aScalars);
325 theLookupTable->SetRange(aScalars->GetRange());
326 theLookupTable->SetNumberOfTableValues(theScalarBarActor->GetMaximumNumberOfColors());
327 theLookupTable->Build();
329 myMergeFilter->SetScalars(aDataSet);
332 GetMapper()->SetScalarVisibility(anIsInitialized);
333 theScalarBarActor->SetVisibility(anIsInitialized);
338 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor,
339 SMESH_ScalarBarActor* theScalarBarActor,
340 vtkLookupTable* theLookupTable)
342 bool anIsInitialized = theFunctor;
343 myExtractUnstructuredGrid->ClearRegisteredCells();
344 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
345 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
346 myVisualObj->UpdateFunctor(theFunctor);
348 using namespace SMESH::Controls;
349 if (anIsInitialized){
350 if (Length2D* aLength2D = dynamic_cast<Length2D*>(theFunctor.get())){
351 SMESH::Controls::Length2D::TValues aValues;
353 aLength2D->GetValues(aValues);
354 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
355 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
357 aDataSet->SetPoints(aGrid->GetPoints());
359 vtkIdType aNbCells = aValues.size();
361 vtkDoubleArray *aScalars = vtkDoubleArray::New();
362 aScalars->SetNumberOfComponents(1);
363 aScalars->SetNumberOfTuples(aNbCells);
365 vtkIdType aCellsSize = 3*aNbCells;
366 vtkCellArray* aConnectivity = vtkCellArray::New();
367 aConnectivity->Allocate( aCellsSize, 0 );
369 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
370 aCellTypesArray->SetNumberOfComponents( 1 );
371 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
373 vtkIdList *anIdList = vtkIdList::New();
374 anIdList->SetNumberOfIds(2);
376 Length2D::TValues::const_iterator anIter = aValues.begin();
377 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
378 const Length2D::Value& aValue = *anIter;
380 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
381 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
383 if(aNode[0] >= 0 && aNode[1] >= 0){
384 anIdList->SetId( 0, aNode[0] );
385 anIdList->SetId( 1, aNode[1] );
386 aConnectivity->InsertNextCell( anIdList );
387 aCellTypesArray->InsertNextValue( VTK_LINE );
388 aScalars->SetValue(aVtkId,aValue.myLength);
392 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
393 aCellLocationsArray->SetNumberOfComponents( 1 );
394 aCellLocationsArray->SetNumberOfTuples( aNbCells );
396 aConnectivity->InitTraversal();
397 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
398 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
400 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
401 SetUnstructuredGrid(aDataSet);
403 aDataSet->GetCellData()->SetScalars(aScalars);
406 theLookupTable->SetRange(aScalars->GetRange());
407 theLookupTable->Build();
409 myMergeFilter->SetScalars(aDataSet);
412 else if (MultiConnection2D* aMultiConnection2D = dynamic_cast<MultiConnection2D*>(theFunctor.get())){
413 SMESH::Controls::MultiConnection2D::MValues aValues;
415 aMultiConnection2D->GetValues(aValues);
416 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
417 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
418 aDataSet->SetPoints(aGrid->GetPoints());
420 vtkIdType aNbCells = aValues.size();
421 vtkDoubleArray *aScalars = vtkDoubleArray::New();
422 aScalars->SetNumberOfComponents(1);
423 aScalars->SetNumberOfTuples(aNbCells);
425 vtkIdType aCellsSize = 3*aNbCells;
426 vtkCellArray* aConnectivity = vtkCellArray::New();
427 aConnectivity->Allocate( aCellsSize, 0 );
429 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
430 aCellTypesArray->SetNumberOfComponents( 1 );
431 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
433 vtkIdList *anIdList = vtkIdList::New();
434 anIdList->SetNumberOfIds(2);
436 MultiConnection2D::MValues::const_iterator anIter = aValues.begin();
437 for(vtkIdType aVtkId = 0; anIter != aValues.end(); anIter++,aVtkId++){
438 const MultiConnection2D::Value& aValue = (*anIter).first;
440 myVisualObj->GetNodeVTKId(aValue.myPntId[0]),
441 myVisualObj->GetNodeVTKId(aValue.myPntId[1])
443 if(aNode[0] >= 0 && aNode[1] >= 0){
444 anIdList->SetId( 0, aNode[0] );
445 anIdList->SetId( 1, aNode[1] );
446 aConnectivity->InsertNextCell( anIdList );
447 aCellTypesArray->InsertNextValue( VTK_LINE );
448 aScalars->SetValue(aVtkId,(*anIter).second);
452 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
453 aCellLocationsArray->SetNumberOfComponents( 1 );
454 aCellLocationsArray->SetNumberOfTuples( aNbCells );
456 aConnectivity->InitTraversal();
457 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
458 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
460 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
461 SetUnstructuredGrid(aDataSet);
463 aDataSet->GetCellData()->SetScalars(aScalars);
466 theLookupTable->SetRange(aScalars->GetRange());
467 theLookupTable->Build();
469 myMergeFilter->SetScalars(aDataSet);
473 GetMapper()->SetScalarVisibility(anIsInitialized);
474 theScalarBarActor->SetVisibility(anIsInitialized);
479 ::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor)
481 myExtractUnstructuredGrid->ClearRegisteredCells();
482 myExtractUnstructuredGrid->ClearRegisteredCellsWithType();
483 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::ePassAll);
484 myVisualObj->UpdateFunctor(theFunctor);
486 using namespace SMESH::Controls;
487 if ( dynamic_cast<FreeBorders *>(theFunctor.get()) ||
488 dynamic_cast<FreeFaces *>(theFunctor.get()) ||
489 dynamic_cast<BareBorderVolume *>(theFunctor.get()) ||
490 dynamic_cast<BareBorderFace *>(theFunctor.get()) ||
491 dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
492 dynamic_cast<CoincidentElements1D *>(theFunctor.get()) ||
493 dynamic_cast<CoincidentElements2D *>(theFunctor.get()) ||
494 dynamic_cast<CoincidentElements3D *>(theFunctor.get()) ||
495 dynamic_cast<OverConstrainedFace *>(theFunctor.get()))
497 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
498 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
499 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
500 vtkIdType aNbCells = aGrid->GetNumberOfCells();
501 for( vtkIdType i = 0; i < aNbCells; i++ ){
502 vtkIdType anObjId = myVisualObj->GetElemObjId(i);
503 if(aPredicate->IsSatisfy(anObjId))
504 myExtractUnstructuredGrid->RegisterCell(i);
506 if(!myExtractUnstructuredGrid->IsCellsRegistered())
507 myExtractUnstructuredGrid->RegisterCell(-1);
508 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
510 else if(FreeEdges* aFreeEdges = dynamic_cast<FreeEdges*>(theFunctor.get()))
512 SMESH::Controls::FreeEdges::TBorders aBorders;
513 aFreeEdges->GetBoreders(aBorders);
514 vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New();
515 vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
516 aDataSet->SetPoints(aGrid->GetPoints());
518 vtkIdType aNbCells = aBorders.size();
519 vtkIdType aCellsSize = 3*aNbCells;
520 vtkCellArray* aConnectivity = vtkCellArray::New();
521 aConnectivity->Allocate( aCellsSize, 0 );
523 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
524 aCellTypesArray->SetNumberOfComponents( 1 );
525 aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() );
527 vtkIdList *anIdList = vtkIdList::New();
528 anIdList->SetNumberOfIds(2);
530 FreeEdges::TBorders::const_iterator anIter = aBorders.begin();
531 for(; anIter != aBorders.end(); anIter++){
532 const FreeEdges::Border& aBorder = *anIter;
534 myVisualObj->GetNodeVTKId(aBorder.myPntId[0]),
535 myVisualObj->GetNodeVTKId(aBorder.myPntId[1])
537 //cout<<"aNode = "<<aBorder.myPntId[0]<<"; "<<aBorder.myPntId[1]<<endl;
538 if(aNode[0] >= 0 && aNode[1] >= 0){
539 anIdList->SetId( 0, aNode[0] );
540 anIdList->SetId( 1, aNode[1] );
541 aConnectivity->InsertNextCell( anIdList );
542 aCellTypesArray->InsertNextValue( VTK_LINE );
546 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
547 aCellLocationsArray->SetNumberOfComponents( 1 );
548 aCellLocationsArray->SetNumberOfTuples( aNbCells );
550 aConnectivity->InitTraversal();
551 for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ )
552 aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) );
554 aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity );
556 SetUnstructuredGrid(aDataSet);
559 else if(dynamic_cast<FreeNodes *>(theFunctor.get()) ||
560 dynamic_cast<CoincidentNodes*>(theFunctor.get()))
562 Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
563 myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
564 vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
565 for( vtkIdType i = 0; i < aNbNodes; i++ ){
566 vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
567 if(aPredicate->IsSatisfy(anObjId))
568 myExtractUnstructuredGrid->RegisterCell(i);
570 if(!myExtractUnstructuredGrid->IsCellsRegistered())
571 myExtractUnstructuredGrid->RegisterCell(-1);
572 SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid());
583 unsigned long mTime = this->Superclass::GetMTime();
584 mTime = max(mTime,myExtractGeometry->GetMTime());
585 mTime = max(mTime,myExtractUnstructuredGrid->GetMTime());
586 mTime = max(mTime,myMergeFilter->GetMTime());
587 mTime = max(mTime,myGeomFilter->GetMTime());
588 mTime = max(mTime,myTransformFilter->GetMTime());
589 mTime = max(mTime,myFaceOrientationFilter->GetMTime());
596 ::SetTransform(VTKViewer_Transform* theTransform)
598 myTransformFilter->SetTransform(theTransform);
606 if ( !myIsShrinkable ) return;
607 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
609 myShrinkFilter->SetInput( aDataSet );
610 myPassFilter[ 1 ]->SetInput( myShrinkFilter->GetOutput() );
619 if ( !myIsShrunk ) return;
620 if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() )
622 myPassFilter[ 1 ]->SetInput( aDataSet );
623 myPassFilter[ 1 ]->Modified();
632 ::SetFacesOriented(bool theIsFacesOriented)
634 if ( vtkDataSet* aDataSet = myTransformFilter->GetOutput() )
636 myIsFacesOriented = theIsFacesOriented;
637 if( theIsFacesOriented )
638 myFaceOrientationFilter->SetInput( aDataSet );
639 UpdateFaceOrientation();
645 ::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
647 myFaceOrientation->GetProperty()->SetColor( theColor );
652 ::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
654 myFaceOrientation->GetProperty()->GetColor( theColor );
659 ::SetFacesOrientationScale(vtkFloatingPointType theScale)
661 myFaceOrientationFilter->SetOrientationScale( theScale );
666 ::GetFacesOrientationScale()
668 return myFaceOrientationFilter->GetOrientationScale();
673 ::SetFacesOrientation3DVectors(bool theState)
675 myFaceOrientationFilter->Set3dVectors( theState );
680 ::GetFacesOrientation3DVectors()
682 return myFaceOrientationFilter->Get3dVectors();
687 ::UpdateFaceOrientation()
689 bool aShowFaceOrientation = myIsFacesOriented;
690 aShowFaceOrientation &= GetVisibility();
691 aShowFaceOrientation &= myRepresentation == eSurface;
692 myFaceOrientation->SetVisibility(aShowFaceOrientation);
698 ::SetRepresentation(EReperesent theMode)
702 myGeomFilter->SetInside(true);
703 myGeomFilter->SetWireframeMode(false);
704 GetProperty()->SetRepresentation(0);
707 myGeomFilter->SetInside(false);
708 myGeomFilter->SetWireframeMode(true);
709 GetProperty()->SetRepresentation(theMode);
712 myGeomFilter->SetInside(true);
713 myGeomFilter->SetWireframeMode(true);
714 GetProperty()->SetRepresentation(1);
717 myGeomFilter->SetInside(false);
718 myGeomFilter->SetWireframeMode(false);
719 GetProperty()->SetRepresentation(theMode);
721 SetMarkerEnabled(theMode == ePoint);
722 myRepresentation = theMode;
723 UpdateFaceOrientation();
724 GetProperty()->Modified();
725 myMapper->Modified();
732 ::SetVisibility(int theMode)
734 if(!myExtractUnstructuredGrid->GetInput() ||
735 GetUnstructuredGrid()->GetNumberOfCells())
737 vtkLODActor::SetVisibility(theMode);
739 vtkLODActor::SetVisibility(false);
741 UpdateFaceOrientation();
749 if(!GetUnstructuredGrid()->GetNumberOfCells()){
750 vtkLODActor::SetVisibility(false);
752 return vtkLODActor::GetVisibility();
758 ::AddToRender(vtkRenderer* theRenderer)
760 theRenderer->AddActor(this);
761 theRenderer->AddActor(myFaceOrientation);
766 ::RemoveFromRender(vtkRenderer* theRenderer)
768 theRenderer->RemoveActor(this);
769 theRenderer->RemoveActor(myFaceOrientation);
775 ::GetNodeObjId(int theVtkID)
777 vtkIdType anID = theVtkID;
779 if(IsImplicitFunctionUsed())
780 anID = myExtractGeometry->GetNodeObjId(theVtkID);
782 vtkIdType aRetID = myVisualObj->GetNodeObjId(anID);
783 if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "<<theVtkID<<"; anID = "<<anID<<"; aRetID = "<<aRetID);
787 vtkFloatingPointType*
789 ::GetNodeCoord(int theObjID)
791 vtkDataSet* aDataSet = myMergeFilter->GetOutput();
792 vtkIdType anID = myVisualObj->GetNodeVTKId(theObjID);
793 vtkFloatingPointType* aCoord = (anID >=0) ? aDataSet->GetPoint(anID) : NULL;
794 if(MYDEBUG) MESSAGE("GetNodeCoord - theObjID = "<<theObjID<<"; anID = "<<anID);
801 ::GetElemObjId(int theVtkID)
803 vtkIdType anId = myGeomFilter->GetElemObjId(theVtkID);
807 vtkIdType anId2 = anId;
808 if(IsImplicitFunctionUsed())
809 anId2 = myExtractGeometry->GetElemObjId(anId);
813 vtkIdType anId3 = myExtractUnstructuredGrid->GetInputId(anId2);
817 vtkIdType aRetID = myVisualObj->GetElemObjId(anId3);
819 MESSAGE("GetElemObjId - theVtkID = "<<theVtkID<<"; anId2 = "<<anId2<<"; anId3 = "<<anId3<<"; aRetID = "<<aRetID);
825 ::GetElemCell(int theObjID)
827 vtkDataSet* aDataSet = myVisualObj->GetUnstructuredGrid();
828 vtkIdType aGridID = myVisualObj->GetElemVTKId(theObjID);
829 vtkCell* aCell = (aGridID >= 0 ) ? aDataSet->GetCell(aGridID) : NULL;
831 MESSAGE("GetElemCell - theObjID = "<<theObjID<<"; aGridID = "<<aGridID);
840 return myShrinkFilter->GetShrinkFactor();
845 ::SetShrinkFactor(vtkFloatingPointType theValue)
847 theValue = theValue > 0.1? theValue: 0.8;
848 myShrinkFilter->SetShrinkFactor(theValue);
855 ::SetHighlited(bool theIsHighlited)
857 if ( myIsHighlited == theIsHighlited )
859 myIsHighlited = theIsHighlited;
865 ::Render(vtkRenderer *ren, vtkMapper* m)
867 int aResolveCoincidentTopology = vtkMapper::GetResolveCoincidentTopology();
868 vtkFloatingPointType aStoredFactor, aStoredUnit;
869 vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
871 vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
872 vtkFloatingPointType aFactor = myPolygonOffsetFactor, aUnits = myPolygonOffsetUnits;
874 static vtkFloatingPointType EPS = .01;
877 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aFactor,aUnits);
878 vtkLODActor::Render(ren,m);
880 vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(aStoredFactor,aStoredUnit);
881 vtkMapper::SetResolveCoincidentTopology(aResolveCoincidentTopology);
887 ::SetPolygonOffsetParameters(vtkFloatingPointType factor,
888 vtkFloatingPointType units)
890 myPolygonOffsetFactor = factor;
891 myPolygonOffsetUnits = units;
895 * On/Off representation 2D quadratic element as arked polygon
897 void SMESH_DeviceActor::SetQuadraticArcMode(bool theFlag){
898 myGeomFilter->SetQuadraticArcMode(theFlag);
902 * Return true if 2D quadratic element displayed as arked polygon
904 bool SMESH_DeviceActor::GetQuadraticArcMode(){
905 return myGeomFilter->GetQuadraticArcMode();
908 * Set Max angle for representation 2D quadratic element as arked polygon
910 void SMESH_DeviceActor::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle){
911 myGeomFilter->SetQuadraticArcAngle(theMaxAngle);
915 * Return Max angle of the representation 2D quadratic element as arked polygon
917 vtkFloatingPointType SMESH_DeviceActor::GetQuadraticArcAngle(){
918 return myGeomFilter->GetQuadraticArcAngle();
922 * Set point marker enabled
923 * \param theMarkerEnabled flag to enable/disable point marker
925 void SMESH_DeviceActor::SetMarkerEnabled( bool theMarkerEnabled )
927 myMapper->SetMarkerEnabled( theMarkerEnabled );
931 * Set standard point marker
932 * \param theMarkerType type of the marker
934 void SMESH_DeviceActor::SetMarkerStd( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
936 myMapper->SetMarkerStd( theMarkerType, theMarkerScale );
940 * Set custom point marker
941 * \param theMarkerId id of the marker texture
942 * \param theMarkerTexture marker texture
944 void SMESH_DeviceActor::SetMarkerTexture( int theMarkerId, VTK::MarkerTexture theMarkerTexture )
946 myMapper->SetMarkerTexture( theMarkerId, theMarkerTexture );
950 * Get type of the point marker
951 * \return type of the point marker
953 VTK::MarkerType SMESH_DeviceActor::GetMarkerType()
955 return myMapper->GetMarkerType();
959 Get scale of the point marker
960 \return scale of the point marker
962 VTK::MarkerScale SMESH_DeviceActor::GetMarkerScale()
964 return myMapper->GetMarkerScale();
968 * Get texture identifier of the point marker
969 * \return texture identifier of the point marker
971 int SMESH_DeviceActor::GetMarkerTexture()
973 return myMapper->GetMarkerTexture();
976 void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
977 myGeomFilter->SetAppendCoincident3D(theFlag);
980 bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
981 return myGeomFilter->GetAppendCoincident3D();