]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Fixing visibility of standalone vertices in compound in VTK viewer.
authorakl <alexander.kovalev@opencascade.com>
Wed, 17 Sep 2014 08:30:45 +0000 (12:30 +0400)
committerakl <alexander.kovalev@opencascade.com>
Wed, 17 Sep 2014 08:30:45 +0000 (12:30 +0400)
src/GEOMGUI/GEOMGUI_Selection.cxx
src/OBJECT/GEOM_Actor.cxx
src/OBJECT/GEOM_Actor.h
src/OCC2VTK/OCC2VTK_Tools.cxx
src/OCC2VTK/OCC2VTK_Tools.h
src/VTKExport/VTKExport.cxx

index a2ad57d4b40fd94d8a679e2873e436a9113f90be..583a730789d52ebb572eac19e342fa8f79f0577b 100644 (file)
@@ -721,7 +721,8 @@ bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const
             GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor );
             if ( aGeomGActor ) {
               GEOM_VTKPropertyMaterial* mat  = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty());
-              res = mat->GetPhysical();
+              if ( mat )
+                res = mat->GetPhysical();
             } // if ( salome actor )
           } // if ( actor )
         } // if ( lst == vtkPrs->GetObjects() )
index a5cdfbfcb38ab19483b24a5689de6a4d0bb7f93f..1b15c5640c22aff2c3c818de23fec8276ea4c033 100644 (file)
@@ -87,6 +87,9 @@ GEOM_Actor::GEOM_Actor():
   myVertexActor(GEOM_DeviceActor::New(),true), 
   myVertexSource(GEOM_VertexSource::New(),true), 
  
+  myStandaloneVertexActor(GEOM_DeviceActor::New(),true), 
+  myStandaloneVertexSource(GEOM_VertexSource::New(),true), 
+
   myIsolatedEdgeActor(GEOM_DeviceActor::New(),true), 
   myIsolatedEdgeSource(GEOM_EdgeSource::New(),true), 
  
@@ -130,13 +133,13 @@ GEOM_Actor::GEOM_Actor():
   myHighlightProp->SetAmbientColor(1, 1, 1);
   myHighlightProp->SetDiffuseColor(1, 1, 1);
   myHighlightProp->SetSpecularColor(0.5, 0.5, 0.5);
-  myHighlightProp->SetPointSize(0);
+  myHighlightProp->SetPointSize(SALOME_POINT_SIZE+2);
   myHighlightActor->SetProperty(myHighlightProp.GetPointer());
 
   this->myHighlightActor->SetInput(myAppendFilter->GetOutputPort(),false);
 
   myPreHighlightProp->SetColor(0,1,1);
-  myPreHighlightProp->SetPointSize(0);
+  myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE);
   myPreHighlightProp->SetLineWidth(SALOME_LINE_WIDTH+1);
   myPreHighlightProp->SetRepresentationToWireframe();
 
@@ -147,6 +150,13 @@ GEOM_Actor::GEOM_Actor():
   aProperty->SetPointSize(3); 
   aProperty->SetColor(1, 1, 0);
  
+  myAppendFilter->AddInputConnection(myStandaloneVertexSource->GetOutputPort()); 
+  myStandaloneVertexActor->SetInput(myStandaloneVertexSource->GetOutputPort(),false); 
+  aProperty = myStandaloneVertexActor->GetProperty(); 
+  aProperty->SetRepresentation(VTK_POINTS); 
+  aProperty->SetPointSize(3); 
+  aProperty->SetColor(1, 1, 0);
   myAppendFilter->AddInputConnection(myIsolatedEdgeSource->GetOutputPort());
   myIsolatedEdgeActor->SetInput(myIsolatedEdgeSource->GetOutputPort(),false); 
   aProperty = myIsolatedEdgeActor->GetProperty(); 
@@ -229,6 +239,7 @@ GEOM_Actor::
 SetModified() 
 { 
   this->myVertexSource->Modified(); 
+  this->myStandaloneVertexSource->Modified(); 
   this->myIsolatedEdgeSource->Modified(); 
   this->myOneFaceEdgeSource->Modified(); 
   this->mySharedEdgeSource->Modified(); 
@@ -262,6 +273,7 @@ AddToRender(vtkRenderer* theRenderer)
   myIsolatedEdgeActor->AddToRender(theRenderer); 
  
   myVertexActor->AddToRender(theRenderer); 
+  myStandaloneVertexActor->AddToRender(theRenderer); 
 }
  
 void 
@@ -282,6 +294,7 @@ RemoveFromRender(vtkRenderer* theRenderer)
   myIsolatedEdgeActor->RemoveFromRender(theRenderer); 
  
   myVertexActor->RemoveFromRender(theRenderer);
+  myStandaloneVertexActor->RemoveFromRender(theRenderer);
 
   
   SetSelected(false);
@@ -358,6 +371,8 @@ SetVisibility(int theVisibility)
   myIsolatedEdgeActor->SetVisibility(theVisibility && !myIsSelected);
 
   myVertexActor->SetVisibility(theVisibility && (isOnlyVertex || (myVerticesMode && (!myIsSelected && !myIsPreselected))));// must be added new mode points
+
+  myStandaloneVertexActor->SetVisibility(theVisibility);
 }
  
 
@@ -399,11 +414,9 @@ GEOM_Actor
 {
   myVerticesMode = theMode;
   if ( theMode || isOnlyVertex ) {
-    myPreHighlightProp->SetPointSize(SALOME_POINT_SIZE+2);
-    myHighlightProp->SetPointSize(SALOME_POINT_SIZE);
+    myAppendFilter->AddInputConnection(myVertexSource->GetOutputPort()); 
   } else {
-    myPreHighlightProp->SetPointSize(0);
-    myHighlightProp->SetPointSize(0);
+    myAppendFilter->RemoveInputConnection(0, myVertexSource->GetOutputPort()); 
   }
   SetModified();
 }
@@ -436,6 +449,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
   myShape = theShape;
 
   myVertexSource->Clear();
+  myStandaloneVertexSource->Clear();
   myIsolatedEdgeSource->Clear();
   myOneFaceEdgeSource->Clear();
   mySharedEdgeSource->Clear();
@@ -456,6 +470,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
   TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,anEdgeMap);
   
   GEOM::SetShape(theShape,anEdgeMap,theIsVector,
+                 myStandaloneVertexSource.Get(),
                  myIsolatedEdgeSource.Get(),
                  myOneFaceEdgeSource.Get(),
                  mySharedEdgeSource.Get(),
@@ -471,6 +486,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
   
   if((bool)myShape.Infinite() || isOnlyVertex ){
     myVertexActor->GetDeviceActor()->SetInfinitive(true);
+    myStandaloneVertexActor->GetDeviceActor()->SetInfinitive(true);
     myHighlightActor->GetDeviceActor()->SetInfinitive(true);
   }
 
@@ -526,6 +542,11 @@ vtkProperty* GEOM_Actor::GetVertexProperty()
   return myVertexActor->GetProperty();
 }
 
+vtkProperty* GEOM_Actor::GetStandaloneVertexProperty()
+{
+  return myStandaloneVertexActor->GetProperty();
+}
+
 vtkProperty* GEOM_Actor::GetSharedEdgeProperty()
 {
   return mySharedEdgeActor->GetProperty();
@@ -715,6 +736,7 @@ void GEOM_Actor::SetOpacity(double opa)
   myHighlightProp->SetOpacity(opa);
   myPreHighlightProp->SetOpacity(opa);
   myVertexActor->GetProperty()->SetOpacity(opa);
+  myStandaloneVertexActor->GetProperty()->SetOpacity(opa);
 }
 
 double GEOM_Actor::GetOpacity()
@@ -755,6 +777,7 @@ void GEOM_Actor::GetColor(double& r,double& g,double& b)
 void GEOM_Actor::SetPointColor(double r,  double g,  double b)
 {
   myVertexActor->GetProperty()->SetColor(r, g, b);
+  myStandaloneVertexActor->GetProperty()->SetColor(r, g, b);
 }
 
 /*!
@@ -818,6 +841,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   aCoefnt = theProps[0]->GetAmbient();
   myShadingFaceProp->SetAmbient(aCoefnt);
   myVertexActor->GetProperty()->SetAmbient(aCoefnt);
+  myStandaloneVertexActor->GetProperty()->SetAmbient(aCoefnt);
   if ( aSize == 2 )
     aCoefnt = theProps[1]->GetAmbient();
   myShadingBackFaceProp->SetAmbient(aCoefnt);
@@ -826,6 +850,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   aCoefnt = theProps[0]->GetDiffuse();
   myShadingFaceProp->SetDiffuse(aCoefnt);
   myVertexActor->GetProperty()->SetDiffuse(aCoefnt);
+  myStandaloneVertexActor->GetProperty()->SetDiffuse(aCoefnt);
   if ( aSize == 2 )
     aCoefnt = theProps[1]->GetDiffuse();
   myShadingBackFaceProp->SetDiffuse(aCoefnt);
@@ -834,6 +859,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   aCoefnt = theProps[0]->GetSpecular();
   myShadingFaceProp->SetSpecular(aCoefnt);
   myVertexActor->GetProperty()->SetSpecular(aCoefnt);
+  myStandaloneVertexActor->GetProperty()->SetSpecular(aCoefnt);
   if ( aSize == 2 )
     aCoefnt = theProps[1]->GetSpecular();
   myShadingBackFaceProp->SetSpecular(aCoefnt);
@@ -845,6 +871,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   aColor = theProps[0]->GetAmbientColor();
   myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
   myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
+  myStandaloneVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
   if ( aSize == 2 )
     aColor = theProps[1]->GetAmbientColor();
   myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
@@ -853,6 +880,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   aColor = theProps[0]->GetDiffuseColor();
   myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
   myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
+  myStandaloneVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
   if ( aSize == 2 )
     aColor = theProps[1]->GetDiffuseColor();
   myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
@@ -861,6 +889,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   aColor = theProps[0]->GetSpecularColor();
   myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
   myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
+  myStandaloneVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
   if ( aSize == 2 )
     aColor = theProps[1]->GetSpecularColor();
   myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
@@ -869,6 +898,7 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
   aCoefnt = theProps[0]->GetSpecularPower();
   myShadingFaceProp->SetSpecularPower(aCoefnt);
   myVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
+  myStandaloneVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
   if ( aSize == 2 )
     aCoefnt = theProps[1]->GetSpecularPower();
   myShadingBackFaceProp->SetSpecularPower(aCoefnt);
index 173f40a0be9c6cbe636f0016840882b666aeecc5..117f1afcb378cfc7424a9a3c8bc935d2f2fcfed1 100644 (file)
@@ -89,6 +89,7 @@ public:
   vtkProperty* GetShadingProperty();
   vtkProperty* GetIsolatedEdgeProperty();
   vtkProperty* GetVertexProperty();
+  vtkProperty* GetStandaloneVertexProperty();
   vtkProperty* GetSharedEdgeProperty();
   vtkProperty* GetFaceEdgeProperty();
 
@@ -234,6 +235,9 @@ private:
   PDeviceActor myVertexActor;
   PVertexSource myVertexSource;
 
+  PDeviceActor myStandaloneVertexActor;
+  PVertexSource myStandaloneVertexSource;
+
   PDeviceActor myIsolatedEdgeActor;
   PEdgeSource myIsolatedEdgeSource;
 
index 8e325c88700f02a1e4fce053af5529ec4f7b8bce..e9b592035f70bb0d5e05d95d022dc54e8687c536 100755 (executable)
@@ -88,6 +88,7 @@ namespace GEOM
   void SetShape(const TopoDS_Shape& theShape,
                 const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
                 bool theIsVector,
+                GEOM_VertexSource* theStandaloneVertexSource,
                 GEOM_EdgeSource* theIsolatedEdgeSource,
                 GEOM_EdgeSource* theOneFaceEdgeSource,
                 GEOM_EdgeSource* theSharedEdgeSource,
@@ -98,6 +99,7 @@ namespace GEOM
       TopoDS_Iterator anItr(theShape);
       for (; anItr.More(); anItr.Next()) {
         SetShape(anItr.Value(),theEdgeMap,theIsVector,
+                 theStandaloneVertexSource,
                  theIsolatedEdgeSource,
                  theOneFaceEdgeSource,
                  theSharedEdgeSource,
@@ -123,6 +125,10 @@ namespace GEOM
         break;
       }
       case TopAbs_VERTEX: {
+        if ( theStandaloneVertexSource ) {
+          const TopoDS_Vertex& aVertex = TopoDS::Vertex(theShape);
+          theStandaloneVertexSource->AddVertex(aVertex);
+        }
         break;
       }
       default: {
index c4fb478c6cca4fb5c073020115fc4d56392c1631..523ca14b945ffa3724dc6ad271cc3e7243f4730f 100755 (executable)
@@ -25,6 +25,7 @@
 #include <TopoDS_Shape.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 
+class GEOM_VertexSource;
 class GEOM_EdgeSource;
 class GEOM_WireframeFace;
 class GEOM_ShadingFace;
@@ -40,6 +41,7 @@ namespace GEOM
   OCC2VTK_EXPORT void SetShape(const TopoDS_Shape& theShape,
                                const TopTools_IndexedDataMapOfShapeListOfShape& theEdgeMap,
                                bool theIsVector,
+                               GEOM_VertexSource* theStandaloneVertexSource,
                                GEOM_EdgeSource* theIsolatedEdgeSource,
                                GEOM_EdgeSource* theOneFaceEdgeSource,
                                GEOM_EdgeSource* theSharedEdgeSource,
index bc342d3966c6333facfb288234a65369395284a6..ab853c4af934f5e9e4e9c08de0fea53af85f4d83 100644 (file)
@@ -119,6 +119,7 @@ extern "C"
       GEOM::SetShape( theShape,
                       anEdgeMap,
                       anIsVector,
+                      0, // all vertices were added above
                       myIsolatedEdgeSource,
                       myOneFaceEdgeSource,
                       mySharedEdgeSource,