1 // Copyright (C) 2007-2008 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
22 #include "GEOM_ShadingFace.h"
24 #include <vtkObjectFactory.h>
26 #include <vtkPoints.h>
27 #include <vtkCellArray.h>
29 #include <vtkPolyDataMapper.h>
30 #include <vtkPolyData.h>
32 #include <BRep_Tool.hxx>
33 #include <Poly_Triangulation.hxx>
36 vtkStandardNewMacro(GEOM_ShadingFace);
38 GEOM_ShadingFace::GEOM_ShadingFace()
42 GEOM_ShadingFace::~GEOM_ShadingFace()
50 vtkPolyData* aPolyData = GetOutput();
51 aPolyData->Allocate();
52 vtkPoints* aPts = vtkPoints::New();
53 aPolyData->SetPoints(aPts);
56 TFaceSet::Iterator anIter(myFaceSet);
57 for(; anIter.More(); anIter.Next()){
58 const TopoDS_Face& aFace = anIter.Value();
59 OCC2VTK(aFace,aPolyData,aPts);
65 OCC2VTK(const TopoDS_Face& theFace,
66 vtkPolyData* thePolyData,
70 Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(theFace,aLoc);
75 Standard_Boolean identity = true;
76 if(!aLoc.IsIdentity()){
78 myTransf = aLoc.Transformation();
82 int aNbOfNodes = thePts->GetNumberOfPoints();
83 const TColgp_Array1OfPnt& Nodes = aPoly->Nodes();
84 Standard_Integer nbNodesInFace = aPoly->NbNodes();
85 for(i = 1; i <= nbNodesInFace; i++) {
88 P.Transform(myTransf);
89 thePts->InsertNextPoint(P.X(),P.Y(),P.Z());
92 const Poly_Array1OfTriangle& Triangles = aPoly->Triangles();
93 Standard_Integer nbTriInFace = aPoly->NbTriangles();
94 for(i = 1; i <= nbTriInFace; i++){
96 Standard_Integer N1,N2,N3;
97 Triangles(i).Get(N1,N2,N3);
100 N3 += aNbOfNodes - 1;
101 vtkIdType anIds[3] = {N1, N2, N3};
102 thePolyData->InsertNextCell(VTK_TRIANGLE,3,anIds);