1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

OCC22322 Improvement of Extrema performance

This commit is contained in:
ASH
2011-05-19 10:50:52 +00:00
committed by bugmaster
parent ae07527556
commit 92d1589b7f
33 changed files with 3246 additions and 2609 deletions

View File

@@ -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;

View File

@@ -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;
}
}

View 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

View 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

View File

@@ -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);
}

View 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

View File

@@ -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;
}

View 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

View File

@@ -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;
}

View 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

View File

@@ -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);
}

View 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

View File

@@ -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;
}

View 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

View File

@@ -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;
}

View 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

View 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

View 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

View 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
View 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