mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
56
src/BRepTopAdaptor/BRepTopAdaptor.cdl
Executable file
56
src/BRepTopAdaptor/BRepTopAdaptor.cdl
Executable file
@@ -0,0 +1,56 @@
|
||||
-- File: BRepTopAdaptor.cdl
|
||||
-- Created: Fri Apr 1 10:51:41 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@nonox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
package BRepTopAdaptor
|
||||
|
||||
---Purpose:
|
||||
--
|
||||
--
|
||||
-- *** Class2d : Low level algorithm for 2d classification
|
||||
--
|
||||
-- *** FClass2d : 2d classification on a Face from TopoDS
|
||||
-- A face is first loaded and then every
|
||||
-- classification is computed as a rejection.
|
||||
-- (call BRepClass algorithms if necessary,
|
||||
-- ie, when the rejection is not efficient)
|
||||
--
|
||||
-- *** TopolTool : Several tools used by the intersection
|
||||
-- algorithm and topology.
|
||||
--
|
||||
--
|
||||
|
||||
---Level: Internal
|
||||
|
||||
uses Adaptor3d, TopExp, TopoDS, BRepAdaptor, gp, TopAbs, Adaptor2d ,
|
||||
TColgp,TColStd,TCollection,TopTools, CSLib
|
||||
|
||||
is
|
||||
|
||||
--class Class2d;
|
||||
|
||||
alias SeqOfPtr is SequenceOfAddress from TColStd;
|
||||
|
||||
class FClass2d;
|
||||
|
||||
class HVertex; -- inherits HVertex from Adaptor3d
|
||||
|
||||
class TopolTool; -- inherits TopolTool from Adaptor3d
|
||||
|
||||
|
||||
|
||||
--- the folowing classes are used to compute and store
|
||||
-- informations on shapes. ( TopolTool , Bnd_Box ... )
|
||||
|
||||
class Tool;
|
||||
|
||||
class MapOfShapeTool instantiates DataMap from TCollection
|
||||
(Shape from TopoDS,
|
||||
Tool from BRepTopAdaptor,
|
||||
ShapeMapHasher from TopTools);
|
||||
|
||||
|
||||
end BRepTopAdaptor;
|
68
src/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cdl
Executable file
68
src/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cdl
Executable file
@@ -0,0 +1,68 @@
|
||||
-- File: BRepTopAdaptor_FClass2d.cdl
|
||||
-- Created: Wed Mar 22 09:29:42 1995
|
||||
-- Author: Laurent BUCHARD
|
||||
-- <lbr@mastox>
|
||||
---Copyright: Matra Datavision 1995
|
||||
|
||||
|
||||
class FClass2d from BRepTopAdaptor
|
||||
|
||||
uses
|
||||
Pnt2d from gp,
|
||||
Face from TopoDS,
|
||||
State from TopAbs,
|
||||
SequenceOfInteger from TColStd,
|
||||
SeqOfPtr from BRepTopAdaptor
|
||||
|
||||
is
|
||||
|
||||
Create(F: Face from TopoDS; Tol: Real from Standard)
|
||||
returns FClass2d from BRepTopAdaptor;
|
||||
|
||||
|
||||
PerformInfinitePoint(me)
|
||||
returns State from TopAbs;
|
||||
|
||||
Perform(me; Puv: Pnt2d from gp; RecadreOnPeriodic: Boolean from Standard = Standard_True)
|
||||
returns State from TopAbs;
|
||||
|
||||
Destroy(me: in out);
|
||||
---C++: alias ~
|
||||
|
||||
|
||||
Copy(me; Other: FClass2d from BRepTopAdaptor)
|
||||
returns FClass2d from BRepTopAdaptor;
|
||||
---C++: return const &
|
||||
---C++: alias operator=
|
||||
--Purpose *** Raise if called ***
|
||||
|
||||
|
||||
TestOnRestriction(me; Puv: Pnt2d from gp;
|
||||
Tol: Real from Standard;
|
||||
RecadreOnPeriodic: Boolean from Standard = Standard_True)
|
||||
returns State from TopAbs;
|
||||
---Purpose: Test a point with +- an offset (Tol) and returns
|
||||
-- On if some points are OUT an some are IN
|
||||
-- (Caution: Internal use . see the code for more details)
|
||||
|
||||
|
||||
|
||||
|
||||
fields
|
||||
|
||||
TabClass : SeqOfPtr from BRepTopAdaptor;
|
||||
TabOrien : SequenceOfInteger from TColStd;
|
||||
Toluv : Real from Standard;
|
||||
Face : Face from TopoDS;
|
||||
U1 : Real from Standard;
|
||||
V1 : Real from Standard;
|
||||
U2 : Real from Standard;
|
||||
V2 : Real from Standard;
|
||||
|
||||
Umin : Real from Standard;
|
||||
Umax : Real from Standard;
|
||||
Vmin : Real from Standard;
|
||||
Vmax : Real from Standard;
|
||||
|
||||
|
||||
end FClass2d from BRepTopAdaptor;
|
683
src/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cxx
Executable file
683
src/BRepTopAdaptor/BRepTopAdaptor_FClass2d.cxx
Executable file
@@ -0,0 +1,683 @@
|
||||
// File: BRepTopAdaptor_FClass2d.cxx
|
||||
// Created: Wed Mar 22 09:44:18 1995
|
||||
// Author: Laurent BUCHARD
|
||||
// <lbr@mastox>
|
||||
|
||||
#define AFFICHAGE 0
|
||||
|
||||
#define No_Standard_OutOfRange
|
||||
|
||||
#include <BRepTopAdaptor_FClass2d.ixx>
|
||||
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopAbs_Orientation.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TColgp_SequenceOfPnt2d.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <Geom2dInt_Geom2dCurveTool.hxx>
|
||||
#include <BRepAdaptor_Curve2d.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <CSLib_Class2d.hxx>
|
||||
#include <GeomAbs_SurfaceType.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
#include <TopExp.hxx>
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
|
||||
#include <Precision.hxx>
|
||||
|
||||
#ifdef WNT
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEB
|
||||
#define LBRCOMPT 0
|
||||
#else
|
||||
#define LBRCOMPT 0
|
||||
#endif
|
||||
|
||||
|
||||
#if LBRCOMPT
|
||||
class StatistiquesFClass2d {
|
||||
public:
|
||||
long unsigned NbConstrShape;
|
||||
long unsigned NbPerformInfinitePoint;
|
||||
long unsigned NbPerform;
|
||||
long unsigned NbTestOnRestriction;
|
||||
long unsigned NbDestroy;
|
||||
public:
|
||||
StatistiquesFClass2d() {
|
||||
NbConstrShape=NbPerform=NbPerformInfinitePoint=NbDestroy=0;
|
||||
}
|
||||
~StatistiquesFClass2d() {
|
||||
printf("\n--- Statistiques BRepTopAdaptor:\n");
|
||||
printf("\nConstructeur(Shape) : %10lu",NbConstrShape);
|
||||
printf("\nPerformInfinitePoint: %10lu",NbPerformInfinitePoint);
|
||||
printf("\nTestOnRestriction : %10lu",NbTestOnRestriction);
|
||||
printf("\nPerform(pnt2d) : %10lu",NbPerform);
|
||||
printf("\nDestroy : %10lu",NbDestroy);
|
||||
}
|
||||
};
|
||||
|
||||
static StatistiquesFClass2d STAT;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
BRepTopAdaptor_FClass2d::BRepTopAdaptor_FClass2d(const TopoDS_Face& aFace,const Standard_Real TolUV)
|
||||
: Toluv(TolUV), Face(aFace) {
|
||||
|
||||
#if LBRCOMPT
|
||||
STAT.NbConstrShape++;
|
||||
#endif
|
||||
|
||||
//-- impasse sur les surfs definies sur plus d une periode
|
||||
|
||||
Face.Orientation(TopAbs_FORWARD);
|
||||
Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
|
||||
surf->ChangeSurface().Initialize(aFace,Standard_False);
|
||||
|
||||
TopoDS_Edge edge;
|
||||
TopAbs_Orientation Or;
|
||||
Standard_Real u,du,Tole = 0.0,Tol=0.0;
|
||||
BRepTools_WireExplorer WireExplorer;
|
||||
TopExp_Explorer FaceExplorer;
|
||||
|
||||
Umin = Vmin = 0.0; //RealLast();
|
||||
Umax = Vmax = -Umin;
|
||||
|
||||
Standard_Integer BadWire=0;
|
||||
for( FaceExplorer.Init(Face,TopAbs_WIRE); (FaceExplorer.More() && BadWire==0); FaceExplorer.Next() )
|
||||
{
|
||||
Standard_Integer nbpnts = 0;
|
||||
TColgp_SequenceOfPnt2d SeqPnt2d;
|
||||
Standard_Integer firstpoint = 1;
|
||||
Standard_Real FlecheU = 0.0;
|
||||
Standard_Real FlecheV = 0.0;
|
||||
Standard_Boolean WireIsNotEmpty = Standard_False;
|
||||
Standard_Integer NbEdges = 0;
|
||||
|
||||
TopExp_Explorer Explorer;
|
||||
for( Explorer.Init(FaceExplorer.Current(),TopAbs_EDGE); Explorer.More(); Explorer.Next() ) NbEdges++;
|
||||
|
||||
gp_Pnt Ancienpnt3d(0,0,0);
|
||||
Standard_Boolean Ancienpnt3dinitialise = Standard_False;
|
||||
|
||||
for( WireExplorer.Init(TopoDS::Wire(FaceExplorer.Current()),Face); WireExplorer.More(); WireExplorer.Next() )
|
||||
{
|
||||
|
||||
NbEdges--;
|
||||
edge = WireExplorer.Current();
|
||||
Or = edge.Orientation();
|
||||
if(Or == TopAbs_FORWARD || Or == TopAbs_REVERSED)
|
||||
{
|
||||
Standard_Real pfbid,plbid;
|
||||
if(BRep_Tool::CurveOnSurface(edge,Face,pfbid,plbid).IsNull()) return;
|
||||
BRepAdaptor_Curve2d C(edge,Face);
|
||||
|
||||
//-- ----------------------------------------
|
||||
Standard_Boolean degenerated=Standard_False;
|
||||
if(BRep_Tool::Degenerated(edge)) degenerated=Standard_True;
|
||||
if(BRep_Tool::IsClosed(edge,Face)) degenerated=Standard_True;
|
||||
TopoDS_Vertex Va,Vb;
|
||||
TopExp::Vertices(edge,Va,Vb);
|
||||
Standard_Real TolVertex1=0.,TolVertex=0.;
|
||||
if (Va.IsNull()) degenerated=Standard_True;
|
||||
else TolVertex1=BRep_Tool::Tolerance(Va);
|
||||
if (Vb.IsNull()) degenerated=Standard_True;
|
||||
else TolVertex=BRep_Tool::Tolerance(Vb);
|
||||
if(TolVertex<TolVertex1) TolVertex=TolVertex1;
|
||||
BRepAdaptor_Curve C3d;
|
||||
|
||||
if(Abs(plbid-pfbid) < 1.e-9) continue;
|
||||
|
||||
//if(degenerated==Standard_False)
|
||||
// C3d.Initialize(edge,Face);
|
||||
|
||||
//-- Verification des cas ou on a oublie de coder degenereted : PRO17410 (janv 99)
|
||||
if(degenerated == Standard_False)
|
||||
{
|
||||
C3d.Initialize(edge,Face);
|
||||
du=(plbid-pfbid)*0.1;
|
||||
u=pfbid+du;
|
||||
gp_Pnt P3da=C3d.Value(u);
|
||||
degenerated=Standard_True;
|
||||
u+=du;
|
||||
do
|
||||
{
|
||||
|
||||
gp_Pnt P3db=C3d.Value(u);
|
||||
// if(P3da.SquareDistance(P3db)) { degenerated=Standard_False; break; }
|
||||
if(P3da.SquareDistance(P3db) > Precision::Confusion()) { degenerated=Standard_False; break; }
|
||||
u+=du;
|
||||
}
|
||||
while(u<plbid);
|
||||
}
|
||||
|
||||
//-- ----------------------------------------
|
||||
|
||||
Tole = BRep_Tool::Tolerance(edge);
|
||||
if(Tole>Tol) Tol=Tole;
|
||||
|
||||
//Standard_Integer nbs = 1 + Geom2dInt_Geom2dCurveTool::NbSamples(C);
|
||||
Standard_Integer nbs = Geom2dInt_Geom2dCurveTool::NbSamples(C);
|
||||
//-- Attention aux bsplines rationnelles de degree 3. (bouts de cercles entre autres)
|
||||
if (nbs > 2) nbs*=4;
|
||||
du = (plbid-pfbid)/(Standard_Real)(nbs-1);
|
||||
|
||||
if(Or==TopAbs_FORWARD) u = pfbid;
|
||||
else { u = plbid; du=-du; }
|
||||
|
||||
//-- ------------------------------------------------------------
|
||||
//-- On regarde la distance uv entre le point de debut de l edge
|
||||
//-- et le dernier point enregistre dans SeqPnt2d
|
||||
//-- On cherche a eloigner le premier point de l edge courant
|
||||
//-- du dernier point enregistre
|
||||
#ifdef DEB
|
||||
gp_Pnt2d Pnt2dDebutEdgeCourant=
|
||||
#endif
|
||||
C.Value(u);
|
||||
|
||||
//Standard_Real Baillement2dU=0;
|
||||
//Standard_Real Baillement2dV=0;
|
||||
#if AFFICHAGE
|
||||
if(nbpnts>1) printf("\nTolVertex %g ",TolVertex);
|
||||
#endif
|
||||
|
||||
if(firstpoint==2) u+=du;
|
||||
Standard_Integer Avant = nbpnts;
|
||||
for(Standard_Integer e = firstpoint; e<=nbs; e++)
|
||||
{
|
||||
gp_Pnt2d P2d = C.Value(u);
|
||||
if(P2d.X()<Umin) Umin = P2d.X();
|
||||
if(P2d.X()>Umax) Umax = P2d.X();
|
||||
if(P2d.Y()<Vmin) Vmin = P2d.Y();
|
||||
if(P2d.Y()>Vmax) Vmax = P2d.Y();
|
||||
|
||||
Standard_Real dist3dptcourant_ancienpnt=1e+20;//RealLast();
|
||||
gp_Pnt P3d;
|
||||
if(degenerated==Standard_False)
|
||||
{
|
||||
P3d=C3d.Value(u);
|
||||
if(nbpnts>1 && Ancienpnt3dinitialise) dist3dptcourant_ancienpnt = P3d.Distance(Ancienpnt3d);
|
||||
}
|
||||
Standard_Boolean IsRealCurve3d = Standard_True; //patch
|
||||
if(dist3dptcourant_ancienpnt < Precision::Confusion())
|
||||
{
|
||||
gp_Pnt MidP3d = C3d.Value( u-du/2. );
|
||||
if (P3d.Distance( MidP3d ) < Precision::Confusion()) IsRealCurve3d = Standard_False;
|
||||
}
|
||||
if(IsRealCurve3d)
|
||||
{
|
||||
if(degenerated==Standard_False) { Ancienpnt3d=P3d; Ancienpnt3dinitialise=Standard_True; }
|
||||
nbpnts++;
|
||||
SeqPnt2d.Append(P2d);
|
||||
}
|
||||
#if AFFICHAGE
|
||||
else { static int mm=0; printf("\npoint p%d %g %g %g",++mm,P3d.X(),P3d.Y(),P3d.Z()); }
|
||||
#endif
|
||||
u+=du;
|
||||
Standard_Integer ii = nbpnts;
|
||||
//-- printf("\n nbpnts:%4d u=%7.5g FlecheU=%7.5g FlecheV=%7.5g ii=%3d Avant=%3d ",nbpnts,u,FlecheU,FlecheV,ii,Avant);
|
||||
// if(ii>(Avant+4))
|
||||
// Modified by Sergey KHROMOV - Fri Apr 19 09:46:12 2002 Begin
|
||||
if(ii>(Avant+4) && SeqPnt2d(ii-2).SquareDistance(SeqPnt2d(ii)))
|
||||
// Modified by Sergey KHROMOV - Fri Apr 19 09:46:13 2002 End
|
||||
{
|
||||
gp_Lin2d Lin(SeqPnt2d(ii-2),gp_Dir2d(gp_Vec2d(SeqPnt2d(ii-2),SeqPnt2d(ii))));
|
||||
Standard_Real ul = ElCLib::Parameter(Lin,SeqPnt2d(ii-1));
|
||||
gp_Pnt2d Pp = ElCLib::Value(ul,Lin);
|
||||
Standard_Real dU = Abs(Pp.X()-SeqPnt2d(ii-1).X());
|
||||
Standard_Real dV = Abs(Pp.Y()-SeqPnt2d(ii-1).Y());
|
||||
//-- printf(" (du=%7.5g dv=%7.5g)",dU,dV);
|
||||
if(dU>FlecheU) FlecheU = dU;
|
||||
if(dV>FlecheV) FlecheV = dV;
|
||||
}
|
||||
}//for(e=firstpoint
|
||||
if(firstpoint==1) firstpoint=2;
|
||||
WireIsNotEmpty = Standard_True;
|
||||
}//if(Or==FORWARD,REVERSED
|
||||
} //-- Edges -> for(Ware.Explorer
|
||||
|
||||
if(NbEdges)
|
||||
{ //-- on compte ++ avec un explorateur normal et -- avec le Wire Exploreur
|
||||
/*
|
||||
#ifdef DEB
|
||||
|
||||
cout << endl;
|
||||
cout << "*** BRepTopAdaptor_Fclass2d ** Wire Probablement FAUX **" << endl;
|
||||
cout << "*** WireExplorer ne trouve pas tous les edges " << endl;
|
||||
cout << "*** On Branche l ancien classifieur" << endl;
|
||||
#endif
|
||||
*/
|
||||
TColgp_Array1OfPnt2d PClass(1,2);
|
||||
//// modified by jgv, 28.04.2009 ////
|
||||
PClass.Init(gp_Pnt2d(0.,0.));
|
||||
/////////////////////////////////////
|
||||
TabClass.Append((void *)new CSLib_Class2d(PClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
|
||||
BadWire=1;
|
||||
TabOrien.Append(-1);
|
||||
}
|
||||
else if(WireIsNotEmpty)
|
||||
{
|
||||
//Standard_Real anglep=0,anglem=0;
|
||||
TColgp_Array1OfPnt2d PClass(1,nbpnts);
|
||||
Standard_Real angle = 0.0, square = 0.0;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
//-- ** Le mode de calcul a ete un peu change
|
||||
//-- Avant le 31 oct 97 , on evaluait l'angle total de
|
||||
//-- rotation du wire sur tous les angles sauf le dernier
|
||||
//-- ** Maintenant , on evalue exactement l'angle de rotation
|
||||
//-- Si trouve une valeur eloignee de 2PI ou -2PI, c'est qu il
|
||||
//-- y a eu un nombre impair de boucles
|
||||
|
||||
if(nbpnts>3)
|
||||
{
|
||||
// Standard_Integer im2=nbpnts-2;
|
||||
Standard_Integer im1=nbpnts-1;
|
||||
Standard_Integer im0=1;
|
||||
// PClass(im2)=SeqPnt2d.Value(im2);
|
||||
PClass(im1)=SeqPnt2d.Value(im1);
|
||||
PClass(nbpnts)=SeqPnt2d.Value(nbpnts);
|
||||
|
||||
|
||||
// for(Standard_Integer ii=1; ii<nbpnts; ii++,im0++,im1++,im2++)
|
||||
for(Standard_Integer ii=1; ii<nbpnts; ii++,im0++,im1++)
|
||||
{
|
||||
// if(im2>=nbpnts) im2=1;
|
||||
if(im1>=nbpnts) im1=1;
|
||||
PClass(ii)=SeqPnt2d.Value(ii);
|
||||
// gp_Vec2d A(PClass(im2),PClass(im1));
|
||||
// gp_Vec2d B(PClass(im1),PClass(im0));
|
||||
// Standard_Real N = A.Magnitude() * B.Magnitude();
|
||||
|
||||
square += (PClass(im0).X()-PClass(im1).X())*(PClass(im0).Y()+PClass(im1).Y())*.5;
|
||||
|
||||
// if(N>1e-16){ Standard_Real a=A.Angle(B); angle+=a; }
|
||||
}
|
||||
|
||||
|
||||
//-- FlecheU*=10.0;
|
||||
//-- FlecheV*=10.0;
|
||||
if(FlecheU<Toluv) FlecheU = Toluv;
|
||||
if(FlecheV<Toluv) FlecheV = Toluv;
|
||||
//-- cout<<" U:"<<FlecheU<<" V:"<<FlecheV<<endl;
|
||||
TabClass.Append((void *)new CSLib_Class2d(PClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
|
||||
|
||||
// if((angle<2 && angle>-2)||(angle>10)||(angle<-10))
|
||||
// {
|
||||
// BadWire=1;
|
||||
// TabOrien.Append(-1);
|
||||
//#ifdef DEB
|
||||
// cout << endl;
|
||||
// cout << "*** BRepTopAdaptor_Fclass2d ** Wire Probablement FAUX **" << endl;
|
||||
// cout << "*** Angle de rotation cumule du wire : " << angle << endl;
|
||||
// cout << "*** On Branche l ancien classifieur" << endl;
|
||||
//#endif
|
||||
// }
|
||||
// else TabOrien.Append(((angle>0.0)? 1 : 0));
|
||||
TabOrien.Append(((square < 0.0)? 1 : 0));
|
||||
}//if(nbpoints>3
|
||||
else
|
||||
{
|
||||
#ifdef DEB
|
||||
cout << endl;
|
||||
cout << "*** BRepTopAdaptor_Fclass2d ** Wire Probablement FAUX **" << endl;
|
||||
cout << "*** Le wire echantillonne comporte moins de 3 points" << endl;
|
||||
cout << "*** On Branche l ancien classifieur" << endl;
|
||||
#endif
|
||||
BadWire=1;
|
||||
TabOrien.Append(-1);
|
||||
TColgp_Array1OfPnt2d xPClass(1,2);
|
||||
xPClass(1) = SeqPnt2d(1);
|
||||
xPClass(2) = SeqPnt2d(2);
|
||||
TabClass.Append((void *)new CSLib_Class2d(xPClass,FlecheU,FlecheV,Umin,Vmin,Umax,Vmax));
|
||||
}
|
||||
}//else if(WareIsNotEmpty
|
||||
}//for(FaceExplorer
|
||||
|
||||
Standard_Integer nbtabclass = TabClass.Length();
|
||||
|
||||
if(nbtabclass>0)
|
||||
{
|
||||
//-- Si une erreur sur un wire a ete detecte : On met tous les TabOrien a -1
|
||||
if(BadWire) TabOrien(1)=-1;
|
||||
|
||||
if( surf->GetType()==GeomAbs_Cone
|
||||
|| surf->GetType()==GeomAbs_Cylinder
|
||||
|| surf->GetType()==GeomAbs_Torus
|
||||
|| surf->GetType()==GeomAbs_Sphere
|
||||
|| surf->GetType()==GeomAbs_SurfaceOfRevolution)
|
||||
|
||||
{
|
||||
Standard_Real uuu=PI+PI-(Umax-Umin);
|
||||
if(uuu<0) uuu=0;
|
||||
U1 = 0.0; // modified by NIZHNY-OFV Thu May 31 14:24:10 2001 ---> //Umin-uuu*0.5;
|
||||
U2 = 2*PI; // modified by NIZHNY-OFV Thu May 31 14:24:35 2001 ---> //U1+PI+PI;
|
||||
}
|
||||
else { U1=U2=0.0; }
|
||||
|
||||
if(surf->GetType()==GeomAbs_Torus)
|
||||
{
|
||||
Standard_Real uuu=PI+PI-(Vmax-Vmin);
|
||||
if(uuu<0) uuu=0;
|
||||
V1 = 0.0; // modified by NIZHNY-OFV Thu May 31 14:24:55 2001 ---> //Vmin-uuu*0.5;
|
||||
V2 = 2*PI; // modified by NIZHNY-OFV Thu May 31 14:24:59 2001 ---> //V1+PI+PI;
|
||||
}
|
||||
else { V1=V2=0.0; }
|
||||
}
|
||||
}
|
||||
|
||||
TopAbs_State BRepTopAdaptor_FClass2d::PerformInfinitePoint() const {
|
||||
#if LBRCOMPT
|
||||
STAT.NbPerformInfinitePoint++;
|
||||
#endif
|
||||
|
||||
if(Umax==-RealLast() || Vmax==-RealLast() || Umin==RealLast() || Vmin==RealLast()) {
|
||||
return(TopAbs_IN);
|
||||
}
|
||||
gp_Pnt2d P(Umin-(Umax-Umin),Vmin-(Vmax-Vmin));
|
||||
return(Perform(P,Standard_False));
|
||||
}
|
||||
|
||||
TopAbs_State BRepTopAdaptor_FClass2d::Perform(const gp_Pnt2d& _Puv,
|
||||
const Standard_Boolean RecadreOnPeriodic) const
|
||||
{
|
||||
#if LBRCOMPT
|
||||
STAT.NbPerform++;
|
||||
#endif
|
||||
|
||||
Standard_Integer dedans;
|
||||
Standard_Integer nbtabclass = TabClass.Length();
|
||||
|
||||
if(nbtabclass==0) {
|
||||
return(TopAbs_IN);
|
||||
}
|
||||
|
||||
//-- U1 est le First Param et U2 ds ce cas est U1+Period
|
||||
Standard_Real u=_Puv.X();
|
||||
Standard_Real v=_Puv.Y();
|
||||
Standard_Real uu = u, vv = v;
|
||||
|
||||
Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
|
||||
surf->ChangeSurface().Initialize( Face, Standard_False );
|
||||
Standard_Boolean IsUPer, IsVPer;
|
||||
Standard_Real uperiod=0, vperiod=0;
|
||||
if ((IsUPer = surf->IsUPeriodic()))
|
||||
uperiod = surf->UPeriod();
|
||||
if ((IsVPer = surf->IsVPeriodic()))
|
||||
vperiod = surf->VPeriod();
|
||||
TopAbs_State Status = TopAbs_UNKNOWN;
|
||||
Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False;
|
||||
|
||||
if (RecadreOnPeriodic)
|
||||
{
|
||||
if (IsUPer)
|
||||
{
|
||||
if (uu < Umin)
|
||||
while (uu < Umin)
|
||||
uu += uperiod;
|
||||
else
|
||||
{
|
||||
while (uu >= Umin)
|
||||
uu -= uperiod;
|
||||
uu += uperiod;
|
||||
}
|
||||
}
|
||||
if (IsVPer)
|
||||
{
|
||||
if (vv < Vmin)
|
||||
while (vv < Vmin)
|
||||
vv += vperiod;
|
||||
else
|
||||
{
|
||||
while (vv >= Vmin)
|
||||
vv -= vperiod;
|
||||
vv += vperiod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
dedans = 1;
|
||||
gp_Pnt2d Puv(u,v);
|
||||
|
||||
if(TabOrien(1)!=-1) {
|
||||
for(Standard_Integer n=1; n<=nbtabclass; n++) {
|
||||
Standard_Integer cur = ((CSLib_Class2d *)TabClass(n))->SiDans(Puv);
|
||||
if(cur==1) {
|
||||
if(TabOrien(n)==0) {
|
||||
dedans = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(cur==-1) {
|
||||
if(TabOrien(n)==1) {
|
||||
dedans = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dedans = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(dedans==0) {
|
||||
BRepClass_FaceClassifier aClassifier;
|
||||
Standard_Real m_Toluv = (Toluv > 4.0) ? 4.0 : Toluv;
|
||||
//aClassifier.Perform(Face,Puv,Toluv);
|
||||
aClassifier.Perform(Face,Puv,m_Toluv);
|
||||
Status = aClassifier.State();
|
||||
}
|
||||
if(dedans == 1) {
|
||||
Status = TopAbs_IN;
|
||||
}
|
||||
if(dedans == -1) {
|
||||
Status = TopAbs_OUT;
|
||||
}
|
||||
}
|
||||
else { //-- TabOrien(1)=-1 Wire Faux
|
||||
BRepClass_FaceClassifier aClassifier;
|
||||
aClassifier.Perform(Face,Puv,Toluv);
|
||||
Status = aClassifier.State();
|
||||
}
|
||||
|
||||
if (!RecadreOnPeriodic || !IsUPer && !IsVPer)
|
||||
return Status;
|
||||
if (Status == TopAbs_IN || Status == TopAbs_ON)
|
||||
return Status;
|
||||
|
||||
if (!urecadre)
|
||||
{
|
||||
u = uu;
|
||||
urecadre = Standard_True;
|
||||
}
|
||||
else
|
||||
if (IsUPer)
|
||||
u += uperiod;
|
||||
if (u > Umax || !IsUPer)
|
||||
{
|
||||
if (!vrecadre)
|
||||
{
|
||||
v = vv;
|
||||
vrecadre = Standard_True;
|
||||
}
|
||||
else
|
||||
if (IsVPer)
|
||||
v += vperiod;
|
||||
|
||||
u = uu;
|
||||
|
||||
if (v > Vmax || !IsVPer)
|
||||
return Status;
|
||||
}
|
||||
} //for (;;)
|
||||
}
|
||||
|
||||
TopAbs_State BRepTopAdaptor_FClass2d::TestOnRestriction(const gp_Pnt2d& _Puv,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean RecadreOnPeriodic) const
|
||||
{
|
||||
#if LBRCOMPT
|
||||
STAT.NbConstrShape++;
|
||||
#endif
|
||||
|
||||
Standard_Integer dedans;
|
||||
Standard_Integer nbtabclass = TabClass.Length();
|
||||
|
||||
if(nbtabclass==0) {
|
||||
return(TopAbs_IN);
|
||||
}
|
||||
|
||||
//-- U1 est le First Param et U2 ds ce cas est U1+Period
|
||||
Standard_Real u=_Puv.X();
|
||||
Standard_Real v=_Puv.Y();
|
||||
Standard_Real uu = u, vv = v;
|
||||
|
||||
Handle(BRepAdaptor_HSurface) surf = new BRepAdaptor_HSurface();
|
||||
surf->ChangeSurface().Initialize( Face, Standard_False );
|
||||
Standard_Boolean IsUPer, IsVPer;
|
||||
Standard_Real uperiod=0, vperiod=0;
|
||||
if ((IsUPer = surf->IsUPeriodic()))
|
||||
uperiod = surf->UPeriod();
|
||||
if ((IsVPer = surf->IsVPeriodic()))
|
||||
vperiod = surf->VPeriod();
|
||||
TopAbs_State Status = TopAbs_UNKNOWN;
|
||||
Standard_Boolean urecadre = Standard_False, vrecadre = Standard_False;
|
||||
|
||||
if (RecadreOnPeriodic)
|
||||
{
|
||||
if (IsUPer)
|
||||
{
|
||||
if (uu < Umin)
|
||||
while (uu < Umin)
|
||||
uu += uperiod;
|
||||
else
|
||||
{
|
||||
while (uu >= Umin)
|
||||
uu -= uperiod;
|
||||
uu += uperiod;
|
||||
}
|
||||
}
|
||||
if (IsVPer)
|
||||
{
|
||||
if (vv < Vmin)
|
||||
while (vv < Vmin)
|
||||
vv += vperiod;
|
||||
else
|
||||
{
|
||||
while (vv >= Vmin)
|
||||
vv -= vperiod;
|
||||
vv += vperiod;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
dedans = 1;
|
||||
gp_Pnt2d Puv(u,v);
|
||||
|
||||
if(TabOrien(1)!=-1) {
|
||||
for(Standard_Integer n=1; n<=nbtabclass; n++) {
|
||||
Standard_Integer cur = ((CSLib_Class2d *)TabClass(n))->SiDans_OnMode(Puv,Tol);
|
||||
if(cur==1) {
|
||||
if(TabOrien(n)==0) {
|
||||
dedans = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(cur==-1) {
|
||||
if(TabOrien(n)==1) {
|
||||
dedans = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dedans = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(dedans==0) {
|
||||
Status = TopAbs_ON;
|
||||
}
|
||||
if(dedans == 1) {
|
||||
Status = TopAbs_IN;
|
||||
}
|
||||
if(dedans == -1) {
|
||||
Status = TopAbs_OUT;
|
||||
}
|
||||
}
|
||||
else { //-- TabOrien(1)=-1 Wire Faux
|
||||
BRepClass_FaceClassifier aClassifier;
|
||||
aClassifier.Perform(Face,Puv,Tol);
|
||||
Status = aClassifier.State();
|
||||
}
|
||||
|
||||
if (!RecadreOnPeriodic || !IsUPer && !IsVPer)
|
||||
return Status;
|
||||
if (Status == TopAbs_IN || Status == TopAbs_ON)
|
||||
return Status;
|
||||
|
||||
if (!urecadre)
|
||||
{
|
||||
u = uu;
|
||||
urecadre = Standard_True;
|
||||
}
|
||||
else
|
||||
if (IsUPer)
|
||||
u += uperiod;
|
||||
if (u > Umax || !IsUPer)
|
||||
{
|
||||
if (!vrecadre)
|
||||
{
|
||||
v = vv;
|
||||
vrecadre = Standard_True;
|
||||
}
|
||||
else
|
||||
if (IsVPer)
|
||||
v += vperiod;
|
||||
|
||||
u = uu;
|
||||
|
||||
if (v > Vmax || !IsVPer)
|
||||
return Status;
|
||||
}
|
||||
} //for (;;)
|
||||
}
|
||||
|
||||
|
||||
void BRepTopAdaptor_FClass2d::Destroy() {
|
||||
#if LBRCOMPT
|
||||
STAT.NbDestroy++;
|
||||
#endif
|
||||
|
||||
Standard_Integer nbtabclass = TabClass.Length();
|
||||
for(Standard_Integer d=1; d<=nbtabclass;d++) {
|
||||
if(TabClass(d)) {
|
||||
delete ((CSLib_Class2d *)TabClass(d));
|
||||
TabClass(d)=NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
|
||||
|
||||
//const BRepTopAdaptor_FClass2d & BRepTopAdaptor_FClass2d::Copy(const BRepTopAdaptor_FClass2d& Other) const {
|
||||
const BRepTopAdaptor_FClass2d & BRepTopAdaptor_FClass2d::Copy(const BRepTopAdaptor_FClass2d& ) const {
|
||||
cerr<<"Copy not allowed in BRepTopAdaptor_FClass2d"<<endl;
|
||||
Standard_ConstructionError::Raise();
|
||||
return(*this);
|
||||
}
|
81
src/BRepTopAdaptor/BRepTopAdaptor_HVertex.cdl
Executable file
81
src/BRepTopAdaptor/BRepTopAdaptor_HVertex.cdl
Executable file
@@ -0,0 +1,81 @@
|
||||
-- File: BRepTopAdaptor_HVertex.cdl
|
||||
-- Created: Fri Apr 1 10:59:45 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@nonox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class HVertex from BRepTopAdaptor
|
||||
|
||||
---Purpose:
|
||||
|
||||
|
||||
inherits HVertex from Adaptor3d
|
||||
|
||||
uses Pnt2d from gp,
|
||||
Orientation from TopAbs,
|
||||
Vertex from TopoDS,
|
||||
HCurve2d from Adaptor2d,
|
||||
HCurve2d from BRepAdaptor
|
||||
|
||||
is
|
||||
|
||||
Create(Vtx: Vertex from TopoDS; Curve: HCurve2d from BRepAdaptor)
|
||||
|
||||
returns mutable HVertex from BRepTopAdaptor;
|
||||
|
||||
|
||||
Vertex(me)
|
||||
|
||||
returns Vertex from TopoDS
|
||||
---C++: inline
|
||||
---C++: return const&
|
||||
is static;
|
||||
|
||||
|
||||
ChangeVertex(me: mutable)
|
||||
|
||||
returns Vertex from TopoDS
|
||||
---C++: inline
|
||||
---C++: return&
|
||||
is static;
|
||||
|
||||
|
||||
Value(me: mutable)
|
||||
|
||||
returns Pnt2d from gp
|
||||
is redefined;
|
||||
|
||||
|
||||
Parameter(me: mutable; C: HCurve2d from Adaptor2d)
|
||||
|
||||
returns Real from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Resolution(me: mutable; C: HCurve2d from Adaptor2d)
|
||||
|
||||
---Purpose: Parametric resolution (2d).
|
||||
|
||||
returns Real from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Orientation(me: mutable)
|
||||
|
||||
returns Orientation from TopAbs
|
||||
is redefined;
|
||||
|
||||
|
||||
IsSame(me: mutable; Other: mutable like me)
|
||||
|
||||
returns Boolean from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
fields -- redefined from HVertex from Adaptor3d
|
||||
|
||||
myVtx : Vertex from TopoDS;
|
||||
myCurve : HCurve2d from BRepAdaptor;
|
||||
|
||||
end HVertex;
|
140
src/BRepTopAdaptor/BRepTopAdaptor_HVertex.cxx
Executable file
140
src/BRepTopAdaptor/BRepTopAdaptor_HVertex.cxx
Executable file
@@ -0,0 +1,140 @@
|
||||
#include <BRepTopAdaptor_HVertex.ixx>
|
||||
|
||||
#include <BRepAdaptor_HCurve2d.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
#include <gp_Vec2d.hxx>
|
||||
|
||||
|
||||
BRepTopAdaptor_HVertex::BRepTopAdaptor_HVertex
|
||||
(const TopoDS_Vertex& V,
|
||||
const Handle(BRepAdaptor_HCurve2d)& C):
|
||||
myVtx(V),myCurve(C)
|
||||
{}
|
||||
|
||||
gp_Pnt2d BRepTopAdaptor_HVertex::Value ()
|
||||
{
|
||||
// return myCurve->Value(Parameter(myCurve));
|
||||
return gp_Pnt2d(RealFirst(),RealFirst()); // rien a faire
|
||||
}
|
||||
|
||||
Standard_Real BRepTopAdaptor_HVertex::Parameter
|
||||
(const Handle(Adaptor2d_HCurve2d)& C)
|
||||
{
|
||||
Handle(BRepAdaptor_HCurve2d) brhc =
|
||||
Handle(BRepAdaptor_HCurve2d)::DownCast(C);
|
||||
return BRep_Tool::Parameter(myVtx,
|
||||
((BRepAdaptor_Curve2d *)&(brhc->Curve2d()))->Edge(),
|
||||
((BRepAdaptor_Curve2d *)&(brhc->Curve2d()))->Face());
|
||||
}
|
||||
|
||||
|
||||
Standard_Real BRepTopAdaptor_HVertex::Resolution
|
||||
(const Handle(Adaptor2d_HCurve2d)& C)
|
||||
{
|
||||
Handle(BRepAdaptor_HCurve2d) brhc =
|
||||
Handle(BRepAdaptor_HCurve2d)::DownCast(C);
|
||||
const TopoDS_Face& F = ((BRepAdaptor_Curve2d *)&(brhc->Curve2d()))->Face();
|
||||
BRepAdaptor_Surface S(F,0);
|
||||
Standard_Real tv = BRep_Tool::Tolerance(myVtx);
|
||||
Standard_Real pp, p = BRep_Tool::Parameter
|
||||
(myVtx,
|
||||
((BRepAdaptor_Curve2d *)&(brhc->Curve2d()))->Edge(),
|
||||
((BRepAdaptor_Curve2d *)&(brhc->Curve2d()))->Face());
|
||||
TopAbs_Orientation Or = Orientation();
|
||||
gp_Pnt2d p2d; gp_Vec2d v2d;
|
||||
C->D1(p,p2d,v2d);
|
||||
gp_Pnt P, P1;
|
||||
gp_Vec DU, DV, DC;
|
||||
S.D1(p2d.X(),p2d.Y(),P,DU,DV);
|
||||
DC.SetLinearForm(v2d.X(),DU,v2d.Y(),DV);
|
||||
Standard_Real ResUV, mag = DC.Magnitude();
|
||||
|
||||
Standard_Real URes = S.UResolution(tv);
|
||||
Standard_Real VRes = S.VResolution(tv);
|
||||
Standard_Real tURes = C->Resolution(URes);
|
||||
Standard_Real tVRes = C->Resolution(VRes);
|
||||
Standard_Real ResUV1 = Max(tURes, tVRes);
|
||||
|
||||
if(mag<1e-12) {
|
||||
|
||||
return(ResUV1);
|
||||
|
||||
}
|
||||
|
||||
// a defaut de mieux on borne la resolution parametrique a
|
||||
// 10 million*la tolerance du point
|
||||
|
||||
if(tv > 1.e7*mag) ResUV = 1.e7;
|
||||
else ResUV = tv/mag;
|
||||
|
||||
// Controle
|
||||
if (Or == TopAbs_REVERSED) pp = p+ResUV;
|
||||
else pp = p-ResUV;
|
||||
|
||||
Standard_Real UMin=C->FirstParameter();
|
||||
Standard_Real UMax=C->LastParameter();
|
||||
if(pp>UMax) pp=UMax;
|
||||
if(pp<UMin) pp=UMin;
|
||||
|
||||
C->D0(pp, p2d);
|
||||
S.D0(p2d.X(),p2d.Y(),P1);
|
||||
|
||||
Standard_Real Dist=P.Distance(P1);
|
||||
if ((Dist>1e-12) && ((Dist > 1.1*tv) || (Dist< 0.8*tv))) {
|
||||
// Raffinement si possible
|
||||
Standard_Real Dist1;
|
||||
if (Or == TopAbs_REVERSED) pp = p+tv/Dist;
|
||||
else pp = p-tv/Dist;
|
||||
|
||||
if(pp>UMax) pp=UMax;
|
||||
if(pp<UMin) pp=UMin;
|
||||
|
||||
C->D1(pp, p2d, v2d);
|
||||
S.D1(p2d.X(),p2d.Y(),P1,DU,DV);
|
||||
DC.SetLinearForm(v2d.X(),DU,v2d.Y(),DV);
|
||||
Dist1 = P.Distance(P1);
|
||||
if (Abs(Dist1-tv) < Abs(Dist-tv)) {
|
||||
// On prend le resultat d'interpolation
|
||||
ResUV = tv/Dist;
|
||||
Dist = Dist1;
|
||||
}
|
||||
|
||||
mag = DC.Magnitude();
|
||||
if(tv > 1.e7*mag) mag = tv*1.e-7;
|
||||
if (Or == TopAbs_REVERSED) pp = p+tv/mag;
|
||||
else pp = p-tv/mag;
|
||||
|
||||
if(pp>UMax) pp=UMax;
|
||||
if(pp<UMin) pp=UMin;
|
||||
|
||||
C->D0(pp, p2d);
|
||||
S.D0(p2d.X(),p2d.Y(),P1);
|
||||
Dist1 = P.Distance(P1);
|
||||
if (Abs(Dist1-tv) < Abs(Dist-tv)) {
|
||||
// On prend la nouvelle estimation
|
||||
ResUV = tv/mag;
|
||||
Dist = Dist1;
|
||||
}
|
||||
}
|
||||
|
||||
return Min(ResUV, ResUV1);
|
||||
}
|
||||
|
||||
|
||||
TopAbs_Orientation BRepTopAdaptor_HVertex::Orientation ()
|
||||
{
|
||||
return myVtx.Orientation();
|
||||
}
|
||||
|
||||
Standard_Boolean BRepTopAdaptor_HVertex::IsSame
|
||||
(const Handle(Adaptor3d_HVertex)& Other)
|
||||
{
|
||||
Handle(BRepTopAdaptor_HVertex) brhv =
|
||||
Handle(BRepTopAdaptor_HVertex)::DownCast(Other);
|
||||
return myVtx.IsSame(brhv->Vertex());
|
||||
}
|
||||
|
10
src/BRepTopAdaptor/BRepTopAdaptor_HVertex.lxx
Executable file
10
src/BRepTopAdaptor/BRepTopAdaptor_HVertex.lxx
Executable file
@@ -0,0 +1,10 @@
|
||||
inline const TopoDS_Vertex& BRepTopAdaptor_HVertex::Vertex () const
|
||||
{
|
||||
return myVtx;
|
||||
}
|
||||
|
||||
inline TopoDS_Vertex& BRepTopAdaptor_HVertex::ChangeVertex ()
|
||||
{
|
||||
return myVtx;
|
||||
}
|
||||
|
62
src/BRepTopAdaptor/BRepTopAdaptor_Tool.cdl
Executable file
62
src/BRepTopAdaptor/BRepTopAdaptor_Tool.cdl
Executable file
@@ -0,0 +1,62 @@
|
||||
-- File: BRepTopAdaptor_Tool.cdl
|
||||
-- Created: Tue Oct 7 09:42:43 1997
|
||||
-- Author: Laurent BUCHARD
|
||||
-- <lbr@cracbox.paris1.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 1997
|
||||
|
||||
|
||||
|
||||
class Tool from BRepTopAdaptor
|
||||
|
||||
uses
|
||||
Face from TopoDS,
|
||||
TopolTool from BRepTopAdaptor,
|
||||
HSurface from Adaptor3d
|
||||
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns Tool from BRepTopAdaptor;
|
||||
|
||||
Create(F : Face from TopoDS;
|
||||
Tol2d : Real from Standard)
|
||||
returns Tool from BRepTopAdaptor;
|
||||
|
||||
Create(Surface: HSurface from Adaptor3d;
|
||||
Tol2d : Real from Standard)
|
||||
returns Tool from BRepTopAdaptor;
|
||||
|
||||
|
||||
Init(me : in out;
|
||||
F : Face from TopoDS;
|
||||
Tol2d : Real from Standard);
|
||||
|
||||
Init(me : in out;
|
||||
Surface: HSurface from Adaptor3d;
|
||||
Tol2d : Real from Standard);
|
||||
|
||||
----
|
||||
|
||||
GetTopolTool(me: in out)
|
||||
returns mutable TopolTool from BRepTopAdaptor;
|
||||
|
||||
SetTopolTool(me: in out ;
|
||||
TT: TopolTool from BRepTopAdaptor);
|
||||
|
||||
GetSurface(me: in out)
|
||||
returns mutable HSurface from Adaptor3d;
|
||||
|
||||
|
||||
---
|
||||
|
||||
Destroy(me: in out) ;
|
||||
---C++: alias ~
|
||||
|
||||
fields
|
||||
|
||||
myloaded : Boolean from Standard;
|
||||
myTopolTool : TopolTool from BRepTopAdaptor;
|
||||
myHSurface : HSurface from Adaptor3d;
|
||||
|
||||
end Tool;
|
86
src/BRepTopAdaptor/BRepTopAdaptor_Tool.cxx
Executable file
86
src/BRepTopAdaptor/BRepTopAdaptor_Tool.cxx
Executable file
@@ -0,0 +1,86 @@
|
||||
// File: BRepTopAdaptor_Tool.cxx
|
||||
// Created: Tue Oct 7 10:01:50 1997
|
||||
// Author: Laurent BUCHARD
|
||||
// <lbr@cracbox.paris1.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <BRepTopAdaptor_Tool.ixx>
|
||||
|
||||
#include <BRepTopAdaptor_TopolTool.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
#include <Adaptor3d_HSurface.hxx>
|
||||
|
||||
|
||||
BRepTopAdaptor_Tool::BRepTopAdaptor_Tool() {
|
||||
myTopolTool = new BRepTopAdaptor_TopolTool();
|
||||
|
||||
myloaded=Standard_False;
|
||||
}
|
||||
|
||||
BRepTopAdaptor_Tool::BRepTopAdaptor_Tool(const TopoDS_Face& F,
|
||||
const Standard_Real Tol2d) {
|
||||
myTopolTool = new BRepTopAdaptor_TopolTool();
|
||||
|
||||
Handle(BRepAdaptor_HSurface) surface = new BRepAdaptor_HSurface();
|
||||
surface->ChangeSurface().Initialize(F,Standard_True);
|
||||
myTopolTool->Initialize(surface);
|
||||
myHSurface = surface;
|
||||
myloaded=Standard_True;
|
||||
}
|
||||
|
||||
BRepTopAdaptor_Tool::BRepTopAdaptor_Tool(const Handle(Adaptor3d_HSurface)& surface,
|
||||
const Standard_Real Tol2d) {
|
||||
myTopolTool = new BRepTopAdaptor_TopolTool();
|
||||
|
||||
myTopolTool->Initialize(surface);
|
||||
myHSurface = surface;
|
||||
myloaded=Standard_True;
|
||||
}
|
||||
|
||||
void BRepTopAdaptor_Tool::Init(const TopoDS_Face& F,
|
||||
const Standard_Real Tol2d) {
|
||||
Handle(BRepAdaptor_HSurface) surface = new BRepAdaptor_HSurface();
|
||||
surface->ChangeSurface().Initialize(F);
|
||||
myTopolTool->Initialize(surface);
|
||||
myHSurface = surface;
|
||||
myloaded=Standard_True;
|
||||
}
|
||||
|
||||
void BRepTopAdaptor_Tool::Init(const Handle(Adaptor3d_HSurface)& surface,
|
||||
const Standard_Real Tol2d) {
|
||||
myTopolTool->Initialize(surface);
|
||||
myHSurface = surface;
|
||||
myloaded=Standard_True;
|
||||
}
|
||||
|
||||
Handle_BRepTopAdaptor_TopolTool BRepTopAdaptor_Tool::GetTopolTool() {
|
||||
if(myloaded) {
|
||||
return(myTopolTool);
|
||||
}
|
||||
else {
|
||||
cout<<"\n*** Error ds Handle_BRepTopAdaptor_TopolTool BRepTopAdaptor_Tool::GetTopolTool()\n"<<endl;
|
||||
return(myTopolTool);
|
||||
}
|
||||
}
|
||||
|
||||
Handle_Adaptor3d_HSurface BRepTopAdaptor_Tool::GetSurface() {
|
||||
if(myloaded) {
|
||||
return(myHSurface);
|
||||
}
|
||||
else {
|
||||
cout<<"\n*** Error ds Handle_BRepTopAdaptor_TopolTool BRepTopAdaptor_Tool::GetSurface()\n"<<endl;
|
||||
return(myHSurface);
|
||||
}
|
||||
}
|
||||
|
||||
void BRepTopAdaptor_Tool::SetTopolTool(const Handle(BRepTopAdaptor_TopolTool)& TT) {
|
||||
myTopolTool=TT;
|
||||
}
|
||||
|
||||
void BRepTopAdaptor_Tool::Destroy() {
|
||||
int i;
|
||||
i=0;
|
||||
i++;
|
||||
|
||||
}
|
||||
|
230
src/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cdl
Executable file
230
src/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cdl
Executable file
@@ -0,0 +1,230 @@
|
||||
-- File: BRepTopAdaptor_TopolTool.cdl
|
||||
-- Created: Fri Apr 1 11:01:17 1994
|
||||
-- Author: Modelistation
|
||||
-- <model@nonox>
|
||||
---Copyright: Matra Datavision 1994
|
||||
|
||||
|
||||
class TopolTool from BRepTopAdaptor
|
||||
|
||||
|
||||
inherits TopolTool from Adaptor3d
|
||||
|
||||
uses HSurface from Adaptor3d,
|
||||
HCurve2d from Adaptor2d,
|
||||
HCurve2d from BRepAdaptor,
|
||||
HVertex from Adaptor3d,
|
||||
Pnt2d from gp,
|
||||
Pnt from gp,
|
||||
State from TopAbs,
|
||||
Orientation from TopAbs,
|
||||
Explorer from TopExp,
|
||||
Face from TopoDS,
|
||||
FClass2d from BRepTopAdaptor,
|
||||
ListOfTransient from TColStd,
|
||||
ListIteratorOfListOfTransient from TColStd
|
||||
|
||||
raises DomainError from Standard
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
|
||||
returns mutable TopolTool from BRepTopAdaptor;
|
||||
|
||||
|
||||
Create(Surface: HSurface from Adaptor3d)
|
||||
|
||||
returns mutable TopolTool from BRepTopAdaptor;
|
||||
|
||||
Initialize(me: mutable)
|
||||
is redefined;
|
||||
|
||||
|
||||
Initialize(me: mutable; S: HSurface from Adaptor3d)
|
||||
is redefined;
|
||||
|
||||
|
||||
Initialize(me: mutable; Curve: HCurve2d from Adaptor2d)
|
||||
is redefined;
|
||||
|
||||
|
||||
|
||||
--- Arc iterator
|
||||
|
||||
|
||||
Init(me: mutable)
|
||||
is redefined;
|
||||
|
||||
|
||||
More(me: mutable)
|
||||
|
||||
returns Boolean from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Value(me: mutable)
|
||||
|
||||
returns mutable HCurve2d from Adaptor2d
|
||||
raises DomainError from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Next(me: mutable)
|
||||
is redefined;
|
||||
|
||||
|
||||
--modified by NIZNHY-PKV Wed Mar 21 11:37:11 2001 f
|
||||
Edge (me)
|
||||
returns Address from Standard
|
||||
is redefined;
|
||||
--modified by NIZNHY-PKV Wed Mar 21 11:37:17 2001 t
|
||||
|
||||
--- Vertex iterator
|
||||
|
||||
|
||||
InitVertexIterator(me: mutable)
|
||||
is redefined;
|
||||
|
||||
|
||||
MoreVertex(me: mutable)
|
||||
|
||||
returns Boolean from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Vertex(me: mutable)
|
||||
|
||||
returns mutable HVertex from Adaptor3d
|
||||
raises DomainError from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
NextVertex(me: mutable)
|
||||
is redefined;
|
||||
|
||||
|
||||
|
||||
Classify(me: mutable; P2d: Pnt2d from gp;
|
||||
Tol: Real from Standard;
|
||||
RecadreOnPeriodic : Boolean from Standard = Standard_True)
|
||||
|
||||
|
||||
returns State from TopAbs
|
||||
is redefined;
|
||||
|
||||
|
||||
IsThePointOn(me: mutable; P2d: Pnt2d from gp;
|
||||
Tol: Real from Standard;
|
||||
RecadreOnPeriodic : Boolean from Standard = Standard_True)
|
||||
---Purpose (caution: see the code for specifications)
|
||||
returns Boolean from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Orientation(me: mutable; C: HCurve2d from Adaptor2d)
|
||||
|
||||
---Purpose: If the function returns the orientation of the arc.
|
||||
-- If the orientation is FORWARD or REVERSED, the arc is
|
||||
-- a "real" limit of the surface.
|
||||
-- If the orientation is INTERNAL or EXTERNAL, the arc is
|
||||
-- considered as an arc on the surface.
|
||||
|
||||
returns Orientation from TopAbs
|
||||
is redefined;
|
||||
|
||||
Orientation(me: mutable; C: HVertex from Adaptor3d)
|
||||
|
||||
---Purpose: If the function returns the orientation of the arc.
|
||||
-- If the orientation is FORWARD or REVERSED, the arc is
|
||||
-- a "real" limit of the surface.
|
||||
-- If the orientation is INTERNAL or EXTERNAL, the arc is
|
||||
-- considered as an arc on the surface.
|
||||
|
||||
returns Orientation from TopAbs
|
||||
is redefined;
|
||||
|
||||
Destroy(me: mutable);
|
||||
---C++: alias ~
|
||||
|
||||
|
||||
Has3d(me)
|
||||
---Purpose: answers if arcs and vertices may have 3d representations,
|
||||
-- so that we could use Tol3d and Pnt methods.
|
||||
returns Boolean from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Tol3d(me; C: HCurve2d from Adaptor2d)
|
||||
---Purpose: returns 3d tolerance of the arc C
|
||||
returns Real from Standard
|
||||
raises DomainError from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Tol3d(me; V: HVertex from Adaptor3d)
|
||||
---Purpose: returns 3d tolerance of the vertex V
|
||||
returns Real from Standard
|
||||
raises DomainError from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
Pnt(me; V: HVertex from Adaptor3d)
|
||||
---Purpose: returns 3d point of the vertex V
|
||||
returns Pnt from gp
|
||||
raises DomainError from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
--- samples tools
|
||||
|
||||
ComputeSamplePoints(me: mutable)
|
||||
is redefined;
|
||||
|
||||
|
||||
NbSamplesU(me: mutable)
|
||||
---Purpose: compute the sample-points for the intersections algorithms
|
||||
returns Integer from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
NbSamplesV(me: mutable)
|
||||
---Purpose: compute the sample-points for the intersections algorithms
|
||||
returns Integer from Standard
|
||||
is redefined;
|
||||
|
||||
NbSamples(me: mutable)
|
||||
---Purpose: compute the sample-points for the intersections algorithms
|
||||
returns Integer from Standard
|
||||
is redefined;
|
||||
|
||||
SamplePoint(me: mutable; Index: Integer from Standard;
|
||||
P2d : out Pnt2d from gp;
|
||||
P3d : out Pnt from gp)
|
||||
is redefined;
|
||||
|
||||
DomainIsInfinite(me: mutable)
|
||||
returns Boolean from Standard
|
||||
is redefined;
|
||||
|
||||
|
||||
fields -- redefined from TopolTool from Adaptor3d
|
||||
|
||||
myVIterator : Explorer from TopExp;
|
||||
myFace : Face from TopoDS;
|
||||
myFClass2d : Address from Standard;
|
||||
myCurve : HCurve2d from BRepAdaptor;
|
||||
-- MSV: replace myEIterator by myCIterator to return the same HCurve2d
|
||||
-- for the same edge each time the user calls Value()
|
||||
myCurves : ListOfTransient from TColStd;
|
||||
myCIterator : ListIteratorOfListOfTransient from TColStd;
|
||||
|
||||
--myS : HSurface from Adaptor3d; now inherits myS from Adaptor3d_TopolTool
|
||||
myU0 : Real from Standard;
|
||||
myV0 : Real from Standard;
|
||||
myDU : Real from Standard;
|
||||
myDV : Real from Standard;
|
||||
--myNbSamplesU: Integer from Standard; now inherits myS from Adaptor3d_TopolTool
|
||||
--myNbSamplesV: Integer from Standard; now inherits myS from Adaptor3d_TopolTool
|
||||
|
||||
end TopolTool;
|
528
src/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cxx
Executable file
528
src/BRepTopAdaptor/BRepTopAdaptor_TopolTool.cxx
Executable file
@@ -0,0 +1,528 @@
|
||||
|
||||
#include <Standard_NotImplemented.hxx>
|
||||
|
||||
#include <BRepTopAdaptor_TopolTool.ixx>
|
||||
|
||||
#include <Standard_ConstructionError.hxx>
|
||||
#include <Standard_DomainError.hxx>
|
||||
#include <BRepAdaptor_HSurface.hxx>
|
||||
#include <BRepAdaptor_HCurve2d.hxx>
|
||||
#include <BRepTopAdaptor_HVertex.hxx>
|
||||
#include <BRepClass_FaceClassifier.hxx>
|
||||
#include <BRepClass_FaceExplorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <BRepTopAdaptor_FClass2d.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <TColgp_Array2OfPnt.hxx>
|
||||
#include <Geom_BezierSurface.hxx>
|
||||
#include <Geom_BSplineSurface.hxx>
|
||||
|
||||
static
|
||||
void Analyse(const TColgp_Array2OfPnt& array2,
|
||||
const Standard_Integer nbup,
|
||||
const Standard_Integer nbvp,
|
||||
Standard_Integer& myNbSamplesU,
|
||||
Standard_Integer& myNbSamplesV);
|
||||
//=======================================================================
|
||||
//function : BRepTopAdaptor_TopolTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepTopAdaptor_TopolTool::BRepTopAdaptor_TopolTool () : myFClass2d(NULL)
|
||||
{
|
||||
myNbSamplesU=-1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BRepTopAdaptor_TopolTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BRepTopAdaptor_TopolTool::BRepTopAdaptor_TopolTool(const Handle(Adaptor3d_HSurface)& S)
|
||||
: myFClass2d(NULL)
|
||||
{
|
||||
Initialize(S);
|
||||
//myS = S;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::Initialize()
|
||||
{
|
||||
Standard_NotImplemented::Raise("BRepTopAdaptor_TopolTool::Initialize()");
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::Initialize(const Handle(Adaptor3d_HSurface)& S)
|
||||
{
|
||||
Handle(BRepAdaptor_HSurface) brhs =
|
||||
Handle(BRepAdaptor_HSurface)::DownCast(S);
|
||||
if (brhs.IsNull()) {Standard_ConstructionError::Raise();}
|
||||
TopoDS_Shape s_wnt = ((BRepAdaptor_Surface *)&(brhs->Surface()))->Face();
|
||||
s_wnt.Orientation(TopAbs_FORWARD);
|
||||
myFace = TopoDS::Face(s_wnt);
|
||||
if(myFClass2d != NULL) {
|
||||
delete (BRepTopAdaptor_FClass2d *)myFClass2d;
|
||||
}
|
||||
myFClass2d = NULL;
|
||||
myNbSamplesU=-1;
|
||||
myS = S;
|
||||
myCurves.Clear();
|
||||
TopExp_Explorer ex(myFace,TopAbs_EDGE);
|
||||
for (; ex.More(); ex.Next()) {
|
||||
Handle(BRepAdaptor_HCurve2d) aCurve = new BRepAdaptor_HCurve2d
|
||||
(BRepAdaptor_Curve2d(TopoDS::Edge(ex.Current()),myFace));
|
||||
myCurves.Append(aCurve);
|
||||
}
|
||||
myCIterator = TColStd_ListIteratorOfListOfTransient();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Initialize
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::Initialize(const Handle(Adaptor2d_HCurve2d)& C)
|
||||
{
|
||||
myCurve = Handle(BRepAdaptor_HCurve2d)::DownCast(C);
|
||||
if (myCurve.IsNull()) {Standard_ConstructionError::Raise();}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::Init ()
|
||||
{
|
||||
myCIterator.Initialize(myCurves);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : More
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTopAdaptor_TopolTool::More ()
|
||||
{
|
||||
return myCIterator.More();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Next
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::Next()
|
||||
{
|
||||
myCIterator.Next();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Value
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Adaptor2d_HCurve2d) BRepTopAdaptor_TopolTool::Value ()
|
||||
{
|
||||
return Handle(Adaptor2d_HCurve2d)::DownCast(myCIterator.Value());
|
||||
}
|
||||
//modified by NIZNHY-PKV Tue Mar 27 14:23:40 2001 f
|
||||
//=======================================================================
|
||||
//function : Edge
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Address BRepTopAdaptor_TopolTool::Edge () const
|
||||
{
|
||||
Handle(BRepAdaptor_HCurve2d) aHCurve =
|
||||
Handle(BRepAdaptor_HCurve2d)::DownCast(myCIterator.Value());
|
||||
const BRepAdaptor_Curve2d& aCurve = (const BRepAdaptor_Curve2d&)aHCurve->Curve2d();
|
||||
return Standard_Address (& aCurve.Edge());
|
||||
}
|
||||
|
||||
//modified by NIZNHY-PKV Tue Mar 27 14:23:43 2001 t
|
||||
//=======================================================================
|
||||
//function : InitVertexIterator
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::InitVertexIterator ()
|
||||
{
|
||||
myVIterator.Init(((BRepAdaptor_Curve2d *)&(myCurve->Curve2d()))->Edge(),TopAbs_VERTEX);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NextVertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTopAdaptor_TopolTool::MoreVertex ()
|
||||
{
|
||||
return myVIterator.More();
|
||||
}
|
||||
|
||||
void BRepTopAdaptor_TopolTool::NextVertex ()
|
||||
{
|
||||
myVIterator.Next();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Vertex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Adaptor3d_HVertex) BRepTopAdaptor_TopolTool::Vertex ()
|
||||
{
|
||||
return new
|
||||
BRepTopAdaptor_HVertex(TopoDS::Vertex(myVIterator.Current()),myCurve);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Classify
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TopAbs_State BRepTopAdaptor_TopolTool::Classify(const gp_Pnt2d& P,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean RecadreOnPeriodic)
|
||||
{
|
||||
if(myFClass2d == NULL) {
|
||||
myFClass2d = (void *) new BRepTopAdaptor_FClass2d(myFace,Tol);
|
||||
}
|
||||
return(((BRepTopAdaptor_FClass2d *)myFClass2d)->Perform(P,RecadreOnPeriodic));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsThePointOn
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTopAdaptor_TopolTool::IsThePointOn(const gp_Pnt2d& P,
|
||||
const Standard_Real Tol,
|
||||
const Standard_Boolean RecadreOnPeriodic)
|
||||
{
|
||||
if(myFClass2d == NULL) {
|
||||
myFClass2d = (void *) new BRepTopAdaptor_FClass2d(myFace,Tol);
|
||||
}
|
||||
return(TopAbs_ON==((BRepTopAdaptor_FClass2d *)myFClass2d)->TestOnRestriction(P,Tol,RecadreOnPeriodic));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Destroy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::Destroy()
|
||||
{
|
||||
if(myFClass2d != NULL) {
|
||||
delete (BRepTopAdaptor_FClass2d *)myFClass2d;
|
||||
myFClass2d=NULL;
|
||||
}
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Orientation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TopAbs_Orientation BRepTopAdaptor_TopolTool::Orientation (const Handle(Adaptor2d_HCurve2d)& C)
|
||||
{
|
||||
Handle(BRepAdaptor_HCurve2d) brhc =
|
||||
Handle(BRepAdaptor_HCurve2d)::DownCast(C);
|
||||
return ((BRepAdaptor_Curve2d *)&(brhc->Curve2d()))->Edge().Orientation();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : Orientation
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TopAbs_Orientation BRepTopAdaptor_TopolTool::Orientation (const Handle(Adaptor3d_HVertex)& C)
|
||||
{
|
||||
return Adaptor3d_TopolTool::Orientation(C);
|
||||
}
|
||||
//-- ============================================================
|
||||
//-- m e t h o d e s u t i l i s e e s p o u r l e s
|
||||
//-- s a m p l e s
|
||||
//-- ============================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Analyse
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void Analyse(const TColgp_Array2OfPnt& array2,
|
||||
const Standard_Integer nbup,
|
||||
const Standard_Integer nbvp,
|
||||
Standard_Integer& myNbSamplesU,
|
||||
Standard_Integer& myNbSamplesV)
|
||||
{
|
||||
gp_Vec Vi,Vip1;
|
||||
Standard_Integer sh,nbch,i,j;
|
||||
|
||||
sh = 1;
|
||||
nbch = 0;
|
||||
if(nbvp>2) {
|
||||
for(i=2;i<nbup;i++) {
|
||||
const gp_Pnt& A=array2.Value(i,1);
|
||||
const gp_Pnt& B=array2.Value(i,2);
|
||||
const gp_Pnt& C=array2.Value(i,3);
|
||||
Vi.SetCoord(C.X()-B.X()-B.X()+A.X(),
|
||||
C.Y()-B.Y()-B.Y()+A.Y(),
|
||||
C.Z()-B.Z()-B.Z()+A.Z());
|
||||
Standard_Integer locnbch=0;
|
||||
for(j=3; j<nbvp;j++) { //-- essai
|
||||
const gp_Pnt& Ax=array2.Value(i,j-1);
|
||||
const gp_Pnt& Bx=array2.Value(i,j);
|
||||
const gp_Pnt& Cx=array2.Value(i,j+1);
|
||||
Vip1.SetCoord(Cx.X()-Bx.X()-Bx.X()+Ax.X(),
|
||||
Cx.Y()-Bx.Y()-Bx.Y()+Ax.Y(),
|
||||
Cx.Z()-Bx.Z()-Bx.Z()+Ax.Z());
|
||||
Standard_Real pd = Vi.Dot(Vip1);
|
||||
Vi=Vip1;
|
||||
if(pd>1.0e-7 || pd<-1.0e-7) {
|
||||
if(pd>0) { if(sh==-1) { sh=1; locnbch++; } }
|
||||
else { if(sh==1) { sh=-1; locnbch++; } }
|
||||
}
|
||||
}
|
||||
if(locnbch>nbch) {
|
||||
nbch=locnbch;
|
||||
}
|
||||
}
|
||||
}
|
||||
myNbSamplesV = nbch+5;
|
||||
|
||||
|
||||
nbch=0;
|
||||
if(nbup>2) {
|
||||
for(j=2;j<nbvp;j++) {
|
||||
const gp_Pnt& A=array2.Value(1,j);
|
||||
const gp_Pnt& B=array2.Value(2,j);
|
||||
const gp_Pnt& C=array2.Value(3,j);
|
||||
Vi.SetCoord(C.X()-B.X()-B.X()+A.X(),
|
||||
C.Y()-B.Y()-B.Y()+A.Y(),
|
||||
C.Z()-B.Z()-B.Z()+A.Z());
|
||||
Standard_Integer locnbch=0;
|
||||
for(i=3; i<nbup;i++) { //-- essai
|
||||
const gp_Pnt& Ax=array2.Value(i-1,j);
|
||||
const gp_Pnt& Bx=array2.Value(i,j);
|
||||
const gp_Pnt& Cx=array2.Value(i+1,j);
|
||||
Vip1.SetCoord(Cx.X()-Bx.X()-Bx.X()+Ax.X(),
|
||||
Cx.Y()-Bx.Y()-Bx.Y()+Ax.Y(),
|
||||
Cx.Z()-Bx.Z()-Bx.Z()+Ax.Z());
|
||||
Standard_Real pd = Vi.Dot(Vip1);
|
||||
Vi=Vip1;
|
||||
if(pd>1.0e-7 || pd<-1.0e-7) {
|
||||
if(pd>0) { if(sh==-1) { sh=1; locnbch++; } }
|
||||
else { if(sh==1) { sh=-1; locnbch++; } }
|
||||
}
|
||||
}
|
||||
if(locnbch>nbch) nbch=locnbch;
|
||||
}
|
||||
}
|
||||
myNbSamplesU = nbch+5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ComputeSamplePoints
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::ComputeSamplePoints()
|
||||
{
|
||||
Standard_Real uinf,usup,vinf,vsup;
|
||||
uinf = myS->FirstUParameter(); usup = myS->LastUParameter();
|
||||
vinf = myS->FirstVParameter(); vsup = myS->LastVParameter();
|
||||
if (usup < uinf) { Standard_Real temp=uinf; uinf=usup; usup=temp; }
|
||||
if (vsup < vinf) { Standard_Real temp=vinf; vinf=vsup; vsup=temp; }
|
||||
if (uinf == RealFirst() && usup == RealLast()) { uinf=-1.e5; usup=1.e5; }
|
||||
else if (uinf == RealFirst()) { uinf=usup-2.e5; }
|
||||
else if (usup == RealLast()) { usup=uinf+2.e5; }
|
||||
|
||||
if (vinf == RealFirst() && vsup == RealLast()) { vinf=-1.e5; vsup=1.e5; }
|
||||
else if (vinf == RealFirst()) { vinf=vsup-2.e5; }
|
||||
else if (vsup == RealLast()) { vsup=vinf+2.e5; }
|
||||
|
||||
Standard_Integer nbsu,nbsv;
|
||||
GeomAbs_SurfaceType typS = myS->GetType();
|
||||
switch(typS) {
|
||||
case GeomAbs_Plane: { nbsv=2; nbsu=2; } break;
|
||||
case GeomAbs_BezierSurface: { nbsv=3+myS->NbVPoles(); nbsu=3+myS->NbUPoles(); } break;
|
||||
case GeomAbs_BSplineSurface: {
|
||||
nbsv = myS->NbVKnots(); nbsv*= myS->VDegree(); if(nbsv < 4) nbsv=4;
|
||||
nbsu = myS->NbUKnots(); nbsu*= myS->UDegree(); if(nbsu < 4) nbsu=4;
|
||||
}
|
||||
break;
|
||||
case GeomAbs_Cylinder:
|
||||
case GeomAbs_Cone:
|
||||
case GeomAbs_Sphere:
|
||||
case GeomAbs_Torus: {
|
||||
//-- On place 15 echnt pour 2pi
|
||||
//-- pas suffisant ->25 pour 2pi
|
||||
nbsu = (Standard_Integer)(8*(usup-uinf));
|
||||
nbsv = (Standard_Integer)(7*(vsup-vinf));
|
||||
if(nbsu<5) nbsu=5;
|
||||
if(nbsv<5) nbsv=5;
|
||||
if(nbsu>30) nbsu=30; //modif HRT buc60462
|
||||
if(nbsv>15) nbsv=15;
|
||||
//-- printf("\n nbsu=%d nbsv=%d\n",nbsu,nbsv);
|
||||
} break;
|
||||
case GeomAbs_SurfaceOfRevolution:
|
||||
case GeomAbs_SurfaceOfExtrusion: { nbsv = 15; nbsu=25; } break;
|
||||
default: { nbsu = 10; nbsv=10; } break;
|
||||
}
|
||||
|
||||
//-- Si le nb de points est trop grand on analyse
|
||||
//--
|
||||
//--
|
||||
|
||||
if(nbsu<10) nbsu=10;
|
||||
if(nbsv<10) nbsv=10;
|
||||
|
||||
myNbSamplesU = nbsu;
|
||||
myNbSamplesV = nbsv;
|
||||
|
||||
//-- printf("\n BRepTopAdaptor_TopolTool NbSu=%d NbSv=%d ",nbsu,nbsv);
|
||||
if(nbsu>10 || nbsv>10) {
|
||||
if(typS == GeomAbs_BSplineSurface) {
|
||||
const Handle(Geom_BSplineSurface)& Bspl = myS->BSpline();
|
||||
Standard_Integer nbup = Bspl->NbUPoles();
|
||||
Standard_Integer nbvp = Bspl->NbVPoles();
|
||||
TColgp_Array2OfPnt array2(1,nbup,1,nbvp);
|
||||
Bspl->Poles(array2);
|
||||
Analyse(array2,nbup,nbvp,myNbSamplesU,myNbSamplesV);
|
||||
nbsu=myNbSamplesU;
|
||||
nbsv=myNbSamplesV;
|
||||
//-- printf("\n Apres analyse BSPline NbSu=%d NbSv=%d ",myNbSamplesU,myNbSamplesV);
|
||||
}
|
||||
else if(typS == GeomAbs_BezierSurface) {
|
||||
const Handle(Geom_BezierSurface)& Bez = myS->Bezier();
|
||||
Standard_Integer nbup = Bez->NbUPoles();
|
||||
Standard_Integer nbvp = Bez->NbVPoles();
|
||||
TColgp_Array2OfPnt array2(1,nbup,1,nbvp);
|
||||
Bez->Poles(array2);
|
||||
Analyse(array2,nbup,nbvp,myNbSamplesU,myNbSamplesV);
|
||||
nbsu=myNbSamplesU;
|
||||
nbsv=myNbSamplesV;
|
||||
//-- printf("\n Apres analyse Bezier NbSu=%d NbSv=%d ",myNbSamplesU,myNbSamplesV);
|
||||
}
|
||||
}
|
||||
|
||||
if(nbsu<10) nbsu=10;
|
||||
if(nbsv<10) nbsv=10;
|
||||
|
||||
myNbSamplesU = nbsu;
|
||||
myNbSamplesV = nbsv;
|
||||
|
||||
myU0 = uinf;
|
||||
myV0 = vinf;
|
||||
|
||||
myDU = (usup-uinf)/(myNbSamplesU+1);
|
||||
myDV = (vsup-vinf)/(myNbSamplesV+1);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NbSamplesU
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer BRepTopAdaptor_TopolTool::NbSamplesU()
|
||||
{
|
||||
if(myNbSamplesU <0) {
|
||||
ComputeSamplePoints();
|
||||
}
|
||||
return(myNbSamplesU);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NbSamplesV
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer BRepTopAdaptor_TopolTool::NbSamplesV()
|
||||
{
|
||||
if(myNbSamplesU <0) {
|
||||
ComputeSamplePoints();
|
||||
}
|
||||
return(myNbSamplesV);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : NbSamples
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer BRepTopAdaptor_TopolTool::NbSamples()
|
||||
{
|
||||
if(myNbSamplesU <0) {
|
||||
ComputeSamplePoints();
|
||||
}
|
||||
return(myNbSamplesU*myNbSamplesV);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SamplePoint
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BRepTopAdaptor_TopolTool::SamplePoint(const Standard_Integer i,
|
||||
gp_Pnt2d& P2d,
|
||||
gp_Pnt& P3d)
|
||||
{
|
||||
Standard_Integer iv = 1 + i/myNbSamplesU;
|
||||
Standard_Integer iu = 1+ i-(iv-1)*myNbSamplesU;
|
||||
Standard_Real u=myU0+iu*myDU;
|
||||
Standard_Real v=myV0+iv*myDV;
|
||||
P2d.SetCoord(u,v);
|
||||
P3d=myS->Value(u,v);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : DomainIsInfinite
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BRepTopAdaptor_TopolTool::DomainIsInfinite()
|
||||
{
|
||||
Standard_Real uinf,usup,vinf,vsup;
|
||||
uinf = myS->FirstUParameter(); usup = myS->LastUParameter();
|
||||
vinf = myS->FirstVParameter(); vsup = myS->LastVParameter();
|
||||
if(Precision::IsNegativeInfinite(uinf)) return(Standard_True);
|
||||
if(Precision::IsPositiveInfinite(usup)) return(Standard_True);
|
||||
if(Precision::IsNegativeInfinite(vinf)) return(Standard_True);
|
||||
if(Precision::IsPositiveInfinite(vsup)) return(Standard_True);
|
||||
return(Standard_False);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Has3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean BRepTopAdaptor_TopolTool::Has3d() const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Tol3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepTopAdaptor_TopolTool::Tol3d(const Handle(Adaptor2d_HCurve2d)& C) const
|
||||
{
|
||||
Handle(BRepAdaptor_HCurve2d) brhc = Handle(BRepAdaptor_HCurve2d)::DownCast(C);
|
||||
if (brhc.IsNull())
|
||||
Standard_DomainError::Raise("BRepTopAdaptor_TopolTool: arc has no 3d representation");
|
||||
const BRepAdaptor_Curve2d& brc = (const BRepAdaptor_Curve2d &)brhc->Curve2d();
|
||||
const TopoDS_Edge& edge = brc.Edge();
|
||||
if (edge.IsNull())
|
||||
Standard_DomainError::Raise("BRepTopAdaptor_TopolTool: arc has no 3d representation");
|
||||
return BRep_Tool::Tolerance(edge);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Tol3d
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real BRepTopAdaptor_TopolTool::Tol3d(const Handle(Adaptor3d_HVertex)& V) const
|
||||
{
|
||||
Handle(BRepTopAdaptor_HVertex) brhv = Handle(BRepTopAdaptor_HVertex)::DownCast(V);
|
||||
if (brhv.IsNull())
|
||||
Standard_DomainError::Raise("BRepTopAdaptor_TopolTool: vertex has no 3d representation");
|
||||
const TopoDS_Vertex& ver = brhv->Vertex();
|
||||
if (ver.IsNull())
|
||||
Standard_DomainError::Raise("BRepTopAdaptor_TopolTool: vertex has no 3d representation");
|
||||
return BRep_Tool::Tolerance(ver);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Pnt
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt BRepTopAdaptor_TopolTool::Pnt(const Handle(Adaptor3d_HVertex)& V) const
|
||||
{
|
||||
Handle(BRepTopAdaptor_HVertex) brhv = Handle(BRepTopAdaptor_HVertex)::DownCast(V);
|
||||
if (brhv.IsNull())
|
||||
Standard_DomainError::Raise("BRepTopAdaptor_TopolTool: vertex has no 3d representation");
|
||||
const TopoDS_Vertex& ver = brhv->Vertex();
|
||||
if (ver.IsNull())
|
||||
Standard_DomainError::Raise("BRepTopAdaptor_TopolTool: vertex has no 3d representation");
|
||||
return BRep_Tool::Pnt(ver);
|
||||
}
|
Reference in New Issue
Block a user