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

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

120
src/BRepExtrema/BRepExtrema.cdl Executable file
View File

@@ -0,0 +1,120 @@
-- File: BRepExtrema.cdl
-- Created: Fri Dec 3 15:48:19 1993
-- Author: Christophe MARION
-- <cma@sdsun1>
---Copyright: Matra Datavision 1993
package BRepExtrema
---Purpose: This package gives tools to compute extrema between
-- Shapes from BRep.
uses
Standard,
StdFail,
TopoDS,
GeomAdaptor,
BRepAdaptor,
gp,
Extrema,
TColStd,
TopTools,
TCollection,
Bnd
is
----------------------------------------------------------
-- Extrema between two Shapes with triangulation.
----------------------------------------------------------
class Poly;
----------------------------------------------------------
-- Extrema between a Point and an Edge.
----------------------------------------------------------
class ExtPC;
----------------------------------------------------------
-- Extrema between two Edges.
----------------------------------------------------------
class ExtCC;
----------------------------------------------------------
-- Extrema between a Point and a Face.
----------------------------------------------------------
class ExtPF;
----------------------------------------------------------
-- Extrema between an Edge and a Face.
----------------------------------------------------------
class ExtCF;
----------------------------------------------------------
-- Extrema between two Faces.
----------------------------------------------------------
class ExtFF;
----------------------------------------------------------
--
----------------------------------------------------------
exception UnCompatibleShape inherits DomainError;
----------------------------------------------------------
-- enumeration used to describe the type of the support solution:
-- IsVertex => The solution is a vertex.
-- IsOnEdge => The solution belongs to an Edge.
-- IsInFace => The solution is inside a Face.
----------------------------------------------------------
enumeration SupportType is IsVertex, IsOnEdge, IsInFace end SupportType;
----------------------------------------------------------
-- This class gives tools to compute the minimum distance value
-- between two shapes and the corresponding couples of solution points.
----------------------------------------------------------
class DistShapeShape;
----------------------------------------------------------
-- This class is used to store a solution on a Shape.
-- (used only by class DistShapeShape)
----------------------------------------------------------
class SolutionElem;
----------------------------------------------------------
-- This sequence is used to store all the solution on each Shape.
----------------------------------------------------------
class SeqOfSolution instantiates Sequence from TCollection
( SolutionElem from BRepExtrema);
----------------------------------------------------------
-- This class is used to compute minimum distance between two elementary
-- Shapes ( Vertex, Edge, Face ) (used only by class DistShapeShape)
----------------------------------------------------------
private class DistanceSS from BRepExtrema;
end BRepExtrema;

View File

@@ -0,0 +1,229 @@
-- File: BRepExtrema_DistShapeShape.cdl
-- Created: Tue Apr 9 14:29:10 1996
-- Author: Maria PUMBORIOS
-- Author: Herve LOUESSARD
-- <mps@sgi30>
---Copyright: Matra Datavision 1996
class DistShapeShape from BRepExtrema
---Purpose: This class provides tools to compute minimum distance
-- between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex).
uses
IndexedMapOfShape from TopTools,
Boolean, Integer, OutOfRange from Standard,
Pnt from gp,
SupportType,SeqOfSolution from BRepExtrema,
Shape from TopoDS,
Box, SeqOfBox from Bnd,
NotDone from StdFail
raises
NotDone from StdFail,
OutOfRange from Standard,
UnCompatibleShape from BRepExtrema
is
-- -- the computation of the minimum distance is made in the constructor
Create returns DistShapeShape from BRepExtrema;
---Purpose: create empty brepextrema
Create(Shape1 : Shape from TopoDS;
Shape2 : Shape from TopoDS)
---Purpose: computation of the minimum distance (value and
-- couple of points) using default deflection
returns DistShapeShape from BRepExtrema;
Create(Shape1 : Shape from TopoDS;
Shape2 : Shape from TopoDS;
theDeflection : Real from Standard)
---Purpose: Creates brepextrema and load both shapes into it
-- Default value is Precision::Confusion().
--
-- Computation of the minimum distance (value and
-- couple of points). Parameter theDeflection is used
-- to specify a maximum deviation of extreme distances
-- from the minimum one.
-- Default value is Precision::Confusion().
returns DistShapeShape from BRepExtrema;
SetDeflection(me: in out; theDeflection : Real from Standard);
-- Default value is Precision::Confusion().
LoadS1(me: in out; Shape1 : Shape from TopoDS);
---Purpose: load first shape into extrema
LoadS2(me: in out; Shape1 : Shape from TopoDS);
---Purpose: load second shape into extrema
Perform(me: in out) returns Boolean from Standard;
---Purpose: computation of the minimum distance (value and
-- couple of points). Parameter theDeflection is used
-- to specify a maximum deviation of extreme distances
-- from the minimum one.
-- Returns IsDone status.
-- the following method is only used in the computation of
-- minimum distance
DistanceMapMap(me :in out; Map1, Map2: IndexedMapOfShape from TopTools;
LBox1, LBox2: SeqOfBox from Bnd)
---Purpose: computes the minimum distance between two map of
-- shapes(Face,Edge,Vertex)
is private;
--- methods giving informations about the solutions
IsDone(me) returns Boolean from Standard;
---Purpose: True if the minimum distance is found.
NbSolution(me) returns Integer from Standard
---Purpose: Returns the number of solutions satisfying the minimum
-- distance.
raises NotDone from StdFail;
Value(me) returns Real from Standard
---Purpose: Returns the value of the minimum distance.
raises NotDone from StdFail;
InnerSolution (me) returns Boolean from Standard;
---Purpose: True if one of the shapes is a solid and the
-- other shape is completely or partially inside the solid.
PointOnShape1(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point corresponding to the <N>th
-- solution on the first Shape
raises NotDone from StdFail,
OutOfRange from Standard;
PointOnShape2(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point corresponding to the <N>th
-- solution on the second Shape
raises NotDone from StdFail,
OutOfRange from Standard;
SupportTypeShape1(me; N : Integer from Standard)
returns SupportType from BRepExtrema
---Purpose: gives the type of the support where the Nth
-- solution on the first shape is situated:
-- IsVertex :
-- => the Nth solution on the first shape is a Vertex
-- IsOnEdge
-- => the Nth soluion on the first shape is on a Edge
-- IsInFace
-- => the Nth solution on the first shape is inside a
-- face
--
-- the corresponding support is obtained by the
-- method SupportOnShape1
raises NotDone from StdFail,
OutOfRange from Standard;
SupportTypeShape2(me; N : Integer from Standard)
returns SupportType from BRepExtrema
---Purpose: gives the type of the support where the Nth
-- solution on the second shape is situated:
-- IsVertex :
-- => the Nth solution on the second shape is a Vertex
-- IsOnEdge
-- => the Nth soluion on the secondt shape is on a Edge
-- IsInFace
-- => the Nth solution on the second shape is inside a
-- face
--
-- the support is obtained by the method SupportOnShape2
raises NotDone from StdFail,
OutOfRange from Standard;
SupportOnShape1(me; N : Integer from Standard) returns Shape from TopoDS
---Purpose :gives the support where the Nth
-- solution on the first shape is situated.
-- This support can be a Vertex, an Edge or a Face.
raises NotDone from StdFail,
OutOfRange from Standard;
SupportOnShape2(me; N : Integer from Standard) returns Shape from TopoDS
---Purpose: gives the support where the Nth
-- solution on the second shape is situated.
-- This support can be a Vertex, an Edge or a Face.
raises NotDone from StdFail,
OutOfRange from Standard;
ParOnEdgeS1(me; N: Integer from Standard; t: out Real from Standard)
---Purpose: gives the corresponding parameter t if the Nth
-- Solution is situated on an Egde of the first shape
raises UnCompatibleShape,
NotDone from StdFail,
OutOfRange from Standard;
ParOnEdgeS2(me; N: Integer from Standard; t: out Real from Standard)
---Purpose: gives the corresponding parameter t if the Nth
-- Solution is situated on an Egde of the first shape
raises UnCompatibleShape,
NotDone from StdFail,
OutOfRange from Standard;
ParOnFaceS1(me; N: Integer from Standard; u: out Real from Standard;
v:out Real from Standard)
---Purpose: gives the corresponding parameters (U,V) if the Nth
-- Solution is situated on an face of the first shape
raises UnCompatibleShape,
NotDone from StdFail,
OutOfRange from Standard;
ParOnFaceS2(me; N: Integer from Standard; u: out Real from Standard;
v:out Real from Standard)
---Purpose: gives the corresponding parameters (U,V) if the Nth
-- Solution is situated on an Face of the second shape
raises UnCompatibleShape,
NotDone from StdFail,
OutOfRange from Standard;
Dump(me ; o : in out OStream);
---Purpose: Prints on the stream o information on the current state
-- of the object.
--
fields
myNbSolution : Integer from Standard;
myDistRef : Real from Standard;
myDistValue : Real from Standard;
myIsDone : Boolean from Standard;
ListeDeSolutionShape1 : SeqOfSolution from BRepExtrema;
ListeDeSolutionShape2 : SeqOfSolution from BRepExtrema;
myInnerSol : Boolean from Standard;
myEps : Real from Standard;
myShape1 : Shape from TopoDS;
myShape2 : Shape from TopoDS;
myMapV1 : IndexedMapOfShape from TopTools;
myMapV2 : IndexedMapOfShape from TopTools;
myMapE1 : IndexedMapOfShape from TopTools;
myMapE2 : IndexedMapOfShape from TopTools;
myMapF1 : IndexedMapOfShape from TopTools;
myMapF2 : IndexedMapOfShape from TopTools;
end DistShapeShape;

View File

@@ -0,0 +1,625 @@
// File: BRepExtrema_DistShapeShape.cxx
// Created: Mon Apr 22 17:03:37 1996
// Modified : Mps(10-04-97) portage WNT
// Author: Maria PUMBORIOS
// Author: Herve LOUESSARD
// <mps@sgi64>
#include <BRepExtrema_DistShapeShape.ixx>
#include <Standard_OStream.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#include <TopExp.hxx>
#include <TCollection.hxx>
#include <Standard_Real.hxx>
#include <BRepExtrema_DistanceSS.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <Precision.hxx>
#include <BRepExtrema_SeqOfSolution.hxx>
#include <BRepExtrema_SolutionElem.hxx>
#include <Bnd_SeqOfBox.hxx>
#include <BRepExtrema_UnCompatibleShape.hxx>
#include <BRep_Tool.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
static void Decomposition(const TopoDS_Shape& S,
TopTools_IndexedMapOfShape& MapV,
TopTools_IndexedMapOfShape& MapE,
TopTools_IndexedMapOfShape& MapF)
{
MapV.Clear();
MapE.Clear();
MapF.Clear();
TopExp::MapShapes(S,TopAbs_VERTEX,MapV);
TopExp::MapShapes(S,TopAbs_EDGE,MapE);
TopExp::MapShapes(S,TopAbs_FACE,MapF);
}
static void BoxCalculation(const TopTools_IndexedMapOfShape& Map,
Bnd_SeqOfBox& SBox)
{
Standard_Integer i = 0;
for(i = 1; i <= Map.Extent(); i++) {
Bnd_Box box;
BRepBndLib::Add( Map(i), box);
SBox.Append(box);
}
}
static Standard_Real DistanceInitiale(const TopoDS_Vertex V1,
const TopoDS_Vertex V2)
{
gp_Pnt P1,P2;
P1= BRep_Tool::Pnt(V1);
P2= BRep_Tool::Pnt(V2);
return(P1.Distance(P2));
}
//=======================================================================
//function : DistanceMapMap
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,
const TopTools_IndexedMapOfShape& Map2,
const Bnd_SeqOfBox& LBox1,
const Bnd_SeqOfBox& LBox2)
{
Standard_Integer i = 0, j = 0;
Bnd_Box box1, box2;
TopoDS_Shape S1, S2;
BRepExtrema_SeqOfSolution seq1, seq2;
Standard_Integer n1 = Map1.Extent();
Standard_Integer n2 = Map2.Extent();
for(i = 1; i <= n1; i++) {
box1= LBox1.Value(i);
S1= TopoDS_Shape (Map1(i));
for(j = 1; j <= n2; j++) {
box2= LBox2.Value(j);
S2 = TopoDS_Shape (Map2(j));
BRepExtrema_DistanceSS dist(S1,S2,box1,box2,myDistRef,myEps);
if(dist.IsDone())
if(dist.DistValue() < (myDistRef-myEps)) {
ListeDeSolutionShape1.Clear();
ListeDeSolutionShape2.Clear();
seq1= dist.Seq1Value();
seq2= dist.Seq2Value();
ListeDeSolutionShape1.Append(seq1);
ListeDeSolutionShape2.Append(seq2);
myDistRef=dist.DistValue();
}
else if(fabs (dist.DistValue()-myDistRef)< myEps ) {
seq1= dist.Seq1Value();
seq2= dist.Seq2Value();
ListeDeSolutionShape1.Append(seq1);
ListeDeSolutionShape2.Append(seq2);
// Modified by Sergey KHROMOV - Tue Mar 6 12:15:39 2001 Begin
if (myDistRef > dist.DistValue())
myDistRef=dist.DistValue();
// Modified by Sergey KHROMOV - Tue Mar 6 12:15:37 2001 End
}
}
}
}
//=======================================================================
//function : BRepExtrema_DistShapeShape
//purpose :
//=======================================================================
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape()
{
myEps = Precision::Confusion();
}
//=======================================================================
//function : BRepExtrema_DistShapeShape
//purpose :
//=======================================================================
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
const TopoDS_Shape& Shape2)
{
myEps = Precision::Confusion();
LoadS1(Shape1);
LoadS2(Shape2);
Perform();
}
//=======================================================================
//function : BRepExtrema_DistShapeShape
//purpose :
//=======================================================================
BRepExtrema_DistShapeShape::BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,
const TopoDS_Shape& Shape2,
const Standard_Real theDeflection)
{
myEps = theDeflection;
LoadS1(Shape1);
LoadS2(Shape2);
Perform();
}
//=======================================================================
//function : SetDeflection
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::SetDeflection(const Standard_Real theDeflection)
{
myEps = theDeflection;
}
//=======================================================================
//function : LoadS1
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::LoadS1(const TopoDS_Shape& Shape1)
{
myShape1 = Shape1;
Decomposition(Shape1, myMapV1, myMapE1, myMapF1);
}
//=======================================================================
//function : LoadS2
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::LoadS2(const TopoDS_Shape& Shape2)
{
myShape2 = Shape2;
Decomposition(Shape2, myMapV2, myMapE2, myMapF2);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_DistShapeShape::Perform()
{
myIsDone=Standard_False;
myInnerSol=Standard_False;
ListeDeSolutionShape1.Clear();
ListeDeSolutionShape2.Clear();
if( myShape1.IsNull() || myShape2.IsNull() )
return Standard_False;
Bnd_SeqOfBox BV1, BV2, BE1, BE2, BF1, BF2;
Standard_Real tol = 0.001;
gp_Pnt P;
Standard_Integer nbv1,nbv2;
// traitement des solides
TopAbs_ShapeEnum Type1 = myShape1.ShapeType();
TopAbs_ShapeEnum Type2 = myShape2.ShapeType();
if((Type1==TopAbs_SOLID) || (Type1 == TopAbs_COMPSOLID)) {
BRepClass3d_SolidClassifier Classi(myShape1);
nbv2=myMapV2.Extent();
nbv1=0;
do {
nbv1++;
TopoDS_Vertex V2 = TopoDS::Vertex(myMapV2(nbv1));
P=BRep_Tool::Pnt(V2);
Classi.Perform(P,tol);
if(Classi.State()==TopAbs_IN) {
myInnerSol = Standard_True;
myNbSolution = 1;
myDistRef = 0;
myIsDone = Standard_True;
BRepExtrema_SolutionElem Sol(0,P,BRepExtrema_IsVertex,V2);
ListeDeSolutionShape1.Append(Sol);
ListeDeSolutionShape2.Append(Sol);
}
} while ( (nbv1<nbv2) && (! myInnerSol));
}
if(((Type2==TopAbs_SOLID)||(Type2==TopAbs_COMPSOLID))&&(!myInnerSol)) {
BRepClass3d_SolidClassifier Classi(myShape2);
nbv1= myMapV1.Extent();
nbv2=0;
do {
nbv2++;
TopoDS_Vertex V1=TopoDS::Vertex(myMapV1(nbv2));
P=BRep_Tool::Pnt(V1);
Classi.Perform(P,tol);
if (Classi.State()==TopAbs_IN) {
myInnerSol = Standard_True;
myNbSolution = 1;
myDistRef = 0;
myIsDone = Standard_True;
BRepExtrema_SolutionElem Sol (0,P,BRepExtrema_IsVertex,V1);
ListeDeSolutionShape1.Append(Sol);
ListeDeSolutionShape2.Append(Sol);
}
} while ((nbv2<nbv1) && (! myInnerSol));
}
if (!myInnerSol) {
BoxCalculation( myMapV1,BV1);
BoxCalculation( myMapE1,BE1);
BoxCalculation( myMapF1,BF1);
BoxCalculation( myMapV2,BV2);
BoxCalculation( myMapE2,BE2);
BoxCalculation( myMapF2,BF2);
if (myMapV1.Extent()!=0 && myMapV2.Extent()!=0) {
TopoDS_Vertex V1 = TopoDS::Vertex(myMapV1(1));
TopoDS_Vertex V2 = TopoDS::Vertex(myMapV2(1));
myDistRef = DistanceInitiale(V1, V2);
}
else
myDistRef= 1.e30;
DistanceMapMap( myMapV1, myMapV2, BV1, BV2);
DistanceMapMap( myMapV1, myMapE2, BV1, BE2);
DistanceMapMap( myMapE1, myMapV2, BE1, BV2);
DistanceMapMap( myMapV1, myMapF2, BV1, BF2);
DistanceMapMap( myMapF1, myMapV2, BF1, BV2);
DistanceMapMap( myMapE1, myMapE2, BE1, BE2);
DistanceMapMap( myMapE1, myMapF2, BE1, BF2);
DistanceMapMap( myMapF1, myMapE2, BF1, BE2);
if( (fabs(myDistRef)) > myEps )
DistanceMapMap(myMapF1,myMapF2,BF1,BF2);
// Modified by Sergey KHROMOV - Tue Mar 6 11:55:03 2001 Begin
Standard_Integer i = 0;
for(i = 1; i <= ListeDeSolutionShape1.Length(); i++)
if (ListeDeSolutionShape1.Value(i).Dist() > myDistRef + myEps) {
ListeDeSolutionShape1.Remove(i);
ListeDeSolutionShape2.Remove(i);
}
// Modified by Sergey KHROMOV - Tue Mar 6 11:55:04 2001 End
myNbSolution = ListeDeSolutionShape1.Length();
if( myNbSolution > 0 )
myIsDone = Standard_True;
else
myIsDone = Standard_False;
}
return myIsDone;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_DistShapeShape:: InnerSolution () const
{
return (myInnerSol);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_DistShapeShape::IsDone() const
{
return (myIsDone);
}
//=======================================================================
//function : NbSolution
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_DistShapeShape::NbSolution() const
{
if (myIsDone == Standard_False) {
StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::NbSolution: There's no solution ");
}
return (myNbSolution);
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Real BRepExtrema_DistShapeShape::Value() const
{
if (myIsDone == Standard_False) {
StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::Value: There's no solution ");
}
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());
}
//=======================================================================
//function : SupportOnShape1
//purpose :
//=======================================================================
TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape1(const Standard_Integer N) const
{
BRepExtrema_SupportType Type;
TopoDS_Shape a_shape;
if (myIsDone == Standard_False)
{ StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::SupportOnShape1: There's no solution ");
}
if ((N<1)||(N>myNbSolution))
{ Standard_OutOfRange::Raise
("BRepExtrema_DistShapeShape::SupportOnShape1: Nth solution doesn't exist ");
}
Type = ((ListeDeSolutionShape1.Value(N)).SupportKind());
switch ( Type)
{ case BRepExtrema_IsVertex : a_shape=ListeDeSolutionShape1.Value(N).Vertex();
break;
case BRepExtrema_IsOnEdge : a_shape=ListeDeSolutionShape1.Value(N).Edge();
break;
case BRepExtrema_IsInFace : a_shape=ListeDeSolutionShape1.Value(N).Face();
break;
default :{}
}
return a_shape ;
}
//=======================================================================
//function : SupportOnShape2
//purpose :
//=======================================================================
TopoDS_Shape BRepExtrema_DistShapeShape::SupportOnShape2(const Standard_Integer N) const
{
BRepExtrema_SupportType Type;
TopoDS_Shape a_shape ;
if (myIsDone == Standard_False)
{ StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::SupportOnShape2: There's no solution ");
}
if ((N<1)||(N>myNbSolution))
{ Standard_OutOfRange::Raise
("BRepExtrema_DistShapeShape::SupportOnShape2: Nth solution doesn't exist ");
}
Type = ((ListeDeSolutionShape2.Value(N)).SupportKind());
switch ( Type)
{ case BRepExtrema_IsVertex : a_shape=ListeDeSolutionShape2.Value(N).Vertex();
break;
case BRepExtrema_IsOnEdge : a_shape=ListeDeSolutionShape2.Value(N).Edge();
break;
case BRepExtrema_IsInFace : a_shape=ListeDeSolutionShape2.Value(N).Face();
break;
default :{}
}
return a_shape ;
}
//=======================================================================
//function : ParOnEdgeS1
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::ParOnEdgeS1(const Standard_Integer N, Standard_Real& t) const
{
BRepExtrema_SupportType Type;
if (myIsDone == Standard_False)
{ StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::ParOnEdgeS1: There's no solution ");
}
if ((N<1)||(N>myNbSolution))
{ Standard_OutOfRange::Raise
("BRepExtrema_DistShapeShape::ParOnEdgeS1: Nth solution doesn't exist ");
}
Type = ((ListeDeSolutionShape1.Value(N)).SupportKind());
if (Type != BRepExtrema_IsOnEdge)
{ BRepExtrema_UnCompatibleShape::Raise
("BRepExtrema_DistShapeShape::ParOnEdgeS1:ParOnEdgeS1 is impossible without EDGE ");
}
(ListeDeSolutionShape1.Value(N)).EdgeParameter(t);
}
//=======================================================================
//function : ParOnEdgeS2
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::ParOnEdgeS2(const Standard_Integer N, Standard_Real& t) const
{
BRepExtrema_SupportType Type;
if (myIsDone == Standard_False)
{ StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::ParOnEdgeS2: There's no solution ");
}
if ((N<1)||(N>myNbSolution))
{ Standard_OutOfRange::Raise
("BRepExtrema_DistShapeShape::ParOnEdgeS2: Nth solution doesn't exist ");
}
Type = ((ListeDeSolutionShape2.Value(N)).SupportKind());
if (Type != BRepExtrema_IsOnEdge)
{ BRepExtrema_UnCompatibleShape::Raise
("BRepExtrema_DistShapeShape::ParOnEdgeS2:ParOnEdgeS2 is impossible without EDGE ");
}
(ListeDeSolutionShape2.Value(N)).EdgeParameter(t);
}
//=======================================================================
//function : ParOnFaceS1
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::ParOnFaceS1(const Standard_Integer N, Standard_Real& u, Standard_Real& v) const
{
BRepExtrema_SupportType Type;
if (myIsDone == Standard_False)
{ StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::ParOnFaceS1: There's no solution ");
}
if ((N<1)||(N>myNbSolution))
{ Standard_OutOfRange::Raise
("BRepExtrema_DistShapeShape::ParOnFaceS1: Nth solution doesn't exist ");
}
Type = ((ListeDeSolutionShape1.Value(N)).SupportKind());
if (Type != BRepExtrema_IsInFace)
{ BRepExtrema_UnCompatibleShape::Raise
("BRepExtrema_DistShapeShape::ParOnFaceS1:ParOnFaceS1 is impossible without FACE ");
}
(ListeDeSolutionShape1.Value(N)).FaceParameter(u, v);
}
void BRepExtrema_DistShapeShape::ParOnFaceS2(const Standard_Integer N, Standard_Real& u, Standard_Real& v) const
{
BRepExtrema_SupportType Type;
if (myIsDone == Standard_False)
{ StdFail_NotDone::Raise
("BRepExtrema_DistShapeShape::ParOnFaceS2: There's no solution ");
}
if ((N<1)||(N>myNbSolution))
{ Standard_OutOfRange::Raise
("BRepExtrema_DistShapeShape::ParOnFaceS2: Nth solution doesn't exist ");
}
Type = ((ListeDeSolutionShape2.Value(N)).SupportKind());
if (Type != BRepExtrema_IsInFace)
{ BRepExtrema_UnCompatibleShape::Raise
("BRepExtrema_DistShapeShape::ParOnFaceS2:ParOnFaceS2 is impossible without FACE ");
}
(ListeDeSolutionShape2.Value(N)).FaceParameter(u, v);
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
void BRepExtrema_DistShapeShape::Dump(Standard_OStream& o) const
{
Standard_Integer i;
Standard_Real r1,r2;
BRepExtrema_SupportType Type1, Type2;
o<< "the distance value is : " << Value()<<endl;
o<< "the number of solutions is :"<<NbSolution()<<endl;
o<<endl;
for (i=1;i<=NbSolution();i++) {
o<<"solution number "<<i<<": "<< endl;
o<<"the type of the solution on the first shape is " <<Standard_Integer( SupportTypeShape1(i)) <<endl;
o<<"the type of the solution on the second shape is "<<Standard_Integer( SupportTypeShape2(i))<< endl;
o<< "the coordinates of the point on the first shape are: "<<endl;
o<<"X=" <<PointOnShape1(i).X()<<" Y=" <<PointOnShape1(i).Y()<<" Z="<<PointOnShape1(i).Z()<<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;
Type1=SupportTypeShape1(i);
Type2=SupportTypeShape2(i);
if (Type1 == BRepExtrema_IsOnEdge)
{
ParOnEdgeS1(i,r1);
o << "parameter on the first edge : t= " << r1 << endl;
}
if (Type1 == BRepExtrema_IsInFace)
{
ParOnFaceS1(i,r1,r2);
o << "parameters on the first face : u= " << r1 << " v=" << r2 << endl;
}
if (Type2 == BRepExtrema_IsOnEdge)
{
ParOnEdgeS2(i,r1);
o << "parameter on the second edge : t=" << r1 << endl;
}
if (Type2 == BRepExtrema_IsInFace)
{
ParOnFaceS2(i,r1,r2);
o << "parameters on the second face : u= " << r1 << " v=" << r2 << endl;
}
o<<endl;
}
}

View File

@@ -0,0 +1,128 @@
-- File: BRepExtrema_DistanceSS.cdl
-- Created: Wed Apr 17 16:03:05 1996
-- Author: Maria PUMBORIOS
-- Author: Herve LOUESSARD
-- <mps@sgi30>
---Copyright: Matra Datavision 1996
--
private class DistanceSS from BRepExtrema
---Purpose: This class allows to compute minimum distance between two shapes
-- (face edge vertex) and is used in DistShapeShape class.
uses
Shape from TopoDS,
Box from Bnd,
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
Pnt from gp,
SeqOfSolution from BRepExtrema,
Real from Standard
is
Create( S1: Shape from TopoDS; S2: Shape from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose: computes the distance between two Shapes
-- ( face edge vertex)
returns DistanceSS from BRepExtrema;
Create( S1: Shape from TopoDS; S2: Shape from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard;
aDeflection: Real from Standard)
---Purpose: computes the distance between two Shapes
-- ( face edge vertex). Parameter theDeflection is used
-- to specify a maximum deviation of extreme distances
-- from the minimum one.
-- Default value is Precision::Confusion().
returns DistanceSS from BRepExtrema;
Perform(me:in out; S1: Shape from TopoDS; S2: Shape from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose: computes the distance between two Shapes
-- ( face edge vertex)
is private;
Perform (me:in out; S1: Vertex from TopoDS; S2: Vertex from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose: computes the distance between two vertices
is private;
Perform( me:in out;S1: Vertex from TopoDS; S2: Edge from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose: computes the minimum distance between a vertex and an edge
is private;
Perform( me:in out; S1: Vertex from TopoDS; S2: Face from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard )
---Purpose:computes the minimum distance between a vertex and a face
is private;
Perform(me:in out; S1: Edge from TopoDS; S2: Vertex from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose: computes the minimum distance between an edge and a vertex
is private;
Perform( me:in out;S1:Edge from TopoDS; S2: Edge from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose:
is private;
Perform(me:in out; S1: Edge from TopoDS; S2: Face from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard )
---Purpose:computes the minimum distance an edge and a face
is private;
Perform( me:in out; S1: Face from TopoDS; S2: Vertex from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose:computes the minimum distance betwwen a face and a vertex
is private;
Perform( me: in out ;S1: Face from TopoDS; S2: Edge from TopoDS;
B1, B2: Box from Bnd; DstRef: Real from Standard)
---Purpose:computes the minimum distance between a face and an edge
is private;
Perform( me:in out; S1: Face from TopoDS; S2: Face from TopoDS;
B1, B2: Box from Bnd ; DstRef: Real from Standard)
---Purpose:computes the minimum distance between a face and a face
is private;
IsDone(me) returns Boolean from Standard;
---Purpose: True if the distance has been computed
DistValue(me) returns Real from Standard;
---Purpose: returns the distance value
Seq1Value(me) returns SeqOfSolution from BRepExtrema;
---C++: return const&
---Purpose : returns the list of solutions on the first shape
Seq2Value(me) returns SeqOfSolution from BRepExtrema;
---C++: return const&
---Purpose returns the list of solutions on the second shape
fields
SeqSolShape1 : SeqOfSolution from BRepExtrema;
SeqSolShape2 : SeqOfSolution from BRepExtrema;
myDstRef: Real from Standard;
myModif : Boolean from Standard;
myEps : Real from Standard;
end;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,104 @@
-- File: BRepExtrema_ExtCC.cdl
-- Created: Tue Feb 8 09:03:52 1994
-- Author: Laurent PAINNOT
-- <lpa@phylox>
---Copyright: Matra Datavision 1994
class ExtCC from BRepExtrema
uses
Integer from Standard,
Real from Standard,
Boolean from Standard,
Edge from TopoDS,
HCurve from BRepAdaptor,
ExtCC from Extrema,
Pnt from gp
raises
NotDone from StdFail,
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns ExtCC from BRepExtrema;
Create(E1 : Edge from TopoDS;
E2 : Edge from TopoDS)
---Purpose: It calculates all the distances.
returns ExtCC from BRepExtrema;
Initialize(me: in out; E2 : Edge from TopoDS)
---Purpose:
is static;
Perform(me: in out; E1 : Edge from TopoDS)
---Purpose: An exception is raised if the fields have not been
-- initialized.
raises TypeMismatch from Standard
is static;
IsDone(me) returns Boolean from Standard
---Purpose: True if the distances are found.
is static;
NbExt(me) returns Integer from Standard
---Purpose: Returns the number of extremum distances.
raises NotDone from StdFail
is static;
IsParallel(me) returns Boolean from Standard
---Purpose: Returns True if E1 and E2 are parallel.
raises NotDone from StdFail
is static;
SquareDistance(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the value of the <N>th extremum square distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
ParameterOnE1(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the parameter on the first edge of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
PointOnE1(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance
-- on the edge E1.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
ParameterOnE2(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the parameter on the second edge of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
PointOnE2(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance
-- on the edge E2.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
TrimmedSquareDistances(me; dist11, distP12, distP21, distP22: out Real;
P11, P12, P21, P22: out Pnt)
---Purpose: if the edges is a trimmed curve,
-- dist11 is a square distance between the point on E1
-- of parameter FirstParameter and the point of
-- parameter FirstParameter on E2.
is static;
fields
myExtrem : ExtCC from Extrema;
myHC : HCurve from BRepAdaptor;
end ExtCC;

View File

@@ -0,0 +1,180 @@
// File: BRepExtrema_ExtCC.cxx
// Created: Wed Dec 15 16:48:53 1993
// Author: Christophe MARION
// <cma@sdsun1>
#include <BRepExtrema_ExtCC.ixx>
#include <BRep_Tool.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <Extrema_POnCurv.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HCurve.hxx>
//=======================================================================
//function : BRepExtrema_ExtCC
//purpose :
//=======================================================================
BRepExtrema_ExtCC::BRepExtrema_ExtCC()
{
}
//=======================================================================
//function : BRepExtrema_ExtCC
//purpose :
//=======================================================================
BRepExtrema_ExtCC::BRepExtrema_ExtCC
(const TopoDS_Edge& E1,
const TopoDS_Edge& E2)
{
Initialize(E2);
Perform(E1);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
{
Standard_Real V1,V2;
BRepAdaptor_Curve Curv(E2);
myHC = new BRepAdaptor_HCurve(Curv);
BRep_Tool::Range(E2,V1,V2);
myExtrem.SetCurve (2, myHC->Curve(),V1,V2);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
{
Standard_Real U1, U2;
BRepAdaptor_Curve Curv(E1);
Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
BRep_Tool::Range(E1,U1,U2);
myExtrem.SetCurve (1, HC->Curve(), U1, U2);
myExtrem.Perform();
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtCC::IsDone()const
{
return myExtrem.IsDone();
}
//=======================================================================
//function : NbExt
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_ExtCC::NbExt() const
{
return myExtrem.NbExt();
}
//=======================================================================
//function : IsMin
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtCC::IsParallel() const
{
return myExtrem.IsParallel();
}
//=======================================================================
//function : SquareDistance
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtCC::SquareDistance
(const Standard_Integer N) const
{
return myExtrem.SquareDistance(N);
}
//=======================================================================
//function : ParameterOnE1
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtCC::ParameterOnE1
(const Standard_Integer N) const
{
Extrema_POnCurv POnE1, POnE2;
myExtrem.Points(N, POnE1, POnE2);
return POnE1.Parameter();
}
//=======================================================================
//function : PointOnE1
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtCC::PointOnE1
(const Standard_Integer N) const
{
Extrema_POnCurv POnE1, POnE2;
myExtrem.Points(N, POnE1, POnE2);
gp_Pnt P = POnE1.Value();
return P;
}
//=======================================================================
//function : ParameterOnE2
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtCC::ParameterOnE2
(const Standard_Integer N) const
{
Extrema_POnCurv POnE1, POnE2;
myExtrem.Points(N, POnE1, POnE2);
return POnE2.Parameter();
}
//=======================================================================
//function : PointOnE2
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtCC::PointOnE2
(const Standard_Integer N) const
{
Extrema_POnCurv POnE1, POnE2;
myExtrem.Points(N, POnE1, POnE2);
gp_Pnt P = POnE2.Value();
return P;
}
//=======================================================================
//function : TrimmedSquareDistances
//purpose :
//=======================================================================
void BRepExtrema_ExtCC::TrimmedSquareDistances
(Standard_Real& dist11,
Standard_Real& dist12,
Standard_Real& dist21,
Standard_Real& dist22,
gp_Pnt& pnt11,
gp_Pnt& pnt12,
gp_Pnt& pnt21,
gp_Pnt& pnt22) const
{
myExtrem.TrimmedSquareDistances(dist11,dist12,dist21, dist22,
pnt11,pnt12, pnt21, pnt22);
}

View File

@@ -0,0 +1,109 @@
-- File: BRepExtrema_ExtCF.cdl
-- Created: Wed Feb 9 12:57:57 1994
-- Author: Laurent PAINNOT
-- <lpa@phylox>
---Copyright: Matra Datavision 1994
class ExtCF from BRepExtrema
uses
Integer from Standard,
Real from Standard,
Boolean from Standard,
Face from TopoDS,
Edge from TopoDS,
HSurface from BRepAdaptor,
ExtCS from Extrema,
SequenceOfReal from TColStd,
SequenceOfPOnCurv from Extrema,
SequenceOfPOnSurf from Extrema,
Pnt from gp
raises
NotDone from StdFail,
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns ExtCF from BRepExtrema;
Create(V : Edge from TopoDS;
E : Face from TopoDS)
---Purpose: It calculates all the distances.
returns ExtCF from BRepExtrema;
Initialize(me: in out; E : Face from TopoDS)
---Purpose:
is static;
Perform(me: in out; V : Edge from TopoDS;
E : Face from TopoDS)
---Purpose: An exception is raised if the fields have not been
-- initialized.
-- Be careful: this method uses the Face only for
-- classify not for the fields.
raises TypeMismatch from Standard
is static;
IsDone(me) returns Boolean from Standard
---Purpose: True if the distances are found.
is static;
NbExt(me) returns Integer from Standard
---Purpose: Returns the number of extremum distances.
raises NotDone from StdFail
is static;
SquareDistance(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the value of the <N>th extremum square distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
IsParallel (me) returns Boolean
---Purpose: Returns True if the curve is on a parallel surface.
is static;
ParameterOnEdge(me; N : Integer from Standard) returns Real
---Purpose: Returns the parameters on the Edge of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
ParameterOnFace(me; N : Integer from Standard; U, V: out Real)
---Purpose: Returns the parameters on the Face of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
PointOnEdge(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
PointOnFace(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
fields
myExtrem : ExtCS from Extrema;
mynbext : Integer from Standard;
mySqDist : SequenceOfReal from TColStd;
myPointsOnS : SequenceOfPOnSurf from Extrema;
myPointsOnC : SequenceOfPOnCurv from Extrema;
myHS : HSurface from BRepAdaptor;
end ExtCF;

View File

@@ -0,0 +1,209 @@
// File: BRepExtrema_ExtCF.cxx
// Created: Wed Dec 15 16:48:53 1993
// Author: Christophe MARION
// <cma@sdsun1>
#include <BRepExtrema_ExtCF.ixx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <Geom_Curve.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Extrema_POnCurv.hxx>
#include <Extrema_POnSurf.hxx>
#include <gp_Pnt2d.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HCurve.hxx>
//=======================================================================
//function : BRepExtrema_ExtCF
//purpose :
//=======================================================================
BRepExtrema_ExtCF::BRepExtrema_ExtCF()
{
}
//=======================================================================
//function : BRepExtrema_ExtCF
//purpose :
//=======================================================================
BRepExtrema_ExtCF::BRepExtrema_ExtCF
(const TopoDS_Edge& E,
const TopoDS_Face& F)
{
Initialize(F);
Perform(E, F);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void BRepExtrema_ExtCF::Initialize(const TopoDS_Face& F2)
{
BRepAdaptor_Surface Surf(F2);
myHS = new BRepAdaptor_HSurface(Surf);
Standard_Real Tol = BRep_Tool::Tolerance(F2);
Standard_Real U1, U2, V1, V2;
BRepTools::UVBounds(F2, U1, U2, V1, V2);
myExtrem.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol, Tol);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E,
const TopoDS_Face& F2)
{
mySqDist.Clear();
myPointsOnS.Clear();
myPointsOnC.Clear();
Standard_Real U1, U2;
BRep_Tool::Range(E, U1, U2);
BRepAdaptor_Curve Curv(E);
Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
myExtrem.Perform(HC->Curve(), U1, U2);
// exploration des points et classification:
BRepClass_FaceClassifier classifier;
gp_Pnt2d Puv;
TopAbs_State state;
Standard_Real Tol = BRep_Tool::Tolerance(F2);
Extrema_POnCurv P1;
Extrema_POnSurf P2;
mynbext = 0;
if(!myExtrem.IsDone())
return;
if (myExtrem.IsParallel()) {
mySqDist.Append(myExtrem.SquareDistance(1));
mynbext = 1;
}
else {
for (Standard_Integer i = 1; i <= myExtrem.NbExt(); i++) {
myExtrem.Points(i, P1, P2);
P2.Parameter(U1, U2);
Puv.SetCoord(U1, U2);
classifier.Perform(F2, Puv, Tol);
state = classifier.State();
if(state == TopAbs_ON || state == TopAbs_IN) {
mynbext++;
mySqDist.Append(myExtrem.SquareDistance(i));
myPointsOnC.Append(P1);
myPointsOnS.Append(P2);
}
}
}
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtCF::IsDone()const
{
return myExtrem.IsDone();
}
//=======================================================================
//function : IsParallel
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtCF::IsParallel()const
{
return myExtrem.IsParallel();
}
//=======================================================================
//function : NbExt
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_ExtCF::NbExt() const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
return mynbext;
}
//=======================================================================
//function : SquareDistance
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtCF::SquareDistance
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
return mySqDist.Value(N);
}
//=======================================================================
//function : ParameterOnFace
//purpose :
//=======================================================================
void BRepExtrema_ExtCF::ParameterOnFace(const Standard_Integer N,
Standard_Real& U,
Standard_Real& V) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
myPointsOnS.Value(N).Parameter(U, V);
}
//=======================================================================
//function : ParameterOnEdge
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtCF::ParameterOnEdge
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
return myPointsOnC.Value(N).Parameter();
}
//=======================================================================
//function : PointOnEdge
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtCF::PointOnEdge
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPointsOnC.Value(N).Value();
return P;
}
//=======================================================================
//function : PointOnFace
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtCF::PointOnFace
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPointsOnS.Value(N).Value();
return P;
}

View File

@@ -0,0 +1,111 @@
-- File: BRepExtrema_ExtFF.cdl
-- Created: Wed Feb 9 13:01:29 1994
-- Author: Laurent PAINNOT
-- <lpa@phylox>
---Copyright: Matra Datavision 1994
class ExtFF from BRepExtrema
uses
Integer from Standard,
Real from Standard,
Boolean from Standard,
Face from TopoDS,
SequenceOfReal from TColStd,
SequenceOfPOnSurf from Extrema,
ExtSS from Extrema,
Pnt from gp,
HSurface from BRepAdaptor
raises
NotDone from StdFail,
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns ExtFF from BRepExtrema;
Create(F1 : Face from TopoDS;
F2 : Face from TopoDS)
---Purpose: It calculates all the distances.
returns ExtFF from BRepExtrema;
Initialize(me: in out; F2 : Face from TopoDS)
---Purpose:
is static;
Perform(me: in out; F1 : Face from TopoDS;
F2 : Face from TopoDS)
---Purpose: An exception is raised if the fields have not been
-- initialized.
-- Be careful: this method uses the Face F2 only for
-- classify, not for the fields.
raises TypeMismatch from Standard
is static;
IsDone(me) returns Boolean from Standard
---Purpose: True if the distances are found.
is static;
IsParallel (me) returns Boolean
---Purpose: Returns True if the surfaces are parallel.
is static;
NbExt(me) returns Integer from Standard
---Purpose: Returns the number of extremum distances.
raises NotDone from StdFail
is static;
SquareDistance(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the value of the <N>th extremum square distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
ParameterOnFace1(me; N : Integer from Standard; U, V: out Real)
---Purpose: Returns the parameters on the Face F1 of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
ParameterOnFace2(me; N : Integer from Standard; U, V: out Real)
---Purpose: Returns the parameters on the Face F2 of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
PointOnFace1(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
PointOnFace2(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
fields
myExtrem : ExtSS from Extrema;
mynbext : Integer from Standard;
mySqDist : SequenceOfReal from TColStd;
myPointsOnS1: SequenceOfPOnSurf from Extrema;
myPointsOnS2: SequenceOfPOnSurf from Extrema;
myHS : HSurface from BRepAdaptor;
end ExtFF;

View File

@@ -0,0 +1,218 @@
// File: BRepExtrema_ExtFF.cxx
// Created: Wed Dec 15 16:48:53 1993
// Author: Christophe MARION
// <cma@sdsun1>
// modified by mps (juillet 96 ): on utilise BRepAdaptor a la place de
// GeomAdaptor dans Initialize et Perform.
#include <BRepExtrema_ExtFF.ixx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <Geom_Curve.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <TopoDS.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom_Surface.hxx>
#include <Extrema_POnSurf.hxx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <BRepAdaptor_HSurface.hxx>
//=======================================================================
//function : BRepExtrema_ExtFF
//purpose :
//=======================================================================
BRepExtrema_ExtFF::BRepExtrema_ExtFF()
{
}
//=======================================================================
//function : BRepExtrema_ExtFF
//purpose :
//=======================================================================
BRepExtrema_ExtFF::BRepExtrema_ExtFF
(const TopoDS_Face& F1,
const TopoDS_Face& F2)
{
Initialize(F2);
Perform(F1,F2);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
{
BRepAdaptor_Surface Surf(F2);
myHS = new BRepAdaptor_HSurface(Surf);
Standard_Real Tol = BRep_Tool::Tolerance(F2);
Standard_Real U1, U2, V1, V2;
BRepTools::UVBounds(F2, U1, U2, V1, V2);
myExtrem.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1,
const TopoDS_Face& F2)
{
Standard_Real U1, U2, V1, V2;
Standard_Integer i;
mySqDist.Clear();
myPointsOnS1.Clear();
myPointsOnS2.Clear();
BRepAdaptor_Surface Surf1(F1);
Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1);
Standard_Real Tol1 = BRep_Tool::Tolerance(F1);
BRepTools::UVBounds(F1, U1, U2, V1, V2);
myExtrem.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1);
// exploration des points et classification:
BRepClass_FaceClassifier classifier;
gp_Pnt2d Puv;
TopAbs_State state1, state2;
Standard_Real Tol2 = BRep_Tool::Tolerance(F2);
Extrema_POnSurf P1, P2;
mynbext = 0;
if (myExtrem.IsParallel()) {
mySqDist.Append(myExtrem.SquareDistance(1));
mynbext = 1;
}
else {
for (i = 1; i <= myExtrem.NbExt(); i++) {
myExtrem.Points(i, P1, P2);
P1.Parameter(U1, U2);
Puv.SetCoord(U1, U2);
classifier.Perform(F1, Puv, Tol1);
state1 = classifier.State();
P2.Parameter(U1, U2);
Puv.SetCoord(U1, U2);
classifier.Perform(F2, Puv, Tol2);
state2 = classifier.State();
if((state1 == TopAbs_ON || state1 == TopAbs_IN) &&
(state2 == TopAbs_ON || state2 == TopAbs_IN)) {
mynbext++;
mySqDist.Append(myExtrem.SquareDistance(i));
myPointsOnS1.Append(P1);
myPointsOnS2.Append(P2);
}
}
}
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtFF::IsDone()const
{
return myExtrem.IsDone();
}
//=======================================================================
//function : IsParallel
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtFF::IsParallel()const
{
return myExtrem.IsParallel();
}
//=======================================================================
//function : NbExt
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_ExtFF::NbExt() const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
return mynbext;
}
//=======================================================================
//function : SquareDistance
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtFF::SquareDistance
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
return mySqDist.Value(N);
}
//=======================================================================
//function : ParameterOnFace1
//purpose :
//=======================================================================
void BRepExtrema_ExtFF::ParameterOnFace1(const Standard_Integer N,
Standard_Real& U,
Standard_Real& V) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
myPointsOnS1.Value(N).Parameter(U, V);
}
//=======================================================================
//function : PointOnFace1
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtFF::PointOnFace1
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPointsOnS1.Value(N).Value();
return P;
}
//=======================================================================
//function : ParameterOnFace2
//purpose :
//=======================================================================
void BRepExtrema_ExtFF::ParameterOnFace2(const Standard_Integer N,
Standard_Real& U,
Standard_Real& V) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
myPointsOnS2.Value(N).Parameter(U, V);
}
//=======================================================================
//function : PointOnFace1
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtFF::PointOnFace2
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPointsOnS2.Value(N).Value();
return P;
}

View File

@@ -0,0 +1,91 @@
-- File: BRepExtrema_ExtPC.cdl
-- Created: Fri Dec 3 16:01:30 1993
-- Author: Christophe MARION
-- <cma@sdsun1>
---Copyright: Matra Datavision 1993
class ExtPC from BRepExtrema
uses
Integer from Standard,
Real from Standard,
Boolean from Standard,
Vertex from TopoDS,
Edge from TopoDS,
ExtPC from Extrema,
Pnt from gp,
HCurve from BRepAdaptor
raises
NotDone from StdFail,
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns ExtPC from BRepExtrema;
Create(V : Vertex from TopoDS;
E : Edge from TopoDS)
---Purpose: It calculates all the distances.
returns ExtPC from BRepExtrema;
Initialize(me: in out; E : Edge from TopoDS)
---Purpose:
is static;
Perform(me: in out; V : Vertex from TopoDS)
---Purpose: An exception is raised if the fields have not been
-- initialized.
raises TypeMismatch from Standard
is static;
IsDone(me) returns Boolean from Standard
---Purpose: True if the distances are found.
is static;
NbExt(me) returns Integer from Standard
---Purpose: Returns the number of extremum distances.
raises NotDone from StdFail
is static;
IsMin(me; N : Integer from Standard) returns Boolean from Standard
---Purpose: Returns True if the <N>th extremum distance is a
-- minimum.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
SquareDistance(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the value of the <N>th extremum square distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
Parameter(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the parameter on the edge of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
Point(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
TrimmedSquareDistances(me; dist1 : out Real from Standard;
dist2 : out Real from Standard;
pnt1 : out Pnt from gp;
pnt2 : out Pnt from gp)
---Purpose: if the curve is a trimmed curve,
-- dist1 is a square distance between <P> and the point
-- of parameter FirstParameter <pnt1> and
-- dist2 is a square distance between <P> and the point
-- of parameter LastParameter <pnt2>.
is static;
fields
myExtrem : ExtPC from Extrema;
myHC : HCurve from BRepAdaptor;
end ExtPC;

View File

@@ -0,0 +1,147 @@
// File: BRepExtrema_ExtPC.cxx
// Created: Wed Dec 15 16:48:53 1993
// Author: Christophe MARION
// <cma@sdsun1>
#include <BRepExtrema_ExtPC.ixx>
#include <BRep_Tool.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HCurve.hxx>
//=======================================================================
//function : BRepExtrema_ExtPC
//purpose :
//=======================================================================
BRepExtrema_ExtPC::BRepExtrema_ExtPC()
{
}
//=======================================================================
//function : BRepExtrema_ExtPC
//purpose :
//=======================================================================
BRepExtrema_ExtPC::BRepExtrema_ExtPC
(const TopoDS_Vertex& V,
const TopoDS_Edge& E)
{
Initialize(E);
Perform(V);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
{
Standard_Real U1,U2;
BRepAdaptor_Curve Curv(E);
myHC = new BRepAdaptor_HCurve(Curv);
BRep_Tool::Range(E,U1,U2);
myExtrem.Initialize(myHC->Curve(),U1,U2);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepExtrema_ExtPC::Perform(const TopoDS_Vertex& V)
{
gp_Pnt P = BRep_Tool::Pnt(V);
myExtrem.Perform(P);
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtPC::IsDone()const
{
return myExtrem.IsDone();
}
//=======================================================================
//function : NbExt
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_ExtPC::NbExt() const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
return myExtrem.NbExt();
}
//=======================================================================
//function : IsMin
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtPC::IsMin
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
return myExtrem.IsMin(N);
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtPC::SquareDistance
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
return myExtrem.SquareDistance(N);
}
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtPC::Parameter
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
return myExtrem.Point(N).Parameter();
}
//=======================================================================
//function : Point
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtPC::Point
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
return (myExtrem.Point(N).Value());
}
//=======================================================================
//function : TrimmedDistances
//purpose :
//=======================================================================
void BRepExtrema_ExtPC::TrimmedSquareDistances
(Standard_Real& dist1,
Standard_Real& dist2,
gp_Pnt& pnt1,
gp_Pnt& pnt2) const
{
myExtrem.TrimmedSquareDistances(dist1,dist2,pnt1,pnt2);
}

View File

@@ -0,0 +1,85 @@
-- File: BRepExtrema_ExtPF.cdl
-- Created: Wed Feb 9 08:33:21 1994
-- Author: Laurent PAINNOT
-- <lpa@phylox>
---Copyright: Matra Datavision 1994
class ExtPF from BRepExtrema
uses
Integer from Standard,
Real from Standard,
Boolean from Standard,
Face from TopoDS,
Vertex from TopoDS,
ExtPS from Extrema,
SequenceOfReal from TColStd,
SequenceOfPOnSurf from Extrema,
Pnt from gp,
Surface from BRepAdaptor
raises
NotDone from StdFail,
OutOfRange from Standard,
TypeMismatch from Standard
is
Create returns ExtPF from BRepExtrema;
Create(V : Vertex from TopoDS;
E : Face from TopoDS)
---Purpose: It calculates all the distances.
returns ExtPF from BRepExtrema;
Initialize(me: in out; E : Face from TopoDS)
---Purpose:
is static;
Perform(me: in out; V : Vertex from TopoDS;
E : Face from TopoDS)
---Purpose: An exception is raised if the fields have not been
-- initialized.
-- Be careful: this method uses the Face only for
-- classify not for the fields.
raises TypeMismatch from Standard
is static;
IsDone(me) returns Boolean from Standard
---Purpose: True if the distances are found.
is static;
NbExt(me) returns Integer from Standard
---Purpose: Returns the number of extremum distances.
raises NotDone from StdFail
is static;
SquareDistance(me; N : Integer from Standard) returns Real from Standard
---Purpose: Returns the value of the <N>th extremum square distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
Parameter(me; N : Integer from Standard; U, V: out Real)
---Purpose: Returns the parameters on the Face of the <N>th
-- extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
Point(me; N : Integer from Standard) returns Pnt from gp
---Purpose: Returns the Point of the <N>th extremum distance.
raises NotDone from StdFail,
OutOfRange from Standard
is static;
fields
myExtrem : ExtPS from Extrema;
mynbext : Integer from Standard;
mySqDist : SequenceOfReal from TColStd;
myPoints : SequenceOfPOnSurf from Extrema;
mySurf : Surface from BRepAdaptor;
end ExtPF;

View File

@@ -0,0 +1,153 @@
// File: BRepExtrema_ExtPF.cxx
// Created: Wed Dec 15 16:48:53 1993
// Author: Christophe MARION
// <cma@sdsun1>
// modified by MPS (june 96) : on utilise BRepClass_FaceClassifier seulement
// si IsDone de Extrema est vrai
#include <BRepExtrema_ExtPF.ixx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <StdFail_NotDone.hxx>
#include <Standard_Failure.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <gp_Pnt2d.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HCurve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_HSurface.hxx>
//=======================================================================
//function : BRepExtrema_ExtPF
//purpose :
//=======================================================================
BRepExtrema_ExtPF::BRepExtrema_ExtPF()
{
}
//=======================================================================
//function : BRepExtrema_ExtPF
//purpose :
//=======================================================================
BRepExtrema_ExtPF::BRepExtrema_ExtPF
(const TopoDS_Vertex& V,
const TopoDS_Face& E)
{
Initialize(E);
Perform(V, E);
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& F)
{
// cette surface doit etre en champ. Extrema ne fait
// pas de copie et prend seulement un pointeur dessus.
mySurf.Initialize(F, Standard_False);
Standard_Real Tol = BRep_Tool::Tolerance(F);
Standard_Real U1, U2, V1, V2;
BRepTools::UVBounds(F, U1, U2, V1, V2);
myExtrem.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& V,
const TopoDS_Face& E)
{
mySqDist.Clear();
myPoints.Clear();
gp_Pnt P = BRep_Tool::Pnt(V);
myExtrem.Perform(P);
// exploration des points et classification:
if (myExtrem.IsDone()) {
BRepClass_FaceClassifier classifier;
gp_Pnt2d Puv;
Standard_Real U1, U2;
TopAbs_State state;
Standard_Real Tol = BRep_Tool::Tolerance(E);
mynbext = 0;
for (Standard_Integer i = 1; i <= myExtrem.NbExt(); i++) {
myExtrem.Point(i).Parameter(U1, U2);
Puv.SetCoord(U1, U2);
classifier.Perform(E, Puv, Tol);
state = classifier.State();
if(state == TopAbs_ON || state == TopAbs_IN) {
mynbext++;
mySqDist.Append(myExtrem.SquareDistance(i));
myPoints.Append(myExtrem.Point(i));
}
}
}
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_ExtPF::IsDone()const
{
return myExtrem.IsDone();
}
//=======================================================================
//function : NbExt
//purpose :
//=======================================================================
Standard_Integer BRepExtrema_ExtPF::NbExt() const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
return mynbext;
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
Standard_Real BRepExtrema_ExtPF::SquareDistance
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
return mySqDist.Value(N);
}
//=======================================================================
//function : Parameters
//purpose :
//=======================================================================
void BRepExtrema_ExtPF::Parameter(const Standard_Integer N,
Standard_Real& U,
Standard_Real& V) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
myPoints.Value(N).Parameter(U, V);
}
//=======================================================================
//function : Point
//purpose :
//=======================================================================
gp_Pnt BRepExtrema_ExtPF::Point
(const Standard_Integer N) const
{
if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
gp_Pnt P = myPoints.Value(N).Value();
return P;
}

View File

@@ -0,0 +1,22 @@
-- File: BRepExtrema_Poly.cdl
-- Created: Fri Sep 8 10:53:43 1995
-- Author: Christophe MARION
-- <cma@ecolox>
---Copyright: Matra Datavision 1995
class Poly from BRepExtrema
uses
Boolean from Standard,
Shape from TopoDS,
Pnt from gp
is
Distance(myclass; S1,S2 : Shape from TopoDS;
P1,P2 : out Pnt from gp;
dist : out Real from Standard)
---Purpose: returns Standard_True if OK.
returns Boolean from Standard;
end Poly;

View File

@@ -0,0 +1,109 @@
// File: BRepExtrema_Poly.cxx
// Created: Fri Sep 8 11:03:14 1995
// Author: Christophe MARION
// <cma@ecolox>
#include <BRepExtrema_Poly.ixx>
#include <BRep_Tool.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <Precision.hxx>
#include <Poly_Triangulation.hxx>
#include <TColgp_Array1OfPnt.hxx>
//=======================================================================
//function : Distance
//purpose :
//=======================================================================
Standard_Boolean BRepExtrema_Poly::Distance (const TopoDS_Shape& S1,
const TopoDS_Shape& S2,
gp_Pnt& P1,
gp_Pnt& P2,
Standard_Real& dist)
{
Standard_Real dCur;
dist = Precision::Infinite();
Standard_Integer i,i1,i2,n;
TopExp_Explorer exFace;
Handle(Poly_Triangulation) Tr;
TopLoc_Location L;
Standard_Integer nbn1 = 0;
for (exFace.Init(S1, TopAbs_FACE);
exFace.More();
exFace.Next()) {
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
nbn1 += Tr->NbNodes();
}
Standard_Integer nbn2 = 0;
for (exFace.Init(S2, TopAbs_FACE);
exFace.More();
exFace.Next()) {
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull())
nbn2 += Tr->NbNodes();
}
if (nbn1 == 0 || nbn2 == 0) return Standard_False;
TColgp_Array1OfPnt TP1(1,nbn1);
nbn1 = 0;
for (exFace.Init(S1, TopAbs_FACE);
exFace.More();
exFace.Next()) {
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull()) {
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
n = Tr->NbNodes();
for (i = 1;i <= n; i++) {
nbn1++;
TP1.SetValue(nbn1,Nod(i).Transformed(L));
}
}
}
TColgp_Array1OfPnt TP2(1,nbn2);
nbn2 = 0;
for (exFace.Init(S2, TopAbs_FACE);
exFace.More();
exFace.Next()) {
const TopoDS_Face& F = TopoDS::Face(exFace.Current());
Tr = BRep_Tool::Triangulation(F,L);
if (!Tr.IsNull()) {
const TColgp_Array1OfPnt& Nod = Tr->Nodes();
n = Tr->NbNodes();
for (i = 1;i <= n; i++) {
nbn2++;
TP2.SetValue(nbn2,Nod(i).Transformed(L));
}
}
}
for (i1 = 1; i1 <= nbn1; i1++) {
gp_Pnt& PP1 = TP1(i1);
for (i2 = 1; i2 <= nbn2; i2++) {
gp_Pnt& PP2 = TP2(i2);
dCur = PP1.Distance(PP2);
if (dist > dCur) {
P1 = PP1;
P2 = PP2;
dist = dCur;
}
}
}
return Standard_True;
}

View File

@@ -0,0 +1,126 @@
-- File: BRepExtrema_SolutionElem.cdl
-- Created: Thu Apr 18 10:00:04 1996
-- Author: Maria PUMBORIOS
-- Author: Herve LOUESSARD
-- <jpi@sgi64>
---Copyright: Matra Datavision 1996
class SolutionElem from BRepExtrema
---Purpose: This class is used to store information relative to the
-- minimum distance between two shapes.
uses
Real from Standard,
Pnt from gp,
Vertex from TopoDS,
Face from TopoDS,
Edge from TopoDS,
SupportType from BRepExtrema
is
Create returns SolutionElem from BRepExtrema;
Create( d: Real from Standard;
Pt: Pnt from gp;
SolType: SupportType from BRepExtrema ;
vertex: Vertex from TopoDS) returns SolutionElem from BRepExtrema;
--- Purpose: initialisation of the fields
-- This creator is used when the solution of a distance is a Vertex.
-- The different initialized fields are: _ the distance d
-- _ the solution point
-- _ the type of solution
-- _ and the Vertex.
Create( d: Real from Standard;
Pt: Pnt from gp;
SolType: SupportType from BRepExtrema ;
edge: Edge from TopoDS;
t: Real from Standard ) returns SolutionElem from BRepExtrema;
---Purpose: initialisation of the fiels.
-- This constructor is used when the solution of distance is on
-- an Edge. The different initialized fields are:
-- _ the distance d,
-- _ the solution point,
-- _ the type of solution,
-- _ the Edge,
-- _ and the parameter t to locate the solution.
Create( d: Real from Standard;
Pt: Pnt from gp;
SolType: SupportType from BRepExtrema ;
face: Face from TopoDS;
u: Real from Standard;
v: Real from Standard ) returns SolutionElem from BRepExtrema;
--- Purpose: initialisation of the fields
-- This constructor is used when the solution of distance is in
-- a Face. The different initialized fields are:
-- _ the distance d,
-- _ the solution point,
-- _ the type of solution,
-- _ the Face,
-- _ and the parameter u et v to locate the solution.
Dist(me) returns Real from Standard;
--- Purpose:
-- returns the value of the minimum distance.
--
Point(me) returns Pnt from gp;
--- Purpose:
-- returns the solution point.
--
SupportKind(me) returns SupportType from BRepExtrema;
--- Purpose:
-- returns the Support type :
-- IsVertex => The solution is a vertex.
-- IsOnEdge => The solution belongs to an Edge.
-- IsInFace => The solution is inside a Face.
Vertex(me) returns Vertex from TopoDS;
--- Purpose:
-- returns the vertex if the solution is a Vertex.
Edge(me) returns Edge from TopoDS;
--- Purpose:
-- returns the vertex if the solution is an Edge.
Face(me) returns Face from TopoDS;
--- Purpose:
-- returns the vertex if the solution is an Face.
EdgeParameter(me; par1:out Real from Standard);
--- Purpose:
-- returns the parameter t if the solution is on Edge.
FaceParameter(me; par1: out Real from Standard; par2:out Real from Standard);
--- Purpose:
-- returns the parameters u et v if the solution is in a Face.
fields
myDist : Real from Standard;
myPoint : Pnt from gp;
mySupType : SupportType from BRepExtrema;
myVertex : Vertex from TopoDS;
myEdge : Edge from TopoDS;
myFace : Face from TopoDS;
myPar1 : Real from Standard;
myPar2 : Real from Standard;
end;

View File

@@ -0,0 +1,102 @@
// File: BRepExtrema_SolutionElem.cxx
// Created: Mon Apr 22 17:03:37 1996
// Author: Maria PUMBORIOS
// Author: Herve LOUESSARD
// <mps@sgi64>
#include <BRepExtrema_SolutionElem.ixx>
/*********************************************************************************/
/*********************************************************************************/
BRepExtrema_SolutionElem::BRepExtrema_SolutionElem()
: myDist(0.), myPoint(0.,0.,0.), mySupType(BRepExtrema_IsVertex), myPar1(0.), myPar2(0.)
{
}
/*********************************************************************************/
BRepExtrema_SolutionElem::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.)
{
}
/*********************************************************************************/
BRepExtrema_SolutionElem::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.)
{
}
/*********************************************************************************/
BRepExtrema_SolutionElem::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)
{
}
/*********************************************************************************/
Standard_Real BRepExtrema_SolutionElem::Dist() const
{ return(myDist);
}
/*********************************************************************************/
gp_Pnt BRepExtrema_SolutionElem::Point() const
{ return (myPoint);
}
/*********************************************************************************/
BRepExtrema_SupportType BRepExtrema_SolutionElem::SupportKind() const
{ return (mySupType);
}
/*********************************************************************************/
TopoDS_Vertex BRepExtrema_SolutionElem::Vertex() const
{ return (myVertex);
}
/*********************************************************************************/
TopoDS_Edge BRepExtrema_SolutionElem::Edge() const
{ return (myEdge);
}
/*********************************************************************************/
TopoDS_Face BRepExtrema_SolutionElem::Face() const
{ return (myFace);
}
/*********************************************************************************/
void BRepExtrema_SolutionElem::EdgeParameter(Standard_Real& par1) const
{ par1 = myPar1;
}
/*********************************************************************************/
void BRepExtrema_SolutionElem::FaceParameter(Standard_Real& par1, Standard_Real& par2) const
{ par1 = myPar1;
par2 = myPar2;
}
/*********************************************************************************/
/*********************************************************************************/