1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +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

1
src/TopClass/FILES Executable file
View File

@@ -0,0 +1 @@
TopClass.cxx

59
src/TopClass/TopClass.cdl Executable file
View File

@@ -0,0 +1,59 @@
-- File: TopClass.cdl
-- Created: Tue Nov 17 14:09:55 1992
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1992
package TopClass
---Purpose: The package TopClass provides Classification
-- algorithms. A Classification algorithm is used to
-- compute if a point is inside, outside or on the
-- boundary of a Shape.
uses
gp,
TopTrans, -- complex transitions
TopAbs, -- enumerations Orientation and State
TopoDS,
IntRes2d, -- to describe the result of intersections
IntCurveSurface
--- TopExp ------------- Pas Utilise mais sinon ca plante !!!
is
deferred generic class Intersection2d;
---Purpose: Describes the intersection algorithm for 2d
-- classifications.
generic class Classifier2d;
---Purpose: Basic algorithm for 2d classifications.
deferred generic class FaceExplorer;
---Purpose: Defines the description of a face for the
-- FaceClassifier.
generic class FaceClassifier, FClass2d;
---Purpose: Algorithm for classification in a Face.
deferred class Intersection3d;
---Purpose: Describes the intersection algorithm for 3d
-- classifications.
generic class Classifier3d;
---Purpose: Basic algorithm for 3d classification.
deferred class SolidExplorer;
---Purpose: Defines the description of a solid for the
-- SolidClassifier.
generic class SolidClassifier;
---Purpose: Algorithm for classification in a Solid.
end TopClass;

13
src/TopClass/TopClass.cxx Executable file
View File

@@ -0,0 +1,13 @@
// File: TopClass.cxx
// Created: Thu Sep 14 14:35:43 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <Standard_Type.hxx>
// trace functions called in TopClass_FaceClassifier.gxx
static Standard_Boolean TopClass_traceFC = Standard_False;
Standard_EXPORT void TopClass_SettraceFC(const Standard_Boolean b) { TopClass_traceFC = b; }
Standard_EXPORT Standard_Boolean TopClass_GettraceFC() { return TopClass_traceFC; }

View File

@@ -0,0 +1,98 @@
-- File: Classifier2d.cdl
-- Created: Tue Nov 17 11:38:42 1992
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1992
-- Modified by skv - Wed Jul 12 15:15:38 2006 OCC12627
generic class Classifier2d from TopClass
(TheEdge as any;
TheIntersector as any) -- as Intersection2d from TopClass
---Purpose:
uses
Lin2d from gp,
CurveTransition from TopTrans,
Orientation from TopAbs,
State from TopAbs
raises
DomainError
is
Create returns Classifier2d from TopClass;
---Purpose: Creates an undefined classifier.
Reset(me : in out; L : Lin2d from gp; P : Real; Tol : Real)
---Purpose: Starts a classification process. The point to
-- classify is the origin of the line <L>. <P> is
-- the original length of the segment on <L> used to
-- compute intersections. <Tol> is the tolerance
-- attached to the line segment in intersections.
is static;
Compare(me : in out; E : TheEdge;
Or : Orientation from TopAbs)
---Purpose: Updates the classification process with the edge
-- <E> from the boundary.
raises
DomainError -- The classifier has not been set
is static;
Parameter(me) returns Real
---Purpose: Returns the current value of the parameter.
---C++: inline
is static;
Intersector(me : in out) returns TheIntersector
---Purpose: Returns the intersecting algorithm.
--
---C++: inline
---C++: return &
is static;
ClosestIntersection(me) returns Integer
---Purpose: Returns 0 if the last compared edge had no
-- relevant intersection. Else returns the index of
-- this intersection in the last intersection
-- algorithm.
--
---C++: inline
is static;
State(me) returns State from TopAbs
---Purpose: Returns the current state of the point.
--
---C++: inline
is static;
-- Modified by skv - Wed Jul 12 15:15:38 2006 OCC12627 Begin
IsHeadOrEnd(me)
---Purpose: Returns the Standard_True if the closest intersection point
-- represents head or end of the edge. Returns Standard_False
-- otherwise.
---C++: inline
returns Boolean from Standard
is static;
-- Modified by skv - Wed Jul 12 15:15:38 2006 OCC12627 End
fields
myIsSet : Boolean from Standard;
myFirstCompare : Boolean from Standard;
myFirstTrans : Boolean from Standard;
myLin : Lin2d from gp;
myParam : Real from Standard;
myTolerance : Real from Standard;
myTrans : CurveTransition from TopTrans;
myIntersector : TheIntersector;
myClosest : Integer from Standard;
myState : State from TopAbs;
-- Modified by skv - Wed Jul 12 15:15:38 2006 OCC12627 Begin
myIsHeadOrEnd : Boolean from Standard;
-- Modified by skv - Wed Jul 12 15:15:38 2006 OCC12627 End
end Classifier2d;

View File

@@ -0,0 +1,233 @@
// File: TopClass_Classifier2d.gxx
// Created: Tue Nov 17 17:47:02 1992
// Author: Remi LEQUETTE
// <rle@phylox>
// Modified: Mon May 13 15:20:43 1996
// Author: Laurent BUCHARD
// <lbr@sherlox>
//-- Reinitialisation des transitions complexes
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
#include <gp_Vec2d.hxx>
//=======================================================================
//function : TopClass_Classifier2d
//purpose :
//=======================================================================
TopClass_Classifier2d::TopClass_Classifier2d() :
myIsSet(Standard_False),
myFirstCompare(Standard_True),
myIsHeadOrEnd(Standard_False), // skv OCC12627
myState(TopAbs_UNKNOWN) // skv OCC12627
{
}
//=======================================================================
//function : Reset
//purpose :
//=======================================================================
void TopClass_Classifier2d::Reset(const gp_Lin2d& L,
const Standard_Real P,
const Standard_Real Tol)
{
myLin = L;
myParam = P;
myTolerance = Tol;
myState = TopAbs_UNKNOWN;
myFirstCompare = Standard_True;
myFirstTrans = Standard_True;
myClosest = 0;
myIsSet = Standard_True;
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
myIsHeadOrEnd = Standard_False;
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
}
//=======================================================================
//function : Compare
//purpose :
//=======================================================================
void TopClass_Classifier2d::Compare(const TheEdge& E,
const TopAbs_Orientation Or)
{
// intersect the edge and the segment
myClosest = 0;
myIntersector.Perform(myLin,myParam,myTolerance,E);
if (!myIntersector.IsDone()) return;
if ((myIntersector.NbPoints() == 0)&&
(myIntersector.NbSegments() == 0)) return;
// find the closest point
Standard_Integer iPoint, iSegment, nbPoints, nbSegments;
#ifndef DEB
const IntRes2d_IntersectionPoint *PClosest = NULL;
#else
const IntRes2d_IntersectionPoint *PClosest;
#endif
Standard_Real dMin = RealLast();
nbPoints = myIntersector.NbPoints();
for (iPoint = 1; iPoint <= nbPoints; iPoint++) {
const IntRes2d_IntersectionPoint& PInter = myIntersector.Point(iPoint);
// test for ON
if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head) {
myClosest = iPoint;
myState = TopAbs_ON;
return;
}
Standard_Real paramfirst = PInter.ParamOnFirst();
if (paramfirst < dMin) {
myClosest = iPoint;
PClosest = &PInter;
dMin = paramfirst;
}
}
// for the segments we only test the first point
nbSegments = myIntersector.NbSegments();
for (iSegment = 1; iSegment <= nbSegments; iSegment++) {
const IntRes2d_IntersectionSegment& SegInter =
myIntersector.Segment(iSegment);
const IntRes2d_IntersectionPoint& PInter = SegInter.FirstPoint();
if (PInter.TransitionOfFirst().PositionOnCurve() == IntRes2d_Head) {
myClosest = nbPoints + iSegment+ iSegment - 1;
myState = TopAbs_ON;
return;
}
Standard_Real paramfirst = PInter.ParamOnFirst();
if (paramfirst < dMin) {
myClosest = nbPoints + iSegment+iSegment - 1;
PClosest = &PInter;
dMin = paramfirst;
}
}
// if no point was found return
if (myClosest == 0) return;
// if the Edge is INTERNAL or EXTERNAL, no problem
if (Or == TopAbs_INTERNAL) {
myState = TopAbs_IN;
return;
}
else if (Or == TopAbs_EXTERNAL) {
myState = TopAbs_OUT;
return;
}
if ( ! myFirstCompare ) {
Standard_Boolean b = (dMin > myParam);
if (b) {
// dMin > myParam : le point le plus proche (dMin) trouve dans CETTE
// intersection ligne,arete n'est pas le plus proche
// de TOUS les points d'intersection avec les autres aretes (myParam).
return;
}
}
// process the closest point PClosest, found at dMin on line.
myFirstCompare = Standard_False;
if(myParam > dMin) { //-- lbr le 13 mai 96
myFirstTrans = Standard_True;
}
myParam = dMin;
const IntRes2d_Transition& T2 = PClosest->TransitionOfSecond();
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
// Standard_Boolean isHeadorEnd = (T2.PositionOnCurve() == IntRes2d_Head) ||
// (T2.PositionOnCurve() == IntRes2d_End);
myIsHeadOrEnd = (T2.PositionOnCurve() == IntRes2d_Head) ||
(T2.PositionOnCurve() == IntRes2d_End);
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End
// transition on the segment
#ifndef DEB
TopAbs_Orientation SegTrans = TopAbs_FORWARD;
#else
TopAbs_Orientation SegTrans;
#endif
const IntRes2d_Transition& T1 = PClosest->TransitionOfFirst();
switch (T1.TransitionType()) {
case IntRes2d_In :
if (Or == TopAbs_REVERSED) SegTrans = TopAbs_REVERSED;
else SegTrans = TopAbs_FORWARD;
break;
case IntRes2d_Out :
if (Or == TopAbs_REVERSED) SegTrans = TopAbs_FORWARD;
else SegTrans = TopAbs_REVERSED;
break;
case IntRes2d_Touch :
switch (T1.Situation()) {
case IntRes2d_Inside :
if (Or == TopAbs_REVERSED) SegTrans = TopAbs_EXTERNAL;
else SegTrans = TopAbs_INTERNAL;
break;
case IntRes2d_Outside :
if (Or == TopAbs_REVERSED) SegTrans = TopAbs_INTERNAL;
else SegTrans = TopAbs_EXTERNAL;
break;
case IntRes2d_Unknown : return;
}
break;
case IntRes2d_Undecided : return;
}
// are we inside the Edge ?
// const IntRes2d_Transition& T2 = PClosest->TransitionOfSecond();
if ( ! myIsHeadOrEnd ) {
// PClosest is inside the edge
switch (SegTrans) {
case TopAbs_FORWARD :
case TopAbs_EXTERNAL :
myState = TopAbs_OUT;
break;
case TopAbs_REVERSED :
case TopAbs_INTERNAL :
myState = TopAbs_IN;
break;
}
}
else {
// PClosest is Head or End of the edge : update the complex transition
gp_Dir2d Tang2d,Norm2d;
Standard_Real Curv;
myIntersector.LocalGeometry
(E,PClosest->ParamOnSecond(),Tang2d,Norm2d,Curv);
gp_Dir Tang(Tang2d.X(),Tang2d.Y(),0.);
gp_Dir Norm(Norm2d.X(),Norm2d.Y(),0.);
if (myFirstTrans) {
gp_Dir D(myLin.Direction().X(),myLin.Direction().Y(),0.);
myTrans.Reset(D);
myFirstTrans = Standard_False;
}
TopAbs_Orientation Ort;
if (T2.PositionOnCurve() == IntRes2d_Head) Ort = TopAbs_FORWARD;
else Ort = TopAbs_REVERSED;
myTrans.Compare(RealEpsilon(), Tang, Norm, Curv, SegTrans, Ort);
myState = myTrans.StateBefore();
}
}

View File

@@ -0,0 +1,60 @@
// File: TopClass_Classifier2d.lxx
// Created: Tue Nov 17 17:57:55 1992
// Author: Remi LEQUETTE
// <rle@phylox>
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627
//=======================================================================
//function : Parameter
//purpose :
//=======================================================================
inline Standard_Real TopClass_Classifier2d::Parameter() const
{
return myParam;
}
//=======================================================================
//function : Intersector
//purpose :
//=======================================================================
inline TheIntersector& TopClass_Classifier2d::Intersector()
{
return myIntersector;
}
//=======================================================================
//function : ClosestIntersection
//purpose :
//=======================================================================
inline Standard_Integer TopClass_Classifier2d::ClosestIntersection() const
{
return myClosest;
}
//=======================================================================
//function : State
//purpose :
//=======================================================================
inline TopAbs_State TopClass_Classifier2d::State() const
{
return myState;
}
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 Begin
//=======================================================================
//function : IsHeadOrEnd
//purpose :
//=======================================================================
inline Standard_Boolean TopClass_Classifier2d::IsHeadOrEnd() const
{
return myIsHeadOrEnd;
}
// Modified by skv - Wed Jul 12 15:20:58 2006 OCC12627 End

View File

@@ -0,0 +1,80 @@
-- File: Classifier3d.cdl
-- Created: Wed Mar 30 09:38:14 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
generic class Classifier3d from TopClass
(TheIntersector as any) -- as Intersection3d from TopClass
---Purpose:
uses
Lin from gp,
CurveTransition from TopTrans,
Orientation from TopAbs,
State from TopAbs,
Face from TopoDS
raises
DomainError from Standard
is
Create returns Classifier3d from TopClass;
---Purpose: Creates an undefined classifier.
Reset(me : in out; L : Lin from gp;
P : Real from Standard;
Tol : Real from Standard)
---Purpose: Starts a classification process. The point to
-- classify is the origin of the line <L>. <P> is
-- the original length of the segment on <L> used to
-- compute intersections. <Tol> is the tolerance
-- attached to the intersections.
is static;
Compare(me : in out; F : Face from TopoDS;
Or : Orientation from TopAbs)
---Purpose: Updates the classification process with the face
-- <F> from the boundary.
raises
DomainError -- The classifier has not been set
is static;
Parameter(me) returns Real
---Purpose: Returns the current value of the parameter.
---C++: inline
is static;
HasIntersection(me) returns Boolean from Standard
---Purpose: Returns True if an intersection is computed.
is static;
Intersector(me : in out) returns TheIntersector
---Purpose: Returns the intersecting algorithm.
--
---C++: inline
---C++: return &
is static;
State(me) returns State from TopAbs
---Purpose: Returns the current state of the point.
--
---C++: inline
is static;
fields
isSet : Boolean from Standard;
myFace : Face from TopoDS;
myLin : Lin from gp;
myParam : Real from Standard;
myTolerance : Real from Standard;
myState : State from TopAbs;
hasIntersect : Boolean from Standard;
myIntersector : TheIntersector;
end Classifier3d;

View File

@@ -0,0 +1,72 @@
// File: TopClass_Classifier3d.gxx
// Created: Wed Mar 30 09:54:56 1994
// Author: Laurent BUCHARD
// <lbr@fuegox>
//======================================================================
TopClass_Classifier3d::TopClass_Classifier3d() : isSet(Standard_False)
{
}
//======================================================================
void TopClass_Classifier3d::Reset(const gp_Lin& L,
const Standard_Real Param,
const Standard_Real Tol) {
myLin = L;
myParam = RealLast();
myTolerance = Tol;
myState = TopAbs_UNKNOWN;
isSet = Standard_True;
}
//======================================================================
#include <IntCurveSurface_IntersectionPoint.hxx>
#include <IntCurveSurface_TransitionOnCurve.hxx>
void TopClass_Classifier3d::Compare(const TopoDS_Face& Face,
const TopAbs_Orientation Orientation) {
if(!isSet) {
cout<<" Call to TopClass_Classifier3d::Compare without a Reset ! ";
return;
}
hasIntersect = Standard_False;
myIntersector.Perform(myLin,myParam,myTolerance,Face);
if(myIntersector.IsDone()) {
if(myIntersector.HasAPoint()) {
hasIntersect = Standard_True;
if(myIntersector.WParameter() < myParam) {
myParam = myIntersector.WParameter();
myFace = myIntersector.Face();
if(Abs(myParam)<=myTolerance) {
//-- #########################################
cout<<" myParam = "<<myParam<<" ds TopClass_Classifier3d.gxx "<<endl;
//-- #########################################
myState = TopAbs_ON;
}
else {
//-- The intersection point between the line and a face F of the solid
//-- is in the face F or On a boundary of the face
if(myIntersector.Transition() == IntCurveSurface_Out) {
//-- The line is going from inside the solid to outside the solid.
myState = TopAbs_IN;
}
else if(myIntersector.Transition() == IntCurveSurface_In) {
myState = TopAbs_OUT;
}
else {
cout<<" -------- Probleme ds TopClass_Classifier3d.gxx "<<endl;
}
}
}
else {
//-- No point has been found by the myIntersector.
//-- Or a Point has been found with a greater parameter.
}
} //-- myIntersector Has a point
else {
//-- The myIntersector failed.
}
} //-- Face has not been rejected
}

View File

@@ -0,0 +1,26 @@
// File: TopClass_Classifier3d.lxx
// Created: Wed Mar 30 14:12:48 1994
// Author: Laurent BUCHARD
// <lbr@fuegox>
inline Standard_Real TopClass_Classifier3d::Parameter() const
{
return myParam;
}
//=======================================================================
inline TheIntersector& TopClass_Classifier3d::Intersector()
{
return(myIntersector);
}
//=======================================================================
inline Standard_Boolean TopClass_Classifier3d::HasIntersection() const
{
return(hasIntersect);
}
//=======================================================================
inline TopAbs_State TopClass_Classifier3d::State() const
{
return(myState);
}

View File

@@ -0,0 +1,91 @@
-- File: FaceClassifier.cdl
-- Created: Tue Nov 17 14:34:03 1992
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1992
generic class FaceClassifier from TopClass
(TheFaceExplorer as any;
TheEdge as any;
TheIntersection2d as any)
---Purpose: Provides an algorithm to classify a point in a 2D
-- face (or in the UV space of a face on a surface).
uses
Pnt2d from gp,
Position from IntRes2d,
State from TopAbs
raises
DomainError
class FClass2d instantiates Classifier2d from TopClass
(TheEdge, TheIntersection2d);
is
Create returns FaceClassifier from TopClass;
---Purpose: Empty constructor, undefined algorithm.
Create(F : in out TheFaceExplorer; P : Pnt2d from gp; Tol : Real)
returns FaceClassifier from TopClass;
---Purpose: Creates an algorithm to classify the Point P with
-- Tolerance <T> on the face described by <F>.
Perform(me : in out;
F : in out TheFaceExplorer; P : Pnt2d from gp; Tol : Real)
---Purpose: Classify the Point P with Tolerance <T> on the
-- face described by <F>.
is static;
State(me) returns State from TopAbs
---Purpose: Returns the result of the classification.
is static;
Rejected(me) returns Boolean
---Purpose: Returns True when the state was computed by a
-- rejection. The state is OUT.
---C++: inline
is static;
NoWires(me) returns Boolean
---Purpose: Returns True if the face contains no wire. The
-- state is IN.
---C++: inline
is static;
Edge(me) returns TheEdge
---Purpose: Returns the Edge used to determine the
-- classification. When the State is ON this is the
-- Edge containing the point.
---C++: return const &
raises
DomainError -- when no edge was used (rejected or nowires)
is static;
EdgeParameter(me) returns Real from Standard
---Purpose: Returns the parameter on Edge() used to determine the
-- classification.
raises
DomainError -- when no edge was used (rejected or nowires)
is static;
Position(me) returns Position from IntRes2d
---Purpose: Returns the position of the point on the edge
-- returned by Edge.
---C++: inline
is static;
fields
myClassifier : FClass2d is protected;
myEdge : TheEdge is protected;
myEdgeParameter : Real from Standard is protected;
myPosition : Position from IntRes2d is protected;
rejected : Boolean from Standard is protected;
nowires : Boolean from Standard is protected;
end FaceClassifier;

View File

@@ -0,0 +1,167 @@
// File: TopClass_FaceClassifier.gxx
// Created: Wed Nov 18 12:21:14 1992
// Author: Remi LEQUETTE
// <rle@phylox>
// Modified by skv - Thu Jul 13 18:00:34 2006 OCC12627
// The method Perform is totally rewroted.
#include <IntRes2d_IntersectionSegment.hxx>
#include <IntRes2d_IntersectionPoint.hxx>
//=======================================================================
//function : TopClass_FaceClassifier
//purpose :
//=======================================================================
TopClass_FaceClassifier::TopClass_FaceClassifier()
{
}
//=======================================================================
//function : TopClass_FaceClassifier
//purpose :
//=======================================================================
TopClass_FaceClassifier::TopClass_FaceClassifier(TheFaceExplorer& FExp,
const gp_Pnt2d& P,
const Standard_Real Tol)
{
Perform(FExp,P,Tol);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void TopClass_FaceClassifier::Perform(TheFaceExplorer& Fexp,
const gp_Pnt2d& P,
const Standard_Real Tol)
{
// Test for rejection.
rejected = Fexp.Reject(P);
if (rejected)
return;
gp_Lin2d aLine;
Standard_Real aParam;
Standard_Boolean IsValidSegment = Fexp.Segment(P, aLine, aParam);
TheEdge anEdge;
TopAbs_Orientation anEdgeOri;
Standard_Integer aClosestInd;
IntRes2d_IntersectionPoint aPInter;
TopAbs_State aState;
Standard_Boolean IsWReject;
Standard_Boolean IsEReject;
nowires = Standard_True;
while (IsValidSegment) {
myClassifier.Reset(aLine, aParam, Tol);
for (Fexp.InitWires(); Fexp.MoreWires(); Fexp.NextWire()) {
nowires = Standard_False;
IsWReject = Fexp.RejectWire(aLine, myClassifier.Parameter());
if (!IsWReject) {
// test this wire
for (Fexp.InitEdges(); Fexp.MoreEdges(); Fexp.NextEdge()) {
IsEReject = Fexp.RejectEdge(aLine, myClassifier.Parameter());
if (!IsEReject) {
// test this edge
Fexp.CurrentEdge(anEdge, anEdgeOri);
if (anEdgeOri == TopAbs_FORWARD || anEdgeOri == TopAbs_REVERSED) {
myClassifier.Compare(anEdge, anEdgeOri);
aClosestInd = myClassifier.ClosestIntersection();
if (aClosestInd != 0) {
// save the closest edge
TheIntersection2d &anIntersector = myClassifier.Intersector();
Standard_Integer aNbPnts = anIntersector.NbPoints();
myEdge = anEdge;
if (aClosestInd <= aNbPnts) {
aPInter = anIntersector.Point(aClosestInd);
} else {
aClosestInd -= aNbPnts;
if (aClosestInd&1) {
aPInter = anIntersector.
Segment((aClosestInd + 1)/2).FirstPoint();
} else {
aPInter = anIntersector.
Segment((aClosestInd + 1)/2).LastPoint();
}
}
myPosition = aPInter.
TransitionOfSecond().PositionOnCurve();
myEdgeParameter = aPInter.ParamOnSecond();
}
// if we are ON, we stop
aState = myClassifier.State();
if (aState == TopAbs_ON)
return;
}
}
}
// if we are out of the wire we stop
aState = myClassifier.State();
if (aState == TopAbs_OUT)
return;
}
}
if (!myClassifier.IsHeadOrEnd())
break;
// Bad case for classification. Trying to get another segment.
IsValidSegment = Fexp.OtherSegment(P, aLine, aParam);
}
}
//=======================================================================
//function : State
//purpose :
//=======================================================================
TopAbs_State TopClass_FaceClassifier::State() const
{
if (rejected) return TopAbs_OUT;
else if (nowires) return TopAbs_IN;
else return myClassifier.State();
}
//=======================================================================
//function : Edge
//purpose :
//=======================================================================
const TheEdge& TopClass_FaceClassifier::Edge() const
{
Standard_DomainError_Raise_if(rejected,
"TopClass_FaceClassifier::Edge:rejected");
return myEdge;
}
//=======================================================================
//function : EdgeParameter
//purpose :
//=======================================================================
Standard_Real TopClass_FaceClassifier::EdgeParameter() const
{
Standard_DomainError_Raise_if(rejected,
"TopClass_FaceClassifier::EdgeParameter:rejected");
return myEdgeParameter;
}

View File

@@ -0,0 +1,37 @@
// File: TopClass_FaceClassifier.lxx
// Created: Wed Nov 18 12:27:58 1992
// Author: Remi LEQUETTE
// <rle@phylox>
#include TheFaceExplorer_hxx
//=======================================================================
//function : Rejected
//purpose :
//=======================================================================
inline Standard_Boolean TopClass_FaceClassifier::Rejected() const
{
return rejected;
}
//=======================================================================
//function : Nowires
//purpose :
//=======================================================================
inline Standard_Boolean TopClass_FaceClassifier::NoWires() const
{
return nowires;
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
inline IntRes2d_Position TopClass_FaceClassifier::Position() const
{
return myPosition;
}

View File

@@ -0,0 +1,75 @@
-- File: FaceExplorer.cdl
-- Created: Tue Nov 17 16:39:19 1992
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1992
deferred generic class FaceExplorer from TopClass
(TheEdge as any)
---Purpose: Describe an exploration of a 2D face suitable for
-- classification.
uses
Orientation from TopAbs,
Pnt2d from gp,
Lin2d from gp
is
Reject(me; P : Pnt2d from gp) returns Boolean
---Purpose: Should return True if the point is outside a
-- bounding volume of the face.
is deferred;
Segment(me; P : Pnt2d from gp;
L : out Lin2d from gp; Par : out Real)
---Purpose: Returns in <L>, <Par> a segment having at least
-- one intersection with the face boundary to
-- compute intersections.
is deferred;
InitWires(me : in out)
---Purpose: Starts an exploration of the wires.
is deferred;
MoreWires(me) returns Boolean
---Purpose: Returns True if there is a current wire.
---C++: inline
is deferred;
NextWire(me : in out)
---Purpose: Sets the explorer to the next wire and returns
-- False if there are no more wires.
is deferred;
RejectWire(me; L : Lin2d from gp; Par : Real) returns Boolean
---Purpose: Returns True if the wire bounding volume does not
-- intersect the segment.
is deferred;
InitEdges(me : in out)
---Purpose: Starts an exploration of the edges of the current
-- wire.
is deferred;
MoreEdges(me) returns Boolean
---Purpose: Returns True if there is a current edge.
---C++: inline
is deferred;
NextEdge(me : in out)
---Purpose: Sets the explorer to the next wire and returns
-- False if there are no more wires.
is deferred;
RejectEdge(me; L : Lin2d from gp; Par : Real) returns Boolean
---Purpose: Returns True if the edge bounding volume does not
-- intersect the segment.
is deferred;
CurrentEdge(me; E : out TheEdge; Or : out Orientation from TopAbs)
---Purpose: Curent edge in current wire and its orientation
is deferred;
end FaceExplorer;

View File

@@ -0,0 +1,4 @@
// File: TopClass_FaceExplorer.gxx
// Created: Mon May 12 10:09:07 1997
// Author: Didier PIFFAULT
// <dpf@motox.paris1.matra-dtv.fr>

View File

@@ -0,0 +1,4 @@
// File: TopClass_FaceExplorer.lxx
// Created: Wed Oct 23 17:06:29 1996
// Author: Laurent BUCHARD
// <lbr@cracbox.paris1.matra-dtv.fr>

View File

@@ -0,0 +1,52 @@
-- File: Intersection2d.cdl
-- Created: Tue Nov 17 12:24:18 1992
-- Author: Remi LEQUETTE
-- <rle@phylox>
---Copyright: Matra Datavision 1992
deferred generic class Intersection2d from TopClass
(TheEdge as any) inherits Intersection from IntRes2d
---Purpose: Template class for the intersection algorithm
-- required by the 2D classifications.
--
-- The results should be expressed as the result of
-- Intersection from IntRes2d. The class used to
-- instantiate the Classifier2d can be inherited from
-- the Intersection algorithms inherited from
-- Intersection from IntRes2d.
--
-- It is not necesary to return all the Intersection
-- points, the point with the smallest parameter
-- value on the segment is enough.
uses
Lin2d from gp,
Dir2d from gp
is
Initialize;
---Purpose: An empty constructor is required.
Perform(me : in out; L : Lin2d from gp; P : Real; Tol : Real; E : TheEdge)
---Purpose: Performs the intersection between the 2d line
-- segment (<L>, <P>) and the Edge <E>. The line
-- segment is the part of the 2d line <L> of
-- parameter range [0, <P>] (P is positive and can be
-- RealLast()). Tol is the Tolerance on the segment.
-- The order is relevant, the first argument is the
-- segment, the second the Edge.
is deferred;
LocalGeometry(me; E : TheEdge; U : Real;
T : out Dir2d from gp;
N : out Dir2d from gp;
C : out Real)
---Purpose: Returns in <T>, <N> and <C> the tangent, normal
-- and curvature of the edge <E> at parameter value
-- <U>.
is deferred;
end Intersection2d;

View File

@@ -0,0 +1,4 @@
// File: TopClass_Intersection2d.gxx
// Created: Wed Oct 23 17:07:02 1996
// Author: Laurent BUCHARD
// <lbr@cracbox.paris1.matra-dtv.fr>

View File

@@ -0,0 +1,82 @@
-- File: TopClass_Intersection3d.cdl
-- Created: Wed Mar 30 14:37:00 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
deferred class Intersection3d from TopClass
---Purpose: Template class for the intersection algorithm required
-- by the 3D classifications.
--
-- (a intersection point near the origin of the line, ie.
-- at a distance less or equal than <tolerance>, will be
-- returned even if it has a negative parameter.)
--
uses
Lin from gp,
Pnt from gp,
Face from TopoDS,
State from TopAbs,
IntersectionPoint from IntCurveSurface
is
Initialize;
---Purpose: Empty constructor.
Perform(me: in out; L : Lin from gp;
Prm : Real from Standard;
Tol : Real from Standard;
Face : Face from TopoDS)
---Purpose: Perform the intersection between the
-- segment L(0) ... L(Prm) and the Face <Face>.
--
-- Only the point with the smallest parameter on the
-- line is returned.
--
-- The Tolerance <Tol> is used to determine if the
-- first point of the segment is near the face. In
-- that case, the parameter of the intersection point
-- on the line can be a negative value (greater than -Tol).
is deferred;
IsDone(me)
---Purpose: True is returned when the intersection have been computed.
returns Boolean from Standard
is deferred;
HasAPoint(me)
---Purpose: True is returned if a point has been found.
returns Boolean from Standard
is deferred;
Point(me)
---Purpose: Returns the Intersection Point.
--
---C++: return const &
returns IntersectionPoint from IntCurveSurface
is deferred;
State(me)
---Purpose: Returns the state of the point on the face.
-- The values can be either TopAbs_IN
-- ( the point is in the face)
-- or TopAbs_ON
-- ( the point is on a boudary of the face).
returns State from TopAbs
is deferred;
---------------------- Loacl Geometry avec courbureS dans une
-- direction et la direction normale
end Intersection3d;

View File

@@ -0,0 +1,7 @@
// File: TopClass_Intersection3d.cxx
// Created: Wed Oct 23 17:07:20 1996
// Author: Laurent BUCHARD
// <lbr@cracbox.paris1.matra-dtv.fr>

View File

@@ -0,0 +1,78 @@
-- File: TopClass_SolidClassifier.cdl
-- Created: Wed Mar 30 18:28:29 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
generic class SolidClassifier from TopClass
(TheSolidExplorer as any;
TheIntersection3d as any)
---Purpose: Provides an algorithm to classify a point in a solid.
uses
Pnt from gp,
Face from TopoDS,
Shape from TopoDS,
State from TopAbs
raises
DomainError from Standard
is
Create
---Purpose: Empty constructor.
returns SolidClassifier from TopClass;
Create(S : in out TheSolidExplorer;
P : Pnt from gp;
Tol : Real from Standard)
---Purpose: Constructor to classify the point P with the
-- tolerance Tol on the solid S.
returns SolidClassifier from TopClass;
Perform(me : in out;
S : in out TheSolidExplorer;
P : Pnt from gp;
Tol : Real from Standard);
---Purpose: Classify the point P with the
-- tolerance Tol on the solid S.
Rejected(me)
---Purpose: Returns True if the classification has been
-- computed by rejection.
-- The State is then OUT.
returns Boolean from Standard;
State(me) returns State from TopAbs;
---Purpose: Returns the result of the classification.
IsOnAFace(me) returns Boolean from Standard;
---Purpose: Returns True when the point is a point of a face.
Face(me)
---Purpose: Returns the face used to determine the
-- classification. When the state is ON, this is the
-- face containing the point.
--
-- When Rejected() returns True, Face() has no signification.
returns Face from TopoDS;
fields
myFace : Face from TopoDS;
myState : Integer from Standard; -- 1: Rejected 2: IsOnFace 3: In 4: Out
end SolidClassifier;

View File

@@ -0,0 +1,182 @@
//-- TopClass_SolidClassifier.gxx
#ifdef DEB
Standard_EXPORT Standard_Boolean TopClass_GettraceFC();
#endif
#include <gp_Lin.hxx>
//extern void DrawSegment(const gp_Pnt& P1,const gp_Lin& L,const Standard_Real par);
//extern Standard_Boolean DebugDrawSegment;
TopClass_SolidClassifier::TopClass_SolidClassifier()
{
}
TopClass_SolidClassifier::TopClass_SolidClassifier(TheSolidExplorer& S,
const gp_Pnt& P,
const Standard_Real Tol) {
Perform(S,P,Tol);
}
void TopClass_SolidClassifier::Perform(TheSolidExplorer& SolidExplorer,
const gp_Pnt& P,
const Standard_Real Tol) {
#ifdef DEB
Standard_Boolean trace = TopClass_GettraceFC();
#endif
myState = 0;
if(SolidExplorer.Reject(P) == Standard_False) {
//-- There is no rejection between the Shape loaded in the SolidExplorer
//-- and the point P.
gp_Lin L;
Standard_Real Par;
//-- We compute the intersection betwwen the line builded in the Solid Explorer
//-- and the shape.
SolidExplorer.Segment(P,L,Par);
TheIntersection3d Intersector;
Standard_Real parmin = RealLast();
for(SolidExplorer.InitShell();
SolidExplorer.MoreShell();
SolidExplorer.NextShell()) {
if(SolidExplorer.RejectShell(L) == Standard_False) {
for(SolidExplorer.InitFace();
SolidExplorer.MoreFace();
SolidExplorer.NextFace()) {
if(SolidExplorer.RejectFace(L) == Standard_False) {
Intersector.Perform(L,Par,Tol,SolidExplorer.CurrentFace());
if(Intersector.IsDone()) {
if(Intersector.HasAPoint()) {
if(Intersector.WParameter() < parmin) {
parmin = Intersector.WParameter();
if(Abs(parmin)<=Tol) {
#ifdef DEB
if (trace) {
//-- #########################################
cout<<" parmin = "<<parmin<< " avec Par = "<<Par;
cout<<" ds TopClass_SolidClassifier.gxx "<<endl;
//-- #########################################
}
#endif
myState = 2;
myFace = Intersector.Face();
}
else if(Intersector.State()==TopAbs_IN) {
//-- The intersection point between the line and a face F
// -- of the solid is in the face F
if(Intersector.Transition() == IntCurveSurface_Out) {
//-- The line is going from inside the solid to outside
//-- the solid.
myState = 3; //-- IN --
}
else if(Intersector.Transition() == IntCurveSurface_In) {
myState = 4; //-- OUT --
}
else {
#ifdef DEB
cout<<"*Probleme ds TopClass_SolidClassifier.gxx"<<endl;
#endif
}
myFace = Intersector.Face();
}
else if(Intersector.State()==TopAbs_ON) {
//-- The intersection point between the line and a face F
//-- of the solid is in the face F
if(Intersector.Transition() == IntCurveSurface_Out) {
//-- The line is going from inside the solid to outside
//-- the solid.
myState = 3; //-- IN --
}
else if(Intersector.Transition() == IntCurveSurface_In) {
myState = 4; //-- OUT --
}
else {
#ifdef DEB
cout<<"*Probleme ds TopClass_SolidClassifier.gxx "<<endl;
#endif
}
#ifdef DEB
//-- #########################################
// cout<<" Intersector.State() == TopAbs_ON";
// cout<<" ds TopClass_SolidClassifier.gxx "<<endl;
// cout<<" Transition : ";
// if(myState==3) { cout<<" IN "; }
// else if(myState==4) { cout<<" OUT "; }
// else { cout<<" PB "; }
// cout<<endl;
//-- #########################################
#endif
//-- myState = 2;
myFace = Intersector.Face();
}
}
else {
//-- No point has been found by the intersector.
//-- Or a Point has been found with a greater parameter.
}
} //-- Intersector Has a point
else {
//-- The intersector failed.
}
} //-- Face has not been rejected
else {
myState = 1;
}
}
} //-- Exploration of the faces
} //-- Shell has not been rejected
else {
myState=1;
}
} //-- Exploration of the shells
#ifdef DEB
//#################################################
SolidExplorer.DumpSegment(P,L,parmin,State());
//#################################################
#endif
} //-- Solid has not been rejected
else {
myState = 1;
}
}
TopAbs_State TopClass_SolidClassifier::State() const {
if(myState==2) return(TopAbs_ON);
if(myState==4) return(TopAbs_OUT); //--
else if(myState==3) return(TopAbs_IN); //--
return(TopAbs_OUT);
}
TopoDS_Face TopClass_SolidClassifier::Face() const {
return(myFace);
}
Standard_Boolean TopClass_SolidClassifier::Rejected() const {
return(myState==1);
}
Standard_Boolean TopClass_SolidClassifier::IsOnAFace() const {
return(myState==2);
}

View File

@@ -0,0 +1,104 @@
-- File: SolidExplorer.cdl
-- Created: Thu Mar 10 14:02:10 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
deferred class SolidExplorer from TopClass
---Purpose: Provide an exploration of a BRep Shape for the
-- classification.
uses
Pnt from gp,
Lin from gp,
Face from TopoDS,
Shape from TopoDS
is
Reject(me; P : Pnt from gp) returns Boolean
---Purpose: Should return True if the point is outside a
-- bounding volume of the shape.
is deferred;
Segment(me: in out; P : Pnt from gp;
L : out Lin from gp; Par : out Real)
---Purpose: Returns in <L>, <Par> a segment having at least
-- one intersection with the shape boundary to
-- compute intersections.
--
is deferred;
OtherSegment(me: in out; P : Pnt from gp;
L : out Lin from gp; Par : out Real)
---Purpose: Returns in <L>, <Par> a segment having at least
-- one intersection with the shape boundary to
-- compute intersections.
--
-- The First Call to this method returns a line which
-- point to a point of the first face of the shape.
-- The Second Call provide a line to the second face
-- and so on.
--
-- if the method is called N times on a shape with F
-- faces (N>F) the line point to other points on the
-- face 1,2,3 ... N
is deferred;
InitShell(me : in out)
---Purpose: Starts an exploration of the shells.
is deferred;
MoreShells(me) returns Boolean
---Purpose: Returns True if there is a current shell.
is deferred;
NextShell(me : in out)
---Purpose: Sets the explorer to the next shell and returns
-- False if there are no more wires.
is deferred;
RejectShell(me; L : Lin from gp; Par : Real) returns Boolean
---Purpose: Returns True if the shell bounding volume does not
-- intersect the segment.
is deferred;
InitFace(me : in out)
---Purpose: Starts an exploration of the faces.
is deferred;
MoreFaces(me) returns Boolean
---Purpose: Returns True if there is a current face.
is deferred;
NextFace(me : in out)
---Purpose: Sets the explorer to the next face and returns
-- False if there are no more wires.
is deferred;
CurrentFace(me) returns Face from TopoDS
---Purpose: Returns the current face.
is deferred;
RejectFace(me; L : Lin from gp; Par : Real) returns Boolean
---Purpose: Returns True if the face bounding volume does not
-- intersect the segment.
is deferred;
--------------------------------------------------------------------
end SolidExplorer;

View File

@@ -0,0 +1,6 @@
// File: TopClass_SolidExplorer.cxx
// Created: Wed Oct 23 17:07:40 1996
// Author: Laurent BUCHARD
// <lbr@cracbox.paris1.matra-dtv.fr>