Skip to content

Commit

Permalink
Added support for OCCT 7.6.1
Browse files Browse the repository at this point in the history
Note: The test WingSegmentGuideCurves.tiglWingGetSegmentUpperSurfaceAreaTrimmed
is failing due to some tolerance error. I did not look into it further.
  • Loading branch information
rainman110 authored and joergbrech committed Nov 21, 2023
1 parent 45a9428 commit cd60b61
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 62 deletions.
1 change: 1 addition & 0 deletions TIGLViewer/src/ISession_Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ IMPLEMENT_STANDARD_RTTIEXT(ISession_Text,AIS_InteractiveObject)
#include <SelectMgr_Selection.hxx>
#include <Prs3d_Text.hxx>
#include <Prs3d_Presentation.hxx>
#include <Prs3d_Root.hxx>
#include <PrsMgr_PresentationManager3d.hxx>
#include <gp_Pnt.hxx>
#include <TCollection_ExtendedString.hxx>
Expand Down
53 changes: 23 additions & 30 deletions TIGLViewer/src/TIGLAISTriangulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ TIGLAISTriangulation::TIGLAISTriangulation(const Handle(Poly_Triangulation)& Tri
maxy = DBL_MIN;
maxz = DBL_MIN;

const TColgp_Array1OfPnt& nodes = Triangulation->Nodes();
for (int i = nodes.Lower(); i <= nodes.Upper(); ++i) {
const gp_Pnt& p = nodes.Value(i);
for (int i = 1; i <= Triangulation->NbNodes(); ++i) {
const gp_Pnt& p = Triangulation->Node(i);
minx = min(minx, p.X());
miny = min(miny, p.Y());
minz = min(minz, p.Z());
Expand Down Expand Up @@ -108,9 +107,6 @@ void TIGLAISTriangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& a
Standard_Real ambient = 1.0;
#endif

const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes(); //Nodes
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles(); //Triangle

Standard_Boolean hasVNormals = myTriangulation->HasNormals();
Standard_Boolean hasVColors = (myFlagColor == 1);

Expand All @@ -122,47 +118,46 @@ void TIGLAISTriangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& a
Standard_False //hasTexels
);

Standard_Integer i;
Standard_Integer j;

gp_Vec3f aNormal;
if (hasVNormals) {
const TShort_Array1OfShortReal& normals = myTriangulation->Normals();
if (hasVColors) {
const TColStd_Array1OfInteger& colors = myColor->Array1();
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));
for (int i = 1; i <= myTriangulation->NbNodes(); i++ ) {
anArray->AddVertex(myTriangulation->Node(i), AttenuateColor(colors(i), ambient));
myTriangulation->Normal(i, aNormal);
anArray->SetVertexNormal(i, aNormal.x(), aNormal.y(), aNormal.z());
}
}
// !hasVColors
else {
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));
for (int i = 1; i <= myTriangulation->NbNodes(); i++ ) {
anArray->AddVertex(myTriangulation->Node(i));
myTriangulation->Normal(i, aNormal);
anArray->SetVertexNormal(i, aNormal.x(), aNormal.y(), aNormal.z());

}
}
}
// !hasVNormals
else {
if (hasVColors) {
const TColStd_Array1OfInteger& colors = myColor->Array1();
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ ) {
anArray->AddVertex(nodes(i), AttenuateColor(colors(i), ambient));
for (int i = 1; i <= myTriangulation->NbNodes(); i++ ) {
anArray->AddVertex(myTriangulation->Node(i), AttenuateColor(colors(i), ambient));
}
}
// !hasVColors
else {
for ( i = nodes.Lower(); i <= nodes.Upper(); i++ ) {
anArray->AddVertex(nodes(i));
for (int i = 1; i <= myTriangulation->NbNodes(); i++ ) {
anArray->AddVertex(myTriangulation->Node(i));
}
}
}

Standard_Integer indexTriangle[3] = {0,0,0};
for ( i = triangles.Lower(); i<= triangles.Upper(); i++ ) {
triangles(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
for (Standard_Integer i = 1; i<= myTriangulation->NbTriangles(); i++ ) {
myTriangulation->Triangle(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
anArray->AddEdge(indexTriangle[0]);
anArray->AddEdge(indexTriangle[1]);
anArray->AddEdge(indexTriangle[2]);
Expand All @@ -172,18 +167,16 @@ void TIGLAISTriangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& a
break;
}
case 0: {
const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes();
const Poly_Array1OfTriangle& triangles = myTriangulation->Triangles();
Handle(Graphic3d_AspectLine3d) aspect = myDrawer->WireAspect()->Aspect();

Handle(Graphic3d_ArrayOfPrimitives) segments = new Graphic3d_ArrayOfSegments(nodes.Length(),triangles.Length()*6);
for (Standard_Integer i = nodes.Lower(); i <= nodes.Upper(); i++ ) {
segments->AddVertex(nodes(i));
Handle(Graphic3d_ArrayOfPrimitives) segments = new Graphic3d_ArrayOfSegments(myTriangulation->NbNodes(),myTriangulation->NbTriangles()*6);
for (Standard_Integer i = 1; i <= myTriangulation->NbNodes(); i++ ) {
segments->AddVertex(myTriangulation->Node(i));
}

Standard_Integer indexTriangle[3] = {0,0,0};
for (Standard_Integer i = triangles.Lower(); i<= triangles.Upper(); i++ ) {
triangles(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
for (Standard_Integer i = 1; i<= myTriangulation->NbTriangles(); i++ ) {
myTriangulation->Triangle(i).Get(indexTriangle[0], indexTriangle[1], indexTriangle[2]);
segments->AddEdge(indexTriangle[0]);
segments->AddEdge(indexTriangle[1]);
segments->AddEdge(indexTriangle[1]);
Expand Down
4 changes: 4 additions & 0 deletions TIGLViewer/src/TIGLQAspectWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ void TIGLQAspectWindow::Unmap() const
// function : DoResize
// purpose :
// =======================================================================
#if OCC_VERSION_HEX >= 0x070600
Aspect_TypeOfResize TIGLQAspectWindow::DoResize()
#else
Aspect_TypeOfResize TIGLQAspectWindow::DoResize() const
#endif
{
int aMask = 0;
Aspect_TypeOfResize aMode = Aspect_TOR_UNKNOWN;
Expand Down
4 changes: 4 additions & 0 deletions TIGLViewer/src/TIGLQAspectWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ class TIGLQAspectWindow : public Aspect_Window
Aspect_Drawable NativeParentHandle() const override;

//! Applies the resizing to the window <me>
#if OCC_VERSION_HEX >= 0x070600
Aspect_TypeOfResize DoResize() override;
#else
Aspect_TypeOfResize DoResize() const override;
#endif

//! Returns True if the window <me> is opened
//! and False if the window is closed.
Expand Down
12 changes: 5 additions & 7 deletions TIGLViewer/src/TIGLViewerDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2734,16 +2734,14 @@ void TIGLViewerDocument::createShapeTriangulation(const TopoDS_Shape& shape, Top
}

gp_Trsf nodeTransformation = location;
const TColgp_Array1OfPnt& nodes = triangulation->Nodes();

int index1, index2, index3;
const Poly_Array1OfTriangle& triangles = triangulation->Triangles();
for (int j = triangles.Lower(); j <= triangles.Upper(); j++) {
const Poly_Triangle& triangle = triangles(j);
for (int j = 1; j <= triangulation->NbTriangles(); j++) {
const Poly_Triangle& triangle = triangulation->Triangle(j);
triangle.Get(index1, index2, index3);
gp_Pnt point1 = nodes(index1).Transformed(nodeTransformation);
gp_Pnt point2 = nodes(index2).Transformed(nodeTransformation);
gp_Pnt point3 = nodes(index3).Transformed(nodeTransformation);
gp_Pnt point1 = triangulation->Node(index1).Transformed(nodeTransformation);
gp_Pnt point2 = triangulation->Node(index2).Transformed(nodeTransformation);
gp_Pnt point3 = triangulation->Node(index3).Transformed(nodeTransformation);

BRepBuilderAPI_MakeEdge edge1(point1, point2);
BRepBuilderAPI_MakeEdge edge2(point2, point3);
Expand Down
2 changes: 1 addition & 1 deletion cmake/UseOpenCASCADE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if(OCE_FOUND)
option(OCE_STATIC_LIBS "Should be checked, if static OCE libs are linked" OFF)
else(OCE_FOUND)
message("OCE not found! Searching for OpenCASCADE.")
find_package(OpenCASCADE 7.4.0 CONFIG REQUIRED)
find_package(OpenCASCADE CONFIG REQUIRED)
option(OpenCASCADE_STATIC_LIBS "Should be checked, if static OpenCASCADE libs are linked" OFF)

message(STATUS "Found opencascade " ${OpenCASCADE_VERSION})
Expand Down
8 changes: 8 additions & 0 deletions src/boolean_operations/GEOMAlgo_Splitter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ void GEOMAlgo_Splitter::BuildResult(const TopAbs_ShapeEnum theType)
//function : PostTreat
//purpose :
//=======================================================================
#if OCC_VERSION_HEX >= VERSION_HEX_CODE(7,6,0)
void GEOMAlgo_Splitter::PostTreat(const Message_ProgressRange& p)
#else
void GEOMAlgo_Splitter::PostTreat()
#endif
{
if (myLimit!=TopAbs_SHAPE) {
Standard_Integer i, aNbS;
Expand Down Expand Up @@ -340,7 +344,11 @@ void GEOMAlgo_Splitter::PostTreat()
myShape=aLS.First();
}
//
#if OCC_VERSION_HEX >= VERSION_HEX_CODE(7,6,0)
BOPAlgo_Builder::PostTreat(p);
#else
BOPAlgo_Builder::PostTreat();
#endif
}
//=======================================================================
//function : TreatCompound
Expand Down
4 changes: 4 additions & 0 deletions src/boolean_operations/GEOMAlgo_Splitter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ public:
void BuildResult(const TopAbs_ShapeEnum theType) override;

TIGL_EXPORT
#if OCC_VERSION_HEX >= VERSION_HEX_CODE(7,6,0)
void PostTreat(const Message_ProgressRange&) override;
#else
void PostTreat() override;
#endif

protected:
#if OCC_VERSION_HEX >= VERSION_HEX_CODE(7,3,0)
Expand Down
7 changes: 4 additions & 3 deletions src/common/tiglcommonfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "CTiglProjectPointOnCurveAtAngle.h"
#include "CTiglBSplineAlgorithms.h"

#include "Standard_Version.hxx"

#include "Geom_Curve.hxx"
#include "Geom_Surface.hxx"
#include "GeomAdaptor_Curve.hxx"
Expand Down Expand Up @@ -77,7 +79,6 @@
#include "BRepExtrema_DistShapeShape.hxx"

#include <Approx_Curve3d.hxx>
#include <BRepAdaptor_HCompCurve.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_FindPlane.hxx>
Expand Down Expand Up @@ -1101,8 +1102,8 @@ TopoDS_Face BuildRuledFace(const TopoDS_Wire& wire1, const TopoDS_Wire& wire2)

// Wrap the adaptor in a class which manages curve access via handle (HCurve). According to doxygen
// this is required by the algorithms
Handle(Adaptor3d_HCurve) curve1 = new BRepAdaptor_HCompCurve(compCurve1);
Handle(Adaptor3d_HCurve) curve2 = new BRepAdaptor_HCompCurve(compCurve2);
const Handle(Adaptor3d_Curve) curve1 = new BRepAdaptor_CompCurve(compCurve1);
const Handle(Adaptor3d_Curve) curve2 = new BRepAdaptor_CompCurve(compCurve2);

// We have to generate an approximated curve now from the wire using the adaptor
// NOTE: last parameter value unknown
Expand Down
1 change: 1 addition & 0 deletions src/control_devices/CControlSurfaceBorderBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <gp_Vec.hxx>
#include <Geom_Plane.hxx>
#include <Geom2dAPI_Interpolate.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepIntCurveSurface_Inter.hxx>
Expand Down
27 changes: 11 additions & 16 deletions src/geometry/CTiglTriangularizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,11 @@ int CTiglTriangularizer::triangularizeFace(const TopoDS_Face & face, unsigned lo

BRepGProp_Face prop(face);

const TColgp_Array1OfPnt2d& uvnodes = triangulation->UVNodes(); // get (face-local) list of nodes
ilower = uvnodes.Lower();

iBufferSize = uvnodes.Upper()-uvnodes.Lower()+1;
ilower = 1;
iBufferSize = triangulation->NbNodes();
indexBuffer.reserve(iBufferSize);
for (int inode = uvnodes.Lower(); inode <= uvnodes.Upper(); ++inode) {
const gp_Pnt2d& uv_pnt = uvnodes(inode);
for (int inode = 1; inode <= triangulation->NbNodes(); ++inode) {
const gp_Pnt2d& uv_pnt = triangulation->UVNode(inode);
gp_Pnt p; gp_Vec n;
prop.Normal(uv_pnt.X(),uv_pnt.Y(),p,n);
if (n.SquareMagnitude() > 0.) {
Expand All @@ -315,23 +313,20 @@ int CTiglTriangularizer::triangularizeFace(const TopoDS_Face & face, unsigned lo
else {
// we cannot compute normals

const TColgp_Array1OfPnt& nodes = triangulation->Nodes(); // get (face-local) list of nodes
ilower = nodes.Lower();

iBufferSize = nodes.Upper()-nodes.Lower()+1;
ilower = 1;
iBufferSize = triangulation->NbNodes();
indexBuffer.reserve(iBufferSize);
for (int inode = nodes.Lower(); inode <= nodes.Upper(); inode++) {
const gp_Pnt& p = nodes(inode).Transformed(nodeTransformation);
for (int inode = 1; inode <= triangulation->NbNodes(); inode++) {
const gp_Pnt& p = triangulation->Node(inode).Transformed(nodeTransformation);
indexBuffer.push_back(polys.currentObject().addPointNormal(p.XYZ(), CTiglPoint(1,0,0)));
}
}

const Poly_Array1OfTriangle& triangles = triangulation->Triangles();
iPolyLower = ULONG_MAX;
iPolyUpper = 0;
// iterate over triangles in the array
for (int j = triangles.Lower(); j <= triangles.Upper(); j++) {
const Poly_Triangle& triangle = triangles(j);
// iterate over triangles in the array
for (int j = 1; j <= triangulation->NbTriangles(); j++) {
const Poly_Triangle& triangle = triangulation->Triangle(j);
int occindex1, occindex2, occindex3;
triangle.Get(occindex1, occindex2, occindex3); // get indices into index1..3
unsigned long index1, index2, index3;
Expand Down
2 changes: 0 additions & 2 deletions src/wing/CCPACSWingSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@

#include "Geom_BSplineCurve.hxx"
#include "GeomAPI_PointsToBSpline.hxx"
#include "GeomAdaptor_HCurve.hxx"
#include "GeomFill.hxx"
#include "GeomFill_SimpleBound.hxx"
#include "GeomFill_BSplineCurves.hxx"
Expand All @@ -105,7 +104,6 @@
#include "BRepExtrema_DistShapeShape.hxx"
#include "BRepIntCurveSurface_Inter.hxx"
#include "GCPnts_AbscissaPoint.hxx"
#include "BRepAdaptor_CompCurve.hxx"
#include "BRepTools.hxx"
#include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
Expand Down
7 changes: 4 additions & 3 deletions tests/unittests/tiglShapeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ TEST(ShapeCache, Get)
TopoDS_Shape shape1(wireBuilder.Wire()), shape2(wireBuilder.Wire()), shape3(wireBuilder.Wire());

gp_Trsf trafo1, trafo2, trafo3;
trafo1.SetScaleFactor(1.0);
trafo2.SetScaleFactor(2.0);
trafo3.SetScaleFactor(3.0);
trafo1.SetTranslation(gp_Vec(1., 0., 0.));
trafo2.SetTranslation(gp_Vec(0., 1., 0.));
trafo3.SetTranslation(gp_Vec(0., 0., 1.));

shape1.Move(trafo1);
shape2.Move(trafo2);
shape3.Move(trafo3);
Expand Down

0 comments on commit cd60b61

Please sign in to comment.