mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0022971: TKOpenGl clean up obsolete functionality
Added native handles to OpenGl_Context Removed unused and unimplemented PolygonHoles Removed unimplemented Polygon functions Removed unused QuadrangleMesh functions Removed unused TriangleMesh functions Removed dead Bezier function declarations Redirect Graphic3d_Group::Polyline() to primitives array Move Prs3d_ShadedShape template code to StdPrs_ShadedShape where it is only used before. Remove TriangleSet usage from AIS_TexturedShape Texture coordinates functionality added StdPrs_ShadedShape to eliminate code duplication. Eliminated usage of TriangleSet from QABugs_PresentableObject Eliminated usage of TriangleMesh from StdPrs_ShadedSurface Removed TriangleMesh and TriangleSet support OpenGl_PrimitiveArray - render Edges only for primitives > GL_LINE_STRIP Added vgrid command to show grid in 3D Viewer
This commit is contained in:
@@ -60,6 +60,7 @@ is
|
||||
class HLRToolShape;
|
||||
--class ToolSectionShape;
|
||||
class ToolShadedShape;
|
||||
class ShadedShape;
|
||||
|
||||
|
||||
class Point
|
||||
@@ -97,9 +98,6 @@ is
|
||||
class ShadedSurface;
|
||||
---Purpose: computes the shading presentation of surfaces.
|
||||
|
||||
class ShadedPoleSurface;
|
||||
|
||||
|
||||
-----------------------------------------------
|
||||
--- deflection drawing classes :
|
||||
-----------------------------------------------
|
||||
@@ -140,15 +138,6 @@ is
|
||||
Curve from StdPrs,
|
||||
Vertex from StdPrs);
|
||||
|
||||
|
||||
class ShadedShape instantiates ShadedShape from Prs3d
|
||||
(Shape from TopoDS,
|
||||
Face from TopoDS,
|
||||
Triangle from BRepMesh,
|
||||
Edge from BRepMesh,
|
||||
ToolShadedShape from StdPrs);
|
||||
|
||||
|
||||
class HLRShape instantiates HLRShape from Prs3d
|
||||
(Shape from TopoDS,
|
||||
HLRToolShape from StdPrs,
|
||||
|
@@ -1,48 +0,0 @@
|
||||
-- Created on: 1993-07-05
|
||||
-- Created by: Jean Louis FRENKEL
|
||||
-- Copyright (c) 1993-1999 Matra Datavision
|
||||
-- Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
--
|
||||
-- The content of this file is subject to the Open CASCADE Technology Public
|
||||
-- License Version 6.5 (the "License"). You may not use the content of this file
|
||||
-- except in compliance with the License. Please obtain a copy of the License
|
||||
-- at http://www.opencascade.org and read it completely before using this file.
|
||||
--
|
||||
-- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
-- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
--
|
||||
-- The Original Code and all software distributed under the License is
|
||||
-- distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
-- Initial Developer hereby disclaims all such warranties, including without
|
||||
-- limitation, any warranties of merchantability, fitness for a particular
|
||||
-- purpose or non-infringement. Please see the License for the specific terms
|
||||
-- and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
|
||||
class ShadedPoleSurface from StdPrs
|
||||
|
||||
inherits Root from Prs3d
|
||||
--- Purpose: Draws a surface by drawing the isoparametric curves with respect to
|
||||
-- a maximal chordial deviation.
|
||||
-- The number of isoparametric curves to be drawn and their color are
|
||||
-- controlled by the furnished Drawer.
|
||||
|
||||
uses
|
||||
Presentation from Prs3d,
|
||||
Surface from Adaptor3d,
|
||||
Drawer from Prs3d
|
||||
|
||||
is
|
||||
|
||||
|
||||
Add(myclass; aPresentation: Presentation from Prs3d;
|
||||
aSurface : Surface from Adaptor3d;
|
||||
aDrawer : Drawer from Prs3d);
|
||||
---Purpose: Adds the surface aSurface to the presentation object aPresentation.
|
||||
-- The surface's display attributes are set in the attribute manager, aDrawer.
|
||||
|
||||
end ShadedPoleSurface;
|
||||
|
||||
|
||||
|
@@ -1,125 +0,0 @@
|
||||
// Created on: 1995-08-01
|
||||
// Created by: Modelistation
|
||||
// Copyright (c) 1995-1999 Matra Datavision
|
||||
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
||||
//
|
||||
// The content of this file is subject to the Open CASCADE Technology Public
|
||||
// License Version 6.5 (the "License"). You may not use the content of this file
|
||||
// except in compliance with the License. Please obtain a copy of the License
|
||||
// at http://www.opencascade.org and read it completely before using this file.
|
||||
//
|
||||
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
||||
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
||||
//
|
||||
// The Original Code and all software distributed under the License is
|
||||
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
||||
// Initial Developer hereby disclaims all such warranties, including without
|
||||
// limitation, any warranties of merchantability, fitness for a particular
|
||||
// purpose or non-infringement. Please see the License for the specific terms
|
||||
// and conditions governing the rights and limitations under the License.
|
||||
|
||||
|
||||
#define G005 //ATS,GG 04/01/01 Use PrimitiveArray instead Sets of primitives
|
||||
// for performance improvment
|
||||
|
||||
#include <StdPrs_ShadedPoleSurface.ixx>
|
||||
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_Array2OfVertex.hxx>
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
#ifdef G005
|
||||
#include <Graphic3d_ArrayOfQuadrangleStrips.hxx>
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void StdPrs_ShadedPoleSurface::Add(
|
||||
const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Adaptor3d_Surface& aSurface,
|
||||
const Handle (Prs3d_Drawer)& aDrawer)
|
||||
{
|
||||
if ( ! aDrawer->ShadingAspectGlobal() ) {
|
||||
|
||||
// If the surface is closed, the faces from back-side are not traced:
|
||||
|
||||
|
||||
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
|
||||
if(aSurface.IsUClosed() && aSurface.IsVClosed()) {
|
||||
Asp->SuppressBackFace();
|
||||
} else {
|
||||
Asp->AllowBackFace();
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
|
||||
}
|
||||
|
||||
Standard_Integer i,j,n = aSurface.NbUPoles(), m = aSurface.NbVPoles();
|
||||
|
||||
if (aSurface.GetType() == GeomAbs_BezierSurface) {
|
||||
Handle(Geom_BezierSurface) surface = aSurface.Bezier();
|
||||
#ifdef G005
|
||||
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
|
||||
Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
|
||||
new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
|
||||
Standard_False,Standard_False,Standard_False,Standard_False);
|
||||
for ( i=1; i<=n; i++) {
|
||||
parray->AddBound(m);
|
||||
for ( j=1; j<=m; j++) {
|
||||
parray->AddVertex(surface->Pole(i,j));
|
||||
}
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
TColgp_Array2OfPnt A(1,n,1,m);
|
||||
surface->Poles(A);
|
||||
Graphic3d_Array2OfVertex V(1,n,1,m);
|
||||
Standard_Real x,y,z;
|
||||
for ( i=1; i<=n; i++) {
|
||||
for ( j=1; j<=m; j++) {
|
||||
A(i,j).Coord(x,y,z);
|
||||
V(i,j).SetCoord(x,y,z);
|
||||
}
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);
|
||||
}
|
||||
else if (aSurface.GetType() == GeomAbs_BSplineSurface) {
|
||||
Handle(Geom_BSplineSurface) surface = aSurface.BSpline();
|
||||
#ifdef G005
|
||||
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
|
||||
Handle(Graphic3d_ArrayOfQuadrangleStrips) parray =
|
||||
new Graphic3d_ArrayOfQuadrangleStrips(n*m,n,
|
||||
Standard_False,Standard_False,Standard_False,Standard_False);
|
||||
for ( i=1; i<=n; i++) {
|
||||
parray->AddBound(m);
|
||||
for ( j=1; j<=m; j++) {
|
||||
parray->AddVertex(surface->Pole(i,j));
|
||||
}
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
TColgp_Array2OfPnt A(1,n,1,m);
|
||||
surface->Poles(A);
|
||||
Graphic3d_Array2OfVertex V(1,n,1,m);
|
||||
Standard_Real x,y,z;
|
||||
for ( i=1; i<=n; i++) {
|
||||
for ( j=1; j<=m; j++) {
|
||||
A(i,j).Coord(x,y,z);
|
||||
V(i,j).SetCoord(x,y,z);
|
||||
}
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->QuadrangleMesh(V);
|
||||
}
|
||||
}
|
36
src/StdPrs/StdPrs_ShadedShape.cdl
Normal file
36
src/StdPrs/StdPrs_ShadedShape.cdl
Normal file
@@ -0,0 +1,36 @@
|
||||
-- File: StdPrs_ShadedShape.cdl
|
||||
-- Created: 23 Sep 1993
|
||||
-- Author: Jean Louis FRENKEL
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
class ShadedShape from StdPrs
|
||||
|
||||
inherits Root from Prs3d
|
||||
--- Purpose: unknown.
|
||||
|
||||
uses
|
||||
|
||||
Presentation from Prs3d,
|
||||
Drawer from Prs3d,
|
||||
Shape from TopoDS,
|
||||
Pnt2d from gp
|
||||
|
||||
is
|
||||
|
||||
Add (myclass;
|
||||
thePresentation : Presentation from Prs3d;
|
||||
theShape : Shape from TopoDS;
|
||||
theDrawer : Drawer from Prs3d);
|
||||
---Purpose: Shades <theShape>.
|
||||
|
||||
Add (myclass;
|
||||
thePresentation : Presentation from Prs3d;
|
||||
theShape : Shape from TopoDS;
|
||||
theDrawer : Drawer from Prs3d;
|
||||
theHasTexels : Boolean from Standard;
|
||||
theUVOrigin : Pnt2d from gp;
|
||||
theUVRepeat : Pnt2d from gp;
|
||||
theUVScale : Pnt2d from gp);
|
||||
---Purpose: Shades <theShape> with texture coordinates.
|
||||
|
||||
end ShadedShape;
|
289
src/StdPrs/StdPrs_ShadedShape.cxx
Normal file
289
src/StdPrs/StdPrs_ShadedShape.cxx
Normal file
@@ -0,0 +1,289 @@
|
||||
// File: StdPrs_ShadedShape.cxx
|
||||
// Created: 23 Sep 1993
|
||||
// Author: Jean-Louis FRENKEL
|
||||
// Copyright: OPEN CASCADE 2012
|
||||
|
||||
#include <StdPrs_ShadedShape.hxx>
|
||||
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepMesh_DiscretFactory.hxx>
|
||||
#include <BRepMesh_DiscretRoot.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <Graphic3d_ArrayOfTriangles.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_Presentation.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Poly_Connect.hxx>
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <StdPrs_ToolShadedShape.hxx>
|
||||
#include <StdPrs_WFShape.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TColgp_Array1OfDir.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
|
||||
#define MAX2(X, Y) (Abs(X) > Abs(Y) ? Abs(X) : Abs(Y))
|
||||
#define MAX3(X, Y, Z) (MAX2 (MAX2 (X, Y), Z))
|
||||
|
||||
namespace
|
||||
{
|
||||
// =======================================================================
|
||||
// function : GetDeflection
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
static Standard_Real GetDeflection (const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Standard_Real aDeflection = theDrawer->MaximalChordialDeviation();
|
||||
if (theDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE)
|
||||
{
|
||||
Bnd_Box aBndBox;
|
||||
BRepBndLib::Add (theShape, aBndBox, Standard_False);
|
||||
if (!aBndBox.IsVoid())
|
||||
{
|
||||
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||
aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||
aDeflection = MAX3 (aXmax-aXmin, aYmax-aYmin, aZmax-aZmin) * theDrawer->DeviationCoefficient() * 4.0;
|
||||
}
|
||||
}
|
||||
return aDeflection;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ShadeFromShape
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
static Standard_Boolean ShadeFromShape (const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const Handle (Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale)
|
||||
{
|
||||
StdPrs_ToolShadedShape SST;
|
||||
Handle(Poly_Triangulation) T;
|
||||
TopLoc_Location aLoc;
|
||||
gp_Pnt p;
|
||||
Standard_Integer decal;
|
||||
Standard_Integer t[3], n[3];
|
||||
Standard_Integer nbTriangles = 0, nbVertices = 0;
|
||||
Standard_Real aUmin (0.0), aUmax (0.0), aVmin (0.0), aVmax (0.0), dUmax (0.0), dVmax (0.0);
|
||||
|
||||
// precision for compare square distances
|
||||
const double aPreci = Precision::Confusion() * Precision::Confusion();
|
||||
|
||||
if (!theDrawer->ShadingAspectGlobal())
|
||||
{
|
||||
Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
|
||||
if (StdPrs_ToolShadedShape::IsClosed (theShape))
|
||||
{
|
||||
anAsp->SuppressBackFace();
|
||||
}
|
||||
else
|
||||
{
|
||||
anAsp->AllowBackFace();
|
||||
}
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->SetGroupPrimitivesAspect (anAsp);
|
||||
}
|
||||
|
||||
for (SST.Init (theShape); SST.MoreFace(); SST.NextFace())
|
||||
{
|
||||
const TopoDS_Face& aFace = SST.CurrentFace();
|
||||
T = SST.Triangulation (aFace, aLoc);
|
||||
if (!T.IsNull())
|
||||
{
|
||||
nbTriangles += T->NbTriangles();
|
||||
nbVertices += T->NbNodes();
|
||||
}
|
||||
}
|
||||
|
||||
if (nbVertices > 2 && nbTriangles > 0)
|
||||
{
|
||||
Handle(Graphic3d_ArrayOfTriangles) aPArray
|
||||
= new Graphic3d_ArrayOfTriangles (nbVertices, 3 * nbTriangles,
|
||||
Standard_True, Standard_False, theHasTexels, Standard_True);
|
||||
for (SST.Init (theShape); SST.MoreFace(); SST.NextFace())
|
||||
{
|
||||
const TopoDS_Face& aFace = SST.CurrentFace();
|
||||
T = SST.Triangulation (aFace, aLoc);
|
||||
if (T.IsNull())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const gp_Trsf& aTrsf = aLoc.Transformation();
|
||||
Poly_Connect pc (T);
|
||||
// Extracts vertices & normals from nodes
|
||||
const TColgp_Array1OfPnt& aNodes = T->Nodes();
|
||||
const TColgp_Array1OfPnt2d& aUVNodes = T->UVNodes();
|
||||
TColgp_Array1OfDir aNormals (aNodes.Lower(), aNodes.Upper());
|
||||
SST.Normal (aFace, pc, aNormals);
|
||||
|
||||
if (theHasTexels)
|
||||
{
|
||||
BRepTools::UVBounds (aFace, aUmin, aUmax, aVmin, aVmax);
|
||||
dUmax = (aUmax - aUmin);
|
||||
dVmax = (aVmax - aVmin);
|
||||
}
|
||||
|
||||
decal = aPArray->VertexNumber();
|
||||
for (Standard_Integer aNodeIter = aNodes.Lower(); aNodeIter <= aNodes.Upper(); ++aNodeIter)
|
||||
{
|
||||
p = aNodes (aNodeIter);
|
||||
if (!aLoc.IsIdentity())
|
||||
{
|
||||
p.Transform (aTrsf);
|
||||
aNormals (aNodeIter).Transform (aTrsf);
|
||||
}
|
||||
|
||||
if (theHasTexels && aUVNodes.Upper() == aNodes.Upper())
|
||||
{
|
||||
const gp_Pnt2d aTexel = gp_Pnt2d ((-theUVOrigin.X() + (theUVRepeat.X() * (aUVNodes (aNodeIter).X() - aUmin)) / dUmax) / theUVScale.X(),
|
||||
(-theUVOrigin.Y() + (theUVRepeat.Y() * (aUVNodes (aNodeIter).Y() - aVmin)) / dVmax) / theUVScale.Y());
|
||||
aPArray->AddVertex (p, aNormals (aNodeIter), aTexel);
|
||||
}
|
||||
else
|
||||
{
|
||||
aPArray->AddVertex (p, aNormals (aNodeIter));
|
||||
}
|
||||
}
|
||||
|
||||
// Fill parray with vertex and edge visibillity info
|
||||
const Poly_Array1OfTriangle& aTriangles = T->Triangles();
|
||||
for (Standard_Integer aTriIter = 1; aTriIter <= T->NbTriangles(); ++aTriIter)
|
||||
{
|
||||
pc.Triangles (aTriIter, t[0], t[1], t[2]);
|
||||
if (SST.Orientation (aFace) == TopAbs_REVERSED)
|
||||
aTriangles (aTriIter).Get (n[0], n[2], n[1]);
|
||||
else
|
||||
aTriangles (aTriIter).Get (n[0], n[1], n[2]);
|
||||
|
||||
gp_Pnt P1 = aNodes (n[0]);
|
||||
gp_Pnt P2 = aNodes (n[1]);
|
||||
gp_Pnt P3 = aNodes (n[2]);
|
||||
|
||||
gp_Vec V1 (P1, P2);
|
||||
if (V1.SquareMagnitude() <= aPreci)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gp_Vec V2 (P2, P3);
|
||||
if (V2.SquareMagnitude() <= aPreci)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
gp_Vec V3 (P3, P1);
|
||||
if (V3.SquareMagnitude() <= aPreci)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
V1.Normalize();
|
||||
V2.Normalize();
|
||||
V1.Cross (V2);
|
||||
if (V1.SquareMagnitude() > aPreci)
|
||||
{
|
||||
aPArray->AddEdge (n[0] + decal, t[0] == 0);
|
||||
aPArray->AddEdge (n[1] + decal, t[1] == 0);
|
||||
aPArray->AddEdge (n[2] + decal, t[2] == 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->BeginPrimitives();
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->AddPrimitiveArray (aPArray);
|
||||
Prs3d_Root::CurrentGroup (thePresentation)->EndPrimitives();
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
};
|
||||
|
||||
// =======================================================================
|
||||
// function : Add
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void StdPrs_ShadedShape::Add (const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
gp_Pnt2d aDummy;
|
||||
StdPrs_ShadedShape::Add (thePresentation, theShape, theDrawer,
|
||||
Standard_False, aDummy, aDummy, aDummy);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Add
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void StdPrs_ShadedShape::Add (const Handle (Prs3d_Presentation)& thePresentation,
|
||||
const TopoDS_Shape& theShape,
|
||||
const Handle (Prs3d_Drawer)& theDrawer,
|
||||
const Standard_Boolean theHasTexels,
|
||||
const gp_Pnt2d& theUVOrigin,
|
||||
const gp_Pnt2d& theUVRepeat,
|
||||
const gp_Pnt2d& theUVScale)
|
||||
{
|
||||
if (theShape.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (theShape.ShapeType() == TopAbs_COMPOUND)
|
||||
{
|
||||
TopExp_Explorer ex;
|
||||
ex.Init (theShape, TopAbs_FACE);
|
||||
if (ex.More())
|
||||
{
|
||||
TopoDS_Compound CO;
|
||||
BRep_Builder aBuilder;
|
||||
aBuilder.MakeCompound (CO);
|
||||
Standard_Boolean hasElement = Standard_False;
|
||||
|
||||
// il faut presenter les edges isoles.
|
||||
for (ex.Init (theShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next())
|
||||
{
|
||||
hasElement = Standard_True;
|
||||
aBuilder.Add (CO, ex.Current());
|
||||
}
|
||||
// il faut presenter les vertex isoles.
|
||||
for (ex.Init (theShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next())
|
||||
{
|
||||
hasElement = Standard_True;
|
||||
aBuilder.Add (CO, ex.Current());
|
||||
}
|
||||
if (hasElement)
|
||||
{
|
||||
StdPrs_WFShape::Add (thePresentation, CO, theDrawer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
StdPrs_WFShape::Add (thePresentation, theShape, theDrawer);
|
||||
}
|
||||
}
|
||||
Standard_Real aDeflection = GetDeflection (theShape, theDrawer);
|
||||
|
||||
// Check if it is possible to avoid unnecessary recomputation
|
||||
// of shape triangulation
|
||||
if (!BRepTools::Triangulation (theShape, aDeflection))
|
||||
{
|
||||
BRepTools::Clean (theShape);
|
||||
|
||||
// retrieve meshing tool from Factory
|
||||
Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (theShape,
|
||||
aDeflection,
|
||||
theDrawer->HLRAngle());
|
||||
if (!aMeshAlgo.IsNull())
|
||||
aMeshAlgo->Perform();
|
||||
}
|
||||
|
||||
ShadeFromShape (theShape, thePresentation, theDrawer,
|
||||
theHasTexels, theUVOrigin, theUVRepeat, theUVScale);
|
||||
}
|
||||
|
@@ -24,158 +24,95 @@
|
||||
|
||||
#include <StdPrs_ShadedSurface.ixx>
|
||||
|
||||
#include <Graphic3d_ArrayOfTriangleStrips.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_Group.hxx>
|
||||
#include <Graphic3d_Vertex.hxx>
|
||||
#include <Graphic3d_VertexN.hxx>
|
||||
#include <Graphic3d_Array1OfVertexN.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#ifdef G005
|
||||
#include <Graphic3d_ArrayOfTriangleStrips.hxx>
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void StdPrs_ShadedSurface::Add(const Handle(Prs3d_Presentation)& aPresentation,
|
||||
const Adaptor3d_Surface& aSurface,
|
||||
const Handle(Prs3d_Drawer)& aDrawer)
|
||||
void StdPrs_ShadedSurface::Add (const Handle(Prs3d_Presentation)& thePrs,
|
||||
const Adaptor3d_Surface& theSurface,
|
||||
const Handle(Prs3d_Drawer)& theDrawer)
|
||||
{
|
||||
Standard_Integer N1 = aDrawer->UIsoAspect()->Number();
|
||||
Standard_Integer N2 = aDrawer->VIsoAspect()->Number();
|
||||
|
||||
Standard_Integer N1 = theDrawer->UIsoAspect()->Number();
|
||||
Standard_Integer N2 = theDrawer->VIsoAspect()->Number();
|
||||
N1 = N1 < 3 ? 3 : N1;
|
||||
N2 = N2 < 3 ? 3 : N2;
|
||||
|
||||
if ( ! aDrawer->ShadingAspectGlobal() ) {
|
||||
|
||||
// If the surface is closed, the faces from back-side are not traced:
|
||||
|
||||
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
|
||||
|
||||
if(aSurface.IsUClosed() && aSurface.IsVClosed()) {
|
||||
Asp->SuppressBackFace();
|
||||
} else {
|
||||
Asp->AllowBackFace();
|
||||
if (!theDrawer->ShadingAspectGlobal())
|
||||
{
|
||||
// If the surface is closed, the faces from back-side are not traced:
|
||||
Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
|
||||
if (theSurface.IsUClosed() && theSurface.IsVClosed())
|
||||
{
|
||||
anAsp->SuppressBackFace();
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->SetPrimitivesAspect(Asp);
|
||||
else
|
||||
{
|
||||
anAsp->AllowBackFace();
|
||||
}
|
||||
Prs3d_Root::CurrentGroup (thePrs)->SetGroupPrimitivesAspect (anAsp);
|
||||
}
|
||||
|
||||
Standard_Integer NBUintv = aSurface.NbUIntervals(GeomAbs_C1);
|
||||
Standard_Integer NBVintv = aSurface.NbVIntervals(GeomAbs_C1);
|
||||
TColStd_Array1OfReal InterU(1, NBUintv+1);
|
||||
TColStd_Array1OfReal InterV(1, NBVintv+1);
|
||||
|
||||
aSurface.UIntervals(InterU, GeomAbs_C1);
|
||||
aSurface.VIntervals(InterV, GeomAbs_C1);
|
||||
|
||||
Standard_Real U1, U2, V1, V2, DU, DV;
|
||||
|
||||
Standard_Integer i,j;
|
||||
|
||||
gp_Pnt P1,P2;
|
||||
gp_Vec D1U,D1V,D1,D2;
|
||||
Standard_Integer aNBUintv = theSurface.NbUIntervals (GeomAbs_C1);
|
||||
Standard_Integer aNBVintv = theSurface.NbVIntervals (GeomAbs_C1);
|
||||
TColStd_Array1OfReal anInterU (1, aNBUintv + 1);
|
||||
TColStd_Array1OfReal anInterV (1, aNBVintv + 1);
|
||||
|
||||
#ifdef G005
|
||||
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
|
||||
for (Standard_Integer NU = 1; NU <= NBUintv; NU++) {
|
||||
for (Standard_Integer NV = 1; NV <= NBVintv; NV++) {
|
||||
U1 = InterU(NU); U2 = InterU(NU+1);
|
||||
V1 = InterV(NV); V2 = InterV(NV+1);
|
||||
theSurface.UIntervals (anInterU, GeomAbs_C1);
|
||||
theSurface.VIntervals (anInterV, GeomAbs_C1);
|
||||
|
||||
U1 = (Precision::IsNegativeInfinite(U1)) ? - aDrawer->MaximalParameterValue() : U1;
|
||||
U2 = (Precision::IsPositiveInfinite(U2)) ? aDrawer->MaximalParameterValue() : U2;
|
||||
|
||||
V1 = (Precision::IsNegativeInfinite(V1)) ? - aDrawer->MaximalParameterValue() : V1;
|
||||
V2 = (Precision::IsPositiveInfinite(V2)) ? aDrawer->MaximalParameterValue() : V2;
|
||||
|
||||
DU = (U2-U1)/ N1;
|
||||
DV = (V2-V1)/ N2;
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangleStrips) parray = new
|
||||
Graphic3d_ArrayOfTriangleStrips(2*(N1+1)*(N2+1),N1+1,
|
||||
Standard_True,Standard_False,Standard_False,Standard_False);
|
||||
for ( i = 1; i<= N1+1; i++) {
|
||||
parray->AddBound(N2+1);
|
||||
for (j = 1; j <= N2+1; j++) {
|
||||
aSurface.D1(U1 + DU * (i-1), V1 + DV * (j-1),P2,D1U,D1V);
|
||||
D1 = D1U^D1V;
|
||||
D1.Normalize();
|
||||
aSurface.D1(U1 + DU * i, V1 + DV * (j-1),P2,D1U,D1V);
|
||||
D2 = D1U^D1V;
|
||||
D2.Normalize();
|
||||
parray->AddVertex(P1,D1);
|
||||
parray->AddVertex(P2,D2);
|
||||
}
|
||||
Standard_Real U1, U2, V1, V2, DU, DV;
|
||||
|
||||
gp_Pnt P1, P2;
|
||||
gp_Vec D1U, D1V, D1, D2;
|
||||
|
||||
Prs3d_Root::CurrentGroup (thePrs)->BeginPrimitives();
|
||||
for (Standard_Integer NU = 1; NU <= aNBUintv; ++NU)
|
||||
{
|
||||
for (Standard_Integer NV = 1; NV <= aNBVintv; ++NV)
|
||||
{
|
||||
U1 = anInterU (NU); U2 = anInterU (NU + 1);
|
||||
V1 = anInterV (NV); V2 = anInterV (NV + 1);
|
||||
|
||||
U1 = (Precision::IsNegativeInfinite (U1)) ? - theDrawer->MaximalParameterValue() : U1;
|
||||
U2 = (Precision::IsPositiveInfinite (U2)) ? theDrawer->MaximalParameterValue() : U2;
|
||||
|
||||
V1 = (Precision::IsNegativeInfinite (V1)) ? - theDrawer->MaximalParameterValue() : V1;
|
||||
V2 = (Precision::IsPositiveInfinite (V2)) ? theDrawer->MaximalParameterValue() : V2;
|
||||
|
||||
DU = (U2 - U1) / N1;
|
||||
DV = (V2 - V1) / N2;
|
||||
|
||||
Handle(Graphic3d_ArrayOfTriangleStrips) aPArray
|
||||
= new Graphic3d_ArrayOfTriangleStrips (2 * (N1 + 1) * (N2 + 1), N1 + 1,
|
||||
Standard_True, Standard_False, Standard_False, Standard_False);
|
||||
for (Standard_Integer i = 1; i <= N1 + 1; ++i)
|
||||
{
|
||||
aPArray->AddBound (N2 + 1);
|
||||
for (Standard_Integer j = 1; j <= N2 + 1; ++j)
|
||||
{
|
||||
theSurface.D1 (U1 + DU * (i - 1), V1 + DV * (j - 1), P2, D1U, D1V);
|
||||
D1 = D1U ^ D1V;
|
||||
D1.Normalize();
|
||||
theSurface.D1 (U1 + DU * i, V1 + DV * (j - 1), P2, D1U, D1V);
|
||||
D2 = D1U ^ D1V;
|
||||
D2.Normalize();
|
||||
aPArray->AddVertex (P1, D1);
|
||||
aPArray->AddVertex (P2, D2);
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
|
||||
Prs3d_Root::CurrentGroup (thePrs)->AddPrimitiveArray (aPArray);
|
||||
}
|
||||
return;
|
||||
Prs3d_Root::CurrentGroup (thePrs)->EndPrimitives();
|
||||
}
|
||||
#endif
|
||||
gp_Pnt P;
|
||||
gp_Vec Normale;
|
||||
Quantity_Length x,y,z;
|
||||
Graphic3d_Array1OfVertexN A1 ( 1 , N2+1);
|
||||
Graphic3d_Array1OfVertexN A2 ( 1 , N2+1);
|
||||
Graphic3d_Array1OfVertexN TriangleStrip ( 1, 2*(N2+1));
|
||||
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
|
||||
for (Standard_Integer NU = 1; NU <= NBUintv; NU++) {
|
||||
for (Standard_Integer NV = 1; NV <= NBVintv; NV++) {
|
||||
U1 = InterU(NU); U2 = InterU(NU+1);
|
||||
V1 = InterV(NV); V2 = InterV(NV+1);
|
||||
|
||||
U1 = (Precision::IsNegativeInfinite(U1)) ? - aDrawer->MaximalParameterValue() : U1;
|
||||
U2 = (Precision::IsPositiveInfinite(U2)) ? aDrawer->MaximalParameterValue() : U2;
|
||||
|
||||
V1 = (Precision::IsNegativeInfinite(V1)) ? - aDrawer->MaximalParameterValue() : V1;
|
||||
V2 = (Precision::IsPositiveInfinite(V2)) ? aDrawer->MaximalParameterValue() : V2;
|
||||
|
||||
DU = (U2-U1)/ N1;
|
||||
DV = (V2-V1)/ N2;
|
||||
|
||||
// Calculation of the first line;
|
||||
|
||||
for ( i = 1; i<= N2+1; i++) {
|
||||
aSurface.D1(U1 , V1 + DV * (i-1),P,D1U,D1V);
|
||||
P.Coord(x,y,z);
|
||||
A1(i).SetCoord (x,y,z);
|
||||
Normale = D1U^D1V;
|
||||
Normale.Normalize();
|
||||
Normale.Coord(x,y,z);
|
||||
A1(i).SetNormal(x,y,z);
|
||||
}
|
||||
|
||||
for ( i = 2; i<= N1+1; i++) {
|
||||
for (j = 1; j <= N2+1; j++) {
|
||||
aSurface.D1(U1 + DU * (i-1), V1 + DV * (j-1),
|
||||
P,D1U,D1V);
|
||||
|
||||
P.Coord(x,y,z);
|
||||
A2(j).SetCoord (x,y,z);
|
||||
Normale = D1U^D1V;
|
||||
Normale.Normalize();
|
||||
Normale.Coord(x,y,z);
|
||||
A2(j).SetNormal(x,y,z);
|
||||
TriangleStrip (2*(j-1) + 1) = A1(j);
|
||||
TriangleStrip (2*(j-1) + 2) = A2(j);
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->TriangleMesh(TriangleStrip);
|
||||
for ( j = 1; j <= N2 + 1; j++) { A1(j) = A2(j);}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
|
||||
}
|
||||
|
Reference in New Issue
Block a user