1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "GEOM_ShadingFace.h"
22 #include <vtkObjectFactory.h>
24 #include <vtkPoints.h>
25 #include <vtkCellArray.h>
27 #include <vtkPolyDataMapper.h>
28 #include <vtkPolyData.h>
30 #include <BRep_Tool.hxx>
31 #include <Poly_Triangulation.hxx>
34 vtkStandardNewMacro(GEOM_ShadingFace);
36 GEOM_ShadingFace::GEOM_ShadingFace()
40 GEOM_ShadingFace::~GEOM_ShadingFace()
48 vtkPolyData* aPolyData = GetOutput();
49 aPolyData->Allocate();
50 vtkPoints* aPts = vtkPoints::New();
51 aPolyData->SetPoints(aPts);
54 TFaceSet::Iterator anIter(myFaceSet);
55 for(; anIter.More(); anIter.Next()){
56 const TopoDS_Face& aFace = anIter.Value();
57 OCC2VTK(aFace,aPolyData,aPts);
63 OCC2VTK(const TopoDS_Face& theFace,
64 vtkPolyData* thePolyData,
68 Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(theFace,aLoc);
73 Standard_Boolean identity = true;
74 if(!aLoc.IsIdentity()){
76 myTransf = aLoc.Transformation();
80 int aNbOfNodes = thePts->GetNumberOfPoints();
81 const TColgp_Array1OfPnt& Nodes = aPoly->Nodes();
82 Standard_Integer nbNodesInFace = aPoly->NbNodes();
83 for(i = 1; i <= nbNodesInFace; i++) {
86 P.Transform(myTransf);
87 thePts->InsertNextPoint(P.X(),P.Y(),P.Z());
90 const Poly_Array1OfTriangle& Triangles = aPoly->Triangles();
91 Standard_Integer nbTriInFace = aPoly->NbTriangles();
92 for(i = 1; i <= nbTriInFace; i++){
94 Standard_Integer N1,N2,N3;
95 Triangles(i).Get(N1,N2,N3);
99 vtkIdType anIds[3] = {N1, N2, N3};
100 thePolyData->InsertNextCell(VTK_TRIANGLE,3,anIds);