Adapt OCE 3D plugin to OpenCascade 7.6.0 (for KiCad 5.1)

In line with
https://dev.opencascade.org/doc/overview/html/occt__upgrade.html#upgrade_occt760_poly
the Poly_Triangulation does not provide direct access to the internal
arrays anymore - use the accessor functions instead.
To keep changes minimal, switch only builds with a new (7.6+)
OpenCascade to the new API and keep everything else the same.

Related: !1013
This commit is contained in:
Christoph Moench-Tegeder 2021-11-17 23:40:06 +01:00
parent 401b2fb524
commit 9a9c7856b3
1 changed files with 12 additions and 0 deletions

View File

@ -71,6 +71,8 @@
#include <TDF_LabelSequence.hxx> #include <TDF_LabelSequence.hxx>
#include <TDF_ChildIterator.hxx> #include <TDF_ChildIterator.hxx>
#include <Standard_Version.hxx>
#include "plugins/3dapi/ifsg_all.h" #include "plugins/3dapi/ifsg_all.h"
// log mask for wxLogTrace // log mask for wxLogTrace
@ -865,8 +867,10 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
else else
S3D::AddSGNodeRef( vshape.GetRawPtr(), ocolor ); S3D::AddSGNodeRef( vshape.GetRawPtr(), ocolor );
#if OCC_VERSION_HEX < 0x070600
const TColgp_Array1OfPnt& arrPolyNodes = triangulation->Nodes(); const TColgp_Array1OfPnt& arrPolyNodes = triangulation->Nodes();
const Poly_Array1OfTriangle& arrTriangles = triangulation->Triangles(); const Poly_Array1OfTriangle& arrTriangles = triangulation->Triangles();
#endif
std::vector< SGPOINT > vertices; std::vector< SGPOINT > vertices;
std::vector< int > indices; std::vector< int > indices;
@ -875,14 +879,22 @@ bool processFace( const TopoDS_Face& face, DATA& data, SGNODE* parent,
for(int i = 1; i <= triangulation->NbNodes(); i++) for(int i = 1; i <= triangulation->NbNodes(); i++)
{ {
#if OCC_VERSION_HEX < 0x070600
gp_XYZ v( arrPolyNodes(i).Coord() ); gp_XYZ v( arrPolyNodes(i).Coord() );
#else
gp_XYZ v( triangulation->Node(i).Coord() );
#endif
vertices.push_back( SGPOINT( v.X(), v.Y(), v.Z() ) ); vertices.push_back( SGPOINT( v.X(), v.Y(), v.Z() ) );
} }
for(int i = 1; i <= triangulation->NbTriangles(); i++) for(int i = 1; i <= triangulation->NbTriangles(); i++)
{ {
int a, b, c; int a, b, c;
#if OCC_VERSION_HEX < 0x070600
arrTriangles( i ).Get( a, b, c ); arrTriangles( i ).Get( a, b, c );
#else
triangulation->Triangle(i).Get(a, b, c);
#endif
a--; a--;
if( reverse ) if( reverse )