b311480e |
1 | // Created on: 1995-07-24 |
2 | // Created by: Modelistation |
3 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | |
42cf5bc1 |
18 | #include <Adaptor3d_Surface.hxx> |
7fd59977 |
19 | #include <Geom_BezierSurface.hxx> |
20 | #include <Geom_BSplineSurface.hxx> |
42cf5bc1 |
21 | #include <Graphic3d_ArrayOfPolylines.hxx> |
22 | #include <Graphic3d_Group.hxx> |
23 | #include <Prs3d_IsoAspect.hxx> |
24 | #include <Prs3d_Presentation.hxx> |
25 | #include <StdPrs_WFPoleSurface.hxx> |
26 | #include <TColgp_Array2OfPnt.hxx> |
7fd59977 |
27 | |
28 | static void AddPoles(const Handle (Prs3d_Presentation)& aPresentation, |
b8ddfc2f |
29 | const TColgp_Array2OfPnt& A, |
30 | const Handle (Prs3d_Drawer)& aDrawer) |
7fd59977 |
31 | { |
32 | Standard_Integer i,j; |
b8ddfc2f |
33 | const Standard_Integer n = A.ColLength(); |
34 | const Standard_Integer m = A.RowLength(); |
35 | |
7fd59977 |
36 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->UIsoAspect()->Aspect()); |
b8ddfc2f |
37 | Handle(Graphic3d_ArrayOfPolylines) aPrims = new Graphic3d_ArrayOfPolylines(n*m,n); |
7fd59977 |
38 | for (i=1; i<=n; i++){ |
b8ddfc2f |
39 | aPrims->AddBound(m); |
40 | for (j=1; j<=m; j++) |
41 | aPrims->AddVertex(A(i,j)); |
7fd59977 |
42 | } |
b8ddfc2f |
43 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
44 | |
7fd59977 |
45 | Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(aDrawer->VIsoAspect()->Aspect()); |
b8ddfc2f |
46 | aPrims = new Graphic3d_ArrayOfPolylines(n*m,m); |
7fd59977 |
47 | for (j=1; j<=m; j++){ |
b8ddfc2f |
48 | aPrims->AddBound(n); |
49 | for (i=1; i<=n; i++) |
50 | aPrims->AddVertex(A(i,j)); |
7fd59977 |
51 | } |
b8ddfc2f |
52 | Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(aPrims); |
7fd59977 |
53 | } |
54 | |
55 | |
56 | //======================================================================= |
57 | //function : Add |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | void StdPrs_WFPoleSurface::Add (const Handle (Prs3d_Presentation)& aPresentation, |
62 | const Adaptor3d_Surface& aSurface, |
63 | const Handle (Prs3d_Drawer)& aDrawer) |
64 | { |
65 | |
66 | GeomAbs_SurfaceType SType = aSurface.GetType(); |
67 | if (SType == GeomAbs_BezierSurface || SType == GeomAbs_BSplineSurface) { |
68 | Standard_Integer n , m; |
69 | if (SType == GeomAbs_BezierSurface) { |
70 | Handle(Geom_BezierSurface) B = aSurface.Bezier(); |
71 | n = aSurface.NbUPoles(); |
72 | m = aSurface.NbVPoles(); |
73 | TColgp_Array2OfPnt A(1,n,1,m); |
74 | (aSurface.Bezier())->Poles(A); |
75 | AddPoles(aPresentation, A, aDrawer); |
76 | } |
77 | else if (SType == GeomAbs_BSplineSurface) { |
78 | Handle(Geom_BSplineSurface) B = aSurface.BSpline(); |
79 | n = (aSurface.BSpline())->NbUPoles(); |
80 | m = (aSurface.BSpline())->NbVPoles(); |
81 | TColgp_Array2OfPnt A(1,n,1,m); |
82 | (aSurface.BSpline())->Poles(A); |
83 | AddPoles(aPresentation, A, aDrawer); |
84 | } |
85 | |
86 | } |
87 | } |
88 | |