Salome HOME
PR: synchro V6_main tag mergeto_V7_main_11Feb13
[modules/smesh.git] / src / OBJECT / SMESH_DeviceActor.cxx
index d4a04203bb16663384de8af2e094fe943cd4a272..c82bbf30524a34ebea0025dc4c3737ebc80775b0 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
-//  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
 //
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 //  SMESH OBJECT : interactive object for SMESH visualization
@@ -138,33 +138,29 @@ SMESH_DeviceActor
 {
   if(MYDEBUG) MESSAGE("~SMESH_DeviceActor - "<<this);
 
-  myProperty->Delete();
-
   myMapper->Delete();
 
-  myShrinkFilter->Delete();
+  myProperty->Delete();
 
-  myExtractUnstructuredGrid->Delete();
+  myExtractGeometry->Delete();
 
   myMergeFilter->Delete();
+  myExtractUnstructuredGrid->Delete();
 
-  myGeomFilter->Delete();
+  // Orientation of faces
+  myFaceOrientationFilter->Delete();
+  myFaceOrientationDataMapper->RemoveAllInputs();
+  myFaceOrientationDataMapper->Delete();
+  myFaceOrientation->Delete();
 
-  myExtractGeometry->Delete();
+  myGeomFilter->Delete();
 
   myTransformFilter->Delete();
 
-  for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){
+  for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
     myPassFilter[i]->Delete();
-  }
-
-  // Orientation of faces
-  myFaceOrientationFilter->Delete();
-
-  myFaceOrientationDataMapper->RemoveAllInputs();
-  myFaceOrientationDataMapper->Delete();
 
-  myFaceOrientation->Delete();
+  myShrinkFilter->Delete();
 }
 
 
@@ -240,17 +236,17 @@ SMESH_DeviceActor
     myPassFilter[ anId + 1]->SetInput( myPassFilter[ anId ]->GetOutput() );
     
     anId++; // 1
-    myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
+    myTransformFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 2
-    myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() ); 
+    myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
     myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 3
-    myTransformFilter->SetInput( myPassFilter[ anId ]->GetPolyDataOutput() );
+    myGeomFilter->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 4
-    myPassFilter[ anId ]->SetInput( myTransformFilter->GetOutput() );
+    myPassFilter[ anId ]->SetInput( myGeomFilter->GetOutput() ); 
     myPassFilter[ anId + 1 ]->SetInput( myPassFilter[ anId ]->GetOutput() );
 
     anId++; // 5
@@ -489,15 +485,18 @@ SMESH_DeviceActor
        dynamic_cast<BareBorderVolume     *>(theFunctor.get()) ||
        dynamic_cast<BareBorderFace       *>(theFunctor.get()) ||
        dynamic_cast<OverConstrainedVolume*>(theFunctor.get()) ||
+       dynamic_cast<CoincidentElements1D *>(theFunctor.get()) ||
+       dynamic_cast<CoincidentElements2D *>(theFunctor.get()) ||
+       dynamic_cast<CoincidentElements3D *>(theFunctor.get()) ||
        dynamic_cast<OverConstrainedFace  *>(theFunctor.get()))
   {
-    Predicate* aFreePredicate = dynamic_cast<Predicate*>(theFunctor.get());
+    Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
     myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
     vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid();
     vtkIdType aNbCells = aGrid->GetNumberOfCells();
     for( vtkIdType i = 0; i < aNbCells; i++ ){
       vtkIdType anObjId = myVisualObj->GetElemObjId(i);
-      if(aFreePredicate->IsSatisfy(anObjId))
+      if(aPredicate->IsSatisfy(anObjId))
         myExtractUnstructuredGrid->RegisterCell(i);
     }
     if(!myExtractUnstructuredGrid->IsCellsRegistered())
@@ -553,13 +552,15 @@ SMESH_DeviceActor
     SetUnstructuredGrid(aDataSet);
     aDataSet->Delete();
   }
-  else if(FreeNodes* aFreeNodes = dynamic_cast<FreeNodes*>(theFunctor.get()))
+  else if(dynamic_cast<FreeNodes      *>(theFunctor.get()) ||
+          dynamic_cast<CoincidentNodes*>(theFunctor.get()))
   {
+    Predicate* aPredicate = dynamic_cast<Predicate*>(theFunctor.get());
     myExtractUnstructuredGrid->SetModeOfChanging(VTKViewer_ExtractUnstructuredGrid::eAdding);
     vtkIdType aNbNodes = myVisualObj->GetNbEntities(SMDSAbs_Node);
     for( vtkIdType i = 0; i < aNbNodes; i++ ){
       vtkIdType anObjId = myVisualObj->GetNodeObjId(i);
-      if(aFreeNodes->IsSatisfy(anObjId))
+      if(aPredicate->IsSatisfy(anObjId))
         myExtractUnstructuredGrid->RegisterCell(i);
     }
     if(!myExtractUnstructuredGrid->IsCellsRegistered())
@@ -626,7 +627,7 @@ void
 SMESH_DeviceActor
 ::SetFacesOriented(bool theIsFacesOriented) 
 {
-  if ( vtkDataSet* aDataSet = myPassFilter[ 1 ]->GetOutput() )
+  if ( vtkDataSet* aDataSet = myTransformFilter->GetOutput() )
   {
     myIsFacesOriented = theIsFacesOriented;
     if( theIsFacesOriented )
@@ -637,16 +638,16 @@ SMESH_DeviceActor
 
 void
 SMESH_DeviceActor
-::SetFacesOrientationColor(vtkFloatingPointType theColor[3])
+::SetFacesOrientationColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b)
 {
-  myFaceOrientation->GetProperty()->SetColor( theColor );
+  myFaceOrientation->GetProperty()->SetColor( r, g, b );
 }
 
 void
 SMESH_DeviceActor
-::GetFacesOrientationColor(vtkFloatingPointType theColor[3])
+::GetFacesOrientationColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFloatingPointType& b)
 {
-  myFaceOrientation->GetProperty()->GetColor( theColor );
+  myFaceOrientation->GetProperty()->GetColor( r, g, b );
 }
 
 void
@@ -967,3 +968,11 @@ int SMESH_DeviceActor::GetMarkerTexture()
 {
   return myMapper->GetMarkerTexture();
 }
+
+void SMESH_DeviceActor::SetCoincident3DAllowed(bool theFlag) {
+  myGeomFilter->SetAppendCoincident3D(theFlag);
+}
+
+bool SMESH_DeviceActor::IsCoincident3DAllowed() const {
+  return myGeomFilter->GetAppendCoincident3D();
+}