1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-06-30 12:14:08 +03:00

0028639: Improve performance of the IntPolyh_MaillageAffinage algorithm

The following improvements have been made:
1. Linking edges to triangles while creating the edges.
2. Replacing the array of couples of intersecting triangles with the list to avoid unnecessary allocations of memory.
3. Using the algorithm of unbalanced binary tree when looking for pairs of interfering triangles.
4. Building bounding boxes for the triangles only once and then reusing it.
5. Making the simple methods of the IntPolyh_Point, IntPolyh_Edge, IntPolyh_Triangle, IntPolyh_Couple classes inline.
6. The following methods of the *IntPolyh_Triangle* class have been removed as unused:
  - *CheckCommonEdge*
  - *SetEdgeandOrientation*
  - *MultipleMiddleRefinement2*.
7. The method *IntPolyh_Triangle::TriangleDeflection* has been replaced with the *IntPolyh_Triangle::ComputeDeflection*.
8. The following methods of the *IntPolyh_MaillageAffinage* class have been removed as unused:
  - *LinkEdges2Triangles*;
  - *TriangleEdgeContact2*;
  - *StartingPointsResearch2*;
  - *NextStartingPointsResearch2*;
  - *TriangleComparePSP*;
  - *StartPointsCalcul*.
This commit is contained in:
emv 2017-04-07 07:43:44 +03:00 committed by bugmaster
parent a9bdd54d1d
commit 68b0769935
18 changed files with 1398 additions and 2786 deletions

View File

@ -1131,6 +1131,18 @@ The following obsolete features have been removed:
* The package *TestTopOpeDraw* has been removed; * The package *TestTopOpeDraw* has been removed;
* The package *TestTopOpeTools* has been removed. * The package *TestTopOpeTools* has been removed.
* The packages *QANewModTopOpe*, *QANewBRepNaming* and *QANewDBRepNaming* have been removed as containing obsolete features. * The packages *QANewModTopOpe*, *QANewBRepNaming* and *QANewDBRepNaming* have been removed as containing obsolete features.
* The following methods of the *IntPolyh_Triangle* class have been removed as unused:
- *CheckCommonEdge*
- *SetEdgeandOrientation*
- *MultipleMiddleRefinement2*.
* The method *IntPolyh_Triangle::TriangleDeflection* has been renamed to *IntPolyh_Triangle::ComputeDeflection*.
* The following methods of the *IntPolyh_MaillageAffinage* class have been removed as unused:
- *LinkEdges2Triangles*;
- *TriangleEdgeContact2*;
- *StartingPointsResearch2*;
- *NextStartingPointsResearch2*;
- *TriangleComparePSP*;
- *StartPointsCalcul*.
@subsection upgrade_occt720_correction_of_Offset_API Corrections in BRepOffset API @subsection upgrade_occt720_correction_of_Offset_API Corrections in BRepOffset API

View File

@ -1,18 +1,18 @@
IntPolyh_Array.hxx IntPolyh_Array.hxx
IntPolyh_ArrayOfCouples.hxx
IntPolyh_ArrayOfEdges.hxx IntPolyh_ArrayOfEdges.hxx
IntPolyh_ArrayOfPoints.hxx IntPolyh_ArrayOfPoints.hxx
IntPolyh_ArrayOfSectionLines.hxx IntPolyh_ArrayOfSectionLines.hxx
IntPolyh_ArrayOfStartPoints.hxx
IntPolyh_ArrayOfTangentZones.hxx IntPolyh_ArrayOfTangentZones.hxx
IntPolyh_ArrayOfTriangles.hxx IntPolyh_ArrayOfTriangles.hxx
IntPolyh_Couple.cxx IntPolyh_Couple.cxx
IntPolyh_Couple.hxx IntPolyh_Couple.hxx
IntPolyh_CoupleMapHasher.hxx
IntPolyh_Edge.cxx IntPolyh_Edge.cxx
IntPolyh_Edge.hxx IntPolyh_Edge.hxx
IntPolyh_Intersection.cxx IntPolyh_Intersection.cxx
IntPolyh_Intersection.hxx IntPolyh_Intersection.hxx
IntPolyh_Intersection_1.cxx IntPolyh_Intersection_1.cxx
IntPolyh_ListOfCouples.hxx
IntPolyh_MaillageAffinage.cxx IntPolyh_MaillageAffinage.cxx
IntPolyh_MaillageAffinage.hxx IntPolyh_MaillageAffinage.hxx
IntPolyh_PMaillageAffinage.hxx IntPolyh_PMaillageAffinage.hxx
@ -24,4 +24,4 @@ IntPolyh_SeqOfStartPoints.hxx
IntPolyh_StartPoint.cxx IntPolyh_StartPoint.cxx
IntPolyh_StartPoint.hxx IntPolyh_StartPoint.hxx
IntPolyh_Triangle.cxx IntPolyh_Triangle.cxx
IntPolyh_Triangle.hxx IntPolyh_Triangle.hxx

View File

@ -1,24 +0,0 @@
// Created on: 2012-11-13
// Created by: Peter KURNEV
// Copyright (c) 2012-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef IntPolyh_ArrayOfStartPoints_HeaderFile
#define IntPolyh_ArrayOfStartPoints_HeaderFile
#include <IntPolyh_Array.hxx>
#include <IntPolyh_StartPoint.hxx>
typedef IntPolyh_Array <IntPolyh_StartPoint> IntPolyh_ArrayOfStartPoints;
#endif

View File

@ -16,26 +16,12 @@
#include <IntPolyh_Couple.hxx> #include <IntPolyh_Couple.hxx>
#include <stdio.h> #include <stdio.h>
IntPolyh_Couple::IntPolyh_Couple() : t1(-1),t2(-1),ia(0),angle(-2.0) { }
IntPolyh_Couple::IntPolyh_Couple(const Standard_Integer a,const Standard_Integer b) : t1(a),t2(b),ia(0),angle(-2.0) { } //=======================================================================
//function : Dump
Standard_Integer IntPolyh_Couple::FirstValue() const{ return(t1);} //purpose :
Standard_Integer IntPolyh_Couple::SecondValue() const{ return(t2);} //=======================================================================
Standard_Integer IntPolyh_Couple::AnalyseFlagValue() const{ return(ia);} void IntPolyh_Couple::Dump(const Standard_Integer i) const{
Standard_Real IntPolyh_Couple::AngleValue() const{ return(angle);} printf("\nCouple(%3d) : %5d %5d %3d %5f\n", i, myIndex1, myIndex2, myAnalyzed, myAngle);
void IntPolyh_Couple::SetCoupleValue(const Standard_Integer a,const Standard_Integer b)
{ t1=a; t2=b; }
void IntPolyh_Couple::SetAnalyseFlag(const Standard_Integer iiaa) { ia=iiaa; }
void IntPolyh_Couple::SetAngleValue(const Standard_Real ang) { angle=ang; }
void IntPolyh_Couple::Dump(const Standard_Integer i) const{
printf("\nCouple(%3d) : %5d %5d %3d %5f\n",i,t1,t2,ia,angle);
} }

View File

@ -24,60 +24,92 @@
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <Standard_Real.hxx> #include <Standard_Real.hxx>
//! The class represents the couple of indices with additional
//! couple of triangles //! characteristics such as analyzed flag and an angle.<br>
class IntPolyh_Couple //! In IntPolyh_MaillageAffinage algorithm the class is used as a
//! couple of interfering triangles with the intersection angle.
class IntPolyh_Couple
{ {
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
//! Constructor
Standard_EXPORT IntPolyh_Couple(); IntPolyh_Couple() :
myIndex1(-1),myIndex2(-1),myAnalyzed(0),myAngle(-2.0)
Standard_EXPORT IntPolyh_Couple(const Standard_Integer i1, const Standard_Integer i2); {}
//! Constructor
Standard_EXPORT Standard_Integer FirstValue() const; IntPolyh_Couple(const Standard_Integer theTriangle1,
const Standard_Integer theTriangle2,
Standard_EXPORT Standard_Integer SecondValue() const; const Standard_Real theAngle = -2.0)
:
Standard_EXPORT Standard_Integer AnalyseFlagValue() const; myIndex1(theTriangle1),
myIndex2(theTriangle2),
Standard_EXPORT Standard_Real AngleValue() const; myAnalyzed(Standard_False),
myAngle(theAngle)
Standard_EXPORT void SetCoupleValue (const Standard_Integer v, const Standard_Integer w); {}
Standard_EXPORT void SetAnalyseFlag (const Standard_Integer v); //! Returns the first index
Standard_Integer FirstValue() const
Standard_EXPORT void SetAngleValue (const Standard_Real ang); {
return myIndex1;
}
//! Returns the second index
Standard_Integer SecondValue() const
{
return myIndex2;
}
//! Returns TRUE if the couple has been analyzed
Standard_Boolean IsAnalyzed() const
{
return myAnalyzed;
}
//! Returns the angle
Standard_Real Angle() const
{
return myAngle;
}
//! Sets the triangles
void SetCoupleValue(const Standard_Integer theInd1,
const Standard_Integer theInd2)
{
myIndex1 = theInd1;
myIndex2 = theInd2;
}
//! Sets the analyzed flag
void SetAnalyzed(const Standard_Boolean theAnalyzed)
{
myAnalyzed = theAnalyzed;
}
//! Sets the angle
void SetAngle(const Standard_Real theAngle)
{
myAngle = theAngle;
}
//! Returns true if the Couple is equal to <theOther>
Standard_Boolean IsEqual (const IntPolyh_Couple& theOther) const
{
return (myIndex1 == theOther.myIndex1 && myIndex2 == theOther.myIndex2) ||
(myIndex1 == theOther.myIndex2 && myIndex2 == theOther.myIndex1);
}
//
//! Returns hash code
Standard_Integer HashCode (const Standard_Integer theUpper) const
{
return ::HashCode(myIndex1 + myIndex2, theUpper);
}
// Dump
Standard_EXPORT void Dump (const Standard_Integer v) const; Standard_EXPORT void Dump (const Standard_Integer v) const;
protected: protected:
private: private:
Standard_Integer myIndex1;
Standard_Integer myIndex2;
Standard_Integer t1; Standard_Boolean myAnalyzed;
Standard_Integer t2; Standard_Real myAngle;
Standard_Integer ia;
Standard_Real angle;
}; };
#endif // _IntPolyh_Couple_HeaderFile #endif // _IntPolyh_Couple_HeaderFile

View File

@ -0,0 +1,46 @@
// Created by: Eugeny MALTCHIKOV
// Copyright (c) 2017 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _IntPolyh_CoupleMapHasher_HeaderFile
#define _IntPolyh_CoupleMapHasher_HeaderFile
#include <Standard_Integer.hxx>
#include <Standard_Boolean.hxx>
#include <IntPolyh_Couple.hxx>
class IntPolyh_Couple;
class IntPolyh_CoupleMapHasher
{
public:
static Standard_Integer HashCode(const IntPolyh_Couple& theCouple,
const Standard_Integer Upper)
{
return theCouple.HashCode(Upper);
}
static Standard_Boolean IsEqual(const IntPolyh_Couple& theCouple1,
const IntPolyh_Couple& theCouple2)
{
return theCouple1.IsEqual(theCouple2);
}
protected:
private:
};
#endif // _IntPolyh_CoupleMapHasher_HeaderFile

View File

@ -14,31 +14,14 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#include <IntPolyh_Edge.hxx> #include <IntPolyh_Edge.hxx>
#include <stdio.h> #include <stdio.h>
IntPolyh_Edge::IntPolyh_Edge() : p1(-1),p2(-1),t1(-1),t2(-1),ia(-1) { }
IntPolyh_Edge::IntPolyh_Edge(const Standard_Integer a, const Standard_Integer b,
const Standard_Integer c, const Standard_Integer d) : p1(a),p2(b),t1(c),t2(d),ia(-1) {
}
Standard_Integer IntPolyh_Edge::FirstPoint() const{ return(p1);}
Standard_Integer IntPolyh_Edge::SecondPoint() const{ return(p2);}
Standard_Integer IntPolyh_Edge::FirstTriangle() const{ return(t1);}
Standard_Integer IntPolyh_Edge::SecondTriangle() const{ return(t2);}
Standard_Integer IntPolyh_Edge::AnalysisFlag() const{ return(ia);}
void IntPolyh_Edge::SetFirstPoint(const Standard_Integer a) { p1=a; }
void IntPolyh_Edge::SetSecondPoint(const Standard_Integer b) { p2=b; }
void IntPolyh_Edge::SetFirstTriangle(const Standard_Integer c) { t1=c; }
void IntPolyh_Edge::SetSecondTriangle(const Standard_Integer d) { t2=d; }
void IntPolyh_Edge::SetAnalysisFlag(const Standard_Integer e) { ia=e; }
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void IntPolyh_Edge::Dump(const Standard_Integer i) const{ void IntPolyh_Edge::Dump(const Standard_Integer i) const{
printf("\nEdge(%3d) : P1:%5d P2:%5d T1:%5d T2:%5d AnalysisFlag:%5d\n",i,p1,p2,t1,t2,ia); printf("\nEdge(%3d) : P1:%5d P2:%5d T1:%5d T2:%5d\n",
i, myPoint1, myPoint2, myTriangle1, myTriangle2);
} }

View File

@ -23,67 +23,81 @@
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
//! The class represents the edge built between the two IntPolyh points.<br>
//! It is linked to two IntPolyh triangles.
class IntPolyh_Edge class IntPolyh_Edge
{ {
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
//! Constructor
Standard_EXPORT IntPolyh_Edge(); IntPolyh_Edge() :
myPoint1(-1), myPoint2(-1), myTriangle1(-1), myTriangle2(-1)
Standard_EXPORT IntPolyh_Edge(const Standard_Integer i1, const Standard_Integer i2, const Standard_Integer i3, const Standard_Integer i4); {}
//! Constructor
Standard_EXPORT Standard_Integer FirstPoint() const; IntPolyh_Edge(const Standard_Integer thePoint1,
const Standard_Integer thePoint2,
Standard_EXPORT Standard_Integer SecondPoint() const; const Standard_Integer theTriangle1,
const Standard_Integer theTriangle2)
Standard_EXPORT Standard_Integer FirstTriangle() const; :
myPoint1(thePoint1),
Standard_EXPORT Standard_Integer SecondTriangle() const; myPoint2(thePoint2),
myTriangle1(theTriangle1),
Standard_EXPORT Standard_Integer AnalysisFlag() const; myTriangle2(theTriangle2)
{}
Standard_EXPORT void SetFirstPoint (const Standard_Integer v);
//! Returns the first point
Standard_EXPORT void SetSecondPoint (const Standard_Integer v); Standard_Integer FirstPoint() const
{
Standard_EXPORT void SetFirstTriangle (const Standard_Integer v); return myPoint1;
}
Standard_EXPORT void SetSecondTriangle (const Standard_Integer v); //! Returns the second point
Standard_Integer SecondPoint() const
Standard_EXPORT void SetAnalysisFlag (const Standard_Integer v); {
return myPoint2;
}
//! Returns the first triangle
Standard_Integer FirstTriangle() const
{
return myTriangle1;
}
//! Returns the second triangle
Standard_Integer SecondTriangle() const
{
return myTriangle2;
}
//! Sets the first point
void SetFirstPoint (const Standard_Integer thePoint)
{
myPoint1 = thePoint;
}
//! Sets the second point
void SetSecondPoint (const Standard_Integer thePoint)
{
myPoint2 = thePoint;
}
//! Sets the first triangle
void SetFirstTriangle (const Standard_Integer theTriangle)
{
myTriangle1 = theTriangle;
}
//! Sets the second triangle
void SetSecondTriangle (const Standard_Integer theTriangle)
{
myTriangle2 = theTriangle;
}
Standard_EXPORT void Dump (const Standard_Integer v) const; Standard_EXPORT void Dump (const Standard_Integer v) const;
protected: protected:
private: private:
Standard_Integer myPoint1;
Standard_Integer myPoint2;
Standard_Integer p1; Standard_Integer myTriangle1;
Standard_Integer p2; Standard_Integer myTriangle2;
Standard_Integer t1;
Standard_Integer t2;
Standard_Integer ia;
}; };
#endif // _IntPolyh_Edge_HeaderFile #endif // _IntPolyh_Edge_HeaderFile

View File

@ -24,6 +24,8 @@
#include <IntPolyh_SectionLine.hxx> #include <IntPolyh_SectionLine.hxx>
#include <IntPolyh_StartPoint.hxx> #include <IntPolyh_StartPoint.hxx>
#include <IntPolyh_Triangle.hxx> #include <IntPolyh_Triangle.hxx>
#include <NCollection_Map.hxx>
#include <IntPolyh_CoupleMapHasher.hxx>
Standard_Integer MYDISPLAY = 0; Standard_Integer MYDISPLAY = 0;
Standard_Integer MYPRINT = 0; Standard_Integer MYPRINT = 0;
@ -229,14 +231,12 @@ Standard_Boolean IntPolyh_Intersection::PerformMaillage
theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2), theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2),
xx0, yy0, zz0, xx1, yy1, zz1); xx0, yy0, zz0, xx1, yy1, zz1);
theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->FillArrayOfTriangles(1); theMaillageS->FillArrayOfTriangles(1);
theMaillageS->FillArrayOfTriangles(2); theMaillageS->FillArrayOfTriangles(2);
theMaillageS->LinkEdges2Triangles(); theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->TrianglesDeflectionsRefinementBSB(); theMaillageS->TrianglesDeflectionsRefinementBSB();
Standard_Integer FinTTC = theMaillageS->TriangleCompare(); Standard_Integer FinTTC = theMaillageS->TriangleCompare();
@ -272,14 +272,12 @@ Standard_Boolean IntPolyh_Intersection::PerformMaillage(IntPolyh_PMaillageAffina
theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2), theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2),
xx0, yy0, zz0, xx1, yy1, zz1); xx0, yy0, zz0, xx1, yy1, zz1);
theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->FillArrayOfTriangles(1); theMaillageS->FillArrayOfTriangles(1);
theMaillageS->FillArrayOfTriangles(2); theMaillageS->FillArrayOfTriangles(2);
theMaillageS->LinkEdges2Triangles(); theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->TrianglesDeflectionsRefinementBSB(); theMaillageS->TrianglesDeflectionsRefinementBSB();
Standard_Integer FinTTC = theMaillageS->TriangleCompare(); Standard_Integer FinTTC = theMaillageS->TriangleCompare();
@ -291,113 +289,63 @@ Standard_Boolean IntPolyh_Intersection::PerformMaillage(IntPolyh_PMaillageAffina
theMaillageS->FillArrayOfPnt(2); theMaillageS->FillArrayOfPnt(2);
theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2), theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2),
xx0, yy0, zz0, xx1, yy1, zz1); xx0, yy0, zz0, xx1, yy1, zz1);
theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->FillArrayOfTriangles(1); theMaillageS->FillArrayOfTriangles(1);
theMaillageS->FillArrayOfTriangles(2); theMaillageS->FillArrayOfTriangles(2);
theMaillageS->LinkEdges2Triangles(); theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->TrianglesDeflectionsRefinementBSB(); theMaillageS->TrianglesDeflectionsRefinementBSB();
FinTTC = theMaillageS->TriangleCompare(); FinTTC = theMaillageS->TriangleCompare();
myZone = Standard_False; myZone = Standard_False;
theMaillageS->SetEnlargeZone( myZone ); theMaillageS->SetEnlargeZone( myZone );
} }
/*
// if too many intersections, consider surfaces parallel (eap)
if(FinTTC > 200 &&
(FinTTC >= theMaillageS->GetArrayOfTriangles(1).NbTriangles() ||
FinTTC >= theMaillageS->GetArrayOfTriangles(2).NbTriangles()) ) {
return Standard_False;
}
*/
return Standard_True; return Standard_True;
} }
//======================================================================= //=======================================================================
//function : MergeCouples //function : MergeCouples
//purpose : This method analyzes arrays to find same couples. If some //purpose : This method analyzes the lists to find same couples.
// are detected it leaves the couple in only one array // If some are detected it leaves the couple in only one list
// deleting from others. // deleting from others.
//======================================================================= //=======================================================================
void IntPolyh_Intersection::MergeCouples void IntPolyh_Intersection::MergeCouples(IntPolyh_ListOfCouples &anArrayFF,
(IntPolyh_ArrayOfCouples &anArrayFF, IntPolyh_ListOfCouples &anArrayFR,
IntPolyh_ArrayOfCouples &anArrayFR, IntPolyh_ListOfCouples &anArrayRF,
IntPolyh_ArrayOfCouples &anArrayRF, IntPolyh_ListOfCouples &anArrayRR) const
IntPolyh_ArrayOfCouples &anArrayRR) const
{ {
// Step 1: Sorting arrays. // Fence map to remove from the lists the duplicating elements.
IntPolyh_ArrayOfCouples *anArrays[4]; NCollection_Map<IntPolyh_Couple, IntPolyh_CoupleMapHasher> aFenceMap;
Standard_Integer aNbCouples[4]; //
Standard_Integer i; IntPolyh_ListOfCouples* pLists[4] = {&anArrayFF, &anArrayFR, &anArrayRF, &anArrayRR};
IntPolyh_ArrayOfCouples *aTmpPtr; for (Standard_Integer i = 0; i < 4; ++i) {
Standard_Integer aTmpNbr; IntPolyh_ListIteratorOfListOfCouples aIt(*pLists[i]);
for (; aIt.More();) {
anArrays[0] = &anArrayFF; if (!aFenceMap.Add(aIt.Value())) {
anArrays[1] = &anArrayFR; pLists[i]->Remove(aIt);
anArrays[2] = &anArrayRF; continue;
anArrays[3] = &anArrayRR;
for (i = 0; i < 4; i++)
aNbCouples[i] = anArrays[i]->NbItems();
Standard_Boolean isChanged = Standard_True;
while (isChanged) {
isChanged = Standard_False;
for (i = 0; i < 3; i++) {
if (aNbCouples[i] < aNbCouples[i + 1]) {
aTmpPtr = anArrays[i];
anArrays[i] = anArrays[i + 1];
anArrays[i + 1] = aTmpPtr;
aTmpNbr = aNbCouples[i];
aNbCouples[i] = aNbCouples[i + 1];
aNbCouples[i + 1] = aTmpNbr;
isChanged = Standard_True;
}
}
}
// Step 2: Searching for same couples.
Standard_Integer j;
Standard_Integer indC1;
Standard_Integer indC2;
for (i = 0; i < 3; i++) {
for (j = i + 1; j < 4; j++) {
for (indC1 = 1; indC1 <= aNbCouples[i]; indC1++) {
IntPolyh_Couple &aCouple1 = anArrays[i]->ChangeValue(indC1);
if (aCouple1.AnalyseFlagValue() == 1)
continue;
for (indC2 = 1; indC2 <= aNbCouples[j]; indC2++) {
IntPolyh_Couple &aCouple2 = anArrays[j]->ChangeValue(indC2);
if (aCouple2.AnalyseFlagValue() == 1)
continue;
if (aCouple1.FirstValue() == aCouple2.FirstValue() &&
aCouple1.SecondValue() == aCouple2.SecondValue()) {
aCouple2.SetAnalyseFlag(1);
}
}
} }
aIt.Next();
} }
} }
} }
// Modified by skv - Thu Sep 25 18:07:42 2003 OCC567 End
//=======================================================================
//function : PerformStd
//purpose :
//=======================================================================
Standard_Boolean IntPolyh_Intersection::PerformStd(IntPolyh_PMaillageAffinage& MaillageS, Standard_Boolean IntPolyh_Intersection::PerformStd(IntPolyh_PMaillageAffinage& MaillageS,
Standard_Integer& NbCouples) Standard_Integer& NbCouples)
{ {
Standard_Boolean isdone = PerformMaillage(MaillageS); Standard_Boolean isdone = PerformMaillage(MaillageS);
NbCouples = (isdone) ? (MaillageS->GetArrayOfCouples().NbItems()) : 0; NbCouples = (isdone) ? (MaillageS->GetCouples().Extent()) : 0;
return isdone; return isdone;
} }
//=======================================================================
//function : PerformAdv
//purpose :
//=======================================================================
Standard_Boolean IntPolyh_Intersection::PerformAdv(IntPolyh_PMaillageAffinage& MaillageFF, Standard_Boolean IntPolyh_Intersection::PerformAdv(IntPolyh_PMaillageAffinage& MaillageFF,
IntPolyh_PMaillageAffinage& MaillageFR, IntPolyh_PMaillageAffinage& MaillageFR,
IntPolyh_PMaillageAffinage& MaillageRF, IntPolyh_PMaillageAffinage& MaillageRF,
@ -414,14 +362,14 @@ Standard_Boolean IntPolyh_Intersection::PerformAdv(IntPolyh_PMaillageAffinage& M
isdone = Standard_False; isdone = Standard_False;
if(isdone) { if(isdone) {
NbCouples = MaillageFF->GetArrayOfCouples().NbItems() + NbCouples = MaillageFF->GetCouples().Extent() +
MaillageFR->GetArrayOfCouples().NbItems() + MaillageFR->GetCouples().Extent() +
MaillageRF->GetArrayOfCouples().NbItems() + MaillageRF->GetCouples().Extent() +
MaillageRR->GetArrayOfCouples().NbItems(); MaillageRR->GetCouples().Extent();
if(NbCouples > 0) if(NbCouples > 0)
MergeCouples(MaillageFF->GetArrayOfCouples(),MaillageFR->GetArrayOfCouples(), MergeCouples(MaillageFF->GetCouples(),MaillageFR->GetCouples(),
MaillageRF->GetArrayOfCouples(),MaillageRR->GetArrayOfCouples()); MaillageRF->GetCouples(),MaillageRR->GetCouples());
} }
return isdone; return isdone;
} }

View File

@ -28,7 +28,7 @@
#include <TColStd_Array1OfReal.hxx> #include <TColStd_Array1OfReal.hxx>
#include <Standard_Real.hxx> #include <Standard_Real.hxx>
#include <IntPolyh_PMaillageAffinage.hxx> #include <IntPolyh_PMaillageAffinage.hxx>
#include <IntPolyh_ArrayOfCouples.hxx> #include <IntPolyh_ListOfCouples.hxx>
class Adaptor3d_HSurface; class Adaptor3d_HSurface;
@ -109,7 +109,7 @@ private:
//! This method analyzes arrays to find same couples. If some //! This method analyzes arrays to find same couples. If some
//! are detected it leaves the couple in only one array //! are detected it leaves the couple in only one array
//! deleting from others. //! deleting from others.
Standard_EXPORT void MergeCouples (IntPolyh_ArrayOfCouples& anArrayFF, IntPolyh_ArrayOfCouples& anArrayFR, IntPolyh_ArrayOfCouples& anArrayRF, IntPolyh_ArrayOfCouples& anArrayRR) const; Standard_EXPORT void MergeCouples (IntPolyh_ListOfCouples& anArrayFF, IntPolyh_ListOfCouples& anArrayFR, IntPolyh_ListOfCouples& anArrayRF, IntPolyh_ListOfCouples& anArrayRR) const;
//! Process default interference //! Process default interference
Standard_EXPORT Standard_Boolean PerformStd (IntPolyh_PMaillageAffinage& MaillageS, Standard_Integer& NbCouples); Standard_EXPORT Standard_Boolean PerformStd (IntPolyh_PMaillageAffinage& MaillageS, Standard_Integer& NbCouples);

View File

@ -15,7 +15,7 @@
#include <Adaptor3d_HSurface.hxx> #include <Adaptor3d_HSurface.hxx>
#include <IntPolyh_ArrayOfCouples.hxx> #include <IntPolyh_ListOfCouples.hxx>
#include <IntPolyh_Couple.hxx> #include <IntPolyh_Couple.hxx>
#include <IntPolyh_Intersection.hxx> #include <IntPolyh_Intersection.hxx>
#include <IntPolyh_MaillageAffinage.hxx> #include <IntPolyh_MaillageAffinage.hxx>
@ -153,34 +153,26 @@ Standard_Boolean IntPolyh_Intersection::PerformMaillage(const Standard_Boolean i
theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2), theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2),
xx0, yy0, zz0, xx1, yy1, zz1); xx0, yy0, zz0, xx1, yy1, zz1);
theMaillageS->FillArrayOfTriangles(1);
theMaillageS->FillArrayOfTriangles(2);
theMaillageS->FillArrayOfEdges(1); theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2); theMaillageS->FillArrayOfEdges(2);
theMaillageS->FillArrayOfTriangles(1);
theMaillageS->FillArrayOfTriangles(2);
theMaillageS->LinkEdges2Triangles();
theMaillageS->TrianglesDeflectionsRefinementBSB(); theMaillageS->TrianglesDeflectionsRefinementBSB();
Standard_Integer FinTTC = theMaillageS->TriangleCompare(); Standard_Integer FinTTC = theMaillageS->TriangleCompare();
// if too many intersections, consider surfaces parallel (eap) // if too many intersections, consider surfaces parallel (eap)
/* // test for parallel surf
if(FinTTC > 200 &&
(FinTTC >= theMaillageS->GetArrayOfTriangles(1).NbTriangles() ||
FinTTC >= theMaillageS->GetArrayOfTriangles(2).NbTriangles()) ) {
return Standard_False;
}
*/
//IFV test for parallel surf
if(FinTTC > 200) { if(FinTTC > 200) {
const Standard_Real eps = .996; //~ cos of 5deg. const Standard_Real eps = .996; //~ cos of 5deg.
IntPolyh_ArrayOfCouples& Couples = theMaillageS->GetArrayOfCouples(); IntPolyh_ListOfCouples& Couples = theMaillageS->GetCouples();
Standard_Integer i, npara = 0; Standard_Integer npara = 0;
for(i = 0; i < FinTTC; ++i) { IntPolyh_ListIteratorOfListOfCouples aIt(Couples);
Standard_Real cosa = Abs(Couples[i].AngleValue()); for(; aIt.More(); aIt.Next()) {
Standard_Real cosa = Abs(aIt.Value().Angle());
if(cosa > eps) ++npara; if(cosa > eps) ++npara;
} }
if(npara >= theMaillageS->GetArrayOfTriangles(1).NbItems() || if(npara >= theMaillageS->GetArrayOfTriangles(1).NbItems() ||
@ -214,14 +206,13 @@ Standard_Boolean IntPolyh_Intersection::PerformMaillage(const TColStd_Array1OfRe
Standard_Real xx0,yy0,zz0,xx1,yy1,zz1; Standard_Real xx0,yy0,zz0,xx1,yy1,zz1;
theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2), theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2),
xx0, yy0, zz0, xx1, yy1, zz1); xx0, yy0, zz0, xx1, yy1, zz1);
theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->FillArrayOfTriangles(1); theMaillageS->FillArrayOfTriangles(1);
theMaillageS->FillArrayOfTriangles(2); theMaillageS->FillArrayOfTriangles(2);
theMaillageS->LinkEdges2Triangles(); theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->TrianglesDeflectionsRefinementBSB(); theMaillageS->TrianglesDeflectionsRefinementBSB();
Standard_Integer FinTTC = theMaillageS->TriangleCompare(); Standard_Integer FinTTC = theMaillageS->TriangleCompare();
@ -233,11 +224,10 @@ Standard_Boolean IntPolyh_Intersection::PerformMaillage(const TColStd_Array1OfRe
theMaillageS->FillArrayOfPnt(2); theMaillageS->FillArrayOfPnt(2);
theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2), theMaillageS->CommonBox(theMaillageS->GetBox(1), theMaillageS->GetBox(2),
xx0, yy0, zz0, xx1, yy1, zz1); xx0, yy0, zz0, xx1, yy1, zz1);
theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->FillArrayOfTriangles(1); theMaillageS->FillArrayOfTriangles(1);
theMaillageS->FillArrayOfTriangles(2); theMaillageS->FillArrayOfTriangles(2);
theMaillageS->LinkEdges2Triangles(); theMaillageS->FillArrayOfEdges(1);
theMaillageS->FillArrayOfEdges(2);
theMaillageS->TrianglesDeflectionsRefinementBSB(); theMaillageS->TrianglesDeflectionsRefinementBSB();
FinTTC = theMaillageS->TriangleCompare(); FinTTC = theMaillageS->TriangleCompare();
myZone = Standard_False; myZone = Standard_False;
@ -245,21 +235,15 @@ Standard_Boolean IntPolyh_Intersection::PerformMaillage(const TColStd_Array1OfRe
} }
// if too many intersections, consider surfaces parallel (eap) // if too many intersections, consider surfaces parallel (eap)
/*
if(FinTTC > 200 &&
(FinTTC >= theMaillageS->GetArrayOfTriangles(1).NbTriangles() ||
FinTTC >= theMaillageS->GetArrayOfTriangles(2).NbTriangles()) ) {
return Standard_False;
}
*/
//IFV test for parallel surf //IFV test for parallel surf
if(FinTTC > 200) { if(FinTTC > 200) {
const Standard_Real eps = .996; //~ cos of 5deg. const Standard_Real eps = .996; //~ cos of 5deg.
IntPolyh_ArrayOfCouples& Couples = theMaillageS->GetArrayOfCouples(); IntPolyh_ListOfCouples& Couples = theMaillageS->GetCouples();
Standard_Integer i, npara = 0; Standard_Integer npara = 0;
for(i = 0; i < FinTTC; ++i) { IntPolyh_ListIteratorOfListOfCouples aIt(Couples);
Standard_Real cosa = Abs(Couples[i].AngleValue()); for(; aIt.More(); aIt.Next()) {
Standard_Real cosa = Abs(aIt.Value().Angle());
if(cosa > eps) ++npara; if(cosa > eps) ++npara;
} }
if(npara >= theMaillageS->GetArrayOfTriangles(1).NbItems() || if(npara >= theMaillageS->GetArrayOfTriangles(1).NbItems() ||
@ -303,14 +287,14 @@ Standard_Boolean IntPolyh_Intersection::PerformAdv(const TColStd_Array1OfReal& U
isdone = Standard_False; isdone = Standard_False;
if(isdone) { if(isdone) {
NbCouples = MaillageFF->GetArrayOfCouples().NbItems() + NbCouples = MaillageFF->GetCouples().Extent() +
MaillageFR->GetArrayOfCouples().NbItems() + MaillageFR->GetCouples().Extent() +
MaillageRF->GetArrayOfCouples().NbItems() + MaillageRF->GetCouples().Extent() +
MaillageRR->GetArrayOfCouples().NbItems(); MaillageRR->GetCouples().Extent();
if(NbCouples > 0) if(NbCouples > 0)
MergeCouples(MaillageFF->GetArrayOfCouples(),MaillageFR->GetArrayOfCouples(), MergeCouples(MaillageFF->GetCouples(),MaillageFR->GetCouples(),
MaillageRF->GetArrayOfCouples(),MaillageRR->GetArrayOfCouples()); MaillageRF->GetCouples(),MaillageRR->GetCouples());
} }
return isdone; return isdone;
} }
@ -328,6 +312,6 @@ Standard_Boolean IntPolyh_Intersection::PerformStd(const TColStd_Array1OfReal& U
{ {
Standard_Boolean isdone = PerformMaillage(Upars1, Vpars1, Upars2, Vpars2, Standard_Boolean isdone = PerformMaillage(Upars1, Vpars1, Upars2, Vpars2,
MaillageS); MaillageS);
NbCouples = (isdone) ? (MaillageS->GetArrayOfCouples().NbItems()) : 0; NbCouples = (isdone) ? (MaillageS->GetCouples().Extent()) : 0;
return isdone; return isdone;
} }

View File

@ -13,12 +13,13 @@
// Alternatively, this file may be used under the terms of Open CASCADE // Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement. // commercial license or contractual agreement.
#ifndef IntPolyh_ArrayOfCouples_HeaderFile #ifndef IntPolyh_ListOfCouples_HeaderFile
#define IntPolyh_ArrayOfCouples_HeaderFile #define IntPolyh_ListOfCouples_HeaderFile
#include <IntPolyh_Array.hxx> #include <NCollection_List.hxx>
#include <IntPolyh_Couple.hxx> #include <IntPolyh_Couple.hxx>
typedef IntPolyh_Array <IntPolyh_Couple> IntPolyh_ArrayOfCouples; typedef NCollection_List <IntPolyh_Couple> IntPolyh_ListOfCouples;
typedef IntPolyh_ListOfCouples::Iterator IntPolyh_ListIteratorOfListOfCouples;
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -27,8 +27,7 @@
#include <IntPolyh_ArrayOfPoints.hxx> #include <IntPolyh_ArrayOfPoints.hxx>
#include <IntPolyh_ArrayOfEdges.hxx> #include <IntPolyh_ArrayOfEdges.hxx>
#include <IntPolyh_ArrayOfTriangles.hxx> #include <IntPolyh_ArrayOfTriangles.hxx>
#include <IntPolyh_ArrayOfCouples.hxx> #include <IntPolyh_ListOfCouples.hxx>
#include <IntPolyh_ArrayOfStartPoints.hxx>
#include <Standard_Boolean.hxx> #include <Standard_Boolean.hxx>
#include <TColStd_Array1OfReal.hxx> #include <TColStd_Array1OfReal.hxx>
#include <IntPolyh_ArrayOfSectionLines.hxx> #include <IntPolyh_ArrayOfSectionLines.hxx>
@ -92,10 +91,6 @@ public:
//! CommonBox function. //! CommonBox function.
Standard_EXPORT void FillArrayOfTriangles (const Standard_Integer SurfID); Standard_EXPORT void FillArrayOfTriangles (const Standard_Integer SurfID);
//! fill the edge fields in Triangle object for the
//! two array of triangles.
Standard_EXPORT void LinkEdges2Triangles();
//! Refine systematicaly all marked triangles of both surfaces //! Refine systematicaly all marked triangles of both surfaces
Standard_EXPORT void CommonPartRefinement(); Standard_EXPORT void CommonPartRefinement();
@ -118,23 +113,17 @@ public:
//! if no. //! if no.
Standard_EXPORT Standard_Integer TriContact (const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& Q1, const IntPolyh_Point& Q2, const IntPolyh_Point& Q3, Standard_Real& Angle) const; Standard_EXPORT Standard_Integer TriContact (const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& Q1, const IntPolyh_Point& Q2, const IntPolyh_Point& Q3, Standard_Real& Angle) const;
Standard_EXPORT Standard_Integer TriangleEdgeContact (const Standard_Integer TriSurfID, const Standard_Integer EdgeIndice, const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& C1, const IntPolyh_Point& C2, const IntPolyh_Point& C3, const IntPolyh_Point& Pe1, const IntPolyh_Point& Pe2, const IntPolyh_Point& E, const IntPolyh_Point& N, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const; Standard_EXPORT Standard_Integer TriangleEdgeContact (const Standard_Integer TriSurfID, const Standard_Integer EdgeIndice, const IntPolyh_Triangle& Tri1, const IntPolyh_Triangle& Tri2, const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& C1, const IntPolyh_Point& C2, const IntPolyh_Point& C3, const IntPolyh_Point& Pe1, const IntPolyh_Point& Pe2, const IntPolyh_Point& E, const IntPolyh_Point& N, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const;
Standard_EXPORT Standard_Integer TriangleEdgeContact2 (const Standard_Integer TriSurfID, const Standard_Integer EdgeIndice, const IntPolyh_Triangle& Tri1, const IntPolyh_Triangle& Tri2, const IntPolyh_Point& P1, const IntPolyh_Point& P2, const IntPolyh_Point& P3, const IntPolyh_Point& C1, const IntPolyh_Point& C2, const IntPolyh_Point& C3, const IntPolyh_Point& Pe1, const IntPolyh_Point& Pe2, const IntPolyh_Point& E, const IntPolyh_Point& N, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const;
Standard_EXPORT Standard_Integer StartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const;
//! From two triangles compute intersection points. //! From two triangles compute intersection points.
//! If I found more than two intersection points //! If I found more than two intersection points
//! that's mean that those triangle are coplanar //! that's mean that those triangle are coplanar
Standard_EXPORT Standard_Integer StartingPointsResearch2 (const Standard_Integer T1, const Standard_Integer T2, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const; Standard_EXPORT Standard_Integer StartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, IntPolyh_StartPoint& SP1, IntPolyh_StartPoint& SP2) const;
Standard_EXPORT Standard_Integer NextStartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, const IntPolyh_StartPoint& SPInit, IntPolyh_StartPoint& SPNext) const;
//! from two triangles and an intersection point I //! from two triangles and an intersection point I
//! seach the other point (if it exist). //! seach the other point (if it exist).
//! This function is used by StartPointChain //! This function is used by StartPointChain
Standard_EXPORT Standard_Integer NextStartingPointsResearch2 (const Standard_Integer T1, const Standard_Integer T2, const IntPolyh_StartPoint& SPInit, IntPolyh_StartPoint& SPNext) const; Standard_EXPORT Standard_Integer NextStartingPointsResearch (const Standard_Integer T1, const Standard_Integer T2, const IntPolyh_StartPoint& SPInit, IntPolyh_StartPoint& SPNext) const;
//! Analyse each couple of triangles from the two -- //! Analyse each couple of triangles from the two --
//! array of triangles, to see if they are in //! array of triangles, to see if they are in
@ -142,14 +131,6 @@ public:
//! couples in contact in the array of couples //! couples in contact in the array of couples
Standard_EXPORT Standard_Integer TriangleCompare(); Standard_EXPORT Standard_Integer TriangleCompare();
//! The same as TriangleCompare, plus compute the
//! StartPoints without chaining them.
Standard_EXPORT Standard_Integer TriangleComparePSP();
//! From the array of couples compute all the start
//! points and display them on the screen
Standard_EXPORT void StartPointsCalcul() const;
//! Loop on the array of couples. Compute StartPoints. //! Loop on the array of couples. Compute StartPoints.
//! Try to chain the StartPoints into SectionLines or //! Try to chain the StartPoints into SectionLines or
//! put the point in the ArrayOfTangentZones if //! put the point in the ArrayOfTangentZones if
@ -172,12 +153,8 @@ public:
Standard_EXPORT Bnd_Box GetBox (const Standard_Integer SurfID) const; Standard_EXPORT Bnd_Box GetBox (const Standard_Integer SurfID) const;
Standard_EXPORT void GetBoxDraw (const Standard_Integer SurfID) const; //! This method returns list of couples of contact triangles.
Standard_EXPORT IntPolyh_ListOfCouples& GetCouples();
Standard_EXPORT const IntPolyh_ArrayOfStartPoints& GetArrayOfSP() const;
//! This method returns array of couples of contact triangles.
Standard_EXPORT IntPolyh_ArrayOfCouples& GetArrayOfCouples();
Standard_EXPORT void SetEnlargeZone (Standard_Boolean& EnlargeZone); Standard_EXPORT void SetEnlargeZone (Standard_Boolean& EnlargeZone);
@ -190,14 +167,9 @@ public:
Standard_EXPORT Standard_Real GetMaxDeflection (const Standard_Integer SurfID) const; Standard_EXPORT Standard_Real GetMaxDeflection (const Standard_Integer SurfID) const;
protected: protected:
private: private:
@ -216,23 +188,21 @@ private:
Standard_Real FlecheMin2; Standard_Real FlecheMin2;
Standard_Real FlecheMoy1; Standard_Real FlecheMoy1;
Standard_Real FlecheMoy2; Standard_Real FlecheMoy2;
// For the arrays of Points, Edges and Triangles we need instant access to the items.
// Moreover, we might add new items during refinement process in case the deflection
// is too big, thus the vectors should be used.
IntPolyh_ArrayOfPoints TPoints1; IntPolyh_ArrayOfPoints TPoints1;
IntPolyh_ArrayOfPoints TPoints2; IntPolyh_ArrayOfPoints TPoints2;
IntPolyh_ArrayOfEdges TEdges1; IntPolyh_ArrayOfEdges TEdges1;
IntPolyh_ArrayOfEdges TEdges2; IntPolyh_ArrayOfEdges TEdges2;
IntPolyh_ArrayOfTriangles TTriangles1; IntPolyh_ArrayOfTriangles TTriangles1;
IntPolyh_ArrayOfTriangles TTriangles2; IntPolyh_ArrayOfTriangles TTriangles2;
IntPolyh_ArrayOfCouples TTrianglesContacts; // The intersecting triangles are just filled and then
IntPolyh_ArrayOfStartPoints TStartPoints; // sequentially analyzed, thus we might use the list.
Standard_Boolean myEnlargeZone; IntPolyh_ListOfCouples TTrianglesContacts;
Standard_Boolean myEnlargeZone;
}; };
#endif // _IntPolyh_MaillageAffinage_HeaderFile #endif // _IntPolyh_MaillageAffinage_HeaderFile

View File

@ -19,159 +19,6 @@
#include <IntPolyh_Point.hxx> #include <IntPolyh_Point.hxx>
#include <stdio.h> #include <stdio.h>
//=======================================================================
//function : IntPolyh_Point
//purpose :
//=======================================================================
IntPolyh_Point::IntPolyh_Point()
:
x(0),y(0),z(0),u(0),v(0),POC(1),
myDegenerated(Standard_False)
{
}
//=======================================================================
//function : IntPolyh_Point
//purpose :
//=======================================================================
IntPolyh_Point::IntPolyh_Point(const Standard_Real _x,
const Standard_Real _y,
const Standard_Real _z,
const Standard_Real _u,
const Standard_Real _v)
:
POC(1),
myDegenerated(Standard_False)
{
x=_x; y=_y; z=_z; u=_u; v=_v;
}
//=======================================================================
//function : X
//purpose :
//=======================================================================
Standard_Real IntPolyh_Point::X() const
{
return x;
}
//=======================================================================
//function : Y
//purpose :
//=======================================================================
Standard_Real IntPolyh_Point::Y() const
{
return y;
}
//=======================================================================
//function : Z
//purpose :
//=======================================================================
Standard_Real IntPolyh_Point::Z() const
{
return z;
}
//=======================================================================
//function : U
//purpose :
//=======================================================================
Standard_Real IntPolyh_Point::U() const
{
return u;
}
//=======================================================================
//function : V
//purpose :
//=======================================================================
Standard_Real IntPolyh_Point::V() const
{
return v;
}
//=======================================================================
//function : PartOfCommon
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Point::PartOfCommon() const
{
return POC;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void IntPolyh_Point::Set(const Standard_Real _x,
const Standard_Real _y,
const Standard_Real _z,
const Standard_Real _u,
const Standard_Real _v,
const Standard_Integer II)
{
x=_x;
y=_y;
z=_z;
u=_u;
v=_v;
POC=II;
}
//=======================================================================
//function : Equal
//purpose :
//=======================================================================
void IntPolyh_Point::Equal(const IntPolyh_Point &Pt)
{
x = Pt.x;
y = Pt.y;
z = Pt.z;
u = Pt.u;
v = Pt.v;
}
//=======================================================================
//function : SetX
//purpose :
//=======================================================================
void IntPolyh_Point::SetX(const Standard_Real _x)
{
x=_x;
}
//=======================================================================
//function : SetY
//purpose :
//=======================================================================
void IntPolyh_Point::SetY(const Standard_Real _y)
{
y=_y;
}
//=======================================================================
//function : SetZ
//purpose :
//=======================================================================
void IntPolyh_Point::SetZ(const Standard_Real _z)
{
z=_z;
}
//=======================================================================
//function : SetU
//purpose :
//=======================================================================
void IntPolyh_Point::SetU(const Standard_Real _u)
{
u=_u;
}
//=======================================================================
//function : SetV
//purpose :
//=======================================================================
void IntPolyh_Point::SetV(const Standard_Real _v)
{
v=_v;
}
//=======================================================================
//function : SetPartOfCommon
//purpose :
//=======================================================================
void IntPolyh_Point::SetPartOfCommon(const Standard_Integer ii)
{
POC=ii;
}
//======================================================================= //=======================================================================
//function : Middle //function : Middle
@ -180,14 +27,14 @@ void IntPolyh_Point::SetPartOfCommon(const Standard_Integer ii)
void IntPolyh_Point::Middle(const Handle(Adaptor3d_HSurface)& MySurface, void IntPolyh_Point::Middle(const Handle(Adaptor3d_HSurface)& MySurface,
const IntPolyh_Point & Point1, const IntPolyh_Point & Point1,
const IntPolyh_Point & Point2){ const IntPolyh_Point & Point2){
u = (Point1.U()+Point2.U())*0.5; myU = (Point1.U()+Point2.U())*0.5;
v = (Point1.V()+Point2.V())*0.5; myV = (Point1.V()+Point2.V())*0.5;
gp_Pnt PtXYZ = (MySurface)->Value(u, v); gp_Pnt PtXYZ = (MySurface)->Value(myU, myV);
x=PtXYZ.X(); myX=PtXYZ.X();
y=PtXYZ.Y(); myY=PtXYZ.Y();
z=PtXYZ.Z(); myZ=PtXYZ.Z();
} }
//======================================================================= //=======================================================================
//function : Add //function : Add
@ -197,11 +44,11 @@ IntPolyh_Point IntPolyh_Point::Add(const IntPolyh_Point &P1)const
{ {
IntPolyh_Point res; IntPolyh_Point res;
// //
res.SetX(x+P1.X()); res.SetX(myX+P1.X());
res.SetY(y+P1.Y()); res.SetY(myY+P1.Y());
res.SetZ(z+P1.Z()); res.SetZ(myZ+P1.Z());
res.SetU(u+P1.U()); res.SetU(myU+P1.U());
res.SetV(v+P1.V()); res.SetV(myV+P1.V());
return res; return res;
} }
@ -213,11 +60,11 @@ IntPolyh_Point IntPolyh_Point::Sub(const IntPolyh_Point &P1)const
{ {
IntPolyh_Point res; IntPolyh_Point res;
// //
res.SetX(x-P1.X()); res.SetX(myX-P1.X());
res.SetY(y-P1.Y()); res.SetY(myY-P1.Y());
res.SetZ(z-P1.Z()); res.SetZ(myZ-P1.Z());
res.SetU(u-P1.U()); res.SetU(myU-P1.U());
res.SetV(v-P1.V()); res.SetV(myV-P1.V());
return res; return res;
} }
//======================================================================= //=======================================================================
@ -229,11 +76,11 @@ IntPolyh_Point IntPolyh_Point::Divide(const Standard_Real RR)const
IntPolyh_Point res; IntPolyh_Point res;
// //
if (Abs(RR)>10.0e-20) { if (Abs(RR)>10.0e-20) {
res.SetX(x/RR); res.SetX(myX/RR);
res.SetY(y/RR); res.SetY(myY/RR);
res.SetZ(z/RR); res.SetZ(myZ/RR);
res.SetU(u/RR); res.SetU(myU/RR);
res.SetV(v/RR); res.SetV(myV/RR);
} }
else { else {
printf("Division par zero RR=%f\n",RR); printf("Division par zero RR=%f\n",RR);
@ -248,11 +95,11 @@ IntPolyh_Point IntPolyh_Point::Multiplication(const Standard_Real RR)const
{ {
IntPolyh_Point res; IntPolyh_Point res;
// //
res.SetX(x*RR); res.SetX(myX*RR);
res.SetY(y*RR); res.SetY(myY*RR);
res.SetZ(z*RR); res.SetZ(myZ*RR);
res.SetU(u*RR); res.SetU(myU*RR);
res.SetV(v*RR); res.SetV(myV*RR);
return res; return res;
} }
//======================================================================= //=======================================================================
@ -261,7 +108,7 @@ IntPolyh_Point IntPolyh_Point::Multiplication(const Standard_Real RR)const
//======================================================================= //=======================================================================
Standard_Real IntPolyh_Point::SquareModulus()const Standard_Real IntPolyh_Point::SquareModulus()const
{ {
Standard_Real res=x*x+y*y+z*z; Standard_Real res=myX*myX+myY*myY+myZ*myZ;
return res; return res;
} }
@ -271,7 +118,7 @@ Standard_Real IntPolyh_Point::SquareModulus()const
//======================================================================= //=======================================================================
Standard_Real IntPolyh_Point::SquareDistance(const IntPolyh_Point &P2)const Standard_Real IntPolyh_Point::SquareDistance(const IntPolyh_Point &P2)const
{ {
Standard_Real res=(x-P2.x)*(x-P2.x)+(y-P2.y)*(y-P2.y)+(z-P2.z)*(z-P2.z); Standard_Real res=(myX-P2.myX)*(myX-P2.myX)+(myY-P2.myY)*(myY-P2.myY)+(myZ-P2.myZ)*(myZ-P2.myZ);
return res; return res;
} }
//======================================================================= //=======================================================================
@ -280,7 +127,7 @@ Standard_Real IntPolyh_Point::SquareDistance(const IntPolyh_Point &P2)const
//======================================================================= //=======================================================================
Standard_Real IntPolyh_Point::Dot(const IntPolyh_Point &b ) const Standard_Real IntPolyh_Point::Dot(const IntPolyh_Point &b ) const
{ {
Standard_Real t=x*b.x+y*b.y+z*b.z; Standard_Real t=myX*b.myX+myY*b.myY+myZ*b.myZ;
return t; return t;
} }
//======================================================================= //=======================================================================
@ -288,9 +135,9 @@ Standard_Real IntPolyh_Point::Dot(const IntPolyh_Point &b ) const
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntPolyh_Point::Cross(const IntPolyh_Point &a,const IntPolyh_Point &b){ void IntPolyh_Point::Cross(const IntPolyh_Point &a,const IntPolyh_Point &b){
x=a.y*b.z-a.z*b.y; myX=a.myY*b.myZ-a.myZ*b.myY;
y=a.z*b.x-a.x*b.z; myY=a.myZ*b.myX-a.myX*b.myZ;
z=a.x*b.y-a.y*b.x; myZ=a.myX*b.myY-a.myY*b.myX;
} }
//======================================================================= //=======================================================================
//function : Dump //function : Dump
@ -298,7 +145,7 @@ void IntPolyh_Point::Cross(const IntPolyh_Point &a,const IntPolyh_Point &b){
//======================================================================= //=======================================================================
void IntPolyh_Point::Dump() const void IntPolyh_Point::Dump() const
{ {
printf("\nPoint : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg\n",x,y,z,u,v); printf("\nPoint : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg\n",myX,myY,myZ,myU,myV);
} }
//======================================================================= //=======================================================================
//function : Dump //function : Dump
@ -307,29 +154,5 @@ void IntPolyh_Point::Dump() const
void IntPolyh_Point::Dump(const Standard_Integer i) const void IntPolyh_Point::Dump(const Standard_Integer i) const
{ {
printf("\nPoint(%3d) : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg poc=%3d\n", printf("\nPoint(%3d) : x=%+8.3eg y=%+8.3eg z=%+8.3eg u=%+8.3eg v=%+8.3eg poc=%3d\n",
i,x,y,z,u,v,POC); i,myX,myY,myZ,myU,myV,myPOC);
} }
//modified by NIZNHY-PKV Fri Jan 20 12:13:03 2012f
//=======================================================================
//function : SetDegenerated
//purpose :
//=======================================================================
void IntPolyh_Point::SetDegenerated(const Standard_Boolean theFlag)
{
myDegenerated=theFlag;
}
//=======================================================================
//function : Degenerated
//purpose :
//=======================================================================
Standard_Boolean IntPolyh_Point::Degenerated()const
{
return myDegenerated;
}

View File

@ -26,121 +26,177 @@
#include <Standard_Boolean.hxx> #include <Standard_Boolean.hxx>
class Adaptor3d_HSurface; class Adaptor3d_HSurface;
//! The class represents the point on the surface with
//! both 3D and 2D points.
class IntPolyh_Point class IntPolyh_Point
{ {
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
//! Constructor
Standard_EXPORT IntPolyh_Point(); IntPolyh_Point() :
myX(0.), myY(0.), myZ(0.), myU(0.), myV(0.), myPOC(1), myDegenerated(Standard_False)
Standard_EXPORT IntPolyh_Point(const Standard_Real xx, const Standard_Real yy, const Standard_Real zz, const Standard_Real uu, const Standard_Real vv); {}
//! Constructor
Standard_EXPORT Standard_Real X() const; IntPolyh_Point(const Standard_Real x,
const Standard_Real y,
Standard_EXPORT Standard_Real Y() const; const Standard_Real z,
const Standard_Real u,
Standard_EXPORT Standard_Real Z() const; const Standard_Real v)
:
Standard_EXPORT Standard_Real U() const; myX(x), myY(y), myZ(z), myU(u), myV(v), myPOC(1), myDegenerated(Standard_False)
{}
Standard_EXPORT Standard_Real V() const;
//! Returns X coordinate of the 3D point
Standard_EXPORT Standard_Integer PartOfCommon() const; Standard_Real X() const
{
Standard_EXPORT void Equal (const IntPolyh_Point& Pt); return myX;
void operator = (const IntPolyh_Point& Pt) }
{ //! Returns Y coordinate of the 3D point
Equal(Pt); Standard_Real Y() const
} {
return myY;
Standard_EXPORT void Set (const Standard_Real v1, const Standard_Real v2, const Standard_Real v3, const Standard_Real v4, const Standard_Real v5, const Standard_Integer II = 1); }
//! Returns the Z coordinate of the 3D point
Standard_EXPORT void SetX (const Standard_Real v); Standard_Real Z() const
{
Standard_EXPORT void SetY (const Standard_Real v); return myZ;
}
Standard_EXPORT void SetZ (const Standard_Real v); //! Returns the U coordinate of the 2D point
Standard_Real U() const
Standard_EXPORT void SetU (const Standard_Real v); {
return myU;
Standard_EXPORT void SetV (const Standard_Real v); }
//! Returns the V coordinate of the 2D point
Standard_EXPORT void SetPartOfCommon (const Standard_Integer ii); Standard_Real V() const
{
return myV;
}
//! Returns 0 if the point is not common with the other surface
Standard_Integer PartOfCommon() const
{
return myPOC;
}
//! Assignment operator
void Equal (const IntPolyh_Point& Pt)
{
myX = Pt.myX;
myY = Pt.myY;
myZ = Pt.myZ;
myU = Pt.myU;
myV = Pt.myV;
}
void operator = (const IntPolyh_Point& Pt)
{
Equal(Pt);
}
//! Sets the point
void Set (const Standard_Real x,
const Standard_Real y,
const Standard_Real z,
const Standard_Real u,
const Standard_Real v,
const Standard_Integer II = 1)
{
myX = x;
myY = y;
myZ = z;
myU = u;
myV = v;
myPOC = II;
}
//! Sets the X coordinate for the 3D point
void SetX (const Standard_Real x)
{
myX = x;
}
//! Sets the Y coordinate for the 3D point
void SetY (const Standard_Real y)
{
myY = y;
}
//! Sets the Z coordinate for the 3D point
void SetZ (const Standard_Real z)
{
myZ = z;
}
//! Sets the U coordinate for the 2D point
void SetU (const Standard_Real u)
{
myU = u;
}
//! Sets the V coordinate for the 2D point
void SetV (const Standard_Real v)
{
myV = v;
}
//! Sets the part of common
void SetPartOfCommon (const Standard_Integer ii)
{
myPOC = ii;
}
//! Creates middle point from P1 and P2 and stores it to this
Standard_EXPORT void Middle (const Handle(Adaptor3d_HSurface)& MySurface, const IntPolyh_Point& P1, const IntPolyh_Point& P2); Standard_EXPORT void Middle (const Handle(Adaptor3d_HSurface)& MySurface, const IntPolyh_Point& P1, const IntPolyh_Point& P2);
//! Addition
Standard_EXPORT IntPolyh_Point Add (const IntPolyh_Point& P1) const; Standard_EXPORT IntPolyh_Point Add (const IntPolyh_Point& P1) const;
IntPolyh_Point operator + (const IntPolyh_Point& P1) const IntPolyh_Point operator + (const IntPolyh_Point& P1) const
{ {
return Add(P1); return Add(P1);
} }
//! Subtraction
Standard_EXPORT IntPolyh_Point Sub (const IntPolyh_Point& P1) const; Standard_EXPORT IntPolyh_Point Sub (const IntPolyh_Point& P1) const;
IntPolyh_Point operator - (const IntPolyh_Point& P1) const IntPolyh_Point operator - (const IntPolyh_Point& P1) const
{ {
return Sub(P1); return Sub(P1);
} }
//! Division
Standard_EXPORT IntPolyh_Point Divide (const Standard_Real rr) const; Standard_EXPORT IntPolyh_Point Divide (const Standard_Real rr) const;
IntPolyh_Point operator / (const Standard_Real rr) const IntPolyh_Point operator / (const Standard_Real rr) const
{ {
return Divide(rr); return Divide(rr);
} }
//! Multiplication
Standard_EXPORT IntPolyh_Point Multiplication (const Standard_Real rr) const; Standard_EXPORT IntPolyh_Point Multiplication (const Standard_Real rr) const;
IntPolyh_Point operator * (const Standard_Real rr) const IntPolyh_Point operator * (const Standard_Real rr) const
{ {
return Multiplication(rr); return Multiplication(rr);
} }
//! Square modulus
Standard_EXPORT Standard_Real SquareModulus() const; Standard_EXPORT Standard_Real SquareModulus() const;
//! Square distance to the other point
Standard_EXPORT Standard_Real SquareDistance (const IntPolyh_Point& P2) const; Standard_EXPORT Standard_Real SquareDistance (const IntPolyh_Point& P2) const;
//! Dot
Standard_EXPORT Standard_Real Dot (const IntPolyh_Point& P2) const; Standard_EXPORT Standard_Real Dot (const IntPolyh_Point& P2) const;
//! Cross
Standard_EXPORT void Cross (const IntPolyh_Point& P1, const IntPolyh_Point& P2); Standard_EXPORT void Cross (const IntPolyh_Point& P1, const IntPolyh_Point& P2);
//! Dump
Standard_EXPORT void Dump() const; Standard_EXPORT void Dump() const;
//! Dump
Standard_EXPORT void Dump (const Standard_Integer i) const; Standard_EXPORT void Dump (const Standard_Integer i) const;
//! Sets the degenerated flag
Standard_EXPORT void SetDegenerated (const Standard_Boolean theFlag); void SetDegenerated (const Standard_Boolean theFlag)
{
Standard_EXPORT Standard_Boolean Degenerated() const; myDegenerated = theFlag;
}
//! Returns the degenerated flag
Standard_Boolean Degenerated() const
{
return myDegenerated;
}
protected: protected:
private: private:
Standard_Real myX;
Standard_Real myY;
Standard_Real x; Standard_Real myZ;
Standard_Real y; Standard_Real myU;
Standard_Real z; Standard_Real myV;
Standard_Real u; Standard_Integer myPOC;
Standard_Real v;
Standard_Integer POC;
Standard_Boolean myDegenerated; Standard_Boolean myDegenerated;
}; };
#endif // _IntPolyh_Point_HeaderFile #endif // _IntPolyh_Point_HeaderFile

View File

@ -17,10 +17,8 @@
#include <Adaptor3d_HSurface.hxx> #include <Adaptor3d_HSurface.hxx>
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <IntPolyh_Couple.hxx>
#include <IntPolyh_Edge.hxx> #include <IntPolyh_Edge.hxx>
#include <IntPolyh_Point.hxx> #include <IntPolyh_Point.hxx>
#include <IntPolyh_StartPoint.hxx>
#include <IntPolyh_Triangle.hxx> #include <IntPolyh_Triangle.hxx>
#include <stdio.h> #include <stdio.h>
@ -57,418 +55,95 @@ static
IntPolyh_ArrayOfEdges & TEdges) ; IntPolyh_ArrayOfEdges & TEdges) ;
//======================================================================= //=======================================================================
//function : IntPolyh_Triangle //function : ComputeDeflection
//purpose : //purpose : Computes the deflection of the triangle.
// It is computed as a distance between triangles plane and
// barycenter of the triangle in UV space.
//======================================================================= //=======================================================================
IntPolyh_Triangle::IntPolyh_Triangle() Standard_Real
: IntPolyh_Triangle::ComputeDeflection(const Handle(Adaptor3d_HSurface)& theSurface,
p1(-1),p2(-1),p3(-1), const IntPolyh_ArrayOfPoints& TPoints)
e1(-1),oe1(0),e2(-1),oe2(0),e3(-1),oe3(0),
II(0),IP(1),Fleche(0.0)
{ {
} myDeflection = 0.;
//======================================================================= //
//function : IntPolyh_Triangle const IntPolyh_Point & P1 = TPoints[myPoints[0]];
//purpose : const IntPolyh_Point & P2 = TPoints[myPoints[1]];
//======================================================================= const IntPolyh_Point & P3 = TPoints[myPoints[2]];
IntPolyh_Triangle::IntPolyh_Triangle(const Standard_Integer a,
const Standard_Integer b,
const Standard_Integer c)
:
p1(a),p2(b),p3(c),
e1(-1),oe1(0),e2(-1),oe2(0),e3(-1),oe3(0),
II(0),IP(1),Fleche(0.0)
{
}
//=======================================================================
//function : FirstPoint
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::FirstPoint() const
{
return(p1);
}
//=======================================================================
//function : SecondPoint
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::SecondPoint() const
{
return(p2);
}
//=======================================================================
//function : ThirdPoint
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::ThirdPoint() const
{
return(p3);
}
//=======================================================================
//function : FirstEdge
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::FirstEdge() const
{
return(e1);
}
//=======================================================================
//function : FirstEdgeOrientation
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::FirstEdgeOrientation() const
{
return(oe1);
}
//=======================================================================
//function : SecondEdge
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::SecondEdge() const
{
return(e2);
}
//=======================================================================
//function : SecondEdgeOrientation
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::SecondEdgeOrientation() const
{
return(oe2);
}
//=======================================================================
//function : ThirdEdge
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::ThirdEdge() const
{
return(e3);
}
//=======================================================================
//function : ThirdEdgeOrientation
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::ThirdEdgeOrientation() const
{
return(oe3);
}
//=======================================================================
//function : GetFleche
//purpose :
//=======================================================================
Standard_Real IntPolyh_Triangle::GetFleche() const
{
return(Fleche);
}
//=======================================================================
//function : IndiceIntersectionPossible
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::IndiceIntersectionPossible() const
{
return(IP);
}
//=======================================================================
//function : IndiceIntersection
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::IndiceIntersection() const
{
return(II);
}
//=======================================================================
//function : SetFirstPoint
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetFirstPoint(const Standard_Integer a)
{
p1=a;
}
//=======================================================================
//function : SetSecondPoint
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetSecondPoint(const Standard_Integer b)
{
p2=b;
}
//=======================================================================
//function : SetThirdPoint
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetThirdPoint(const Standard_Integer c)
{
p3=c;
}
//=======================================================================
//function : SetFirstEdge
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetFirstEdge(const Standard_Integer e,
const Standard_Integer oe)
{
e1=e;
oe1=oe;
}
//=======================================================================
//function : SetSecondEdge
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetSecondEdge(const Standard_Integer f,
const Standard_Integer of)
{
e2=f;
oe2=of;
}
//=======================================================================
//function : SetThirdEdge
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetThirdEdge(const Standard_Integer g,
const Standard_Integer og)
{
e3=g;
oe3=og;
}
//=======================================================================
//function : SetFleche
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetFleche(const Standard_Real A)
{
Fleche=A;
}
//=======================================================================
//function : SetIndiceIntersectionPossible
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetIndiceIntersectionPossible(const Standard_Integer I)
{
IP=I;
}
//=======================================================================
//function : SetIndiceIntersection
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetIndiceIntersection(const Standard_Integer I)
{
II=I;
}
//=======================================================================
//function : GetEdgeNumber
//purpose :
//=======================================================================
Standard_Integer
IntPolyh_Triangle::GetEdgeNumber(const Standard_Integer EdgeIndex) const
{
if(EdgeIndex==1)
return(e1);
if(EdgeIndex==2)
return(e2);
if(EdgeIndex==3)
return(e3);
return 0;
}
//=======================================================================
//function : SetEdge
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetEdge(const Standard_Integer EdgeIndex,
const Standard_Integer EdgeNumber)
{
if(EdgeIndex==1)
e1=EdgeNumber;
if(EdgeIndex==2)
e2=EdgeNumber;
if(EdgeIndex==3)
e3=EdgeNumber;
}
//=======================================================================
//function : GetEdgeOrientation
//purpose :
//=======================================================================
Standard_Integer
IntPolyh_Triangle::GetEdgeOrientation(const Standard_Integer EdgeIndex) const
{
if(EdgeIndex==1)
return(oe1);
if(EdgeIndex==2)
return(oe2);
if(EdgeIndex==3)
return(oe3);
return 0;
}
//=======================================================================
//function : SetEdgeOrientation
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetEdgeOrientation(const Standard_Integer EdgeIndex,
const Standard_Integer OrEd)
{
if(EdgeIndex==1)
oe1=OrEd;
if(EdgeIndex==2)
oe2=OrEd;
if(EdgeIndex==3)
oe3=OrEd;
}
//=======================================================================
//function : TriangleDeflection
//purpose :
/*Calcul de la fleche pour un triangle**************
Distance entre le plan forme par le triangle et
le barycentre situe sur la surface calcule avec les coordonnees Gu,Gv
(coordonnees du barycentre du triangle dans l'espace UV)*/
//=======================================================================
void IntPolyh_Triangle::TriangleDeflection(const Handle(Adaptor3d_HSurface)& MySurface,
const IntPolyh_ArrayOfPoints& TPoints)
{
const IntPolyh_Point & P1 = TPoints[p1];
const IntPolyh_Point & P2 = TPoints[p2];
const IntPolyh_Point & P3 = TPoints[p3];
// //
//modified by NIZNHY-PKV Fri Jan 20 14:25:11 2012f
{ {
Standard_Integer iDeg1, iDeg2, iDeg3, iDeg; // check if the triangle is not degenerated - no more than one point
// // has a degenerated flag
iDeg1=(P1.Degenerated()) ? 1 : 0; Standard_Integer iDeg = (P1.Degenerated() ? 1 : 0) +
iDeg2=(P2.Degenerated()) ? 1 : 0; (P2.Degenerated() ? 1 : 0) +
iDeg3=(P3.Degenerated()) ? 1 : 0; (P3.Degenerated() ? 1 : 0);
iDeg=iDeg1+iDeg2+iDeg3; if (iDeg > 1) {
if (iDeg>1) { myIsDegenerated = Standard_True;
Fleche=0.; return myDeflection;
return;
} }
} }
//modified by NIZNHY-PKV Fri Jan 20 14:25:13 2012t
Standard_Real Gu, Gv, SqNorme;
gp_Pnt PtXYZ;
// //
Gu=(P1.U()+P2.U()+P3.U())/3.0; // Plane of the triangle
Gv=(P1.V()+P2.V()+P3.V())/3.0;
PtXYZ = (MySurface)->Value( Gu, Gv);
IntPolyh_Point BarycentreReel(PtXYZ.X(), PtXYZ.Y(), PtXYZ.Z(), Gu, Gv);
IntPolyh_Point NormaleTri; IntPolyh_Point NormaleTri;
NormaleTri.Cross(P2-P1,P3-P1); NormaleTri.Cross(P2-P1,P3-P1);
SqNorme=NormaleTri.SquareModulus(); Standard_Real SqNorm = NormaleTri.SquareModulus();
if (SqNorm < SquareMyConfusionPrecision) {
if (SqNorme > SquareMyConfusionPrecision) { // The triangle is degenerated
NormaleTri=NormaleTri/sqrt(SqNorme); myIsDegenerated = Standard_True;
Fleche=Abs(NormaleTri.Dot( BarycentreReel-P1)); return myDeflection;
} }
else { //
// On calcule la fleche sur le plus grand des edges // Compute point on the surface
// calcul des longueurs des cotes au carre Standard_Real Gu=(P1.U()+P2.U()+P3.U())/3.0;
Standard_Real L12 = P1.SquareDistance(P2); Standard_Real Gv=(P1.V()+P2.V()+P3.V())/3.0;
Standard_Real L23 = P2.SquareDistance(P3); gp_Pnt PtXYZ = theSurface->Value( Gu, Gv);
Standard_Real L31 = P3.SquareDistance(P1); // Point on the surface
IntPolyh_Point BarycentreReel(PtXYZ.X(), PtXYZ.Y(), PtXYZ.Z(), Gu, Gv);
IntPolyh_Point Milieu; // milieu du plus grand des edges // compute distance to plane
NormaleTri = NormaleTri / sqrt(SqNorm);
if ((L12>L23) && (L12>L31)) myDeflection = Abs(NormaleTri.Dot(BarycentreReel - P1));
Milieu.Middle( MySurface,P1, P2); return myDeflection;
else if ((L23>L31) && (L23>L12))
Milieu.Middle( MySurface,P2, P3);
else if ((L31>L12) && (L31>L23))
Milieu.Middle( MySurface,P3, P1);
gp_Pnt PtXYZMilieu = (MySurface)->Value( Milieu.U(), Milieu.V());
IntPolyh_Point MilieuReel(PtXYZMilieu.X(), PtXYZMilieu.Y(), PtXYZMilieu.Z(), Milieu.U(), Milieu.V());
Fleche = sqrt(Milieu.SquareDistance(MilieuReel));
}
} }
//======================================================================= //=======================================================================
//function : CheckCommonEdge //function : GetNextTriangle
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Integer Standard_Integer
IntPolyh_Triangle::CheckCommonEdge(const Standard_Integer PT1, IntPolyh_Triangle::GetNextTriangle(const Standard_Integer theTriangle,
const Standard_Integer PT2, const Standard_Integer theEdgeNum,
const Standard_Integer PT3, const IntPolyh_ArrayOfEdges& TEdges) const
const Standard_Integer Index,
const IntPolyh_ArrayOfTriangles &TTriangles) const
{ {
Standard_Integer P1,P2,P3,res=-1; Standard_Integer aNextTriangle = -1;
P1=TTriangles[Index].FirstPoint(); if (theEdgeNum < 1 || theEdgeNum > 3) {
P2=TTriangles[Index].SecondPoint(); return aNextTriangle;
P3=TTriangles[Index].ThirdPoint();
if ( (P1==PT1)||(P1==PT2) ) {
if ( ( (P2==PT1)||(P2==PT2) )&&(P3!=PT3) ) res = Index; //edge commun P1P2
else if ( ( (P3==PT1)||(P3==PT2) )&&(P2!=PT3) ) res = Index;//edge commun P1P3
} }
else if ( (P2==PT1)||(P2==PT2) ) { //
if ( ( (P3==PT1)||(P3==PT2) )&&(P1!=PT3) ) res = Index; //edge commun P2P3 const IntPolyh_Edge & anEdge = TEdges[myEdges[theEdgeNum-1]];
} aNextTriangle = ((anEdge.FirstTriangle() == theTriangle) ?
else res=-1; anEdge.SecondTriangle() : anEdge.FirstTriangle());
return(res); return aNextTriangle;
} }
//=======================================================================
//function : GetNextTriangle2
//purpose :
//=======================================================================
Standard_Integer
IntPolyh_Triangle::GetNextTriangle2(const Standard_Integer NumTri,
const Standard_Integer NumEdge,
const IntPolyh_ArrayOfEdges &TEdges) const
{
Standard_Integer NumNextTri=-1;
if (NumEdge==1) {
const IntPolyh_Edge & Edge1=TEdges[e1];
if(Edge1.FirstTriangle()==NumTri)
NumNextTri=Edge1.SecondTriangle();
else
NumNextTri=Edge1.FirstTriangle();
}
else if (NumEdge==2) {
const IntPolyh_Edge & Edge2=TEdges[e2];
if(Edge2.FirstTriangle()==NumTri)
NumNextTri=Edge2.SecondTriangle();
else
NumNextTri=Edge2.FirstTriangle();
}
else if (NumEdge==3) {
const IntPolyh_Edge & Edge3=TEdges[e3];
if(Edge3.FirstTriangle()==NumTri)
NumNextTri=Edge3.SecondTriangle();
else
NumNextTri=Edge3.FirstTriangle();
}
return (NumNextTri);
}
//======================================================================= //=======================================================================
//function : LinkEdges2Triangle //function : LinkEdges2Triangle
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntPolyh_Triangle::LinkEdges2Triangle(const IntPolyh_ArrayOfEdges & TEdges, void IntPolyh_Triangle::LinkEdges2Triangle(const IntPolyh_ArrayOfEdges& TEdges,
const Standard_Integer edge1, const Standard_Integer theEdge1,
const Standard_Integer edge2, const Standard_Integer theEdge2,
const Standard_Integer edge3) { const Standard_Integer theEdge3)
if( (edge1<0)||(edge2<0)||(edge3<0) ) { {
if (theEdge1 < 0 || theEdge2 < 0 || theEdge3 < 0) {
} return;
else {
e1=edge1;
e2=edge2;
e3=edge3;
if(TEdges[e1].FirstPoint()==p1) oe1=1;
else oe1=-1;
if(TEdges[e2].FirstPoint()==p2) oe2=1;
else oe2=-1;
if(TEdges[e3].FirstPoint()==p3) oe3=1;
else oe3=-1;
} }
//
myEdges[0] = theEdge1;
myEdges[1] = theEdge2;
myEdges[2] = theEdge3;
//
myEdgesOrientations[0] = ((TEdges[myEdges[0]].FirstPoint() == myPoints[0]) ? 1 : -1);
myEdgesOrientations[1] = ((TEdges[myEdges[1]].FirstPoint() == myPoints[1]) ? 1 : -1);
myEdgesOrientations[2] = ((TEdges[myEdges[2]].FirstPoint() == myPoints[2]) ? 1 : -1);
} }
//======================================================================= //=======================================================================
@ -549,7 +224,7 @@ void NewTriangle(const Standard_Integer P1,
TTriangles[FinTT].SetFirstPoint(P1); TTriangles[FinTT].SetFirstPoint(P1);
TTriangles[FinTT].SetSecondPoint(P2); TTriangles[FinTT].SetSecondPoint(P2);
TTriangles[FinTT].SetThirdPoint(P3); TTriangles[FinTT].SetThirdPoint(P3);
TTriangles[FinTT].TriangleDeflection(MySurface, TPoints); TTriangles[FinTT].ComputeDeflection(MySurface, TPoints);
TTriangles.IncrementNbItems(); TTriangles.IncrementNbItems();
} }
@ -595,27 +270,25 @@ void OldEdge(const Standard_Integer EdgeN,
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri, void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
const Handle(Adaptor3d_HSurface)& MySurface, const Handle(Adaptor3d_HSurface)& MySurface,
IntPolyh_ArrayOfPoints &TPoints, IntPolyh_ArrayOfPoints &TPoints,
IntPolyh_ArrayOfTriangles &TTriangles, IntPolyh_ArrayOfTriangles &TTriangles,
IntPolyh_ArrayOfEdges & TEdges) { IntPolyh_ArrayOfEdges & TEdges)
{
Standard_Integer FinTE = TEdges.NbItems(); Standard_Integer FinTE = TEdges.NbItems();
Standard_Integer FinTT = TTriangles.NbItems(); Standard_Integer FinTT = TTriangles.NbItems();
///Raffinage de la maille et de ses voisines par le milieu du plus grand des cotes
// Refinement of the mesh by the middle of the largest dimensions
Standard_Integer numP1 = FirstPoint(); Standard_Integer numP1 = FirstPoint();
Standard_Integer numP2 = SecondPoint(); Standard_Integer numP2 = SecondPoint();
Standard_Integer numP3 = ThirdPoint(); Standard_Integer numP3 = ThirdPoint();
IntPolyh_Point P1 = TPoints[numP1]; const IntPolyh_Point& P1 = TPoints[numP1];
IntPolyh_Point P2 = TPoints[numP2]; const IntPolyh_Point& P2 = TPoints[numP2];
IntPolyh_Point P3 = TPoints[numP3]; const IntPolyh_Point& P3 = TPoints[numP3];
// compute the largest dimension
///calcul des longueurs des cotes au carre
Standard_Real L12 = P1.SquareDistance(P2); Standard_Real L12 = P1.SquareDistance(P2);
Standard_Real L23 = P2.SquareDistance(P3); Standard_Real L23 = P2.SquareDistance(P3);
Standard_Real L31 = P3.SquareDistance(P1); Standard_Real L31 = P3.SquareDistance(P1);
@ -636,7 +309,7 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
///***AFFINAGE DU TRIANGLE ADJACENT*** ///***AFFINAGE DU TRIANGLE ADJACENT***
Standard_Integer numTA = GetNextTriangle2(NumTri,1,TEdges); Standard_Integer numTA = GetNextTriangle(NumTri,1,TEdges);
if (numTA>=0) { if (numTA>=0) {
Standard_Integer numP3b = -1; Standard_Integer numP3b = -1;
@ -669,20 +342,20 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
NewEdge(FinTP,numP3b,T3,T4,TEdges); NewEdge(FinTP,numP3b,T3,T4,TEdges);
///On met a jour les anciens edges ///On met a jour les anciens edges
OldEdge(e2,NumTri,T1,TEdges); OldEdge(myEdges[1],NumTri,T1,TEdges);
OldEdge(e3,NumTri,T2,TEdges); OldEdge(myEdges[2],NumTri,T2,TEdges);
OldEdge(Edge2b,numTA,T3,TEdges); OldEdge(Edge2b,numTA,T3,TEdges);
OldEdge(Edge3b,numTA,T4,TEdges); OldEdge(Edge3b,numTA,T4,TEdges);
/// On remplit les nouveaux triangles avec les edges /// On remplit les nouveaux triangles avec les edges
TTriangles[T1].LinkEdges2Triangle(TEdges,e2,E3,E2); TTriangles[T1].LinkEdges2Triangle(TEdges,myEdges[1],E3,E2);
TTriangles[T2].LinkEdges2Triangle(TEdges,e3,E1,E3); TTriangles[T2].LinkEdges2Triangle(TEdges,myEdges[2],E1,E3);
TTriangles[T3].LinkEdges2Triangle(TEdges,Edge2b,E4,E2); TTriangles[T3].LinkEdges2Triangle(TEdges,Edge2b,E4,E2);
TTriangles[T4].LinkEdges2Triangle(TEdges,Edge3b,E1,E4); TTriangles[T4].LinkEdges2Triangle(TEdges,Edge3b,E1,E4);
///On tue le triangle adjacent ///On tue le triangle adjacent
TTriangles[numTA].Fleche=-1.0; TTriangles[numTA].SetDeflection(-1.0);
TTriangles[numTA].IP=0; TTriangles[numTA].SetIntersectionPossible(Standard_False);
} }
else { ///seulement deux nouveaux triangles else { ///seulement deux nouveaux triangles
@ -699,12 +372,12 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
NewEdge(FinTP,numP3,T1,T2,TEdges); NewEdge(FinTP,numP3,T1,T2,TEdges);
///On met a jour les anciens edges ///On met a jour les anciens edges
OldEdge(e2,NumTri,T1,TEdges); OldEdge(myEdges[1],NumTri,T1,TEdges);
OldEdge(e3,NumTri,T2,TEdges); OldEdge(myEdges[2],NumTri,T2,TEdges);
/// On remplit les nouveaux triangles avec les edges /// On remplit les nouveaux triangles avec les edges
TTriangles[T1].LinkEdges2Triangle(TEdges,e2,E3,E2); TTriangles[T1].LinkEdges2Triangle(TEdges,myEdges[1],E3,E2);
TTriangles[T2].LinkEdges2Triangle(TEdges,e3,E1,E3); TTriangles[T2].LinkEdges2Triangle(TEdges,myEdges[2],E1,E3);
} }
} }
@ -724,7 +397,7 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
///*RAFFINAGE DU TRIANGLE ADJACENT*** ///*RAFFINAGE DU TRIANGLE ADJACENT***
Standard_Integer numTA = GetNextTriangle2(NumTri,2,TEdges); Standard_Integer numTA = GetNextTriangle(NumTri,2,TEdges);
if (numTA>=0) { if (numTA>=0) {
Standard_Integer numP1b=-1; Standard_Integer numP1b=-1;
@ -757,20 +430,20 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
NewEdge(FinTP,numP1b,T3,T4,TEdges); NewEdge(FinTP,numP1b,T3,T4,TEdges);
///On met a jour les anciens edges ///On met a jour les anciens edges
OldEdge(e1,NumTri,T1,TEdges); OldEdge(myEdges[0],NumTri,T1,TEdges);
OldEdge(e3,NumTri,T2,TEdges); OldEdge(myEdges[2],NumTri,T2,TEdges);
OldEdge(Edge1b,numTA,T3,TEdges); OldEdge(Edge1b,numTA,T3,TEdges);
OldEdge(Edge3b,numTA,T4,TEdges); OldEdge(Edge3b,numTA,T4,TEdges);
/// On remplit les nouveaux triangles avec les edges /// On remplit les nouveaux triangles avec les edges
TTriangles[T1].LinkEdges2Triangle(TEdges,e1,E1,E3); TTriangles[T1].LinkEdges2Triangle(TEdges,myEdges[0],E1,E3);
TTriangles[T2].LinkEdges2Triangle(TEdges,e3,E3,E2); TTriangles[T2].LinkEdges2Triangle(TEdges,myEdges[2],E3,E2);
TTriangles[T3].LinkEdges2Triangle(TEdges,Edge1b,E4,E1); TTriangles[T3].LinkEdges2Triangle(TEdges,Edge1b,E4,E1);
TTriangles[T4].LinkEdges2Triangle(TEdges,Edge3b,E2,E4); TTriangles[T4].LinkEdges2Triangle(TEdges,Edge3b,E2,E4);
///On tue le triangle adjacent ///On tue le triangle adjacent
TTriangles[numTA].Fleche=-1.0; TTriangles[numTA].SetDeflection(-1.0);
TTriangles[numTA].IP=0; TTriangles[numTA].SetIntersectionPossible(Standard_False);
} }
else { ///seulement deux nouveaux triangles else { ///seulement deux nouveaux triangles
///Nouveaux Edges ///Nouveaux Edges
@ -786,12 +459,12 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
NewEdge(FinTP,numP1,T1,T2,TEdges); NewEdge(FinTP,numP1,T1,T2,TEdges);
///On met a jour les anciens edges ///On met a jour les anciens edges
OldEdge(e1,NumTri,T1,TEdges); OldEdge(myEdges[0],NumTri,T1,TEdges);
OldEdge(e3,NumTri,T2,TEdges); OldEdge(myEdges[2],NumTri,T2,TEdges);
/// On remplit les nouveaux triangles avec les edges /// On remplit les nouveaux triangles avec les edges
TTriangles[T1].LinkEdges2Triangle(TEdges,e1,E1,E3); TTriangles[T1].LinkEdges2Triangle(TEdges,myEdges[0],E1,E3);
TTriangles[T2].LinkEdges2Triangle(TEdges,e3,E3,E2); TTriangles[T2].LinkEdges2Triangle(TEdges,myEdges[2],E3,E2);
} }
} }
else { else {
@ -809,7 +482,7 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
///*RAFFINAGE DU TRIANGLE ADJACENT*** ///*RAFFINAGE DU TRIANGLE ADJACENT***
Standard_Integer numTA = GetNextTriangle2(NumTri,3,TEdges); Standard_Integer numTA = GetNextTriangle(NumTri,3,TEdges);
if (numTA>=0) { if (numTA>=0) {
@ -843,20 +516,20 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
NewEdge(FinTP,numP1,T1,T3,TEdges); NewEdge(FinTP,numP1,T1,T3,TEdges);
///On met a jour les anciens edges ///On met a jour les anciens edges
OldEdge(e1,NumTri,T1,TEdges); OldEdge(myEdges[0],NumTri,T1,TEdges);
OldEdge(e2,NumTri,T2,TEdges); OldEdge(myEdges[1],NumTri,T2,TEdges);
OldEdge(Edge1b,numTA,T3,TEdges); OldEdge(Edge1b,numTA,T3,TEdges);
OldEdge(Edge2b,numTA,T4,TEdges); OldEdge(Edge2b,numTA,T4,TEdges);
/// On remplit les nouveaux triangles avec les edges /// On remplit les nouveaux triangles avec les edges
TTriangles[T1].LinkEdges2Triangle(TEdges,e1,E1,E4); TTriangles[T1].LinkEdges2Triangle(TEdges,myEdges[0],E1,E4);
TTriangles[T2].LinkEdges2Triangle(TEdges,e2,E2,E1); TTriangles[T2].LinkEdges2Triangle(TEdges,myEdges[1],E2,E1);
TTriangles[T3].LinkEdges2Triangle(TEdges,Edge1b,E3,E4); TTriangles[T3].LinkEdges2Triangle(TEdges,Edge1b,E3,E4);
TTriangles[T4].LinkEdges2Triangle(TEdges,Edge2b,E2,E3); TTriangles[T4].LinkEdges2Triangle(TEdges,Edge2b,E2,E3);
///On tue le triangle adjacent ///On tue le triangle adjacent
TTriangles[numTA].Fleche=-1.0; TTriangles[numTA].SetDeflection(-1.0);
TTriangles[numTA].IP=0; TTriangles[numTA].SetIntersectionPossible(Standard_False);
} }
else { ///seulement deux nouveaux triangles else { ///seulement deux nouveaux triangles
///Nouveaux Edges ///Nouveaux Edges
@ -872,197 +545,113 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
NewEdge(FinTP,numP1,T1,-1,TEdges); NewEdge(FinTP,numP1,T1,-1,TEdges);
///On met a jour les anciens edges ///On met a jour les anciens edges
OldEdge(e1,NumTri,T1,TEdges); OldEdge(myEdges[0],NumTri,T1,TEdges);
OldEdge(e2,NumTri,T2,TEdges); OldEdge(myEdges[1],NumTri,T2,TEdges);
/// On remplit les nouveaux triangles avec les edges /// On remplit les nouveaux triangles avec les edges
TTriangles[T1].LinkEdges2Triangle(TEdges,e1,E1,E4); TTriangles[T1].LinkEdges2Triangle(TEdges,myEdges[0],E1,E4);
TTriangles[T2].LinkEdges2Triangle(TEdges,e2,E2,E1); TTriangles[T2].LinkEdges2Triangle(TEdges,myEdges[1],E2,E1);
} }
} }
/// Le triangle traite est maintenant obsolete
///***On tue le triangle***
Fleche=-1.0;
IP=0;
TPoints.IncrementNbItems(); TPoints.IncrementNbItems();
// make the triangle obsolete
myDeflection = -1.0;
myIsIntersectionPossible = Standard_False;
} }
//======================================================================= //=======================================================================
//function : MultipleMiddleRefinement //function : MultipleMiddleRefinement
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntPolyh_Triangle::MultipleMiddleRefinement(const Standard_Integer NbAffinages, void IntPolyh_Triangle::MultipleMiddleRefinement(const Standard_Real theRefineCriterion,
const Standard_Integer NumTri, const Bnd_Box& theBox,
const Handle(Adaptor3d_HSurface)& MySurface, const Standard_Integer theTriangleNumber,
IntPolyh_ArrayOfPoints &TPoints, const Handle(Adaptor3d_HSurface)& theSurface,
IntPolyh_ArrayOfTriangles &TTriangles, IntPolyh_ArrayOfPoints& TPoints,
IntPolyh_ArrayOfEdges & TEdges) { IntPolyh_ArrayOfTriangles& TTriangles,
IntPolyh_ArrayOfEdges& TEdges)
{
// Number of triangles before refinement of current triangle
const Standard_Integer FinTTInit = TTriangles.NbItems(); const Standard_Integer FinTTInit = TTriangles.NbItems();
// Split the current triangle
//On sait qu'il faut affiner au moins une fois MiddleRefinement(theTriangleNumber, theSurface, TPoints, TTriangles, TEdges);
TTriangles[NumTri].MiddleRefinement(NumTri,MySurface,TPoints, // Refine the new triangles
TTriangles,TEdges); for (Standard_Integer i = FinTTInit; i < TTriangles.NbItems(); ++i) {
IntPolyh_Triangle& aTriangle = TTriangles[i];
if (NbAffinages>1) { if(theBox.IsOut(aTriangle.BoundingBox(TPoints))) {
Standard_Integer MyNbAffinages=0; aTriangle.SetIntersectionPossible(Standard_False);
if (NbAffinages > 5) }
MyNbAffinages = 4;//5 est le maximum et on a deja affine une fois else if (aTriangle.Deflection() > theRefineCriterion) {
//On a decide d'arreter a 5 car avec un triangle on peut en obtenir 1024 aTriangle.MiddleRefinement(i, theSurface, TPoints, TTriangles, TEdges);
else MyNbAffinages = NbAffinages-1;//dans tous les cas MyNbAffinages>0
//Un affinage peut donner deux ou quatre nouveaux triangles
// ils seront ajoute a la fin du tableau de triangles, et auront comme indice
// FinTTInit, FinTTInit+1,...
Standard_Integer NombreReelsAffinages = 4;
for(Standard_Integer iii=1; iii<MyNbAffinages; iii++)
NombreReelsAffinages*=4;
//Avec ce calcul on fait l'hypothese que chaque triangle affine donne quatre nouveaux triangles
//ce qui peut etre faux si on n'affine pas le triangle adjacent
//dans quel cas on n'obtient que deux nouveaux triangles
Standard_Integer FinTTAffinage = FinTTInit + NombreReelsAffinages;
for(Standard_Integer NumTriangle=FinTTInit; NumTriangle < FinTTAffinage; NumTriangle++)
TTriangles[NumTriangle].MiddleRefinement(NumTriangle,MySurface,TPoints,
TTriangles,TEdges);
}
}
//=======================================================================
//function : CompareBoxTriangle
//purpose :
//=======================================================================
Standard_Integer IntPolyh_Triangle::CompareBoxTriangle(const Bnd_Box &b,
const IntPolyh_ArrayOfPoints &TPoints) const{
Standard_Integer Test=0;
Bnd_Box maboite;
const IntPolyh_Point& PA=TPoints[p1];
const IntPolyh_Point& PB=TPoints[p2];
const IntPolyh_Point& PC=TPoints[p3];
gp_Pnt pntA(PA.X(),PA.Y(),PA.Z());
gp_Pnt pntB(PB.X(),PB.Y(),PB.Z());
gp_Pnt pntC(PC.X(),PC.Y(),PC.Z());
maboite.Add(pntA);
maboite.Add(pntB);
maboite.Add(pntC);
maboite.Enlarge(Fleche+MyTolerance);
if (maboite.IsOut(b))
Test=0;
else
Test=1;
return(Test);
//Pour gagner du temps on pourrait envisager de garder la boite englobante dans la structure du triangle
}
//=======================================================================
//function : MultipleMiddleRefinement2
//purpose :
//=======================================================================
void IntPolyh_Triangle::MultipleMiddleRefinement2(const Standard_Real CritereAffinage,
const Bnd_Box &b,//boite englobante de l'autre surface
const Standard_Integer NumTri,
const Handle(Adaptor3d_HSurface)& MySurface,
IntPolyh_ArrayOfPoints &TPoints,
IntPolyh_ArrayOfTriangles &TTriangles,
IntPolyh_ArrayOfEdges & TEdges) {
const Standard_Integer FinTTInit = TTriangles.NbItems();
Standard_Integer CritereArret=FinTTInit+250;
//On sait qu'il faut affiner une fois au moins
MiddleRefinement(NumTri,MySurface,TPoints,
TTriangles,TEdges);
Standard_Integer FinTT = TTriangles.NbItems();// FinTT n'est pas une constante, elle augmente avec l'affinage
for(Standard_Integer iii=FinTTInit; iii<(FinTT=TTriangles.NbItems()); iii++) {
IntPolyh_Triangle& TriangleCourant = TTriangles[iii];
if(TriangleCourant.CompareBoxTriangle(b,TPoints)==0)
//On n'affine pas le triangle
TriangleCourant.IP=0;
else if (TriangleCourant.Fleche > CritereAffinage)
TriangleCourant.MiddleRefinement(iii,MySurface,TPoints,
TTriangles,TEdges);
if ( FinTT > CritereArret )//critere d'arret 250 nouveaux triangles
iii = FinTT;
}
}
//=======================================================================
//function : SetEdgeandOrientation
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetEdgeandOrientation(const Standard_Integer EdgeIndex,
const IntPolyh_ArrayOfEdges &TEdges) {
const Standard_Integer FinTE = TEdges.NbItems();
Standard_Integer PE1 =0,PE2 =0;
Standard_Integer Test=1;
if (EdgeIndex==1) { PE1=p1; PE2=p2; }
else if (EdgeIndex==2) { PE1=p2; PE2=p3; }
else if (EdgeIndex==3) { PE1=p3; PE2=p1; }
else {
Test=0;
}
if (Test!=0) {
for(Standard_Integer iioo=0; iioo<FinTE; iioo++) {
Standard_Integer EFP=TEdges[iioo].FirstPoint();
if (EFP==PE1) {
Standard_Integer ESP=TEdges[iioo].SecondPoint();
if (ESP!=EFP) {
if (ESP==PE2) {
SetEdgeOrientation(EdgeIndex,1);
SetEdge(EdgeIndex,iioo);
iioo=FinTE;
}
}
else {
Test=0;
}
}
else if (EFP==PE2) {
Standard_Integer ESP=TEdges[iioo].SecondPoint();
if (ESP!=EFP) {
if (ESP==PE1) {
SetEdgeOrientation(EdgeIndex,-1);
SetEdge(EdgeIndex,iioo);
iioo=FinTE;
}
}
else {
}
}
} }
} }
} }
//=======================================================================
//function : SetEdgeAndOrientation
//purpose :
//=======================================================================
void IntPolyh_Triangle::SetEdgeAndOrientation(const IntPolyh_Edge& theEdge,
const Standard_Integer theEdgeIndex)
{
// Points on the edge - pe1, pe2
Standard_Integer pe1 = theEdge.FirstPoint(), pe2 = theEdge.SecondPoint();
//
// We have points on the triangle - p1, p2 and p3;
// And points on the edge - pe1, pe2;
// By comparing these points we should define which
// edge it is for the triangle and its orientation on it:
// e1 = p1->p2;
// e2 = p2->p3;
// e3 = p3->p1;
// In case the order of points on the edge is forward,
// the orientation is positive, otherwise it is negative.
for (Standard_Integer i = 0, i1 = 1; i < 3; ++i, ++i1) {
if (i1 > 2) {
i1 = 0;
}
//
if (pe1 == myPoints[i] && pe2 == myPoints[i1]) {
myEdges[i] = theEdgeIndex;
myEdgesOrientations[i] = 1;
break;
}
if (pe1 == myPoints[i1] && pe2 == myPoints[i]) {
myEdges[i] = theEdgeIndex;
myEdgesOrientations[i] = -1;
break;
}
}
}
//=======================================================================
//function : BoundingBox
//purpose :
//=======================================================================
const Bnd_Box& IntPolyh_Triangle::BoundingBox(const IntPolyh_ArrayOfPoints& thePoints)
{
if (myBox.IsVoid()) {
const IntPolyh_Point& aP1 = thePoints[myPoints[0]];
const IntPolyh_Point& aP2 = thePoints[myPoints[1]];
const IntPolyh_Point& aP3 = thePoints[myPoints[2]];
myBox.Add(gp_Pnt(aP1.X(), aP1.Y(), aP1.Z()));
myBox.Add(gp_Pnt(aP2.X(), aP2.Y(), aP2.Z()));
myBox.Add(gp_Pnt(aP3.X(), aP3.Y(), aP3.Z()));
myBox.SetGap(myDeflection + Precision::Confusion());
}
return myBox;
}
//======================================================================= //=======================================================================
//function : Dump //function : Dump
//purpose : //purpose :
//======================================================================= //=======================================================================
void IntPolyh_Triangle::Dump (const Standard_Integer i) const void IntPolyh_Triangle::Dump (const Standard_Integer i) const
{ {
printf("\nTriangle(%3d) : Points %5d %5d %5d Edges %5d %5d %5d fleche: %8f intersection possible %8d intersection: %5d\n" printf("\nTriangle(%3d) : Points %5d %5d %5d Edges %5d %5d %5d deflection: %8f "
,i,p1,p2,p3,e1,e2,e3,Fleche,IP,II); "intersection possible %8d intersection: %5d\n",
i, myPoints[0], myPoints[1], myPoints[2],
myEdges[0], myEdges[1], myEdges[2],
myDeflection, (myIsIntersectionPossible ? 1 : 0), (myHasIntersection ? 1 : 0));
} }
//=======================================================================
//function : DumpFleche
//purpose :
//=======================================================================
void IntPolyh_Triangle::DumpFleche (const Standard_Integer i) const {
printf("\nTriangle(%3d) fleche: %5f\n",i,Fleche);
}

View File

@ -23,134 +23,264 @@
#include <Standard_Integer.hxx> #include <Standard_Integer.hxx>
#include <Standard_Real.hxx> #include <Standard_Real.hxx>
#include <Bnd_Box.hxx>
#include <IntPolyh_ArrayOfPoints.hxx> #include <IntPolyh_ArrayOfPoints.hxx>
#include <IntPolyh_ArrayOfTriangles.hxx> #include <IntPolyh_ArrayOfTriangles.hxx>
#include <IntPolyh_ArrayOfEdges.hxx> #include <IntPolyh_ArrayOfEdges.hxx>
#include <IntPolyh_ArrayOfCouples.hxx>
class Adaptor3d_HSurface; class Adaptor3d_HSurface;
class Bnd_Box;
class IntPolyh_StartPoint; class IntPolyh_StartPoint;
//! The class represents the triangle built from three IntPolyh points
//! and three IntPolyh edges.
class IntPolyh_Triangle class IntPolyh_Triangle
{ {
public: public:
DEFINE_STANDARD_ALLOC DEFINE_STANDARD_ALLOC
//! Constructor
Standard_EXPORT IntPolyh_Triangle(); IntPolyh_Triangle() :
myHasIntersection(Standard_False),
Standard_EXPORT IntPolyh_Triangle(const Standard_Integer i1, const Standard_Integer i2, const Standard_Integer i3); myIsIntersectionPossible(Standard_True),
myIsDegenerated(Standard_False),
Standard_EXPORT Standard_Integer FirstPoint() const; myDeflection(0.0)
{
Standard_EXPORT Standard_Integer SecondPoint() const; myPoints[0] = -1;
myPoints[1] = -1;
Standard_EXPORT Standard_Integer ThirdPoint() const; myPoints[2] = -1;
myEdges[0] = -1;
Standard_EXPORT Standard_Integer FirstEdge() const; myEdges[1] = -1;
myEdges[2] = -1;
Standard_EXPORT Standard_Integer FirstEdgeOrientation() const; myEdgesOrientations[0] = 0;
myEdgesOrientations[1] = 0;
Standard_EXPORT Standard_Integer SecondEdge() const; myEdgesOrientations[2] = 0;
}
Standard_EXPORT Standard_Integer SecondEdgeOrientation() const;
//! Constructor
Standard_EXPORT Standard_Integer ThirdEdge() const; IntPolyh_Triangle(const Standard_Integer thePoint1,
const Standard_Integer thePoint2,
Standard_EXPORT Standard_Integer ThirdEdgeOrientation() const; const Standard_Integer thePoint3)
:
Standard_EXPORT Standard_Real GetFleche() const; myHasIntersection(Standard_False),
myIsIntersectionPossible(Standard_True),
Standard_EXPORT Standard_Integer IndiceIntersectionPossible() const; myIsDegenerated(Standard_False),
myDeflection(0.0)
Standard_EXPORT Standard_Integer IndiceIntersection() const; {
myPoints[0] = thePoint1;
Standard_EXPORT void SetFirstPoint (const Standard_Integer v); myPoints[1] = thePoint2;
myPoints[2] = thePoint3;
Standard_EXPORT void SetSecondPoint (const Standard_Integer v); myEdges[0] = -1;
myEdges[1] = -1;
Standard_EXPORT void SetThirdPoint (const Standard_Integer v); myEdges[2] = -1;
myEdgesOrientations[0] = 0;
Standard_EXPORT void SetFirstEdge (const Standard_Integer v, const Standard_Integer s); myEdgesOrientations[1] = 0;
myEdgesOrientations[2] = 0;
Standard_EXPORT void SetSecondEdge (const Standard_Integer v, const Standard_Integer s); }
Standard_EXPORT void SetThirdEdge (const Standard_Integer v, const Standard_Integer s); //! Returns the first point
Standard_Integer FirstPoint() const
Standard_EXPORT void SetFleche (const Standard_Real v); {
return myPoints[0];
Standard_EXPORT void SetIndiceIntersectionPossible (const Standard_Integer v); }
//! Returns the second point
Standard_EXPORT void SetIndiceIntersection (const Standard_Integer v); Standard_Integer SecondPoint() const
{
Standard_EXPORT Standard_Integer GetEdgeNumber (const Standard_Integer v) const; return myPoints[1];
}
Standard_EXPORT void SetEdge (const Standard_Integer v, const Standard_Integer en); //! Returns the third point
Standard_Integer ThirdPoint() const
Standard_EXPORT Standard_Integer GetEdgeOrientation (const Standard_Integer v) const; {
return myPoints[2];
Standard_EXPORT void SetEdgeOrientation (const Standard_Integer v, const Standard_Integer oe); }
//! Returns the first edge
Standard_EXPORT void TriangleDeflection (const Handle(Adaptor3d_HSurface)& MaSurface, const IntPolyh_ArrayOfPoints& TP); Standard_Integer FirstEdge() const
{
Standard_EXPORT Standard_Integer CheckCommonEdge (const Standard_Integer PE1, const Standard_Integer PE2, const Standard_Integer P3, const Standard_Integer Index, const IntPolyh_ArrayOfTriangles& TTriangles) const; return myEdges[0];
}
Standard_EXPORT Standard_Integer GetNextTriangle2 (const Standard_Integer NumTri, const Standard_Integer NumEdge, const IntPolyh_ArrayOfEdges& TEdges) const; //! Returns the orientation of the first edge
Standard_Integer FirstEdgeOrientation() const
Standard_EXPORT void MiddleRefinement (const Standard_Integer TriangleNumber, const Handle(Adaptor3d_HSurface)& MySurface, IntPolyh_ArrayOfPoints& TPoints, IntPolyh_ArrayOfTriangles& TTriangles, IntPolyh_ArrayOfEdges& TEdges); {
return myEdgesOrientations[0];
Standard_EXPORT void MultipleMiddleRefinement (const Standard_Integer NombreAffinages, const Standard_Integer TriangleNumber, const Handle(Adaptor3d_HSurface)& MySurface, IntPolyh_ArrayOfPoints& TPoints, IntPolyh_ArrayOfTriangles& TTriangles, IntPolyh_ArrayOfEdges& TEdges); }
//! Returns the second edge
Standard_EXPORT Standard_Integer CompareBoxTriangle (const Bnd_Box& b, const IntPolyh_ArrayOfPoints& TPoints) const; Standard_Integer SecondEdge() const
{
Standard_EXPORT void MultipleMiddleRefinement2 (const Standard_Real RefineCriterion, const Bnd_Box& thebox, const Standard_Integer TriangleNumber, const Handle(Adaptor3d_HSurface)& MySurface, IntPolyh_ArrayOfPoints& TPoints, IntPolyh_ArrayOfTriangles& TTriangles, IntPolyh_ArrayOfEdges& TEdges); return myEdges[1];
}
Standard_EXPORT Standard_Integer GetNextChainTriangle (const IntPolyh_StartPoint& SPIni, const Standard_Integer LastTTC, IntPolyh_ArrayOfCouples& TriContactsArray, const IntPolyh_ArrayOfTriangles& TTriangles1, const IntPolyh_ArrayOfTriangles& TTriangles2, Standard_Integer& NumContact, Standard_Integer& NextTriangle) const; //! Returns the orientation of the second edge
Standard_Integer SecondEdgeOrientation() const
Standard_EXPORT void LinkEdges2Triangle (const IntPolyh_ArrayOfEdges& TEdges, const Standard_Integer ed1, const Standard_Integer ed2, const Standard_Integer ed3); {
return myEdgesOrientations[1];
Standard_EXPORT void SetEdgeandOrientation (const Standard_Integer Edge, const IntPolyh_ArrayOfEdges& TEdges); }
//! Returns the third edge
Standard_Integer ThirdEdge() const
{
return myEdges[2];
}
//! Returns the orientation of the third edge
Standard_Integer ThirdEdgeOrientation() const
{
return myEdgesOrientations[2];
}
//! Returns the deflection of the triangle
Standard_Real Deflection() const
{
return myDeflection;
}
//! Returns possibility of the intersection
Standard_Boolean IsIntersectionPossible() const
{
return myIsIntersectionPossible;
}
//! Returns true if the triangle has interfered the other triangle
Standard_Boolean HasIntersection() const
{
return myHasIntersection;
}
//! Returns the Degenerated flag
Standard_Boolean IsDegenerated() const
{
return myIsDegenerated;
}
//! Sets the first point
void SetFirstPoint(const Standard_Integer thePoint)
{
myPoints[0] = thePoint;
}
//! Sets the second point
void SetSecondPoint(const Standard_Integer thePoint)
{
myPoints[1] = thePoint;
}
//! Sets the third point
void SetThirdPoint(const Standard_Integer thePoint)
{
myPoints[2] = thePoint;
}
//! Sets the first edge
void SetFirstEdge(const Standard_Integer theEdge,
const Standard_Integer theEdgeOrientation)
{
myEdges[0] = theEdge;
myEdgesOrientations[0] = theEdgeOrientation;
}
//! Sets the second edge
void SetSecondEdge(const Standard_Integer theEdge,
const Standard_Integer theEdgeOrientation)
{
myEdges[1] = theEdge;
myEdgesOrientations[1] = theEdgeOrientation;
}
//! Sets the third edge
void SetThirdEdge(const Standard_Integer theEdge,
const Standard_Integer theEdgeOrientation)
{
myEdges[2] = theEdge;
myEdgesOrientations[2] = theEdgeOrientation;
}
//! Sets the deflection
void SetDeflection(const Standard_Real theDeflection)
{
myDeflection = theDeflection;
}
//! Sets the flag of possibility of intersection
void SetIntersectionPossible(const Standard_Boolean theIP)
{
myIsIntersectionPossible = theIP;
}
//! Sets the flag of intersection
void SetIntersection(const Standard_Boolean theInt)
{
myHasIntersection = theInt;
}
//! Sets the degenerated flag
void SetDegenerated(const Standard_Boolean theDegFlag)
{
myIsDegenerated = theDegFlag;
}
//! Gets the edge number by the index
Standard_Integer GetEdgeNumber(const Standard_Integer theEdgeIndex) const
{
return ((theEdgeIndex >= 1 && theEdgeIndex <= 3) ? myEdges[theEdgeIndex - 1] : 0);
}
//! Sets the edge by the index
void SetEdge(const Standard_Integer theEdgeIndex,
const Standard_Integer theEdgeNumber)
{
if (theEdgeIndex >= 1 && theEdgeIndex <= 3) {
myEdges[theEdgeIndex - 1] = theEdgeNumber;
}
}
//! Gets the edges orientation by the index
Standard_Integer GetEdgeOrientation(const Standard_Integer theEdgeIndex) const
{
return ((theEdgeIndex >= 1 && theEdgeIndex <= 3) ?
myEdgesOrientations[theEdgeIndex - 1] : 0);
}
//! Sets the edges orientation by the index
void SetEdgeOrientation(const Standard_Integer theEdgeIndex,
const Standard_Integer theEdgeOrientation)
{
if (theEdgeIndex >= 1 && theEdgeIndex <= 3) {
myEdgesOrientations[theEdgeIndex - 1] = theEdgeOrientation;
}
}
//! Computes the deflection for the triangle
Standard_EXPORT Standard_Real ComputeDeflection(const Handle(Adaptor3d_HSurface)& theSurface,
const IntPolyh_ArrayOfPoints& thePoints);
//! Gets the adjacent triangle
Standard_EXPORT Standard_Integer GetNextTriangle(const Standard_Integer theTriangle,
const Standard_Integer theEdgeNum,
const IntPolyh_ArrayOfEdges& TEdges) const;
//! Splits the triangle on two to decrease its deflection
Standard_EXPORT void MiddleRefinement(const Standard_Integer theTriangleNumber,
const Handle(Adaptor3d_HSurface)& theSurface,
IntPolyh_ArrayOfPoints& TPoints,
IntPolyh_ArrayOfTriangles& TTriangles,
IntPolyh_ArrayOfEdges& TEdges);
//! Splits the current triangle and new triangles until the refinement
//! criterion is not achieved
Standard_EXPORT void MultipleMiddleRefinement(const Standard_Real theRefineCriterion,
const Bnd_Box& theBox,
const Standard_Integer theTriangleNumber,
const Handle(Adaptor3d_HSurface)& theSurface,
IntPolyh_ArrayOfPoints& TPoints,
IntPolyh_ArrayOfTriangles& TTriangles,
IntPolyh_ArrayOfEdges& TEdges);
//! Links edges to triangle
Standard_EXPORT void LinkEdges2Triangle(const IntPolyh_ArrayOfEdges& TEdges,
const Standard_Integer theEdge1,
const Standard_Integer theEdge2,
const Standard_Integer theEdge3);
//! Sets the appropriate edge and orientation for the triangle.
Standard_EXPORT void SetEdgeAndOrientation(const IntPolyh_Edge& theEdge,
const Standard_Integer theEdgeIndex);
//! Returns the bounding box of the triangle.
Standard_EXPORT const Bnd_Box& BoundingBox(const IntPolyh_ArrayOfPoints& thePoints);
//! Dumps the contents of the triangle.
Standard_EXPORT void Dump (const Standard_Integer v) const; Standard_EXPORT void Dump (const Standard_Integer v) const;
Standard_EXPORT void DumpFleche (const Standard_Integer v) const;
protected: protected:
private: private:
Standard_Integer myPoints[3];
Standard_Integer myEdges[3];
Standard_Integer p1; Standard_Integer myEdgesOrientations[3];
Standard_Integer p2; Standard_Boolean myHasIntersection:1;
Standard_Integer p3; Standard_Boolean myIsIntersectionPossible:1;
Standard_Integer e1; Standard_Boolean myIsDegenerated:1;
Standard_Integer oe1; Standard_Real myDeflection;
Standard_Integer e2; Bnd_Box myBox;
Standard_Integer oe2;
Standard_Integer e3;
Standard_Integer oe3;
Standard_Integer II;
Standard_Integer IP;
Standard_Real Fleche;
}; };
#endif // _IntPolyh_Triangle_HeaderFile #endif // _IntPolyh_Triangle_HeaderFile