mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
OCC22322 Improvement of Extrema performance
This commit is contained in:
parent
ae07527556
commit
92d1589b7f
@ -1,8 +1,7 @@
|
||||
-- File: BRepExtrema.cdl
|
||||
-- Created: Fri Dec 3 15:48:19 1993
|
||||
-- Author: Christophe MARION
|
||||
-- <cma@sdsun1>
|
||||
---Copyright: Matra Datavision 1993
|
||||
-- File: BRepExtrema.cdl
|
||||
-- Created: Fri Dec 3 15:48:19 1993
|
||||
-- Author: Christophe MARION
|
||||
---Copyright: Matra Datavision 1993
|
||||
|
||||
package BRepExtrema
|
||||
|
||||
@ -27,37 +26,37 @@ is
|
||||
----------------------------------------------------------
|
||||
-- Extrema between two Shapes with triangulation.
|
||||
----------------------------------------------------------
|
||||
class Poly;
|
||||
imported Poly;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- Extrema between a Point and an Edge.
|
||||
----------------------------------------------------------
|
||||
class ExtPC;
|
||||
imported ExtPC;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- Extrema between two Edges.
|
||||
----------------------------------------------------------
|
||||
class ExtCC;
|
||||
imported ExtCC;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- Extrema between a Point and a Face.
|
||||
----------------------------------------------------------
|
||||
class ExtPF;
|
||||
imported ExtPF;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- Extrema between an Edge and a Face.
|
||||
----------------------------------------------------------
|
||||
class ExtCF;
|
||||
imported ExtCF;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- Extrema between two Faces.
|
||||
----------------------------------------------------------
|
||||
class ExtFF;
|
||||
imported ExtFF;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
@ -73,8 +72,7 @@ is
|
||||
-- IsInFace => The solution is inside a Face.
|
||||
|
||||
----------------------------------------------------------
|
||||
enumeration SupportType is IsVertex, IsOnEdge, IsInFace end SupportType;
|
||||
|
||||
imported SupportType;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
@ -82,39 +80,21 @@ is
|
||||
-- between two shapes and the corresponding couples of solution points.
|
||||
|
||||
----------------------------------------------------------
|
||||
class DistShapeShape;
|
||||
|
||||
|
||||
imported DistShapeShape;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- This class is used to store a solution on a Shape.
|
||||
-- (used only by class DistShapeShape)
|
||||
----------------------------------------------------------
|
||||
class SolutionElem;
|
||||
|
||||
imported SolutionElem;
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- This sequence is used to store all the solution on each Shape.
|
||||
----------------------------------------------------------
|
||||
class SeqOfSolution instantiates Sequence from TCollection
|
||||
( SolutionElem from BRepExtrema);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------
|
||||
-- This class is used to compute minimum distance between two elementary
|
||||
-- Shapes ( Vertex, Edge, Face ) (used only by class DistShapeShape)
|
||||
----------------------------------------------------------
|
||||
private class DistanceSS from BRepExtrema;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
imported SeqOfSolution;
|
||||
|
||||
imported DistanceSS;
|
||||
|
||||
end BRepExtrema;
|
||||
|
@ -1,18 +1,16 @@
|
||||
// File: BRepExtrema_DistShapeShape.cxx
|
||||
// Created: Mon Apr 22 17:03:37 1996
|
||||
// Modified : Mps(10-04-97) portage WNT
|
||||
// Author: Maria PUMBORIOS
|
||||
// Author: Herve LOUESSARD
|
||||
// <mps@sgi64>
|
||||
// File: BRepExtrema_DistShapeShape.cxx
|
||||
// Created: Mon Apr 22 17:03:37 1996
|
||||
// Modified: Mps(10-04-97) portage WNT
|
||||
// Author: Maria PUMBORIOS
|
||||
// Author: Herve LOUESSARD
|
||||
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
|
||||
#include <BRepExtrema_DistShapeShape.ixx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <TCollection.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <BRepExtrema_DistanceSS.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopAbs.hxx>
|
||||
@ -21,44 +19,40 @@
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <BRepExtrema_SeqOfSolution.hxx>
|
||||
#include <BRepExtrema_SolutionElem.hxx>
|
||||
#include <Bnd_SeqOfBox.hxx>
|
||||
#include <BRepExtrema_UnCompatibleShape.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepClass3d_SolidClassifier.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
|
||||
static void Decomposition(const TopoDS_Shape& S,
|
||||
TopTools_IndexedMapOfShape& MapV,
|
||||
TopTools_IndexedMapOfShape& MapE,
|
||||
TopTools_IndexedMapOfShape& MapF)
|
||||
{
|
||||
MapV.Clear();
|
||||
MapE.Clear();
|
||||
MapF.Clear();
|
||||
TopExp::MapShapes(S,TopAbs_VERTEX,MapV);
|
||||
TopExp::MapShapes(S,TopAbs_EDGE,MapE);
|
||||
TopExp::MapShapes(S,TopAbs_FACE,MapF);
|
||||
MapV.Clear();
|
||||
MapE.Clear();
|
||||
MapF.Clear();
|
||||
TopExp::MapShapes(S,TopAbs_VERTEX,MapV);
|
||||
TopExp::MapShapes(S,TopAbs_EDGE,MapE);
|
||||
TopExp::MapShapes(S,TopAbs_FACE,MapF);
|
||||
}
|
||||
|
||||
static void BoxCalculation(const TopTools_IndexedMapOfShape& Map,
|
||||
Bnd_SeqOfBox& SBox)
|
||||
{
|
||||
Standard_Integer i = 0;
|
||||
for(i = 1; i <= Map.Extent(); i++) {
|
||||
Bnd_Box box;
|
||||
BRepBndLib::Add( Map(i), box);
|
||||
SBox.Append(box);
|
||||
}
|
||||
for (Standard_Integer i = 1; i <= Map.Extent(); i++)
|
||||
{
|
||||
Bnd_Box box;
|
||||
BRepBndLib::Add(Map(i), box);
|
||||
SBox.Append(box);
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Real DistanceInitiale(const TopoDS_Vertex V1,
|
||||
inline Standard_Real DistanceInitiale(const TopoDS_Vertex V1,
|
||||
const TopoDS_Vertex V2)
|
||||
{
|
||||
gp_Pnt P1,P2;
|
||||
P1= BRep_Tool::Pnt(V1);
|
||||
P2= BRep_Tool::Pnt(V2);
|
||||
return(P1.Distance(P2));
|
||||
return (BRep_Tool::Pnt(V1).Distance(BRep_Tool::Pnt(V2)));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -71,39 +65,40 @@ void BRepExtrema_DistShapeShape::DistanceMapMap(const TopTools_IndexedMapOfShape
|
||||
const Bnd_SeqOfBox& LBox1,
|
||||
const Bnd_SeqOfBox& LBox2)
|
||||
{
|
||||
Standard_Integer i = 0, j = 0;
|
||||
Bnd_Box box1, box2;
|
||||
TopoDS_Shape S1, S2;
|
||||
BRepExtrema_SeqOfSolution seq1, seq2;
|
||||
Standard_Integer i, j;
|
||||
BRepExtrema_SeqOfSolution seq1, seq2;
|
||||
|
||||
const Standard_Integer n1 = Map1.Extent();
|
||||
const Standard_Integer n2 = Map2.Extent();
|
||||
for (i = 1; i <= n1; i++)
|
||||
{
|
||||
const Bnd_Box &box1 = LBox1.Value(i);
|
||||
const TopoDS_Shape &S1 = Map1(i);
|
||||
for (j = 1; j <= n2; j++)
|
||||
{
|
||||
const Bnd_Box &box2= LBox2.Value(j);
|
||||
const TopoDS_Shape &S2 = Map2(j);
|
||||
|
||||
Standard_Integer n1 = Map1.Extent();
|
||||
Standard_Integer n2 = Map2.Extent();
|
||||
for(i = 1; i <= n1; i++) {
|
||||
box1= LBox1.Value(i);
|
||||
S1= TopoDS_Shape (Map1(i));
|
||||
for(j = 1; j <= n2; j++) {
|
||||
box2= LBox2.Value(j);
|
||||
S2 = TopoDS_Shape (Map2(j));
|
||||
BRepExtrema_DistanceSS dist(S1,S2,box1,box2,myDistRef,myEps);
|
||||
if(dist.IsDone())
|
||||
if(dist.DistValue() < (myDistRef-myEps)) {
|
||||
ListeDeSolutionShape1.Clear();
|
||||
ListeDeSolutionShape2.Clear();
|
||||
if (dist.IsDone())
|
||||
if(dist.DistValue() < (myDistRef-myEps))
|
||||
{
|
||||
mySolutionsShape1.Clear();
|
||||
mySolutionsShape2.Clear();
|
||||
seq1= dist.Seq1Value();
|
||||
seq2= dist.Seq2Value();
|
||||
ListeDeSolutionShape1.Append(seq1);
|
||||
ListeDeSolutionShape2.Append(seq2);
|
||||
mySolutionsShape1.Append(seq1);
|
||||
mySolutionsShape2.Append(seq2);
|
||||
myDistRef=dist.DistValue();
|
||||
}
|
||||
else if(fabs (dist.DistValue()-myDistRef)< myEps ) {
|
||||
else if(fabs(dist.DistValue()-myDistRef) < myEps)
|
||||
{
|
||||
seq1= dist.Seq1Value();
|
||||
seq2= dist.Seq2Value();
|
||||
ListeDeSolutionShape1.Append(seq1);
|
||||
ListeDeSolutionShape2.Append(seq2);
|
||||
// Modified by Sergey KHROMOV - Tue Mar 6 12:15:39 2001 Begin
|
||||
mySolutionsShape1.Append(seq1);
|
||||
mySolutionsShape2.Append(seq2);
|
||||
if (myDistRef > dist.DistValue())
|
||||
myDistRef=dist.DistValue();
|
||||
// Modified by Sergey KHROMOV - Tue Mar 6 12:15:37 2001 End
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -115,8 +110,14 @@ void BRepExtrema_DistShapeShape::DistanceMapMap(const TopTools_IndexedMapOfShape
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape()
|
||||
: myDistRef(0.),
|
||||
myDistValue(0.),
|
||||
myIsDone(Standard_False),
|
||||
myInnerSol(Standard_False),
|
||||
myEps(Precision::Confusion()),
|
||||
myFlag(Extrema_ExtFlag_MINMAX),
|
||||
myAlgo(Extrema_ExtAlgo_Grad)
|
||||
{
|
||||
myEps = Precision::Confusion();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -124,9 +125,17 @@ BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape()
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
|
||||
const TopoDS_Shape& Shape2)
|
||||
const TopoDS_Shape& Shape2,
|
||||
const Extrema_ExtFlag F,
|
||||
const Extrema_ExtAlgo A)
|
||||
: myDistRef(0.),
|
||||
myDistValue(0.),
|
||||
myIsDone(Standard_False),
|
||||
myInnerSol(Standard_False),
|
||||
myEps(Precision::Confusion()),
|
||||
myFlag(F),
|
||||
myAlgo(A)
|
||||
{
|
||||
myEps = Precision::Confusion();
|
||||
LoadS1(Shape1);
|
||||
LoadS2(Shape2);
|
||||
Perform();
|
||||
@ -138,25 +147,23 @@ BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
|
||||
const TopoDS_Shape& Shape2,
|
||||
const Standard_Real theDeflection)
|
||||
const TopoDS_Shape& Shape2,
|
||||
const Standard_Real theDeflection,
|
||||
const Extrema_ExtFlag F,
|
||||
const Extrema_ExtAlgo A)
|
||||
: myDistRef(0.),
|
||||
myDistValue(0.),
|
||||
myIsDone(Standard_False),
|
||||
myInnerSol(Standard_False),
|
||||
myEps(theDeflection),
|
||||
myFlag(F),
|
||||
myAlgo(A)
|
||||
{
|
||||
myEps = theDeflection;
|
||||
LoadS1(Shape1);
|
||||
LoadS2(Shape2);
|
||||
Perform();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDeflection
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_DistShapeShape::SetDeflection(const Standard_Real theDeflection)
|
||||
{
|
||||
myEps = theDeflection;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadS1
|
||||
//purpose :
|
||||
@ -188,143 +195,110 @@ Standard_Boolean BRepExtrema_DistShapeShape::Perform()
|
||||
{
|
||||
myIsDone=Standard_False;
|
||||
myInnerSol=Standard_False;
|
||||
ListeDeSolutionShape1.Clear();
|
||||
ListeDeSolutionShape2.Clear();
|
||||
|
||||
if( myShape1.IsNull() || myShape2.IsNull() )
|
||||
mySolutionsShape1.Clear();
|
||||
mySolutionsShape2.Clear();
|
||||
|
||||
if ( myShape1.IsNull() || myShape2.IsNull() )
|
||||
return Standard_False;
|
||||
|
||||
TopoDS_Vertex V;
|
||||
Bnd_SeqOfBox BV1, BV2, BE1, BE2, BF1, BF2;
|
||||
Standard_Real tol = 0.001;
|
||||
gp_Pnt P;
|
||||
Standard_Integer nbv1,nbv2;
|
||||
const Standard_Real tol = 0.001;
|
||||
|
||||
// traitement des solides
|
||||
TopAbs_ShapeEnum Type1 = myShape1.ShapeType();
|
||||
TopAbs_ShapeEnum Type2 = myShape2.ShapeType();
|
||||
if((Type1==TopAbs_SOLID) || (Type1 == TopAbs_COMPSOLID)) {
|
||||
// Treatment of solids
|
||||
const TopAbs_ShapeEnum Type1 = myShape1.ShapeType();
|
||||
if ((Type1==TopAbs_SOLID) || (Type1 == TopAbs_COMPSOLID))
|
||||
{
|
||||
BRepClass3d_SolidClassifier Classi(myShape1);
|
||||
nbv2=myMapV2.Extent();
|
||||
nbv1=0;
|
||||
while ( (nbv1<nbv2) && (! myInnerSol))
|
||||
const Standard_Integer nbv2 = myMapV2.Extent();
|
||||
Standard_Integer nbv1 = 0;
|
||||
do
|
||||
{
|
||||
nbv1++;
|
||||
TopoDS_Vertex V2 = TopoDS::Vertex(myMapV2(nbv1));
|
||||
P=BRep_Tool::Pnt(V2);
|
||||
V = TopoDS::Vertex(myMapV2(nbv1));
|
||||
const gp_Pnt &P = BRep_Tool::Pnt(V);
|
||||
Classi.Perform(P,tol);
|
||||
if(Classi.State()==TopAbs_IN) {
|
||||
if (Classi.State()==TopAbs_IN)
|
||||
{
|
||||
myInnerSol = Standard_True;
|
||||
myNbSolution = 1;
|
||||
myDistRef = 0;
|
||||
myDistRef = 0.;
|
||||
myIsDone = Standard_True;
|
||||
BRepExtrema_SolutionElem Sol(0,P,BRepExtrema_IsVertex,V2);
|
||||
ListeDeSolutionShape1.Append(Sol);
|
||||
ListeDeSolutionShape2.Append(Sol);
|
||||
BRepExtrema_SolutionElem Sol(0,P,BRepExtrema_IsVertex,V);
|
||||
mySolutionsShape1.Append(Sol);
|
||||
mySolutionsShape2.Append(Sol);
|
||||
}
|
||||
}
|
||||
while ( (nbv1<nbv2) && (!myInnerSol) );
|
||||
}
|
||||
|
||||
if(((Type2==TopAbs_SOLID)||(Type2==TopAbs_COMPSOLID))&&(!myInnerSol)) {
|
||||
const TopAbs_ShapeEnum Type2 = myShape2.ShapeType();
|
||||
if (((Type2==TopAbs_SOLID) || (Type2==TopAbs_COMPSOLID)) && (!myInnerSol))
|
||||
{
|
||||
BRepClass3d_SolidClassifier Classi(myShape2);
|
||||
nbv1= myMapV1.Extent();
|
||||
nbv2=0;
|
||||
while ((nbv2<nbv1) && (! myInnerSol))
|
||||
const Standard_Integer nbv1 = myMapV1.Extent();
|
||||
Standard_Integer nbv2 = 0;
|
||||
do
|
||||
{
|
||||
nbv2++;
|
||||
TopoDS_Vertex V1=TopoDS::Vertex(myMapV1(nbv2));
|
||||
P=BRep_Tool::Pnt(V1);
|
||||
V = TopoDS::Vertex(myMapV1(nbv2));
|
||||
const gp_Pnt &P = BRep_Tool::Pnt(V);
|
||||
Classi.Perform(P,tol);
|
||||
if (Classi.State()==TopAbs_IN) {
|
||||
myInnerSol = Standard_True;
|
||||
myNbSolution = 1;
|
||||
myDistRef = 0;
|
||||
myIsDone = Standard_True;
|
||||
BRepExtrema_SolutionElem Sol (0,P,BRepExtrema_IsVertex,V1);
|
||||
ListeDeSolutionShape1.Append(Sol);
|
||||
ListeDeSolutionShape2.Append(Sol);
|
||||
BRepExtrema_SolutionElem Sol (0,P,BRepExtrema_IsVertex,V);
|
||||
mySolutionsShape1.Append(Sol);
|
||||
mySolutionsShape2.Append(Sol);
|
||||
}
|
||||
}
|
||||
while ( (nbv2<nbv1) && (!myInnerSol) );
|
||||
}
|
||||
|
||||
if (!myInnerSol) {
|
||||
BoxCalculation( myMapV1,BV1);
|
||||
BoxCalculation( myMapE1,BE1);
|
||||
BoxCalculation( myMapF1,BF1);
|
||||
BoxCalculation( myMapV2,BV2);
|
||||
BoxCalculation( myMapE2,BE2);
|
||||
BoxCalculation( myMapF2,BF2);
|
||||
if (!myInnerSol)
|
||||
{
|
||||
BoxCalculation(myMapV1,BV1);
|
||||
BoxCalculation(myMapE1,BE1);
|
||||
BoxCalculation(myMapF1,BF1);
|
||||
BoxCalculation(myMapV2,BV2);
|
||||
BoxCalculation(myMapE2,BE2);
|
||||
BoxCalculation(myMapF2,BF2);
|
||||
|
||||
if (myMapV1.Extent()!=0 && myMapV2.Extent()!=0) {
|
||||
if (myMapV1.Extent() && myMapV2.Extent())
|
||||
{
|
||||
TopoDS_Vertex V1 = TopoDS::Vertex(myMapV1(1));
|
||||
TopoDS_Vertex V2 = TopoDS::Vertex(myMapV2(1));
|
||||
myDistRef = DistanceInitiale(V1, V2);
|
||||
myDistRef = DistanceInitiale(V1, V2);
|
||||
}
|
||||
else
|
||||
myDistRef= 1.e30;
|
||||
|
||||
DistanceMapMap( myMapV1, myMapV2, BV1, BV2);
|
||||
DistanceMapMap( myMapV1, myMapE2, BV1, BE2);
|
||||
DistanceMapMap( myMapE1, myMapV2, BE1, BV2);
|
||||
DistanceMapMap( myMapV1, myMapF2, BV1, BF2);
|
||||
DistanceMapMap( myMapF1, myMapV2, BF1, BV2);
|
||||
DistanceMapMap( myMapE1, myMapE2, BE1, BE2);
|
||||
DistanceMapMap( myMapE1, myMapF2, BE1, BF2);
|
||||
DistanceMapMap( myMapF1, myMapE2, BF1, BE2);
|
||||
|
||||
myDistRef= 1.e30; //szv:!!!
|
||||
|
||||
DistanceMapMap(myMapV1, myMapV2, BV1, BV2);
|
||||
DistanceMapMap(myMapV1, myMapE2, BV1, BE2);
|
||||
DistanceMapMap(myMapE1, myMapV2, BE1, BV2);
|
||||
DistanceMapMap(myMapV1, myMapF2, BV1, BF2);
|
||||
DistanceMapMap(myMapF1, myMapV2, BF1, BV2);
|
||||
DistanceMapMap(myMapE1, myMapE2, BE1, BE2);
|
||||
DistanceMapMap(myMapE1, myMapF2, BE1, BF2);
|
||||
DistanceMapMap(myMapF1, myMapE2, BF1, BE2);
|
||||
|
||||
if( (fabs(myDistRef)) > myEps )
|
||||
DistanceMapMap(myMapF1,myMapF2,BF1,BF2);
|
||||
|
||||
// Modified by Sergey KHROMOV - Tue Mar 6 11:55:03 2001 Begin
|
||||
Standard_Integer i = 0;
|
||||
for(i = 1; i <= ListeDeSolutionShape1.Length(); i++)
|
||||
if (ListeDeSolutionShape1.Value(i).Dist() > myDistRef + myEps) {
|
||||
ListeDeSolutionShape1.Remove(i);
|
||||
ListeDeSolutionShape2.Remove(i);
|
||||
Standard_Integer i = 1;
|
||||
for (; i <= mySolutionsShape1.Length(); i++)
|
||||
if (mySolutionsShape1.Value(i).Dist() > myDistRef + myEps)
|
||||
{
|
||||
mySolutionsShape1.Remove(i);
|
||||
mySolutionsShape2.Remove(i);
|
||||
}
|
||||
// Modified by Sergey KHROMOV - Tue Mar 6 11:55:04 2001 End
|
||||
myNbSolution = ListeDeSolutionShape1.Length();
|
||||
if( myNbSolution > 0 )
|
||||
myIsDone = Standard_True;
|
||||
else
|
||||
myIsDone = Standard_False;
|
||||
myIsDone = ( mySolutionsShape1.Length() > 0 );
|
||||
}
|
||||
return myIsDone;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_DistShapeShape:: InnerSolution () const
|
||||
{
|
||||
return (myInnerSol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_DistShapeShape::IsDone() const
|
||||
{
|
||||
return (myIsDone);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbSolution
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepExtrema_DistShapeShape::NbSolution() const
|
||||
{
|
||||
if (myIsDone == Standard_False) {
|
||||
StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::NbSolution: There's no solution ");
|
||||
}
|
||||
return (myNbSolution);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
@ -332,83 +306,10 @@ Standard_Integer BRepExtrema_DistShapeShape::NbSolution() const
|
||||
|
||||
Standard_Real BRepExtrema_DistShapeShape::Value() const
|
||||
{
|
||||
if (myIsDone == Standard_False) {
|
||||
StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::Value: There's no solution ");
|
||||
}
|
||||
return (myDistRef);
|
||||
}
|
||||
if (!myIsDone)
|
||||
StdFail_NotDone::Raise("BRepExtrema_DistShapeShape::Value: There's no solution ");
|
||||
|
||||
//=======================================================================
|
||||
//function : PointOnShape1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_DistShapeShape::PointOnShape1(const Standard_Integer N) const
|
||||
{
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::PointOnShape1: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::PointOnShape1: Nth solution doesn't exist ");
|
||||
}
|
||||
return ((ListeDeSolutionShape1.Value(N)).Point());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PointOnShape2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_DistShapeShape::PointOnShape2(const Standard_Integer N) const
|
||||
{
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::PointOnShape2: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::PointOnShape2: Nth solution doesn't exist ");
|
||||
}
|
||||
return ((ListeDeSolutionShape2.Value(N)).Point());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SupportTypeShape1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_SupportType BRepExtrema_DistShapeShape::SupportTypeShape1(const Standard_Integer N) const
|
||||
{
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportTypeShape1: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportTypeShape1: Nth solution doesn't exist ");
|
||||
}
|
||||
return ((ListeDeSolutionShape1.Value(N)).SupportKind());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SupportTypeShape2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_SupportType BRepExtrema_DistShapeShape::SupportTypeShape2(const Standard_Integer N) const
|
||||
{
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportTypeShape2: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportTypeShape2: Nth solution doesn't exist ");
|
||||
}
|
||||
return ((ListeDeSolutionShape2.Value(N)).SupportKind());
|
||||
return myDistRef;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -416,30 +317,19 @@ BRepExtrema_SupportType BRepExtrema_DistShapeShape::SupportTypeShape2(const Stan
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape1(const Standard_Integer N) const
|
||||
TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape1(const Standard_Integer N) const
|
||||
{
|
||||
BRepExtrema_SupportType Type;
|
||||
TopoDS_Shape a_shape;
|
||||
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportOnShape1: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportOnShape1: Nth solution doesn't exist ");
|
||||
}
|
||||
Type = ((ListeDeSolutionShape1.Value(N)).SupportKind());
|
||||
switch ( Type)
|
||||
{ case BRepExtrema_IsVertex : a_shape=ListeDeSolutionShape1.Value(N).Vertex();
|
||||
break;
|
||||
case BRepExtrema_IsOnEdge : a_shape=ListeDeSolutionShape1.Value(N).Edge();
|
||||
break;
|
||||
case BRepExtrema_IsInFace : a_shape=ListeDeSolutionShape1.Value(N).Face();
|
||||
break;
|
||||
default :{}
|
||||
}
|
||||
return a_shape ;
|
||||
if (!myIsDone)
|
||||
StdFail_NotDone::Raise("BRepExtrema_DistShapeShape::SupportOnShape1: There's no solution ");
|
||||
|
||||
const BRepExtrema_SolutionElem &sol = mySolutionsShape1.Value(N);
|
||||
switch (sol.SupportKind())
|
||||
{
|
||||
case BRepExtrema_IsVertex : return sol.Vertex();
|
||||
case BRepExtrema_IsOnEdge : return sol.Edge();
|
||||
case BRepExtrema_IsInFace : return sol.Face();
|
||||
}
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -449,28 +339,17 @@ TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape1(const Standard_Integer
|
||||
|
||||
TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape2(const Standard_Integer N) const
|
||||
{
|
||||
BRepExtrema_SupportType Type;
|
||||
TopoDS_Shape a_shape ;
|
||||
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportOnShape2: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::SupportOnShape2: Nth solution doesn't exist ");
|
||||
}
|
||||
Type = ((ListeDeSolutionShape2.Value(N)).SupportKind());
|
||||
switch ( Type)
|
||||
{ case BRepExtrema_IsVertex : a_shape=ListeDeSolutionShape2.Value(N).Vertex();
|
||||
break;
|
||||
case BRepExtrema_IsOnEdge : a_shape=ListeDeSolutionShape2.Value(N).Edge();
|
||||
break;
|
||||
case BRepExtrema_IsInFace : a_shape=ListeDeSolutionShape2.Value(N).Face();
|
||||
break;
|
||||
default :{}
|
||||
}
|
||||
return a_shape ;
|
||||
if (!myIsDone)
|
||||
StdFail_NotDone::Raise("BRepExtrema_DistShapeShape::SupportOnShape2: There's no solution ");
|
||||
|
||||
const BRepExtrema_SolutionElem &sol = mySolutionsShape2.Value(N);
|
||||
switch (sol.SupportKind())
|
||||
{
|
||||
case BRepExtrema_IsVertex : return sol.Vertex();
|
||||
case BRepExtrema_IsOnEdge : return sol.Edge();
|
||||
case BRepExtrema_IsInFace : return sol.Face();
|
||||
}
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -480,24 +359,15 @@ TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape2(const Standard_Integer
|
||||
|
||||
void BRepExtrema_DistShapeShape::ParOnEdgeS1(const Standard_Integer N, Standard_Real& t) const
|
||||
{
|
||||
BRepExtrema_SupportType Type;
|
||||
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS1: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS1: Nth solution doesn't exist ");
|
||||
}
|
||||
if (!myIsDone)
|
||||
StdFail_NotDone::Raise("BRepExtrema_DistShapeShape::ParOnEdgeS1: There's no solution");
|
||||
|
||||
Type = ((ListeDeSolutionShape1.Value(N)).SupportKind());
|
||||
if (Type != BRepExtrema_IsOnEdge)
|
||||
{ BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS1:ParOnEdgeS1 is impossible without EDGE ");
|
||||
}
|
||||
const BRepExtrema_SolutionElem &sol = mySolutionsShape1.Value(N);
|
||||
if (sol.SupportKind() != BRepExtrema_IsOnEdge)
|
||||
BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS1: ParOnEdgeS1 is impossible without EDGE");
|
||||
|
||||
(ListeDeSolutionShape1.Value(N)).EdgeParameter(t);
|
||||
sol.EdgeParameter(t);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -507,24 +377,15 @@ void BRepExtrema_DistShapeShape::ParOnEdgeS1(const Standard_Integer N, Standard_
|
||||
|
||||
void BRepExtrema_DistShapeShape::ParOnEdgeS2(const Standard_Integer N, Standard_Real& t) const
|
||||
{
|
||||
BRepExtrema_SupportType Type;
|
||||
if (!myIsDone)
|
||||
StdFail_NotDone::Raise("BRepExtrema_DistShapeShape::ParOnEdgeS2: There's no solution");
|
||||
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS2: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS2: Nth solution doesn't exist ");
|
||||
}
|
||||
|
||||
Type = ((ListeDeSolutionShape2.Value(N)).SupportKind());
|
||||
if (Type != BRepExtrema_IsOnEdge)
|
||||
{ BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS2:ParOnEdgeS2 is impossible without EDGE ");
|
||||
}
|
||||
const BRepExtrema_SolutionElem &sol = mySolutionsShape2.Value(N);
|
||||
if (sol.SupportKind() != BRepExtrema_IsOnEdge)
|
||||
BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnEdgeS2: ParOnEdgeS2 is impossible without EDGE");
|
||||
|
||||
(ListeDeSolutionShape2.Value(N)).EdgeParameter(t);
|
||||
sol.EdgeParameter(t);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -534,46 +395,33 @@ void BRepExtrema_DistShapeShape::ParOnEdgeS2(const Standard_Integer N, Standard
|
||||
|
||||
void BRepExtrema_DistShapeShape::ParOnFaceS1(const Standard_Integer N, Standard_Real& u, Standard_Real& v) const
|
||||
{
|
||||
BRepExtrema_SupportType Type;
|
||||
if (!myIsDone)
|
||||
StdFail_NotDone::Raise("BRepExtrema_DistShapeShape::ParOnFaceS1: There's no solution");
|
||||
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS1: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS1: Nth solution doesn't exist ");
|
||||
}
|
||||
|
||||
Type = ((ListeDeSolutionShape1.Value(N)).SupportKind());
|
||||
if (Type != BRepExtrema_IsInFace)
|
||||
{ BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS1:ParOnFaceS1 is impossible without FACE ");
|
||||
}
|
||||
const BRepExtrema_SolutionElem &sol = mySolutionsShape1.Value(N);
|
||||
if (sol.SupportKind() != BRepExtrema_IsInFace)
|
||||
BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS1: ParOnFaceS1 is impossible without FACE");
|
||||
|
||||
(ListeDeSolutionShape1.Value(N)).FaceParameter(u, v);
|
||||
sol.FaceParameter(u, v);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ParOnFaceS2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_DistShapeShape::ParOnFaceS2(const Standard_Integer N, Standard_Real& u, Standard_Real& v) const
|
||||
{
|
||||
BRepExtrema_SupportType Type;
|
||||
if (!myIsDone)
|
||||
StdFail_NotDone::Raise("BRepExtrema_DistShapeShape::ParOnFaceS2: There's no solution");
|
||||
|
||||
if (myIsDone == Standard_False)
|
||||
{ StdFail_NotDone::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS2: There's no solution ");
|
||||
}
|
||||
if ((N<1)||(N>myNbSolution))
|
||||
{ Standard_OutOfRange::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS2: Nth solution doesn't exist ");
|
||||
}
|
||||
Type = ((ListeDeSolutionShape2.Value(N)).SupportKind());
|
||||
if (Type != BRepExtrema_IsInFace)
|
||||
{ BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS2:ParOnFaceS2 is impossible without FACE ");
|
||||
}
|
||||
const BRepExtrema_SolutionElem &sol = mySolutionsShape2.Value(N);
|
||||
if (sol.SupportKind() != BRepExtrema_IsInFace)
|
||||
BRepExtrema_UnCompatibleShape::Raise
|
||||
("BRepExtrema_DistShapeShape::ParOnFaceS2:ParOnFaceS2 is impossible without FACE ");
|
||||
|
||||
(ListeDeSolutionShape2.Value(N)).FaceParameter(u, v);
|
||||
|
||||
sol.FaceParameter(u, v);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -585,13 +433,13 @@ void BRepExtrema_DistShapeShape::Dump(Standard_OStream& o) const
|
||||
{
|
||||
Standard_Integer i;
|
||||
Standard_Real r1,r2;
|
||||
BRepExtrema_SupportType Type1, Type2;
|
||||
|
||||
o<< "the distance value is : " << Value()<<endl;
|
||||
o<< "the number of solutions is :"<<NbSolution()<<endl;
|
||||
o<<endl;
|
||||
for (i=1;i<=NbSolution();i++) {
|
||||
o<<"solution number "<<i<<": "<< endl;
|
||||
for (i=1;i<=NbSolution();i++)
|
||||
{
|
||||
o<<"solution number "<<i<<": "<< endl;
|
||||
o<<"the type of the solution on the first shape is " <<Standard_Integer( SupportTypeShape1(i)) <<endl;
|
||||
o<<"the type of the solution on the second shape is "<<Standard_Integer( SupportTypeShape2(i))<< endl;
|
||||
o<< "the coordinates of the point on the first shape are: "<<endl;
|
||||
@ -599,29 +447,28 @@ void BRepExtrema_DistShapeShape::Dump(Standard_OStream& o) const
|
||||
o<< "the coordinates of the point on the second shape are: "<<endl;
|
||||
o<<"X="<< PointOnShape2(i).X()<< " Y="<<PointOnShape2(i).Y()<<" Z="<< PointOnShape2(i).Z()<<endl;
|
||||
|
||||
Type1=SupportTypeShape1(i);
|
||||
Type2=SupportTypeShape2(i);
|
||||
if (Type1 == BRepExtrema_IsOnEdge)
|
||||
{
|
||||
ParOnEdgeS1(i,r1);
|
||||
o << "parameter on the first edge : t= " << r1 << endl;
|
||||
}
|
||||
if (Type1 == BRepExtrema_IsInFace)
|
||||
{
|
||||
ParOnFaceS1(i,r1,r2);
|
||||
o << "parameters on the first face : u= " << r1 << " v=" << r2 << endl;
|
||||
}
|
||||
if (Type2 == BRepExtrema_IsOnEdge)
|
||||
{
|
||||
ParOnEdgeS2(i,r1);
|
||||
o << "parameter on the second edge : t=" << r1 << endl;
|
||||
}
|
||||
if (Type2 == BRepExtrema_IsInFace)
|
||||
{
|
||||
ParOnFaceS2(i,r1,r2);
|
||||
o << "parameters on the second face : u= " << r1 << " v=" << r2 << endl;
|
||||
}
|
||||
|
||||
switch (SupportTypeShape1(i))
|
||||
{
|
||||
case BRepExtrema_IsOnEdge:
|
||||
ParOnEdgeS1(i,r1);
|
||||
o << "parameter on the first edge : t= " << r1 << endl;
|
||||
break;
|
||||
case BRepExtrema_IsInFace:
|
||||
ParOnFaceS1(i,r1,r2);
|
||||
o << "parameters on the first face : u= " << r1 << " v=" << r2 << endl;
|
||||
break;
|
||||
}
|
||||
switch (SupportTypeShape2(i))
|
||||
{
|
||||
case BRepExtrema_IsOnEdge:
|
||||
ParOnEdgeS2(i,r1);
|
||||
o << "parameter on the second edge : t=" << r1 << endl;
|
||||
break;
|
||||
case BRepExtrema_IsInFace:
|
||||
ParOnFaceS2(i,r1,r2);
|
||||
o << "parameters on the second face : u= " << r1 << " v=" << r2 << endl;
|
||||
break;
|
||||
}
|
||||
o<<endl;
|
||||
}
|
||||
}
|
||||
|
215
src/BRepExtrema/BRepExtrema_DistShapeShape.hxx
Normal file
215
src/BRepExtrema/BRepExtrema_DistShapeShape.hxx
Normal file
@ -0,0 +1,215 @@
|
||||
// File generated by CPPExt (Value)
|
||||
//
|
||||
// Copyright (C) 1991 - 2000 by
|
||||
// Matra Datavision SA. All rights reserved.
|
||||
//
|
||||
// Copyright (C) 2001 - 2004 by
|
||||
// Open CASCADE SA. All rights reserved.
|
||||
//
|
||||
// This file is part of the Open CASCADE Technology software.
|
||||
//
|
||||
// This software may be distributed and/or modified under the terms and
|
||||
// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
|
||||
// and appearing in the file LICENSE included in the packaging of this file.
|
||||
//
|
||||
// This software is distributed on an "AS IS" basis, without warranty of any
|
||||
// kind, and Open CASCADE SA hereby disclaims all such warranties,
|
||||
// including without limitation, any warranties of merchantability, fitness
|
||||
// for a particular purpose or non-infringement. Please see the License for
|
||||
// the specific terms and conditions governing rights and limitations under the
|
||||
// License.
|
||||
|
||||
#ifndef _BRepExtrema_DistShapeShape_HeaderFile
|
||||
#define _BRepExtrema_DistShapeShape_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
|
||||
#include <BRepExtrema_SeqOfSolution.hxx>
|
||||
#endif
|
||||
#ifndef _BRepExtrema_SolutionElem_HeaderFile
|
||||
#include <BRepExtrema_SolutionElem.hxx>
|
||||
#endif
|
||||
#ifndef _TopoDS_Shape_HeaderFile
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#endif
|
||||
#ifndef _TopTools_IndexedMapOfShape_HeaderFile
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_ExtFlag_HeaderFile
|
||||
#include <Extrema_ExtFlag.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_ExtAlgo_HeaderFile
|
||||
#include <Extrema_ExtAlgo.hxx>
|
||||
#endif
|
||||
#ifndef _BRepExtrema_SupportType_HeaderFile
|
||||
#include <BRepExtrema_SupportType.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_OStream_HeaderFile
|
||||
#include <Standard_OStream.hxx>
|
||||
#endif
|
||||
#ifndef _gp_Pnt_HeaderFile
|
||||
#include <gp_Pnt.hxx>
|
||||
#endif
|
||||
class TopoDS_Shape;
|
||||
class TopTools_IndexedMapOfShape;
|
||||
class Bnd_SeqOfBox;
|
||||
|
||||
|
||||
//! This class provides tools to compute minimum distance <br>
|
||||
//! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). <br>
|
||||
class BRepExtrema_DistShapeShape
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
//! create empty tool <br>
|
||||
Standard_EXPORT BRepExtrema_DistShapeShape();
|
||||
//! computation of the minimum distance (value and pair of points) using default deflection <br>
|
||||
//! Default value is Precision::Confusion(). <br>
|
||||
Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
|
||||
//! create tool and load both shapes into it <br>
|
||||
Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Standard_Real theDeflection,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad);
|
||||
|
||||
Standard_EXPORT void SetDeflection(const Standard_Real theDeflection)
|
||||
{
|
||||
myEps = theDeflection;
|
||||
}
|
||||
//! load first shape into extrema <br>
|
||||
Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1);
|
||||
//! load second shape into extrema <br>
|
||||
Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1);
|
||||
//! computation of the minimum distance (value and <br>
|
||||
//! couple of points). Parameter theDeflection is used <br>
|
||||
//! to specify a maximum deviation of extreme distances <br>
|
||||
//! from the minimum one. <br>
|
||||
//! Returns IsDone status. <br>
|
||||
Standard_EXPORT Standard_Boolean Perform();
|
||||
//! True if the minimum distance is found. <br>
|
||||
Standard_EXPORT Standard_Boolean IsDone() const
|
||||
{
|
||||
return myIsDone;
|
||||
}
|
||||
//! Returns the number of solutions satisfying the minimum distance. <br>
|
||||
Standard_EXPORT Standard_Integer NbSolution() const
|
||||
{
|
||||
return mySolutionsShape1.Length();
|
||||
}
|
||||
//! Returns the value of the minimum distance. <br>
|
||||
Standard_EXPORT Standard_Real Value() const;
|
||||
//! True if one of the shapes is a solid and the other shape <br>
|
||||
//! is completely or partially inside the solid. <br>
|
||||
Standard_EXPORT Standard_Boolean InnerSolution() const
|
||||
{
|
||||
return myInnerSol;
|
||||
}
|
||||
//! Returns the Point corresponding to the <N>th solution on the first Shape <br>
|
||||
Standard_EXPORT const gp_Pnt & PointOnShape1(const Standard_Integer N) const
|
||||
{
|
||||
return mySolutionsShape1.Value(N).Point();
|
||||
}
|
||||
//! Returns the Point corresponding to the <N>th solution on the second Shape <br>
|
||||
Standard_EXPORT const gp_Pnt & PointOnShape2(const Standard_Integer N) const
|
||||
{
|
||||
return mySolutionsShape2.Value(N).Point();
|
||||
}
|
||||
//! gives the type of the support where the Nth solution on the first shape is situated: <br>
|
||||
//! IsVertex => the Nth solution on the first shape is a Vertex <br>
|
||||
//! IsOnEdge => the Nth soluion on the first shape is on a Edge <br>
|
||||
//! IsInFace => the Nth solution on the first shape is inside a face <br>
|
||||
//! the corresponding support is obtained by the method SupportOnShape1 <br>
|
||||
Standard_EXPORT BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const
|
||||
{
|
||||
return mySolutionsShape1.Value(N).SupportKind();
|
||||
}
|
||||
//! gives the type of the support where the Nth solution on the second shape is situated: <br>
|
||||
//! IsVertex => the Nth solution on the second shape is a Vertex <br>
|
||||
//! IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br>
|
||||
//! IsInFace => the Nth solution on the second shape is inside a face <br>
|
||||
//! the corresponding support is obtained by the method SupportOnShape2 <br>
|
||||
Standard_EXPORT BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const
|
||||
{
|
||||
return mySolutionsShape2.Value(N).SupportKind();
|
||||
}
|
||||
//! gives the support where the Nth solution on the first shape is situated. <br>
|
||||
//! This support can be a Vertex, an Edge or a Face. <br>
|
||||
Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const;
|
||||
//! gives the support where the Nth solution on the second shape is situated. <br>
|
||||
//! This support can be a Vertex, an Edge or a Face. <br>
|
||||
Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) const;
|
||||
//! gives the corresponding parameter t if the Nth solution <br>
|
||||
//! is situated on an Egde of the first shape <br>
|
||||
Standard_EXPORT void ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const;
|
||||
//! gives the corresponding parameter t if the Nth solution <br>
|
||||
//! is situated on an Egde of the first shape <br>
|
||||
Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const;
|
||||
//! gives the corresponding parameters (U,V) if the Nth solution <br>
|
||||
//! is situated on an face of the first shape <br>
|
||||
Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
|
||||
//! gives the corresponding parameters (U,V) if the Nth solution <br>
|
||||
//! is situated on an Face of the second shape <br>
|
||||
Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
|
||||
//! Prints on the stream o information on the current state of the object. <br>
|
||||
Standard_EXPORT void Dump(Standard_OStream& o) const;
|
||||
|
||||
Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
|
||||
{
|
||||
myFlag = F;
|
||||
}
|
||||
|
||||
Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
|
||||
{
|
||||
myAlgo = A;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br>
|
||||
Standard_EXPORT void DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,const TopTools_IndexedMapOfShape& Map2,const Bnd_SeqOfBox& LBox1,const Bnd_SeqOfBox& LBox2);
|
||||
|
||||
Standard_Real myDistRef;
|
||||
Standard_Real myDistValue;
|
||||
Standard_Boolean myIsDone;
|
||||
BRepExtrema_SeqOfSolution mySolutionsShape1;
|
||||
BRepExtrema_SeqOfSolution mySolutionsShape2;
|
||||
Standard_Boolean myInnerSol;
|
||||
Standard_Real myEps;
|
||||
TopoDS_Shape myShape1;
|
||||
TopoDS_Shape myShape2;
|
||||
TopTools_IndexedMapOfShape myMapV1;
|
||||
TopTools_IndexedMapOfShape myMapV2;
|
||||
TopTools_IndexedMapOfShape myMapE1;
|
||||
TopTools_IndexedMapOfShape myMapE2;
|
||||
TopTools_IndexedMapOfShape myMapF1;
|
||||
TopTools_IndexedMapOfShape myMapF2;
|
||||
Extrema_ExtFlag myFlag;
|
||||
Extrema_ExtAlgo myAlgo;
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
174
src/BRepExtrema/BRepExtrema_DistanceSS.hxx
Normal file
174
src/BRepExtrema/BRepExtrema_DistanceSS.hxx
Normal file
@ -0,0 +1,174 @@
|
||||
// File generated by CPPExt (Value)
|
||||
//
|
||||
// Copyright (C) 1991 - 2000 by
|
||||
// Matra Datavision SA. All rights reserved.
|
||||
//
|
||||
// Copyright (C) 2001 - 2004 by
|
||||
// Open CASCADE SA. All rights reserved.
|
||||
//
|
||||
// This file is part of the Open CASCADE Technology software.
|
||||
//
|
||||
// This software may be distributed and/or modified under the terms and
|
||||
// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
|
||||
// and appearing in the file LICENSE included in the packaging of this file.
|
||||
//
|
||||
// This software is distributed on an "AS IS" basis, without warranty of any
|
||||
// kind, and Open CASCADE SA hereby disclaims all such warranties,
|
||||
// including without limitation, any warranties of merchantability, fitness
|
||||
// for a particular purpose or non-infringement. Please see the License for
|
||||
// the specific terms and conditions governing rights and limitations under the
|
||||
// License.
|
||||
|
||||
#ifndef _BRepExtrema_DistanceSS_HeaderFile
|
||||
#define _BRepExtrema_DistanceSS_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
|
||||
#include <BRepExtrema_SeqOfSolution.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_ExtFlag_HeaderFile
|
||||
#include <Extrema_ExtFlag.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_ExtAlgo_HeaderFile
|
||||
#include <Extrema_ExtAlgo.hxx>
|
||||
#endif
|
||||
#ifndef _Precision_HeaderFile
|
||||
#include <Precision.hxx>
|
||||
#endif
|
||||
class TopoDS_Shape;
|
||||
class Bnd_Box;
|
||||
class TopoDS_Vertex;
|
||||
class TopoDS_Edge;
|
||||
class TopoDS_Face;
|
||||
|
||||
|
||||
//! This class allows to compute minimum distance between two shapes <br>
|
||||
//! (face edge vertex) and is used in DistShapeShape class. <br>
|
||||
class BRepExtrema_DistanceSS
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
//! computes the distance between two Shapes ( face edge vertex). <br>
|
||||
Standard_EXPORT BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
|
||||
const Bnd_Box& B1, const Bnd_Box& B2,
|
||||
const Standard_Real DstRef,
|
||||
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
|
||||
const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
|
||||
: myDstRef(DstRef), myModif(Standard_False), myEps(Precision::Confusion()), myFlag(F), myAlgo(A)
|
||||
{
|
||||
Perform(S1, S2, B1, B2);
|
||||
}
|
||||
//! computes the distance between two Shapes ( face edge vertex). <br>
|
||||
//! Parameter theDeflection is used to specify a maximum deviation <br>
|
||||
//! of extreme distances from the minimum one. <br>
|
||||
//! Default value is Precision::Confusion(). <br>
|
||||
Standard_EXPORT BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
|
||||
const Bnd_Box& B1, const Bnd_Box& B2,
|
||||
const Standard_Real DstRef, const Standard_Real aDeflection,
|
||||
const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
|
||||
const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
|
||||
: myDstRef(DstRef), myModif(Standard_False), myEps(aDeflection), myFlag(F), myAlgo(A)
|
||||
{
|
||||
Perform(S1, S2, B1, B2);
|
||||
}
|
||||
//! True if the distance has been computed <br>
|
||||
Standard_EXPORT Standard_Boolean IsDone() const
|
||||
{
|
||||
return myModif;
|
||||
}
|
||||
//! returns the distance value <br>
|
||||
Standard_EXPORT Standard_Real DistValue() const
|
||||
{
|
||||
return myDstRef;
|
||||
}
|
||||
//! returns the list of solutions on the first shape <br>
|
||||
Standard_EXPORT const BRepExtrema_SeqOfSolution& Seq1Value() const
|
||||
{
|
||||
return SeqSolShape1;
|
||||
}
|
||||
//! returns the list of solutions on the second shape <br>
|
||||
Standard_EXPORT const BRepExtrema_SeqOfSolution& Seq2Value() const
|
||||
{
|
||||
return SeqSolShape2;
|
||||
}
|
||||
//! sets the flag controlling minimum and maximum search
|
||||
Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
|
||||
{
|
||||
myFlag = F;
|
||||
}
|
||||
//! sets the flag controlling ...
|
||||
Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
|
||||
{
|
||||
myAlgo = A;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//! computes the distance between two Shapes ( face edge vertex) <br>
|
||||
void Perform(const TopoDS_Shape& S1,const TopoDS_Shape& S2,const Bnd_Box& B1,const Bnd_Box& B2);
|
||||
|
||||
//! computes the distance between two vertices <br>
|
||||
void Perform(const TopoDS_Vertex& S1,const TopoDS_Vertex& S2);
|
||||
//! computes the minimum distance between a vertex and an edge <br>
|
||||
void Perform(const TopoDS_Vertex& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
|
||||
//! computes the minimum distance between a vertex and a face <br>
|
||||
void Perform(const TopoDS_Vertex& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
|
||||
|
||||
//! computes the minimum distance between an edge and a vertex <br>
|
||||
void Perform(const TopoDS_Edge& S1,const TopoDS_Vertex& S2,const Bnd_Box& B1,const Bnd_Box& B2)
|
||||
{
|
||||
Perform(S2, S1, B2, B1);
|
||||
}
|
||||
//! computes the minimum distance between two edges <br>
|
||||
void Perform(const TopoDS_Edge& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
|
||||
//! computes the minimum distance an edge and a face <br>
|
||||
void Perform(const TopoDS_Edge& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
|
||||
|
||||
//! computes the minimum distance betwwen a face and a vertex <br>
|
||||
void Perform(const TopoDS_Face& S1,const TopoDS_Vertex& S2,const Bnd_Box& B1,const Bnd_Box& B2)
|
||||
{
|
||||
Perform(S2, S1, B2, B1);
|
||||
}
|
||||
//! computes the minimum distance between a face and an edge <br>
|
||||
void Perform(const TopoDS_Face& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2)
|
||||
{
|
||||
Perform(S2, S1, B2, B1);
|
||||
}
|
||||
//! computes the minimum distance between two faces <br>
|
||||
void Perform(const TopoDS_Face& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
|
||||
|
||||
BRepExtrema_SeqOfSolution SeqSolShape1;
|
||||
BRepExtrema_SeqOfSolution SeqSolShape2;
|
||||
Standard_Real myDstRef;
|
||||
Standard_Boolean myModif;
|
||||
Standard_Real myEps;
|
||||
Extrema_ExtFlag myFlag;
|
||||
Extrema_ExtAlgo myAlgo;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,12 +1,10 @@
|
||||
// File: BRepExtrema_ExtCC.cxx
|
||||
// Created: Wed Dec 15 16:48:53 1993
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun1>
|
||||
|
||||
#include <BRepExtrema_ExtCC.ixx>
|
||||
#include <BRepExtrema_ExtCC.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Extrema_POnCurv.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_HCurve.hxx>
|
||||
@ -17,18 +15,7 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtCC::BRepExtrema_ExtCC()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ExtCC
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtCC::BRepExtrema_ExtCC
|
||||
(const TopoDS_Edge& E1,
|
||||
const TopoDS_Edge& E2)
|
||||
BRepExtrema_ExtCC::BRepExtrema_ExtCC(const TopoDS_Edge& E1, const TopoDS_Edge& E2)
|
||||
{
|
||||
Initialize(E2);
|
||||
Perform(E1);
|
||||
@ -45,7 +32,7 @@ void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
|
||||
BRepAdaptor_Curve Curv(E2);
|
||||
myHC = new BRepAdaptor_HCurve(Curv);
|
||||
BRep_Tool::Range(E2,V1,V2);
|
||||
myExtrem.SetCurve (2, myHC->Curve(),V1,V2);
|
||||
myExtCC.SetCurve(2,myHC->Curve(),V1,V2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -59,49 +46,8 @@ void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
|
||||
BRepAdaptor_Curve Curv(E1);
|
||||
Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
|
||||
BRep_Tool::Range(E1,U1,U2);
|
||||
myExtrem.SetCurve (1, HC->Curve(), U1, U2);
|
||||
myExtrem.Perform();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtCC::IsDone()const
|
||||
{
|
||||
return myExtrem.IsDone();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbExt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepExtrema_ExtCC::NbExt() const
|
||||
{
|
||||
return myExtrem.NbExt();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsMin
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtCC::IsParallel() const
|
||||
{
|
||||
return myExtrem.IsParallel();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SquareDistance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtCC::SquareDistance
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
return myExtrem.SquareDistance(N);
|
||||
myExtCC.SetCurve (1, HC->Curve(), U1, U2);
|
||||
myExtCC.Perform();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -109,11 +55,10 @@ Standard_Real BRepExtrema_ExtCC::SquareDistance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtCC::ParameterOnE1
|
||||
(const Standard_Integer N) const
|
||||
Standard_Real BRepExtrema_ExtCC::ParameterOnE1(const Standard_Integer N) const
|
||||
{
|
||||
Extrema_POnCurv POnE1, POnE2;
|
||||
myExtrem.Points(N, POnE1, POnE2);
|
||||
myExtCC.Points(N, POnE1, POnE2);
|
||||
return POnE1.Parameter();
|
||||
}
|
||||
|
||||
@ -122,13 +67,11 @@ Standard_Real BRepExtrema_ExtCC::ParameterOnE1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtCC::PointOnE1
|
||||
(const Standard_Integer N) const
|
||||
gp_Pnt BRepExtrema_ExtCC::PointOnE1(const Standard_Integer N) const
|
||||
{
|
||||
Extrema_POnCurv POnE1, POnE2;
|
||||
myExtrem.Points(N, POnE1, POnE2);
|
||||
gp_Pnt P = POnE1.Value();
|
||||
return P;
|
||||
myExtCC.Points(N, POnE1, POnE2);
|
||||
return POnE1.Value();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -136,11 +79,10 @@ gp_Pnt BRepExtrema_ExtCC::PointOnE1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtCC::ParameterOnE2
|
||||
(const Standard_Integer N) const
|
||||
Standard_Real BRepExtrema_ExtCC::ParameterOnE2(const Standard_Integer N) const
|
||||
{
|
||||
Extrema_POnCurv POnE1, POnE2;
|
||||
myExtrem.Points(N, POnE1, POnE2);
|
||||
myExtCC.Points(N, POnE1, POnE2);
|
||||
return POnE2.Parameter();
|
||||
}
|
||||
|
||||
@ -149,13 +91,11 @@ Standard_Real BRepExtrema_ExtCC::ParameterOnE2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtCC::PointOnE2
|
||||
(const Standard_Integer N) const
|
||||
gp_Pnt BRepExtrema_ExtCC::PointOnE2(const Standard_Integer N) const
|
||||
{
|
||||
Extrema_POnCurv POnE1, POnE2;
|
||||
myExtrem.Points(N, POnE1, POnE2);
|
||||
gp_Pnt P = POnE2.Value();
|
||||
return P;
|
||||
myExtCC.Points(N, POnE1, POnE2);
|
||||
return POnE2.Value();
|
||||
}
|
||||
|
||||
|
||||
@ -174,7 +114,6 @@ void BRepExtrema_ExtCC::TrimmedSquareDistances
|
||||
gp_Pnt& pnt21,
|
||||
gp_Pnt& pnt22) const
|
||||
{
|
||||
myExtrem.TrimmedSquareDistances(dist11,dist12,dist21, dist22,
|
||||
pnt11,pnt12, pnt21, pnt22);
|
||||
myExtCC.TrimmedSquareDistances(dist11,dist12,dist21,dist22,
|
||||
pnt11,pnt12,pnt21,pnt22);
|
||||
}
|
||||
|
||||
|
102
src/BRepExtrema/BRepExtrema_ExtCC.hxx
Normal file
102
src/BRepExtrema/BRepExtrema_ExtCC.hxx
Normal file
@ -0,0 +1,102 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_ExtCC_HeaderFile
|
||||
#define _BRepExtrema_ExtCC_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Extrema_ExtCC_HeaderFile
|
||||
#include <Extrema_ExtCC.hxx>
|
||||
#endif
|
||||
#ifndef _Handle_BRepAdaptor_HCurve_HeaderFile
|
||||
#include <Handle_BRepAdaptor_HCurve.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
class BRepAdaptor_HCurve;
|
||||
class TopoDS_Edge;
|
||||
class gp_Pnt;
|
||||
|
||||
|
||||
class BRepExtrema_ExtCC
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
Standard_EXPORT BRepExtrema_ExtCC()
|
||||
{
|
||||
}
|
||||
//! It calculates all the distances. <br>
|
||||
Standard_EXPORT BRepExtrema_ExtCC(const TopoDS_Edge& E1,const TopoDS_Edge& E2);
|
||||
|
||||
Standard_EXPORT void Initialize(const TopoDS_Edge& E2);
|
||||
//! An exception is raised if the fields have not been initialized. <br>
|
||||
Standard_EXPORT void Perform(const TopoDS_Edge& E1);
|
||||
//! True if the distances are found. <br>
|
||||
Standard_EXPORT Standard_Boolean IsDone() const
|
||||
{
|
||||
return myExtCC.IsDone();
|
||||
}
|
||||
//! Returns the number of extremum distances. <br>
|
||||
Standard_EXPORT Standard_Integer NbExt() const
|
||||
{
|
||||
return myExtCC.NbExt();
|
||||
}
|
||||
//! Returns True if E1 and E2 are parallel. <br>
|
||||
Standard_EXPORT Standard_Boolean IsParallel() const
|
||||
{
|
||||
return myExtCC.IsParallel();
|
||||
}
|
||||
//! Returns the value of the <N>th extremum square distance. <br>
|
||||
Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
|
||||
{
|
||||
return myExtCC.SquareDistance(N);
|
||||
}
|
||||
//! Returns the parameter on the first edge of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT Standard_Real ParameterOnE1(const Standard_Integer N) const;
|
||||
//! Returns the Point of the <N>th extremum distance on the edge E1. <br>
|
||||
Standard_EXPORT gp_Pnt PointOnE1(const Standard_Integer N) const;
|
||||
//! Returns the parameter on the second edge of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT Standard_Real ParameterOnE2(const Standard_Integer N) const;
|
||||
//! Returns the Point of the <N>th extremum distance on the edge E2. <br>
|
||||
Standard_EXPORT gp_Pnt PointOnE2(const Standard_Integer N) const;
|
||||
//! if the edges is a trimmed curve, <br>
|
||||
//! dist11 is a square distance between the point on E1 <br>
|
||||
//! of parameter FirstParameter and the point of <br>
|
||||
//! parameter FirstParameter on E2. <br>
|
||||
Standard_EXPORT void TrimmedSquareDistances(Standard_Real& dist11,Standard_Real& distP12,Standard_Real& distP21,Standard_Real& distP22,gp_Pnt& P11,gp_Pnt& P12,gp_Pnt& P21,gp_Pnt& P22) const;
|
||||
|
||||
private:
|
||||
|
||||
Extrema_ExtCC myExtCC;
|
||||
Handle_BRepAdaptor_HCurve myHC;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,18 +1,13 @@
|
||||
// File: BRepExtrema_ExtCF.cxx
|
||||
// Created: Wed Dec 15 16:48:53 1993
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun1>
|
||||
|
||||
#include <BRepExtrema_ExtCF.ixx>
|
||||
#include <BRepExtrema_ExtCF.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <GeomAdaptor_Surface.hxx>
|
||||
#include <Extrema_POnCurv.hxx>
|
||||
#include <Extrema_POnSurf.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
@ -24,18 +19,7 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtCF::BRepExtrema_ExtCF()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ExtCF
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtCF::BRepExtrema_ExtCF
|
||||
(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F)
|
||||
BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F)
|
||||
{
|
||||
Initialize(F);
|
||||
Perform(E, F);
|
||||
@ -50,10 +34,10 @@ void BRepExtrema_ExtCF::Initialize(const TopoDS_Face& F2)
|
||||
{
|
||||
BRepAdaptor_Surface Surf(F2);
|
||||
myHS = new BRepAdaptor_HSurface(Surf);
|
||||
Standard_Real Tol = BRep_Tool::Tolerance(F2);
|
||||
const Standard_Real Tol = BRep_Tool::Tolerance(F2);
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
BRepTools::UVBounds(F2, U1, U2, V1, V2);
|
||||
myExtrem.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol, Tol);
|
||||
myExtCS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol, Tol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -61,149 +45,45 @@ void BRepExtrema_ExtCF::Initialize(const TopoDS_Face& F2)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E,
|
||||
const TopoDS_Face& F2)
|
||||
void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2)
|
||||
{
|
||||
mySqDist.Clear();
|
||||
myPointsOnS.Clear();
|
||||
myPointsOnC.Clear();
|
||||
|
||||
Standard_Real U1, U2;
|
||||
BRep_Tool::Range(E, U1, U2);
|
||||
|
||||
BRepAdaptor_Curve Curv(E);
|
||||
Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
|
||||
myExtrem.Perform(HC->Curve(), U1, U2);
|
||||
myExtCS.Perform(HC->Curve(), U1, U2);
|
||||
|
||||
// exploration des points et classification:
|
||||
BRepClass_FaceClassifier classifier;
|
||||
gp_Pnt2d Puv;
|
||||
TopAbs_State state;
|
||||
Standard_Real Tol = BRep_Tool::Tolerance(F2);
|
||||
Extrema_POnCurv P1;
|
||||
Extrema_POnSurf P2;
|
||||
mynbext = 0;
|
||||
|
||||
if(!myExtrem.IsDone())
|
||||
if(!myExtCS.IsDone())
|
||||
return;
|
||||
|
||||
if (myExtrem.IsParallel()) {
|
||||
mySqDist.Append(myExtrem.SquareDistance(1));
|
||||
mynbext = 1;
|
||||
}
|
||||
else {
|
||||
for (Standard_Integer i = 1; i <= myExtrem.NbExt(); i++) {
|
||||
myExtrem.Points(i, P1, P2);
|
||||
if (myExtCS.IsParallel())
|
||||
mySqDist.Append(myExtCS.SquareDistance(1));
|
||||
else
|
||||
{
|
||||
// Exploration of points and classification
|
||||
BRepClass_FaceClassifier classifier;
|
||||
const Standard_Real Tol = BRep_Tool::Tolerance(F2);
|
||||
Extrema_POnCurv P1;
|
||||
Extrema_POnSurf P2;
|
||||
|
||||
for (Standard_Integer i = 1; i <= myExtCS.NbExt(); i++)
|
||||
{
|
||||
myExtCS.Points(i, P1, P2);
|
||||
P2.Parameter(U1, U2);
|
||||
Puv.SetCoord(U1, U2);
|
||||
const gp_Pnt2d Puv(U1, U2);
|
||||
classifier.Perform(F2, Puv, Tol);
|
||||
state = classifier.State();
|
||||
if(state == TopAbs_ON || state == TopAbs_IN) {
|
||||
mynbext++;
|
||||
mySqDist.Append(myExtrem.SquareDistance(i));
|
||||
myPointsOnC.Append(P1);
|
||||
myPointsOnS.Append(P2);
|
||||
const TopAbs_State state = classifier.State();
|
||||
if (state == TopAbs_ON || state == TopAbs_IN)
|
||||
{
|
||||
mySqDist.Append(myExtCS.SquareDistance(i));
|
||||
myPointsOnC.Append(P1);
|
||||
myPointsOnS.Append(P2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtCF::IsDone()const
|
||||
{
|
||||
return myExtrem.IsDone();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsParallel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtCF::IsParallel()const
|
||||
{
|
||||
return myExtrem.IsParallel();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbExt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepExtrema_ExtCF::NbExt() const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
return mynbext;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SquareDistance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtCF::SquareDistance
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
return mySqDist.Value(N);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ParameterOnFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtCF::ParameterOnFace(const Standard_Integer N,
|
||||
Standard_Real& U,
|
||||
Standard_Real& V) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
myPointsOnS.Value(N).Parameter(U, V);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ParameterOnEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtCF::ParameterOnEdge
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
return myPointsOnC.Value(N).Parameter();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PointOnEdge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtCF::PointOnEdge
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
gp_Pnt P = myPointsOnC.Value(N).Value();
|
||||
return P;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PointOnFace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtCF::PointOnFace
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
gp_Pnt P = myPointsOnS.Value(N).Value();
|
||||
return P;
|
||||
}
|
||||
|
||||
|
129
src/BRepExtrema/BRepExtrema_ExtCF.hxx
Normal file
129
src/BRepExtrema/BRepExtrema_ExtCF.hxx
Normal file
@ -0,0 +1,129 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_ExtCF_HeaderFile
|
||||
#define _BRepExtrema_ExtCF_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Extrema_ExtCS_HeaderFile
|
||||
#include <Extrema_ExtCS.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _TColStd_SequenceOfReal_HeaderFile
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
|
||||
#include <Extrema_SequenceOfPOnSurf.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_SequenceOfPOnCurv_HeaderFile
|
||||
#include <Extrema_SequenceOfPOnCurv.hxx>
|
||||
#endif
|
||||
#ifndef _Handle_BRepAdaptor_HSurface_HeaderFile
|
||||
#include <Handle_BRepAdaptor_HSurface.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_POnCurv_HeaderFile
|
||||
#include <Extrema_POnCurv.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_POnSurf_HeaderFile
|
||||
#include <Extrema_POnSurf.hxx>
|
||||
#endif
|
||||
class BRepAdaptor_HSurface;
|
||||
class TopoDS_Edge;
|
||||
class TopoDS_Face;
|
||||
class gp_Pnt;
|
||||
|
||||
|
||||
class BRepExtrema_ExtCF
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
Standard_EXPORT BRepExtrema_ExtCF()
|
||||
{
|
||||
}
|
||||
//! It calculates all the distances. <br>
|
||||
Standard_EXPORT BRepExtrema_ExtCF(const TopoDS_Edge& V,const TopoDS_Face& E);
|
||||
|
||||
Standard_EXPORT void Initialize(const TopoDS_Face& E);
|
||||
//! An exception is raised if the fields have not been initialized. <br>
|
||||
//! Be careful: this method uses the Face only for classify not for the fields. <br>
|
||||
Standard_EXPORT void Perform(const TopoDS_Edge& V,const TopoDS_Face& F);
|
||||
//! True if the distances are found. <br>
|
||||
Standard_EXPORT Standard_Boolean IsDone() const
|
||||
{
|
||||
return myExtCS.IsDone();
|
||||
}
|
||||
//! Returns the number of extremum distances. <br>
|
||||
Standard_EXPORT Standard_Integer NbExt() const
|
||||
{
|
||||
return mySqDist.Length();
|
||||
}
|
||||
//! Returns the value of the <N>th extremum square distance. <br>
|
||||
Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
|
||||
{
|
||||
return mySqDist.Value(N);
|
||||
}
|
||||
//! Returns True if the curve is on a parallel surface. <br>
|
||||
Standard_EXPORT Standard_Boolean IsParallel() const
|
||||
{
|
||||
return myExtCS.IsParallel();
|
||||
}
|
||||
//! Returns the parameters on the Edge of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT Standard_Real ParameterOnEdge(const Standard_Integer N) const
|
||||
{
|
||||
return myPointsOnC.Value(N).Parameter();
|
||||
}
|
||||
//! Returns the parameters on the Face of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT void ParameterOnFace(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
|
||||
{
|
||||
myPointsOnS.Value(N).Parameter(U, V);
|
||||
}
|
||||
//! Returns the Point of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT gp_Pnt PointOnEdge(const Standard_Integer N) const
|
||||
{
|
||||
return myPointsOnC.Value(N).Value();
|
||||
}
|
||||
//! Returns the Point of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT gp_Pnt PointOnFace(const Standard_Integer N) const
|
||||
{
|
||||
return myPointsOnS.Value(N).Value();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Extrema_ExtCS myExtCS;
|
||||
TColStd_SequenceOfReal mySqDist;
|
||||
Extrema_SequenceOfPOnSurf myPointsOnS;
|
||||
Extrema_SequenceOfPOnCurv myPointsOnC;
|
||||
Handle_BRepAdaptor_HSurface myHS;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,22 +1,15 @@
|
||||
// File: BRepExtrema_ExtFF.cxx
|
||||
// Created: Wed Dec 15 16:48:53 1993
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun1>
|
||||
// modified by mps (juillet 96 ): on utilise BRepAdaptor a la place de
|
||||
// GeomAdaptor dans Initialize et Perform.
|
||||
#include <BRepExtrema_ExtFF.ixx>
|
||||
|
||||
#include <BRepExtrema_ExtFF.hxx>
|
||||
|
||||
#include <BRepExtrema_ExtCF.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <Geom_Surface.hxx>
|
||||
#include <Extrema_POnSurf.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
@ -26,22 +19,12 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtFF::BRepExtrema_ExtFF()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ExtFF
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtFF::BRepExtrema_ExtFF
|
||||
(const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2)
|
||||
BRepExtrema_ExtFF::BRepExtrema_ExtFF(const TopoDS_Face& F1, const TopoDS_Face& F2)
|
||||
{
|
||||
Initialize(F2);
|
||||
Perform(F1,F2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
@ -51,11 +34,10 @@ void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
|
||||
{
|
||||
BRepAdaptor_Surface Surf(F2);
|
||||
myHS = new BRepAdaptor_HSurface(Surf);
|
||||
Standard_Real Tol = BRep_Tool::Tolerance(F2);
|
||||
const Standard_Real Tol = BRep_Tool::Tolerance(F2);
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
BRepTools::UVBounds(F2, U1, U2, V1, V2);
|
||||
myExtrem.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol);
|
||||
|
||||
myExtSS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -63,156 +45,52 @@ void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1,
|
||||
const TopoDS_Face& F2)
|
||||
void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2)
|
||||
{
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
Standard_Integer i;
|
||||
mySqDist.Clear();
|
||||
myPointsOnS1.Clear();
|
||||
myPointsOnS2.Clear();
|
||||
|
||||
BRepAdaptor_Surface Surf1(F1);
|
||||
Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1);
|
||||
Standard_Real Tol1 = BRep_Tool::Tolerance(F1);
|
||||
const Standard_Real Tol1 = BRep_Tool::Tolerance(F1);
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
BRepTools::UVBounds(F1, U1, U2, V1, V2);
|
||||
myExtrem.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1);
|
||||
|
||||
myExtSS.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1);
|
||||
|
||||
// exploration des points et classification:
|
||||
BRepClass_FaceClassifier classifier;
|
||||
gp_Pnt2d Puv;
|
||||
TopAbs_State state1, state2;
|
||||
Standard_Real Tol2 = BRep_Tool::Tolerance(F2);
|
||||
Extrema_POnSurf P1, P2;
|
||||
mynbext = 0;
|
||||
if (!myExtSS.IsDone())
|
||||
return;
|
||||
|
||||
if (myExtrem.IsParallel()) {
|
||||
mySqDist.Append(myExtrem.SquareDistance(1));
|
||||
mynbext = 1;
|
||||
}
|
||||
else {
|
||||
for (i = 1; i <= myExtrem.NbExt(); i++) {
|
||||
myExtrem.Points(i, P1, P2);
|
||||
if (myExtSS.IsParallel())
|
||||
mySqDist.Append(myExtSS.SquareDistance(1));
|
||||
else
|
||||
{
|
||||
// Exploration of points and classification
|
||||
BRepClass_FaceClassifier classifier;
|
||||
const Standard_Real Tol2 = BRep_Tool::Tolerance(F2);
|
||||
Extrema_POnSurf P1, P2;
|
||||
|
||||
Standard_Integer i;
|
||||
for (i = 1; i <= myExtSS.NbExt(); i++)
|
||||
{
|
||||
myExtSS.Points(i, P1, P2);
|
||||
P1.Parameter(U1, U2);
|
||||
Puv.SetCoord(U1, U2);
|
||||
classifier.Perform(F1, Puv, Tol1);
|
||||
state1 = classifier.State();
|
||||
P2.Parameter(U1, U2);
|
||||
Puv.SetCoord(U1, U2);
|
||||
classifier.Perform(F2, Puv, Tol2);
|
||||
state2 = classifier.State();
|
||||
if((state1 == TopAbs_ON || state1 == TopAbs_IN) &&
|
||||
(state2 == TopAbs_ON || state2 == TopAbs_IN)) {
|
||||
mynbext++;
|
||||
mySqDist.Append(myExtrem.SquareDistance(i));
|
||||
myPointsOnS1.Append(P1);
|
||||
myPointsOnS2.Append(P2);
|
||||
const gp_Pnt2d Puv1(U1, U2);
|
||||
classifier.Perform(F1, Puv1, Tol1);
|
||||
const TopAbs_State state1 = classifier.State();
|
||||
if (state1 == TopAbs_ON || state1 == TopAbs_IN)
|
||||
{
|
||||
P2.Parameter(U1, U2);
|
||||
const gp_Pnt2d Puv2(U1, U2);
|
||||
classifier.Perform(F2, Puv2, Tol2);
|
||||
const TopAbs_State state2 = classifier.State();
|
||||
if (state2 == TopAbs_ON || state2 == TopAbs_IN)
|
||||
{
|
||||
mySqDist.Append(myExtSS.SquareDistance(i));
|
||||
myPointsOnS1.Append(P1);
|
||||
myPointsOnS2.Append(P2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtFF::IsDone()const
|
||||
{
|
||||
return myExtrem.IsDone();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsParallel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtFF::IsParallel()const
|
||||
{
|
||||
return myExtrem.IsParallel();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NbExt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepExtrema_ExtFF::NbExt() const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
return mynbext;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SquareDistance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtFF::SquareDistance
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
return mySqDist.Value(N);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ParameterOnFace1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtFF::ParameterOnFace1(const Standard_Integer N,
|
||||
Standard_Real& U,
|
||||
Standard_Real& V) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
myPointsOnS1.Value(N).Parameter(U, V);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PointOnFace1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtFF::PointOnFace1
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
gp_Pnt P = myPointsOnS1.Value(N).Value();
|
||||
return P;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ParameterOnFace2
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtFF::ParameterOnFace2(const Standard_Integer N,
|
||||
Standard_Real& U,
|
||||
Standard_Real& V) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
myPointsOnS2.Value(N).Parameter(U, V);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : PointOnFace1
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtFF::PointOnFace2
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
gp_Pnt P = myPointsOnS2.Value(N).Value();
|
||||
return P;
|
||||
}
|
||||
|
||||
|
||||
|
124
src/BRepExtrema/BRepExtrema_ExtFF.hxx
Normal file
124
src/BRepExtrema/BRepExtrema_ExtFF.hxx
Normal file
@ -0,0 +1,124 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_ExtFF_HeaderFile
|
||||
#define _BRepExtrema_ExtFF_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Extrema_ExtSS_HeaderFile
|
||||
#include <Extrema_ExtSS.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _TColStd_SequenceOfReal_HeaderFile
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
|
||||
#include <Extrema_SequenceOfPOnSurf.hxx>
|
||||
#endif
|
||||
#ifndef _Handle_BRepAdaptor_HSurface_HeaderFile
|
||||
#include <Handle_BRepAdaptor_HSurface.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_POnSurf_HeaderFile
|
||||
#include <Extrema_POnSurf.hxx>
|
||||
#endif
|
||||
class BRepAdaptor_HSurface;
|
||||
class TopoDS_Face;
|
||||
class gp_Pnt;
|
||||
|
||||
|
||||
|
||||
class BRepExtrema_ExtFF
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
|
||||
Standard_EXPORT BRepExtrema_ExtFF()
|
||||
{
|
||||
}
|
||||
//! It calculates all the distances. <br>
|
||||
Standard_EXPORT BRepExtrema_ExtFF(const TopoDS_Face& F1,const TopoDS_Face& F2);
|
||||
|
||||
Standard_EXPORT void Initialize(const TopoDS_Face& F2) ;
|
||||
//! An exception is raised if the fields have not been initialized. <br>
|
||||
//! Be careful: this method uses the Face F2 only for classify, not for the fields. <br>
|
||||
Standard_EXPORT void Perform(const TopoDS_Face& F1,const TopoDS_Face& F2);
|
||||
//! True if the distances are found. <br>
|
||||
Standard_EXPORT Standard_Boolean IsDone() const
|
||||
{
|
||||
return myExtSS.IsDone();
|
||||
}
|
||||
//! Returns True if the surfaces are parallel. <br>
|
||||
Standard_EXPORT Standard_Boolean IsParallel() const
|
||||
{
|
||||
return myExtSS.IsParallel();
|
||||
}
|
||||
//! Returns the number of extremum distances. <br>
|
||||
Standard_EXPORT Standard_Integer NbExt() const
|
||||
{
|
||||
return mySqDist.Length();
|
||||
}
|
||||
//! Returns the value of the <N>th extremum square distance. <br>
|
||||
Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
|
||||
{
|
||||
return mySqDist.Value(N);
|
||||
}
|
||||
//! Returns the parameters on the Face F1 of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT void ParameterOnFace1(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
|
||||
{
|
||||
myPointsOnS1.Value(N).Parameter(U, V);
|
||||
}
|
||||
//! Returns the parameters on the Face F2 of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT void ParameterOnFace2(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
|
||||
{
|
||||
myPointsOnS2.Value(N).Parameter(U, V);
|
||||
}
|
||||
//! Returns the Point of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT gp_Pnt PointOnFace1(const Standard_Integer N) const
|
||||
{
|
||||
return myPointsOnS1.Value(N).Value();
|
||||
}
|
||||
//! Returns the Point of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT gp_Pnt PointOnFace2(const Standard_Integer N) const
|
||||
{
|
||||
return myPointsOnS2.Value(N).Value();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Extrema_ExtSS myExtSS;
|
||||
TColStd_SequenceOfReal mySqDist;
|
||||
Extrema_SequenceOfPOnSurf myPointsOnS1;
|
||||
Extrema_SequenceOfPOnSurf myPointsOnS2;
|
||||
Handle_BRepAdaptor_HSurface myHS;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,12 +1,12 @@
|
||||
// File: BRepExtrema_ExtPC.cxx
|
||||
// Created: Wed Dec 15 16:48:53 1993
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun1>
|
||||
|
||||
#include <BRepExtrema_ExtPC.ixx>
|
||||
#include <BRepExtrema_ExtPC.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
//#include <StdFail_NotDone.hxx>
|
||||
//#include <Standard_Failure.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_HCurve.hxx>
|
||||
|
||||
@ -16,18 +16,7 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtPC::BRepExtrema_ExtPC()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ExtPC
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtPC::BRepExtrema_ExtPC
|
||||
(const TopoDS_Vertex& V,
|
||||
const TopoDS_Edge& E)
|
||||
BRepExtrema_ExtPC::BRepExtrema_ExtPC(const TopoDS_Vertex& V, const TopoDS_Edge& E)
|
||||
{
|
||||
Initialize(E);
|
||||
Perform(V);
|
||||
@ -44,7 +33,7 @@ void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
|
||||
BRepAdaptor_Curve Curv(E);
|
||||
myHC = new BRepAdaptor_HCurve(Curv);
|
||||
BRep_Tool::Range(E,U1,U2);
|
||||
myExtrem.Initialize(myHC->Curve(),U1,U2);
|
||||
myExtPC.Initialize(myHC->Curve(),U1,U2);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -55,93 +44,5 @@ void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
|
||||
void BRepExtrema_ExtPC::Perform(const TopoDS_Vertex& V)
|
||||
{
|
||||
gp_Pnt P = BRep_Tool::Pnt(V);
|
||||
myExtrem.Perform(P);
|
||||
myExtPC.Perform(P);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtPC::IsDone()const
|
||||
{
|
||||
return myExtrem.IsDone();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbExt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepExtrema_ExtPC::NbExt() const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
return myExtrem.NbExt();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsMin
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtPC::IsMin
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
|
||||
return myExtrem.IsMin(N);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtPC::SquareDistance
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
|
||||
return myExtrem.SquareDistance(N);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Parameter
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtPC::Parameter
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
|
||||
return myExtrem.Point(N).Parameter();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Point
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtPC::Point
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
|
||||
return (myExtrem.Point(N).Value());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TrimmedDistances
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtPC::TrimmedSquareDistances
|
||||
(Standard_Real& dist1,
|
||||
Standard_Real& dist2,
|
||||
gp_Pnt& pnt1,
|
||||
gp_Pnt& pnt2) const
|
||||
{
|
||||
myExtrem.TrimmedSquareDistances(dist1,dist2,pnt1,pnt2);
|
||||
}
|
||||
|
||||
|
110
src/BRepExtrema/BRepExtrema_ExtPC.hxx
Normal file
110
src/BRepExtrema/BRepExtrema_ExtPC.hxx
Normal file
@ -0,0 +1,110 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_ExtPC_HeaderFile
|
||||
#define _BRepExtrema_ExtPC_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Extrema_ExtPC_HeaderFile
|
||||
#include <Extrema_ExtPC.hxx>
|
||||
#endif
|
||||
#ifndef _Handle_BRepAdaptor_HCurve_HeaderFile
|
||||
#include <Handle_BRepAdaptor_HCurve.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
class BRepAdaptor_HCurve;
|
||||
class TopoDS_Vertex;
|
||||
class TopoDS_Edge;
|
||||
class gp_Pnt;
|
||||
|
||||
|
||||
class BRepExtrema_ExtPC
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
|
||||
Standard_EXPORT BRepExtrema_ExtPC()
|
||||
{
|
||||
}
|
||||
//! It calculates all the distances. <br>
|
||||
Standard_EXPORT BRepExtrema_ExtPC(const TopoDS_Vertex& V,const TopoDS_Edge& E);
|
||||
|
||||
Standard_EXPORT void Initialize(const TopoDS_Edge& E);
|
||||
//! An exception is raised if the fields have not been initialized. <br>
|
||||
Standard_EXPORT void Perform(const TopoDS_Vertex& V);
|
||||
//! True if the distances are found. <br>
|
||||
Standard_EXPORT Standard_Boolean IsDone() const
|
||||
{
|
||||
return myExtPC.IsDone();
|
||||
}
|
||||
//! Returns the number of extremum distances. <br>
|
||||
Standard_EXPORT Standard_Integer NbExt() const
|
||||
{
|
||||
return myExtPC.NbExt();
|
||||
}
|
||||
//! Returns True if the <N>th extremum distance is a minimum. <br>
|
||||
Standard_EXPORT Standard_Boolean IsMin(const Standard_Integer N) const
|
||||
{
|
||||
return myExtPC.IsMin(N);
|
||||
}
|
||||
//! Returns the value of the <N>th extremum square distance. <br>
|
||||
Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
|
||||
{
|
||||
return myExtPC.SquareDistance(N);
|
||||
}
|
||||
//! Returns the parameter on the edge of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT Standard_Real Parameter(const Standard_Integer N) const
|
||||
{
|
||||
return myExtPC.Point(N).Parameter();
|
||||
}
|
||||
//! Returns the Point of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT gp_Pnt Point(const Standard_Integer N) const
|
||||
{
|
||||
return myExtPC.Point(N).Value();
|
||||
}
|
||||
//! if the curve is a trimmed curve, <br>
|
||||
//! dist1 is a square distance between <P> and the point <br>
|
||||
//! of parameter FirstParameter <pnt1> and <br>
|
||||
//! dist2 is a square distance between <P> and the point <br>
|
||||
//! of parameter LastParameter <pnt2>. <br>
|
||||
Standard_EXPORT void TrimmedSquareDistances(Standard_Real& dist1,Standard_Real& dist2,gp_Pnt& pnt1,gp_Pnt& pnt2) const
|
||||
{
|
||||
myExtPC.TrimmedSquareDistances(dist1,dist2,pnt1,pnt2);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Extrema_ExtPC myExtPC;
|
||||
Handle_BRepAdaptor_HCurve myHC;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,41 +1,27 @@
|
||||
// File: BRepExtrema_ExtPF.cxx
|
||||
// Created: Wed Dec 15 16:48:53 1993
|
||||
// Author: Christophe MARION
|
||||
// <cma@sdsun1>
|
||||
// modified by MPS (june 96) : on utilise BRepClass_FaceClassifier seulement
|
||||
// si IsDone de Extrema est vrai
|
||||
#include <BRepExtrema_ExtPF.ixx>
|
||||
|
||||
#include <BRepExtrema_ExtPF.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <StdFail_NotDone.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_HCurve.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ExtPF
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtPF::BRepExtrema_ExtPF()
|
||||
BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace,
|
||||
const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepExtrema_ExtPF
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
BRepExtrema_ExtPF::BRepExtrema_ExtPF
|
||||
(const TopoDS_Vertex& V,
|
||||
const TopoDS_Face& E)
|
||||
{
|
||||
Initialize(E);
|
||||
Perform(V, E);
|
||||
Initialize(TheFace,TheFlag,TheAlgo);
|
||||
Perform(TheVertex,TheFace);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -43,15 +29,18 @@ BRepExtrema_ExtPF::BRepExtrema_ExtPF
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& F)
|
||||
void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
|
||||
const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
|
||||
{
|
||||
// cette surface doit etre en champ. Extrema ne fait
|
||||
// pas de copie et prend seulement un pointeur dessus.
|
||||
mySurf.Initialize(F, Standard_False);
|
||||
Standard_Real Tol = BRep_Tool::Tolerance(F);
|
||||
mySurf.Initialize(TheFace, Standard_False);
|
||||
const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
|
||||
Standard_Real U1, U2, V1, V2;
|
||||
BRepTools::UVBounds(F, U1, U2, V1, V2);
|
||||
myExtrem.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
|
||||
BRepTools::UVBounds(TheFace, U1, U2, V1, V2);
|
||||
myExtPS.SetFlag(TheFlag);
|
||||
myExtPS.SetAlgo(TheAlgo);
|
||||
myExtPS.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@ -59,95 +48,31 @@ void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& F)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& V,
|
||||
const TopoDS_Face& E)
|
||||
void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace)
|
||||
{
|
||||
mySqDist.Clear();
|
||||
myPoints.Clear();
|
||||
gp_Pnt P = BRep_Tool::Pnt(V);
|
||||
myExtrem.Perform(P);
|
||||
|
||||
// exploration des points et classification:
|
||||
if (myExtrem.IsDone()) {
|
||||
BRepClass_FaceClassifier classifier;
|
||||
gp_Pnt2d Puv;
|
||||
Standard_Real U1, U2;
|
||||
TopAbs_State state;
|
||||
Standard_Real Tol = BRep_Tool::Tolerance(E);
|
||||
mynbext = 0;
|
||||
for (Standard_Integer i = 1; i <= myExtrem.NbExt(); i++) {
|
||||
myExtrem.Point(i).Parameter(U1, U2);
|
||||
Puv.SetCoord(U1, U2);
|
||||
classifier.Perform(E, Puv, Tol);
|
||||
state = classifier.State();
|
||||
if(state == TopAbs_ON || state == TopAbs_IN) {
|
||||
mynbext++;
|
||||
mySqDist.Append(myExtrem.SquareDistance(i));
|
||||
myPoints.Append(myExtrem.Point(i));
|
||||
const gp_Pnt P = BRep_Tool::Pnt(TheVertex);
|
||||
myExtPS.Perform(P);
|
||||
|
||||
// Exploration of points and classification
|
||||
if (myExtPS.IsDone())
|
||||
{
|
||||
BRepClass_FaceClassifier classifier;
|
||||
Standard_Real U1, U2;
|
||||
const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
|
||||
for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++)
|
||||
{
|
||||
myExtPS.Point(i).Parameter(U1, U2);
|
||||
const gp_Pnt2d Puv(U1, U2);
|
||||
classifier.Perform(TheFace, Puv, Tol);
|
||||
const TopAbs_State state = classifier.State();
|
||||
if(state == TopAbs_ON || state == TopAbs_IN)
|
||||
{
|
||||
mySqDist.Append(myExtPS.SquareDistance(i));
|
||||
myPoints.Append(myExtPS.Point(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_ExtPF::IsDone()const
|
||||
{
|
||||
return myExtrem.IsDone();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbExt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer BRepExtrema_ExtPF::NbExt() const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
return mynbext;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepExtrema_ExtPF::SquareDistance
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
return mySqDist.Value(N);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Parameters
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
|
||||
void BRepExtrema_ExtPF::Parameter(const Standard_Integer N,
|
||||
Standard_Real& U,
|
||||
Standard_Real& V) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
myPoints.Value(N).Parameter(U, V);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Point
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepExtrema_ExtPF::Point
|
||||
(const Standard_Integer N) const
|
||||
{
|
||||
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
|
||||
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
|
||||
gp_Pnt P = myPoints.Value(N).Value();
|
||||
return P;
|
||||
}
|
||||
|
139
src/BRepExtrema/BRepExtrema_ExtPF.hxx
Normal file
139
src/BRepExtrema/BRepExtrema_ExtPF.hxx
Normal file
@ -0,0 +1,139 @@
|
||||
// File generated by CPPExt (Value)
|
||||
//
|
||||
// Copyright (C) 1991 - 2000 by
|
||||
// Matra Datavision SA. All rights reserved.
|
||||
//
|
||||
// Copyright (C) 2001 - 2004 by
|
||||
// Open CASCADE SA. All rights reserved.
|
||||
//
|
||||
// This file is part of the Open CASCADE Technology software.
|
||||
//
|
||||
// This software may be distributed and/or modified under the terms and
|
||||
// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
|
||||
// and appearing in the file LICENSE included in the packaging of this file.
|
||||
//
|
||||
// This software is distributed on an "AS IS" basis, without warranty of any
|
||||
// kind, and Open CASCADE SA hereby disclaims all such warranties,
|
||||
// including without limitation, any warranties of merchantability, fitness
|
||||
// for a particular purpose or non-infringement. Please see the License for
|
||||
// the specific terms and conditions governing rights and limitations under the
|
||||
// License.
|
||||
|
||||
#ifndef _BRepExtrema_ExtPF_HeaderFile
|
||||
#define _BRepExtrema_ExtPF_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Extrema_ExtPS_HeaderFile
|
||||
#include <Extrema_ExtPS.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Integer_HeaderFile
|
||||
#include <Standard_Integer.hxx>
|
||||
#endif
|
||||
#ifndef _TColStd_SequenceOfReal_HeaderFile
|
||||
#include <TColStd_SequenceOfReal.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_SequenceOfPOnSurf_HeaderFile
|
||||
#include <Extrema_SequenceOfPOnSurf.hxx>
|
||||
#endif
|
||||
#ifndef _BRepAdaptor_Surface_HeaderFile
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_ExtFlag_HeaderFile
|
||||
#include <Extrema_ExtFlag.hxx>
|
||||
#endif
|
||||
#ifndef _Extrema_ExtAlgo_HeaderFile
|
||||
#include <Extrema_ExtAlgo.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
class TopoDS_Vertex;
|
||||
class TopoDS_Face;
|
||||
class gp_Pnt;
|
||||
|
||||
|
||||
class BRepExtrema_ExtPF
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
Standard_EXPORT BRepExtrema_ExtPF()
|
||||
{}
|
||||
//! It calculates all the distances. <br>
|
||||
Standard_EXPORT BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex,const TopoDS_Face& TheFace,
|
||||
const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX,
|
||||
const Extrema_ExtAlgo TheAlgo = Extrema_ExtAlgo_Grad);
|
||||
|
||||
Standard_EXPORT void Initialize(const TopoDS_Face& TheFace,
|
||||
const Extrema_ExtFlag TheFlag = Extrema_ExtFlag_MINMAX,
|
||||
const Extrema_ExtAlgo TheAlgo = Extrema_ExtAlgo_Grad);
|
||||
|
||||
//! An exception is raised if the fields have not been initialized. <br>
|
||||
//! Be careful: this method uses the Face only for classify not for the fields. <br>
|
||||
Standard_EXPORT void Perform(const TopoDS_Vertex& TheVertex,const TopoDS_Face& TheFace);
|
||||
//! True if the distances are found. <br>
|
||||
Standard_EXPORT Standard_Boolean IsDone() const
|
||||
{
|
||||
return myExtPS.IsDone();
|
||||
}
|
||||
//! Returns the number of extremum distances. <br>
|
||||
Standard_EXPORT Standard_Integer NbExt() const
|
||||
{
|
||||
return myPoints.Length();
|
||||
}
|
||||
//! Returns the value of the <N>th extremum square distance. <br>
|
||||
Standard_EXPORT Standard_Real SquareDistance(const Standard_Integer N) const
|
||||
{
|
||||
return mySqDist.Value(N);
|
||||
}
|
||||
//! Returns the parameters on the Face of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT void Parameter(const Standard_Integer N,Standard_Real& U,Standard_Real& V) const
|
||||
{
|
||||
myPoints.Value(N).Parameter(U, V);
|
||||
}
|
||||
//! Returns the Point of the <N>th extremum distance. <br>
|
||||
Standard_EXPORT gp_Pnt Point(const Standard_Integer N) const
|
||||
{
|
||||
return myPoints.Value(N).Value();
|
||||
}
|
||||
|
||||
Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
|
||||
{
|
||||
myExtPS.SetFlag(F);
|
||||
}
|
||||
|
||||
Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
|
||||
{
|
||||
myExtPS.SetAlgo(A);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Extrema_ExtPS myExtPS;
|
||||
TColStd_SequenceOfReal mySqDist;
|
||||
Extrema_SequenceOfPOnSurf myPoints;
|
||||
BRepAdaptor_Surface mySurf;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,9 +1,9 @@
|
||||
// File: BRepExtrema_Poly.cxx
|
||||
// Created: Fri Sep 8 11:03:14 1995
|
||||
// Author: Christophe MARION
|
||||
// <cma@ecolox>
|
||||
|
||||
#include <BRepExtrema_Poly.ixx>
|
||||
#include <BRepExtrema_Poly.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
@ -17,56 +17,58 @@
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1,
|
||||
const TopoDS_Shape& S2,
|
||||
gp_Pnt& P1,
|
||||
gp_Pnt& P2,
|
||||
Standard_Real& dist)
|
||||
Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1, const TopoDS_Shape& S2,
|
||||
gp_Pnt& P1, gp_Pnt& P2, Standard_Real& dist)
|
||||
{
|
||||
Standard_Real dCur;
|
||||
dist = Precision::Infinite();
|
||||
Standard_Integer i,i1,i2,n;
|
||||
TopExp_Explorer exFace;
|
||||
Handle(Poly_Triangulation) Tr;
|
||||
TopLoc_Location L;
|
||||
Standard_Integer nbn1 = 0;
|
||||
|
||||
TopLoc_Location L;
|
||||
Handle(Poly_Triangulation) Tr;
|
||||
TopExp_Explorer exFace;
|
||||
|
||||
Standard_Integer nbn1 = 0;
|
||||
for (exFace.Init(S1, TopAbs_FACE);
|
||||
exFace.More();
|
||||
exFace.Next()) {
|
||||
exFace.Next())
|
||||
{
|
||||
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
|
||||
Tr = BRep_Tool::Triangulation(F,L);
|
||||
if (!Tr.IsNull())
|
||||
nbn1 += Tr->NbNodes();
|
||||
}
|
||||
if (nbn1 == 0) return Standard_False;
|
||||
|
||||
Standard_Integer nbn2 = 0;
|
||||
|
||||
for (exFace.Init(S2, TopAbs_FACE);
|
||||
exFace.More();
|
||||
exFace.Next()) {
|
||||
exFace.Next())
|
||||
{
|
||||
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
|
||||
Tr = BRep_Tool::Triangulation(F,L);
|
||||
if (!Tr.IsNull())
|
||||
nbn2 += Tr->NbNodes();
|
||||
}
|
||||
if (nbn2 == 0) return Standard_False;
|
||||
|
||||
if (nbn1 == 0 || nbn2 == 0) return Standard_False;
|
||||
Standard_Integer i,n;
|
||||
|
||||
TColgp_Array1OfPnt TP1(1,nbn1);
|
||||
nbn1 = 0;
|
||||
|
||||
for (exFace.Init(S1, TopAbs_FACE);
|
||||
exFace.More();
|
||||
exFace.Next()) {
|
||||
exFace.Next())
|
||||
{
|
||||
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
|
||||
Tr = BRep_Tool::Triangulation(F,L);
|
||||
if (!Tr.IsNull()) {
|
||||
if (!Tr.IsNull())
|
||||
{
|
||||
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
|
||||
n = Tr->NbNodes();
|
||||
|
||||
for (i = 1;i <= n; i++) {
|
||||
nbn1++;
|
||||
TP1.SetValue(nbn1,Nod(i).Transformed(L));
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
nbn1++;
|
||||
TP1.SetValue(nbn1,Nod(i).Transformed(L));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -76,34 +78,37 @@ Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1,
|
||||
|
||||
for (exFace.Init(S2, TopAbs_FACE);
|
||||
exFace.More();
|
||||
exFace.Next()) {
|
||||
exFace.Next())
|
||||
{
|
||||
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
|
||||
Tr = BRep_Tool::Triangulation(F,L);
|
||||
if (!Tr.IsNull()) {
|
||||
if (!Tr.IsNull())
|
||||
{
|
||||
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
|
||||
n = Tr->NbNodes();
|
||||
|
||||
for (i = 1;i <= n; i++) {
|
||||
nbn2++;
|
||||
TP2.SetValue(nbn2,Nod(i).Transformed(L));
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
nbn2++;
|
||||
TP2.SetValue(nbn2,Nod(i).Transformed(L));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i1 = 1; i1 <= nbn1; i1++) {
|
||||
gp_Pnt& PP1 = TP1(i1);
|
||||
|
||||
for (i2 = 1; i2 <= nbn2; i2++) {
|
||||
gp_Pnt& PP2 = TP2(i2);
|
||||
|
||||
dCur = PP1.Distance(PP2);
|
||||
if (dist > dCur) {
|
||||
P1 = PP1;
|
||||
P2 = PP2;
|
||||
dist = dCur;
|
||||
|
||||
Standard_Integer i1,i2;
|
||||
for (i1 = 1; i1 <= nbn1; i1++)
|
||||
{
|
||||
const gp_Pnt& PP1 = TP1(i1);
|
||||
for (i2 = 1; i2 <= nbn2; i2++)
|
||||
{
|
||||
const gp_Pnt& PP2 = TP2(i2);
|
||||
const Standard_Real dCur = PP1.Distance(PP2);
|
||||
if (dist > dCur)
|
||||
{
|
||||
P1 = PP1;
|
||||
P2 = PP2;
|
||||
dist = dCur;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
34
src/BRepExtrema/BRepExtrema_Poly.hxx
Normal file
34
src/BRepExtrema/BRepExtrema_Poly.hxx
Normal file
@ -0,0 +1,34 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_Poly_HeaderFile
|
||||
#define _BRepExtrema_Poly_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Standard_Boolean_HeaderFile
|
||||
#include <Standard_Boolean.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
class TopoDS_Shape;
|
||||
class gp_Pnt;
|
||||
|
||||
|
||||
class BRepExtrema_Poly
|
||||
{
|
||||
public:
|
||||
|
||||
//! returns Standard_True if OK. <br>
|
||||
Standard_EXPORT static Standard_Boolean Distance(const TopoDS_Shape& S1,const TopoDS_Shape& S2,gp_Pnt& P1,gp_Pnt& P2,Standard_Real& dist);
|
||||
};
|
||||
|
||||
#endif
|
18
src/BRepExtrema/BRepExtrema_SeqOfSolution.hxx
Normal file
18
src/BRepExtrema/BRepExtrema_SeqOfSolution.hxx
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
|
||||
#define _BRepExtrema_SeqOfSolution_HeaderFile
|
||||
|
||||
#ifndef _NCollection_Sequence_HeaderFile
|
||||
#include <NCollection_Sequence.hxx>
|
||||
#endif
|
||||
#ifndef _BRepExtrema_SolutionElem_HeaderFile
|
||||
#include <BRepExtrema_SolutionElem.hxx>
|
||||
#endif
|
||||
|
||||
typedef NCollection_Sequence<BRepExtrema_SolutionElem> BRepExtrema_SeqOfSolution;
|
||||
|
||||
#endif
|
156
src/BRepExtrema/BRepExtrema_SolutionElem.hxx
Normal file
156
src/BRepExtrema/BRepExtrema_SolutionElem.hxx
Normal file
@ -0,0 +1,156 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_SolutionElem_HeaderFile
|
||||
#define _BRepExtrema_SolutionElem_HeaderFile
|
||||
|
||||
#ifndef _Standard_HeaderFile
|
||||
#include <Standard.hxx>
|
||||
#endif
|
||||
#ifndef _Standard_Macro_HeaderFile
|
||||
#include <Standard_Macro.hxx>
|
||||
#endif
|
||||
|
||||
#ifndef _Standard_Real_HeaderFile
|
||||
#include <Standard_Real.hxx>
|
||||
#endif
|
||||
#ifndef _gp_Pnt_HeaderFile
|
||||
#include <gp_Pnt.hxx>
|
||||
#endif
|
||||
#ifndef _BRepExtrema_SupportType_HeaderFile
|
||||
#include <BRepExtrema_SupportType.hxx>
|
||||
#endif
|
||||
#ifndef _TopoDS_Vertex_HeaderFile
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#endif
|
||||
#ifndef _TopoDS_Edge_HeaderFile
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#endif
|
||||
#ifndef _TopoDS_Face_HeaderFile
|
||||
#include <TopoDS_Face.hxx>
|
||||
#endif
|
||||
class gp_Pnt;
|
||||
class TopoDS_Vertex;
|
||||
class TopoDS_Edge;
|
||||
class TopoDS_Face;
|
||||
|
||||
|
||||
//! This class is used to store information relative to the <br>
|
||||
//! minimum distance between two shapes. <br>
|
||||
class BRepExtrema_SolutionElem
|
||||
{
|
||||
public:
|
||||
|
||||
void* operator new(size_t,void* anAddress)
|
||||
{
|
||||
return anAddress;
|
||||
}
|
||||
void* operator new(size_t size)
|
||||
{
|
||||
return Standard::Allocate(size);
|
||||
}
|
||||
void operator delete(void *anAddress)
|
||||
{
|
||||
if (anAddress) Standard::Free((Standard_Address&)anAddress);
|
||||
}
|
||||
|
||||
|
||||
Standard_EXPORT BRepExtrema_SolutionElem()
|
||||
: myDist(0.), myPoint(0.,0.,0.), mySupType(BRepExtrema_IsVertex), myPar1(0.), myPar2(0.)
|
||||
{
|
||||
}
|
||||
//! initialisation of the fields <br>
|
||||
//! This constructor is used when the solution of a distance is a Vertex. <br>
|
||||
//! The different initialized fields are: <br>
|
||||
//! _ the distance d <br>
|
||||
//! _ the solution point <br>
|
||||
//! _ the type of solution <br>
|
||||
//! _ and the Vertex. <br>
|
||||
Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Vertex& vertex)
|
||||
: myDist(d), myPoint(Pt), mySupType(SolType), myVertex(vertex), myPar1(0.), myPar2(0.)
|
||||
{
|
||||
}
|
||||
//! initialisation of the fiels. <br>
|
||||
//! This constructor is used when the solution of distance is on an Edge. <br>
|
||||
//! The different initialized fields are: <br>
|
||||
//! _ the distance d, <br>
|
||||
//! _ the solution point, <br>
|
||||
//! _ the type of solution, <br>
|
||||
//! _ the Edge, <br>
|
||||
//! _ and the parameter t to locate the solution. <br>
|
||||
Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Edge& edge,const Standard_Real t)
|
||||
: myDist(d), myPoint(Pt), mySupType(SolType), myEdge(edge), myPar1(t), myPar2(0.)
|
||||
{
|
||||
}
|
||||
//! initialisation of the fields <br>
|
||||
//! This constructor is used when the solution of distance is in <br>
|
||||
//! a Face. The different initialized fields are: <br>
|
||||
//! _ the distance d, <br>
|
||||
//! _ the solution point, <br>
|
||||
//! _ the type of solution, <br>
|
||||
//! _ the Face, <br>
|
||||
//! _ and the parameter u et v to locate the solution. <br>
|
||||
Standard_EXPORT BRepExtrema_SolutionElem(const Standard_Real d,const gp_Pnt& Pt,const BRepExtrema_SupportType SolType,const TopoDS_Face& face,const Standard_Real u,const Standard_Real v)
|
||||
: myDist(d), myPoint(Pt), mySupType(SolType), myFace(face), myPar1(u), myPar2(v)
|
||||
{
|
||||
}
|
||||
//! returns the value of the minimum distance. <br>
|
||||
Standard_EXPORT Standard_Real Dist() const
|
||||
{
|
||||
return myDist;
|
||||
}
|
||||
//! returns the solution point. <br>
|
||||
Standard_EXPORT const gp_Pnt & Point() const
|
||||
{
|
||||
return myPoint;
|
||||
}
|
||||
//! returns the Support type : <br>
|
||||
//! IsVertex => The solution is a vertex. <br>
|
||||
//! IsOnEdge => The solution belongs to an Edge. <br>
|
||||
//! IsInFace => The solution is inside a Face. <br>
|
||||
Standard_EXPORT BRepExtrema_SupportType SupportKind() const
|
||||
{
|
||||
return mySupType;
|
||||
}
|
||||
//! returns the vertex if the solution is a Vertex. <br>
|
||||
Standard_EXPORT const TopoDS_Vertex & Vertex() const
|
||||
{
|
||||
return myVertex;
|
||||
}
|
||||
//! returns the vertex if the solution is an Edge. <br>
|
||||
Standard_EXPORT const TopoDS_Edge & Edge() const
|
||||
{
|
||||
return myEdge;
|
||||
}
|
||||
//! returns the vertex if the solution is an Face. <br>
|
||||
Standard_EXPORT const TopoDS_Face & Face() const
|
||||
{
|
||||
return myFace;
|
||||
}
|
||||
//! returns the parameter t if the solution is on Edge. <br>
|
||||
Standard_EXPORT void EdgeParameter(Standard_Real& par1) const
|
||||
{
|
||||
par1 = myPar1;
|
||||
}
|
||||
//! returns the parameters u et v if the solution is in a Face. <br>
|
||||
Standard_EXPORT void FaceParameter(Standard_Real& par1,Standard_Real& par2) const
|
||||
{
|
||||
par1 = myPar1;
|
||||
par2 = myPar2;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Standard_Real myDist;
|
||||
gp_Pnt myPoint;
|
||||
BRepExtrema_SupportType mySupType;
|
||||
TopoDS_Vertex myVertex;
|
||||
TopoDS_Edge myEdge;
|
||||
TopoDS_Face myFace;
|
||||
Standard_Real myPar1;
|
||||
Standard_Real myPar2;
|
||||
};
|
||||
|
||||
#endif
|
20
src/BRepExtrema/BRepExtrema_SupportType.hxx
Normal file
20
src/BRepExtrema/BRepExtrema_SupportType.hxx
Normal file
@ -0,0 +1,20 @@
|
||||
// This file is generated by WOK (CPPExt).
|
||||
// Please do not edit this file; modify original file instead.
|
||||
// The copyright and license terms as defined for the original file apply to
|
||||
// this header file considered to be the "object code" form of the original source.
|
||||
|
||||
#ifndef _BRepExtrema_SupportType_HeaderFile
|
||||
#define _BRepExtrema_SupportType_HeaderFile
|
||||
|
||||
enum BRepExtrema_SupportType
|
||||
{
|
||||
BRepExtrema_IsVertex,
|
||||
BRepExtrema_IsOnEdge,
|
||||
BRepExtrema_IsInFace
|
||||
};
|
||||
|
||||
#ifndef _Standard_PrimitiveTypes_HeaderFile
|
||||
#include <Standard_PrimitiveTypes.hxx>
|
||||
#endif
|
||||
|
||||
#endif
|
19
src/BRepExtrema/FILES
Normal file
19
src/BRepExtrema/FILES
Normal file
@ -0,0 +1,19 @@
|
||||
BRepExtrema_DistanceSS.hxx
|
||||
BRepExtrema_DistanceSS.cxx
|
||||
BRepExtrema_DistShapeShape.hxx
|
||||
BRepExtrema_DistShapeShape.cxx
|
||||
BRepExtrema_ExtCC.hxx
|
||||
BRepExtrema_ExtCC.cxx
|
||||
BRepExtrema_ExtCF.hxx
|
||||
BRepExtrema_ExtCF.cxx
|
||||
BRepExtrema_ExtFF.hxx
|
||||
BRepExtrema_ExtFF.cxx
|
||||
BRepExtrema_ExtPC.hxx
|
||||
BRepExtrema_ExtPC.cxx
|
||||
BRepExtrema_ExtPF.hxx
|
||||
BRepExtrema_ExtPF.cxx
|
||||
BRepExtrema_Poly.hxx
|
||||
BRepExtrema_Poly.cxx
|
||||
BRepExtrema_SeqOfSolution.hxx
|
||||
BRepExtrema_SolutionElem.hxx
|
||||
BRepExtrema_SupportType.hxx
|
@ -47,7 +47,8 @@ package Bnd
|
||||
uses Standard,
|
||||
TCollection,
|
||||
TColStd,
|
||||
gp
|
||||
gp,
|
||||
MMgt
|
||||
|
||||
|
||||
is class Box;
|
||||
@ -59,6 +60,13 @@ is class Box;
|
||||
(Box from Bnd,
|
||||
Array1OfBox from Bnd);
|
||||
|
||||
class Sphere;
|
||||
class Array1OfSphere instantiates Array1 from TCollection
|
||||
(Sphere from Bnd);
|
||||
class HArray1OfSphere instantiates HArray1 from TCollection
|
||||
(Sphere from Bnd,
|
||||
Array1OfSphere from Bnd);
|
||||
|
||||
|
||||
class Box2d;
|
||||
---Purpose: A rectangle parallel to the main axes.
|
||||
|
86
src/Bnd/Bnd_Sphere.cdl
Normal file
86
src/Bnd/Bnd_Sphere.cdl
Normal file
@ -0,0 +1,86 @@
|
||||
-- File: Bnd_Sphere.cdl
|
||||
-- Created: Fri Dec 3 17:39:44 2010
|
||||
-- Author: Artem SHAL
|
||||
---Copyright: OPEN CASCADE 2010
|
||||
|
||||
class Sphere from Bnd
|
||||
|
||||
---Purpose: This class represents a bounding sphere of a geometric entity
|
||||
-- (triangle, segment of line or whatever else).
|
||||
|
||||
uses XYZ from gp
|
||||
|
||||
is
|
||||
|
||||
Create returns Sphere;
|
||||
---Purpose: Empty constructor
|
||||
|
||||
Create (theCntr : XYZ from gp; theRad : Real; theU : Integer; theV : Integer)
|
||||
returns Sphere;
|
||||
---Purpose: Constructor of a definite sphere
|
||||
|
||||
U (me) returns Integer;
|
||||
---C++: inline
|
||||
---Purpose: Returns the U parameter on shape
|
||||
|
||||
V (me) returns Integer;
|
||||
---C++: inline
|
||||
---Purpose: Returns the V parameter on shape
|
||||
|
||||
IsValid (me) returns Boolean;
|
||||
---C++: inline
|
||||
---Purpose: Returns validity status, indicating that this
|
||||
-- sphere corresponds to a real entity
|
||||
|
||||
SetValid (me : in out; isValid : Boolean);
|
||||
---C++: inline
|
||||
|
||||
Center (me) returns XYZ from gp;
|
||||
---C++: inline
|
||||
---C++: return const &
|
||||
---Purpose: Returns center of sphere object
|
||||
|
||||
Radius (me) returns Real;
|
||||
---C++: inline
|
||||
---Purpose: Returns the radius value
|
||||
|
||||
Distances (me; theXYZ : XYZ from gp; theMin : in out Real; theMax : in out Real) is static;
|
||||
---Purpose: Calculate and return minimal and maximal distance to sphere.
|
||||
-- NOTE: This function is tightly optimized; any modifications
|
||||
-- may affect performance!
|
||||
|
||||
SquareDistances (me; theXYZ : XYZ from gp; theMin : in out Real; theMax : in out Real) is static;
|
||||
---Purpose: Calculate and return minimal and maximal distance to sphere.
|
||||
-- NOTE: This function is tightly optimized; any modifications
|
||||
-- may affect performance!
|
||||
|
||||
Project (me; theNode : XYZ from gp; theProjNode : in out XYZ from gp; theDist : in out Real; theInside : in out Boolean)
|
||||
---Purpose: Projects a point on entity.
|
||||
-- Returns true if success
|
||||
returns Boolean;
|
||||
|
||||
Distance (me; theNode : XYZ from gp)
|
||||
returns Real;
|
||||
|
||||
SquareDistance (me; theNode : XYZ from gp)
|
||||
returns Real;
|
||||
|
||||
Add (me : in out; theOther : Sphere from Bnd);
|
||||
|
||||
IsOut (me; theOther : Sphere from Bnd)
|
||||
returns Boolean;
|
||||
|
||||
IsOut (me; thePnt : XYZ from gp; theMaxDist : in out Real)
|
||||
returns Boolean;
|
||||
|
||||
SquareExtent (me) returns Real;
|
||||
|
||||
fields
|
||||
|
||||
myCenter : XYZ from gp;
|
||||
myRadius : Real;
|
||||
myIsValid : Boolean;
|
||||
myU : Integer;
|
||||
myV : Integer;
|
||||
|
||||
end Sphere;
|
102
src/Bnd/Bnd_Sphere.cxx
Normal file
102
src/Bnd/Bnd_Sphere.cxx
Normal file
@ -0,0 +1,102 @@
|
||||
#include <Bnd_Sphere.hxx>
|
||||
|
||||
Bnd_Sphere::Bnd_Sphere()
|
||||
: myCenter (0., 0., 0.),
|
||||
myRadius (0.),
|
||||
myIsValid (Standard_False),
|
||||
myU (0),
|
||||
myV (0)
|
||||
{}
|
||||
|
||||
Bnd_Sphere::Bnd_Sphere( const gp_XYZ& theCenter, const Standard_Real theRadius,
|
||||
const Standard_Integer theU, const Standard_Integer theV )
|
||||
: myCenter (theCenter),
|
||||
myRadius (theRadius),
|
||||
myIsValid (Standard_False),
|
||||
myU (theU),
|
||||
myV (theV)
|
||||
{}
|
||||
|
||||
void Bnd_Sphere::SquareDistances( const gp_XYZ& theXYZ,
|
||||
Standard_Real& theMin, Standard_Real& theMax ) const
|
||||
{
|
||||
theMax = ( theXYZ - myCenter ).SquareModulus();
|
||||
theMin = ( theMax - myRadius <0 ? 0.0 : theMax - myRadius * myRadius );
|
||||
theMax += myRadius * myRadius;
|
||||
}
|
||||
|
||||
void Bnd_Sphere::Distances( const gp_XYZ& theXYZ,
|
||||
Standard_Real& theMin, Standard_Real& theMax ) const
|
||||
{
|
||||
theMax = ( theXYZ - myCenter ).Modulus();
|
||||
theMin = ( theMax - myRadius <0 ? 0.0 : theMax - myRadius );
|
||||
theMax += myRadius;
|
||||
}
|
||||
|
||||
Standard_Boolean Bnd_Sphere::Project(const gp_XYZ& theNode, gp_XYZ& theProjNode, Standard_Real& theDist, Standard_Boolean& theInside) const
|
||||
{
|
||||
theProjNode = myCenter;
|
||||
theDist = ( theNode - theProjNode ).Modulus();
|
||||
theInside = Standard_True;
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
Standard_Real Bnd_Sphere::Distance(const gp_XYZ& theNode) const
|
||||
{
|
||||
return ( theNode - myCenter ).Modulus();
|
||||
}
|
||||
|
||||
Standard_Real Bnd_Sphere::SquareDistance(const gp_XYZ& theNode) const
|
||||
{
|
||||
return ( theNode - myCenter ).SquareModulus();
|
||||
}
|
||||
|
||||
void Bnd_Sphere::Add( const Bnd_Sphere& theOther)
|
||||
{
|
||||
if ( myRadius < 0.0 )
|
||||
{
|
||||
// not initialised yet
|
||||
*this = theOther;
|
||||
return;
|
||||
}
|
||||
|
||||
const Standard_Real aDist = (myCenter - theOther.myCenter).Modulus();
|
||||
if ( myRadius + aDist <= theOther.myRadius )
|
||||
{
|
||||
// the other sphere is larger and encloses this
|
||||
*this = theOther;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( theOther.myRadius + aDist <= myRadius )
|
||||
return; // this sphere encloses other
|
||||
|
||||
// expansion
|
||||
const Standard_Real dfR = ( aDist + myRadius + theOther.myRadius ) * 0.5;
|
||||
const Standard_Real aParamOnDiam = ( dfR - myRadius ) / aDist;
|
||||
myCenter = myCenter * ( 1.0 - aParamOnDiam ) + theOther.myCenter * aParamOnDiam;
|
||||
myRadius = dfR;
|
||||
myIsValid = Standard_False;
|
||||
}
|
||||
|
||||
Standard_Boolean Bnd_Sphere::IsOut( const Bnd_Sphere& theOther ) const
|
||||
{
|
||||
return (myCenter - theOther.myCenter).SquareModulus() > (myRadius + theOther.myRadius) * (myRadius + theOther.myRadius);
|
||||
}
|
||||
|
||||
Standard_Boolean Bnd_Sphere::IsOut( const gp_XYZ& theXYZ,
|
||||
Standard_Real& theMaxDist) const
|
||||
{
|
||||
Standard_Real aCurMinDist, aCurMaxDist;
|
||||
Distances( theXYZ, aCurMinDist, aCurMaxDist );
|
||||
if ( aCurMinDist > theMaxDist )
|
||||
return Standard_True;
|
||||
if( myIsValid && aCurMaxDist < theMaxDist )
|
||||
theMaxDist = aCurMaxDist;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Standard_Real Bnd_Sphere::SquareExtent() const
|
||||
{
|
||||
return 4 * myRadius * myRadius;
|
||||
}
|
30
src/Bnd/Bnd_Sphere.lxx
Normal file
30
src/Bnd/Bnd_Sphere.lxx
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
inline Standard_Integer Bnd_Sphere::U() const
|
||||
{
|
||||
return myU;
|
||||
}
|
||||
|
||||
inline Standard_Integer Bnd_Sphere::V() const
|
||||
{
|
||||
return myV;
|
||||
}
|
||||
|
||||
inline Standard_Boolean Bnd_Sphere::IsValid() const
|
||||
{
|
||||
return myIsValid;
|
||||
}
|
||||
|
||||
inline void Bnd_Sphere::SetValid(const Standard_Boolean isValid)
|
||||
{
|
||||
myIsValid = isValid;
|
||||
}
|
||||
|
||||
inline const gp_XYZ& Bnd_Sphere::Center() const
|
||||
{
|
||||
return myCenter;
|
||||
}
|
||||
|
||||
inline Standard_Real Bnd_Sphere::Radius() const
|
||||
{
|
||||
return myRadius;
|
||||
}
|
@ -30,10 +30,15 @@ uses
|
||||
Adaptor3d,
|
||||
Adaptor2d,
|
||||
Geom,
|
||||
Geom2d
|
||||
Geom2d,
|
||||
Bnd
|
||||
|
||||
is
|
||||
|
||||
enumeration ExtFlag is ExtFlag_MIN, ExtFlag_MAX, ExtFlag_MINMAX;
|
||||
|
||||
enumeration ExtAlgo is ExtAlgo_Grad, ExtAlgo_Tree;
|
||||
|
||||
class CurveTool;
|
||||
class Curve2dTool;
|
||||
|
||||
@ -70,6 +75,7 @@ is
|
||||
private class FuncExtPS;
|
||||
class GenExtPS;
|
||||
class GenLocateExtPS;
|
||||
imported HUBTreeOfSphere;
|
||||
|
||||
----------------------------------------------
|
||||
-- generic classes for CURVE-CURVE extremas:
|
||||
|
@ -20,7 +20,9 @@ uses
|
||||
SequenceOfReal from TColStd,
|
||||
Surface from Adaptor3d,
|
||||
SurfacePtr from Adaptor3d,
|
||||
GenExtPS from Extrema
|
||||
GenExtPS from Extrema,
|
||||
ExtFlag from Extrema,
|
||||
ExtAlgo from Extrema
|
||||
-- ExtPExtS from Extrema,
|
||||
-- ExtPRevS from Extrema
|
||||
|
||||
@ -35,7 +37,9 @@ is
|
||||
Create returns ExtPS;
|
||||
|
||||
|
||||
Create (P: Pnt from gp; S: Surface from Adaptor3d; TolU,TolV: Real)
|
||||
Create (P: Pnt from gp; S: Surface from Adaptor3d; TolU,TolV: Real;
|
||||
F : ExtFlag from Extrema = Extrema_ExtFlag_MINMAX;
|
||||
A : ExtAlgo from Extrema = Extrema_ExtAlgo_Grad)
|
||||
returns ExtPS;
|
||||
---Purpose: It calculates all the distances.
|
||||
-- NbU and NbV are used to locate the close points
|
||||
@ -48,7 +52,9 @@ is
|
||||
|
||||
Create (P: Pnt from gp; S: Surface from Adaptor3d;
|
||||
Uinf, Usup, Vinf, Vsup: Real;
|
||||
TolU,TolV: Real)
|
||||
TolU,TolV: Real;
|
||||
F : ExtFlag from Extrema = Extrema_ExtFlag_MINMAX;
|
||||
A : ExtAlgo from Extrema = Extrema_ExtAlgo_Grad)
|
||||
returns ExtPS;
|
||||
---Purpose: It calculates all the distances.
|
||||
-- NbU and NbV are used to locate the close points
|
||||
@ -114,6 +120,12 @@ is
|
||||
-- dUlVl is a square distance between <P> and the point
|
||||
-- of parameter LastUParameter and LastVParameter <PUlVl>.
|
||||
is static;
|
||||
|
||||
SetFlag(me : in out; F : ExtFlag from Extrema)
|
||||
is static;
|
||||
|
||||
SetAlgo(me : in out; A : ExtAlgo from Extrema)
|
||||
is static;
|
||||
|
||||
|
||||
Bidon(me) returns SurfacePtr from Adaptor3d
|
||||
|
@ -52,6 +52,9 @@ static Standard_Boolean IsoIsDeg (const Adaptor3d_Surface& S,
|
||||
if(Step < Precision::PConfusion()) {
|
||||
return Standard_False;
|
||||
}
|
||||
if(Step < Precision::PConfusion()) {
|
||||
return Standard_False;
|
||||
}
|
||||
D1NormMax=0.;
|
||||
for (T=U1;T<=U2;T=T+Step)
|
||||
{
|
||||
@ -68,6 +71,9 @@ static Standard_Boolean IsoIsDeg (const Adaptor3d_Surface& S,
|
||||
if(Step < Precision::PConfusion()) {
|
||||
return Standard_False;
|
||||
}
|
||||
if(Step < Precision::PConfusion()) {
|
||||
return Standard_False;
|
||||
}
|
||||
D1NormMax=0.;
|
||||
for (T=V1;T<=V2;T=T+Step)
|
||||
{
|
||||
@ -126,9 +132,13 @@ Extrema_ExtPS::Extrema_ExtPS()
|
||||
Extrema_ExtPS::Extrema_ExtPS(const gp_Pnt& P,
|
||||
const Adaptor3d_Surface& S,
|
||||
const Standard_Real TolU,
|
||||
const Standard_Real TolV)
|
||||
const Standard_Real TolV,
|
||||
const Extrema_ExtFlag F,
|
||||
const Extrema_ExtAlgo A)
|
||||
|
||||
{
|
||||
myExtPS.SetFlag(F);
|
||||
myExtPS.SetAlgo(A);
|
||||
Initialize(S, S.FirstUParameter(), S.LastUParameter(),
|
||||
S.FirstVParameter(), S.LastVParameter(),
|
||||
TolU, TolV);
|
||||
@ -147,9 +157,13 @@ Extrema_ExtPS::Extrema_ExtPS(const gp_Pnt& P,
|
||||
const Standard_Real Vinf,
|
||||
const Standard_Real Vsup,
|
||||
const Standard_Real TolU,
|
||||
const Standard_Real TolV)
|
||||
const Standard_Real TolV,
|
||||
const Extrema_ExtFlag F,
|
||||
const Extrema_ExtAlgo A)
|
||||
|
||||
{
|
||||
myExtPS.SetFlag(F);
|
||||
myExtPS.SetAlgo(A);
|
||||
Initialize(S, Uinf, Usup, Vinf, Vsup, TolU, TolV);
|
||||
Perform(P);
|
||||
}
|
||||
@ -336,3 +350,13 @@ void Extrema_ExtPS::TrimmedSquareDistances(Standard_Real& dUfVf,
|
||||
PUlVf = P21;
|
||||
PUlVl = P22;
|
||||
}
|
||||
|
||||
void Extrema_ExtPS::SetFlag(const Extrema_ExtFlag F)
|
||||
{
|
||||
myExtPS.SetFlag(F);
|
||||
}
|
||||
|
||||
void Extrema_ExtPS::SetAlgo(const Extrema_ExtAlgo A)
|
||||
{
|
||||
myExtPS.SetAlgo(A);
|
||||
}
|
@ -13,10 +13,15 @@ class GenExtPS from Extrema
|
||||
|
||||
uses POnSurf from Extrema,
|
||||
Pnt from gp,
|
||||
HArray2OfPnt from TColgp,
|
||||
FuncExtPS from Extrema,
|
||||
Surface from Adaptor3d,
|
||||
SurfacePtr from Adaptor3d
|
||||
SurfacePtr from Adaptor3d,
|
||||
HUBTreeOfSphere from Extrema,
|
||||
ExtFlag from Extrema,
|
||||
ExtAlgo from Extrema,
|
||||
HArray1OfSphere from Bnd,
|
||||
Vector from math,
|
||||
HArray2OfPnt from TColgp
|
||||
|
||||
raises NotDone from StdFail,
|
||||
OutOfRange from Standard,
|
||||
@ -27,7 +32,7 @@ is
|
||||
|
||||
Create returns GenExtPS;
|
||||
|
||||
Create (P: Pnt; S: Surface from Adaptor3d; NbU,NbV: Integer; TolU,TolV: Real)
|
||||
Create (P: Pnt; S: Surface from Adaptor3d; NbU,NbV: Integer; TolU,TolV: Real; F : ExtFlag from Extrema = Extrema_ExtFlag_MINMAX; A : ExtAlgo from Extrema = Extrema_ExtAlgo_Grad)
|
||||
returns GenExtPS;
|
||||
---Purpose: It calculates all the distances.
|
||||
-- The function F(u,v)=distance(P,S(u,v)) has an
|
||||
@ -44,7 +49,7 @@ is
|
||||
|
||||
|
||||
Create (P: Pnt; S: Surface from Adaptor3d; NbU,NbV: Integer;
|
||||
Umin, Usup, Vmin, Vsup: Real; TolU,TolV: Real)
|
||||
Umin, Usup, Vmin, Vsup: Real; TolU,TolV: Real; F : ExtFlag from Extrema = Extrema_ExtFlag_MINMAX; A : ExtAlgo from Extrema = Extrema_ExtAlgo_Grad)
|
||||
returns GenExtPS;
|
||||
---Purpose: It calculates all the distances.
|
||||
-- The function F(u,v)=distance(P,S(u,v)) has an
|
||||
@ -77,6 +82,12 @@ is
|
||||
-- been initialized.
|
||||
raises TypeMismatch from Standard
|
||||
is static;
|
||||
|
||||
SetFlag(me : in out; F : ExtFlag from Extrema)
|
||||
is static;
|
||||
|
||||
SetAlgo(me : in out; A : ExtAlgo from Extrema)
|
||||
is static;
|
||||
|
||||
|
||||
IsDone (me) returns Boolean
|
||||
@ -107,6 +118,12 @@ is
|
||||
|
||||
Bidon(me) returns SurfacePtr from Adaptor3d
|
||||
is static private;
|
||||
|
||||
BuildTree(me : in out)
|
||||
is static private;
|
||||
|
||||
FindSolution(me: in out; P : Pnt from gp; UV : Vector from math; PasU, PasV : Real; f : ExtFlag from Extrema)
|
||||
is static private;
|
||||
|
||||
fields
|
||||
myDone : Boolean;
|
||||
@ -117,10 +134,14 @@ fields
|
||||
myvsup : Real;
|
||||
myusample : Integer;
|
||||
myvsample : Integer;
|
||||
mypoints : HArray2OfPnt from TColgp;
|
||||
mytolu : Real;
|
||||
mytolv : Real;
|
||||
mypoints : HArray2OfPnt from TColgp;
|
||||
mySphereUBTree : HUBTreeOfSphere from Extrema;
|
||||
mySphereArray : HArray1OfSphere from Bnd;
|
||||
myF : FuncExtPS from Extrema;
|
||||
myS : SurfacePtr from Adaptor3d;
|
||||
myFlag : ExtFlag from Extrema;
|
||||
myAlgo : ExtAlgo from Extrema;
|
||||
|
||||
end GenExtPS;
|
||||
|
@ -16,55 +16,182 @@
|
||||
#include <math_Vector.hxx>
|
||||
#include <math_NewtonFunctionSetRoot.hxx>
|
||||
#include <GeomAbs_IsoType.hxx>
|
||||
#include <Bnd_Sphere.hxx>
|
||||
#include <Extrema_HUBTreeOfSphere.hxx>
|
||||
#include <Extrema_ExtFlag.hxx>
|
||||
#include <Bnd_Array1OfSphere.hxx>
|
||||
#include <Bnd_HArray1OfSphere.hxx>
|
||||
|
||||
//IMPLEMENT_HARRAY1(Extrema_HArray1OfSphere)
|
||||
|
||||
|
||||
class Bnd_SphereUBTreeSelector : public Extrema_UBTreeOfSphere::Selector
|
||||
{
|
||||
public:
|
||||
|
||||
Bnd_SphereUBTreeSelector (const Handle(Bnd_HArray1OfSphere)& theSphereArray,
|
||||
Bnd_Sphere& theSol)
|
||||
: myXYZ(0,0,0),
|
||||
mySphereArray(theSphereArray),
|
||||
mySol(theSol)
|
||||
{
|
||||
//myXYZ = gp_Pnt(0, 0, 0);
|
||||
}
|
||||
|
||||
void DefineCheckPoint( const gp_Pnt& theXYZ )
|
||||
{ myXYZ = theXYZ; }
|
||||
|
||||
Bnd_Sphere& Sphere() const
|
||||
{ return mySol; }
|
||||
|
||||
virtual Standard_Boolean Reject( const Bnd_Sphere &theBnd ) const = 0;
|
||||
|
||||
virtual Standard_Boolean Accept(const Standard_Integer& theObj) = 0;
|
||||
|
||||
protected:
|
||||
gp_Pnt myXYZ;
|
||||
const Handle(Bnd_HArray1OfSphere)& mySphereArray;
|
||||
Bnd_Sphere& mySol;
|
||||
|
||||
};
|
||||
|
||||
class Bnd_SphereUBTreeSelectorMin : public Bnd_SphereUBTreeSelector
|
||||
{
|
||||
public:
|
||||
Bnd_SphereUBTreeSelectorMin (const Handle(Bnd_HArray1OfSphere)& theSphereArray,
|
||||
Bnd_Sphere& theSol)
|
||||
: Bnd_SphereUBTreeSelector(theSphereArray, theSol),
|
||||
myMinDist(RealLast())
|
||||
{}
|
||||
|
||||
void SetMinDist( const Standard_Real theMinDist )
|
||||
{ myMinDist = theMinDist; }
|
||||
|
||||
Standard_Real MinDist() const
|
||||
{ return myMinDist; }
|
||||
|
||||
Standard_Boolean Reject( const Bnd_Sphere &theBnd ) const
|
||||
{
|
||||
Bnd_SphereUBTreeSelectorMin* me =
|
||||
const_cast<Bnd_SphereUBTreeSelectorMin*>(this);
|
||||
// myMinDist is decreased each time a nearer object is found
|
||||
return theBnd.IsOut( myXYZ.XYZ(), me->myMinDist );
|
||||
}
|
||||
|
||||
Standard_Boolean Accept(const Standard_Integer&);
|
||||
|
||||
private:
|
||||
Standard_Real myMinDist;
|
||||
};
|
||||
|
||||
Standard_Boolean Bnd_SphereUBTreeSelectorMin::Accept(const Standard_Integer& theInd)
|
||||
{
|
||||
const Bnd_Sphere& aSph = mySphereArray->Value(theInd);
|
||||
Standard_Real aCurDist;
|
||||
|
||||
if ( (aCurDist = aSph.SquareDistance(myXYZ.XYZ())) < mySol.SquareDistance(myXYZ.XYZ()) )
|
||||
{
|
||||
mySol = aSph;
|
||||
if ( aCurDist < myMinDist )
|
||||
myMinDist = aCurDist;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
class Bnd_SphereUBTreeSelectorMax : public Bnd_SphereUBTreeSelector
|
||||
{
|
||||
public:
|
||||
Bnd_SphereUBTreeSelectorMax (const Handle(Bnd_HArray1OfSphere)& theSphereArray,
|
||||
Bnd_Sphere& theSol)
|
||||
: Bnd_SphereUBTreeSelector(theSphereArray, theSol),
|
||||
myMaxDist(0)
|
||||
{}
|
||||
|
||||
void SetMaxDist( const Standard_Real theMaxDist )
|
||||
{ myMaxDist = theMaxDist; }
|
||||
|
||||
Standard_Real MaxDist() const
|
||||
{ return myMaxDist; }
|
||||
|
||||
Standard_Boolean Reject( const Bnd_Sphere &theBnd ) const
|
||||
{
|
||||
Bnd_SphereUBTreeSelectorMax* me =
|
||||
const_cast<Bnd_SphereUBTreeSelectorMax*>(this);
|
||||
// myMaxDist is decreased each time a nearer object is found
|
||||
return theBnd.IsOut( myXYZ.XYZ(), me->myMaxDist );
|
||||
}
|
||||
|
||||
Standard_Boolean Accept(const Standard_Integer&);
|
||||
|
||||
private:
|
||||
Standard_Real myMaxDist;
|
||||
};
|
||||
|
||||
Standard_Boolean Bnd_SphereUBTreeSelectorMax::Accept(const Standard_Integer& theInd)
|
||||
{
|
||||
const Bnd_Sphere& aSph = mySphereArray->Value(theInd);
|
||||
Standard_Real aCurDist;
|
||||
|
||||
if ( (aCurDist = aSph.SquareDistance(myXYZ.XYZ())) > mySol.SquareDistance(myXYZ.XYZ()) )
|
||||
{
|
||||
mySol = aSph;
|
||||
if ( aCurDist > myMaxDist )
|
||||
myMaxDist = aCurDist;
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=============================================================================
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
Fonction:
|
||||
Recherche de toutes les distances extremales entre le point P et la surface
|
||||
S a partir d'un echantillonnage (NbU,NbV).
|
||||
Function:
|
||||
Find all extremum distances between point P and surface
|
||||
S using sampling (NbU,NbV).
|
||||
|
||||
Methode:
|
||||
L'algorithme part de l'hypothese que l'echantillonnage est suffisamment fin
|
||||
Method:
|
||||
The algorithm bases on the hypothesis that sampling is precise enough
|
||||
pour que, s'il existe N distances extremales entre le point et la surface,
|
||||
alors il existe aussi N extrema entre le point et la grille.
|
||||
Ainsi, l'algorithme consiste a partir des extrema de la grille pour trouver
|
||||
les extrema de la surface.
|
||||
Les extrema sont calcules par l'algorithme math_FunctionSetRoot avec les
|
||||
arguments suivants:
|
||||
- F: Extrema_FuncExtPS cree a partir de P et S,
|
||||
- UV: math_Vector dont les composantes sont les parametres de l'extremum sur
|
||||
la grille,
|
||||
- Tol: Min(TolU,TolV), (Prov.:math_FunctionSetRoot n'autorise pas un vecteur)
|
||||
- UVinf: math_Vector dont les composantes sont les bornes inferieures de u et
|
||||
v,
|
||||
- UVsup: math_Vector dont les composantes sont les bornes superieures de u et
|
||||
v.
|
||||
So, the algorithm consists in starting from extrema of the grid to find the
|
||||
extrema of the surface.
|
||||
The extrema are calculated by the algorithm math_FunctionSetRoot with the
|
||||
following arguments:
|
||||
- F: Extrema_FuncExtPS created from P and S,
|
||||
- UV: math_Vector the components which of are parameters of the extremum on the
|
||||
grid,
|
||||
- Tol: Min(TolU,TolV), (Prov.:math_FunctionSetRoot does not autorize a vector)
|
||||
- UVinf: math_Vector the components which of are lower limits of u and v,
|
||||
- UVsup: math_Vector the components which of are upper limits of u and v.
|
||||
|
||||
Traitement:
|
||||
a- Constitution du tableau des distances (TbDist(0,NbU+1,0,NbV+1)):
|
||||
Le tableau est volontairement etendu; les lignes 0 et NbU+1 et les
|
||||
colonnes 0 et NbV+1 seront initialisees a RealFirst() ou RealLast()
|
||||
pour simplifier les tests effectues dans l'etape b
|
||||
(on n'a pas besoin de tester si le point est sur un bord de la grille).
|
||||
b- Calcul des extrema:
|
||||
On recherche d'abord les minima et ensuite les maxima. Ces 2 traitements
|
||||
se passent de facon similaire:
|
||||
b.a- Initialisations:
|
||||
- des 'bords' du tableau TbDist (a RealLast() dans le cas des minima
|
||||
et a RealLast() dans le cas des maxima),
|
||||
- du tableau TbSel(0,NbU+1,0,NbV+1) de selection des points pour un
|
||||
calcul d'extremum local (a 0). Lorsqu'un point sera selectionne,
|
||||
il ne sera plus selectionnable, ainsi que ses points adjacents
|
||||
(8 au maximum). Les adresses correspondantes seront mises a 1.
|
||||
b.b- Calcul des minima (ou maxima):
|
||||
On boucle sur toutes les distances du tableau TbDist:
|
||||
- recherche d'un minimum (ou maximum) sur la grille,
|
||||
- calcul de l'extremum sur la surface,
|
||||
- mise a jour du tableau TbSel.
|
||||
Processing:
|
||||
a- Creation of the table of distances (TbDist(0,NbU+1,0,NbV+1)):
|
||||
The table is expanded at will; lines 0 and NbU+1 and
|
||||
columns 0 and NbV+1 are initialized at RealFirst() or RealLast()
|
||||
to simplify the tests carried out at stage b
|
||||
(there is no need to test if the point is on border of the grid).
|
||||
b- Calculation of extrema:
|
||||
First the minimums and then the maximums are found. These 2 procedured
|
||||
pass in a similar way:
|
||||
b.a- Initialization:
|
||||
- 'borders' of table TbDist (RealLast() in case of minimums
|
||||
and RealLast() in case of maximums),
|
||||
- table TbSel(0,NbU+1,0,NbV+1) of selection of points for
|
||||
calculation of local extremum (0). When a point will selected,
|
||||
it will not be selectable, as well as the ajacent points
|
||||
(8 at least). The corresponding addresses will be set to 1.
|
||||
b.b- Calculation of minimums (or maximums):
|
||||
All distances from table TbDist are parsed in a loop:
|
||||
- search minimum (or maximum) in the grid,
|
||||
- calculate extremum on the surface,
|
||||
- update table TbSel.
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
static Standard_Boolean IsoIsDeg (const Adaptor3d_Surface& S,
|
||||
@ -117,6 +244,8 @@ Extrema_GenExtPS::Extrema_GenExtPS()
|
||||
{
|
||||
myDone = Standard_False;
|
||||
myInit = Standard_False;
|
||||
myFlag = Extrema_ExtFlag_MINMAX;
|
||||
myAlgo = Extrema_ExtAlgo_Grad;
|
||||
}
|
||||
|
||||
|
||||
@ -125,8 +254,10 @@ Extrema_GenExtPS::Extrema_GenExtPS (const gp_Pnt& P,
|
||||
const Standard_Integer NbU,
|
||||
const Standard_Integer NbV,
|
||||
const Standard_Real TolU,
|
||||
const Standard_Real TolV)
|
||||
: myF (P,S)
|
||||
const Standard_Real TolV,
|
||||
const Extrema_ExtFlag F,
|
||||
const Extrema_ExtAlgo A)
|
||||
: myF (P,S), myFlag(F), myAlgo(A)
|
||||
{
|
||||
Initialize(S, NbU, NbV, TolU, TolV);
|
||||
Perform(P);
|
||||
@ -141,8 +272,10 @@ Extrema_GenExtPS::Extrema_GenExtPS (const gp_Pnt& P,
|
||||
const Standard_Real Vmin,
|
||||
const Standard_Real Vsup,
|
||||
const Standard_Real TolU,
|
||||
const Standard_Real TolV)
|
||||
: myF (P,S)
|
||||
const Standard_Real TolV,
|
||||
const Extrema_ExtFlag F,
|
||||
const Extrema_ExtAlgo A)
|
||||
: myF (P,S), myFlag(F), myAlgo(A)
|
||||
{
|
||||
Initialize(S, NbU, NbV, Umin, Usup, Vmin, Vsup, TolU, TolV);
|
||||
Perform(P);
|
||||
@ -189,15 +322,12 @@ void Extrema_GenExtPS::Initialize(const Adaptor3d_Surface& S,
|
||||
|
||||
myF.Initialize(S);
|
||||
|
||||
mypoints = new TColgp_HArray2OfPnt(0,myusample+1,0,myvsample+1);
|
||||
|
||||
/*
|
||||
a- Constitution du tableau des distances (TbDist(0,myusample+1,0,myvsample+1)):
|
||||
---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Parametrage de l echantillon
|
||||
mySphereUBTree.Clear();
|
||||
|
||||
if(myAlgo == Extrema_ExtAlgo_Grad)
|
||||
{
|
||||
//If flag was changed and extrema not reinitialized Extrema would fail
|
||||
mypoints = new TColgp_HArray2OfPnt(0,myusample+1,0,myvsample+1);
|
||||
Standard_Real PasU = myusup - myumin;
|
||||
Standard_Real PasV = myvsup - myvmin;
|
||||
Standard_Real U0 = PasU / myusample / 100.;
|
||||
@ -218,24 +348,168 @@ a- Constitution du tableau des distances (TbDist(0,myusample+1,0,myvsample+1)):
|
||||
mypoints->SetValue(NoU,NoV,P1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Extrema_GenExtPS::Perform(const gp_Pnt& P)
|
||||
{
|
||||
myDone = Standard_False;
|
||||
myF.SetPoint(P);
|
||||
}
|
||||
|
||||
//mypoints = new TColgp_HArray2OfPnt(0,myusample+1,0,myvsample+1);
|
||||
|
||||
/*
|
||||
b- Calcul des minima:
|
||||
-----------------
|
||||
b.a) Initialisations:
|
||||
a- Constitution du tableau des distances (TbDist(0,myusample+1,0,myvsample+1)):
|
||||
---------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Parametrage de l echantillon
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Extrema_GenExtPS::BuildTree()
|
||||
{
|
||||
if(mySphereUBTree.IsEmpty())
|
||||
{
|
||||
Standard_Real PasU = myusup - myumin;
|
||||
Standard_Real PasV = myvsup - myvmin;
|
||||
Standard_Real U0 = PasU / myusample / 100.;
|
||||
Standard_Real V0 = PasV / myvsample / 100.;
|
||||
gp_Pnt P1;
|
||||
PasU = (PasU - U0) / (myusample - 1);
|
||||
PasV = (PasV - V0) / (myvsample - 1);
|
||||
U0 = U0/2. + myumin;
|
||||
V0 = V0/2. + myvmin;
|
||||
|
||||
// Calcul des distances
|
||||
|
||||
Standard_Integer NoU, NoV;
|
||||
//mySphereUBTree.Clear();
|
||||
Extrema_UBTreeFillerOfSphere aFiller(mySphereUBTree.ChangeTree());
|
||||
Standard_Integer i = myusample * myvsample;
|
||||
Standard_Real U, V;
|
||||
/*for ( NoU = 1; NoU <= myusample; NoU++) {
|
||||
for ( NoV = 1; NoV <= myvsample; NoV++) {
|
||||
i++;
|
||||
}
|
||||
}*/
|
||||
mySphereArray = new Bnd_HArray1OfSphere(0, i);
|
||||
i = 0;
|
||||
for ( NoU = 1, U = U0; NoU <= myusample; NoU++, U += PasU) {
|
||||
for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV) {
|
||||
P1 = myS->Value(U, V);
|
||||
//mypoints->SetValue(NoU, NoV, P1);
|
||||
Bnd_Sphere aSph(P1.XYZ(), 0/*mytolu < mytolv ? mytolu : mytolv*/, NoU, NoV);
|
||||
aFiller.Add(i, aSph);
|
||||
mySphereArray->SetValue( i, aSph );
|
||||
i++;
|
||||
}
|
||||
}
|
||||
aFiller.Fill();
|
||||
}
|
||||
}
|
||||
|
||||
void Extrema_GenExtPS::FindSolution(const gp_Pnt& P, const math_Vector& UV, const Standard_Real PasU, const Standard_Real PasV, const Extrema_ExtFlag f)
|
||||
{
|
||||
math_Vector Tol(1,2);
|
||||
Tol(1) = mytolu;
|
||||
Tol(2) = mytolv;
|
||||
|
||||
math_Vector UVinf(1,2), UVsup(1,2);
|
||||
UVinf(1) = myumin;
|
||||
UVinf(2) = myvmin;
|
||||
UVsup(1) = myusup;
|
||||
UVsup(2) = myvsup;
|
||||
|
||||
math_Vector errors(1,2);
|
||||
math_Vector root(1, 2);
|
||||
Standard_Real eps = 1.e-9;
|
||||
Standard_Integer nbsubsample = 11;
|
||||
|
||||
Standard_Integer aNbMaxIter = 100;
|
||||
|
||||
if (myF.HasDegIso())
|
||||
aNbMaxIter = 150;
|
||||
|
||||
math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
|
||||
if(S.IsDone()) {
|
||||
root = S.Root();
|
||||
myF.Value(root, errors);
|
||||
if(f == Extrema_ExtFlag_MIN)
|
||||
{
|
||||
if(Abs(errors(1)) > eps || Abs(errors(2)) > eps) {
|
||||
//try to improve solution on subgrid of sample points
|
||||
gp_Pnt PSol = myS->Value(root(1), root(2));
|
||||
Standard_Real DistSol = P.SquareDistance(PSol);
|
||||
|
||||
Standard_Real u1 = Max(UV(1) - PasU, myumin), u2 = Min(UV(1) + PasU, myusup);
|
||||
Standard_Real v1 = Max(UV(2) - PasV, myvmin), v2 = Min(UV(2) + PasV, myvsup);
|
||||
|
||||
if(u2 - u1 < 2.*PasU) {
|
||||
if(Abs(u1 - myumin) < 1.e-9) {
|
||||
u2 = u1 + 2.*PasU;
|
||||
u2 = Min(u2, myusup);
|
||||
}
|
||||
if(Abs(u2 - myusup) < 1.e-9) {
|
||||
u1 = u2 - 2.*PasU;
|
||||
u1 = Max(u1, myumin);
|
||||
}
|
||||
}
|
||||
|
||||
if(v2 - v1 < 2.*PasV) {
|
||||
if(Abs(v1 - myvmin) < 1.e-9) {
|
||||
v2 = v1 + 2.*PasV;
|
||||
v2 = Min(v2, myvsup);
|
||||
}
|
||||
if(Abs(v2 - myvsup) < 1.e-9) {
|
||||
v1 = v2 - 2.*PasV;
|
||||
v1 = Max(v1, myvmin);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real du = (u2 - u1)/(nbsubsample-1);
|
||||
Standard_Real dv = (v2 - v1)/(nbsubsample-1);
|
||||
Standard_Real u, v;
|
||||
Standard_Real dist;
|
||||
|
||||
Standard_Boolean NewSolution = Standard_False;
|
||||
Standard_Integer Nu, Nv;
|
||||
for (Nu = 1, u = u1; Nu < nbsubsample; Nu++, u += du) {
|
||||
for (Nv = 1, v = v1; Nv < nbsubsample; Nv++, v += dv) {
|
||||
gp_Pnt Puv = myS->Value(u, v);
|
||||
dist = P.SquareDistance(Puv);
|
||||
|
||||
if(dist < DistSol) {
|
||||
UV(1) = u;
|
||||
UV(2) = v;
|
||||
NewSolution = Standard_True;
|
||||
DistSol = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(NewSolution) {
|
||||
//try to precise
|
||||
math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
myDone = Standard_True;
|
||||
}
|
||||
|
||||
void Extrema_GenExtPS::SetFlag(const Extrema_ExtFlag F)
|
||||
{
|
||||
myFlag = F;
|
||||
}
|
||||
|
||||
void Extrema_GenExtPS::SetAlgo(const Extrema_ExtAlgo A)
|
||||
{
|
||||
myAlgo = A;
|
||||
}
|
||||
|
||||
void Extrema_GenExtPS::Perform(const gp_Pnt& P)
|
||||
{
|
||||
//BuildTree();
|
||||
myDone = Standard_False;
|
||||
myF.SetPoint(P);
|
||||
|
||||
Standard_Real PasU = myusup - myumin;
|
||||
Standard_Real PasV = myvsup - myvmin;
|
||||
Standard_Real U, U0 = PasU / myusample / 100.;
|
||||
@ -245,211 +519,123 @@ b- Calcul des minima:
|
||||
U0 = U0/2.+myumin;
|
||||
V0 = V0/2.+myvmin;
|
||||
|
||||
// - generales
|
||||
math_Vector Tol(1, 2);
|
||||
Tol(1) = mytolu;
|
||||
Tol(2) = mytolv;
|
||||
math_Vector UV(1,2), UVinf(1,2), UVsup(1,2);
|
||||
UVinf(1) = myumin;
|
||||
UVinf(2) = myvmin;
|
||||
UVsup(1) = myusup;
|
||||
UVsup(2) = myvsup;
|
||||
//math_Vector Tol(1, 2);
|
||||
math_Vector UV(1,2);
|
||||
|
||||
// - des 'bords' du tableau mytbdist
|
||||
Standard_Integer NoU,NoV;
|
||||
if(myAlgo == Extrema_ExtAlgo_Grad)
|
||||
{
|
||||
Standard_Integer NoU,NoV;
|
||||
|
||||
TColStd_Array2OfReal TheDist(0, myusample+1, 0, myvsample+1);
|
||||
for ( NoU = 1, U = U0; NoU <= myusample; NoU++, U += PasU) {
|
||||
for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV) {
|
||||
TheDist(NoU, NoV) = P.SquareDistance(mypoints->Value(NoU, NoV));
|
||||
TColStd_Array2OfReal TheDist(0, myusample+1, 0, myvsample+1);
|
||||
for ( NoU = 1, U = U0; NoU <= myusample; NoU++, U += PasU) {
|
||||
for ( NoV = 1, V = V0; NoV <= myvsample; NoV++, V += PasV) {
|
||||
TheDist(NoU, NoV) = P.SquareDistance(mypoints->Value(NoU, NoV));
|
||||
}
|
||||
}
|
||||
|
||||
TColStd_Array2OfInteger TbSel(0,myusample+1,0,myvsample+1);
|
||||
TbSel.Init(0);
|
||||
|
||||
Standard_Real Dist;
|
||||
|
||||
if(myFlag == Extrema_ExtFlag_MIN || myFlag == Extrema_ExtFlag_MINMAX)
|
||||
{
|
||||
for (NoV = 0; NoV <= myvsample+1; NoV++) {
|
||||
TheDist(0,NoV) = RealLast();
|
||||
TheDist(myusample+1,NoV) = RealLast();
|
||||
}
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
TheDist(NoU,0) = RealLast();
|
||||
TheDist(NoU,myvsample+1) = RealLast();
|
||||
}
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
for (NoV = 1; NoV <= myvsample; NoV++) {
|
||||
if (TbSel(NoU,NoV) == 0) {
|
||||
Dist = TheDist(NoU,NoV);
|
||||
if ((TheDist(NoU-1,NoV-1) >= Dist) &&
|
||||
(TheDist(NoU-1,NoV ) >= Dist) &&
|
||||
(TheDist(NoU-1,NoV+1) >= Dist) &&
|
||||
(TheDist(NoU ,NoV-1) >= Dist) &&
|
||||
(TheDist(NoU ,NoV+1) >= Dist) &&
|
||||
(TheDist(NoU+1,NoV-1) >= Dist) &&
|
||||
(TheDist(NoU+1,NoV ) >= Dist) &&
|
||||
(TheDist(NoU+1,NoV+1) >= Dist)) {
|
||||
//Create array of UV vectors to calculate min
|
||||
UV(1) = U0 + (NoU - 1) * PasU;
|
||||
UV(2) = V0 + (NoV - 1) * PasV;
|
||||
FindSolution(P, UV, PasU, PasV, Extrema_ExtFlag_MIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(myFlag == Extrema_ExtFlag_MAX || myFlag == Extrema_ExtFlag_MINMAX)
|
||||
{
|
||||
for (NoV = 0; NoV <= myvsample+1; NoV++) {
|
||||
TheDist(0,NoV) = RealFirst();
|
||||
TheDist(myusample+1,NoV) = RealFirst();
|
||||
}
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
TheDist(NoU,0) = RealFirst();
|
||||
TheDist(NoU,myvsample+1) = RealFirst();
|
||||
}
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
for (NoV = 1; NoV <= myvsample; NoV++) {
|
||||
if (TbSel(NoU,NoV) == 0) {
|
||||
Dist = TheDist(NoU,NoV);
|
||||
if ((TheDist(NoU-1,NoV-1) <= Dist) &&
|
||||
(TheDist(NoU-1,NoV ) <= Dist) &&
|
||||
(TheDist(NoU-1,NoV+1) <= Dist) &&
|
||||
(TheDist(NoU ,NoV-1) <= Dist) &&
|
||||
(TheDist(NoU ,NoV+1) <= Dist) &&
|
||||
(TheDist(NoU+1,NoV-1) <= Dist) &&
|
||||
(TheDist(NoU+1,NoV ) <= Dist) &&
|
||||
(TheDist(NoU+1,NoV+1) <= Dist)) {
|
||||
//Create array of UV vectors to calculate max
|
||||
UV(1) = U0 + (NoU - 1) * PasU;
|
||||
UV(2) = V0 + (NoV - 1) * PasV;
|
||||
FindSolution(P, UV, PasU, PasV, Extrema_ExtFlag_MAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (NoV = 0; NoV <= myvsample+1; NoV++) {
|
||||
TheDist(0,NoV) = RealLast();
|
||||
TheDist(myusample+1,NoV) = RealLast();
|
||||
}
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
TheDist(NoU,0) = RealLast();
|
||||
TheDist(NoU,myvsample+1) = RealLast();
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildTree();
|
||||
if(myFlag == Extrema_ExtFlag_MIN || myFlag == Extrema_ExtFlag_MINMAX)
|
||||
{
|
||||
Bnd_Sphere aSol = mySphereArray->Value(0);
|
||||
Bnd_SphereUBTreeSelectorMin aSelector(mySphereArray, aSol);
|
||||
//aSelector.SetMaxDist( RealLast() );
|
||||
aSelector.DefineCheckPoint( P );
|
||||
Standard_Integer aNbSel = mySphereUBTree.Select( aSelector );
|
||||
//TODO: check if no solution in binary tree
|
||||
Bnd_Sphere& aSph = aSelector.Sphere();
|
||||
|
||||
// - du tableau TbSel(0,myusample+1,0,myvsample+1) de selection des points
|
||||
TColStd_Array2OfInteger TbSel(0,myusample+1,0,myvsample+1);
|
||||
TbSel.Init(0);
|
||||
/*
|
||||
b.b) Calcul des minima:
|
||||
*/
|
||||
// - recherche d un minimum sur la grille
|
||||
math_Vector errors(1,2);
|
||||
math_Vector root(1, 2);
|
||||
Standard_Real eps = 1.e-9;
|
||||
Standard_Integer nbsubsample = 11;
|
||||
Standard_Integer Nu, Nv;
|
||||
Standard_Real Dist;
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
for (NoV = 1; NoV <= myvsample; NoV++) {
|
||||
if (TbSel(NoU,NoV) == 0) {
|
||||
Dist = TheDist(NoU,NoV);
|
||||
if ((TheDist(NoU-1,NoV-1) >= Dist) &&
|
||||
(TheDist(NoU-1,NoV ) >= Dist) &&
|
||||
(TheDist(NoU-1,NoV+1) >= Dist) &&
|
||||
(TheDist(NoU ,NoV-1) >= Dist) &&
|
||||
(TheDist(NoU ,NoV+1) >= Dist) &&
|
||||
(TheDist(NoU+1,NoV-1) >= Dist) &&
|
||||
(TheDist(NoU+1,NoV ) >= Dist) &&
|
||||
(TheDist(NoU+1,NoV+1) >= Dist)) {
|
||||
UV(1) = U0 + (aSph.U() - 1) * PasU;
|
||||
UV(2) = V0 + (aSph.V() - 1) * PasV;
|
||||
|
||||
// - calcul de l extremum sur la surface:
|
||||
UV(1) = U0 + (NoU - 1) * PasU;
|
||||
UV(2) = V0 + (NoV - 1) * PasV;
|
||||
// Modified by skv - Thu Sep 30 15:21:07 2004 OCC593 Begin
|
||||
// math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup);
|
||||
// Default value for math_FunctionSetRoot.
|
||||
Standard_Integer aNbMaxIter = 100;
|
||||
FindSolution(P, UV, PasU, PasV, Extrema_ExtFlag_MIN);
|
||||
}
|
||||
if(myFlag == Extrema_ExtFlag_MAX || myFlag == Extrema_ExtFlag_MINMAX)
|
||||
{
|
||||
Bnd_Sphere aSol = mySphereArray->Value(0);
|
||||
Bnd_SphereUBTreeSelectorMax aSelector(mySphereArray, aSol);
|
||||
//aSelector.SetMaxDist( RealLast() );
|
||||
aSelector.DefineCheckPoint( P );
|
||||
Standard_Integer aNbSel = mySphereUBTree.Select( aSelector );
|
||||
//TODO: check if no solution in binary tree
|
||||
Bnd_Sphere& aSph = aSelector.Sphere();
|
||||
|
||||
if (myF.HasDegIso())
|
||||
aNbMaxIter = 150;
|
||||
UV(1) = U0 + (aSph.U() - 1) * PasU;
|
||||
UV(2) = V0 + (aSph.V() - 1) * PasV;
|
||||
|
||||
math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
|
||||
if(S.IsDone()) {
|
||||
root = S.Root();
|
||||
myF.Value(root, errors);
|
||||
if(Abs(errors(1)) > eps || Abs(errors(2)) > eps) {
|
||||
//try to improve solution on subgrid of sample points
|
||||
gp_Pnt PSol = myS->Value(root(1), root(2));
|
||||
Standard_Real DistSol = P.SquareDistance(PSol);
|
||||
|
||||
Standard_Real u1 = Max(UV(1) - PasU, myumin), u2 = Min(UV(1) + PasU, myusup);
|
||||
Standard_Real v1 = Max(UV(2) - PasV, myvmin), v2 = Min(UV(2) + PasV, myvsup);
|
||||
|
||||
if(u2 - u1 < 2.*PasU) {
|
||||
if(Abs(u1 - myumin) < 1.e-9) {
|
||||
u2 = u1 + 2.*PasU;
|
||||
u2 = Min(u2, myusup);
|
||||
}
|
||||
if(Abs(u2 - myusup) < 1.e-9) {
|
||||
u1 = u2 - 2.*PasU;
|
||||
u1 = Max(u1, myumin);
|
||||
}
|
||||
}
|
||||
|
||||
if(v2 - v1 < 2.*PasV) {
|
||||
if(Abs(v1 - myvmin) < 1.e-9) {
|
||||
v2 = v1 + 2.*PasV;
|
||||
v2 = Min(v2, myvsup);
|
||||
}
|
||||
if(Abs(v2 - myvsup) < 1.e-9) {
|
||||
v1 = v2 - 2.*PasV;
|
||||
v1 = Max(v1, myvmin);
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Real du = (u2 - u1)/(nbsubsample-1);
|
||||
Standard_Real dv = (v2 - v1)/(nbsubsample-1);
|
||||
Standard_Real u, v;
|
||||
Standard_Real dist;
|
||||
|
||||
Standard_Boolean NewSolution = Standard_False;
|
||||
for (Nu = 1, u = u1; Nu < nbsubsample; Nu++, u += du) {
|
||||
for (Nv = 1, v = v1; Nv < nbsubsample; Nv++, v += dv) {
|
||||
gp_Pnt Puv = myS->Value(u, v);
|
||||
dist = P.SquareDistance(Puv);
|
||||
|
||||
if(dist < DistSol) {
|
||||
UV(1) = u;
|
||||
UV(2) = v;
|
||||
NewSolution = Standard_True;
|
||||
DistSol = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(NewSolution) {
|
||||
//try to precise
|
||||
math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// Modified by skv - Thu Sep 30 15:21:07 2004 OCC593 End
|
||||
|
||||
// - mise a jour du tableau TbSel
|
||||
for (Nu = NoU-1; Nu <= NoU+1; Nu++) {
|
||||
for (Nv = NoV-1; Nv <= NoV+1; Nv++) {
|
||||
TbSel(Nu,Nv) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // if (TbSel(NoU,NoV)
|
||||
} // for (NoV = 1; ...
|
||||
} // for (NoU = 1; ...
|
||||
/*
|
||||
c- Calcul des maxima:
|
||||
-----------------
|
||||
c.a) Initialisations:
|
||||
*/
|
||||
// - des 'bords' du tableau mytbdist
|
||||
for (NoV = 0; NoV <= myvsample+1; NoV++) {
|
||||
TheDist(0,NoV) = RealFirst();
|
||||
TheDist(myusample+1,NoV) = RealFirst();
|
||||
}
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
TheDist(NoU,0) = RealFirst();
|
||||
TheDist(NoU,myvsample+1) = RealFirst();
|
||||
}
|
||||
|
||||
// - du tableau TbSel(0,myusample+1,0,myvsample+1) de selection des points
|
||||
for (NoU = 0; NoU <= myusample+1; NoU++) {
|
||||
for (NoV = 0; NoV <= myvsample+1; NoV++) {
|
||||
TbSel(NoU,NoV) = 0;
|
||||
FindSolution(P, UV, PasU, PasV, Extrema_ExtFlag_MAX);
|
||||
}
|
||||
}
|
||||
/*
|
||||
c.b) Calcul des maxima:
|
||||
*/
|
||||
// - recherche d un maximum sur la grille
|
||||
for (NoU = 1; NoU <= myusample; NoU++) {
|
||||
for (NoV = 1; NoV <= myvsample; NoV++) {
|
||||
if (TbSel(NoU,NoV) == 0) {
|
||||
Dist = TheDist(NoU,NoV);
|
||||
if ((TheDist(NoU-1,NoV-1) <= Dist) &&
|
||||
(TheDist(NoU-1,NoV ) <= Dist) &&
|
||||
(TheDist(NoU-1,NoV+1) <= Dist) &&
|
||||
(TheDist(NoU ,NoV-1) <= Dist) &&
|
||||
(TheDist(NoU ,NoV+1) <= Dist) &&
|
||||
(TheDist(NoU+1,NoV-1) <= Dist) &&
|
||||
(TheDist(NoU+1,NoV ) <= Dist) &&
|
||||
(TheDist(NoU+1,NoV+1) <= Dist)) {
|
||||
|
||||
// - calcul de l extremum sur la surface:
|
||||
UV(1) = U0 + (NoU - 1) * PasU;
|
||||
UV(2) = V0 + (NoV - 1) * PasV;
|
||||
// Modified by skv - Thu Sep 30 15:21:07 2004 OCC593 Begin
|
||||
// math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup);
|
||||
// Default value for math_FunctionSetRoot.
|
||||
Standard_Integer aNbMaxIter = 100;
|
||||
|
||||
if (myF.HasDegIso())
|
||||
aNbMaxIter = 150;
|
||||
|
||||
math_FunctionSetRoot S (myF,UV,Tol,UVinf,UVsup, aNbMaxIter);
|
||||
if(S.IsDone()) {
|
||||
root = S.Root();
|
||||
myF.Value(root, errors);
|
||||
}
|
||||
// Modified by skv - Thu Sep 30 15:21:07 2004 OCC593 End
|
||||
|
||||
// - mise a jour du tableau TbSel
|
||||
for (Nu = NoU-1; Nu <= NoU+1; Nu++) {
|
||||
for (Nv = NoV-1; Nv <= NoV+1; Nv++) {
|
||||
TbSel(Nu,Nv) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // if (TbSel(NoU,NoV))
|
||||
} // for (NoV = 1; ...)
|
||||
} // for (NoU = 1; ...)
|
||||
myDone = Standard_True;
|
||||
}
|
||||
//=============================================================================
|
||||
|
||||
@ -476,4 +662,3 @@ Extrema_POnSurf Extrema_GenExtPS::Point (const Standard_Integer N) const
|
||||
return myF.Point(N);
|
||||
}
|
||||
//=============================================================================
|
||||
|
||||
|
8
src/Extrema/Extrema_HUBTreeOfSphere.cxx
Normal file
8
src/Extrema/Extrema_HUBTreeOfSphere.cxx
Normal file
@ -0,0 +1,8 @@
|
||||
// File: BestFitBnd_HUBTreeOfSphere.cxx
|
||||
// Created: Thu Mar 17 14:30:42 2005
|
||||
// Author: OPEN CASCADE Support
|
||||
// Copyright: OPEN CASCADE SA 2005
|
||||
|
||||
#include <Extrema_HUBTreeOfSphere.hxx>
|
||||
|
||||
IMPLEMENT_HUBTREE(Extrema_HUBTreeOfSphere,MMgt_TShared)
|
17
src/Extrema/Extrema_HUBTreeOfSphere.hxx
Normal file
17
src/Extrema/Extrema_HUBTreeOfSphere.hxx
Normal file
@ -0,0 +1,17 @@
|
||||
// File: BestFitBnd_HUBTreeOfSphere.hxx
|
||||
// Created: Thu Mar 17 14:30:42 2005
|
||||
// Author: OPEN CASCADE Support
|
||||
// Copyright: OPEN CASCADE SA 2005
|
||||
|
||||
#ifndef _Extrema_HUBTreeOfSphere_HeaderFile
|
||||
#define _Extrema_HUBTreeOfSphere_HeaderFile
|
||||
|
||||
#include <NCollection_UBTree.hxx>
|
||||
#include <NCollection_UBTreeFiller.hxx>
|
||||
#include <Bnd_Sphere.hxx>
|
||||
|
||||
typedef NCollection_UBTree<Standard_Integer,Bnd_Sphere> Extrema_UBTreeOfSphere;
|
||||
typedef NCollection_UBTreeFiller<Standard_Integer,Bnd_Sphere> Extrema_UBTreeFillerOfSphere;
|
||||
DEFINE_HUBTREE(Extrema_HUBTreeOfSphere, Standard_Integer, Bnd_Sphere, MMgt_TShared)
|
||||
|
||||
#endif //_Extrema_HUBTreeOfSphere_HeaderFile
|
2
src/Extrema/FILES
Normal file
2
src/Extrema/FILES
Normal file
@ -0,0 +1,2 @@
|
||||
Extrema_HUBTreeOfSphere.hxx
|
||||
Extrema_HUBTreeOfSphere.cxx
|
Loading…
x
Reference in New Issue
Block a user