mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0023743: AIS_Triangulation crashes if Poly_Triangulation has no normals
A crash on absent normals is avoided. AIS_Triangulation::Compute() is corrected so that it is much faster, Adding test case for this fix
This commit is contained in:
parent
5f05c0a3d8
commit
16e65a0347
@ -56,14 +56,9 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre
|
|||||||
case 0:
|
case 0:
|
||||||
const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes(); //Nodes
|
const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes(); //Nodes
|
||||||
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles(); //Triangle
|
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles(); //Triangle
|
||||||
const TShort_Array1OfShortReal& normals = myTriangulation->Normals(); //Normal
|
|
||||||
|
|
||||||
Standard_Boolean hasVNormals = Standard_False;
|
Standard_Boolean hasVNormals = myTriangulation->HasNormals();
|
||||||
Standard_Boolean hasVColors = Standard_False;
|
Standard_Boolean hasVColors = (myFlagColor == 1);
|
||||||
if( normals.Length() > 0 )
|
|
||||||
hasVNormals = Standard_True;
|
|
||||||
if( myFlagColor == 1 )
|
|
||||||
hasVColors = Standard_True;
|
|
||||||
|
|
||||||
Handle(Graphic3d_ArrayOfTriangles) anArray =
|
Handle(Graphic3d_ArrayOfTriangles) anArray =
|
||||||
new Graphic3d_ArrayOfTriangles ( myNbNodes, //maxVertexs
|
new Graphic3d_ArrayOfTriangles ( myNbNodes, //maxVertexs
|
||||||
@ -80,13 +75,46 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& aPre
|
|||||||
Standard_Integer j;
|
Standard_Integer j;
|
||||||
|
|
||||||
Standard_Real ambient = aspect->FrontMaterial().Ambient();
|
Standard_Real ambient = aspect->FrontMaterial().Ambient();
|
||||||
for ( i = nodes.Lower(); i<= nodes.Upper(); i++ ){
|
if (hasVNormals)
|
||||||
if( myFlagColor == 1 )
|
{
|
||||||
anArray->AddVertex( nodes(i), AttenuateColor(myColor->Value(i),ambient));
|
const TShort_Array1OfShortReal& normals = myTriangulation->Normals();
|
||||||
if( myFlagColor == 0 )
|
if (hasVColors)
|
||||||
anArray->AddVertex( nodes(i) );
|
{
|
||||||
j = (i - nodes.Lower()) * 3;
|
const TColStd_Array1OfInteger& colors = myColor->Array1();
|
||||||
anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
|
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
|
||||||
|
{
|
||||||
|
j = (i - nodes.Lower()) * 3;
|
||||||
|
anArray->AddVertex(nodes(i), AttenuateColor(colors(i), ambient));
|
||||||
|
anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // !hasVColors
|
||||||
|
{
|
||||||
|
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
|
||||||
|
{
|
||||||
|
j = (i - nodes.Lower()) * 3;
|
||||||
|
anArray->AddVertex(nodes(i));
|
||||||
|
anArray->SetVertexNormal(i, normals(j+1), normals(j+2), normals(j+3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // !hasVNormals
|
||||||
|
{
|
||||||
|
if (hasVColors)
|
||||||
|
{
|
||||||
|
const TColStd_Array1OfInteger& colors = myColor->Array1();
|
||||||
|
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
|
||||||
|
{
|
||||||
|
anArray->AddVertex(nodes(i), AttenuateColor(colors(i), ambient));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // !hasVColors
|
||||||
|
{
|
||||||
|
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ )
|
||||||
|
{
|
||||||
|
anArray->AddVertex(nodes(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Standard_Integer indexTriangle[3] = {0,0,0};
|
Standard_Integer indexTriangle[3] = {0,0,0};
|
||||||
|
13
tests/bugs/vis/bug23743
Executable file
13
tests/bugs/vis/bug23743
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
puts "================"
|
||||||
|
puts "CR23743"
|
||||||
|
puts "================"
|
||||||
|
puts ""
|
||||||
|
#######################################################################
|
||||||
|
# AIS_Triangulation crashes if Poly_Triangulation has no normals
|
||||||
|
#######################################################################
|
||||||
|
|
||||||
|
vinit
|
||||||
|
vdrawsphere result 100
|
||||||
|
vfit
|
||||||
|
|
||||||
|
set only_screen 1
|
Loading…
x
Reference in New Issue
Block a user