0025129: Visualization - add interactive object for Points Cloud objects
[occt.git] / src / StdPrs / StdPrs_WFPoleSurface.cxx
1 // Created on: 1995-07-24
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <StdPrs_WFPoleSurface.ixx>
18
19 #include <Graphic3d_Group.hxx>
20 #include <TColgp_Array2OfPnt.hxx>
21 #include <Prs3d_IsoAspect.hxx>
22 #include <Graphic3d_ArrayOfPolylines.hxx>
23
24 #include <Geom_BezierSurface.hxx>
25 #include <Geom_BSplineSurface.hxx>
26
27 static void AddPoles(const Handle (Prs3d_Presentation)& aPresentation,
28                      const TColgp_Array2OfPnt&          A,
29                      const Handle (Prs3d_Drawer)&       aDrawer)
30 {
31   Standard_Integer i,j;
32   const Standard_Integer n = A.ColLength();
33   const Standard_Integer m = A.RowLength();
34
35   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect());    
36   Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(n*m,n);
37   for (i=1; i<=n; i++){
38     aPrims->AddBound(m);
39     for (j=1; j<=m; j++)
40       aPrims->AddVertex(A(i,j));
41   }
42   Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
43
44   Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect());    
45   aPrims = new Graphic3d_ArrayOfPolylines(n*m,m);
46   for (j=1; j<=m; j++){
47     aPrims->AddBound(n);
48     for (i=1; i<=n; i++)
49       aPrims->AddVertex(A(i,j));
50   }
51   Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims);
52 }
53
54
55 //=======================================================================
56 //function : Add
57 //purpose  : 
58 //=======================================================================
59
60 void StdPrs_WFPoleSurface::Add (const Handle (Prs3d_Presentation)& aPresentation,
61                                 const Adaptor3d_Surface&             aSurface,
62                                 const Handle (Prs3d_Drawer)&       aDrawer)
63 {
64
65   GeomAbs_SurfaceType SType = aSurface.GetType();
66   if (SType == GeomAbs_BezierSurface || SType == GeomAbs_BSplineSurface) {
67     Standard_Integer n , m;
68     if (SType == GeomAbs_BezierSurface) {
69       Handle(Geom_BezierSurface) B = aSurface.Bezier();
70       n = aSurface.NbUPoles();
71       m = aSurface.NbVPoles();
72       TColgp_Array2OfPnt A(1,n,1,m);
73       (aSurface.Bezier())->Poles(A);
74       AddPoles(aPresentation, A, aDrawer);
75     }
76     else if (SType == GeomAbs_BSplineSurface) {
77       Handle(Geom_BSplineSurface) B = aSurface.BSpline();
78       n = (aSurface.BSpline())->NbUPoles();
79       m = (aSurface.BSpline())->NbVPoles();
80       TColgp_Array2OfPnt A(1,n,1,m);
81       (aSurface.BSpline())->Poles(A);
82       AddPoles(aPresentation, A, aDrawer);
83     }
84
85   }
86 }
87