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

52
src/BRepClass3d/BRepClass3d.cdl Executable file
View File

@@ -0,0 +1,52 @@
-- File: BRepClass3d.cdl
-- Created: Mon Apr 18 09:56:10 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
package BRepClass3d
uses
gp,
TopAbs,
TopoDS,
TopTools,
TCollection,
TopExp,
TopClass,
BRepClass,
Geom2dInt,
IntCurveSurface,
IntCurvesFace,
Bnd,
BRepAdaptor
is
class Intersector3d;
class MapOfInter instantiates
DataMap from TCollection(Shape from TopoDS,
Address from Standard,
ShapeMapHasher from TopTools);
class SolidExplorer;
class SolidPassiveClassifier instantiates Classifier3d from TopClass
(Intersector3d from BRepClass3d);
---class SClassifier instantiates SolidClassifier from TopClass
--- (SolidExplorer from BRepClass3d,
--- Intersector3d from BRepClass3d);
class SClassifier;
class SolidClassifier;
end BRepClass3d;

View File

@@ -0,0 +1,138 @@
-- File: BRepClass3d_Intersector3d.cdl
-- Created: Fri Apr 1 09:14:28 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
class Intersector3d from BRepClass3d
uses
Lin from gp,
Pnt from gp,
Face from TopoDS,
Shape from TopoDS,
State from TopAbs,
TransitionOnCurve from IntCurveSurface
is
Create returns Intersector3d from BRepClass3d;
---Purpose: Empty constructor.
Perform(me: in out; L : Lin from gp;
Prm : Real from Standard;
Tol : Real from Standard;
F : Face from TopoDS)
---Purpose: Perform the intersection between the
-- segment L(0) ... L(Prm) and the Shape <Sh>.
--
-- 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 static;
IsDone(me)
---Purpose: True is returned when the intersection have been computed.
---C++: inline
returns Boolean from Standard
is static;
HasAPoint(me)
---Purpose: True is returned if a point has been found.
---C++: inline
returns Boolean from Standard
is static;
UParameter(me)
---Purpose: Returns the U parameter of the intersection point
-- on the surface.
---C++: inline
returns Real from Standard
is static;
VParameter(me)
---Purpose: Returns the V parameter of the intersection point
-- on the surface.
---C++: inline
returns Real from Standard
is static;
WParameter(me)
---Purpose: Returns the parameter of the intersection point
-- on the line.
---C++: inline
returns Real from Standard
is static;
Pnt(me)
---Purpose: Returns the geometric point of the intersection
-- between the line and the surface.
---C++: inline
---C++: return const &
returns Pnt from gp
is static;
Transition(me)
---Purpose: Returns the transition of the line on the surface.
---C++: inline
returns TransitionOnCurve from IntCurveSurface
is static;
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).
---C++: inline
returns State from TopAbs
is static;
Face(me)
---Purpose: Returns the significant face used to determine
-- the intersection.
--
---C++: inline
---C++: return const &
returns Face from TopoDS
is static;
---------------------- Local Geometry avec courbureS dans une
-- direction et la direction normale
fields
pnt : Pnt from gp;
U : Real from Standard;
V : Real from Standard;
W : Real from Standard;
transition : TransitionOnCurve from IntCurveSurface;
done : Boolean from Standard;
hasapoint : Boolean from Standard;
state : State from TopAbs;
face : Face from TopoDS;
end Intersector3d;

View File

@@ -0,0 +1,130 @@
// File: BRepClass_Intersector3d.cdl
// Created: Fri Apr 1 09:14:28 1994
// Author: Laurent BUCHARD
// <lbr@fuegox>
//-Copyright: Matra Datavision 1994
// Modified by skv - Fri Mar 4 12:07:34 2005 OCC7966
#include <BRepClass3d_Intersector3d.ixx>
#include <IntCurveSurface_IntersectionPoint.hxx>
#include <gp_Lin.hxx>
#include <TopoDS_Face.hxx>
#include <TopAbs.hxx>
#include <IntCurveSurface_HInter.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <Geom_Line.hxx>
#include <gp_Pnt2d.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <BRepAdaptor_HSurface.hxx>
//============================================================================
BRepClass3d_Intersector3d::BRepClass3d_Intersector3d()
: done(Standard_False),hasapoint(Standard_False)
{
}
//============================================================================
void BRepClass3d_Intersector3d::Perform(const gp_Lin& L,
const Standard_Real /*Prm*/,
const Standard_Real Tol,
const TopoDS_Face& Face) {
static IntCurveSurface_HInter HICS;
static BRepAdaptor_Surface surface;
static BRepClass_FaceClassifier classifier2d;
Handle(Geom_Line) geomline = new Geom_Line(L);
GeomAdaptor_Curve LL(geomline);
surface.Initialize(Face,Standard_True);
Standard_Boolean IsUPer, IsVPer;
Standard_Real uperiod=0, vperiod=0;
if ((IsUPer = surface.IsUPeriodic()))
uperiod = surface.UPeriod();
if ((IsVPer = surface.IsVPeriodic()))
vperiod = surface.VPeriod();
Standard_Real U1, U2, V1, V2;
U1 = surface.FirstUParameter();
U2 = surface.LastUParameter();
V1 = surface.FirstVParameter();
V2 = surface.LastVParameter();
//--
Handle(GeomAdaptor_HCurve) HLL = new GeomAdaptor_HCurve(LL);
Handle(BRepAdaptor_HSurface) Hsurface = new BRepAdaptor_HSurface(surface);
//--
HICS.Perform(HLL,Hsurface);
W=RealLast();
if(HICS.IsDone()) {
for(Standard_Integer index=HICS.NbPoints(); index>=1; index--) {
gp_Pnt2d Puv(HICS.Point(index).U(),HICS.Point(index).V());
Standard_Integer N1 = 0;
Standard_Integer N2 = 0;
Standard_Real X = Puv.X();
Standard_Real Y = Puv.Y();
if(IsUPer) {
if(X > U2) {
N1 = RealToInt( (X - U1) / uperiod );
}
if(X < U1) {
N1 = RealToInt( (X - U2) / uperiod );
}
Puv.SetX(X - uperiod * N1);
}
if(IsVPer) {
if(Y > V2) {
N2 = RealToInt ( (Y - V1) / vperiod );
}
if(Y < V1) {
N2 = RealToInt ( (Y - V2) / vperiod );
}
Puv.SetY(Y - vperiod * N2);
}
classifier2d.Perform(Face,Puv,Tol);
TopAbs_State currentstate = classifier2d.State();
if(currentstate==TopAbs_IN || currentstate==TopAbs_ON) {
const IntCurveSurface_IntersectionPoint& HICSPoint = HICS.Point(index);
Standard_Real HICSW = HICSPoint.W();
// Modified by skv - Fri Mar 4 12:07:34 2005 OCC7966 Begin
if((W > HICSW) && (HICSW>-Tol)) {
// if(W > HICSW) {
// Modified by skv - Fri Mar 4 12:07:34 2005 OCC7966 End
hasapoint = Standard_True;
U = HICSPoint.U();
V = HICSPoint.V();
W = HICSW;
transition = HICSPoint.Transition();
pnt = HICSPoint.Pnt();
state = currentstate;
face = Face;
if(Face.Orientation()==TopAbs_REVERSED) {
if(transition == IntCurveSurface_In)
transition = IntCurveSurface_Out;
else
transition = IntCurveSurface_In;
}
}
} //-- classifier state is IN or ON
done = Standard_True;
} //-- Loop on Intersection points.
} //-- HICS.IsDone()
}

View File

@@ -0,0 +1,44 @@
// File: BRepClass3d_Intersector3d.lxx
// Created: Thu Mar 10 14:52:22 1994
// Author: Laurent BUCHARD
// <lbr@fuegox>
//============================================================================
inline Standard_Boolean BRepClass3d_Intersector3d::IsDone() const {
return(done);
}
//============================================================================
inline Standard_Boolean BRepClass3d_Intersector3d::HasAPoint() const {
return(hasapoint);
}
//============================================================================
inline const gp_Pnt& BRepClass3d_Intersector3d::Pnt() const {
return(pnt);
}
//============================================================================
inline Standard_Real BRepClass3d_Intersector3d::UParameter() const {
return(U);
}
//============================================================================
inline Standard_Real BRepClass3d_Intersector3d::VParameter() const {
return(V);
}
//============================================================================
inline Standard_Real BRepClass3d_Intersector3d::WParameter() const {
return(W);
}
//============================================================================
inline IntCurveSurface_TransitionOnCurve BRepClass3d_Intersector3d::Transition() const {
return(transition);
}
//============================================================================
inline TopAbs_State BRepClass3d_Intersector3d::State() const {
return(state);
}
//============================================================================
inline const TopoDS_Face& BRepClass3d_Intersector3d::Face() const {
return(face);
}
//============================================================================

View File

@@ -0,0 +1,88 @@
-- File: BRepClass3d_SClassifier.cdl
-- Created: Mon Jul 15 17:25:58 1996
-- Author: Laurent BUCHARD
-- <lbr@cracbox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class SClassifier from BRepClass3d
---Purpose: Provides an algorithm to classify a point in a solid.
uses
Pnt from gp,
Face from TopoDS,
Shape from TopoDS,
State from TopAbs,
SolidExplorer from BRepClass3d
raises
DomainError from Standard
is
Create
---Purpose: Empty constructor.
returns SClassifier from BRepClass3d;
Create(S : in out SolidExplorer from BRepClass3d;
P : Pnt from gp;
Tol : Real from Standard)
---Purpose: Constructor to classify the point P with the
-- tolerance Tol on the solid S.
returns SClassifier from BRepClass3d;
Perform(me : in out;
S : in out SolidExplorer from BRepClass3d;
P : Pnt from gp;
Tol : Real from Standard);
---Purpose: Classify the point P with the
-- tolerance Tol on the solid S.
--
PerformInfinitePoint(me : in out;
S : in out SolidExplorer from BRepClass3d;
Tol : Real from Standard);
---Purpose: Classify an infinite point 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;
ForceIn(me: in out)
is protected;
ForceOut(me: in out)
is protected;
fields
myFace : Face from TopoDS;
myState : Integer from Standard; -- 1: Rejected 2: IsOnFace 3: In 4: Out
end SClassifier;

View File

@@ -0,0 +1,479 @@
// File: BRepClass3d_SClassifier.cxx
// Created: Mon Jul 15 17:26:21 1996
// Author: Laurent BUCHARD
// <lbr@cracbox.paris1.matra-dtv.fr>
// Modified by skv - Thu Sep 4 11:22:05 2003 OCC578
#include <BRepClass3d_SClassifier.ixx>
#include <gp_Pnt.hxx>
#include <gp_Lin.hxx>
#include <gp_Vec.hxx>
#include <BRepClass3d_Intersector3d.hxx>
#include <TopoDS.hxx>
#include <IntCurvesFace_Intersector.hxx>
// modified by NIZHNY-MKK Mon Jun 21 15:13:40 2004
#include <Precision.hxx>
#include <ElCLib.hxx>
static Standard_Real GetAddToParam(const gp_Lin& L,const Standard_Real P,const Bnd_Box& B);
//extern void DrawSegment(const gp_Pnt& P1,const gp_Lin& L,const Standard_Real par);
//extern Standard_Boolean DebugDrawSegment;
BRepClass3d_SClassifier::BRepClass3d_SClassifier()
{
}
BRepClass3d_SClassifier::BRepClass3d_SClassifier(BRepClass3d_SolidExplorer& S,
const gp_Pnt& P,
const Standard_Real Tol) {
if(S.Reject(P)) {
myState=3; //-- in ds le cas solide sans face
}
else {
Perform(S,P,Tol);
}
}
void BRepClass3d_SClassifier::PerformInfinitePoint(BRepClass3d_SolidExplorer& SolidExplorer,
const Standard_Real /*Tol*/) {
//-- Idee : On prend un point A dans la face1 et un point B dans la face B
//-- ( si on a une seule face , on prend 2 points dans la meme face.)
//--
//-- On intersecte la droite AB avec le solide et on s interesse a la transition du
//-- premier point. Si le solide a une seule face et que la droite AB ne le coupe pas
//-- on ne peut pas decider.
if(SolidExplorer.Reject(gp_Pnt(0,0,0))) {
myState=3; //-- in ds le cas solide sans face
return;
}
Standard_Integer nump = 0;
gp_Pnt A,B;
Standard_Real aParam = 0.5;
myFace.Nullify();
myState=2;
for(SolidExplorer.InitShell();
SolidExplorer.MoreShell() && nump<2;
SolidExplorer.NextShell()) {
for(SolidExplorer.InitFace();
SolidExplorer.MoreFace() && nump<2;
) {
TopoDS_Shape aLocalShape = SolidExplorer.CurrentFace();
TopoDS_Face f = TopoDS::Face(aLocalShape);
// TopoDS_Face f = TopoDS::Face(SolidExplorer.CurrentFace());
SolidExplorer.NextFace();
if(nump==0) {
nump++;
if(SolidExplorer.FindAPointInTheFace(f,A,aParam)) {
if(SolidExplorer.MoreFace() == Standard_False) {
nump++;
SolidExplorer.FindAPointInTheFace(f,B,aParam);
}
}
else {
return;
}
}
else if(nump==1) {
if(SolidExplorer.FindAPointInTheFace(f,B,aParam)) {
nump++;
}
else {
return;
}
}
}
}
//------------------------------------------------------------
Standard_Real parmin = RealLast();
if(A.SquareDistance(B)<0.000001) {
B.SetCoord(A.X()+1,A.Y()+1,A.Z()+1);
}
Standard_Integer cpasbon = 0;
gp_Vec AB(A,B);
do {
switch (cpasbon)
{
case 1 : AB.SetX(-AB.X());break;
case 2 : AB.SetY(-AB.Y());break;
case 3 : AB.SetZ(-AB.Z());break;
case 4 : AB.SetY(-AB.Y());break;
case 5 : AB.SetX(-AB.X());break;
}
gp_Lin L(A,gp_Dir(AB));
//-- cout<<"\npoint A "<<A.X()<<" "<<A.Y()<<" "<<A.Z()<<endl;
//-- cout<<"\npoint B "<<B.X()<<" "<<B.Y()<<" "<<B.Z()<<endl;
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) {
TopoDS_Shape aLocalShape = SolidExplorer.CurrentFace();
TopoDS_Face f = TopoDS::Face(aLocalShape);
// TopoDS_Face f = TopoDS::Face(SolidExplorer.CurrentFace());
IntCurvesFace_Intersector& Intersector3d = SolidExplorer.Intersector(f);
Intersector3d.Perform(L,-RealLast(),parmin); //-- Avant (14 oct 98 il y avait -RealLast RealLast)
if(Intersector3d.IsDone()) {
if(Intersector3d.NbPnt()) {
if(Intersector3d.WParameter(1) < parmin) {
parmin = Intersector3d.WParameter(1);
if(Intersector3d.State(1)==TopAbs_IN) {
//-- The intersection point between the line and a face F
// -- of the solid is in the face F
if(Intersector3d.Transition(1) == IntCurveSurface_Out) {
//-- The line is going from inside the solid to outside
//-- the solid.
myState = 3; //-- IN --
}
else if(Intersector3d.Transition(1) == IntCurveSurface_In) {
myState = 4; //-- OUT --
}
myFace = f;
}
else if(Intersector3d.State(1)==TopAbs_ON) {
//-- The intersection point between the line and a face F
//-- of the solid is in the face F
if(Intersector3d.Transition(1) == IntCurveSurface_Out) {
//-- The line is going from inside the solid to outside
//-- the solid.
myState = 3; //-- IN --
}
else if(Intersector3d.Transition(1) == IntCurveSurface_In) {
myState = 4; //-- OUT --
}
//-- myState = 2;
myFace = f;
}
}
else {
//-- No point has been found by the Intersector3d.
//-- Or a Point has been found with a greater parameter.
}
}
}
}
} //-- Exploration of the faces
} //-- Shell has not been rejected
else {
myState=1;
}
} //-- Exploration of the shells
cpasbon++;
}
while(cpasbon!=0 && cpasbon<5);
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer,
const gp_Pnt& P,
const Standard_Real Tol)
{
if(SolidExplorer.Reject(P)) {
myState=3; //-- in ds le cas solide sans face
return;
}
myFace.Nullify();
myState = 0;
if(SolidExplorer.Reject(P) == Standard_False) {
gp_Lin L;
Standard_Real Par;
//-- We compute the intersection betwwen the line builded in the Solid Explorer
//-- and the shape.
//-- --------------------------------------------------------------------------------
//-- ON calcule l intersection avec la face la plus proche au sens des boites
//-- englobantes en priorite de facon a avoir un parmin le plus faible possible.
//-- optimisation pour assurer le plus de rejections possibles avec les autres
//-- faces.
//modified by NIZNHY-PKV Thu Nov 14 12:33:53 2002 f
Standard_Integer iFlag;
//
// Modified by skv - Thu Sep 4 11:22:05 2003 OCC578 Begin
// If found line passes through a bound of any face, it means that the line
// is not found properly and it is necessary to repeat whole procedure.
// That's why the main loop while is added.
Standard_Boolean isFaultyLine = Standard_True;
Standard_Integer anIndFace = 0;
Standard_Real parmin;
while (isFaultyLine) {
if (anIndFace == 0) {
iFlag = SolidExplorer.Segment(P,L,Par);
} else {
iFlag = SolidExplorer.OtherSegment(P,L,Par);
}
Standard_Integer aCurInd = SolidExplorer.GetFaceSegmentIndex();
if (aCurInd > anIndFace) {
anIndFace = aCurInd;
} else {
myState = 1;
return;
}
// Modified by skv - Thu Sep 4 11:22:10 2003 OCC578 End
if (iFlag==1) {
// IsOnFace
// iFlag==1 i.e face is Infinite
myState=2;
return;
}
//SolidExplorer.Segment(P,L,Par);
//modified by NIZNHY-PKV Thu Nov 14 12:33:58 2002 t
//
//process results from uncorrected shells
//
//modified by NIZNHY-PKV Thu Nov 14 15:05:43 2002 f
//if(Par > 1.e+100 && L.Direction().IsParallel(gp_Dir(0.,0.,1.),1.e-8)) {
if (iFlag==2) {
//modified by NIZNHY-PKV Thu Nov 14 15:06:16 2002 t
myState = 4;
return;
}
//-- BRepClass3d_Intersector3d Intersector3d;
// Modified by skv - Thu Sep 4 13:48:27 2003 OCC578 Begin
// Check if the point is ON surface but OUT of the face.
// Just skip this face because it is bad for classification.
if (iFlag == 3)
continue;
isFaultyLine = Standard_False;
// Standard_Real parmin = RealLast();
// for(SolidExplorer.InitShell();
// SolidExplorer.MoreShell();
// SolidExplorer.NextShell()) {
parmin = RealLast();
for(SolidExplorer.InitShell();
SolidExplorer.MoreShell() && !isFaultyLine;
SolidExplorer.NextShell()) {
// Modified by skv - Thu Sep 4 13:48:27 2003 OCC578 End
if(SolidExplorer.RejectShell(L) == Standard_False) {
// Modified by skv - Thu Sep 4 13:48:27 2003 OCC578 Begin
// for(SolidExplorer.InitFace();
// SolidExplorer.MoreFace();
// SolidExplorer.NextFace()) {
for(SolidExplorer.InitFace();
SolidExplorer.MoreFace() && !isFaultyLine;
SolidExplorer.NextFace()) {
// Modified by skv - Thu Sep 4 13:48:27 2003 OCC578 End
if(SolidExplorer.RejectFace(L) == Standard_False) {
//-- Intersector3d.Perform(L,Par,Tol,SolidExplorer.CurrentFace());
TopoDS_Shape aLocalShape = SolidExplorer.CurrentFace();
TopoDS_Face f = TopoDS::Face(aLocalShape);
// TopoDS_Face f = TopoDS::Face(SolidExplorer.CurrentFace());
IntCurvesFace_Intersector& Intersector3d = SolidExplorer.Intersector(f);
// MSV Oct 25, 2001: prolong segment, since there are cases when
// the intersector does not find intersection points with the original
// segment due to rough triangulation of a parametrized surface
Standard_Real addW = Max(10*Tol, 0.01*Par);
Standard_Real AddW = addW;
Bnd_Box aBoxF = Intersector3d.Bounding();
// MSV 23.09.2004: the box must be finite in order to
// correctly prolong the segment to its bounds
if (!aBoxF.IsVoid() && !aBoxF.IsWhole()) {
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
aBoxF.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
Standard_Real boxaddW = GetAddToParam(L,Par,aBoxF);
addW = Max(addW,boxaddW);
}
Standard_Real minW = -AddW;//-addW;
Standard_Real maxW = Min(Par*10,Par+addW);//Par+addW;
//cout << "range [" << minW << "," << maxW << "]" << endl << endl;
Intersector3d.Perform(L,minW,maxW);
//Intersector3d.Perform(L,-Tol,Par+10.0*Tol);
if(Intersector3d.IsDone()) {
Standard_Integer i;
for (i=1; i <= Intersector3d.NbPnt(); i++) {
if(Abs(Intersector3d.WParameter(i)) < Abs(parmin)) {
parmin = Intersector3d.WParameter(i);
// Modified by skv - Thu Sep 4 12:46:32 2003 OCC578 Begin
TopAbs_State aState = Intersector3d.State(i);
// Modified by skv - Thu Sep 4 12:46:33 2003 OCC578 End
if(Abs(parmin)<=Tol) {
myState = 2;
myFace = f;
}
// Modified by skv - Thu Sep 4 12:46:32 2003 OCC578 Begin
// Treatment of case TopAbs_ON separately.
else if(aState==TopAbs_IN) {
// Modified by skv - Thu Sep 4 12:46:32 2003 OCC578 End
//-- The intersection point between the line and a face F
// -- of the solid is in the face F
IntCurveSurface_TransitionOnCurve tran = Intersector3d.Transition(i);
if (tran == IntCurveSurface_Tangent) {
#ifdef DEB
cout<<"*Probleme ds BRepClass3d_SClassifier.cxx"<<endl;
#endif
continue; // ignore this point
}
// if parmin is negative we should reverse transition
if (parmin < 0)
tran = (tran == IntCurveSurface_Out
? IntCurveSurface_In : IntCurveSurface_Out);
if(tran == IntCurveSurface_Out) {
//-- The line is going from inside the solid to outside
//-- the solid.
myState = 3; //-- IN --
}
else /* if(tran == IntCurveSurface_In) */ {
myState = 4; //-- OUT --
}
myFace = f;
}
// Modified by skv - Thu Sep 4 12:48:50 2003 OCC578 Begin
// If the state is TopAbs_ON, it is necessary to chose
// another line and to repeat the whole procedure.
else if(aState==TopAbs_ON) {
isFaultyLine = Standard_True;
break;
}
// Modified by skv - Thu Sep 4 12:48:50 2003 OCC578 End
}
else {
//-- No point has been found by the Intersector3d.
//-- Or a Point has been found with a greater parameter.
}
} //-- loop by intersection points
} //-- Face has not been rejected
else {
myState = 1;
}
}
} //-- Exploration of the faces
} //-- Shell has not been rejected
else {
myState=1;
}
} //-- Exploration of the shells
// Modified by skv - Thu Sep 4 11:42:03 2003 OCC578 Begin
// The end of main loop.
}
// Modified by skv - Thu Sep 4 11:42:03 2003 OCC578 End
#ifdef DEB
//#################################################
SolidExplorer.DumpSegment(P,L,parmin,State());
//#################################################
#endif
} //-- Solid has not been rejected
else {
myState = 1;
}
}
TopAbs_State BRepClass3d_SClassifier::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 BRepClass3d_SClassifier::Face() const {
return(myFace);
}
Standard_Boolean BRepClass3d_SClassifier::Rejected() const {
return(myState==1);
}
Standard_Boolean BRepClass3d_SClassifier::IsOnAFace() const {
return(myState==2);
}
void BRepClass3d_SClassifier::ForceIn() {
myState=3;
}
void BRepClass3d_SClassifier::ForceOut() {
myState=4;
}
Standard_Real GetAddToParam(const gp_Lin& L,
const Standard_Real P,
const Bnd_Box& B)
{
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
Standard_Real x[2] = {aXmin,aXmax}, y[2] = {aYmin,aYmax}, z[2] = {aZmin,aZmax};
Standard_Integer i = 0, j = 0, k = 0;
Standard_Real Par = P;
for(i = 0 ; i < 2; i++) {
for(j = 0; j < 2; j++) {
for(k = 0; k < 2; k++) {
Standard_Real X = fabs(x[i]-L.Location().X());
Standard_Real Y = fabs(y[j]-L.Location().Y());
Standard_Real Z = fabs(z[k]-L.Location().Z());
if(X < 1.e+20 && Y < 1.e+20 && Z < 1.e+20) {
gp_Pnt aP(x[i],y[j],z[k]);
Standard_Real par = ElCLib::Parameter(L,aP);
if(par > Par)
Par = par;
}
else
return 1.e+20;
}
}
}
return Par - P;
}

View File

@@ -0,0 +1,73 @@
-- File: BRepClass3d_SolidClassifier.cdl
-- Created: Wed Mar 30 18:28:29 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
class SolidClassifier from BRepClass3d inherits SClassifier from BRepClass3d
---Purpose: Provides an algorithm to classify a point in a solid.
uses
Pnt from gp,
Face from TopoDS,
Shape from TopoDS,
SolidExplorer from BRepClass3d
raises
DomainError from Standard
is
Create
---Purpose : empty constructor
returns SolidClassifier from BRepClass3d;
Load(me:in out; S : Shape from TopoDS)
is static;
Create(S : Shape from TopoDS)
---Purpose: Constructor from a Shape.
returns SolidClassifier from BRepClass3d;
Create(S : Shape from TopoDS;
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 BRepClass3d;
Perform(me: in out;
P : Pnt from gp;
Tol : Real from Standard)
---Purpose: Classify the point P with the
-- tolerance Tol on the solid S.
is static;
PerformInfinitePoint(me: in out;
Tol : Real from Standard)
---Purpose: Classify an infinite point with the
-- tolerance Tol on the solid S.
-- Useful for compute the orientation of a solid.
is static;
Destroy(me:in out)
---C++: alias ~
is static;
fields
aSolidLoaded : Boolean from Standard;
explorer : SolidExplorer from BRepClass3d;
isaholeinspace : Boolean from Standard;
end SolidClassifier;

View File

@@ -0,0 +1,210 @@
// File: BRepClass3d_SolidClassifier.cxx
// Created: Wed Mar 30 18:28:29 1994
// Author: Laurent BUCHARD
// <lbr@fuegox>
//-Copyright: Matra Datavision 1994
#define MARCHEPASSIUNESEULEFACE 0
#ifdef DEB
#define LBRCOMPT 0
#else
#define LBRCOMPT 0
#endif
#if LBRCOMPT
#include <stdio.h>
class StatistiquesBRepClass3d {
public:
long unsigned NbConstrVide;
long unsigned NbLoad;
long unsigned NbConstrShape;
long unsigned NbConstrShapePnt;
long unsigned NbPerform;
long unsigned NbPerformRejection;
long unsigned NbPerformInfinitePoint;
long unsigned NbDestroy;
public:
StatistiquesBRepClass3d() {
NbConstrVide=NbLoad=NbConstrShape=NbConstrShapePnt=NbPerform=NbPerformInfinitePoint=NbDestroy=0;
}
~StatistiquesBRepClass3d() {
printf("\n--- Statistiques BRepClass3d:\n");
printf("\nConstructeurVide : %10lu",NbConstrVide);
printf("\nConstructeur(Shape) : %10lu",NbConstrShape);
printf("\nLoad(Shape) : %10lu",NbLoad);
printf("\nPerform(pnt3d) : %10lu",NbPerform);
printf("\nPerform(pnt3d) REJ : %10lu",NbPerformRejection);
printf("\nPerformInfinitePoint: %10lu",NbPerformInfinitePoint);
printf("\nDestroy : %10lu",NbDestroy );
}
};
static StatistiquesBRepClass3d STAT;
#endif
#include <BRepClass3d_SolidClassifier.ixx>
#include <TopoDS_Shape.hxx>
BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier()
{
aSolidLoaded=isaholeinspace=Standard_False;
#if LBRCOMPT
STAT.NbConstrVide++;
#endif
}
void BRepClass3d_SolidClassifier::Load(const TopoDS_Shape& S) {
#if LBRCOMPT
STAT.NbLoad++;
#endif
if(aSolidLoaded) {
explorer.Destroy();
}
explorer.InitShape(S);
aSolidLoaded = Standard_True;
#if MARCHEPASSIUNESEULEFACE
PerformInfinitePoint(1e-7);
if(State()==TopAbs_OUT) {
isaholeinspace=Standard_False;
}
else {
isaholeinspace=Standard_True;
}
#endif
}
BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S)
: aSolidLoaded(Standard_True),explorer(S)
{
#if LBRCOMPT
STAT.NbConstrShape++;
#endif
#if MARCHEPASSIUNESEULEFACE
PerformInfinitePoint(1e-7);
if(State()==TopAbs_OUT) {
isaholeinspace=Standard_False;
}
else {
isaholeinspace=Standard_True;
}
#endif
}
BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S,
const gp_Pnt& P,
const Standard_Real Tol)
: explorer(S) {
#if LBRCOMPT
STAT.NbConstrShapePnt++;
#endif
aSolidLoaded = Standard_True;
#if MARCHEPASSIUNESEULEFACE
PerformInfinitePoint(1e-7);
if(State()==TopAbs_OUT) {
isaholeinspace=Standard_False;
}
else {
isaholeinspace=Standard_True;
}
if(isaholeinspace==Standard_False) {
if(explorer.Box().IsOut(P)) {
ForceOut();
}
else {
Perform(P,Tol);
}
}
else {
if(explorer.Box().IsOut(P)) {
ForceIn();
}
else {
Perform(P,Tol);
}
}
#else
Perform(P,Tol);
#endif
}
void BRepClass3d_SolidClassifier::Perform(const gp_Pnt& P,const Standard_Real Tol) {
#if LBRCOMPT
STAT.NbPerform++;
#endif
#if MARCHEPASSIUNESEULEFACE
if(aSolidLoaded) {
if(isaholeinspace==Standard_False) {
if(explorer.Box().IsOut(P)) {
ForceOut();
#if LBRCOMPT
STAT.NbPerformRejection++;
#endif
}
else {
BRepClass3d_SClassifier::Perform(explorer,P,Tol);
}
}
else {
if(explorer.Box().IsOut(P)) {
ForceIn();
#if LBRCOMPT
STAT.NbPerformRejection++;
#endif
}
else {
BRepClass3d_SClassifier::Perform(explorer,P,Tol);
}
}
}
#else
BRepClass3d_SClassifier::Perform(explorer,P,Tol);
#endif
}
void BRepClass3d_SolidClassifier::PerformInfinitePoint(const Standard_Real Tol) {
#if LBRCOMPT
STAT.NbPerformInfinitePoint++;
#endif
if(aSolidLoaded) {
BRepClass3d_SClassifier::PerformInfinitePoint(explorer,Tol);
if(State()==TopAbs_OUT)
isaholeinspace=Standard_False;
else
isaholeinspace=Standard_True;
}
}
void BRepClass3d_SolidClassifier::Destroy() {
#if LBRCOMPT
STAT.NbDestroy++;
#endif
if(aSolidLoaded) {
explorer.Destroy();
aSolidLoaded = Standard_False;
}
}

View File

@@ -0,0 +1,192 @@
-- File: SolidExplorer.cdl
-- Created: Thu Mar 10 14:02:10 1994
-- Author: Laurent BUCHARD
-- <lbr@fuegox>
---Copyright: Matra Datavision 1994
-- Modified by skv - Thu Sep 4 12:19:22 2003 OCC578
-- Add the method GetFaceSegmentIndex() which is used to obtain the index of
-- the face for which last segment is calculated.
class SolidExplorer from BRepClass3d
---Purpose: Provide an exploration of a BRep Shape for the
-- classification.
uses
Orientation from TopAbs,
Pnt from gp,
Pnt2d from gp,
Lin from gp,
Face from TopoDS,
Shell from TopoDS,
Shape from TopoDS,
Explorer from TopExp,
Edge from BRepClass,
Box from Bnd,
State from TopAbs,
Intersector from IntCurvesFace,
MapOfInter from BRepClass3d,
HSurface from BRepAdaptor
is
Create returns SolidExplorer from BRepClass3d;
Create (Oth: SolidExplorer from BRepClass3d)
---Purpose: Raise if called.
returns SolidExplorer from BRepClass3d;
Create (S : Shape from TopoDS) returns SolidExplorer from BRepClass3d;
Delete(me:out) is virtual;
---C++: alias "Standard_EXPORT virtual ~BRepClass3d_SolidExplorer(){Destroy() ; }"
InitShape(me : in out; S : Shape from TopoDS) is static ;
Reject(me; P : Pnt from gp) returns Boolean is virtual ;
---Purpose: Should return True if P outside of bounding vol. of the shape
FindAPointInTheFace(myclass; F: Face from TopoDS;
P: out Pnt from gp;
Param: out Real from Standard)
---Purpose : compute a point P in the face F. Param is a Real in
-- ]0,1[ and is used to initialise the algorithm. For
-- different values , different points are returned.
returns Boolean from Standard;
FindAPointInTheFace(myclass; F: Face from TopoDS;
P: out Pnt from gp;
u,v: out Real from Standard;
Param: out Real from Standard)
returns Boolean from Standard;
FindAPointInTheFace(myclass; F: Face from TopoDS;
P: out Pnt from gp;
u,v: out Real from Standard)
returns Boolean from Standard;
FindAPointInTheFace(myclass; F: Face from TopoDS;
P: out Pnt from gp)
returns Boolean from Standard;
FindAPointInTheFace(myclass; F: Face from TopoDS;
u,v: out Real from Standard)
returns Boolean from Standard;
-----------------------------------------------------------------------
PointInTheFace(me; F: Face from TopoDS;
P: out Pnt from gp;
u,v: out Real from Standard;
Param: out Real from Standard;
Index: out Integer from Standard)
returns Boolean from Standard is static ;
PointInTheFace(me; F: Face from TopoDS;
P: out Pnt from gp;
u,v: out Real from Standard;
Param: out Real from Standard;
Index: out Integer from Standard;
surf: HSurface from BRepAdaptor;
u1,v1,u2,v2: Real from Standard)
returns Boolean from Standard is static ;
---Purpose: <Index> gives point index to search from and returns
-- point index of succeseful search
InitShell(me: in out) is static ;
---Purpose: Starts an exploration of the shells.
MoreShell(me) returns Boolean from Standard is static ;
---Purpose: Returns True if there is a current shell.
NextShell(me: in out) is static ;
---Purpose: Sets the explorer to the next shell.
CurrentShell(me) returns Shell from TopoDS is static ;
---Purpose: Returns the current shell.
RejectShell(me; L: Lin from gp) returns Boolean from Standard is virtual;
---Purpose: Returns True if the Shell is rejected.
InitFace(me: in out) is static ;
---Purpose: Starts an exploration of the faces of the current shell.
MoreFace(me) returns Boolean from Standard is static ;
---Purpose: Returns True if current face in current shell.
NextFace(me: in out) is static ;
---Purpose: Sets the explorer to the next Face of the current shell.
CurrentFace(me) returns Face from TopoDS is static ;
---Purpose: Returns the current face.
RejectFace(me; L: Lin from gp) returns Boolean from Standard is virtual;
---Purpose: returns True if the face is rejected.
----------------------------------------------------------------------
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.
--
--modified by NIZNHY-PKV Thu Nov 14 12:20:17 2002 f
returns Integer from Standard
--modified by NIZNHY-PKV Thu Nov 14 12:20:21 2002 t
is static;
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.
--
--modified by NIZNHY-PKV Thu Nov 14 12:20:17 2002 f
returns Integer from Standard
--modified by NIZNHY-PKV Thu Nov 14 12:20:21 2002 t
is static;
-- Modified by skv - Thu Sep 4 12:19:22 2003 OCC578 Begin
GetFaceSegmentIndex(me)
---Purpose: Returns the index of face for which
-- last segment is calculated.
returns Integer from Standard
is static;
-- Modified by skv - Thu Sep 4 12:19:23 2003 OCC578 End
--------------------------------------------------------------------
--- Dump method
DumpSegment(me; P : Pnt from gp; L : Lin from gp;
Par : Real from Standard; S : State from TopAbs) is virtual;
Box(me)
---C++: return const &
returns Box from Bnd
is static;
Intersector(me; F : Face from TopoDS)
---C++: return &
returns Intersector from IntCurvesFace is static;
Destroy(me: in out)
--C++: alias ~
is static;
fields
myBox : Box from Bnd;
myShape : Shape from TopoDS;
myReject : Boolean from Standard;
myFirstFace : Integer from Standard;
myParamOnEdge : Real from Standard;
myShellExplorer : Explorer from TopExp;
myFaceExplorer : Explorer from TopExp;
myMapOfInter : MapOfInter from BRepClass3d;
end SolidExplorer;

View File

@@ -0,0 +1,924 @@
// File: BRepClass3d_SolidExplorer.cxx
// Created: Thu Mar 10 14:52:22 1994
// Author: Laurent BUCHARD
// <lbr@fuegox>
// Modifed: Portage NT 7-5-97 DPF (stdio.h)
// Apr 16 2002 eap, classification against infinite solid (occ299)
// Modified by skv - Thu Sep 4 12:29:30 2003 OCC578
//-- Traiter le cas d un trou !!
#define REJECTION 1
//-- Pour printf sur NT
#include <stdio.h>
#include <BRepClass3d_SolidExplorer.ixx>
#include <gp.hxx>
#include <TopoDS.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <BRepTools.hxx>
#include <Geom2d_Curve.hxx>
#include <gp_Vec2d.hxx>
#include <GeomAbs_Shape.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepClass_FacePassiveClassifier.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepClass_Edge.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <ElCLib.hxx>
#include <BRepClass3d_DataMapIteratorOfMapOfInter.hxx>
#include <Precision.hxx>
//OCC454(apo)->
#include <Extrema_ExtPS.hxx>
#include <BRep_Tool.hxx>
#include <BRepClass_FaceClassifier.hxx>
//<-OCC454(apo)
static Standard_Integer numedg=0;
static gp_Vec staticd1u_gp_vec;
static gp_Vec staticd1v_gp_vec;
//=======================================================================
//function : FindAPointInTheFace
//purpose : compute a point P in the face F. Param is a Real in
// ]0,1[ and is used to initialise the algorithm. For
// different values , different points are returned.
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
(const TopoDS_Face& _face,
gp_Pnt& APoint_,
Standard_Real& param_)
{
Standard_Real u,v;
Standard_Boolean r = FindAPointInTheFace(_face,APoint_,u,v,param_);
return r;
}
//=======================================================================
//function : FindAPointInTheFace
//purpose :
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
(const TopoDS_Face& _face,
gp_Pnt& APoint_,
Standard_Real& u_, Standard_Real& v_,
Standard_Real& param_)
{
TopoDS_Face face=_face;
face.Orientation(TopAbs_FORWARD);
TopExp_Explorer faceexplorer;
BRepAdaptor_Curve2d c;
gp_Vec2d T;
gp_Pnt2d P;
//Standard_Boolean Ok = Standard_False;
Standard_Integer nedg=1;
for (faceexplorer.Init(face,TopAbs_EDGE);
faceexplorer.More();
faceexplorer.Next()) {
if(numedg==0 || nedg++==numedg) {
TopoDS_Edge Edge = TopoDS::Edge(faceexplorer.Current());
c.Initialize(Edge,face);
#ifdef DEB
Standard_Integer nbinterval =
#endif
c.NbIntervals(GeomAbs_C1);
c.D1((c.LastParameter() - c.FirstParameter()) * param_ + c.FirstParameter(),P,T);
Standard_Real x=T.X();
Standard_Real y=T.Y();
if(Edge.Orientation() == TopAbs_FORWARD) {
T.SetCoord(-y,x);
}
else {
T.SetCoord(y,-x);
}
Standard_Real ParamInit = RealLast();
Standard_Real TolInit = 0.00001;
Standard_Boolean APointExist = Standard_False;
BRepClass_FacePassiveClassifier FClassifier;
T.Normalize();
P.SetCoord(P.X()+TolInit*T.X(),P.Y()+TolInit*T.Y());
FClassifier.Reset(gp_Lin2d(P,T),ParamInit,RealEpsilon()); //-- Longueur et Tolerance #######
TopExp_Explorer otherfaceexplorer;
// Modified by Sergey KHROMOV - Tue Apr 1 11:32:51 2003 Begin
Standard_Integer aNbEdges = 0;
for (otherfaceexplorer.Init(face,TopAbs_EDGE);
otherfaceexplorer.More();
otherfaceexplorer.Next(), aNbEdges++) {
// for (otherfaceexplorer.Init(face,TopAbs_EDGE);
// otherfaceexplorer.More();
// otherfaceexplorer.Next()) {
// Modified by Sergey KHROMOV - Tue Apr 1 11:32:52 2003 End
TopoDS_Edge OtherEdge = TopoDS::Edge(otherfaceexplorer.Current());
if((OtherEdge.Orientation() == TopAbs_EXTERNAL ||
OtherEdge == Edge)) {
}
else {
BRepClass_Edge AEdge(OtherEdge,face);
FClassifier.Compare(AEdge,OtherEdge.Orientation());
if(FClassifier.ClosestIntersection()) {
//-- cout<<" ---> Edge : "<<FClassifier.Parameter()<<endl;
if(ParamInit > FClassifier.Parameter()) {
ParamInit = FClassifier.Parameter();
APointExist = Standard_True;
}
}
}
}
// Modified by Sergey KHROMOV - Tue Apr 1 11:34:36 2003 Begin
if (aNbEdges == 1) {
BRepClass_Edge AEdge(Edge,face);
FClassifier.Compare(AEdge,Edge.Orientation());
if(FClassifier.ClosestIntersection()) {
if(ParamInit > FClassifier.Parameter()) {
ParamInit = FClassifier.Parameter();
APointExist = Standard_True;
}
}
}
// Modified by Sergey KHROMOV - Tue Apr 1 11:34:36 2003 End
if(APointExist) {
ParamInit*=0.41234;
u_ = P.X() + ParamInit* T.X();
v_ = P.Y() + ParamInit* T.Y();
BRepAdaptor_Surface s;
s.Initialize(face,Standard_False);
s.D1(u_,v_,APoint_,staticd1u_gp_vec,staticd1v_gp_vec);
return(Standard_True);
}
}
}
return(Standard_False);
}
//=======================================================================
//function : PointInTheFace
//purpose :
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
(const TopoDS_Face& Face,
gp_Pnt& APoint_,
Standard_Real& u_, Standard_Real& v_,
Standard_Real& param_,
Standard_Integer& IndexPoint,
const Handle(BRepAdaptor_HSurface)& surf,
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
const Standard_Real V2 ) const
{
Standard_Real u,du = (U2-U1)/6.0;
Standard_Real v,dv = (V2-V1)/6.0;
if(du<1e-12) du=1e-12;
if(dv<1e-12) dv=1e-12;
Standard_Integer NbPntCalc=0;
if(myMapOfInter.IsBound(Face)) {
void *ptr = (void*)(myMapOfInter.Find(Face));
if(ptr) {
const IntCurvesFace_Intersector& TheIntersector = (*((IntCurvesFace_Intersector *)ptr));
//-- On prend les 4 points dans chaque Quart de surface
//-- -> Index : 1 -> 16
//--
//--
//-- Puis on prend une matrice de points sur une grille serree
//--
for(u=du+(U1+U2)*0.5; u<U2; u+=du) { //-- 0 X u croit
for(v=dv+(V1+V2)*0.5; v<V2; v+=dv) { //-- 0 0 v croit
if(++NbPntCalc>=IndexPoint) {
if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
u_=u; v_=v;
surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec);
IndexPoint = NbPntCalc;
return(Standard_True);
}
}
}
}
for(u=-du+(U1+U2)*0.5; u>U1; u-=du) { //-- 0 0 u decroit
for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) { //-- X 0 v decroit
if(++NbPntCalc>=IndexPoint) {
if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
u_=u; v_=v;
surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec);
IndexPoint = NbPntCalc;
return(Standard_True);
}
}
}
}
for(u=-du+(U1+U2)*0.5; u>U1; u-=du) { //-- X 0 u decroit
for(v=dv+(V1+V2)*0.5; v<V2; v+=dv) { //-- 0 0 v croit
if(++NbPntCalc>=IndexPoint) {
if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
u_=u; v_=v;
surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec);
IndexPoint = NbPntCalc;
return(Standard_True);
}
}
}
}
for(u=du+(U1+U2)*0.5; u<U2; u+=du) { //-- 0 0 u croit
for(v=-dv+(V1+V2)*0.5; v>V1; v-=dv) { //-- 0 X v decroit
if(++NbPntCalc>=IndexPoint) {
if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
u_=u; v_=v;
surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec);
IndexPoint = NbPntCalc;
return(Standard_True);
}
}
}
}
//-- le reste
du = (U2-U1)/37.0;
dv = (V2-V1)/37.0;
if(du<1e-12) du=1e-12;
if(dv<1e-12) dv=1e-12;
for(u=du+U1; u<U2; u+=du) {
for(v=dv+V1; v<V2; v+=dv) {
if(++NbPntCalc>=IndexPoint) {
if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
u_=u; v_=v;
surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec);
IndexPoint = NbPntCalc;
return(Standard_True);
}
}
}
}
u=(U1+U2)*0.5;
v=(V1+V2)*0.5;
if(++NbPntCalc>=IndexPoint) {
if(TheIntersector.ClassifyUVPoint(gp_Pnt2d(u,v))==TopAbs_IN) {
u_=u; v_=v;
surf->D1(u,v,APoint_,staticd1u_gp_vec,staticd1v_gp_vec);
IndexPoint = NbPntCalc;
return(Standard_True);
}
}
}
IndexPoint = NbPntCalc;
}
else {
//printf("BRepClass3d_SolidExplorer Face non trouvee ds la map \n");
}
return(BRepClass3d_SolidExplorer::FindAPointInTheFace(Face,APoint_,u_,v_,param_));
}
//=======================================================================
//function : LimitInfiniteUV
//purpose : Limit infinite parameters
//=======================================================================
static void LimitInfiniteUV (Standard_Real& U1,
Standard_Real& V1,
Standard_Real& U2,
Standard_Real& V2)
{
Standard_Boolean
infU1 = Precision::IsNegativeInfinite(U1),
infV1 = Precision::IsNegativeInfinite(V1),
infU2 = Precision::IsPositiveInfinite(U2),
infV2 = Precision::IsPositiveInfinite(V2);
if (infU1) U1 = -1e10;
if (infV1) V1 = -1e10;
if (infU2) U2 = 1e10;
if (infV2) V2 = 1e10;
}
// Modified by skv - Tue Sep 16 13:50:38 2003 OCC578 Begin
//OCC454(apo)->
// static Standard_Boolean IsInfiniteUV (Standard_Real& U1, Standard_Real& V1, Standard_Real& U2, Standard_Real& V2) {
// return (Precision::IsNegativeInfinite(U1) || Precision::IsNegativeInfinite(V1) ||
// Precision::IsNegativeInfinite(U2) || Precision::IsNegativeInfinite(V2));
// }
static Standard_Integer IsInfiniteUV (Standard_Real& U1, Standard_Real& V1,
Standard_Real& U2, Standard_Real& V2) {
Standard_Integer aVal = 0;
if (Precision::IsInfinite(U1))
aVal |= 1;
if (Precision::IsInfinite(V1))
aVal |= 2;
if (Precision::IsInfinite(U2))
aVal |= 4;
if (Precision::IsInfinite(V2))
aVal |= 8;
return aVal;
}
//<-OCC454
// Modified by skv - Tue Sep 16 13:50:39 2003 OCC578 End
//=======================================================================
//function : OtherSegment
//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.
//=======================================================================
//modified by NIZNHY-PKV Thu Nov 14 14:34:05 2002 f
//void BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
// gp_Lin& L,
// Standard_Real& _Par)
Standard_Integer BRepClass3d_SolidExplorer::OtherSegment(const gp_Pnt& P,
gp_Lin& L,
Standard_Real& _Par)
//modified by NIZNHY-PKV Thu Nov 14 14:34:10 2002 t
{
TopoDS_Face face;
TopExp_Explorer faceexplorer;
//TopExp_Explorer edgeexplorer;
gp_Pnt APoint;
Standard_Real maxscal=0;
Standard_Boolean ptfound=Standard_False;
Standard_Real Par;
//Standard_Integer i=1;
Standard_Real _u,_v;
Standard_Integer IndexPoint=0;
Standard_Integer NbPointsOK=0;
Standard_Integer NbFacesInSolid=0;
do {
myFirstFace++;
faceexplorer.Init(myShape,TopAbs_FACE);
// look for point on face starting from myFirstFace
// Modified by skv - Thu Sep 4 14:31:12 2003 OCC578 Begin
// while (faceexplorer.More()) {
for (; faceexplorer.More(); faceexplorer.Next()) {
// Modified by skv - Thu Sep 4 14:31:12 2003 OCC578 End
NbFacesInSolid++;
if (myFirstFace > NbFacesInSolid) continue;
face = TopoDS::Face(faceexplorer.Current());
Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
surf->ChangeSurface().Initialize(face);
Standard_Real U1,V1,U2,V2;
U1 = surf->FirstUParameter();
V1 = surf->FirstVParameter();
U2 = surf->LastUParameter();
V2 = surf->LastVParameter();
face.Orientation(TopAbs_FORWARD);
//
//avoid process faces from uncorrected shells
if( Abs (U2 - U1) < 1.e-12 || Abs(V2 - V1) < 1.e-12) {
//modified by NIZNHY-PKV Thu Nov 14 15:03:18 2002 f
//gp_Vec avoidV(gp_Pnt(0.,0.,0.),gp_Pnt(0.,0.,1.));
//gp_Lin avoidL(gp_Pnt(0.,0.,0.),avoidV);
//_Par = RealLast();
//L = avoidL;
return 2;
//return ;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
}
//
Standard_Real svmyparam=myParamOnEdge;
//
// Modified by skv - Tue Sep 16 13:55:27 2003 OCC578 Begin
// Check if the point is on the face or the face is infinite.
Standard_Integer anInfFlag = IsInfiniteUV(U1,V1,U2,V2);
// if(IsInfiniteUV(U1,V1,U2,V2)){//OCC454(apo)->
GeomAdaptor_Surface GA(BRep_Tool::Surface(face));
static Standard_Real TolU = Precision::PConfusion(), TolV = TolU;
Extrema_ExtPS Ext(P,GA,TolU,TolV);
if (Ext.IsDone() && Ext.NbExt() > 0) {
// evaluate the lower distance and its index;
Standard_Real Dist2, Dist2Min = Ext.SquareDistance(1);
Standard_Integer iNear = 1, i = 2, iEnd = Ext.NbExt();
for (i = 2; i <= iEnd; i++) {
Dist2 = Ext.SquareDistance(i);
if (Dist2 < Dist2Min) {
Dist2Min = Dist2; iNear = i;
}
}
//modified by NIZNHY-PKV Thu Nov 14 12:31:01 2002 f
Standard_Real aDist2Tresh=1.e-24;
if (Dist2Min<aDist2Tresh) {
if (anInfFlag) {
return 1;
} else {
BRepClass_FaceClassifier classifier2d;
Standard_Real aU;
Standard_Real aV;
(Ext.Point(iNear)).Parameter(aU, aV);
gp_Pnt2d aPuv(aU, aV);
classifier2d.Perform(face,aPuv,Precision::PConfusion());
TopAbs_State aState = classifier2d.State();
if (aState == TopAbs_IN || aState == TopAbs_ON)
return 1;
else
return 3; // skv - the point is on surface but outside face.
}
}
//modified by NIZNHY-PKV Thu Nov 14 12:31:03 2002 t
if (anInfFlag) {
APoint = (Ext.Point(iNear)).Value();
gp_Vec V(P,APoint);
_Par = V.Magnitude();
L = gp_Lin(P,V);
ptfound=Standard_True;
numedg=0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
//return ;
return 0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
}
//<-OCC454(apo)
// }else{
}
//The point is not ON the face or surface. The face is restricted.
// find point in a face not too far from a projection of P on face
// Modified by skv - Tue Sep 16 15:25:00 2003 OCC578 End
do {
if(PointInTheFace(face,APoint,_u,_v,myParamOnEdge,++IndexPoint,surf,U1,V1,U2,V2)) {
NbPointsOK++;
gp_Vec V(P,APoint);
Par = V.Magnitude();
if(Par > gp::Resolution()) {
gp_Vec Norm=staticd1u_gp_vec.Crossed(staticd1v_gp_vec);
Standard_Real tt = Norm.Magnitude();
tt=Abs(Norm.Dot(V))/(tt*Par);
if(tt>maxscal) {
maxscal=tt;
L = gp_Lin(P,V);
_Par=Par;
ptfound=Standard_True;
if(maxscal>0.2) {
myParamOnEdge=svmyparam;
numedg=0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
//return ;
return 0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
}
}
}
}
}
while(IndexPoint<200 && NbPointsOK<16);
myParamOnEdge=svmyparam;
numedg=0;
if(maxscal>0.2) {
//modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
//return ;
return 0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
}
// Modified by skv - Thu Sep 4 14:32:14 2003 OCC578 Begin
// Next is done in the main for(..) loop.
// faceexplorer.Next();
// Modified by skv - Thu Sep 4 14:32:14 2003 OCC578 End
IndexPoint = 0;
Standard_Boolean encoreuneface = faceexplorer.More();
if(ptfound==Standard_False && encoreuneface==Standard_False) {
if(myParamOnEdge < 0.0001) {
//-- Ce cas se produit lorsque le point est sur le solide
//-- et ce solide est reduit a une face
gp_Pnt PBidon(P.X()+1.0,P.Y(),P.Z());
gp_Vec V(P,PBidon);
Par= 1.0;
_Par=Par;
L = gp_Lin(P,V);
//modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
//return ;
return 0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
//-- cout<<" FindAPoint **** Pas OK "<<endl;
}
}
} //-- Exploration of the faces
if(NbFacesInSolid==0) {
_Par=0.0;
myReject=Standard_True;
#if DEB
cout<<"\nWARNING : BRepClass3d_SolidExplorer.cxx (Solid sans face)"<<endl;
#endif
//modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
//return ;
return 0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
}
if(ptfound) {
//modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
//return ;
return 0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
}
myFirstFace = 0;
if(myParamOnEdge==0.512345) myParamOnEdge = 0.4;
else if(myParamOnEdge==0.4) myParamOnEdge = 0.6;
else if(myParamOnEdge==0.6) myParamOnEdge = 0.3;
else if(myParamOnEdge==0.3) myParamOnEdge = 0.7;
else if(myParamOnEdge==0.7) myParamOnEdge = 0.2;
else if(myParamOnEdge==0.2) myParamOnEdge = 0.8;
else if(myParamOnEdge==0.8) myParamOnEdge = 0.1;
else if(myParamOnEdge==0.1) myParamOnEdge = 0.9;
else { myParamOnEdge*=0.5; }
} //-- do { ... }
while(1);
//modified by NIZNHY-PKV Thu Nov 14 12:25:28 2002 f
//return ;
return 0;
//modified by NIZNHY-PKV Thu Nov 14 12:25:33 2002 t
}
// Modified by skv - Thu Sep 4 12:30:14 2003 OCC578 Begin
//=======================================================================
//function : GetFaceSegmentIndex
//purpose : Returns the index of face for which last segment is calculated.
//=======================================================================
Standard_Integer BRepClass3d_SolidExplorer::GetFaceSegmentIndex() const
{
return myFirstFace;
}
// Modified by skv - Thu Sep 4 12:30:14 2003 OCC578 End
//=======================================================================
//function : PointInTheFace
//purpose :
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::PointInTheFace
(const TopoDS_Face& _face,
gp_Pnt& APoint_,
Standard_Real& u_, Standard_Real& v_,
Standard_Real& param_,
Standard_Integer& IndexPoint) const
{
TopoDS_Face Face = _face;
Face.Orientation(TopAbs_FORWARD);
Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
surf->ChangeSurface().Initialize(Face);
Standard_Real U1,V1,U2,V2;//,u,v;
U1 = surf->FirstUParameter();
V1 = surf->FirstVParameter();
U2 = surf->LastUParameter();
V2 = surf->LastVParameter();
LimitInfiniteUV (U1,V1,U2,V2);
return(PointInTheFace(Face,APoint_,u_,v_,param_,IndexPoint,surf,U1,V1,U2,V2));
}
//=======================================================================
//function : FindAPointInTheFace
//purpose :
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
(const TopoDS_Face& _face,
gp_Pnt& APoint_,
Standard_Real& u_,Standard_Real& v_)
{
Standard_Real param = 0.1;
Standard_Boolean r = FindAPointInTheFace(_face,APoint_,u_,v_,param);
return r;
}
//=======================================================================
//function : FindAPointInTheFace
//purpose :
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
(const TopoDS_Face& _face,
gp_Pnt& APoint_)
{ Standard_Real u,v;
Standard_Boolean r = FindAPointInTheFace(_face,APoint_,u,v);
return r;
}
//=======================================================================
//function : FindAPointInTheFace
//purpose :
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::FindAPointInTheFace
(const TopoDS_Face& _face,
Standard_Real& u_,Standard_Real& v_)
{ gp_Pnt APoint;
Standard_Boolean r = FindAPointInTheFace(_face,APoint,u_,v_);
return r;
}
//=======================================================================
//function : BRepClass3d_SolidExplorer
//purpose :
//=======================================================================
BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer()
{
}
#include <Standard_ConstructionError.hxx>
//=======================================================================
//function : BRepClass3d_SolidExplorer
//purpose : Raise if called.
//=======================================================================
//BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& Oth)
BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer(const BRepClass3d_SolidExplorer& )
{
Standard_ConstructionError::Raise("Magic constructor not allowed");
}
//=======================================================================
//function : BRepClass3d_SolidExplorer
//purpose :
//=======================================================================
BRepClass3d_SolidExplorer::BRepClass3d_SolidExplorer(const TopoDS_Shape& S)
{
InitShape(S);
}
//=======================================================================
//function : Delete
//purpose :
//=======================================================================
void BRepClass3d_SolidExplorer::Delete()
{
Destroy() ;
}
//=======================================================================
//function : Destroy
//purpose : C++: alias ~
//=======================================================================
void BRepClass3d_SolidExplorer::Destroy() {
BRepClass3d_DataMapIteratorOfMapOfInter iter(myMapOfInter);
for(;iter.More();iter.Next()) {
void *ptr=iter.Value();
if(ptr) {
delete (IntCurvesFace_Intersector *)ptr;
myMapOfInter.ChangeFind(iter.Key()) = NULL;
}
}
myMapOfInter.Clear();
}
//=======================================================================
//function : InitShape
//purpose :
//=======================================================================
void BRepClass3d_SolidExplorer::InitShape(const TopoDS_Shape& S)
{
myShape = S;
myFirstFace = 0;
myParamOnEdge = 0.512345;
//-- Exploration de la Map et delete sur les objets alloues
BRepClass3d_DataMapIteratorOfMapOfInter iter(myMapOfInter);
for(;iter.More();iter.Next()) {
void *ptr=iter.Value();
if(ptr) {
delete (IntCurvesFace_Intersector *)ptr;
myMapOfInter.ChangeFind(iter.Key()) = NULL;
}
}
myMapOfInter.Clear();
myReject = Standard_True; //-- cas de solide infini (sans aucune face)
TopExp_Explorer Expl;
for(Expl.Init(S,TopAbs_FACE);
Expl.More();
Expl.Next()) {
const TopoDS_Face Face = TopoDS::Face(Expl.Current());
void *ptr = (void *)(new IntCurvesFace_Intersector(Face,Precision::Confusion()));
myMapOfInter.Bind(Face,ptr);
myReject=Standard_False; //-- au moins une face dans le solide
}
#if DEB
if(myReject) {
cout<<"\nWARNING : BRepClass3d_SolidExplorer.cxx (Solid sans face)"<<endl;
}
#endif
#if REJECTION
BRepBndLib::Add(myShape,myBox);
#endif
}
//=======================================================================
//function : Reject
//purpose : Should return True if P outside of bounding vol. of the shape
//=======================================================================
//Standard_Boolean BRepClass3d_SolidExplorer::Reject(const gp_Pnt& P) const
Standard_Boolean BRepClass3d_SolidExplorer::Reject(const gp_Pnt& ) const
{
return(myReject); // cas de solide sans face
}
//=======================================================================
//function : InitShell
//purpose : Starts an exploration of the shells.
//=======================================================================
void BRepClass3d_SolidExplorer::InitShell()
{
myShellExplorer.Init(myShape,TopAbs_SHELL);
}
//=======================================================================
//function : MoreShell
//purpose : Returns True if there is a current shell.
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::MoreShell() const
{
return(myShellExplorer.More());
}
//=======================================================================
//function : NextShell
//purpose : Sets the explorer to the next shell.
//=======================================================================
void BRepClass3d_SolidExplorer::NextShell()
{
myShellExplorer.Next();
}
//=======================================================================
//function : CurrentShell
//purpose : Returns the current shell.
//=======================================================================
TopoDS_Shell BRepClass3d_SolidExplorer::CurrentShell() const
{
return(TopoDS::Shell(myShellExplorer.Current()));
}
//=======================================================================
//function : RejectShell
//purpose : Returns True if the Shell is rejected.
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::RejectShell(const gp_Lin& ) const
{
return(Standard_False);
}
//=======================================================================
//function : InitFace
//purpose : Starts an exploration of the faces of the current shell.
//=======================================================================
void BRepClass3d_SolidExplorer::InitFace()
{
myFaceExplorer.Init(TopoDS::Shell(myShellExplorer.Current()),TopAbs_FACE);
}
//=======================================================================
//function : MoreFace
//purpose : Returns True if current face in current shell.
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::MoreFace() const
{
return(myFaceExplorer.More());
}
//=======================================================================
//function : NextFace
//purpose : Sets the explorer to the next Face of the current shell.
//=======================================================================
void BRepClass3d_SolidExplorer::NextFace()
{
myFaceExplorer.Next();
}
//=======================================================================
//function : CurrentFace
//purpose : Returns the current face.
//=======================================================================
TopoDS_Face BRepClass3d_SolidExplorer::CurrentFace() const
{
return(TopoDS::Face(myFaceExplorer.Current()));
}
//=======================================================================
//function : RejectFace
//purpose : returns True if the face is rejected.
//=======================================================================
Standard_Boolean BRepClass3d_SolidExplorer::RejectFace(const gp_Lin& ) const
{
return(Standard_False);
}
#ifdef DEB
#include <TopAbs_State.hxx>
#endif
//=======================================================================
//function : Segment
//purpose : Returns in <L>, <Par> a segment having at least
// one intersection with the shape boundary to
// compute intersections.
//=======================================================================
//modified by NIZNHY-PKV Thu Nov 14 14:40:35 2002 f
//void BRepClass3d_SolidExplorer::Segment(const gp_Pnt& P,
// gp_Lin& L,
// Standard_Real& Par) {
// myFirstFace = 0;
// OtherSegment(P,L,Par);
//}
Standard_Integer BRepClass3d_SolidExplorer::Segment(const gp_Pnt& P,
gp_Lin& L,
Standard_Real& Par)
{
Standard_Integer bRetFlag;
myFirstFace = 0;
bRetFlag=OtherSegment(P,L,Par);
return bRetFlag;
}
//modified by NIZNHY-PKV Thu Nov 14 14:41:48 2002 t
//=======================================================================
//function : Intersector
//purpose :
//=======================================================================
IntCurvesFace_Intersector& BRepClass3d_SolidExplorer::Intersector(const TopoDS_Face& F) const {
void *ptr = (void*)(myMapOfInter.Find(F));
#ifndef DEB
IntCurvesFace_Intersector& curr = (*((IntCurvesFace_Intersector *)ptr));
return curr;
#else
return(*((IntCurvesFace_Intersector *)ptr));
#endif
}
//=======================================================================
//function : Box
//purpose :
//=======================================================================
const Bnd_Box& BRepClass3d_SolidExplorer::Box() const {
return(myBox);
}
//=======================================================================
//function : DumpSegment
//purpose :
//=======================================================================
void BRepClass3d_SolidExplorer::DumpSegment(const gp_Pnt&,
const gp_Lin&,
const Standard_Real,
const TopAbs_State) const
{
#ifdef DEB
// rien pour le moment.
#endif
}