Refactor IntCurvesFace_ShapeIntersector. Use handles and std::unique_ptr instead of raw pointers.
IntCurvesFace_Intersector.lxx
IntCurvesFace_ShapeIntersector.cxx
IntCurvesFace_ShapeIntersector.hxx
-IntCurvesFace_ShapeIntersector.lxx
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(IntCurvesFace_Intersector, Standard_Transient)
+
//
static void ComputeSamplePars(const Handle(Adaptor3d_Surface)& Hsurface,
const Standard_Integer nbsu,
done(Standard_False),
myReady(Standard_False),
nbpnt(0),
- PtrOnPolyhedron(NULL),
- PtrOnBndBounding(NULL),
myUseBoundTol (UseBToler),
myIsParallel(Standard_False)
{
{
Handle(TColStd_HArray1OfReal) UPars, VPars;
ComputeSamplePars(Hsurface, nbsu, nbsv, UPars, VPars);
- PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *)
- new IntCurveSurface_ThePolyhedronOfHInter(Hsurface, UPars->ChangeArray1(),
- VPars->ChangeArray1());
+ myPolyhedron.reset(new IntCurveSurface_ThePolyhedronOfHInter(Hsurface, UPars->ChangeArray1(),
+ VPars->ChangeArray1()));
}
else
{
- PtrOnPolyhedron = (IntCurveSurface_ThePolyhedronOfHInter *)
- new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1);
+ myPolyhedron.reset(new IntCurveSurface_ThePolyhedronOfHInter(Hsurface,nbsu,nbsv,U0,V0,U1,V1));
}
}
myReady = Standard_True;
//purpose :
//=======================================================================
void IntCurvesFace_Intersector::InternalCall(const IntCurveSurface_HInter &HICS,
- const Standard_Real parinf,
- const Standard_Real parsup)
+ const Standard_Real parinf,
+ const Standard_Real parsup)
{
if(HICS.IsDone() && HICS.NbPoints() > 0) {
//Calculate tolerance for 2d classifier
Standard_Real W = HICSW;
IntCurveSurface_TransitionOnCurve transition = HICSPointindex.Transition();
gp_Pnt pnt = HICSPointindex.Pnt();
- // state = currentstate;
// Modified by skv - Wed Sep 3 16:14:10 2003 OCC578 Begin
Standard_Integer anIntState = (currentstate == TopAbs_IN) ? 0 : 1;
// Modified by skv - Wed Sep 3 16:14:11 2003 OCC578 End
//purpose :
//=======================================================================
void IntCurvesFace_Intersector::Perform(const gp_Lin& L,
- const Standard_Real ParMin,
- const Standard_Real ParMax)
+ const Standard_Real ParMin,
+ const Standard_Real ParMax)
{
done = Standard_False;
if (!myReady)
Standard_Real parinf=ParMin;
Standard_Real parsup=ParMax;
//
- if(PtrOnPolyhedron == NULL) {
+ if(!myPolyhedron) {
HICS.Perform(HLL,Hsurface);
}
else {
Bnd_Box boxLine;
bndTool.LinBox
(L,
- ((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding(),
+ myPolyhedron->Bounding(),
boxLine);
if(bndTool.NbSegments() == 0)
return;
if((psup - pinf)<1e-10) { pinf-=1e-10; psup+=1e-10; }
if(nbseg==1) { parinf=pinf; parsup=psup; }
else {
- if(parinf>pinf) parinf = pinf;
- if(parsup<psup) parsup = psup;
+ if(parinf>pinf) parinf = pinf;
+ if(parsup<psup) parsup = psup;
}
}
if(parinf>ParMax) { return; }
if(parsup>ParMax) parsup=ParMax;
if(parinf>(parsup-1e-9)) return;
IntCurveSurface_ThePolygonOfHInter polygon(HLL,
- parinf,
- parsup,
- 2);
+ parinf,
+ parsup,
+ 2);
#if OPTIMISATION
- if(PtrOnBndBounding==NULL) {
- PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox();
- IntCurveSurface_ThePolyhedronOfHInter *thePolyh=
- (IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
- ((Bnd_BoundSortBox *)(PtrOnBndBounding))->
- Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
- IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh));
+ if(!myBndBounding)
+ {
+ myBndBounding.reset(new Bnd_BoundSortBox());
+ myBndBounding->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*myPolyhedron),
+ IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*myPolyhedron));
}
HICS.Perform(HLL,
- polygon,
- Hsurface,
- *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron),
- *((Bnd_BoundSortBox *)PtrOnBndBounding));
+ polygon,
+ Hsurface,
+ *myPolyhedron,
+ *myBndBounding);
#else
HICS.Perform(HLL,
- polygon,
- Hsurface,
- *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron));
+ polygon,
+ Hsurface,
+ *myPolyhedron);
#endif
}
//purpose :
//=======================================================================
void IntCurvesFace_Intersector::Perform(const Handle(Adaptor3d_Curve)& HCu,
- const Standard_Real ParMin,
- const Standard_Real ParMax)
+ const Standard_Real ParMin,
+ const Standard_Real ParMax)
{
done = Standard_False;
if (!myReady)
Standard_Real parinf=ParMin;
Standard_Real parsup=ParMax;
- if(PtrOnPolyhedron == NULL) {
+ if(!myPolyhedron)
+ {
HICS.Perform(HCu,Hsurface);
}
- else {
+ else
+ {
parinf = IntCurveSurface_TheHCurveTool::FirstParameter(HCu);
parsup = IntCurveSurface_TheHCurveTool::LastParameter(HCu);
if(parinf<ParMin) parinf = ParMin;
nbs = IntCurveSurface_TheHCurveTool::NbSamples(HCu,parinf,parsup);
IntCurveSurface_ThePolygonOfHInter polygon(HCu,
- parinf,
- parsup,
- nbs);
+ parinf,
+ parsup,
+ nbs);
#if OPTIMISATION
- if(PtrOnBndBounding==NULL) {
- PtrOnBndBounding = (Bnd_BoundSortBox *) new Bnd_BoundSortBox();
- IntCurveSurface_ThePolyhedronOfHInter *thePolyh=(IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
- ((Bnd_BoundSortBox *)(PtrOnBndBounding))->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*thePolyh),
- IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*thePolyh));
+ if(!myBndBounding) {
+ myBndBounding.reset(new Bnd_BoundSortBox());
+ myBndBounding->Initialize(IntCurveSurface_ThePolyhedronToolOfHInter::Bounding(*myPolyhedron),
+ IntCurveSurface_ThePolyhedronToolOfHInter::ComponentsBounding(*myPolyhedron));
}
HICS.Perform(HCu,
- polygon,
- Hsurface,
- *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron),
- *((Bnd_BoundSortBox *)PtrOnBndBounding));
+ polygon,
+ Hsurface,
+ *myPolyhedron,
+ *myBndBounding);
#else
HICS.Perform(HCu,
- polygon,
- Hsurface,
- *((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron));
+ polygon,
+ Hsurface,
+ *myPolyhedron);
#endif
}
InternalCall(HICS,parinf,parsup);
//============================================================================
Bnd_Box IntCurvesFace_Intersector::Bounding() const {
- if(PtrOnPolyhedron !=NULL) {
- return(((IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron)->Bounding());
+ if(myPolyhedron)
+ {
+ return myPolyhedron->Bounding();
}
- else {
+ else
+ {
Bnd_Box B;
- return(B);
+ return B;
}
}
-TopAbs_State IntCurvesFace_Intersector::ClassifyUVPoint(const gp_Pnt2d& Puv) const {
+
+TopAbs_State IntCurvesFace_Intersector::ClassifyUVPoint(const gp_Pnt2d& Puv) const
+{
TopAbs_State state = myTopolTool->Classify(Puv,1e-7);
- return(state);
-}
-//============================================================================
-void IntCurvesFace_Intersector::Destroy() {
- if(PtrOnPolyhedron !=NULL) {
- delete (IntCurveSurface_ThePolyhedronOfHInter *)PtrOnPolyhedron;
- PtrOnPolyhedron = NULL;
- }
- if(PtrOnBndBounding !=NULL) {
- delete (Bnd_BoundSortBox *)PtrOnBndBounding;
- PtrOnBndBounding=NULL;
- }
+ return state;
}
- void IntCurvesFace_Intersector::SetUseBoundToler(Standard_Boolean UseBToler)
- {
- myUseBoundTol = UseBToler;
- }
+void IntCurvesFace_Intersector::SetUseBoundToler(Standard_Boolean UseBToler)
+{
+ myUseBoundTol = UseBToler;
+}
- Standard_Boolean IntCurvesFace_Intersector::GetUseBoundToler() const
- {
- return myUseBoundTol;
- }
+Standard_Boolean IntCurvesFace_Intersector::GetUseBoundToler() const
+{
+ return myUseBoundTol;
+}
+IntCurvesFace_Intersector::~IntCurvesFace_Intersector()
+{
+}
#define _IntCurvesFace_Intersector_HeaderFile
#include <Adaptor3d_Curve.hxx>
+#include <Bnd_BoundSortBox.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <IntCurveSurface_SequenceOfPnt.hxx>
+#include <IntCurveSurface_ThePolyhedronOfHInter.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TopoDS_Face.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <IntCurveSurface_TransitionOnCurve.hxx>
#include <TopAbs_State.hxx>
+#include <memory>
+
class BRepTopAdaptor_TopolTool;
class gp_Lin;
class gp_Pnt;
class gp_Pnt2d;
class Bnd_Box;
-class IntCurvesFace_Intersector
+DEFINE_STANDARD_HANDLE(IntCurvesFace_Intersector, Standard_Transient)
+
+
+class IntCurvesFace_Intersector : public Standard_Transient
{
+ DEFINE_STANDARD_RTTIEXT(IntCurvesFace_Intersector, Standard_Transient)
+
public:
DEFINE_STANDARD_ALLOC
//! Returns the boundary tolerance flag
Standard_EXPORT Standard_Boolean GetUseBoundToler() const;
- Standard_EXPORT void Destroy();
-~IntCurvesFace_Intersector()
-{
- Destroy();
-}
-
-
-
+ Standard_EXPORT virtual ~IntCurvesFace_Intersector();
protected:
Standard_Boolean myReady;
Standard_Integer nbpnt;
TopoDS_Face face;
- Standard_Address PtrOnPolyhedron;
- Standard_Address PtrOnBndBounding;
+ std::unique_ptr<IntCurveSurface_ThePolyhedronOfHInter> myPolyhedron;
+ std::unique_ptr<Bnd_BoundSortBox> myBndBounding;
Standard_Boolean myUseBoundTol;
Standard_Boolean myIsParallel; //Curve is "parallel" face surface
//This case is recognized only for some pairs
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
-//-- ================================================================================
-IntCurvesFace_ShapeIntersector::IntCurvesFace_ShapeIntersector() {
- nbfaces=0;
- done=Standard_False;
- PtrJetons=NULL;
- PtrJetonsIndex=NULL;
+
+IntCurvesFace_ShapeIntersector::IntCurvesFace_ShapeIntersector()
+: myIsDone(Standard_False),
+ myNbFaces(0)
+{
}
-//-- ================================================================================
-void IntCurvesFace_ShapeIntersector::Load(const TopoDS_Shape& shape,
- const Standard_Real tol) {
- PtrJetons=NULL;
- PtrJetonsIndex=NULL;
- if(nbfaces) {
- Destroy();
- }
+
+void IntCurvesFace_ShapeIntersector::Load(const TopoDS_Shape& theShape,
+ const Standard_Real theTol)
+{
TopExp_Explorer Ex;
Standard_Integer i;
- for(nbfaces=0,i=0,Ex.Init(shape,TopAbs_FACE); Ex.More(); i++,Ex.Next()) {
- nbfaces++;
- TopoDS_Face currentface = TopoDS::Face(Ex.Current());
- PtrIntersector.Append((void *)(new IntCurvesFace_Intersector(currentface,tol)));
- }
-}
-//-- ================================================================================
-void IntCurvesFace_ShapeIntersector::Destroy() {
- if(PtrJetons) {
- delete ((Standard_Integer *)PtrJetons);
- PtrJetons=NULL;
+ for(myNbFaces = 0, i = 0, Ex.Init(theShape, TopAbs_FACE); Ex.More(); ++i, Ex.Next())
+ {
+ ++myNbFaces;
+ TopoDS_Face aCurrentFace = TopoDS::Face(Ex.Current());
+ myIntersector.Append(new IntCurvesFace_Intersector(aCurrentFace, theTol));
}
- if(PtrJetonsIndex) {
- delete ((Standard_Integer *)PtrJetonsIndex);
- PtrJetonsIndex=NULL;
- }
- for(Standard_Integer i=1; i<=nbfaces; i++) {
- IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
- delete Ptr;
- }
- done=Standard_False;
- nbfaces=0;
- PtrIntersector.Clear();
- IndexPt.Clear(); IndexFace.Clear(); IndexIntPnt.Clear();IndexPar.Clear();
}
-//-- ================================================================================
-void IntCurvesFace_ShapeIntersector::Perform(const gp_Lin& L,
- const Standard_Real ParMin,
- const Standard_Real ParMax) {
- done = Standard_False;
- for(Standard_Integer i=1; i<=nbfaces; i++) {
- IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
- Ptr->Perform(L,ParMin,ParMax);
+
+void IntCurvesFace_ShapeIntersector::Perform(const gp_Lin& theL,
+ const Standard_Real theParMin,
+ const Standard_Real theParMax)
+{
+ myIsDone = Standard_False;
+ for(Standard_Integer i = 1; i <= myNbFaces; ++i)
+ {
+ myIntersector.ChangeValue(i)->Perform(theL, theParMin, theParMax);
}
SortResult();
}
-//-- ================================================================================
-void IntCurvesFace_ShapeIntersector::PerformNearest(const gp_Lin& L,
- const Standard_Real ParMin,
- const Standard_Real _ParMax) {
-
- Standard_Integer i;
- Standard_Integer* _PtrJetons=(Standard_Integer *)PtrJetons;
- Standard_Integer* _PtrJetonsIndex=(Standard_Integer *)PtrJetonsIndex;
-
- if(nbfaces>2) {
- if(PtrJetons==NULL) {
- PtrJetons = (void *) new Standard_Integer [nbfaces];
- PtrJetonsIndex = (void *) new Standard_Integer [nbfaces];
- Standard_Integer *Ptr =(Standard_Integer *)PtrJetons;
- Standard_Integer *PtrI=(Standard_Integer *)PtrJetonsIndex;
- for(i=0;i<nbfaces;i++) {
- Ptr[i]=0;
- PtrI[i]=i+1;
+void IntCurvesFace_ShapeIntersector::PerformNearest(const gp_Lin& theL,
+ const Standard_Real theParMin,
+ const Standard_Real theParMax)
+{
+ Standard_Integer i = 0;
+ if(myNbFaces > 2)
+ {
+ if (myPtrNums.IsEmpty())
+ {
+ myPtrNums = TColStd_HArray1OfInteger(0, myNbFaces - 1);
+ myPtrIndexNums = TColStd_HArray1OfInteger(0, myNbFaces - 1);
+ for(; i < myNbFaces; ++i)
+ {
+ myPtrNums.ChangeValue(i) = 0;
+ myPtrIndexNums.ChangeValue(i) = i + 1;
}
- _PtrJetons=(Standard_Integer *)PtrJetons;
- _PtrJetonsIndex=(Standard_Integer *)PtrJetonsIndex;
}
}
-
- Standard_Integer Indexface=-1;
- Standard_Real ParMax=_ParMax;
-
-
- done = Standard_False;
- for(Standard_Integer ii=1; ii<=nbfaces; ii++) {
- if(_PtrJetons) {
- i=_PtrJetonsIndex[ii-1];
+ Standard_Integer anIndexFace = -1;
+ Standard_Real aParMax=theParMax;
+ myIsDone = Standard_False;
+ for(Standard_Integer ii = 1; ii <= myNbFaces; ++ii)
+ {
+ if (!myPtrNums.IsEmpty())
+ {
+ i = myPtrIndexNums.Value(ii - 1);
}
- else {
- i=ii;
+ else
+ {
+ i = ii;
}
-
- IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
- if(ParMin<ParMax) {
- Ptr->Perform(L,ParMin,ParMax);
- if(Ptr->IsDone()) {
- Standard_Integer n=Ptr->NbPnt();
- for(Standard_Integer j=1;j<=n;j++) {
- Standard_Real w=Ptr->WParameter(j);
- if(w<ParMax) {
- ParMax=w;
- Indexface=ii-1;
- }
- }
+ Handle(IntCurvesFace_Intersector) anIntersector = myIntersector.ChangeValue(i);
+ if(theParMin < aParMax)
+ {
+ anIntersector->Perform(theL, theParMin,aParMax);
+ if(anIntersector->IsDone())
+ {
+ Standard_Integer n = anIntersector->NbPnt();
+ for(Standard_Integer j = 1; j <= n; ++j)
+ {
+ Standard_Real w = anIntersector->WParameter(j);
+ if(w < aParMax)
+ {
+ aParMax = w;
+ anIndexFace = ii - 1;
+ }
+ }
}
- else {
- done = Standard_False;
- return;
+ else
+ {
+ myIsDone = Standard_False;
+ return;
}
}
}
- if(PtrJetons && Indexface>=0) {
- _PtrJetons[Indexface]++;
-
+ if (!myPtrNums.IsEmpty() && anIndexFace >= 0)
+ {
+ myPtrNums.ChangeValue(anIndexFace) += 1;
Standard_Integer im1;
- for(im1=Indexface-1,i=Indexface; i>=1 && _PtrJetons[i]>_PtrJetons[i-1]; i--,im1--) {
- Standard_Integer t=_PtrJetonsIndex[i];
- _PtrJetonsIndex[i]=_PtrJetonsIndex[im1];
- _PtrJetonsIndex[im1]=t;
- t=_PtrJetons[i];
- _PtrJetons[i]=_PtrJetons[im1];
- _PtrJetons[im1]=t;
+ for (im1 = anIndexFace - 1, i = anIndexFace; i >= 1 && myPtrNums.Value(i) > myPtrNums.Value(im1); --i, --im1)
+ {
+ std::swap(myPtrIndexNums.ChangeValue(i), myPtrIndexNums.ChangeValue(im1));
+ std::swap(myPtrNums.ChangeValue(i), myPtrNums.ChangeValue(im1));
}
- //--for(Standard_Integer dd=0; dd<nbfaces;dd++) { if(_PtrJetons[dd]) { printf("\n<%3d %3d %3d>",dd,_PtrJetons[dd],_PtrJetonsIndex[dd]); } }
- //--printf("\n");
}
SortResult();
}
-//-- ================================================================================
-void IntCurvesFace_ShapeIntersector::Perform(const Handle(Adaptor3d_Curve)& HCu,
- const Standard_Real ParMin,
- const Standard_Real ParMax) {
- done = Standard_False;
- for(Standard_Integer i=1; i<=nbfaces; i++) {
- IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(i);
- Ptr->Perform(HCu,ParMin,ParMax);
+
+void IntCurvesFace_ShapeIntersector::Perform(const Handle(Adaptor3d_Curve)& theHCurve,
+ const Standard_Real theParMin,
+ const Standard_Real theParMax)
+{
+ myIsDone = Standard_False;
+ for(Standard_Integer i = 1; i <= myNbFaces; ++i)
+ {
+ Handle(IntCurvesFace_Intersector) anIntersector = myIntersector.ChangeValue(i);
+ anIntersector->Perform(theHCurve, theParMin, theParMax);
}
SortResult();
}
//-- ================================================================================
-//-- PtrIntersector : Sequence d addresses
-//-- IndexPt : 1 2 3 .... n points avant le tri
-//-- IndexFace : Numero de la face (de l intersector) du point IndexPt(i)
-//-- IndexIntPnt : Numero du point IndexPt(i) dans l'intersector IndexFace(IndexPt(i))
-//-- IndexPar : W parameter du point IndexPt(i)
+//-- myIntersector : Sequence of the addresses
+//-- myIndexPt : 1 2 3 .... n Points before the sorting
+//-- myNumberFace : Number of the face (of the intersector) of the point myIndexPt(i)
+//-- myNumberIntPnt : Number of the point myIndexPt(i) of the intersection myNumberFace(myIndexPt(i))
+//-- myIndexPar : Parameter W of point myIndexPt(i)
//--
-//-- En resume, pour chaque point indice par K = IndexPt(i) on a
-//-- * la face a laquelle il appartient : IndexFace(K)
-//-- * le numero du point dans l'intersecteur FaceCurve : IndexIntPnt(K)
-//-- * le parametre W du point sur la courbe : IndexPar(K)
+//-- To sum up, for each point index of K = myIndexPt(i) on a
+//-- * the face to which it belongs : myNumberFace(K)
+//-- * the number of the point in the intersection for FaceCurve : myNumberIntPnt(K)
+//-- * the parameter W of the point on the curve : myIndexPar(K)
//--
-//-- SortResult Trie les points par ordre croissant de W
-//-- (remet a jour le tableau d index TabPt(.))
+//-- SortResult Sorts the points in ascending order of W
+//-- (updating the index table TabPt(.))
//--
//-- ================================================================================
-void IntCurvesFace_ShapeIntersector::SortResult() {
- done = Standard_True;
- Standard_Integer nbpnt=0;
- IndexPt.Clear(); IndexFace.Clear(); IndexIntPnt.Clear();IndexPar.Clear();
- //-- -----------------------------------------------------
- //-- r e c u p e r a t i o n d e s r e s u l t a t s
- //--
- for(Standard_Integer f=1; f<=nbfaces; f++) {
- IntCurvesFace_Intersector *Ptr = (IntCurvesFace_Intersector *)PtrIntersector.ChangeValue(f);
- if(Ptr->IsDone()) {
- Standard_Integer n=Ptr->NbPnt();
- for(Standard_Integer j=1;j<=n;j++) {
- IndexPt.Append(++nbpnt);
- IndexFace.Append(f);
- IndexIntPnt.Append(j);
- IndexPar.Append(Ptr->WParameter(j));
+void IntCurvesFace_ShapeIntersector::SortResult()
+{
+ myIsDone = Standard_True;
+ Standard_Integer aNbPnt=0;
+ myIndexPt.Clear();
+ myIndexFace.Clear();
+ myIndexIntPnt.Clear();
+ myIndexPar.Clear();
+
+ //Retrieval of the results
+ for(Standard_Integer f = 1; f <= myNbFaces; ++f)
+ {
+ Handle(IntCurvesFace_Intersector) anIntersector = myIntersector.ChangeValue(f);
+ if(anIntersector->IsDone())
+ {
+ Standard_Integer n = anIntersector->NbPnt();
+ for(Standard_Integer j = 1; j <= n; ++j)
+ {
+ myIndexPt.Append(++aNbPnt);
+ myIndexFace.Append(f);
+ myIndexIntPnt.Append(j);
+ myIndexPar.Append(anIntersector->WParameter(j));
}
}
- else {
- done = Standard_False;
+ else
+ {
+ myIsDone = Standard_False;
return;
}
}
- //-- -----------------------------------------------------
- //-- t r i s e l o n l e p a r a m e t r e w
- //--
- Standard_Boolean triok;
- do {
- triok=Standard_True;
- for(Standard_Integer ind0=1;ind0<nbpnt;ind0++) {
- Standard_Integer ind =IndexPt(ind0);
- Standard_Integer indp1=IndexPt(ind0+1);
- if(IndexPar(ind) > IndexPar(indp1)) {
- IndexPt(ind0) =indp1;
- IndexPt(ind0+1)=ind;
- triok=Standard_False;
+
+ //Sort according to parameter w
+ Standard_Boolean isOK;
+ do
+ {
+ isOK = Standard_True;
+ for(Standard_Integer ind0 = 1; ind0 < aNbPnt; ind0++)
+ {
+ Standard_Integer ind = myIndexPt(ind0);
+ Standard_Integer indp1 = myIndexPt(ind0 + 1);
+ if(myIndexPar(ind) > myIndexPar(indp1))
+ {
+ myIndexPt(ind0) = indp1;
+ myIndexPt(ind0 + 1) = ind;
+ isOK = Standard_False;
}
}
}
- while(triok==Standard_False);
+ while(!isOK);
+}
+
+IntCurvesFace_ShapeIntersector::~IntCurvesFace_ShapeIntersector()
+{
}
-//-- ================================================================================
-//-- Creation le 28 jan 98
-//--
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
-#include <Standard_Address.hxx>
-#include <BRepTopAdaptor_SeqOfPtr.hxx>
+#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_SequenceOfInteger.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <Standard_Real.hxx>
#include <IntCurveSurface_TransitionOnCurve.hxx>
+#include <IntCurvesFace_Intersector.hxx>
#include <TopAbs_State.hxx>
class Adaptor3d_Curve;
//! segment L and the loaded shape.
//!
//! PInf is the smallest parameter on the line
- //! PSup is the highest parammter on the line
+ //! PSup is the highest parameter on the line
//!
//! For an infinite line PInf and PSup can be
//! +/- RealLast.
//! segment L and the loaded shape.
//!
//! PInf is the smallest parameter on the line
- //! PSup is the highest parammter on the line
+ //! PSup is the highest parameter on the line
//!
//! For an infinite line PInf and PSup can be
//! +/- RealLast.
Standard_EXPORT void PerformNearest (const gp_Lin& L, const Standard_Real PInf, const Standard_Real PSup);
//! same method for a HCurve from Adaptor3d.
- //! PInf an PSup can also be - and + INF.
+ //! PInf an PSup can also be -INF and +INF.
Standard_EXPORT void Perform (const Handle(Adaptor3d_Curve)& HCu, const Standard_Real PInf, const Standard_Real PSup);
- //! True is returned when the intersection have been computed.
- Standard_Boolean IsDone() const;
-
- Standard_Integer NbPnt() const;
+ //! True when the intersection has been computed.
+ Standard_Boolean IsDone() const
+ {
+ return myIsDone;
+ }
+ //! Returns the number of the intersection points
+ Standard_Integer NbPnt() const
+ {
+ return myIndexPt.Length();
+ }
//! Returns the U parameter of the ith intersection point
//! on the surface.
- Standard_Real UParameter (const Standard_Integer I) const;
-
+ Standard_Real UParameter (const Standard_Integer I) const
+ {
+ Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
+ return anIntAdaptor->UParameter(myIndexIntPnt(myIndexPt(I)));
+ }
+
//! Returns the V parameter of the ith intersection point
//! on the surface.
- Standard_Real VParameter (const Standard_Integer I) const;
+ Standard_Real VParameter (const Standard_Integer I) const
+ {
+ Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
+ return anIntAdaptor->VParameter(myIndexIntPnt(myIndexPt(I)));
+ }
//! Returns the parameter of the ith intersection point
//! on the line.
- Standard_Real WParameter (const Standard_Integer I) const;
+ Standard_Real WParameter (const Standard_Integer I) const
+ {
+ Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
+ return anIntAdaptor->WParameter(myIndexIntPnt(myIndexPt(I)));
+ }
//! Returns the geometric point of the ith intersection
//! between the line and the surface.
- const gp_Pnt& Pnt (const Standard_Integer I) const;
+ const gp_Pnt& Pnt (const Standard_Integer I) const
+ {
+ Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
+ return anIntAdaptor->Pnt(myIndexIntPnt(myIndexPt(I)));
+ }
//! Returns the ith transition of the line on the surface.
- IntCurveSurface_TransitionOnCurve Transition (const Standard_Integer I) const;
+ IntCurveSurface_TransitionOnCurve Transition (const Standard_Integer I) const
+ {
+ Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
+ return anIntAdaptor->Transition(myIndexIntPnt(myIndexPt(I)));
+ }
//! Returns the ith 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 boundary of the face).
- TopAbs_State State (const Standard_Integer I) const;
+ TopAbs_State State(const Standard_Integer I) const
+ {
+ Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
+ return anIntAdaptor->State(myIndexIntPnt(myIndexPt(I)));
+ }
//! Returns the significant face used to determine
//! the intersection.
- const TopoDS_Face& Face (const Standard_Integer I) const;
+ const TopoDS_Face& Face(const Standard_Integer I) const
+ {
+ Handle(IntCurvesFace_Intersector) anIntAdaptor = myIntersector(myIndexFace(myIndexPt(I)));
+ return anIntAdaptor->Face();
+ }
//! Internal method. Sort the result on the Curve
//! parameter.
Standard_EXPORT void SortResult();
- Standard_EXPORT void Destroy();
-~IntCurvesFace_ShapeIntersector()
-{
- Destroy();
-}
-
-
-
-
-protected:
-
-
-
-
+ Standard_EXPORT virtual ~IntCurvesFace_ShapeIntersector();
private:
-
-
-
- Standard_Boolean done;
- Standard_Integer nbfaces;
- Standard_Address PtrJetons;
- Standard_Address PtrJetonsIndex;
- BRepTopAdaptor_SeqOfPtr PtrIntersector;
- TColStd_SequenceOfInteger IndexPt;
- TColStd_SequenceOfInteger IndexFace;
- TColStd_SequenceOfInteger IndexIntPnt;
- TColStd_SequenceOfReal IndexPar;
-
-
+
+ Standard_Boolean myIsDone;
+ Standard_Integer myNbFaces;
+ TColStd_Array1OfInteger myPtrNums;
+ TColStd_Array1OfInteger myPtrIndexNums;
+ NCollection_Sequence<Handle(IntCurvesFace_Intersector)> myIntersector;
+ TColStd_SequenceOfInteger myIndexPt;
+ TColStd_SequenceOfInteger myIndexFace;
+ TColStd_SequenceOfInteger myIndexIntPnt;
+ TColStd_SequenceOfReal myIndexPar;
};
-
-#include <IntCurvesFace_ShapeIntersector.lxx>
-
-
-
-
-
#endif // _IntCurvesFace_ShapeIntersector_HeaderFile
+++ /dev/null
-// Created on: 1998-01-28
-// Created by: Laurent BUCHARD
-// Copyright (c) 1998-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-#include <IntCurvesFace_Intersector.hxx>
-
-
-inline Standard_Integer IntCurvesFace_ShapeIntersector::NbPnt() const {
- return(IndexPt.Length());
-}
-
-inline Standard_Real IntCurvesFace_ShapeIntersector::UParameter(const Standard_Integer i) const {
- IntCurvesFace_Intersector *Ptr =
- (IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
- return(Ptr->UParameter(IndexIntPnt(IndexPt(i))));
-}
-
-inline Standard_Real IntCurvesFace_ShapeIntersector::VParameter(const Standard_Integer i) const {
- IntCurvesFace_Intersector *Ptr =
- (IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
- return(Ptr->VParameter(IndexIntPnt(IndexPt(i))));
-}
-
-inline Standard_Real IntCurvesFace_ShapeIntersector::WParameter(const Standard_Integer i) const {
- IntCurvesFace_Intersector *Ptr =
- (IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
- return(Ptr->WParameter(IndexIntPnt(IndexPt(i))));
-}
-
-inline const gp_Pnt& IntCurvesFace_ShapeIntersector::Pnt(const Standard_Integer i) const {
- IntCurvesFace_Intersector *Ptr =
- (IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
- return(Ptr->Pnt(IndexIntPnt(IndexPt(i))));
-}
-
-inline IntCurveSurface_TransitionOnCurve IntCurvesFace_ShapeIntersector::Transition(const Standard_Integer i) const {
- IntCurvesFace_Intersector *Ptr =
- (IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
- return(Ptr->Transition(IndexIntPnt(IndexPt(i))));
-}
-
-inline TopAbs_State IntCurvesFace_ShapeIntersector::State(const Standard_Integer i) const {
- IntCurvesFace_Intersector *Ptr =
- (IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
- return(Ptr->State(IndexIntPnt(IndexPt(i))));
-}
-
-
-inline const TopoDS_Face& IntCurvesFace_ShapeIntersector::Face(const Standard_Integer i) const {
- IntCurvesFace_Intersector *Ptr =
- (IntCurvesFace_Intersector *)(PtrIntersector(IndexFace(IndexPt(i))));
- return(Ptr->Face());
-}
-
-inline Standard_Boolean IntCurvesFace_ShapeIntersector::IsDone() const {
- return(done);
-}
-
-