Porting Salome to OCCT 7.7.0

This commit is contained in:
jfa 2023-02-22 22:46:07 +00:00
parent 38ab7c3864
commit 483e992a6d
5 changed files with 69 additions and 51 deletions

View File

@ -57,7 +57,7 @@
#include <GEOMUtils.hxx> #include <GEOMUtils.hxx>
#undef _Precision_HeaderFile //#undef _Precision_HeaderFile
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BRepPrimAPI_MakeBox.hxx> #include <BRepPrimAPI_MakeBox.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>

View File

@ -163,23 +163,15 @@ void SMESHUtils::createPointsSampleFromFace( const TopoDS_Face& theFace,
// Get the transformation associated to the face location // Get the transformation associated to the face location
gp_Trsf aTrsf = aLocation.Transformation(); gp_Trsf aTrsf = aLocation.Transformation();
// Get triangles
int nbTriangles = aTri->NbTriangles();
const Poly_Array1OfTriangle& triangles = aTri->Triangles();
// GetNodes
int nbNodes = aTri->NbNodes();
TColgp_Array1OfPnt nodes(1,nbNodes);
nodes = aTri->Nodes();
// Iterate on triangles and subdivide them // Iterate on triangles and subdivide them
int nbTriangles = aTri->NbTriangles();
thePoints.reserve( thePoints.size() + nbTriangles ); thePoints.reserve( thePoints.size() + nbTriangles );
for ( int i = 1; i <= nbTriangles; i++ ) for ( int i = 1; i <= nbTriangles; i++ )
{ {
const Poly_Triangle& aTriangle = triangles.Value(i); const Poly_Triangle& aTriangle = aTri->Triangle(i);
gp_Pnt p1 = nodes.Value(aTriangle.Value(1)); gp_Pnt p1 = aTri->Node(aTriangle.Value(1));
gp_Pnt p2 = nodes.Value(aTriangle.Value(2)); gp_Pnt p2 = aTri->Node(aTriangle.Value(2));
gp_Pnt p3 = nodes.Value(aTriangle.Value(3)); gp_Pnt p3 = aTri->Node(aTriangle.Value(3));
p1.Transform(aTrsf); p1.Transform(aTrsf);
p2.Transform(aTrsf); p2.Transform(aTrsf);

View File

@ -241,15 +241,14 @@ namespace // internal utils
BBox myBBox; BBox myBBox;
BRepAdaptor_Surface mySurface; BRepAdaptor_Surface mySurface;
ElementBndBoxTree* myTree; ElementBndBoxTree* myTree;
const Poly_Array1OfTriangle* myPolyTrias; TColgp_Array1OfPnt myNodes;
const TColgp_Array1OfPnt* myNodes;
bool myOwnNodes;
typedef vector<int> IntVec; typedef vector<int> IntVec;
IntVec myFoundTriaIDs; IntVec myFoundTriaIDs;
TriaTreeData( const TopoDS_Face& face, ElementBndBoxTree* triaTree ); TriaTreeData( const TopoDS_Face& face, ElementBndBoxTree* triaTree );
~TriaTreeData() { if ( myOwnNodes ) delete myNodes; myNodes = NULL; } ~TriaTreeData() {
}
virtual const Bnd_B3d* GetBox(int elemID) const { return &myTrias[elemID].myBox; } virtual const Bnd_B3d* GetBox(int elemID) const { return &myTrias[elemID].myBox; }
void PrepareToTriaSearch(); void PrepareToTriaSearch();
void SetSizeByTrias( SegSizeTree& sizeTree, double deflection ) const; void SetSizeByTrias( SegSizeTree& sizeTree, double deflection ) const;
@ -311,7 +310,7 @@ namespace // internal utils
TriaTreeData::TriaTreeData( const TopoDS_Face& face, ElementBndBoxTree* triaTree ) TriaTreeData::TriaTreeData( const TopoDS_Face& face, ElementBndBoxTree* triaTree )
: myTriasDeflection(0), mySurface( face ), : myTriasDeflection(0), mySurface( face ),
myTree(NULL), myPolyTrias(NULL), myNodes(NULL), myOwnNodes(false) myTree(NULL)
{ {
TopLoc_Location loc; TopLoc_Location loc;
Handle(Poly_Triangulation) tr = BRep_Tool::Triangulation( face, loc ); Handle(Poly_Triangulation) tr = BRep_Tool::Triangulation( face, loc );
@ -319,21 +318,19 @@ namespace // internal utils
{ {
myFaceTol = SMESH_MesherHelper::MaxTolerance( face ); myFaceTol = SMESH_MesherHelper::MaxTolerance( face );
myTree = triaTree; myTree = triaTree;
myNodes = & tr->Nodes(); myNodes = TColgp_Array1OfPnt( 1, tr->NbNodes() );
myPolyTrias = & tr->Triangles(); for (int ii = 1; ii <= tr->NbNodes(); ++ii) {
myNodes(ii) = tr->Node(ii);
}
myTriasDeflection = tr->Deflection(); myTriasDeflection = tr->Deflection();
if ( !loc.IsIdentity() ) // transform nodes if necessary if ( !loc.IsIdentity() ) // transform nodes if necessary
{ {
TColgp_Array1OfPnt* trsfNodes = new TColgp_Array1OfPnt( myNodes->Lower(), myNodes->Upper() );
trsfNodes->Assign( *myNodes );
myNodes = trsfNodes;
myOwnNodes = true;
const gp_Trsf& trsf = loc; const gp_Trsf& trsf = loc;
for ( int i = trsfNodes->Lower(); i <= trsfNodes->Upper(); ++i ) for ( int i = myNodes.Lower(); i <= myNodes.Upper(); ++i )
trsfNodes->ChangeValue(i).Transform( trsf ); myNodes(i).Transform( trsf );
} }
for ( int i = myNodes->Lower(); i <= myNodes->Upper(); ++i ) for ( int i = myNodes.Lower(); i <= myNodes.Upper(); ++i )
myBBox.Add( myNodes->Value(i).XYZ() ); myBBox.Add( myNodes.Value(i).XYZ() );
} }
} }
//================================================================================ //================================================================================
@ -345,14 +342,16 @@ namespace // internal utils
void TriaTreeData::PrepareToTriaSearch() void TriaTreeData::PrepareToTriaSearch()
{ {
if ( !myTrias.empty() ) return; // already done if ( !myTrias.empty() ) return; // already done
if ( !myPolyTrias ) return;
TopLoc_Location loc;
Handle(Poly_Triangulation) tr = BRep_Tool::Triangulation( mySurface.Face(), loc );
if ( tr.IsNull() || !tr->NbTriangles() ) return;
// get all boundary links and nodes on VERTEXes // get all boundary links and nodes on VERTEXes
map< NLink, Segment* > linkToSegMap; map< NLink, Segment* > linkToSegMap;
map< NLink, Segment* >::iterator l2s; map< NLink, Segment* >::iterator l2s;
set< int > vertexNodes; set< int > vertexNodes;
TopLoc_Location loc;
Handle(Poly_Triangulation) tr = BRep_Tool::Triangulation( mySurface.Face(), loc );
if ( !tr.IsNull() ) if ( !tr.IsNull() )
{ {
TopTools_IndexedMapOfShape edgeMap; TopTools_IndexedMapOfShape edgeMap;
@ -377,21 +376,21 @@ namespace // internal utils
{ {
const NLink& link = (*l2s).first; const NLink& link = (*l2s).first;
(*l2s).second = & mySegments[ iS ]; (*l2s).second = & mySegments[ iS ];
mySegments[ iS ].Init( myNodes->Value( link.N1() ), mySegments[ iS ].Init( myNodes( link.N1() ),
myNodes->Value( link.N2() )); myNodes( link.N2() ));
} }
} }
// initialize myTrias // initialize myTrias
myTrias.resize( myPolyTrias->Length() ); myTrias.resize( tr->NbTriangles() );
Standard_Integer n1,n2,n3; Standard_Integer n1,n2,n3;
for ( int i = 1; i <= myPolyTrias->Upper(); ++i ) for ( int i = 1; i <= tr->NbTriangles(); ++i )
{ {
Triangle & t = myTrias[ i-1 ]; Triangle & t = myTrias[ i-1 ];
myPolyTrias->Value( i ).Get( n1,n2,n3 ); tr->Triangle( i ).Get( n1,n2,n3 );
t.Init( myNodes->Value( n1 ), t.Init( myNodes.Value( n1 ),
myNodes->Value( n2 ), myNodes.Value( n2 ),
myNodes->Value( n3 )); myNodes.Value( n3 ));
int nbSeg = 0; int nbSeg = 0;
if (( l2s = linkToSegMap.find( NLink( n1, n2 ))) != linkToSegMap.end()) if (( l2s = linkToSegMap.find( NLink( n1, n2 ))) != linkToSegMap.end())
t.mySegments[ nbSeg++ ] = l2s->second; t.mySegments[ nbSeg++ ] = l2s->second;
@ -445,15 +444,16 @@ namespace // internal utils
double size = -1., maxLinkLen; double size = -1., maxLinkLen;
int jLongest = 0; int jLongest = 0;
//int nbLinks = 0; TopLoc_Location loc;
for ( int i = 1; i <= myPolyTrias->Upper(); ++i ) Handle(Poly_Triangulation) tr = BRep_Tool::Triangulation( mySurface.Face(), loc );
for ( int i = 1; i <= tr->NbTriangles(); ++i )
{ {
// get corners of a triangle // get corners of a triangle
myPolyTrias->Value( i ).Get( n[0],n[1],n[2] ); tr->Triangle( i ).Get( n[0],n[1],n[2] );
n[3] = n[0]; n[3] = n[0];
p[0] = myNodes->Value( n[0] ); p[0] = myNodes.Value( n[0] );
p[1] = myNodes->Value( n[1] ); p[1] = myNodes.Value( n[1] );
p[2] = myNodes->Value( n[2] ); p[2] = myNodes.Value( n[2] );
p[3] = p[0]; p[3] = p[0];
// get length of links and find the longest one // get length of links and find the longest one
maxLinkLen = 0; maxLinkLen = 0;
@ -493,7 +493,7 @@ namespace // internal utils
} }
//cout << "SetSizeByTrias, i="<< i << " " << sz * factor << endl; //cout << "SetSizeByTrias, i="<< i << " " << sz * factor << endl;
} }
// cout << "SetSizeByTrias, nn tria="<< myPolyTrias->Upper() // cout << "SetSizeByTrias, nn tria="<< tr->NbTriangles()
// << " nb links" << nbLinks << " isConstSize="<<isConstSize // << " nb links" << nbLinks << " isConstSize="<<isConstSize
// << " " << size * factor << endl; // << " " << size * factor << endl;
} }
@ -520,6 +520,9 @@ namespace // internal utils
if ( myFoundTriaIDs.empty() ) if ( myFoundTriaIDs.empty() )
return minDist2; return minDist2;
TopLoc_Location loc;
Handle(Poly_Triangulation) tr = BRep_Tool::Triangulation( mySurface.Face(), loc );
Standard_Integer n[ 3 ]; Standard_Integer n[ 3 ];
for ( size_t i = 0; i < myFoundTriaIDs.size(); ++i ) for ( size_t i = 0; i < myFoundTriaIDs.size(); ++i )
{ {
@ -529,13 +532,13 @@ namespace // internal utils
t.myIsChecked = true; t.myIsChecked = true;
double d, minD2 = minDist2; double d, minD2 = minDist2;
myPolyTrias->Value( myFoundTriaIDs[i]+1 ).Get( n[0],n[1],n[2] ); tr->Triangle( myFoundTriaIDs[i]+1 ).Get( n[0],n[1],n[2] );
if ( avoidPnt && t.myHasNodeOnVertex ) if ( avoidPnt && t.myHasNodeOnVertex )
{ {
bool avoidTria = false; bool avoidTria = false;
for ( int i = 0; i < 3; ++i ) for ( int i = 0; i < 3; ++i )
{ {
const gp_Pnt& pn = myNodes->Value(n[i]); const gp_Pnt& pn = myNodes.Value(n[i]);
if (( avoidTria = ( pn.SquareDistance( *avoidPnt ) <= tol2 ))) if (( avoidTria = ( pn.SquareDistance( *avoidPnt ) <= tol2 )))
break; break;
if ( !projectedOnly ) if ( !projectedOnly )
@ -556,7 +559,7 @@ namespace // internal utils
else else
{ {
for ( int i = 0; i < 3; ++i ) for ( int i = 0; i < 3; ++i )
minD2 = Min( minD2, p.SquareDistance( myNodes->Value(n[i]) )); minD2 = Min( minD2, p.SquareDistance( myNodes.Value(n[i]) ));
if ( minD2 < t.myMaxSize2 && ( t.DistToProjection( p, d ) || t.DistToSegment( p, d ))) if ( minD2 < t.myMaxSize2 && ( t.DistToProjection( p, d ) || t.DistToSegment( p, d )))
minD2 = Min( minD2, d*d ); minD2 = Min( minD2, d*d );
minDist2 = Min( minDist2, minD2 ); minDist2 = Min( minDist2, minD2 );

View File

@ -62,9 +62,15 @@
#include <GeomAPI_ExtremaCurveCurve.hxx> #include <GeomAPI_ExtremaCurveCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx> #include <GeomAPI_ProjectPointOnSurf.hxx>
#include <GeomAdaptor_Curve.hxx> #include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Basics_OCCTVersion.hxx>
#if OCC_VERSION_LARGE < 0x07070000
#include <GeomAdaptor_HCurve.hxx> #include <GeomAdaptor_HCurve.hxx>
#include <GeomAdaptor_HSurface.hxx> #include <GeomAdaptor_HSurface.hxx>
#include <GeomAdaptor_Surface.hxx> #endif
#include <GeomLib_IsPlanarSurface.hxx> #include <GeomLib_IsPlanarSurface.hxx>
#include <Geom_Line.hxx> #include <Geom_Line.hxx>
#include <IntCurveSurface_HInter.hxx> #include <IntCurveSurface_HInter.hxx>
@ -1883,8 +1889,13 @@ namespace {
SMESHDS_Mesh* tgtMeshDS = tgtMesh->GetMeshDS(); SMESHDS_Mesh* tgtMeshDS = tgtMesh->GetMeshDS();
Handle(Geom_Surface) tgtSurface = BRep_Tool::Surface( theTgtFace ); Handle(Geom_Surface) tgtSurface = BRep_Tool::Surface( theTgtFace );
#if OCC_VERSION_LARGE < 0x07070000
Handle(GeomAdaptor_HSurface) tgtSurfAdaptor = new GeomAdaptor_HSurface( tgtSurface ); Handle(GeomAdaptor_HSurface) tgtSurfAdaptor = new GeomAdaptor_HSurface( tgtSurface );
Handle(GeomAdaptor_HCurve) piercingCurve = new GeomAdaptor_HCurve( thePiercingLine ); Handle(GeomAdaptor_HCurve) piercingCurve = new GeomAdaptor_HCurve( thePiercingLine );
#else
Handle(GeomAdaptor_Surface) tgtSurfAdaptor = new GeomAdaptor_Surface( tgtSurface );
Handle(GeomAdaptor_Curve) piercingCurve = new GeomAdaptor_Curve( thePiercingLine );
#endif
IntCurveSurface_HInter intersect; IntCurveSurface_HInter intersect;
SMESH_MesherHelper* srcHelper = theSrcWires[0]->FaceHelper(); SMESH_MesherHelper* srcHelper = theSrcWires[0]->FaceHelper();

View File

@ -52,7 +52,14 @@
#include "StdMeshers_Quadrangle_2D.hxx" #include "StdMeshers_Quadrangle_2D.hxx"
#include "StdMeshers_ViscousLayers2D.hxx" #include "StdMeshers_ViscousLayers2D.hxx"
#include <Basics_OCCTVersion.hxx>
#if OCC_VERSION_LARGE < 0x07070000
#include <Adaptor3d_HSurface.hxx> #include <Adaptor3d_HSurface.hxx>
#else
#include <Adaptor3d_Surface.hxx>
#endif
#include <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Curve2d.hxx> #include <BRepAdaptor_Curve2d.hxx>
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
@ -1818,8 +1825,13 @@ namespace VISCOUS_3D
//case GeomAbs_SurfaceOfExtrusion: //case GeomAbs_SurfaceOfExtrusion:
case GeomAbs_OffsetSurface: case GeomAbs_OffsetSurface:
{ {
#if OCC_VERSION_LARGE < 0x07070000
Handle(Adaptor3d_HSurface) base = surface.BasisSurface(); Handle(Adaptor3d_HSurface) base = surface.BasisSurface();
return getRovolutionAxis( base->Surface(), axis ); return getRovolutionAxis( base->Surface(), axis );
#else
Handle(Adaptor3d_Surface) base = surface.BasisSurface();
return getRovolutionAxis( *base, axis );
#endif
} }
default: return false; default: return false;
} }