1
0
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:
kgv
2012-03-30 17:25:28 +04:00
parent d402d481e5
commit 2bd4c032a3
37 changed files with 977 additions and 5737 deletions

View File

@@ -160,9 +160,6 @@ is
generic class SectionShapeTool;
generic class ShadedShape;
---Category: Basis construction elements.
generic class Vector;
generic class Datum;

View File

@@ -1,43 +0,0 @@
-- Created on: 1993-09-23
-- 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.
generic class ShadedShape from Prs3d(anyShape as any;
anyTopFace as any;
anyMeshTriangle as any;
anyMeshEdge as any;
anyShadedShapeTool as any
)
inherits Root from Prs3d
uses
Presentation from Prs3d,
Drawer from Prs3d
is
Add(myclass; aPresentation: Presentation from Prs3d;
aShape : anyShape;
aDrawer : Drawer from Prs3d);
---Purpose: Shades <aShape>.
end ShadedShape from Prs3d;

View File

@@ -1,351 +0,0 @@
// Created on: 1993-09-23
// 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.
//#define BUC60488//GG_081199 Enable the SuppressBackface() ShadingAspect attribute
#define G005 //ATS,GG 04/01/01 Use ArrayOfPrimitives instead Sets of primitives
// for performance improvment
#include <Graphic3d_Vertex.hxx>
#include <Graphic3d_VertexN.hxx>
#include <Graphic3d_Array1OfVertexN.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Aspect_Edge.hxx>
#include <Aspect_Array1OfEdge.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Graphic3d_Group.hxx>
#include <Aspect_TypeOfEdge.hxx>
#include <Bnd_Box.hxx>
#include <Graphic3d_AspectFillArea3d.hxx>
#include <BRepTools.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
#include <Poly_Triangulation.hxx>
#include <TColgp_HArray1OfPnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_Array1OfDir.hxx>
#include <Poly_Connect.hxx>
#include <TopAbs_Orientation.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <BRepMesh_FactoryError.hxx>
#include <BRepMesh_DiscretRoot.hxx>
#include <BRepMesh_DiscretFactory.hxx>
#include <BRepMesh_PDiscretRoot.hxx>
#include <gp_Vec.hxx>
#include <StdPrs_WFShape.hxx>
#include <BRepBndLib.hxx>
#include <Precision.hxx>
#ifdef G005
#include <Graphic3d_ArrayOfTriangles.hxx>
#endif
#define MAX2(X, Y) ( Abs(X) > Abs(Y)? Abs(X) : Abs(Y) )
#define MAX3(X, Y, Z) ( MAX2 ( MAX2(X,Y) , Z) )
static Standard_Real GetDeflection(const anyShape& aShape,
const Handle(Prs3d_Drawer)& aDrawer)
{
Standard_Real aDeflection = aDrawer->MaximalChordialDeviation();
if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) {
Bnd_Box B;
BRepBndLib::Add(aShape, B, Standard_False);
if ( ! B.IsVoid() )
{
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
aDeflection = MAX3( aXmax-aXmin , aYmax-aYmin , aZmax-aZmin)
* aDrawer->DeviationCoefficient()*4;
}
}
return aDeflection;
}
static Standard_Boolean ShadeFromShape(const anyShape& aShape,
const Standard_Real /*defle*/,
const Standard_Boolean /*share*/,
const Handle (Prs3d_Presentation)& aPresentation,
const Handle (Prs3d_Drawer)& aDrawer)
{
anyShadedShapeTool SST;
Handle(Poly_Triangulation) T;
TopLoc_Location loc;
gp_Pnt p;
Standard_Integer i,j,k,decal ;
Standard_Integer t[3], n[3];
Standard_Integer nbTriangles = 0, nbVertices = 0;
// precision for compare square distances
double dPreci = Precision::Confusion()*Precision::Confusion();
if ( !aDrawer->ShadingAspectGlobal() ) {
Handle(Graphic3d_AspectFillArea3d) Asp = aDrawer->ShadingAspect()->Aspect();
if(anyShadedShapeTool::IsClosed(aShape)) {
Asp->SuppressBackFace();
} else {
Asp->AllowBackFace();
}
Prs3d_Root::CurrentGroup(aPresentation)->SetGroupPrimitivesAspect(Asp);
}
#ifdef G005
if( Graphic3d_ArrayOfPrimitives::IsEnable() ) {
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
nbTriangles += T->NbTriangles();
nbVertices += T->NbNodes();
}
}
if (nbVertices > 2 && nbTriangles > 0) {
Handle(Graphic3d_ArrayOfTriangles) parray =
new Graphic3d_ArrayOfTriangles(nbVertices,3*nbTriangles,
Standard_True,Standard_False,Standard_False,Standard_True);
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
const gp_Trsf& trsf = loc.Transformation();
Poly_Connect pc(T);
// Extracts vertices & normals from nodes
const TColgp_Array1OfPnt& Nodes = T->Nodes();
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
SST.Normal(F, pc, NORMAL);
decal = parray->VertexNumber();
for (i= Nodes.Lower(); i<= Nodes.Upper(); i++) {
p = Nodes(i);
if( !loc.IsIdentity() ) {
p.Transform(trsf);
NORMAL(i).Transform(trsf);
}
parray->AddVertex(p,NORMAL(i));
}
// Fill parray with vertex and edge visibillity info
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = 1; i <= T->NbTriangles(); i++) {
pc.Triangles(i,t[0],t[1],t[2]);
if (SST.Orientation(F) == TopAbs_REVERSED)
triangles(i).Get(n[0],n[2],n[1]);
else
triangles(i).Get(n[0],n[1],n[2]);
gp_Pnt P1 = Nodes(n[0]);
gp_Pnt P2 = Nodes(n[1]);
gp_Pnt P3 = Nodes(n[2]);
gp_Vec V1(P1,P2);
if ( V1.SquareMagnitude() > dPreci ) {
gp_Vec V2(P2,P3);
if ( V2.SquareMagnitude() > dPreci ) {
gp_Vec V3(P3,P1);
if ( V3.SquareMagnitude() > dPreci ) {
V1.Normalize();
V2.Normalize();
V1.Cross(V2);
if ( V1.SquareMagnitude() > dPreci ) {
parray->AddEdge(n[0]+decal,t[0] == 0);
parray->AddEdge(n[1]+decal,t[1] == 0);
parray->AddEdge(n[2]+decal,t[2] == 0);
}
}
}
}
}
}
}
Prs3d_Root::CurrentGroup(aPresentation)->BeginPrimitives();
Prs3d_Root::CurrentGroup(aPresentation)->AddPrimitiveArray(parray);
Prs3d_Root::CurrentGroup(aPresentation)->EndPrimitives();
}
return Standard_True;
}
#endif
// phase de comptage:
Standard_Integer nt, nnn, n1, n2, n3, nnv, EI;
static Standard_Integer plus1mod3[3] = {1, 2, 0};
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
nnn = T->NbTriangles();
const TColgp_Array1OfPnt& Nodes = T->Nodes();
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (nt = 1; nt <= nnn; nt++) {
if (SST.Orientation(F) == TopAbs_REVERSED)
triangles(nt).Get(n1,n3,n2);
else
triangles(nt).Get(n1,n2,n3);
const gp_Pnt& P1 = Nodes(n1);
const gp_Pnt& P2 = Nodes(n2);
const gp_Pnt& P3 = Nodes(n3);
gp_Vec V1(P1,P2);
if ( V1.SquareMagnitude() > dPreci ) {
gp_Vec V2(P2,P3);
if (V2.SquareMagnitude() > dPreci ) {
gp_Vec V3(P3,P1);
if (V3.SquareMagnitude() > dPreci ) {
V1.Normalize();
V2.Normalize();
V1.Cross(V2);
if (V1.SquareMagnitude() > dPreci ) {
nbTriangles++;
}
}
}
}
}
nbVertices += T->NbNodes();
}
}
if (nbVertices > 2 && nbTriangles > 0) {
Graphic3d_Array1OfVertexN AVN(1, nbVertices);
Aspect_Array1OfEdge AE(1, 3*nbTriangles);
EI = 1;
nnv = 1;
for (SST.Init(aShape); SST.MoreFace(); SST.NextFace()) {
const anyTopFace& F = SST.CurrentFace();
T = SST.Triangulation(F, loc);
if (!T.IsNull()) {
Poly_Connect pc(T);
// 1- les noeuds.
const TColgp_Array1OfPnt& Nodes = T->Nodes();
TColgp_Array1OfDir NORMAL(Nodes.Lower(), Nodes.Upper());
SST.Normal(F, pc, NORMAL);
decal = nnv-1;
for (j= Nodes.Lower(); j<= Nodes.Upper(); j++) {
p = Nodes(j).Transformed(loc.Transformation());
AVN(nnv).SetCoord(p.X(), p.Y(), p.Z());
AVN(nnv).SetNormal(NORMAL(j).X(), NORMAL(j).Y(), NORMAL(j).Z());
nnv++;
}
// 2- les edges.
nbTriangles = T->NbTriangles();
const Poly_Array1OfTriangle& triangles = T->Triangles();
for (i = 1; i <= nbTriangles; i++) {
pc.Triangles(i,t[0],t[1],t[2]);
if (SST.Orientation(F) == TopAbs_REVERSED)
triangles(i).Get(n[0],n[2],n[1]);
else
triangles(i).Get(n[0],n[1],n[2]);
const gp_Pnt& P1 = Nodes(n[0]);
const gp_Pnt& P2 = Nodes(n[1]);
const gp_Pnt& P3 = Nodes(n[2]);
gp_Vec V1(P1,P2);
if (V1.SquareMagnitude() > 1.e-10) {
gp_Vec V2(P2,P3);
if (V2.SquareMagnitude() > 1.e-10) {
gp_Vec V3(P3,P1);
if (V3.SquareMagnitude() > 1.e-10) {
V1.Normalize();
V2.Normalize();
V1.Cross(V2);
if (V1.SquareMagnitude() > 1.e-10) {
for (j = 0; j < 3; j++) {
k = plus1mod3[j];
if (t[j] == 0)
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_VISIBLE);
else
AE(EI).SetValues(n[j]+decal, n[k]+decal, Aspect_TOE_INVISIBLE);
EI++;
}
}
}
}
}
}
}
}
Prs3d_Root::CurrentGroup(aPresentation)->TriangleSet(AVN, AE);
}
return Standard_True;
}
void Prs3d_ShadedShape::Add(const Handle (Prs3d_Presentation)& aPresentation,
const anyShape& aShape,
const Handle (Prs3d_Drawer)& aDrawer)
{
if (aShape.IsNull()) return;
TopAbs_ShapeEnum E = aShape.ShapeType();
if (E == TopAbs_COMPOUND) {
TopExp_Explorer ex;
ex.Init(aShape, TopAbs_FACE);
if (ex.More()) {
TopoDS_Compound CO;
BRep_Builder B;
B.MakeCompound(CO);
Standard_Boolean haselement = Standard_False;
// il faut presenter les edges isoles.
for (ex.Init(aShape, TopAbs_EDGE, TopAbs_FACE); ex.More(); ex.Next()) {
haselement = Standard_True;
B.Add(CO, ex.Current());
}
// il faut presenter les vertex isoles.
for (ex.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); ex.More(); ex.Next()) {
haselement = Standard_True;
B.Add(CO, ex.Current());
}
if (haselement) StdPrs_WFShape::Add(aPresentation, CO, aDrawer);
}
else {
StdPrs_WFShape::Add(aPresentation, aShape, aDrawer);
}
}
Standard_Real aDeflection = GetDeflection(aShape, aDrawer);
// Check if it is possible to avoid unnecessary recomputation
// of shape triangulation
if (!BRepTools::Triangulation (aShape, aDeflection))
{
BRepTools::Clean (aShape);
// retrieve meshing tool from Factory
Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (aShape,
aDeflection,
aDrawer->HLRAngle());
if (!aMeshAlgo.IsNull())
aMeshAlgo->Perform();
}
ShadeFromShape(aShape, aDeflection, Standard_True, aPresentation, aDrawer);
}