1 // Created on: 1995-08-01
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #define G005 //ATS,GG 04/01/01 Use PrimitiveArray instead Sets of primitives
23 // for performance improvment
25 #include <StdPrs_ShadedPoleSurface.ixx>
27 #include <Graphic3d_Group.hxx>
28 #include <Graphic3d_Vertex.hxx>
29 #include <Graphic3d_Array2OfVertex.hxx>
30 #include <TColgp_Array2OfPnt.hxx>
32 #include <Prs3d_ShadingAspect.hxx>
33 #include <Graphic3d_AspectFillArea3d.hxx>
35 #include <Geom_BezierSurface.hxx>
36 #include <Geom_BSplineSurface.hxx>
38 #include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
41 //=======================================================================
44 //=======================================================================
46 void StdPrs_ShadedPoleSurface::Add(
47 const Handle(Prs3d_Presentation)& aPresentation,
48 const Adaptor3d_Surface& aSurface,
49 const Handle (Prs3d_Drawer)& aDrawer)
51 if ( ! aDrawer->ShadingAspectGlobal() ) {
53 // If the surface is closed, the faces from back-side are not traced:
56 Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
57 if(aSurface.IsUClosed() && aSurface.IsVClosed()) {
58 Asp->SuppressBackFace();
62 Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
65 Standard_Integer i,j,n = aSurface.NbUPoles(), m = aSurface.NbVPoles();
67 if (aSurface.GetType() == GeomAbs_BezierSurface) {
68 Handle(Geom_BezierSurface) surface = aSurface.Bezier();
70 if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
71 Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
72 new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
73 Standard_False,Standard_False,Standard_False,Standard_False);
74 for ( i=1; i<=n; i++) {
76 for ( j=1; j<=m; j++) {
77 parray->AddVertex(surface->Pole(i,j));
80 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
84 TColgp_Array2OfPnt A(1,n,1,m);
86 Graphic3d_Array2OfVertex V(1,n,1,m);
88 for ( i=1; i<=n; i++) {
89 for ( j=1; j<=m; j++) {
91 V(i,j).SetCoord(x,y,z);
94 Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);
96 else if (aSurface.GetType() == GeomAbs_BSplineSurface) {
97 Handle(Geom_BSplineSurface) surface = aSurface.BSpline();
99 if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
100 Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
101 new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
102 Standard_False,Standard_False,Standard_False,Standard_False);
103 for ( i=1; i<=n; i++) {
105 for ( j=1; j<=m; j++) {
106 parray->AddVertex(surface->Pole(i,j));
109 Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
113 TColgp_Array2OfPnt A(1,n,1,m);
115 Graphic3d_Array2OfVertex V(1,n,1,m);
117 for ( i=1; i<=n; i++) {
118 for ( j=1; j<=m; j++) {
120 V(i,j).SetCoord(x,y,z);
123 Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);