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