1 #include "GEOM_ShadingFace.h"
3 #include <vtkObjectFactory.h>
6 #include <vtkCellArray.h>
8 #include <vtkPolyDataMapper.h>
9 #include <vtkPolyData.h>
11 #include <BRep_Tool.hxx>
12 #include <Poly_Triangulation.hxx>
15 vtkStandardNewMacro(GEOM_ShadingFace);
17 GEOM_ShadingFace::GEOM_ShadingFace()
21 GEOM_ShadingFace::~GEOM_ShadingFace()
29 vtkPolyData* aPolyData = GetOutput();
30 aPolyData->Allocate();
31 vtkPoints* aPts = vtkPoints::New();
32 aPolyData->SetPoints(aPts);
35 TFaceSet::Iterator anIter(myFaceSet);
36 for(; anIter.More(); anIter.Next()){
37 const TopoDS_Face& aFace = anIter.Value();
38 OCC2VTK(aFace,aPolyData,aPts);
44 OCC2VTK(const TopoDS_Face& theFace,
45 vtkPolyData* thePolyData,
49 Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(theFace,aLoc);
54 Standard_Boolean identity = true;
55 if(!aLoc.IsIdentity()){
57 myTransf = aLoc.Transformation();
61 int aNbOfNodes = thePts->GetNumberOfPoints();
62 const TColgp_Array1OfPnt& Nodes = aPoly->Nodes();
63 Standard_Integer nbNodesInFace = aPoly->NbNodes();
64 for(i = 1; i <= nbNodesInFace; i++) {
67 P.Transform(myTransf);
68 thePts->InsertNextPoint(P.X(),P.Y(),P.Z());
71 const Poly_Array1OfTriangle& Triangles = aPoly->Triangles();
72 Standard_Integer nbTriInFace = aPoly->NbTriangles();
73 for(i = 1; i <= nbTriInFace; i++){
75 Standard_Integer N1,N2,N3;
76 Triangles(i).Get(N1,N2,N3);
80 vtkIdType anIds[3] = {N1, N2, N3};
81 thePolyData->InsertNextCell(VTK_TRIANGLE,3,anIds);