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

Integration of OCCT 6.5.0 from SVN

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

32
src/TopOpeBRepTool/FILES Executable file
View File

@@ -0,0 +1,32 @@
FILES
TopOpeBRepTool_faulty.cxx
TopOpeBRepTool_closing.cxx
TopOpeBRepTool_PURGE.hxx
TopOpeBRepTool_PURGE.cxx
TopOpeBRepTool_RegularizeW.cxx
TopOpeBRepTool_RegularizeS.cxx
TopOpeBRepTool_DRAW.cxx
TopOpeBRepTool_DRAW.hxx
TopOpeBRepTool_KRO.hxx
TopOpeBRepTool_trace.cxx
TopOpeBRepTool_STATE.hxx
TopOpeBRepTool_STATE.cxx
TopOpeBRepTool_traceSTATE.cxx
TopOpeBRepTool_EXPORT.hxx
TopOpeBRepTool_PROJECT.hxx
TopOpeBRepTool_PROJECT.cxx
TopOpeBRepTool_GEOMETRY.hxx
TopOpeBRepTool_GEOMETRY.cxx
TopOpeBRepTool_TOPOLOGY.hxx
TopOpeBRepTool_TOPOLOGY.cxx
TopOpeBRepTool_matter.cxx
TopOpeBRepTool_SC.hxx
TopOpeBRepTool_SC.cxx
TopOpeBRepTool_2d.hxx
TopOpeBRepTool_2d.cxx
TopOpeBRepTool_box.hxx
TopOpeBRepTool_box.cxx
TopOpeBRepTool_define.hxx
TopOpeBRepTool_defineG.hxx
TopOpeBRepTool_tol.hxx
TopOpeBRepTool_tol.cxx

View File

@@ -0,0 +1,205 @@
-- File: TopOpeBRepTool.cdl
-- Created: Thu Jun 17 09:59:51 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
package TopOpeBRepTool
---Purpose: This package provides services used by the TopOpeBRep
-- package performing topological operations on the BRep
-- data structure.
--
uses
Standard,
TColStd,
TCollection,
TColgp,
TopAbs,
TopoDS,
TopTools,
TopExp,
GeomAbs,
Geom,
GeomAdaptor,
Geom2d,
Geom2dAdaptor,
gp,
Bnd,
BRepClass,
TopClass,
BRepClass3d,
BRep,
BRepAdaptor,
Geom2dInt,
IntSurf
is
enumeration OutCurveType is
BSPLINE1,APPROX,INTERPOL
end OutCurveType;
class GeomTool;
class AncestorsTool;
pointer PSoClassif to SolidClassifier from BRepClass3d;
class C2DF;
class ListOfC2DF instantiates List from TCollection(C2DF from TopOpeBRepTool);
class DataMapOfOrientedShapeC2DF
instantiates DataMap from TCollection
(Shape from TopoDS,
C2DF from TopOpeBRepTool,
OrientedShapeMapHasher from TopTools);
class DataMapOfShapeListOfC2DF
instantiates DataMap from TCollection
(Shape from TopoDS,
ListOfC2DF from TopOpeBRepTool,
ShapeMapHasher from TopTools);
class IndexedDataMapOfSolidClassifier
instantiates IndexedDataMap from TCollection
(Shape from TopoDS,
SolidClassifier from BRepClass3d,
ShapeMapHasher from TopTools);
pointer Plos to ListOfShape from TopTools;
class SolidClassifier;
class CurveTool;
class IndexedDataMapOfShapeBox2d
instantiates IndexedDataMap from TCollection
(Shape from TopoDS,
Box2d from Bnd,
OrientedShapeMapHasher from TopTools);
class IndexedDataMapOfShapeBox
instantiates IndexedDataMap from TCollection
(Shape from TopoDS,
Box from Bnd,
OrientedShapeMapHasher from TopTools);
class HBoxTool;
class BoxSort;
class ShapeExplorer;
class ShapeTool;
class ShapeClassifier;
pointer PShapeClassifier to ShapeClassifier from TopOpeBRepTool;
class connexity;
class IndexedDataMapOfShapeconnexity instantiates
IndexedDataMap from TCollection (Shape from TopoDS,
connexity from TopOpeBRepTool,
ShapeMapHasher from TopTools);
class face;
class DataMapOfShapeface instantiates
DataMap from TCollection (Shape from TopoDS,
face from TopOpeBRepTool,
ShapeMapHasher from TopTools);
class CLASSI;
class TOOL;
class CORRISO;
class REGUW;
class REGUS;
class makeTransition;
class mkTondgE;
class PurgeInternalEdges;
---Purpose: Detect and remove Internal and External edges (that
-- are not connex to other faces) from all faces of a shape.
class FuseEdges;
---Purpose: Fuse edges (in a wire) of a shape where we have
-- useless vertex.
PurgeClosingEdges(F, FF : in Face from TopoDS;
MWisOld : in DataMapOfShapeInteger from TopTools;
MshNOK : in out IndexedMapOfOrientedShape from TopTools)
returns Boolean from Standard;
---Purpose: In case face <FF> is built on UV-non-connexed wires
-- (with the two closing edges FORWARD and REVERSED, in
-- spite of one only), we find out the faulty edge, add
-- the faulty shapes (edge,wire,face) to <MshNOK>.
-- <FF> is a face descendant of <F>.
-- <MWisOld>(wire) = 1 if wire is wire of <F>
-- 0 wire results from <F>'s wire splitted.
-- returns false if purge fails
PurgeClosingEdges(F : in Face from TopoDS;
LOF : in ListOfShape from TopTools;
MWisOld : in DataMapOfShapeInteger from TopTools;
MshNOK : out IndexedMapOfOrientedShape from TopTools)
returns Boolean from Standard;
-- <LOF> is the list of <F>'s descendant faces.
-- returns false if purge fails
CorrectONUVISO(F : in Face from TopoDS;
Fsp : in out Face from TopoDS)
returns Boolean from Standard;
-- <Fsp> is one of <F>'s split, corrects <Fsp> to have
-- it connexed in UV space.
MakeFaces(F : in Face from TopoDS;
LOF : in ListOfShape from TopTools;
MshNOK : in IndexedMapOfOrientedShape from TopTools;
LOFF : out ListOfShape from TopTools)
returns Boolean from Standard;
---Purpose: Builds up the correct list of faces <LOFF> from <LOF>, using
-- faulty shapes from map <MshNOK>.
-- <LOF> is the list of <F>'s descendant faces.
-- returns false if building fails
Regularize(aFace : in Face from TopoDS;
aListOfFaces : out ListOfShape from TopTools;
ESplits : in out DataMapOfShapeListOfShape from TopTools)
returns Boolean from Standard;
---Purpose: Returns <False> if the face is valid (the UV
-- representation of the face is a set of pcurves
-- connexed by points with connexity 2).
-- Else, splits <aFace> in order to return a list of valid
-- faces.
RegularizeWires(aFace : in Face from TopoDS;
OldWiresNewWires : out DataMapOfShapeListOfShape from TopTools;
ESplits : in out DataMapOfShapeListOfShape from TopTools)
returns Boolean from Standard;
---Purpose: Returns <False> if the face is valid (the UV
-- representation of the face is a set of pcurves
-- connexed by points with connexity 2).
-- Else, splits wires of the face, these are boundaries of the
-- new faces to build up; <OldWiresNewWires> describes (wire,
-- splits of wire); <ESplits> describes (edge, edge's splits)
RegularizeFace(aFace : in Face from TopoDS;
OldWiresnewWires : in DataMapOfShapeListOfShape from TopTools;
aListOfFaces : out ListOfShape from TopTools)
returns Boolean from Standard;
---Purpose: Classify wire's splits of map <OldWiresnewWires> in order to
-- compute <aListOfFaces>, the splits of <aFace>.
RegularizeShells(aSolid : in Solid from TopoDS;
OldSheNewShe : out DataMapOfShapeListOfShape from TopTools;
FSplits : in out DataMapOfShapeListOfShape from TopTools)
returns Boolean from Standard;
---Purpose: Returns <False> if the shell is valid (the solid is a set
-- of faces connexed by edges with connexity 2).
-- Else, splits faces of the shell; <OldFacesnewFaces> describes
-- (face, splits of face).
-- NYI RegularizeSolid(...)
Print(OCT : OutCurveType from TopOpeBRepTool; S : in out OStream)
returns OStream;
---C++: return &
---Purpose: Prints <OCT> as string on stream <S>; returns <S>.
end TopOpeBRepTool;

View File

@@ -0,0 +1,25 @@
// File: TopOpeBRepTool.cxx
// Created: Thu Mar 10 12:13:09 1994
// Author: Jean Yves LEBEY
// <jyl@phobox>
#include <TopOpeBRepTool.hxx>
//=======================================================================
//function : Print
//purpose :
//=======================================================================
Standard_OStream& TopOpeBRepTool::Print(const TopOpeBRepTool_OutCurveType t,
Standard_OStream& OS)
{
//#ifdef DEB
switch (t) {
case TopOpeBRepTool_BSPLINE1 : OS << "BSPLINE1"; break;
case TopOpeBRepTool_APPROX : OS << "APPROX"; break;
case TopOpeBRepTool_INTERPOL : OS << "INTERPOL"; break;
default : OS << "UNKNOWN"; break;
}
//#endif
return OS;
}

View File

@@ -0,0 +1,382 @@
// File: TopOpeBRepTool_2d.cxx
// Created: Mon Mar 23 16:47:44 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#include <gp_Vec2d.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Curve.hxx>
#include <ProjLib_ProjectedCurve.hxx>
#include <Geom_Surface.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <BRepAdaptor_HCurve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <TopOpeBRepTool_CurveTool.hxx>
#include <TopOpeBRepTool_DataMapOfShapeListOfC2DF.hxx>
#include <TopOpeBRepTool_C2DF.hxx>
#include <TopOpeBRepTool_ListOfC2DF.hxx>
#include <TopOpeBRepTool_ListIteratorOfListOfC2DF.hxx>
#include <TopOpeBRepTool_tol.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
#ifdef DEB
void debc2dnull(void) {}
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceC2D();
#endif
// structure e -> C2D/F
static TopOpeBRepTool_DataMapOfShapeListOfC2DF *GLOBAL_pmosloc2df = NULL;
static Standard_Integer GLOBAL_C2D_i = 0; // DEB
// structure ancetre
static TopTools_IndexedDataMapOfShapeListOfShape *GLOBAL_pidmoslosc2df = NULL;
static TopoDS_Face *GLOBAL_pFc2df = NULL;
static TopoDS_Shape *GLOBAL_pS1c2df = NULL;
static TopoDS_Shape *GLOBAL_pS2c2df = NULL;
Standard_EXPORT Handle(Geom2d_Curve) MakePCurve(const ProjLib_ProjectedCurve& PC);
// ------------------------------------------------------------------------------------
static const TopoDS_Face& FC2D_FancestorE(const TopoDS_Edge& E)
{
if (GLOBAL_pmosloc2df == NULL) GLOBAL_pmosloc2df = new TopOpeBRepTool_DataMapOfShapeListOfC2DF();
Standard_Integer ancemp = (*GLOBAL_pidmoslosc2df).Extent();
if (ancemp == 0) {
TopExp::MapShapesAndAncestors(*GLOBAL_pS1c2df,TopAbs_EDGE,TopAbs_FACE,(*GLOBAL_pidmoslosc2df));
TopExp::MapShapesAndAncestors(*GLOBAL_pS2c2df,TopAbs_EDGE,TopAbs_FACE,(*GLOBAL_pidmoslosc2df));
}
Standard_Boolean Eb = (*GLOBAL_pidmoslosc2df).Contains(E);
if ( !Eb ) return *GLOBAL_pFc2df;
const TopTools_ListOfShape& lf = (*GLOBAL_pidmoslosc2df).FindFromKey(E);
if (lf.IsEmpty()) return *GLOBAL_pFc2df;
const TopoDS_Face& F = TopoDS::Face(lf.First());
return F;
}
// ------------------------------------------------------------------------------------
Standard_EXPORT int FC2D_Prepare(const TopoDS_Shape& S1,const TopoDS_Shape& S2)
{
if (GLOBAL_pmosloc2df == NULL) GLOBAL_pmosloc2df = new TopOpeBRepTool_DataMapOfShapeListOfC2DF();
GLOBAL_pmosloc2df->Clear();
GLOBAL_C2D_i = 0;
if (GLOBAL_pidmoslosc2df == NULL) GLOBAL_pidmoslosc2df = new TopTools_IndexedDataMapOfShapeListOfShape();
GLOBAL_pidmoslosc2df->Clear();
if (GLOBAL_pFc2df == NULL) GLOBAL_pFc2df = new TopoDS_Face();
GLOBAL_pFc2df->Nullify();
if (GLOBAL_pS1c2df == NULL) GLOBAL_pS1c2df = new TopoDS_Shape();
*GLOBAL_pS1c2df = S1;
if (GLOBAL_pS2c2df == NULL) GLOBAL_pS2c2df = new TopoDS_Shape();
*GLOBAL_pS2c2df = S2;
return 0;
}
// ------------------------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FC2D_HasC3D(const TopoDS_Edge& E)
{
TopLoc_Location loc; Standard_Real f3d,l3d; Handle(Geom_Curve) C3D = BRep_Tool::Curve(E,loc,f3d,l3d);
Standard_Boolean b = (!C3D.IsNull());
return b;
}
// ------------------------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FC2D_HasCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F)
{
Handle(Geom2d_Curve) C2D;
Standard_Boolean hasold = FC2D_HasOldCurveOnSurface(E,F,C2D);
Standard_Boolean hasnew = FC2D_HasNewCurveOnSurface(E,F,C2D);
Standard_Boolean b = hasold || hasnew;
return b;
}
// ------------------------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FC2D_HasOldCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D,Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol)
{
Standard_Boolean hasold = Standard_False;
tol = BRep_Tool::Tolerance(E);
C2D = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
hasold = (!C2D.IsNull());
return hasold;
}
Standard_EXPORT Standard_Boolean FC2D_HasOldCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D)
{ Standard_Real f2d,l2d,tol; Standard_Boolean hasold = FC2D_HasOldCurveOnSurface(E,F,C2D,f2d,l2d,tol); return hasold;
}
// ------------------------------------------------------------------------------------
static TopOpeBRepTool_C2DF* FC2D_PNewCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F)
{
TopOpeBRepTool_C2DF* pc2df = NULL;
if (GLOBAL_pmosloc2df == NULL) return NULL;
Standard_Boolean Eisb = GLOBAL_pmosloc2df->IsBound(E);
if (!Eisb) return NULL;
TopOpeBRepTool_ListIteratorOfListOfC2DF it(GLOBAL_pmosloc2df->Find(E));
for(;it.More();it.Next()) {
const TopOpeBRepTool_C2DF& c2df = it.Value();
Standard_Boolean isf = c2df.IsFace(F);
if (isf) {
pc2df = (TopOpeBRepTool_C2DF*)&c2df;
break;
}
}
return pc2df;
}
Standard_EXPORT Standard_Boolean FC2D_HasNewCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D,Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol)
{
const TopOpeBRepTool_C2DF* pc2df = FC2D_PNewCurveOnSurface(E,F);
Standard_Boolean hasnew = (pc2df != NULL);
if (hasnew) C2D = pc2df->PC(f2d,l2d,tol);
return hasnew;
}
Standard_EXPORT Standard_Boolean FC2D_HasNewCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D)
{ Standard_Real f2d,l2d,tol; Standard_Boolean b = FC2D_HasNewCurveOnSurface(E,F,C2D,f2d,l2d,tol); return b;
}
// ------------------------------------------------------------------------------------
Standard_Integer FC2D_AddNewCurveOnSurface(Handle(Geom2d_Curve) C2D,const TopoDS_Edge& E,const TopoDS_Face& F,const Standard_Real& f2d,const Standard_Real& l2d,const Standard_Real& tol)
{
if (C2D.IsNull()) return 1;
TopOpeBRepTool_C2DF c2df(C2D,f2d,l2d,tol,F);
if (GLOBAL_pmosloc2df == NULL) return 1;
TopOpeBRepTool_ListOfC2DF thelist;
GLOBAL_pmosloc2df->Bind(E, thelist);
TopOpeBRepTool_ListOfC2DF& lc2df = GLOBAL_pmosloc2df->ChangeFind(E);
lc2df.Append(c2df);
return 0;
}
// ------------------------------------------------------------------------------------
static Handle(Geom2d_Curve) FC2D_make2d(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol,const Standard_Boolean trim3d = Standard_False);
static Handle(Geom2d_Curve) FC2D_make2d(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol,const Standard_Boolean trim3d)
{
Handle(Geom2d_Curve) C2D = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
if (!C2D.IsNull()) return C2D;
// pas de 2D
Standard_Real f3d,l3d;TopLoc_Location eloc;
Handle(Geom_Curve) C1 = BRep_Tool::Curve(E,eloc,f3d,l3d);
Standard_Boolean hasC3D = (!C1.IsNull());
if ( hasC3D ) {
Standard_Boolean elocid = eloc.IsIdentity();
Handle(Geom_Curve) C2;
if (elocid ) C2 = C1;
else C2 = Handle(Geom_Curve)::DownCast(C1->Transformed(eloc.Transformation()));
Standard_Real f=0.,l=0.;
if (trim3d) {f=f3d; l=l3d;}
C2D = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F,C2,tol,f,l);
f2d = f3d; l2d = l3d;
return C2D;
}
else {
// E sans courbe 2d sur F, E sans courbe 3d
// une face accedant a E : FE
const TopoDS_Face& FE = FC2D_FancestorE(E);
if (FE.IsNull()) return C2D;
Standard_Boolean compminmaxUV = Standard_False;
BRepAdaptor_Surface BAS(F,compminmaxUV);
Handle(BRepAdaptor_HSurface) BAHS = new BRepAdaptor_HSurface(BAS);
BRepAdaptor_Curve AC(E,FE);
Handle(BRepAdaptor_HCurve) AHC = new BRepAdaptor_HCurve(AC);
Standard_Real tolin; FTOL_FaceTolerances3d(F,FE,tolin);
ProjLib_ProjectedCurve projcurv(BAHS,AHC,tolin);
C2D = MakePCurve(projcurv);
Standard_Real f,l; BRep_Tool::Range(E,f,l);
f2d = f; l2d = l;
}
#ifdef DEB
if (TopOpeBRepTool_GettraceC2D() && C2D.IsNull()) {
cout<<"#FC2D_make2d1 --> PCurve IsNull"<<endl;
}
#endif
return C2D;
} // make2d1
// ------------------------------------------------------------------------------------
//modified by NIZHNY-MZV Mon Oct 4 10:37:36 1999
Standard_EXPORT Handle(Geom2d_Curve) FC2D_MakeCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f,Standard_Real& l,Standard_Real& tol,const Standard_Boolean trim3d)
{
#ifdef DRAW
if (TopOpeBRepTool_GettraceC2D()) {
cout<<"\n#FC2D_MakeCurveOnSurface : "<<endl;
TCollection_AsciiString fnam("c2df");GLOBAL_C2D_i++;fnam=fnam+GLOBAL_C2D_i;FDRAW_DINS("",F,fnam,"");
TCollection_AsciiString enam("c2de");GLOBAL_C2D_i++;enam=enam+GLOBAL_C2D_i;FDRAW_DINE(" ",E,enam,"\n");
cout.flush(); debc2dnull();
}
#endif
Handle(Geom2d_Curve) C2D = FC2D_make2d(E,F,f,l,tol,trim3d);
FC2D_AddNewCurveOnSurface(C2D,E,F,f,l,tol);
return C2D;
}
// ------------------------------------------------------------------------------------
Standard_EXPORT Handle(Geom2d_Curve) FC2D_CurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f,Standard_Real& l,Standard_Real& tol,const Standard_Boolean trim3d)
{
Handle(Geom2d_Curve) C2D;
Standard_Boolean hasold = FC2D_HasOldCurveOnSurface(E,F,C2D,f,l,tol);
if (hasold) {
return C2D;
}
Standard_Boolean hasnew = FC2D_HasNewCurveOnSurface(E,F,C2D,f,l,tol);
if (hasnew) {
return C2D;
}
C2D = FC2D_MakeCurveOnSurface(E,F,f,l,tol,trim3d);
return C2D;
}
// ------------------------------------------------------------------------------------
Standard_EXPORT Handle(Geom2d_Curve) FC2D_EditableCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f,Standard_Real& l,Standard_Real& tol,const Standard_Boolean trim3d)
{
Standard_Boolean hasold = Standard_False;
{
Handle(Geom2d_Curve) C2D;
hasold = FC2D_HasOldCurveOnSurface(E,F,C2D,f,l,tol);
if (hasold) {
Handle(Geom2d_Curve) copC2D = Handle(Geom2d_Curve)::DownCast(C2D->Copy());
return copC2D;
}
}
Standard_Boolean hasnew = Standard_False;
{
Handle(Geom2d_Curve) newC2D;
hasnew = FC2D_HasNewCurveOnSurface(E,F,newC2D,f,l,tol);
if (hasnew) {
return newC2D;
}
}
Handle(Geom2d_Curve) makC2D = FC2D_MakeCurveOnSurface(E,F,f,l,tol,trim3d);
return makC2D;
}
// ------------------------------------------------------------------------------------
static void FC2D_translate(Handle(Geom2d_Curve) C2D,
// const TopoDS_Edge& E,
const TopoDS_Edge& ,
const TopoDS_Face& F,
const TopoDS_Edge& EF)
{
TopLoc_Location sloc; const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F,sloc);
Standard_Boolean isperio = S1->IsUPeriodic() || S1->IsVPeriodic();
gp_Dir2d d2d; gp_Pnt2d O2d; Standard_Boolean isuiso,isviso;
Standard_Boolean uviso = TopOpeBRepTool_TOOL::UVISO(C2D,isuiso,isviso,d2d,O2d);
Standard_Boolean EFnull = EF.IsNull();
if (isperio && uviso && !EFnull) {
// C2D prend comme origine dans F l'origine de la pcurve de EF dans F
#ifdef DEB
Standard_Real period = S1->IsUPeriodic() ? S1->UPeriod() : S1->IsVPeriodic() ? S1->VPeriod() : 0.;
#endif
TopoDS_Face FFOR = F;
FFOR.Orientation(TopAbs_FORWARD);
gp_Pnt2d p1,p2; BRep_Tool::UVPoints(EF,FFOR,p1,p2);
Standard_Real pEF = isuiso ? p1.X() : p1.Y();
Standard_Real pC2D = isuiso ? O2d.X() : O2d.Y();
Standard_Real factor = pEF - pC2D;
Standard_Boolean b = (Abs(factor) > 1.e-6);
if ( b ) {
gp_Vec2d transl(1.,0.); if (isviso) transl = gp_Vec2d(0.,1.);
transl.Multiply(factor);
C2D->Translate(transl);
}
}
}
// ------------------------------------------------------------------------------------
static Handle(Geom2d_Curve) FC2D_make2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& EF,Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol,const Standard_Boolean trim3d = Standard_False);
static Handle(Geom2d_Curve) FC2D_make2d(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& EF,Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol,const Standard_Boolean trim3d)
{
Handle(Geom2d_Curve) C2D = BRep_Tool::CurveOnSurface(E,F,f2d,l2d);
if (!C2D.IsNull()) return C2D;
// pas de 2D
Standard_Real f3d,l3d;TopLoc_Location eloc;
Handle(Geom_Curve) C1 = BRep_Tool::Curve(E,eloc,f3d,l3d);
Standard_Boolean hasC3D = (!C1.IsNull());
if ( hasC3D ) {
Standard_Boolean elocid = eloc.IsIdentity();
Handle(Geom_Curve) C2;
if (elocid ) C2 = C1;
else C2 = Handle(Geom_Curve)::DownCast(C1->Transformed(eloc.Transformation()));
Standard_Real f=0.,l=0.;
if (trim3d) {f=f3d; l=l3d;}
C2D = TopOpeBRepTool_CurveTool::MakePCurveOnFace(F,C2,tol,f,l);
f2d = f3d; l2d = l3d;
FC2D_translate(C2D,E,F,EF);
return C2D;
}
else {
// E sans courbe 2d sur F, E sans courbe 3d
// une face accedant a E : FE
const TopoDS_Face& FE = FC2D_FancestorE(E);
if (FE.IsNull()) return C2D;
Standard_Boolean compminmaxUV = Standard_False;
BRepAdaptor_Surface BAS(F,compminmaxUV);
Handle(BRepAdaptor_HSurface) BAHS = new BRepAdaptor_HSurface(BAS);
BRepAdaptor_Curve AC(E,FE);
Handle(BRepAdaptor_HCurve) AHC = new BRepAdaptor_HCurve(AC);
Standard_Real tolin; FTOL_FaceTolerances3d(F,FE,tolin);
ProjLib_ProjectedCurve projcurv(BAHS,AHC,tolin);
C2D = MakePCurve(projcurv);
Standard_Real f,l; BRep_Tool::Range(E,f,l);
f2d = f; l2d = l;
FC2D_translate(C2D,E,F,EF);
}
#ifdef DEB
if (TopOpeBRepTool_GettraceC2D() && C2D.IsNull()) {
cout<<"#FC2D_make2d2 --> PCurve IsNull"<<endl;
}
#endif
return C2D;
} // make2d2
// ------------------------------------------------------------------------------------
Standard_EXPORT Handle(Geom2d_Curve) FC2D_CurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& EF,Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol,const Standard_Boolean trim3d)
{
Handle(Geom2d_Curve) C2D;
Standard_Boolean hasold = FC2D_HasOldCurveOnSurface(E,F,C2D,f2d,l2d,tol);
if (hasold) return C2D;
TopOpeBRepTool_C2DF* pc2df = FC2D_PNewCurveOnSurface(E,F);
if (pc2df != NULL) {
C2D = pc2df->PC(f2d,l2d,tol);
FC2D_translate(C2D,E,F,EF);
pc2df->SetPC(C2D,f2d,l2d,tol);
return C2D;
}
#ifdef DRAW
if (TopOpeBRepTool_GettraceC2D()) {
cout<<"\n#FC2D_CurveOnSurface : "<<endl;
TCollection_AsciiString fnam("c2df");GLOBAL_C2D_i++;fnam=fnam+GLOBAL_C2D_i;FDRAW_DINS("",F,fnam,"");
TCollection_AsciiString enam("c2de");GLOBAL_C2D_i++;enam=enam+GLOBAL_C2D_i;FDRAW_DINE(" ",E,enam,"\n");
cout.flush();debc2dnull();
}
#endif
C2D = FC2D_make2d(E,F,EF,f2d,l2d,tol,trim3d);
FC2D_AddNewCurveOnSurface(C2D,E,F,f2d,l2d,tol);
return C2D;
}

View File

@@ -0,0 +1,25 @@
// File: TopOpeBRepTool_2d.hxx
// Created: Mon Mar 23 17:13:14 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_2d_HeaderFile
#define _TopOpeBRepTool_2d_HeaderFile
#include <Geom2d_Curve.hxx>
#include <TopOpeBRepTool_define.hxx>
Standard_EXPORT Standard_Integer FC2D_Prepare(const TopoDS_Shape& S1,const TopoDS_Shape& S2);
Standard_EXPORT Standard_Boolean FC2D_HasC3D(const TopoDS_Edge& E);
Standard_EXPORT Standard_Boolean FC2D_HasCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F);
Standard_EXPORT Standard_Boolean FC2D_HasOldCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D,Standard_Real& f,Standard_Real& l,Standard_Real& tol);
Standard_EXPORT Standard_Boolean FC2D_HasOldCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D);
Standard_EXPORT Standard_Boolean FC2D_HasNewCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D,Standard_Real& f,Standard_Real& l,Standard_Real& tol);
Standard_EXPORT Standard_Boolean FC2D_HasNewCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Handle(Geom2d_Curve)& C2D);
Standard_EXPORT Handle(Geom2d_Curve) FC2D_CurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f,Standard_Real& l,Standard_Real& tol,const Standard_Boolean trim3d = Standard_False);
Standard_EXPORT Handle(Geom2d_Curve) FC2D_CurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,const TopoDS_Edge& EF,Standard_Real& f,Standard_Real& l,Standard_Real& tol,const Standard_Boolean trim3d = Standard_False);
//modified by NIZHNY-MZV
Standard_EXPORT Handle(Geom2d_Curve) FC2D_MakeCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f,Standard_Real& l,Standard_Real& tol,const Standard_Boolean trim3d = Standard_False);
Standard_EXPORT Handle(Geom2d_Curve) FC2D_EditableCurveOnSurface(const TopoDS_Edge& E,const TopoDS_Face& F,Standard_Real& f,Standard_Real& l,Standard_Real& tol,const Standard_Boolean trim3d = Standard_False);
Standard_EXPORT Standard_Integer FC2D_AddNewCurveOnSurface(Handle(Geom2d_Curve) PC,const TopoDS_Edge& E,const TopoDS_Face& F,const Standard_Real& f,const Standard_Real& l,const Standard_Real& tol);
Standard_EXPORT Standard_Integer FC2D_RemNewCurveOnSurface(Handle(Geom2d_Curve) PC,const TopoDS_Edge& E,const TopoDS_Face& F);
#endif

View File

@@ -0,0 +1,38 @@
-- File: TopOpeBRepTool_AncestorsTool.cdl
-- Created: Thu Aug 12 16:35:21 1993
-- Author: Jean Yves LEBEY
-- <jyl@phobox>
---Copyright: Matra Datavision 1993
class AncestorsTool from TopOpeBRepTool
-- as AncestorsTool from TopOpeInter
-- (Shape from TopoDS,
-- IndexedDataMapOfShapeListOfShape from TopTools)
---Purpose: Describes the ancestors tool needed by
-- the class DSFiller from TopOpeInter.
--
-- This class has been created because it is not possible
-- to instantiate the argument TheAncestorsTool (of
-- DSFiller from TopOpeInter) with a package (TopExp)
-- giving services as package methods.
uses
Shape from TopoDS,
ShapeEnum from TopAbs,
IndexedDataMapOfShapeListOfShape from TopTools
is
MakeAncestors(myclass;
S : Shape from TopoDS;
TS : ShapeEnum from TopAbs;
TA : ShapeEnum from TopAbs;
M : in out IndexedDataMapOfShapeListOfShape from TopTools);
---Purpose: same as package method TopExp::MapShapeListOfShapes()
end AncestorsTool;

View File

@@ -0,0 +1,24 @@
// File: TopOpeBRepTool_AncestorsTool.cxx
// Created: Thu Aug 12 16:46:45 1993
// Author: Jean Yves LEBEY
// <jyl@phobox>
#include <TopOpeBRepTool_AncestorsTool.ixx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
//=======================================================================
//function : MakeAncestors
//purpose :
//=======================================================================
void TopOpeBRepTool_AncestorsTool::MakeAncestors
(const TopoDS_Shape& S,
const TopAbs_ShapeEnum TS,
const TopAbs_ShapeEnum TA,
TopTools_IndexedDataMapOfShapeListOfShape& M)
{
TopExp::MapShapesAndAncestors(S,TS,TA,M);
}

View File

@@ -0,0 +1,57 @@
-- File: TopOpeBRepTool_BoxSort.cdl
-- Created: Thu Jul 8 12:12:04 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class BoxSort from TopOpeBRepTool
uses
Box from Bnd,
BoundSortBox from Bnd,
HArray1OfBox from Bnd,
HArray1OfInteger from TColStd,
ListOfInteger from TColStd,
ListIteratorOfListOfInteger from TColStd,
ShapeEnum from TopAbs,
Shape from TopoDS,
IndexedMapOfShape from TopTools,
Box from Bnd,
HBoxTool from TopOpeBRepTool
is
Create returns BoxSort;
Create(T:HBoxTool) returns BoxSort;
SetHBoxTool(me:in out;T:HBoxTool);
HBoxTool(me) returns HBoxTool;---C++: return const &
Clear(me:in out);
AddBoxes(me:in out;S:Shape;TS:ShapeEnum;TA:ShapeEnum=TopAbs_SHAPE);
MakeHAB(me:in out;S:Shape;TS:ShapeEnum;TA:ShapeEnum=TopAbs_SHAPE);
HAB(me) returns HArray1OfBox from Bnd;---C++:return const &
MakeHABCOB(myclass;HAB:HArray1OfBox from Bnd;COB:out Box from Bnd);
HABShape(me; I:Integer) returns Shape;---C++: return const &
MakeCOB(me:in out;S:Shape;TS:ShapeEnum;TA:ShapeEnum=TopAbs_SHAPE);
AddBoxesMakeCOB(me:in out;S:Shape;TS:ShapeEnum;TA:ShapeEnum=TopAbs_SHAPE);
Compare(me:out;S:Shape) returns ListIteratorOfListOfInteger;---C++:return const&
TouchedShape(me;I:ListIteratorOfListOfInteger) returns Shape;---C++:return const&
Box(me;S:Shape) returns Box from Bnd;---C++:return const &
--modified by NIZNHY-PKV Mon Dec 16 10:24:42 2002 f
Destroy(me: out);
---C++: alias "Standard_EXPORT ~TopOpeBRepTool_BoxSort() {Destroy();}"
--modified by NIZNHY-PKV Mon Dec 16 10:25:22 2002 t
fields
myCOB:Box from Bnd;
myBSB:BoundSortBox from Bnd;
myIterator:ListIteratorOfListOfInteger from TColStd;
myLastCompareShape:Shape from TopoDS;
myLastCompareShapeBox:Box from Bnd;
myHBT:HBoxTool from TopOpeBRepTool;
myHAB:HArray1OfBox from Bnd;
myHAI:HArray1OfInteger from TColStd;
end BoxSort;

View File

@@ -0,0 +1,310 @@
// File: TopOpeBRepTool_BoxSort.cxx
// Created: Mon Jul 12 16:33:26 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepTool_BoxSort.ixx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Geom_Surface.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <gp_Pln.hxx>
#include <TopOpeBRepTool_box.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <Standard_ProgramError.hxx>
#ifdef DEB
#define TBOX TopOpeBRepTool_GettraceBOX()
#endif
#define MTOhbt Handle(TopOpeBRepTool_HBoxTool)
#define MTClioloi TColStd_ListIteratorOfListOfInteger
//=======================================================================
//function : TopOpeBRepTool_BoxSort
//purpose :
//=======================================================================
TopOpeBRepTool_BoxSort::TopOpeBRepTool_BoxSort()
{
}
//=======================================================================
//function : TopOpeBRepTool_BoxSort
//purpose :
//=======================================================================
TopOpeBRepTool_BoxSort::TopOpeBRepTool_BoxSort(const MTOhbt& HBT)
{
SetHBoxTool(HBT);
}
//modified by NIZNHY-PKV Mon Dec 16 10:26:00 2002 f
//=======================================================================
//function : Destroy
//purpose : alias ~TopOpeBRepTool_BoxSort
//=======================================================================
void TopOpeBRepTool_BoxSort::Destroy()
{
if (!myHBT.IsNull()) {
myHBT->Clear();
}
}
//modified by NIZNHY-PKV Mon Dec 16 10:26:02 2002 t
//=======================================================================
//function : SetHBoxTool
//purpose :
//=======================================================================
void TopOpeBRepTool_BoxSort::SetHBoxTool(const MTOhbt& HBT)
{
myHBT = HBT;
}
//=======================================================================
//function : HBoxTool
//purpose :
//=======================================================================
const MTOhbt& TopOpeBRepTool_BoxSort::HBoxTool() const
{
return myHBT;
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TopOpeBRepTool_BoxSort::Clear()
{
myCOB.SetVoid();
// myHAB.Nullify();
// myHAI.Nullify();
}
//=======================================================================
//function : AddBoxes
//purpose :
//=======================================================================
void TopOpeBRepTool_BoxSort::AddBoxes(const TopoDS_Shape& S,const TopAbs_ShapeEnum TS,const TopAbs_ShapeEnum TA)
{
if (myHBT.IsNull()) myHBT = new TopOpeBRepTool_HBoxTool();
myHBT->AddBoxes(S,TS,TA);
}
//=======================================================================
//function : MakeHAB
//purpose :
//=======================================================================
void TopOpeBRepTool_BoxSort::MakeHAB(const TopoDS_Shape& S,const TopAbs_ShapeEnum TS,const TopAbs_ShapeEnum TA)
{
#ifdef DEB
TopAbs_ShapeEnum t =
#endif
S.ShapeType();
Standard_Integer n = 0; TopExp_Explorer ex;
for (ex.Init(S,TS,TA);ex.More();ex.Next()) n++;
myHAB = new Bnd_HArray1OfBox(0,n);
Bnd_Array1OfBox& AB = myHAB->ChangeArray1();
myHAI = new TColStd_HArray1OfInteger(0,n);
TColStd_Array1OfInteger& AI = myHAI->ChangeArray1();
Standard_Integer i = 0;
for (ex.Init(S,TS,TA);ex.More();ex.Next()) {
i++;
const TopoDS_Shape& ss = ex.Current();
Standard_Boolean hb = myHBT->HasBox(ss);
if (!hb) myHBT->AddBox(ss);
Standard_Integer im = myHBT->Index(ss);
const Bnd_Box& B = myHBT->Box(ss);
AI.ChangeValue(i) = im;
AB.ChangeValue(i) = B;
}
#ifdef DEB
if (TBOX) {
cout<<"# BS::MakeHAB : ";TopAbs::Print(t,cout);cout<<" : "<<n<<"\n";
cout.flush();
}
#endif
}
//=======================================================================
//function : HAB
//purpose :
//=======================================================================
const Handle(Bnd_HArray1OfBox)& TopOpeBRepTool_BoxSort::HAB() const
{
return myHAB;
}
//=======================================================================
//function : MakeHABCOB
//purpose :
//=======================================================================
void TopOpeBRepTool_BoxSort::MakeHABCOB(const Handle(Bnd_HArray1OfBox)& HAB,
Bnd_Box& COB)
{
COB.SetVoid();
Standard_Integer n = HAB->Upper();
const Bnd_Array1OfBox& AB = HAB->Array1();
for (Standard_Integer i = 1; i <= n; i++) {
const Bnd_Box& B = AB(i);
COB.Add(B);
}
}
//=======================================================================
//function : HABShape
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepTool_BoxSort::HABShape(const Standard_Integer I) const
{
Standard_Integer iu = myHAI->Upper();
Standard_Boolean b = (I >= 1 && I <= iu);
if (!b) {
Standard_ProgramError::Raise("BS::Box3");
}
Standard_Integer im = myHAI->Value(I);
const TopoDS_Shape& S = myHBT->Shape(im);
return S;
}
//=======================================================================
//function : MakeCOB
//purpose :
//=======================================================================
void TopOpeBRepTool_BoxSort::MakeCOB(const TopoDS_Shape& S,const TopAbs_ShapeEnum TS,const TopAbs_ShapeEnum TA)
{
MakeHAB(S,TS,TA);
MakeHABCOB(myHAB,myCOB);
myBSB.Initialize(myCOB,myHAB);
#ifdef DEB
if (TBOX) {myHBT->DumpB(myCOB);cout<<";# BS::MakeCOB"<<endl;}
#endif
}
//=======================================================================
//function : AddBoxesMakeCOB
//purpose :
//=======================================================================
void TopOpeBRepTool_BoxSort::AddBoxesMakeCOB(const TopoDS_Shape& S,const TopAbs_ShapeEnum TS,const TopAbs_ShapeEnum TA)
{
AddBoxes(S,TS,TA);
MakeCOB(S,TS,TA);
}
//=======================================================================
//function : Compare
//purpose :
//=======================================================================
const MTClioloi& TopOpeBRepTool_BoxSort::Compare(const TopoDS_Shape &S)
{
if ( myHBT.IsNull() ) myHBT = new TopOpeBRepTool_HBoxTool();
gp_Pln P;
Standard_Boolean isPlane = Standard_False;
TopAbs_ShapeEnum t = S.ShapeType();
Standard_Boolean hasb = myHBT->HasBox(S);
if (!hasb) myHBT->AddBox(S);
myLastCompareShape = S;
myLastCompareShapeBox.SetVoid();
if ( t == TopAbs_FACE) {
const TopoDS_Face& F = TopoDS::Face(S);
Standard_Boolean natu = BRep_Tool::NaturalRestriction(F);
if (natu) {
Handle(Geom_Surface) surf = BRep_Tool::Surface(F);
GeomAdaptor_Surface GAS(surf);
GeomAbs_SurfaceType suty = GAS.GetType();
isPlane = (suty == GeomAbs_Plane);
if (isPlane) P = GAS.Plane();
else {
myLastCompareShapeBox = myHBT->Box(F);
}
}
else {
myLastCompareShapeBox = myHBT->Box(F);
}
}
else if (t == TopAbs_EDGE) {
const TopoDS_Edge& E = TopoDS::Edge(S);
TopoDS_Vertex V1,V2; TopExp::Vertices(E,V1,V2);
Standard_Boolean perso = (V1.IsNull() || V2.IsNull());
if (perso) {
myHBT->ComputeBoxOnVertices(E,myLastCompareShapeBox);
}
else {
myLastCompareShapeBox = myHBT->Box(E);
}
}
const TColStd_ListOfInteger* L;
if (isPlane) L = &myBSB.Compare(P);
else L = &myBSB.Compare(myLastCompareShapeBox);
myIterator.Initialize(*L);
#ifdef DEB
if (TBOX) {
Standard_Integer nl = (*L).Extent();
cout<<"#------------------------"<<endl;
myHBT->DumpB(myLastCompareShapeBox);cout<<"; # BS::Compare"<<endl;
cout<<"# touche "<<nl<<" boites ";cout.flush();
Standard_Integer il;
for (MTClioloi idd((*L));idd.More();idd.Next()) {
il=idd.Value();cout<<il<<" ";cout.flush();
}
cout<<endl<<"#------------------------"<<endl;
}
#endif
return myIterator;
}
//=======================================================================
//function : TouchedShape
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepTool_BoxSort::TouchedShape(const MTClioloi& LI) const
{
Standard_Integer icur = LI.Value();
const TopoDS_Shape& Scur = HABShape(icur);
return Scur;
}
//=======================================================================
//function : Box
//purpose :
//=======================================================================
const Bnd_Box& TopOpeBRepTool_BoxSort::Box(const TopoDS_Shape& S) const
{
if ( myHBT.IsNull() ) {
*((MTOhbt*)&myHBT) = new TopOpeBRepTool_HBoxTool();
}
if ( myHBT->HasBox(S) ) {
#ifdef DEB
Standard_Integer i =
#endif
myHBT->Index(S);
const Bnd_Box& B = myHBT->Box(S);
return B;
}
else if ( !myLastCompareShape.IsNull() ) {
if ( S.IsEqual(myLastCompareShape) ) {
if ( !myLastCompareShapeBox.IsVoid() ) {
return myLastCompareShapeBox;
}
}
}
const Bnd_Box& B = myHBT->Box(S);
return B;
}

View File

@@ -0,0 +1,34 @@
-- File: TopOpeBRepTool_C2DF.cdl
-- Created: Mon Mar 23 17:06:15 1998
-- Author: Jean Yves LEBEY
-- <jyl@langdox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class C2DF from TopOpeBRepTool
uses
Curve from Geom2d,
Face from TopoDS
is
Create returns C2DF from TopOpeBRepTool;
Create(PC : Curve from Geom2d; f2d,l2d,tol : Real; F : Face from TopoDS)
returns C2DF from TopOpeBRepTool;
SetPC(me : in out;PC : Curve from Geom2d; f2d,l2d,tol : Real);
SetFace(me : in out; F : Face from TopoDS);
PC(me; f2d,l2d,tol : out Real) returns Curve from Geom2d;
---C++: return const &
Face(me) returns Face from TopoDS;
---C++: return const &
IsPC(me;PC:Curve from Geom2d) returns Boolean;
IsFace(me;F:Face from TopoDS) returns Boolean;
fields
myPC : Curve from Geom2d;
myf2d,myl2d,mytol : Real;
myFace : Face from TopoDS;
end C2DF;

View File

@@ -0,0 +1,91 @@
// File: TopOpeBRepTool_C2DF.cxx
// Created: Mon Mar 23 17:14:26 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_C2DF.ixx>
#include <TopOpeBRepTool_define.hxx>
//=======================================================================
//function : TopOpeBRepTool_C2DF
//purpose :
//=======================================================================
TopOpeBRepTool_C2DF::TopOpeBRepTool_C2DF() {}
//=======================================================================
//function : TopOpeBRepTool_C2DF
//purpose :
//=======================================================================
TopOpeBRepTool_C2DF::TopOpeBRepTool_C2DF
(const Handle(Geom2d_Curve)& PC,const Standard_Real f2d,const Standard_Real l2d,const Standard_Real tol,const TopoDS_Face& F)
{
myPC = PC;myf2d = f2d;myl2d = l2d;mytol = tol;
myFace = F;
}
//=======================================================================
//function : SetPC
//purpose :
//=======================================================================
void TopOpeBRepTool_C2DF::SetPC
(const Handle(Geom2d_Curve)& PC,const Standard_Real f2d,const Standard_Real l2d,const Standard_Real tol)
{
myPC = PC;myf2d = f2d;myl2d = l2d;mytol = tol;
}
//=======================================================================
//function : SetFace
//purpose :
//=======================================================================
void TopOpeBRepTool_C2DF::SetFace(const TopoDS_Face& F)
{
myFace = F;
}
//=======================================================================
//function : PC
//purpose :
//=======================================================================
const Handle(Geom2d_Curve)& TopOpeBRepTool_C2DF::PC(Standard_Real& f2d,Standard_Real& l2d,Standard_Real& tol) const
{
f2d = myf2d;l2d = myl2d;tol = mytol;
return myPC;
}
//=======================================================================
//function : Face
//purpose :
//=======================================================================
const TopoDS_Face& TopOpeBRepTool_C2DF::Face() const
{
return myFace;
}
//=======================================================================
//function : IsPC
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_C2DF::IsPC(const Handle(Geom2d_Curve)& PC) const
{
Standard_Boolean b = (PC == myPC);
return b;
}
//=======================================================================
//function : IsFace
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_C2DF::IsFace(const TopoDS_Face& F) const
{
Standard_Boolean b = (F.IsEqual(myFace));
return b;
}

View File

@@ -0,0 +1,72 @@
-- File: TopOpeBRepTool_CLASSI.cdl
-- Created: Wed Jan 13 14:43:00 1999
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class CLASSI from TopOpeBRepTool
uses
Shape from TopoDS,
Face from TopoDS,
Box2d from Bnd,
ListOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools,
face from TopOpeBRepTool,
IndexedDataMapOfShapeBox2d from TopOpeBRepTool,
DataMapOfShapeface from TopOpeBRepTool
is
Create returns CLASSI from TopOpeBRepTool;
Init2d(me : in out; Fref : Face from TopoDS);
-- prequesitory : <Fref> is oriented FORWARD
HasInit2d(me) returns Boolean;
Add2d(me : in out; S : Shape from TopoDS)
returns Boolean;
-- Compute of 2d bounding boxe for shape <S>, stores the box in
-- the map
GetBox2d(me : in out; S : Shape from TopoDS; Box2d : out Box2d from Bnd)
returns Boolean;
-- Compute of <Box2d> 2d bounding boxe for shape <S> if necessary (then
-- stores it in the map).
ClassiBnd2d(me : in out; S1,S2 : Shape from TopoDS; tol: Real; checklarge: Boolean)
returns Integer;
-- Classification of 2drep(S1) with 2drep(S2) using their 2d bounding boxes
-- if shapes are not stored in <mymapsbox2d>, compute the bounding boxes
-- then stores them.
-- Returns state : 0 : unknown
-- -1 : same
-- -2 : disjoints
-- 1 : <S1> IN <S2>
-- 2 : <S2> IN <S1>
Classip2d(me : in out; S1,S2 : Shape from TopoDS; stabnd2d12 : Integer)
returns Integer;
-- prequesitory : <S1> and <S2> are disjoint or connexed by
-- vertices or edges,
-- and classify(<S1>,<S2>) is in {0,-2,1,2}
-- Classification of 2drep(S1) with 2drep(S2), using <stabnd2d12>
-- (from ClassiBnd2d)
-- update for <mymapsface>
Getface(me; S : Shape from TopoDS; fa : out face from TopOpeBRepTool)
returns Boolean;
-- Returns false if <S> is not bound in <mymapsface>
Classilist(me : in out; lS : ListOfShape from TopTools;
mapgreasma : out DataMapOfShapeListOfShape from TopTools)
returns Boolean;
-- prequesitory : <lS> contains a list of wires built on <myFref>
--
-- Classification of wires of <lS>, filling up map <mapgreasma>
-- <mapgreasma> = {(s,los) / shapes of los are IN s}
fields
myFref : Face from TopoDS;
mymapsbox2d : IndexedDataMapOfShapeBox2d from TopOpeBRepTool;
mymapsface : DataMapOfShapeface from TopOpeBRepTool;
end CLASSI;

View File

@@ -0,0 +1,434 @@
// File: TopOpeBRepTool_CLASS.cxx
// Created: Wed Jan 13 15:05:38 1999
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_CLASSI.ixx>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <TopExp_Explorer.hxx>
#include <Bnd_Array1OfBox2d.hxx>
#include <Bnd_Box2d.hxx>
#include <TColStd_Array2OfReal.hxx>
#include <BndLib_Add2dCurve.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <BRepClass3d_SolidExplorer.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#define SAME (-1)
#define DIFF (-2)
#define UNKNOWN ( 0)
#define oneINtwo ( 1)
#define twoINone ( 2)
#define M_IN(st ) (st == TopAbs_IN )
#define M_OUT(st) (st == TopAbs_OUT)
//=======================================================================
//function : TopOpeBRepTool_CLASSI
//purpose :
//=======================================================================
TopOpeBRepTool_CLASSI::TopOpeBRepTool_CLASSI()
{
}
//=======================================================================
//function : Init2d
//purpose :
//=======================================================================
void TopOpeBRepTool_CLASSI::Init2d(const TopoDS_Face& Fref)
{
myFref = Fref;
}
//=======================================================================
//function : HasInit2d
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_CLASSI::HasInit2d() const
{
return (!myFref.IsNull());
}
//=======================================================================
//function : Add2d
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_CLASSI::Add2d(const TopoDS_Shape& S)
{
if (!HasInit2d()) return Standard_False;
Standard_Boolean isb = mymapsbox2d.Contains(S);
if (isb) return Standard_True;
Bnd_Box2d B2d;
TopExp_Explorer exe(S, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Edge& E = TopoDS::Edge(exe.Current());
Standard_Real tolE = BRep_Tool::Tolerance(E);
Standard_Boolean haspc = FC2D_HasCurveOnSurface(E,myFref);
if (!haspc) return Standard_False;
BRepAdaptor_Curve2d BC2d(E,myFref);
Standard_Real tol2d = BC2d.Resolution(tolE);
BndLib_Add2dCurve::Add(BC2d,tol2d,B2d);
}
mymapsbox2d.Add(S,B2d);
return Standard_True;
}
//=======================================================================
//function : GetBox2d
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_CLASSI::GetBox2d(const TopoDS_Shape& S, Bnd_Box2d& B2d)
{
Standard_Boolean isb = mymapsbox2d.Contains(S);
if (!isb) isb = Add2d(S);
if (!isb) return Standard_False;
B2d = mymapsbox2d.FindFromKey(S);
return Standard_True;
}
//=======================================================================
//function : ClassiBnd2d
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_CLASSI::ClassiBnd2d(const TopoDS_Shape& S1,const TopoDS_Shape& S2,
const Standard_Real tol,const Standard_Boolean chklarge)
{
Bnd_Array1OfBox2d B(1,2);
Standard_Boolean isb = mymapsbox2d.Contains(S1);
if (!isb) isb = Add2d(S1);
if (!isb) return Standard_False;
B(1) = mymapsbox2d.FindFromKey(S1);
isb = mymapsbox2d.Contains(S2);
if (!isb) isb = Add2d(S2);
if (!isb) return Standard_False;
B(2) = mymapsbox2d.FindFromKey(S2);
TColStd_Array2OfReal UV(1,2, 1,4);
// for (Standard_Integer i = 1; i <= 2; i++)
Standard_Integer i ;
for ( i = 1; i <= 2; i++)
// (Umin(i), Vmin(i), Umax(i), Vmax(i))
B(i).Get(UV(i,1), UV(i,3), UV(i,2), UV(i,4));
#ifdef DEB
Standard_Boolean trc = Standard_False;
if (trc) {
for (Standard_Integer i = 1; i <= 2; i++)
cout<<"B("<<i<<") = ("<<UV(i,1)<<" "<<UV(i,3)<<" "<<UV(i,2)<<" "<<UV(i,4)<<")"<<endl;
}
#endif
for (Standard_Integer k = 1; k <= 3; k+=2) {
for (i = 1; i <= 2; i++) {
Standard_Integer ii = i, jj = (i == 1) ? 2 : 1;
// diff = Umin<ii> - Umax<jj> : k = 1
// diff = Vmin<ii> - Vmax<jj> : k = 3
Standard_Real diff = UV(ii,k) - UV(jj,k+1);
// IMPORTANT : for splitted faces sharing same edge, use
// chklarge = True.
Standard_Boolean disjoint = chklarge ? (diff >= -tol) : (diff > 0.);
if (disjoint) return DIFF;
}
}
for (i = 1; i <= 2; i++) {
// comparing Bnd2d(ii) with Bnd2d(jj)
Standard_Integer ii = i, jj = (i == 1) ? 2 : 1;
Standard_Boolean smaller=Standard_True, same=Standard_True;
// for (Standard_Integer k = 1; k <= 3; k += 2){
Standard_Integer k ;
for ( k = 1; k <= 3; k += 2){
// diff = Umin<ii> - Umin<jj> : k = 1
// diff = Vmin<ii> - Vmin<jj> : k = 3
Standard_Real diff = UV(ii,k) - UV(jj,k);
smaller = chklarge ? (smaller && (diff > -tol)) : (smaller && (diff > 0.));
same = same && (Abs(diff) <= tol);
}
for (k = 2; k <= 4; k +=2){
// diff = Umax<ii> - Umax<jj> : k = 2
// diff = Vmax<ii> - Vmax<jj> : k = 4
Standard_Real diff = UV(ii,k) - UV(jj,k);
smaller = chklarge ? (smaller && (diff < tol)) : (smaller && (diff < 0.));
same = same && (Abs(diff) <= tol);
}
if (same) return SAME;
if (smaller) {
Standard_Integer sta = (ii==1) ? oneINtwo : twoINone;
return sta;
}
}
return UNKNOWN;
}
static Standard_Integer FUN_thegreatest(const TopoDS_Face& F1, BRepClass_FaceClassifier& class2)
// prequesitory : p2d1 IN f2, p2d2 IN f1
// class2 for f2
// returns oneINtwo || twoINone || UNKNOWN
{
TopExp_Explorer ex1(F1, TopAbs_EDGE);
Standard_Real tolf1 = BRep_Tool::Tolerance(F1);
for (; ex1.More(); ex1.Next()){
const TopoDS_Edge& e1 = TopoDS::Edge(ex1.Current());
Standard_Real f1,l1; FUN_tool_bounds(e1,f1,l1);
Standard_Real x= 0.45678; Standard_Real p1 = (1-x)*f1+x+l1;
gp_Pnt2d uv1; Standard_Boolean ok1 = FUN_tool_paronEF(e1,p1,F1,uv1,tolf1);
if (!ok1) continue;
TopAbs_State sta12 = class2.State();
if (M_IN(sta12) ) return oneINtwo;
else if (M_OUT(sta12)) return twoINone;
}
return UNKNOWN;
}
//=======================================================================
//function : Classip2d
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_CLASSI::Classip2d(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
const Standard_Integer stabnd2d12)
{
if (!HasInit2d()) return UNKNOWN;
Standard_Boolean bnd2dUNK = (stabnd2d12 == UNKNOWN)||(stabnd2d12 == SAME);
// fa1,ffi1,finite1 :
TopOpeBRepTool_face fa1;
Standard_Boolean isb1 = mymapsface.IsBound(S1);
if (isb1) fa1 = mymapsface.Find(S1);
else {
Standard_Boolean ok1 = fa1.Init(TopoDS::Wire(S1), myFref);
if (!ok1) return UNKNOWN;
mymapsface.Bind(S1,fa1);
}
const TopoDS_Face& ffi1 = fa1.Ffinite();
Standard_Boolean finite1 = fa1.Finite();
// fa2,ffi2,finite2 :
TopOpeBRepTool_face fa2;
Standard_Boolean isb2 = mymapsface.IsBound(S2);
if (isb2) fa2 = mymapsface.Find(S2);
else {
Standard_Boolean ok2 = fa2.Init(TopoDS::Wire(S2), myFref);
if (!ok2) return UNKNOWN;
mymapsface.Bind(S2,fa2);
}
const TopoDS_Face& ffi2 = fa2.Ffinite();
Standard_Boolean finite2 = fa2.Finite();
// p2d1 :
Standard_Real u1,v1; Standard_Boolean ok1 = BRepClass3d_SolidExplorer::FindAPointInTheFace(ffi1,u1,v1);
if (!ok1) return UNKNOWN;
gp_Pnt2d p2d1(u1,v1);
// sta12 = status(p2d1 / ffi2) :
// recall : ffi1 and ffi2 are built on same face
// => ffi1(u1,v1) = ffi2(u1,v1)
// ----------------------------
Standard_Real tol2d2 = TopOpeBRepTool_TOOL::TolUV(ffi2,BRep_Tool::Tolerance(ffi2));
BRepClass_FaceClassifier class2(ffi2,p2d1,tol2d2);
TopAbs_State sta12 = class2.State();
// staffi12 : only if !bnd2dUNK and stabnd2d12!=DIFF
// PREQUESITORY : the only possible situations are
// - ffi1 IN ffi2
// - ffi2 IN ffi1
// - ffi1 and ffi2 are distinct
Standard_Integer staffi12 = UNKNOWN;
Standard_Boolean try21 = Standard_False;
if (bnd2dUNK) {
try21 = Standard_True;
}
else if (stabnd2d12 == DIFF) {
return DIFF;
}
else {
if (sta12 == TopAbs_IN) {// 2 possible states : oneINtwo || twoINone
if (stabnd2d12 == oneINtwo) staffi12 = oneINtwo; //Bnd2d(S1) IN Bnd2d(S2)
else if (stabnd2d12 == twoINone) staffi12 = twoINone; //Bnd2d(S2) IN Bnd2d(S1)
else try21 = Standard_True;
}
else if (sta12 == TopAbs_OUT) {// 2 possible states : twoINone || DIFF
if (stabnd2d12 == twoINone) staffi12 = twoINone;
// else if (stabnd2d12 == DIFF) staffi12 = DIFF;
else try21 = Standard_True;
}
else return UNKNOWN; // NYIxpu140199
}
if (try21) {
// p2d2 :
Standard_Real u2,v2; Standard_Boolean ok2 = BRepClass3d_SolidExplorer::FindAPointInTheFace(ffi2,u2,v2);
if (!ok2) return UNKNOWN;
gp_Pnt2d p2d2(u2,v2);
// sta21 :
Standard_Real tol2d1 = TopOpeBRepTool_TOOL::TolUV(ffi1,BRep_Tool::Tolerance(ffi1));
BRepClass_FaceClassifier class1(ffi1,p2d2,tol2d1);
TopAbs_State sta21 = class1.State();
if (bnd2dUNK) {
if (M_OUT(sta12)&& M_OUT(sta21)) staffi12 = DIFF;
else if (M_IN(sta12) && M_OUT(sta21)) staffi12 = oneINtwo;
else if (M_OUT(sta12)&& M_IN(sta21) ) staffi12 = twoINone;
else if (M_IN(sta12) && M_IN(sta21) ) staffi12 = ::FUN_thegreatest(ffi1,class2);
}
else {
if (sta12 == TopAbs_IN) {// 2 possible states : oneINtwo || twoINone
if (sta21 == TopAbs_OUT) staffi12 = oneINtwo;
}
else if (sta12 == TopAbs_OUT) {// 2 possible states : twoINone || DIFF
if (sta21 == TopAbs_OUT) staffi12 = DIFF;
else if (sta21 == TopAbs_IN) staffi12 = twoINone;
}
else return UNKNOWN; // NYIxpu140199
}
}//try21
// classif(S1,S2) knowing staffi12, finite, finite2 :
if (staffi12 == DIFF) {
if (finite1 && finite2) return DIFF;
if (finite1 && !finite2) return twoINone;
if (!finite1 && finite2) return oneINtwo;
return oneINtwo; // !!!!!!! or twoINone
}
else if (staffi12 == oneINtwo) {
if (!finite1 && !finite2) return twoINone;
return oneINtwo;
}
else if (staffi12 == twoINone) {
if (!finite1 && !finite2) return oneINtwo;
return twoINone;
}
return UNKNOWN;
}
//=======================================================================
//function : Getface
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_CLASSI::Getface(const TopoDS_Shape& S, TopOpeBRepTool_face& fa) const
{
Standard_Boolean isb = mymapsface.IsBound(S);
if (!isb) return Standard_False;
fa = mymapsface.Find(S);
return Standard_True;
}
//=======================================================================
//function : Classilist
//purpose :
//=======================================================================
Standard_EXPORT void FUN_addOwlw(const TopoDS_Shape& Ow, const TopTools_ListOfShape& lw, TopTools_ListOfShape& lresu)
{
Standard_Integer nw = lw.Extent();
if (nw == 0) lresu.Append(Ow);
else {
TopTools_ListIteratorOfListOfShape it(lw);
for (; it.More(); it.Next()) lresu.Append(it.Value());
}
}
Standard_Boolean TopOpeBRepTool_CLASSI::Classilist(const TopTools_ListOfShape& lS, TopTools_DataMapOfShapeListOfShape& mapgreasma)
{
Standard_Real tolref = BRep_Tool::Tolerance(myFref);
Standard_Real toluv = TopOpeBRepTool_TOOL::TolUV(myFref,tolref);//nyixpu : cdliser??
TopTools_ListOfShape null;
TopTools_ListOfShape lw; lw.Assign(lS);
mapgreasma.Clear();
TopTools_ListIteratorOfListOfShape itw(lS);
for (; itw.More(); itw.Next()) mapgreasma.Bind(itw.Value(),null);
Standard_Integer nw = lw.Extent();
if (nw <= 1) return Standard_True;
Standard_Integer nite = 0, nitemax = Standard_Integer(nw*(nw-1)/2);
while (nite <= nitemax){
nw = lw.Extent();
if (nw <= 1) break;
// wi1 :
TopoDS_Shape wi1;
TopTools_ListIteratorOfListOfShape itw(lw);
for (; itw.More(); itw.Next()){
wi1 = itw.Value();
Standard_Boolean isb1 = mapgreasma.IsBound(wi1);
if (!isb1) continue; // wi1 stored as smaller shape
break;
}
while (itw.More()) {// compare wi1 with all wi(k) (k>1)
Standard_Boolean isb1 = mapgreasma.IsBound(wi1);
if (!isb1) break;
itw.Next();
if (!itw.More()) break;
// wi2, sta12 :
Standard_Integer sta12 = UNKNOWN;
Standard_Boolean OUTall = Standard_False;
TopoDS_Shape wi2;
for (; itw.More(); itw.Next()){
wi2 = itw.Value();
Standard_Boolean isb2 = mapgreasma.IsBound(wi2);
if (!isb2) continue;
Standard_Integer stabnd2d12 = ClassiBnd2d(wi1,wi2,toluv,Standard_True);
sta12 = Classip2d(wi1,wi2, stabnd2d12);
if (sta12 == DIFF) {OUTall = Standard_True; continue;}
break;
}
// mapgreasma :
if (sta12 == oneINtwo) {//greater = shape two
TopTools_ListOfShape& lwgre = mapgreasma.ChangeFind(wi2);
TopTools_ListOfShape lsma; FUN_addOwlw(wi1,mapgreasma.Find(wi1),lsma);
mapgreasma.UnBind(wi1);
lwgre.Append(lsma);
}
else if (sta12 == twoINone) {//greater = shape one
TopTools_ListOfShape& lwgre = mapgreasma.ChangeFind(wi1);
TopTools_ListOfShape lsma; FUN_addOwlw(wi2,mapgreasma.Find(wi2),lsma);
mapgreasma.UnBind(wi2);
lwgre.Append(lsma);
}
else if (OUTall) {
// nothing's done
}
else return Standard_False;
}//itw.More()
lw.RemoveFirst();
}//nite<=nmax
return Standard_True;
}

View File

@@ -0,0 +1,188 @@
-- File: TopOpeBRepTool_CORRISO.cdl
-- Created: Wed Nov 25 10:51:34 1998
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class CORRISO from TopOpeBRepTool
--- Purpose : Fref is built on x-periodic surface (x=u,v).
-- S built on Fref's geometry, should be UVClosed.
--
-- Give us E, an edge of S. 2drep(E) is not UV connexed.
-- We translate 2drep(E) in xdir*xperiod if necessary.
--
-- call : TopOpeBRepTool_CORRISO Tool(Fref);
-- Tool.Init(S);
-- if (!Tool.UVClosed()) {
-- // initialize EdsToCheck,nfybounds,stopatfirst
--
-- Tool.EdgeWithFaultyUV(EdsToCheck,nfybounds,FyEds,stopatfirst);
-- if (Tool.SetUVClosed()) S = Tool.GetnewS();
-- }
uses
Surface from GeomAdaptor,
Shape from TopoDS,
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
C2DF from TopOpeBRepTool,
Curve from Geom2d,
ListOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools,
DataMapOfOrientedShapeInteger from TopTools,
DataMapOfOrientedShapeC2DF from TopOpeBRepTool
is
Create returns CORRISO from TopOpeBRepTool;
Create (FRef : Face from TopoDS)
returns CORRISO from TopOpeBRepTool;
Fref (me) returns Face from TopoDS;
---C++: return const &
GASref(me) returns Surface from GeomAdaptor;
---C++: return const &
Refclosed (me; x : Integer; xperiod : out Real)
returns Boolean;
-- Returns true if <Fref>'s geometry is x-periodic,
-- and sets <xperiod> with x-period.
-- x = 1 : returns IsUPeriodic
-- x = 2 : returns IsVPeriodic
Init (me : in out; S : Shape from TopoDS)
returns Boolean;
-- Fills up the lists of 2d representations for edges of <S>.
-- <S> is built on <Fref>'s geometry.
-- Returns false if initialization fails
S(me) returns Shape from TopoDS;
---C++: return const &
Eds(me) returns ListOfShape from TopTools;
-- returns list of edges of S
---C++: return const &
UVClosed(me) returns Boolean;
-- Returns true if S with the current set of 2d representations is UVclosed
Tol(me; I : Integer; tol3d : Real) returns Real;
-- I=1/2 (U/V)
PurgeFyClosingE(me; ClEds : ListOfShape from TopTools; fyClEds : out ListOfShape from TopTools)
returns Boolean;
-- Returns true if we have to delete closing <E> from S
EdgeOUTofBoundsUV(me;
E : Edge from TopoDS;
onU : Boolean;
tolx : Real;
parspE : out Real)
returns Integer;
--
-- Checks if x-2drep(E) is in [xfirst,xfirst+xperiod]
-- ( onU = true/false : x = U/V, Fref must be x-periodic )
--
-- returns 0 : split 2drep(E) on <parspE> of <E>
-- returns 1 : translate 2drep(E) +xperiod*xdir
-- returns -1 : translate 2drep(E) -xperiod*xdir
EdgesOUTofBoundsUV(me;
EdsToCheck : ListOfShape from TopTools;
onU : Boolean;
tolx : Real;
FyEds : out DataMapOfOrientedShapeInteger from TopTools)
returns Boolean;
EdgeWithFaultyUV(me;
E : Edge from TopoDS;
Ivfaulty : out Integer)
returns Boolean;
--
-- <Ivfaulty> = 1,2 : <E> has only one faulty bound
-- 3 : <E> has its 2 bounds faulty
--
-- vertex v bound of edge fye is FAULTY if 2drep(v,fye) is not UV-connexed
--
-- returns true if <E> has faulty bounds
-- false elsewhere.
EdgesWithFaultyUV(me;
EdsToCheck : ListOfShape from TopTools;
nfybounds : Integer;
FyEds : out DataMapOfOrientedShapeInteger from TopTools;
stopatfirst : Boolean = Standard_False)
returns Boolean;
--
-- nfybounds = 1 : get edges with only 1 faulty bound.
-- nfybounds = 2 : get only edges with 2 faulty bounds.
-- nfybounds = 3 : get all edges with faulty bounds.
--
-- <FyEds> is a map (fye, indexfaulty), fye in <EdsToCheck>
-- indexfaulty = 1 : vertex(1,fye) is faulty
-- indexfaulty = 2 : vertex(2,fye) is faulty
-- indexfaulty = 3 : vertex(1,fye), vertex(2,fye) are faulty
--
-- If stopatfirst=true, we stop when first faulty edge is found.
EdgeWithFaultyUV(me;
EdsToCheck : ListOfShape from TopTools;
nfybounds : Integer;
fyE : out Shape from TopoDS; Ifaulty : out Integer)
returns Boolean;
-- Gets first faulty edge
TrslUV(me : in out; onU : Boolean; FyEds : DataMapOfOrientedShapeInteger from TopTools)
returns Boolean;
-- Sets new C2DF for edges of <FyEds>, translates on udir if
-- onU=true, on vdir elsewhere.
-- Returns false if an edge is to split or is not
-- stored.
GetnewS(me; newS : out Face from TopoDS)
returns Boolean;
-- newS : myS with the current 2d representation attached to edges.
-- if myS is not a face, or the compute fails returns false
--
--
--
UVRep (me; E : Edge from TopoDS; C2DF : out C2DF from TopOpeBRepTool)
returns Boolean;
SetUVRep (me : in out; E : Edge from TopoDS; C2DF : C2DF from TopOpeBRepTool)
returns Boolean;
Connexity(me; V : Vertex from TopoDS; Eds : out ListOfShape from TopTools)
returns Boolean;
SetConnexity(me : in out; V : Vertex from TopoDS; Eds : ListOfShape from TopTools)
returns Boolean;
AddNewConnexity(me : in out; V : Vertex from TopoDS; E : Edge from TopoDS)
returns Boolean;
-- Modifies connexities from the input data, adding new connexity to vertex <V>,
-- updates map <myVEds> and maps <myEds>,<myERep2d> if necessary.
-- Returns true if update succeeds.
RemoveOldConnexity(me : in out; V : Vertex from TopoDS; E : Edge from TopoDS)
returns Boolean;
-- Modifies connexities from the input data, removing new connexity for vertex <V>,
-- updates map <myVEds> and maps <myEds>,<myERep2d> if necessary.
-- Returns true if update succeeds.
fields
myFref : Face from TopoDS; -- reference face
myGAS : Surface from GeomAdaptor; -- internal use for tolerances
myUclosed, myVclosed : Boolean;
myUper, myVper : Real;
myS : Shape from TopoDS;
myEds : ListOfShape from TopTools; -- edges of myS
myERep2d : DataMapOfOrientedShapeC2DF from TopOpeBRepTool;
myVEds : DataMapOfShapeListOfShape from TopTools; -- map of connexity vertex,edges
end CORRISO;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,70 @@
-- File: TopOpeBRepTool_CurveTool.cdl
-- Created: Thu Jun 24 17:20:00 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class CurveTool from TopOpeBRepTool
uses
Shape from TopoDS,
Curve from Geom,
Curve from Geom2d,
Array1OfPnt from TColgp,
Array1OfPnt2d from TColgp,
GeomTool from TopOpeBRepTool,
OutCurveType from TopOpeBRepTool
is
Create returns CurveTool from TopOpeBRepTool;
Create (OCT:OutCurveType from TopOpeBRepTool)
returns CurveTool from TopOpeBRepTool;
Create(GT:GeomTool from TopOpeBRepTool)
returns CurveTool from TopOpeBRepTool;
ChangeGeomTool(me:in out) returns GeomTool from TopOpeBRepTool is static;
---C++: return &
GetGeomTool(me) returns GeomTool from TopOpeBRepTool is static;
---C++: return const &
SetGeomTool(me:in out; GT:GeomTool from TopOpeBRepTool) is static;
MakeCurves(me;
min,max:Real from Standard;
C3D:Curve from Geom;
PC1,PC2:Curve from Geom2d;
S1,S2:Shape from TopoDS;
C3DN:out Curve from Geom;
PC1N,PC2N:out Curve from Geom2d;
Tol3d,Tol2d:out Real from Standard)
returns Boolean from Standard is static;
---Purpose: Approximates curves.
-- Returns False in the case of failure
-- class methods
MakeBSpline1fromPnt(myclass;P:Array1OfPnt from TColgp)
returns Curve from Geom;
MakeBSpline1fromPnt2d(myclass;P:Array1OfPnt2d from TColgp)
returns Curve from Geom2d;
IsProjectable(myclass;S:Shape from TopoDS;C:Curve from Geom)
returns Boolean;
MakePCurveOnFace(myclass;
S:Shape from TopoDS;
C:Curve from Geom;
TolReached2d : out Real from Standard;
first: Real from Standard = 0.0;
last: Real from Standard = 0.0)
returns Curve from Geom2d;
fields
myGeomTool : GeomTool from TopOpeBRepTool is protected;
end CurveTool;

View File

@@ -0,0 +1,956 @@
// File: TopOpeBRepTool_CurveTool.cxx
// Created: Thu Jun 24 18:45:58 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepTool_CurveTool.ixx>
#include <ProjLib_ProjectedCurve.hxx>
#include <BRepApprox_Approx.hxx>
#include <BRepApprox_ApproxLine.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <Geom_BSplineCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_Circle.hxx>
#include <Geom2d_Ellipse.hxx>
#include <Geom2d_Parabola.hxx>
#include <Geom2d_Hyperbola.hxx>
#include <Geom2d_BSplineCurve.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <GeomLib_CheckBSplineCurve.hxx>
#include <GeomLib_Check2dBSplineCurve.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <BRepAdaptor_HSurface.hxx>
#include <GeomAdaptor_HCurve.hxx>
#include <GeomAbs_SurfaceType.hxx>
#include <gp_Pln.hxx>
#include <gp_Pnt2d.hxx>
#include <ElSLib.hxx>
#include <Standard_NotImplemented.hxx>
#include <Standard_ProgramError.hxx>
#include <OSD_Chronometer.hxx>
#include <GeomTools_Curve2dSet.hxx>
#include <TColStd_Array1OfBoolean.hxx>
#include <gp_Lin.hxx>
#include <gce_MakeLin.hxx>
#include <gp_Lin2d.hxx>
#include <gce_MakeLin2d.hxx>
#include <BRepTools.hxx>
#include <Precision.hxx>
#include <gce_MakeCirc.hxx>
#include <gp_Vec.hxx>
//#include <Approx.hxx>
#include <Geom_Surface.hxx>
#include <TopLoc_Location.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <BRep_Tool.hxx>
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettracePCURV();
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceCHKBSPL();
#ifdef DEB
#include <TopOpeBRepTool_KRO.hxx>
TOPKRO KRO_CURVETOOL_APPRO("approximation");
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceKRO();
#endif
//#define DRAW
//#define IFV
#define CurveImprovement
#ifdef DRAW
#include <DrawTrSurf.hxx>
static Standard_Integer NbCalls = 0;
#endif
//=======================================================================
//function : CurveTool
//purpose :
//=======================================================================
TopOpeBRepTool_CurveTool::TopOpeBRepTool_CurveTool()
{}
//=======================================================================
//function : CurveTool
//purpose :
//=======================================================================
TopOpeBRepTool_CurveTool::TopOpeBRepTool_CurveTool
(const TopOpeBRepTool_OutCurveType O)
{
TopOpeBRepTool_GeomTool GT(O);
SetGeomTool(GT);
}
//=======================================================================
//function : CurveTool
//purpose :
//=======================================================================
TopOpeBRepTool_CurveTool::TopOpeBRepTool_CurveTool
(const TopOpeBRepTool_GeomTool& GT)
{
SetGeomTool(GT);
}
//=======================================================================
//function : ChangeGeomTool
//purpose :
//=======================================================================
TopOpeBRepTool_GeomTool& TopOpeBRepTool_CurveTool::ChangeGeomTool()
{
return myGeomTool;
}
//=======================================================================
//function : GetGeomTool
//purpose :
//=======================================================================
const TopOpeBRepTool_GeomTool& TopOpeBRepTool_CurveTool::GetGeomTool()const
{
return myGeomTool;
}
//=======================================================================
//function : SetGeomTool
//purpose :
//=======================================================================
void TopOpeBRepTool_CurveTool::SetGeomTool
(const TopOpeBRepTool_GeomTool& GT)
{
myGeomTool.Define(GT);
}
//-----------------------------------------------------------------------
//function : MakePCurve
//purpose :
//-----------------------------------------------------------------------
Standard_EXPORT Handle(Geom2d_Curve) MakePCurve(const ProjLib_ProjectedCurve& PC)
{
Handle(Geom2d_Curve) C2D;
switch (PC.GetType()) {
case GeomAbs_Line : C2D = new Geom2d_Line(PC.Line()); break;
case GeomAbs_Circle : C2D = new Geom2d_Circle(PC.Circle()); break;
case GeomAbs_Ellipse : C2D = new Geom2d_Ellipse(PC.Ellipse()); break;
case GeomAbs_Parabola : C2D = new Geom2d_Parabola(PC.Parabola()); break;
case GeomAbs_Hyperbola : C2D = new Geom2d_Hyperbola(PC.Hyperbola()); break;
case GeomAbs_BSplineCurve : C2D = PC.BSpline(); break;
case GeomAbs_BezierCurve : case GeomAbs_OtherCurve : default :
Standard_NotImplemented::Raise("CurveTool::MakePCurve");
break;
}
return C2D;
}
//------------------------------------------------------------------
static Standard_Boolean CheckApproxResults
(const BRepApprox_Approx& Approx)
//------------------------------------------------------------------
{
const AppParCurves_MultiBSpCurve& amc = Approx.Value(1);
Standard_Integer np = amc.NbPoles();
Standard_Integer nc = amc.NbCurves();
if (np < 2 || nc < 1) return Standard_False;
// check the knots for coincidence
const TColStd_Array1OfReal& knots = amc.Knots();
for (Standard_Integer i = knots.Lower(); i < knots.Upper(); i++) {
if (knots(i+1) - knots(i) <= Epsilon(knots(i))) {
return Standard_False;
}
}
return Standard_True;
}
//------------------------------------------------------------------
static Standard_Boolean CheckPCurve
(const Handle(Geom2d_Curve)& aPC, const TopoDS_Face& aFace)
//------------------------------------------------------------------
// check if points of the pcurve are out of the face bounds
{
const Standard_Integer NPoints = 23;
Standard_Real umin,umax,vmin,vmax;
BRepTools::UVBounds(aFace, umin, umax, vmin, vmax);
Standard_Real tolU = Max ((umax-umin)*0.01, Precision::Confusion());
Standard_Real tolV = Max ((vmax-vmin)*0.01, Precision::Confusion());
Standard_Real fp = aPC->FirstParameter();
Standard_Real lp = aPC->LastParameter();
Standard_Real step = (lp-fp)/(NPoints+1);
// adjust domain for periodic surfaces
TopLoc_Location aLoc;
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace, aLoc);
if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
aSurf = (Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf))->BasisSurface();
gp_Pnt2d pnt = aPC->Value((fp+lp)/2);
Standard_Real u,v;
pnt.Coord(u,v);
if (aSurf->IsUPeriodic()) {
Standard_Real aPer = aSurf->UPeriod();
Standard_Integer nshift = (Standard_Integer) ((u-umin)/aPer);
if (u < umin+aPer*nshift) nshift--;
umin += aPer*nshift;
umax += aPer*nshift;
}
if (aSurf->IsVPeriodic()) {
Standard_Real aPer = aSurf->VPeriod();
Standard_Integer nshift = (Standard_Integer) ((v-vmin)/aPer);
if (v < vmin+aPer*nshift) nshift--;
vmin += aPer*nshift;
vmax += aPer*nshift;
}
Standard_Integer i;
for (i=1; i <= NPoints; i++) {
Standard_Real p = fp + i * step;
pnt = aPC->Value(p);
pnt.Coord(u,v);
if (umin-u > tolU || u-umax > tolU ||
vmin-v > tolV || v-vmax > tolV)
return Standard_False;
}
return Standard_True;
}
//------------------------------------------------------------------
static Handle(Geom_Curve) MakeCurve3DfromWLineApprox
(const BRepApprox_Approx& Approx,const Standard_Integer )
//------------------------------------------------------------------
{
const AppParCurves_MultiBSpCurve& amc = Approx.Value(1);
Standard_Integer np = amc.NbPoles();
//Standard_Integer nc = amc.NbCurves();
TColgp_Array1OfPnt poles3d(1,np);
Standard_Integer ic = 1;
//for (ic=1; ic<=nc; ic++) {
//if (ic == CI) {
amc.Curve(ic,poles3d);
//}
//}
const TColStd_Array1OfReal& knots = amc.Knots();
const TColStd_Array1OfInteger& mults = amc.Multiplicities();
Standard_Integer degree = amc.Degree();
Handle(Geom_Curve) C3D = new Geom_BSplineCurve(poles3d,knots,mults,degree);
return C3D;
}
//------------------------------------------------------------------
static Handle(Geom2d_Curve) MakeCurve2DfromWLineApproxAndPlane
(const BRepApprox_Approx& Approx,const gp_Pln& Pl)
//------------------------------------------------------------------
{
const AppParCurves_MultiBSpCurve& amc = Approx.Value(1);
Standard_Integer np = amc.NbPoles();
TColgp_Array1OfPnt2d poles2d(1,np);
TColgp_Array1OfPnt poles3d(1,np);
amc.Curve(1,poles3d);
for(Standard_Integer i=1; i<=np; i++) {
Standard_Real U,V; ElSLib::Parameters(Pl,poles3d.Value(i),U,V);
poles2d.SetValue(i,gp_Pnt2d(U,V));
}
const TColStd_Array1OfReal& knots = amc.Knots();
const TColStd_Array1OfInteger& mults = amc.Multiplicities();
Standard_Integer degree = amc.Degree();
Handle(Geom2d_Curve) C2D = new Geom2d_BSplineCurve(poles2d,knots,mults,degree);
return C2D;
}
//------------------------------------------------------------------
static Handle(Geom2d_Curve) MakeCurve2DfromWLineApprox
(const BRepApprox_Approx& Approx,const Standard_Integer CI)
//------------------------------------------------------------------
{
const AppParCurves_MultiBSpCurve& amc = Approx.Value(1);
Standard_Integer np = amc.NbPoles();
TColgp_Array1OfPnt2d poles2d(1,np);
Standard_Integer nc = amc.NbCurves();
for (Standard_Integer ic=1; ic<=nc; ic++) if (ic == CI) amc.Curve(ic,poles2d);
const TColStd_Array1OfReal& knots = amc.Knots();
const TColStd_Array1OfInteger& mults = amc.Multiplicities();
Standard_Integer degree = amc.Degree();
Handle(Geom2d_Curve) C2D = new Geom2d_BSplineCurve(poles2d,knots,mults,degree);
return C2D;
}
//=======================================================================
//function : MakeCurves
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_CurveTool::MakeCurves
(const Standard_Real parmin, const Standard_Real parmax,
const Handle(Geom_Curve)& C3D,
const Handle(Geom2d_Curve)& PC1, const Handle(Geom2d_Curve)& PC2,
const TopoDS_Shape& S1, const TopoDS_Shape& S2,
Handle(Geom_Curve)& C3Dnew,
Handle(Geom2d_Curve)& PC1new, Handle(Geom2d_Curve)& PC2new,
Standard_Real& TolReached3d, Standard_Real& TolReached2d) const
{
Standard_Boolean CompC3D = myGeomTool.CompC3D();
//cout << "MakeCurves begin" << endl;
if (!CompC3D) return Standard_False;
Standard_Boolean CompPC1 = myGeomTool.CompPC1();
Standard_Boolean CompPC2 = myGeomTool.CompPC2();
Standard_Real tol3d,tol2d;
Standard_Boolean RelativeTol;
myGeomTool.GetTolerances(tol3d,tol2d,RelativeTol);
Standard_Integer NbPntMax = myGeomTool.NbPntMax();
#ifdef DEB
if (TopOpeBRepTool_GettraceKRO()) KRO_CURVETOOL_APPRO.Start();
#endif
//----------------------------------
///*
#ifdef IFV
char name[16];
char *nm = &name[0];
sprintf(name,"C3D_%d",++NbCalls);
DrawTrSurf::Set(nm, C3D);
sprintf(name,"PC1_%d",NbCalls);
DrawTrSurf::Set(nm, PC1);
sprintf(name,"PC2_%d",NbCalls);
DrawTrSurf::Set(nm, PC2);
#endif
//*/
//---------------------------------------------
Standard_Integer iparmin = (Standard_Integer)parmin;
Standard_Integer iparmax = (Standard_Integer)parmax;
Handle(Geom_BSplineCurve)& HC3D = *((Handle(Geom_BSplineCurve)*)&C3D);
Handle(Geom2d_BSplineCurve)& HPC1 = *((Handle(Geom2d_BSplineCurve)*)&PC1);
Handle(Geom2d_BSplineCurve)& HPC2 = *((Handle(Geom2d_BSplineCurve)*)&PC2);
//--------------------- IFV - "improving" initial curves
#ifdef CurveImprovement
Standard_Integer nbpol = HC3D->NbPoles();
//cout <<"nbpol = " << nbpol << endl;
if(nbpol > 100) {
TColgp_Array1OfPnt PolC3D(1, nbpol);
TColgp_Array1OfPnt2d PolPC1(1, nbpol);
TColgp_Array1OfPnt2d PolPC2(1, nbpol);
TColStd_Array1OfBoolean IsValid(1, nbpol);
IsValid.Init(Standard_True);
Standard_Real tol = Max(1.e-10, 100.*tol3d*tol3d); //tol *= tol; - square distance
Standard_Real tl2d = tol*(tol2d*tol2d)/(tol3d*tol3d);
Standard_Real def = tol;
Standard_Real def2d = tol2d;
HC3D->Poles(PolC3D);
if(CompPC1) HPC1->Poles(PolPC1);
if(CompPC2) HPC2->Poles(PolPC2);
Standard_Integer ip = 1, NbPol = 1;
Standard_Real d, d1, d2;
gp_Pnt P = PolC3D(ip);
gp_Pnt2d P1, P2;
if(CompPC1) P1 = PolPC1(ip);
if(CompPC2) P2 = PolPC2(ip);
for(ip = 2; ip <= nbpol; ip++) {
if( IsValid(ip) ) {
d = P.SquareDistance(PolC3D(ip));
if(CompPC1) {d1 = P1.SquareDistance(PolPC1(ip));} else {d1 = 0.;}
if(CompPC2) {d2 = P2.SquareDistance(PolPC2(ip));} else {d2 = 0.;}
if(d > tol || d1 > tl2d || d2 > tl2d ) {
Standard_Real dd=0.;
if(ip < nbpol ) dd = P.Distance(PolC3D(ip+1));
if(ip < nbpol && dd < 10.*tol) {
gce_MakeLin mkL(P, PolC3D(ip+1));
if(mkL.IsDone()) {
gp_Lin L = mkL.Value();
d = L.SquareDistance(PolC3D(ip));
if(CompPC1) {
gp_Lin2d L1 = gce_MakeLin2d(P1, PolPC1(ip+1));
d1 = L1.SquareDistance(PolPC1(ip));
}
else d1 = 0.;
if(CompPC2) {
gp_Lin2d L2 = gce_MakeLin2d(P2, PolPC2(ip+1));
d2 = L2.SquareDistance(PolPC2(ip));
}
else d2 = 0.;
if(d > def || d1 > def2d || d2 > def2d ) {
NbPol++;
P = PolC3D(ip);
if(CompPC1) P1 = PolPC1(ip);
if(CompPC2) P2 = PolPC2(ip);
}
else {
IsValid(ip) = Standard_False;
}
}
else {
IsValid(ip+1) = Standard_False;
NbPol++;
P = PolC3D(ip);
if(CompPC1) P1 = PolPC1(ip);
if(CompPC2) P2 = PolPC2(ip);
}
}
else {
NbPol++;
P = PolC3D(ip);
if(CompPC1) P1 = PolPC1(ip);
if(CompPC2) P2 = PolPC2(ip);
}
}
else {
IsValid(ip) = Standard_False;
}
}
}
if(NbPol < 2) {IsValid(nbpol) = Standard_True; NbPol++;}
if(NbPol < nbpol) {
#ifdef IFV
cout << "NbPol < nbpol : " << NbPol << " " << nbpol << endl;
#endif
TColgp_Array1OfPnt Polc3d(1, NbPol);
TColgp_Array1OfPnt2d Polpc1(1, NbPol);
TColgp_Array1OfPnt2d Polpc2(1, NbPol);
TColStd_Array1OfReal knots(1,NbPol);
TColStd_Array1OfInteger mults(1,NbPol);
mults.Init(1); mults(1) = 2; mults(NbPol) = 2;
Standard_Integer count = 0;
for(ip = 1; ip <= nbpol; ip++) {
if(IsValid(ip)) {
count++;
Polc3d(count) = PolC3D(ip);
if(CompPC1) Polpc1(count) = PolPC1(ip);
if(CompPC2) Polpc2(count) = PolPC2(ip);
knots(count) = count;
}
}
Polc3d(NbPol) = PolC3D(nbpol);
if(CompPC1) Polpc1(NbPol) = PolPC1(nbpol);
if(CompPC2) Polpc2(NbPol) = PolPC2(nbpol);
HC3D = new Geom_BSplineCurve(Polc3d, knots, mults, 1);
if(CompPC1) HPC1 = new Geom2d_BSplineCurve(Polpc1, knots, mults, 1);
if(CompPC2) HPC2 = new Geom2d_BSplineCurve(Polpc2, knots, mults, 1);
iparmax = NbPol;
#ifdef IFV
sprintf(name,"C3Dmod_%d",NbCalls);
nm = &name[0];
DrawTrSurf::Set(nm, HC3D);
sprintf(name,"PC1mod_%d",NbCalls);
nm = &name[0];
DrawTrSurf::Set(nm, HPC1);
sprintf(name,"PC2mod_%d",NbCalls);
nm = &name[0];
DrawTrSurf::Set(nm, HPC2);
#endif
}
}
//--------------- IFV - end "improving"
#endif
BRepApprox_Approx Approx;
Standard_Integer degmin = 4;
Standard_Integer degmax = 8;
Approx_ParametrizationType parametrization = Approx_ChordLength;
Standard_Integer npol = HC3D->NbPoles();
TColgp_Array1OfPnt Polc3d(1, npol);
TColStd_Array1OfReal par(1, npol);
HC3D->Poles(Polc3d);
gp_Pnt P = Polc3d(1);
Standard_Boolean IsBad = Standard_False;
Standard_Integer ip;
Standard_Real ksi = 0., kc, kcprev = 0.;
Standard_Real dist;
par(1) = 0.;
for(ip = 2; ip <= npol; ip++) {
dist = P.Distance(Polc3d(ip));
if(dist < Precision::Confusion()) {
IsBad = Standard_True;
break;
}
par(ip) = par(ip-1) + dist;
P = Polc3d(ip);
}
if(!IsBad) {
TColStd_Array1OfReal Curvature(1, npol);
if(npol > 3) {
Standard_Integer ic = 1;
for(ip = 2; ip <= npol-1; ip += npol-3) {
gp_Vec v1(Polc3d(ip-1),Polc3d(ip));
gp_Vec v2(Polc3d(ip),Polc3d(ip+1));
if(!v1.IsParallel(v2, 1.e-4)) {
gce_MakeCirc mc(Polc3d(ip-1),Polc3d(ip),Polc3d(ip+1));
gp_Circ cir = mc.Value();
kc = 1./cir.Radius();
}
else kc = 0.;
Curvature(ic) = kc;
ic = npol;
}
}
else if(npol == 3) {
ip = 2;
gp_Vec v1(Polc3d(ip-1),Polc3d(ip));
gp_Vec v2(Polc3d(ip),Polc3d(ip+1));
if(!v1.IsParallel(v2, 1.e-4)) {
gce_MakeCirc mc(Polc3d(ip-1),Polc3d(ip),Polc3d(ip+1));
gp_Circ cir = mc.Value();
kc = 1./cir.Radius();
}
else kc = 0.;
Curvature(1) = Curvature(npol) = kc;
}
else {
Curvature(1) = Curvature(npol) = 0.;
}
ip = 1;
Standard_Real dt = par(ip+1) - par(ip);
Standard_Real dx = (Polc3d(ip+1).X() - Polc3d(ip).X())/dt,
dy = (Polc3d(ip+1).Y() - Polc3d(ip).Y())/dt,
dz = (Polc3d(ip+1).Z() - Polc3d(ip).Z())/dt;
Standard_Real dx1, dy1, dz1, d2x, d2y, d2z, d2t;
for(ip = 2; ip <= npol-1; ip++) {
dt = par(ip+1) - par(ip);
dx1 = (Polc3d(ip+1).X() - Polc3d(ip).X())/dt;
dy1 = (Polc3d(ip+1).Y() - Polc3d(ip).Y())/dt,
dz1 = (Polc3d(ip+1).Z() - Polc3d(ip).Z())/dt;
d2t = 2./(par(ip+1) - par(ip-1));
d2x = d2t*(dx1 - dx);
d2y = d2t*(dy1 - dy);
d2z = d2t*(dz1 - dz);
Curvature(ip) = Sqrt(d2x*d2x + d2y*d2y + d2z*d2z);
dx = dx1; dy = dy1; dz = dz1;
}
Standard_Real crit = 1000.; // empirical criterion !!!
dt = par(2) - par(1);
kcprev = (Curvature(2) - Curvature(1))/dt;
for(ip = 2; ip <= npol-1; ip++) {
dt = par(ip+1) - par(ip);
kc = (Curvature(ip+1) - Curvature(ip))/dt;
ksi = ksi + Abs(kc - kcprev);
if(ksi > crit) {IsBad = Standard_True;break;}
kc = kcprev;
}
}
//cout << NbCalls << " ksi = " << ksi << endl;
//cout << "IsBad = " << IsBad << endl;
if(IsBad){
Standard_Real tt = Min(10.*tol3d,Precision::Approximation());
tol2d = tt * tol2d / tol3d;
tol3d = tt;
NbPntMax = 40;
degmax = 4;
parametrization = Approx_Centripetal;
}
Standard_Integer nitmax = 0; // use projection only
Standard_Boolean withtangency = Standard_True;
Standard_Boolean compminmaxUV = Standard_True;
BRepAdaptor_Surface BAS1(TopoDS::Face(S1),compminmaxUV);
BRepAdaptor_Surface BAS2(TopoDS::Face(S2),compminmaxUV);
Handle(BRepApprox_ApproxLine) AL;
AL = new BRepApprox_ApproxLine(HC3D,HPC1,HPC2);
Approx.SetParameters(tol3d,tol2d,RelativeTol,degmin,degmax,nitmax,NbPntMax,withtangency,
parametrization);
if (CompC3D && CompPC1 && BAS1.GetType() == GeomAbs_Plane) {
//-- The curve X,Y,Z and U2,V2 is approximated
Approx.Perform(BAS1,BAS2,AL,CompC3D,Standard_False,CompPC2,iparmin,iparmax);
}
else if(CompC3D && CompPC2 && BAS2.GetType() == GeomAbs_Plane) {
//-- The curve X,Y,Z and U1,V1 is approximated
Approx.Perform(BAS1,BAS2,AL,CompC3D,CompPC1,Standard_False,iparmin,iparmax);
}
else {
Approx.Perform(BAS1,BAS2,AL,CompC3D,CompPC1,CompPC2,iparmin,iparmax);
}
// MSV Nov 9, 2001: do not raise exception in the case of failure,
// but return status
Standard_Boolean done = Approx.IsDone();
done = done && CheckApproxResults(Approx);
if (done) {
if (CompC3D && CompPC1 && BAS1.GetType() == GeomAbs_Plane) {
C3Dnew = ::MakeCurve3DfromWLineApprox(Approx,1);
PC1new = ::MakeCurve2DfromWLineApproxAndPlane(Approx,BAS1.Plane());
if (CompPC2) PC2new = ::MakeCurve2DfromWLineApprox(Approx,2);
}
else if(CompC3D && CompPC2 && BAS2.GetType() == GeomAbs_Plane) {
C3Dnew = ::MakeCurve3DfromWLineApprox(Approx,1);
if (CompPC1) PC1new = ::MakeCurve2DfromWLineApprox(Approx,2);
PC2new = ::MakeCurve2DfromWLineApproxAndPlane(Approx,BAS2.Plane());
}
else {
if (CompC3D) C3Dnew = ::MakeCurve3DfromWLineApprox(Approx,1);
if (CompPC1) PC1new = ::MakeCurve2DfromWLineApprox(Approx,2);
if (CompPC2) {
Standard_Integer i32 = (CompPC1) ? 3 : 2;
PC2new = ::MakeCurve2DfromWLineApprox(Approx,i32);
}
}
// check the pcurves relatively the faces bounds
if (CompPC1)
done = done && CheckPCurve(PC1new,TopoDS::Face(S1));
if (CompPC2)
done = done && CheckPCurve(PC2new,TopoDS::Face(S2));
}
if (!done) {
if (CompC3D) C3Dnew.Nullify();
if (CompPC1) PC1new.Nullify();
if (CompPC2) PC2new.Nullify();
return Standard_False;
}
#ifdef IFV
sprintf(name,"C3Dnew_%d", NbCalls);
nm = &name[0];
DrawTrSurf::Set(nm, C3Dnew);
if (CompPC1) {
sprintf(name,"PC1new_%d", NbCalls);
nm = &name[0];
DrawTrSurf::Set(nm, PC1new);
}
if (CompPC2) {
sprintf(name,"PC2new_%d", NbCalls);
nm = &name[0];
DrawTrSurf::Set(nm, PC2new);
}
#endif
TolReached3d = Approx.TolReached3d();
TolReached2d = Approx.TolReached2d();
#ifdef IFV
cout << NbCalls << " : Tol = " << TolReached3d << " " << TolReached2d << endl;
#endif
Standard_Boolean bf, bl;
const Handle(Geom_BSplineCurve)& Curve = Handle(Geom_BSplineCurve)::DownCast(C3Dnew);
if(!Curve.IsNull()) {
GeomLib_CheckBSplineCurve cbsc(Curve, 1.e-7, 0.1);
cbsc.NeedTangentFix(bf, bl);
#ifdef DEB
if (TopOpeBRepTool_GettraceCHKBSPL()) {
if(bf || bl) {
cout<<"Problem orientation GeomLib_CheckBSplineCurve : First = "<<bf;
cout<<" Last = "<<bl<<endl;
}
}
#endif
cbsc.FixTangent(bf, bl);
}
const Handle(Geom2d_BSplineCurve)& Curve2df = Handle(Geom2d_BSplineCurve)::DownCast(PC1new);
if(!Curve2df.IsNull()) {
GeomLib_Check2dBSplineCurve cbsc2df(Curve2df, 1.e-7, 0.1);
cbsc2df.NeedTangentFix(bf, bl);
#ifdef DEB
if (TopOpeBRepTool_GettraceCHKBSPL()) {
if(bf || bl) {
cout<<"Problem orientation GeomLib_CheckBSplineCurve : First = "<<bf;
cout<<" Last = "<<bl<<endl;
}
}
#endif
cbsc2df.FixTangent(bf, bl);
}
const Handle(Geom2d_BSplineCurve)& Curve2ds = Handle(Geom2d_BSplineCurve)::DownCast(PC2new);
if(!Curve2ds.IsNull()) {
GeomLib_Check2dBSplineCurve cbsc2ds(Curve2ds, 1.e-7, 0.1);
cbsc2ds.NeedTangentFix(bf, bl);
#ifdef DEB
if (TopOpeBRepTool_GettraceCHKBSPL()) {
if(bf || bl) {
cout<<"Problem orientation GeomLib_CheckBSplineCurve : First = "<<bf;
cout<<" Last = "<<bl<<endl;
}
}
#endif
cbsc2ds.FixTangent(bf, bl);
}
#ifdef DEB
if (TopOpeBRepTool_GettraceKRO()) KRO_CURVETOOL_APPRO.Stop();
#endif
// cout << "MakeCurves end" << endl;
return Standard_True;
}
//=======================================================================
//function : MakeBSpline1fromPnt
//purpose :
//=======================================================================
Handle(Geom_Curve) TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt
(const TColgp_Array1OfPnt& Points)
{
Standard_Integer Degree = 1;
Standard_Integer i,nbpoints = Points.Length();
Standard_Integer nbknots = nbpoints - Degree +1;
// First compute the parameters
// Standard_Real length = 0.;
// TColStd_Array1OfReal parameters(1,nbpoints);
// for (i = 1; i < nbpoints; i++) {
// parameters(i) = length;
// Standard_Real dist = Points(i).Distance(Points(i+1));
// length += dist;
// }
// parameters(nbpoints) = length;
// knots and multiplicities
TColStd_Array1OfReal knots(1,nbknots);
TColStd_Array1OfInteger mults(1,nbknots);
mults.Init(1);
mults(1) = mults(nbknots) = Degree + 1;
// knots(1) = 0;
// for (i=2;i<nbknots;i++) knots(i) = (parameters(i) + parameters(i+1)) /2.;
// knots(nbknots) = length;
// take point index as parameter : JYL 01/AUG/94
for (i = 1; i <= nbknots; i++) knots(i) = (Standard_Real)i;
Handle(Geom_Curve) C = new Geom_BSplineCurve(Points,knots,mults,Degree);
return C;
}
//=======================================================================
//function : MakeBSpline1fromPnt2d
//purpose :
//=======================================================================
Handle(Geom2d_Curve) TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt2d
(const TColgp_Array1OfPnt2d& Points)
{
Standard_Integer Degree = 1;
Standard_Integer i,nbpoints = Points.Length();
Standard_Integer nbknots = nbpoints - Degree +1;
// First compute the parameters
// Standard_Real length = 0;
// TColStd_Array1OfReal parameters(1,nbpoints);
// for (i = 1; i < nbpoints; i++) {
// parameters(i) = length;
// Standard_Real dist = Points(i).Distance(Points(i+1));
// length += dist;
// }
// parameters(nbpoints) = length;
// knots and multiplicities
TColStd_Array1OfReal knots(1,nbknots);
TColStd_Array1OfInteger mults(1,nbknots);
mults.Init(1);
mults(1) = mults(nbknots) = Degree + 1;
// knots(1) = 0;
// for (i=2;i<nbknots;i++) knots(i) = (parameters(i) + parameters(i+1)) /2.;
// knots(nbknots) = length;
// take point index as parameter : JYL 01/AUG/94
for (i = 1; i <= nbknots; i++) knots(i) = (Standard_Real)i;
Handle(Geom2d_Curve) C = new Geom2d_BSplineCurve(Points,knots,mults,Degree);
return C;
}
//=======================================================================
//function : IsProjectable
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_CurveTool::IsProjectable
(const TopoDS_Shape& S, const Handle(Geom_Curve)& C3D)
{
const TopoDS_Face& F = TopoDS::Face(S);
Standard_Boolean compminmaxUV = Standard_False;
BRepAdaptor_Surface BAS(F,compminmaxUV);
GeomAbs_SurfaceType suty = BAS.GetType();
GeomAdaptor_Curve GAC(C3D);
GeomAbs_CurveType cuty = GAC.GetType();
// --------
// avoid projection of 3d curve on surface in case
// of a quadric (ellipse,hyperbola,parabola) on a cone.
// Projection fails when the curve in not fully inside the UV domain
// of the cone : only part of 2d curve is built.
// NYI : projection of quadric on cone (crossing cone domain)
// --------
Standard_Boolean projectable = Standard_True;
if ( suty == GeomAbs_Cone ) {
if( (cuty == GeomAbs_Ellipse) ||
( cuty == GeomAbs_Hyperbola) ||
( cuty == GeomAbs_Parabola) ) {
projectable = Standard_False;
}
}
else if ( suty == GeomAbs_Cylinder ) {
if (cuty == GeomAbs_Ellipse) {
projectable = Standard_False;
}
}
else if ( suty == GeomAbs_Sphere ) {
if (cuty == GeomAbs_Circle) {
projectable = Standard_False;
}
}
else if ( suty == GeomAbs_Torus ) {
if (cuty == GeomAbs_Circle) {
projectable = Standard_False;
}
}
#ifdef DEB
if (TopOpeBRepTool_GettracePCURV()) {
cout<<"--- IsProjectable : ";
if (projectable) cout<<"projectable"<<endl;
else cout<<"NOT projectable"<<endl;
}
#endif
return projectable;
}
//=======================================================================
//function : MakePCurveOnFace
//purpose :
//=======================================================================
Handle(Geom2d_Curve) TopOpeBRepTool_CurveTool::MakePCurveOnFace
(const TopoDS_Shape& S,
const Handle(Geom_Curve)& C3D,
Standard_Real& TolReached2d,
const Standard_Real first, const Standard_Real last)
{
Standard_Boolean trim = Standard_False;
if (first < last)
trim = Standard_True;
const TopoDS_Face& F = TopoDS::Face(S);
Standard_Boolean compminmaxUV = Standard_False;
BRepAdaptor_Surface BAS(F,compminmaxUV);
GeomAdaptor_Curve GAC;
if (trim) GAC.Load(C3D,first,last);
else GAC.Load(C3D);
Handle(BRepAdaptor_HSurface) BAHS = new BRepAdaptor_HSurface(BAS);
Handle(GeomAdaptor_HCurve) BAHC = new GeomAdaptor_HCurve(GAC);
ProjLib_ProjectedCurve projcurv(BAHS,BAHC);
Handle(Geom2d_Curve) C2D = ::MakePCurve(projcurv);
TolReached2d = projcurv.GetTolerance();
Standard_Real UMin, UMax, VMin, VMax;
BRepTools::UVBounds(F,UMin, UMax, VMin, VMax);
Standard_Real f = GAC.FirstParameter();
Standard_Real l = GAC.LastParameter();
Standard_Real t =(f+l)*.5;
gp_Pnt2d pC2D; C2D->D0(t,pC2D);
Standard_Real u2 = pC2D.X();
Standard_Real v2 = pC2D.Y();
if (BAS.GetType() == GeomAbs_Sphere) {
// MSV: consider quasiperiodic shift of pcurve
Standard_Real VFirst = BAS.FirstVParameter();
Standard_Real VLast = BAS.LastVParameter();
Standard_Boolean mincond = v2 < VFirst;
Standard_Boolean maxcond = v2 > VLast;
if (mincond || maxcond) {
Handle(Geom2d_Curve) PCT = Handle(Geom2d_Curve)::DownCast(C2D->Copy());
// make mirror relative to the isoline of apex -PI/2 or PI/2
gp_Trsf2d aTrsf;
gp_Pnt2d po(0,-PI/2);
if (maxcond) po.SetY(PI/2);
aTrsf.SetMirror(gp_Ax2d(po, gp_Dir2d(1,0)));
PCT->Transform(aTrsf);
// add translation along U direction on PI
gp_Vec2d vec(PI,0);
Standard_Real UFirst = BAS.FirstUParameter();
if (u2-UFirst-PI > -1e-7) vec.Reverse();
PCT->Translate(vec);
C2D = PCT;
// recompute the test point
C2D->D0(t,pC2D);
u2 = pC2D.X();
v2 = pC2D.Y();
}
}
Standard_Real du = 0.;
if (BAHS->IsUPeriodic()) {
//modified by NIZHNY-MZV Thu Mar 30 10:03:15 2000
Standard_Boolean mincond = (UMin - u2 > 1e-7) ? Standard_True : Standard_False;
Standard_Boolean maxcond = (u2 - UMax > 1e-7) ? Standard_True : Standard_False;
Standard_Boolean decalu = mincond || maxcond;
if (decalu) du = ( mincond ) ? BAHS->UPeriod() : -BAHS->UPeriod();
//Standard_Boolean decalu = ( u2 < UMin || u2 > UMax);
//if (decalu) du = ( u2 < UMin ) ? BAHS->UPeriod() : -BAHS->UPeriod();
}
Standard_Real dv = 0.;
if (BAHS->IsVPeriodic()) {
//modified by NIZHNY-MZV Thu Mar 30 10:06:24 2000
Standard_Boolean mincond = (VMin - v2 > 1e-7) ? Standard_True : Standard_False;
Standard_Boolean maxcond = (v2 - VMax > 1e-7) ? Standard_True : Standard_False;
Standard_Boolean decalv = mincond || maxcond;
if (decalv) dv = ( mincond ) ? BAHS->VPeriod() : -BAHS->VPeriod();
//Standard_Boolean decalv = ( v2 < VMin || v2 > VMax);
//if (decalv) dv = ( v2 < VMin ) ? BAHS->VPeriod() : -BAHS->VPeriod();
}
if ( du != 0. || dv != 0.) {
Handle(Geom2d_Curve) PCT = Handle(Geom2d_Curve)::DownCast(C2D->Copy());
PCT->Translate(gp_Vec2d(du,dv));
C2D = PCT;
}
return C2D;
}

View File

@@ -0,0 +1,250 @@
// File: TopOpeBRepTool_DRAW.cxx
// Created: Thu Jul 21 11:56:06 1994
// Author: Jean Yves LEBEY
// <jyl@meteox>
#ifdef DRAW
#include <DBRep.hxx>
#include <gp_Lin.hxx>
#include <Draw_Appli.hxx>
#include <DrawTrSurf.hxx>
#include <Draw.hxx>
#include <Draw_MarkerShape.hxx>
#include <Draw_Marker3D.hxx>
#include <Draw_Segment3D.hxx>
#include <ElCLib.hxx>
#include <TopAbs_State.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <Draw_Color.hxx>
#include <Geom_Line.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <BRep_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopOpeBRepTool_DRAW.hxx>
Standard_IMPORT Draw_Color DrawTrSurf_CurveColor(const Draw_Color col);
Standard_IMPORT void DBRep_WriteColorOrientation ();
Standard_IMPORT Draw_Color DBRep_ColorOrientation (const TopAbs_Orientation Or);
static Draw_MarkerShape MARKER3DSHAPE = Draw_Square;
static Draw_ColorKind MARKER3DCOLOR = Draw_magenta;
static Standard_Integer MARKER3DSIZE = 1;
static Draw_ColorKind SEGMENTCOLOR = Draw_vert;
//===========================================================================
void TopOpeBRepTool_DrawPoint
(const gp_Pnt& P, const Draw_MarkerShape T, const Draw_ColorKind C)
//===========================================================================
{ dout<<new Draw_Marker3D(P,T,C,MARKER3DSIZE); dout.Flush(); }
void TopOpeBRepTool_DrawPoint(const gp_Pnt& P, const Draw_ColorKind C)
{ TopOpeBRepTool_DrawPoint(P,MARKER3DSHAPE,C); }
void TopOpeBRepTool_DrawPoint(const gp_Pnt& P)
{ TopOpeBRepTool_DrawPoint(P,MARKER3DSHAPE,MARKER3DCOLOR); }
//===========================================================================
void TopOpeBRepTool_DrawSegment
(const gp_Pnt& P1,const gp_Pnt& P2, const Draw_ColorKind C)
//===========================================================================
{
dout << new Draw_Segment3D(P1,P2,C);
TopOpeBRepTool_DrawPoint(P1); TopOpeBRepTool_DrawPoint(P2);
}
void TopOpeBRepTool_DrawSegment(const gp_Pnt& P1, const gp_Pnt& P2)
{ TopOpeBRepTool_DrawSegment(P1,P2,SEGMENTCOLOR); }
//===========================================================================
void TopOpeBRepTool_DrawSegment
(const gp_Pnt& P,const gp_Lin& L,
const Standard_Real Par,const Draw_ColorKind C)
//===========================================================================
{ TopOpeBRepTool_DrawSegment(P,ElCLib::Value(Par,L),C); }
//===========================================================================
Draw_ColorKind TopOpeBRepTool_ColorOnState(const TopAbs_State S)
//===========================================================================
{
Draw_ColorKind c;
switch (S) {
case TopAbs_ON : c = Draw_blanc; break;
case TopAbs_UNKNOWN : c = Draw_rouge; break;
case TopAbs_IN : c = Draw_rose; break;
case TopAbs_OUT : c = Draw_cyan; break;
}
return c;
}
//===========================================================================
void TopOpeBRepTool_DrawSegment
(const gp_Pnt& P,const gp_Lin& L,const Standard_Real Par,
const TopAbs_State S)
//===========================================================================
{ TopOpeBRepTool_DrawSegment(P,L,Par,TopOpeBRepTool_ColorOnState(S)); }
void TopOpeBRepTool_DrawSegment
(const gp_Pnt& P,const gp_Lin& L,const Standard_Real Par)
{ TopOpeBRepTool_DrawSegment(P,L,Par,SEGMENTCOLOR); }
Standard_EXPORT void FDRAW_DINS(const TCollection_AsciiString pref,const TopoDS_Shape& SS,const TCollection_AsciiString Snam,const TCollection_AsciiString suff)
{
DBRep::Set(Snam.ToCString(),SS);
cout<<pref<<FUN_tool_PRODINS()<<" "<<Snam<<";"<<suff;
}
Standard_EXPORT void FDRAW_DINE(const TCollection_AsciiString pref,const TopoDS_Edge& EE,const TCollection_AsciiString Enam,const TCollection_AsciiString suff)
{
TCollection_AsciiString VFnam,VRnam,VInam,VEnam;
TCollection_AsciiString blancV(" ");
TopoDS_Vertex VF,VR;TopExp::Vertices(EE,VF,VR);
if ( ! VF.IsNull() && !VR.IsNull() && !EE.IsNull() ) {
DBRep::Set(Enam.ToCString(),EE);
Standard_Real f,l; BRep_Tool::Range(EE,f,l);
cout<<pref<<FUN_tool_PRODINS()<<"-gO "<<Enam<<"; # f,l : "<<f<<","<<l<<suff;
#if 0
Standard_Integer nfo=0,nre=0,nin=0,nex=0;
TopExp_Explorer exx;
for (exx.Init(EE,TopAbs_VERTEX);exx.More();exx.Next()) {
// for (TopExp_Explorer exx(EE,TopAbs_VERTEX);exx.More();exx.Next()) {
const TopoDS_Vertex& vv = TopoDS::Vertex(exx.Current());
TopAbs_Orientation vvo = vv.Orientation();
if ( vvo == TopAbs_FORWARD ) {
nfo++; VFnam = Enam + ".vf" + nfo;
DBRep::Set(VFnam.ToCString(),vv);
cout<<blancV<<FUN_tool_PRODINS()<<VFnam;
}
else if ( vvo == TopAbs_REVERSED ) {
nre++; VRnam = Enam + ".vr" + nre;
DBRep::Set(VRnam.ToCString(),vv);
cout<<blancV<<FUN_tool_PRODINS()<<VRnam;
}
else if ( vvo == TopAbs_INTERNAL ) {
nin++; VInam = Enam + ".vi" + nin;
DBRep::Set(VInam.ToCString(),vv);
cout<<blancV<<FUN_tool_PRODINS()<<VInam;
}
else if ( vvo == TopAbs_EXTERNAL ) {
nex++; VEnam = Enam + ".ve" + nex;
DBRep::Set(VEnam.ToCString(),vv);
cout<<blancV<<FUN_tool_PRODINS()<<VEnam;
}
Standard_Real p = BRep_Tool::Parameter(vv,EE);
cout<<"; #draw ; par/"<<Enam<<" : "<<p<<endl;
}
#endif
}
}
Standard_EXPORT void FDRAW_DINLOE
(const TCollection_AsciiString pref,const TopTools_ListOfShape& LOE,const TCollection_AsciiString str1,const TCollection_AsciiString str2)
{
TopTools_ListIteratorOfListOfShape it(LOE);
for (Standard_Integer ned=1;it.More();it.Next(),ned++) {
TCollection_AsciiString Enam = str1 + str2 + "." + ned;
FDRAW_DINE(pref,TopoDS::Edge(it.Value()),Enam,"\n");
}
}
Standard_EXPORT void FUN_tool_draw (const TCollection_AsciiString& aa, const gp_Pnt& p, const gp_Dir& d)
{
char* aaa = aa.ToCString();
Handle(Geom_Line) L = new Geom_Line(p,d);
Handle(Geom_TrimmedCurve) tL = new Geom_TrimmedCurve(L,0.,1.);
DrawTrSurf::Set(aaa,tL);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString& aa,const gp_Pnt2d& p, const gp_Dir2d& d,const Standard_Integer& i)
{
TCollection_AsciiString bb(aa); bb += TCollection_AsciiString(i); char* aaa = bb.ToCString();
Handle(Geom2d_Line) L = new Geom2d_Line(p,d);
Handle(Geom2d_TrimmedCurve) tL = new Geom2d_TrimmedCurve(L,0.,.5);
DrawTrSurf::Set(aaa,tL);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const gp_Pnt2d& p2d)
{
char* aaa = aa.ToCString(); DrawTrSurf::Set(aaa,p2d);
}
Standard_EXPORT void FUN_tool_draw (const TCollection_AsciiString aa,const gp_Pnt& p)
{
char* aaa = aa.ToCString(); DrawTrSurf::Set(aaa,p);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const Handle(Geom2d_Curve) c2d)
{
Draw_Color col(Draw_blanc); DrawTrSurf_CurveColor(col); char* aaa = aa.ToCString();
DrawTrSurf::Set(aaa,c2d);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const Handle(Geom2d_Curve) c2d,
const Standard_Real f, const Standard_Real l)
{
Standard_Real tol = 1.e-7; Handle(Geom2d_Curve) cc2d;
if (Abs(f)<=tol && Abs(l)<=tol) cc2d = c2d;
else cc2d = new Geom2d_TrimmedCurve(c2d,f,l);
FUN_tool_draw(aa,cc2d);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString& aa, const Handle(Geom_Curve)& C)
{
char* aaa = aa.ToCString();
DrawTrSurf::Set(aaa,C);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const Handle(Geom_Curve) c,
const Standard_Real f, const Standard_Real l)
{
Standard_Real tol = 1.e-7; Handle(Geom_Curve) cc;
if (Abs(f)<=tol && Abs(l)<=tol) cc = c;
else cc = new Geom_TrimmedCurve(c,f,l);
FUN_tool_draw(aa,cc);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa, const TopoDS_Shape& s)
{
char* aaa = aa.ToCString(); DBRep::Set(aaa,s);
}
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const TopoDS_Shape& S,const Standard_Integer is)
{
TCollection_AsciiString bb(aa); bb += TCollection_AsciiString(is); FUN_tool_draw(bb,S);
}
Standard_EXPORT void FUN_tool_draw(TCollection_AsciiString aa,const TopoDS_Edge& E, const TopoDS_Face& F,const Standard_Integer ie)
{
if (E.IsNull()) {cout<<"************* null edge\n"; return;}
Standard_Real f,l; const Handle(Geom2d_Curve)& PC = BRep_Tool::CurveOnSurface(E,F,f,l);
if (PC.IsNull()) {cout<<"************* no curv on surf\n"; return;}
TCollection_AsciiString bb(aa); bb += TCollection_AsciiString(ie);
char* aaa = bb.ToCString();
Standard_Boolean coldef = Standard_False;
TopExp_Explorer ex(F,TopAbs_EDGE);
Draw_Color col,savecol = DrawTrSurf_CurveColor(Draw_rouge);
for (; ex.More(); ex.Next())
if (E.IsEqual(ex.Current()))
{col = DBRep_ColorOrientation(ex.Current().Orientation());
coldef = Standard_True;
break;}
if (!coldef) col = DBRep_ColorOrientation(E.Orientation());
DrawTrSurf_CurveColor(col);
DrawTrSurf::Set(aaa,new Geom2d_TrimmedCurve(PC,f,l));
}
Standard_EXPORT const TCollection_AsciiString& FUN_tool_PRODINS()
{
static TCollection_AsciiString PRODINS("dins ");
return PRODINS;
}
Standard_EXPORT const TCollection_AsciiString& FUN_tool_PRODINP()
{
static TCollection_AsciiString PRODINP("dinp ");
return PRODINP;
}
#endif

View File

@@ -0,0 +1,44 @@
// File: TopOpeBRepTool_DRAW.hxx
// Created: Mon Oct 24 14:06:42 1994
// Author: Jean Yves LEBEY
// <jyl@bravox>
#ifndef _TopOpeBRepTool_DRAW_HeaderFile
#define _TopOpeBRepTool_DRAW_HeaderFile
#ifdef DRAW
#include <gp_Pnt.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Lin.hxx>
#include <Draw_ColorKind.hxx>
#include <Draw_MarkerShape.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <TopOpeBRepTool_define.hxx>
Standard_EXPORT void TopOpeBRepTool_DrawPoint(const gp_Pnt& P, const Draw_MarkerShape T, const Draw_ColorKind C) ;
Standard_EXPORT void TopOpeBRepTool_DrawSegment(const gp_Pnt& P1,const gp_Pnt& P2, const Draw_ColorKind C);
Standard_EXPORT void TopOpeBRepTool_DrawSegment(const gp_Pnt& P1, const gp_Pnt& P2);
Standard_EXPORT void TopOpeBRepTool_DrawSegment(const gp_Pnt& P,const gp_Lin& ,const Standard_Real Par,const Draw_ColorKind C);
Standard_EXPORT Draw_ColorKind TopOpeBRepTool_ColorOnState(const TopAbs_State S);
Standard_EXPORT void TopOpeBRepTool_DrawSegment(const gp_Pnt& P,const gp_Lin& L,const Standard_Real Par,const TopAbs_State S);
Standard_EXPORT void FDRAW_DINS(const TCollection_AsciiString pref,const TopoDS_Shape& SS,const TCollection_AsciiString Snam,const TCollection_AsciiString suff = "");
Standard_EXPORT void FDRAW_DINE(const TCollection_AsciiString pref,const TopoDS_Edge& EE,const TCollection_AsciiString Enam,const TCollection_AsciiString suff = "");
Standard_EXPORT void FDRAW_DINLOE(const TCollection_AsciiString pref,const TopTools_ListOfShape& LOE,const TCollection_AsciiString str1,const TCollection_AsciiString str2);
Standard_EXPORT void FUN_tool_draw (const TCollection_AsciiString& aa, const gp_Pnt& p, const gp_Dir& d);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString& aa,const gp_Pnt2d& p, const gp_Dir2d& d,const Standard_Integer& i);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const gp_Pnt2d& p2d);
Standard_EXPORT void FUN_tool_draw (const TCollection_AsciiString aa,const gp_Pnt& p);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const Handle(Geom2d_Curve) c2d);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const Handle(Geom2d_Curve) c2d,const Standard_Real f, const Standard_Real l);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString& aa, const Handle(Geom_Curve)& C);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const Handle(Geom_Curve) c,const Standard_Real f, const Standard_Real l);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa, const TopoDS_Shape& s);
Standard_EXPORT void FUN_tool_draw(const TCollection_AsciiString aa,const TopoDS_Shape& S,const Standard_Integer is);
Standard_EXPORT void FUN_tool_draw(TCollection_AsciiString aa,const TopoDS_Edge& E, const TopoDS_Face& F,const Standard_Integer ie);
Standard_EXPORT void FUN_tool_draw(TCollection_AsciiString aa,const TopoDS_Edge& E, const TopoDS_Face& F,const Standard_Integer ie);
Standard_EXPORT const TCollection_AsciiString& FUN_tool_PRODINS();
Standard_EXPORT const TCollection_AsciiString& FUN_tool_PRODINP();
#endif
#endif

View File

@@ -0,0 +1,13 @@
// File: TopOpeBRepTool_EXPORT.hxx
// Created: Fri Nov 28 15:47:56 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_EXPORT_HeaderFile
#define _TopOpeBRepTool_EXPORT_HeaderFile
#include <TopOpeBRepTool_GEOMETRY.hxx>
#include <TopOpeBRepTool_PROJECT.hxx>
#include <TopOpeBRepTool_TOPOLOGY.hxx>
#endif

View File

@@ -0,0 +1,133 @@
-- File: TopOpeBRepTool_FuseEdges.cdl
-- Created: Thu Nov 26 10:17:28 1998
-- Author: Jean-Michel BOULCOURT
-- <jmb@coulox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class FuseEdges from TopOpeBRepTool
---Purpose: This class can detect vertices in a face that can
-- be considered useless and then perform the fuse of
-- the edges and remove the useless vertices. By
-- useles vertices, we mean :
-- * vertices that have exactly two connex edges
-- * the edges connex to the vertex must have
-- exactly the same 2 connex faces .
-- * The edges connex to the vertex must have the
-- same geometric support.
uses
Shape from TopoDS,
Vertex from TopoDS,
Edge from TopoDS,
ShapeEnum from TopAbs,
MapOfShape from TopTools,
ListOfShape from TopTools,
DataMapOfIntegerListOfShape from TopTools,
DataMapOfIntegerShape from TopTools,
DataMapOfShapeShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
IndexedMapOfShape from TopTools
raises
ConstructionError from Standard,
NullObject from Standard
is
Create (theShape : Shape from TopoDS;
PerformNow : Boolean from Standard = Standard_False)
returns FuseEdges from TopOpeBRepTool
raises NullObject from Standard;
---Purpose: Initialise members and build construction of map
-- of ancestors.
AvoidEdges (me : in out; theMapEdg : IndexedMapOfShape from TopTools);
---Purpose: set edges to avoid being fused
Edges (me : in out ; theMapLstEdg : in out DataMapOfIntegerListOfShape from TopTools);
---Purpose: returns all the list of edges to be fused
-- each list of the map represent a set of connex edges
-- that can be fused.
ResultEdges (me : in out ; theMapEdg : in out DataMapOfIntegerShape from TopTools);
---Purpose: returns all the fused edges. each integer entry in
-- the map corresponds to the integer in the
-- DataMapOfIntegerListOfShape we get in method
-- Edges. That is to say, to the list of edges in
-- theMapLstEdg(i) corresponds the resulting edge theMapEdge(i)
--
Faces (me: in out; theMapFac : in out DataMapOfShapeShape from TopTools);
---Purpose: returns the map of modified faces.
Shape (me : in out)
returns Shape from TopoDS
raises NullObject from Standard;
---Purpose: returns myShape modified with the list of internal
-- edges removed from it.
---C++: return &
NbVertices (me : in out)
returns Integer from Standard
raises NullObject from Standard;
---Purpose: returns the number of vertices candidate to be removed
---C++: return const
Perform (me : in out);
---Purpose: Using map of list of connex edges, fuse each list to
-- one edge and then update myShape
BuildAncestors (me; S: Shape from TopoDS; TS: ShapeEnum from TopAbs;
TA: ShapeEnum from TopAbs; M: in out IndexedDataMapOfShapeListOfShape from TopTools)
---Purpose: build a map of shapes and ancestors, like
-- TopExp.MapShapesAndAncestors, but we remove duplicate
-- shapes in list of shapes.
is private;
BuildListEdges (me : in out)
---Purpose: Build the all the lists of edges that are to be fused
is private;
BuildListResultEdges (me : in out)
---Purpose: Build result fused edges according to the list
-- builtin BuildLisEdges
is private;
BuildListConnexEdge (me : in out; theEdge : Shape from TopoDS; theMapUniq : in out MapOfShape from TopTools;
theLstEdg : in out ListOfShape from TopTools)
is private;
NextConnexEdge (me; theVertex : Vertex from TopoDS; theEdge : Shape from TopoDS;
theEdgeConnex : in out Shape from TopoDS)
returns Boolean from Standard
is private;
SameSupport (me; E1 : Edge from TopoDS; E2 :Edge from TopoDS)
returns Boolean from Standard
is private;
UpdatePCurve (me; theOldEdge : Edge from TopoDS;
theNewEdge : in out Edge from TopoDS;
theLstEdg : ListOfShape from TopTools)
returns Boolean from Standard
is private;
fields
myShape : Shape from TopoDS;
myShapeDone : Boolean from Standard;
myEdgesDone : Boolean from Standard;
myResultEdgesDone : Boolean from Standard;
myMapVerLstEdg : IndexedDataMapOfShapeListOfShape from TopTools;
myMapEdgLstFac : IndexedDataMapOfShapeListOfShape from TopTools;
myMapLstEdg : DataMapOfIntegerListOfShape from TopTools;
myMapEdg : DataMapOfIntegerShape from TopTools;
myMapFaces : DataMapOfShapeShape from TopTools;
myNbConnexEdge : Integer from Standard;
myAvoidEdg : IndexedMapOfShape from TopTools;
end FuseEdges;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,265 @@
// File: TopOpeBRepTool_GEOMETRY.cxx
// Created: Tue Oct 6 11:06:01 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_GEOMETRY.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <gp_Vec.hxx>
#include <gp_Cone.hxx>
#include <gp_Sphere.hxx>
#include <Geom2d_OffsetCurve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <TopOpeBRepTool_ShapeTool.hxx>
#include <Precision.hxx>
// ----------------------------------------------------------------------
Standard_EXPORT Handle(Geom2d_Curve) BASISCURVE2D(const Handle(Geom2d_Curve)& C)
{
Handle(Standard_Type) T = C->DynamicType();
if ( T == STANDARD_TYPE(Geom2d_OffsetCurve) )
return ::BASISCURVE2D(Handle(Geom2d_OffsetCurve)::DownCast(C)->BasisCurve());
else if ( T == STANDARD_TYPE(Geom2d_TrimmedCurve) )
return ::BASISCURVE2D(Handle(Geom2d_TrimmedCurve)::DownCast(C)->BasisCurve());
else return C;
}
/*// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_IsUViso(const Handle(Geom2d_Curve)& PC,
Standard_Boolean& isoU,Standard_Boolean& isoV,
gp_Dir2d& d2d,gp_Pnt2d& o2d)
{
isoU = isoV = Standard_False;
if (PC.IsNull()) return Standard_False;
Handle(Geom2d_Curve) LLL = BASISCURVE2D(PC);
Handle(Standard_Type) T2 = LLL->DynamicType();
Standard_Boolean isline2d = (T2 == STANDARD_TYPE(Geom2d_Line));
if (!isline2d) return Standard_False;
Handle(Geom2d_Line) L = Handle(Geom2d_Line)::DownCast(LLL);
d2d = L->Direction();
isoU = (Abs(d2d.X()) < Precision::Parametric(Precision::Confusion()));
isoV = (Abs(d2d.Y()) < Precision::Parametric(Precision::Confusion()));
Standard_Boolean isoUV = isoU || isoV;
if (!isoUV) return Standard_False;
o2d = L->Location();
return Standard_True;
}*/
// ----------------------------------------------------------------------
Standard_EXPORT gp_Dir FUN_tool_dirC(const Standard_Real par,const Handle(Geom_Curve)& C)
{
gp_Pnt p; gp_Vec tgE; C->D1(par,p,tgE);
gp_Dir dirC(tgE);
return dirC;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_onapex(const gp_Pnt2d& p2d,const Handle(Geom_Surface)& S)
{
Standard_Boolean isapex = Standard_False;
GeomAdaptor_Surface GS(S);
Standard_Real tol = Precision::Confusion();
GeomAbs_SurfaceType ST = GS.GetType();
Standard_Real toluv = 1.e-8;
if (ST == GeomAbs_Cone) {
gp_Cone co = GS.Cone();
gp_Pnt apex = co.Apex();
gp_Pnt pnt = GS.Value(p2d.X(),p2d.Y());
Standard_Real dist = pnt.Distance(apex);
isapex = (dist < tol);
}
if (ST == GeomAbs_Sphere) {
Standard_Real pisur2 = PI*.5;
#ifdef DEB
Standard_Real u =
#endif
p2d.X();
Standard_Real v = p2d.Y();
Standard_Boolean vpisur2 = (Abs(v-pisur2) < toluv);
Standard_Boolean vmoinspisur2 = (Abs(v+pisur2) < toluv);
isapex = vpisur2 || vmoinspisur2;
}
return isapex;
}
// ----------------------------------------------------------------------
Standard_EXPORT gp_Dir FUN_tool_ngS(const gp_Pnt2d& p2d,const Handle(Geom_Surface)& S)
{
// ###############################
// nyi : all geometries are direct
// ###############################
gp_Pnt p; gp_Vec d1u,d1v;
S->D1(p2d.X(),p2d.Y(),p,d1u,d1v);
Standard_Real du = d1u.Magnitude();
Standard_Real dv = d1v.Magnitude();
Standard_Real tol = Precision::Confusion();
Standard_Boolean kpart = (du < tol) || (dv < tol);
if (kpart) {
GeomAdaptor_Surface GS(S);
GeomAbs_SurfaceType ST = GS.GetType();
Standard_Real toluv = 1.e-8;
if (ST == GeomAbs_Cone) {
Standard_Boolean nullx = (Abs(p2d.X()) < toluv);
Standard_Boolean apex = nullx && (Abs(p2d.Y()) < toluv);
if (apex) {
const gp_Dir& axis = GS.Cone().Axis().Direction();
gp_Vec ng(axis); ng.Reverse();
return ng;
}
else if (du < tol) {
Standard_Real vf = GS.FirstVParameter();
#ifdef DEB
Standard_Real vl =
#endif
GS.LastVParameter();
Standard_Boolean onvf = Abs(p2d.Y()-vf)<toluv;
Standard_Real x = p2d.X(); Standard_Real y = p2d.Y();
//NYIXPU : devrait plutot etre fait sur les faces & TopOpeBRepTool_TOOL::minDUV...
if (onvf) y += 1.;
else y -= 1.;
S->D1(x,y,p,d1u,d1v);
gp_Vec ng = d1u^d1v;
return ng;
}
}
if (ST == GeomAbs_Sphere) {
// Standard_Real deuxpi = 2*PI;
Standard_Real pisur2 = PI*.5;
Standard_Real u = p2d.X(),v = p2d.Y();
// Standard_Boolean u0 =(Abs(u) < toluv);
// Standard_Boolean u2pi=(Abs(u-deuxpi) < toluv);
// Standard_Boolean apex = u0 || u2pi;
Standard_Boolean vpisur2 = (Abs(v-pisur2) < toluv);
Standard_Boolean vmoinspisur2 = (Abs(v+pisur2) < toluv);
Standard_Boolean apex = vpisur2 || vmoinspisur2;
if (apex) {
gp_Pnt center = GS.Sphere().Location();
gp_Pnt value = GS.Value(u,v);
gp_Vec ng(center,value);
// ng.Reverse();
return ng;
}
}
#ifdef DEB
cout<<"FUN_tool_nggeomF NYI"<<endl;
#endif
return gp_Dir(0,0,1);
}
gp_Dir udir(d1u);
gp_Dir vdir(d1v);
gp_Dir ngS(udir^vdir);
return ngS;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_line(const Handle(Geom_Curve)& C3d)
{
Handle(Geom_Curve) C = TopOpeBRepTool_ShapeTool::BASISCURVE(C3d);
GeomAdaptor_Curve GC(C);
Standard_Boolean line = (GC.GetType() == GeomAbs_Line);
return line;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_quadCT(const GeomAbs_CurveType& CT)
{
Standard_Boolean isquad = Standard_False;
if (CT == GeomAbs_Line) isquad = Standard_True;
if (CT == GeomAbs_Circle) isquad = Standard_True;
if (CT == GeomAbs_Ellipse) isquad = Standard_True;
if (CT == GeomAbs_Hyperbola) isquad = Standard_True;
if (CT == GeomAbs_Parabola) isquad = Standard_True;
return isquad;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_quad(const Handle(Geom_Curve)& C3d)
{
Handle(Geom_Curve) C = TopOpeBRepTool_ShapeTool::BASISCURVE(C3d);
if (C.IsNull()) return Standard_False;
GeomAdaptor_Curve GC(C);
GeomAbs_CurveType CT = GC.GetType();
Standard_Boolean quad = FUN_quadCT(CT);
return quad;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_quad(const Handle(Geom2d_Curve)& pc)
{
Handle(Geom2d_Curve) pcb = BASISCURVE2D(pc); // NYI TopOpeBRepTool_ShapeTool
if (pcb.IsNull()) return Standard_False;
Geom2dAdaptor_Curve GC2d(pcb);
GeomAbs_CurveType typ = GC2d.GetType();
Standard_Boolean isquad = Standard_False;
if (typ == GeomAbs_Line) isquad = Standard_True;
if (typ == GeomAbs_Circle) isquad = Standard_True;
if (typ == GeomAbs_Ellipse) isquad = Standard_True;
if (typ == GeomAbs_Hyperbola) isquad = Standard_True;
if (typ == GeomAbs_Parabola) isquad = Standard_True;
return isquad;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_line(const Handle(Geom2d_Curve)& pc)
{
Handle(Geom2d_Curve) pcb = BASISCURVE2D(pc); // NYI TopOpeBRepTool_ShapeTool
if (pcb.IsNull()) return Standard_False;
Geom2dAdaptor_Curve GC2d(pcb);
GeomAbs_CurveType typ = GC2d.GetType();
#ifdef DEB
Standard_Boolean isquad = Standard_False;
#endif
if (typ == GeomAbs_Line) return Standard_True;
return Standard_False ;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_quad(const Handle(Geom_Surface)& S)
{
if (S.IsNull()) return Standard_False;
GeomAdaptor_Surface GAS(S);
GeomAbs_SurfaceType typ = GAS.GetType();
Standard_Boolean isquad = Standard_False;
if (typ == GeomAbs_Plane) isquad = Standard_True;
if (typ == GeomAbs_Cylinder) isquad = Standard_True;
if (typ == GeomAbs_Cone) isquad = Standard_True;
if (typ == GeomAbs_Sphere) isquad = Standard_True;
if (typ == GeomAbs_Torus) isquad = Standard_True;
return isquad;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_closed(const Handle(Geom_Surface)& S,
Standard_Boolean& uclosed,Standard_Real& uperiod,
Standard_Boolean& vclosed,Standard_Real& vperiod)
{
uperiod = vperiod = 0.;
if (S.IsNull()) return Standard_False;
uclosed = S->IsUClosed(); if (uclosed) uclosed = S->IsUPeriodic(); //xpu261098 (BUC60382)
if (uclosed) uperiod = S->UPeriod();
vclosed = S->IsVClosed(); if (vclosed) vclosed = S->IsVPeriodic();
if (vclosed) vperiod = S->VPeriod();
Standard_Boolean closed = uclosed || vclosed;
return closed;
}
// ----------------------------------------------------------------------
Standard_EXPORT void FUN_tool_UpdateBnd2d(Bnd_Box2d& B2d,const Bnd_Box2d& newB2d)
{
// B2d.SetVoid(); -> DOESN'T EMPTY THE BOX
B2d = newB2d;
}

View File

@@ -0,0 +1,45 @@
// File: TopOpeBRepTool_GEOMETRY.hxx
// Created: Tue Oct 6 12:33:18 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_GEOMETRY_HeaderFile
#define _TopOpeBRepTool_GEOMETRY_HeaderFile
#include <TopOpeBRepTool_define.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Dir.hxx>
#include <gp_Dir2d.hxx>
#include <Bnd_Box2d.hxx>
Standard_EXPORT Handle(Geom2d_Curve) BASISCURVE2D(const Handle(Geom2d_Curve)& C);
//Standard_EXPORT Standard_Boolean FUN_tool_IsUViso(const Handle(Geom2d_Curve)& PC,Standard_Boolean& isoU,Standard_Boolean& isoV,gp_Dir2d& d2d,gp_Pnt2d& O2d);
Standard_EXPORT gp_Dir FUN_tool_dirC(const Standard_Real par,const Handle(Geom_Curve)& C);
Standard_EXPORT Standard_Boolean FUN_tool_onapex(const gp_Pnt2d& p2d,const Handle(Geom_Surface)& S);
Standard_EXPORT gp_Dir FUN_tool_ngS(const gp_Pnt2d& p2d,const Handle(Geom_Surface)& S);
// ----------------------------------------------------------------------
// curve type,surface type :
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_line(const Handle(Geom_Curve)& C3d);
Standard_EXPORT Standard_Boolean FUN_tool_line(const Handle(Geom2d_Curve)& C2d);
Standard_EXPORT Standard_Boolean FUN_quadCT(const GeomAbs_CurveType& CT);
Standard_EXPORT Standard_Boolean FUN_tool_quad(const Handle(Geom_Curve)& C3d);
Standard_EXPORT Standard_Boolean FUN_tool_quad(const Handle(Geom2d_Curve)& pc);
Standard_EXPORT Standard_Boolean FUN_tool_quad(const Handle(Geom_Surface)& S);
Standard_EXPORT Standard_Boolean FUN_tool_closed(const Handle(Geom_Surface)& S,Standard_Boolean& uclosed,Standard_Real& uperiod,Standard_Boolean& vclosed,Standard_Real& vperiod);
Standard_EXPORT void FUN_tool_UpdateBnd2d(Bnd_Box2d& B2d,const Bnd_Box2d& newB2d);
// ----------------------------------------------------------------------
// oriented vectors :
// ----------------------------------------------------------------------
Standard_EXPORT gp_Dir FUN_tool_nCinsideS(const gp_Dir& tgC,const gp_Dir& ngS);
Standard_EXPORT gp_Dir2d FUN_tool_nC2dINSIDES(const gp_Dir2d& tgC2d);
#endif

View File

@@ -0,0 +1,90 @@
-- File: TopOpeBRepTool_GeomTool.cdl
-- Created: Thu Jun 24 17:20:00 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class GeomTool from TopOpeBRepTool
uses
OutCurveType from TopOpeBRepTool
is
Create(TypeC3D : OutCurveType from TopOpeBRepTool = TopOpeBRepTool_BSPLINE1;
CompC3D : Boolean from Standard = Standard_True;
CompPC1 : Boolean from Standard = Standard_True;
CompPC2 : Boolean from Standard = Standard_True)
returns GeomTool from TopOpeBRepTool;
---Purpose: Boolean flags <CompC3D>, <CompPC1>, <CompPC2>
-- indicate whether the corresponding result curves
-- <C3D>, <PC1>, <PC2> of MakeCurves method must or not
-- be computed from an intersection line <L>.
-- When the line <L> is a walking one, <TypeC3D> is the
-- kind of the 3D curve <C3D> to compute :
-- - BSPLINE1 to compute a BSpline of degree 1 on the
-- walking points of <L>,
-- - APPROX to build an approximation curve on the
-- walking points of <L>.
Define(me : in out;
TypeC3D : OutCurveType from TopOpeBRepTool;
CompC3D : Boolean from Standard;
CompPC1 : Boolean from Standard;
CompPC2 : Boolean from Standard)
is static;
Define(me : in out;TypeC3D : OutCurveType from TopOpeBRepTool)
is static;
DefineCurves(me : in out;CompC3D : Boolean from Standard)
is static;
DefinePCurves1(me : in out;CompPC1 : Boolean from Standard)
is static;
DefinePCurves2(me : in out;CompPC2 : Boolean from Standard)
is static;
Define(me : in out;GT : GeomTool from TopOpeBRepTool)
is static;
GetTolerances(me; tol3d,tol2d : out Real from Standard)
is static;
SetTolerances(me : in out; tol3d,tol2d : Real from Standard)
is static;
GetTolerances(me; tol3d,tol2d : out Real from Standard; relative : out Boolean from Standard)
is static;
SetTolerances(me : in out; tol3d,tol2d : Real from Standard; relative : Boolean from Standard)
is static;
NbPntMax(me) returns Integer from Standard is static;
SetNbPntMax(me : in out; NbPntMax : Integer from Standard)
is static;
TypeC3D(me) returns OutCurveType from TopOpeBRepTool is static;
CompC3D(me) returns Boolean from Standard is static;
CompPC1(me) returns Boolean from Standard is static;
CompPC2(me) returns Boolean from Standard is static;
fields
myTypeC3D : OutCurveType from TopOpeBRepTool is protected;
myCompC3D : Boolean from Standard is protected;
myCompPC1 : Boolean from Standard is protected;
myCompPC2 : Boolean from Standard is protected;
myTol3d : Real from Standard;
myTol2d : Real from Standard;
myRelativeTol : Boolean from Standard;
myNbPntMax : Integer from Standard;
end GeomTool;

View File

@@ -0,0 +1,217 @@
// File: TopOpeBRepTool_GeomTool.cxx
// Created: Thu Jun 24 18:45:58 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepTool_GeomTool.ixx>
#include <Precision.hxx>
//=======================================================================
//function : TopOpeBRepTool_GeomTool
//purpose :
//=======================================================================
TopOpeBRepTool_GeomTool::TopOpeBRepTool_GeomTool
(const TopOpeBRepTool_OutCurveType TypeC3D,
const Standard_Boolean CompC3D,
const Standard_Boolean CompPC1,
const Standard_Boolean CompPC2) :
myTypeC3D(TypeC3D),
myCompC3D(CompC3D),
myCompPC1(CompPC1),
myCompPC2(CompPC2),
myTol3d(Precision::Approximation()),
myTol2d(Precision::PApproximation()),
myRelativeTol(Standard_True),
myNbPntMax(30)
{
}
//=======================================================================
//function : Define
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::Define
(const TopOpeBRepTool_OutCurveType TypeC3D,
const Standard_Boolean CompC3D,
const Standard_Boolean CompPC1,
const Standard_Boolean CompPC2)
{
myTypeC3D = TypeC3D;
myCompC3D = CompC3D;
myCompPC1 = CompPC1;
myCompPC2 = CompPC2;
}
//=======================================================================
//function : Define
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::Define
(const TopOpeBRepTool_OutCurveType TypeC3D)
{
myTypeC3D = TypeC3D;
}
//=======================================================================
//function : DefineCurves
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::DefineCurves
(const Standard_Boolean CompC3D)
{
myCompC3D = CompC3D;
}
//=======================================================================
//function : DefinePCurves1
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::DefinePCurves1
(const Standard_Boolean CompPC1)
{
myCompPC1 = CompPC1;
}
//=======================================================================
//function : DefinePCurves2
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::DefinePCurves2
(const Standard_Boolean CompPC2)
{
myCompPC2 = CompPC2;
}
//=======================================================================
//function : Define
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::Define
(const TopOpeBRepTool_GeomTool& GT)
{
*this = GT;
}
//=======================================================================
//function : GetTolerances
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::GetTolerances
(Standard_Real& tol3d, Standard_Real& tol2d) const
{
tol3d = myTol3d;
tol2d = myTol2d;
}
//=======================================================================
//function : SetTolerances
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::SetTolerances
(const Standard_Real tol3d, const Standard_Real tol2d)
{
myTol3d = tol3d;
myTol2d = tol2d;
myRelativeTol = Standard_True;
}
//=======================================================================
//function : GetTolerances
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::GetTolerances
(Standard_Real& tol3d, Standard_Real& tol2d, Standard_Boolean& relative) const
{
tol3d = myTol3d;
tol2d = myTol2d;
relative = myRelativeTol;
}
//=======================================================================
//function : SetTolerances
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::SetTolerances
(const Standard_Real tol3d, const Standard_Real tol2d, const Standard_Boolean relative)
{
myTol3d = tol3d;
myTol2d = tol2d;
myRelativeTol = relative;
}
//=======================================================================
//function : NbPntMax
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_GeomTool::NbPntMax()const
{
return myNbPntMax;
}
//=======================================================================
//function : SetNbPntMax
//purpose :
//=======================================================================
void TopOpeBRepTool_GeomTool::SetNbPntMax (const Standard_Integer NbPntMax)
{
myNbPntMax = NbPntMax ;
}
//=======================================================================
//function : CompC3D
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_GeomTool::CompC3D()const
{
return myCompC3D;
}
//=======================================================================
//function : TypeC3D
//purpose :
//=======================================================================
TopOpeBRepTool_OutCurveType TopOpeBRepTool_GeomTool::TypeC3D()const
{
return myTypeC3D;
}
//=======================================================================
//function : CompPC1
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_GeomTool::CompPC1()const
{
return myCompPC1;
}
//=======================================================================
//function : CompPC2
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_GeomTool::CompPC2()const
{
return myCompPC2;
}

View File

@@ -0,0 +1,40 @@
-- File: TopOpeBRepTool_HBoxTool.cdl
-- Created: Thu Jul 8 20:02:32 1993
-- Author: Jean Yves LEBEY
-- <jyl@zerox>
---Copyright: Matra Datavision 1993
class HBoxTool from TopOpeBRepTool inherits TShared from MMgt
uses
Box from Bnd,
Shape from TopoDS,
ShapeEnum from TopAbs,
IndexedDataMapOfShapeBox from TopOpeBRepTool
is
Create returns mutable HBoxTool from TopOpeBRepTool;
Clear(me:mutable);
AddBoxes(me:mutable;S:Shape;TS:ShapeEnum;TA:ShapeEnum=TopAbs_SHAPE);
AddBox(me:mutable;S:Shape);
ComputeBox(myclass;S:Shape;B:out Box from Bnd);
ComputeBoxOnVertices(myclass;S:Shape;B:out Box from Bnd);
DumpB(myclass;B:Box from Bnd);
Box(me:mutable;S:Shape) returns Box from Bnd;---C++: return const &
Box(me; I:Integer) returns Box from Bnd;---C++: return const &
HasBox(me; S:Shape) returns Boolean;
Shape(me; I:Integer) returns Shape;---C++: return const &
Index(me; S:Shape) returns Integer;
Extent(me) returns Integer;
ChangeIMS(me:mutable) returns IndexedDataMapOfShapeBox;---C++:return &
IMS(me) returns IndexedDataMapOfShapeBox;---C++:return const &
fields
myIMS:IndexedDataMapOfShapeBox from TopOpeBRepTool;
end HBoxTool;

View File

@@ -0,0 +1,231 @@
// File: TopOpeBRepTool_HBoxTool.cxx
// Created: Thu Jul 8 20:08:03 1993
// Author: Jean Yves LEBEY
// <jyl@zerox>
#include <TopOpeBRepTool_HBoxTool.ixx>
#include <TopAbs.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <gp_Pnt.hxx>
#include <BRepBndLib.hxx>
#include <Standard_ProgramError.hxx>
#include <TopOpeBRepTool_box.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <Precision.hxx>
#ifdef DEB
#define TBOX TopOpeBRepTool_GettraceBOX()
#endif
//=======================================================================
//function : TopOpeBRepTool_HBoxTool
//purpose :
//=======================================================================
TopOpeBRepTool_HBoxTool::TopOpeBRepTool_HBoxTool()
{
}
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TopOpeBRepTool_HBoxTool::Clear()
{
myIMS.Clear();
}
//=======================================================================
//function : ComputeBoxes
//purpose :
//=======================================================================
void TopOpeBRepTool_HBoxTool::AddBoxes(const TopoDS_Shape& S,const TopAbs_ShapeEnum TS,const TopAbs_ShapeEnum TA)
{
TopExp_Explorer ex;
for (ex.Init(S,TS,TA);ex.More();ex.Next()) {
// for (TopExp_Explorer ex(S,TS,TA);ex.More();ex.Next()) {
const TopoDS_Shape& ss = ex.Current();
AddBox(ss);
}
}
//=======================================================================
//function : AddBox
//purpose :
//=======================================================================
void TopOpeBRepTool_HBoxTool::AddBox(const TopoDS_Shape& S)
{
#ifdef DEB
TopAbs_ShapeEnum t =
#endif
S.ShapeType();
Standard_Boolean hasb = HasBox(S);
if (hasb) return;
Bnd_Box B;
ComputeBox(S,B);
myIMS.Add(S,B);
#ifdef DEB
if (TBOX) {
DumpB(Box(S));cout<<"; # HBT::AddBox "<<Index(S)<<" : ";TopAbs::Print(t,cout);cout<<"\n";cout<<endl;
}
#endif
}
//=======================================================================
//function : ComputeBox
//purpose :
//=======================================================================
void TopOpeBRepTool_HBoxTool::ComputeBox(const TopoDS_Shape& S,Bnd_Box& B)
{
TopAbs_ShapeEnum t = S.ShapeType();
if ( t == TopAbs_FACE ) BRepBndLib::Add(S,B);
else if ( t == TopAbs_EDGE ) BRepBndLib::Add(S,B);
//modified by NIZHNY-MZV Tue Sep 21 14:04:33 1999
else if ( t == TopAbs_SOLID) BRepBndLib::Add(S,B);
else if ( t == TopAbs_COMPOUND) BRepBndLib::Add(S,B);
//modified by NIZHNY-MZV Wed Apr 5 10:05:53 2000
else if ( t == TopAbs_VERTEX) BRepBndLib::Add(S,B);
else {
Standard_ProgramError::Raise("HBT::ComputeBox : invalid type");
}
}
//=======================================================================
//function : ComputeBoxOnVertices
//purpose :
//=======================================================================
void TopOpeBRepTool_HBoxTool::ComputeBoxOnVertices(const TopoDS_Shape& S,Bnd_Box& B)
{
TopExp_Explorer ex(S,TopAbs_VERTEX);
if (!ex.More()) {
B.Update(-1.e5,-1.e5,-1.e5,1.e5,1.e5,1.e5);
return;
}
Standard_Real tol = Precision::Confusion();
for (; ex.More(); ex.Next() ) {
Standard_Real x,y,z;
BRep_Tool::Pnt(TopoDS::Vertex(ex.Current())).Coord(x,y,z);
B.Update(x,y,z);
tol = Max(tol,BRep_Tool::Tolerance(TopoDS::Vertex(ex.Current())));
}
B.Enlarge(tol);
}
//=======================================================================
//function : Box
//purpose :
//=======================================================================
const Bnd_Box& TopOpeBRepTool_HBoxTool::Box(const TopoDS_Shape& S)
{
Standard_Boolean hb = HasBox(S);
if (!hb) {
Standard_ProgramError::Raise("HBT::Box1");
}
#ifdef DEB
Standard_Integer im =
#endif
Index(S);
const Bnd_Box& B = myIMS.FindFromKey(S);
return B;
}
//=======================================================================
//function : Box
//purpose :
//=======================================================================
const Bnd_Box& TopOpeBRepTool_HBoxTool::Box(const Standard_Integer I) const
{
Standard_Integer iu = Extent();
Standard_Integer hb = (I >= 1 && I <= iu);
if (!hb) {
Standard_ProgramError::Raise("HBT::Box2");
}
const Bnd_Box& B = myIMS.FindFromIndex(I);
return B;
}
//=======================================================================
//function : HasBox
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_HBoxTool::HasBox(const TopoDS_Shape& S) const
{
Standard_Boolean hb = myIMS.Contains(S);
return hb;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepTool_HBoxTool::Shape(const Standard_Integer I) const
{
Standard_Integer iu = Extent();
Standard_Integer hs = (I >= 1 && I <= iu);
if (!hs) {
Standard_ProgramError::Raise("HBT::Box4");
}
const TopoDS_Shape& S = myIMS.FindKey(I);
return S;
}
//=======================================================================
//function : Index
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_HBoxTool::Index(const TopoDS_Shape& S) const
{
Standard_Integer i = myIMS.FindIndex(S);
return i;
}
//=======================================================================
//function : Extent
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_HBoxTool::Extent() const
{
Standard_Integer n = myIMS.Extent();
return n;
}
//=======================================================================
//function : ChangeIMS
//purpose :
//=======================================================================
TopOpeBRepTool_IndexedDataMapOfShapeBox& TopOpeBRepTool_HBoxTool::ChangeIMS()
{
return myIMS;
}
//=======================================================================
//function : IMS
//purpose :
//=======================================================================
const TopOpeBRepTool_IndexedDataMapOfShapeBox& TopOpeBRepTool_HBoxTool::IMS() const
{
return myIMS;
}
//=======================================================================
//function : DumpB
//purpose :
//=======================================================================
void TopOpeBRepTool_HBoxTool::DumpB (const Bnd_Box& B)
{
#ifdef DEB
if (B.IsVoid()) cout<<"# IsVoid";
else if (B.IsWhole()) cout<<"# IsWhole";
else {
Standard_Real x,y,z,X,Y,Z;
B.Get(x,y,z,X,Y,Z);
cout<<"bounding "<<x<<" "<<y<<" "<<z<<" "<<X<<" "<<Y<<" "<<Z;
cout.flush();
}
#endif
}

View File

@@ -0,0 +1,27 @@
// File: TopOpeBRepTool_KRO.hxx
// Created: Tue Oct 1 17:31:34 1996
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_KRO_HeaderFile
#define _TopOpeBRepTool_KRO_HeaderFile
#ifdef DEB
#include <OSD_Chronometer.hxx>
#include <TCollection_AsciiString.hxx>
#include <Standard_OStream.hxx>
// POP pour NT
class TOPKRO:
public OSD_Chronometer{
public:
TOPKRO(const TCollection_AsciiString& n)
:myname(n),mystart(0),mystop(0){myname.RightJustify(30,' ');}
virtual void Start(){mystart=1;OSD_Chronometer::Start();}
virtual void Stop(){OSD_Chronometer::Stop();mystop=1;}
void Print(Standard_OStream& OS){Standard_Real s;Show(s);OS<<myname<<" : ";
if(!mystart)OS<<"(inactif)";else{OS<<s<<" secondes";if(!mystop)OS<<" (run)";}}
private:
TCollection_AsciiString myname;Standard_Integer mystart,mystop;
};
#endif
#endif

View File

@@ -0,0 +1,265 @@
// File: TopOpeBRepTool_PROJECT.cxx
// Created: Mon Nov 24 17:13:50 1997
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_PROJECT.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx>
#include <BRepLib_MakeVertex.hxx>
#include <BRepExtrema_ExtPF.hxx>
#include <Bnd_Box2d.hxx>
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
#include <BndLib_Add2dCurve.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir2d.hxx>
#include <BRep_Tool.hxx>
#include <Precision.hxx>
#include <TopOpeBRepTool_GEOMETRY.hxx>
// ----------------------------------------------------------------------
Standard_EXPORT void FUN_tool_bounds(const TopoDS_Edge& E,Standard_Real& f,Standard_Real& l)
{
BRepAdaptor_Curve BAC(E);
f = BAC.FirstParameter();
l = BAC.LastParameter();
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Integer FUN_tool_getindex(const Extrema_ExtPC& ponc)
{
Standard_Real Dist2,Dist2Min = ponc.SquareDistance(1);
Standard_Integer myIndex = 1,n = ponc.NbExt();
for ( Standard_Integer i = 2; i <= n; i++) {
Dist2 = ponc.SquareDistance(i);
if ( Dist2 < Dist2Min) {
Dist2Min = Dist2;
myIndex = i;
}
}
return myIndex;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Integer FUN_tool_getindex(const Extrema_ExtPC2d& ponc)
{
Standard_Real Dist2,Dist2Min = ponc.SquareDistance(1);
Standard_Integer myIndex = 1,n = ponc.NbExt();
for ( Standard_Integer i = 2; i <= n; i++) {
Dist2 = ponc.SquareDistance(i);
if ( Dist2 < Dist2Min) {
Dist2Min = Dist2;
myIndex = i;
}
}
return myIndex;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonC(const gp_Pnt& P,
const Standard_Real tole,const BRepAdaptor_Curve& BAC,
const Standard_Real pmin,const Standard_Real pmax,
Standard_Real& param,Standard_Real& dist)
{
// <True> if projection succeeds,and sets <param> to parameter of <P> on <C>.
Extrema_ExtPC ponc(P,BAC,pmin,pmax);
Standard_Boolean ok = ponc.IsDone();
Standard_Integer nbext = 0;
if (ok) {nbext = ponc.NbExt(); ok = (nbext > 0);}
if (!ok) {
for (Standard_Integer i = 1; i <= 2; i++) {
Standard_Real par = (i == 1) ? pmin : pmax;
gp_Pnt pt = BAC.Value(par);
Standard_Real d2 = pt.SquareDistance(P);
Standard_Boolean onpt = (d2 < tole * tole);
if (onpt) {
param = par;
dist = sqrt (d2);
return Standard_True;}
}
return Standard_False;
}
Standard_Integer i = FUN_tool_getindex(ponc);
param = ponc.Point(i).Parameter();
dist = sqrt (ponc.SquareDistance(i));
return Standard_True;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonC(const gp_Pnt& P,
const BRepAdaptor_Curve& BAC,
const Standard_Real pmin,const Standard_Real pmax,
Standard_Real& param,Standard_Real& dist)
{
// <True> if projection succeeds,and sets <param> to parameter of <P> on <C>.
Standard_Real tole = BAC.Tolerance();
Standard_Boolean ok = FUN_tool_projPonC(P,tole,BAC,pmin,pmax,param,dist);
return ok;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonC(const gp_Pnt& P,
const BRepAdaptor_Curve& BAC,
Standard_Real& param,Standard_Real& dist)
{
// <True> if projection succeeds,and sets <param> to parameter of <P> on <C>.
Standard_Real tole = BAC.Tolerance();
Standard_Real pmin = BAC.FirstParameter();
Standard_Real pmax = BAC.LastParameter();
Standard_Boolean ok = FUN_tool_projPonC(P,tole,BAC,pmin,pmax,param,dist);
return ok;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,
const Standard_Real tole,const BRepAdaptor_Curve2d& BAC2D,
const Standard_Real pmin,const Standard_Real pmax,
Standard_Real& param,Standard_Real& dist)
{
// <True> if projection succeeds,and sets <param> to parameter of <P> on <C>.
Standard_Boolean ok = Standard_False;
gp_Pnt2d P2D;
const TopoDS_Face& F = BAC2D.Face();
ok = FUN_tool_projPonF(P,F,P2D,dist);
if (!ok) return Standard_False;
Extrema_ExtPC2d ponc2d(P2D,BAC2D,pmin,pmax);
ok = ponc2d.IsDone();
Standard_Integer nbext = ponc2d.NbExt();
if (ok) ok = (nbext > 0);
if (!ok) {
for (Standard_Integer i = 1; i <= 2; i++) {
Standard_Real par = (i == 1) ? pmin : pmax;
gp_Pnt2d pt2d = BAC2D.Value(par);
Standard_Real d2 = pt2d.SquareDistance(P2D);
Standard_Boolean onpt = (d2 < tole * tole);
if (onpt) {
param = par;
dist = sqrt (d2);
return Standard_True;}
}
return Standard_False;
}
Standard_Integer i = FUN_tool_getindex(ponc2d);
param = ponc2d.Point(i).Parameter();
dist = sqrt (ponc2d.SquareDistance(i));
return Standard_True;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,
const BRepAdaptor_Curve2d& BAC2D,
const Standard_Real pmin,const Standard_Real pmax,
Standard_Real& param,Standard_Real& dist)
{
// <True> if projection succeeds,and sets <param> to parameter of <P> on <C>.
Standard_Real tole = BRep_Tool::Tolerance(BAC2D.Edge());
Standard_Boolean ok = FUN_tool_projPonC2D(P,tole,BAC2D,pmin,pmax,param,dist);
return ok;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,
const BRepAdaptor_Curve2d& BAC2D,
Standard_Real& param,Standard_Real& dist)
{
// <True> if projection succeeds,and sets <param> to parameter of <P> on <C>.
Standard_Real tole = BRep_Tool::Tolerance(BAC2D.Edge());
Standard_Real pmin = BAC2D.FirstParameter();
Standard_Real pmax = BAC2D.LastParameter();
Standard_Boolean ok = FUN_tool_projPonC2D(P,tole,BAC2D,pmin,pmax,param,dist);
return ok;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonS(const gp_Pnt& P,
const Handle(Geom_Surface)& S,
gp_Pnt2d& UV,Standard_Real& dist)
{
GeomAPI_ProjectPointOnSurf PonS(P,S);
if (!PonS.Extrema().IsDone()) return Standard_False;
if (PonS.NbPoints() == 0) return Standard_False;
dist = PonS.LowerDistance();
Standard_Real U,V; PonS.LowerDistanceParameters(U,V); UV.SetCoord(U,V);
return Standard_True;
}
// ----------------------------------------------------------------------
// projecting point <P> on topologies (edge <E>,face <F>)
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonE(const gp_Pnt& P,const Standard_Real tole,const TopoDS_Edge& E,
Standard_Real& param,Standard_Real& dist)
{
dist = 1.;
BRepAdaptor_Curve BAC(E);
Standard_Real first = BAC.FirstParameter();
Standard_Real last = BAC.LastParameter();
Standard_Boolean ok = FUN_tool_projPonC(P,tole,BAC,first,last,param,dist);
if (!ok) return Standard_False;
Standard_Real f,l; FUN_tool_bounds(E,f,l);
Standard_Real tolp = Precision::Parametric(Precision::Confusion());
Standard_Boolean onf = Abs(f-param) < tolp; if (onf) param = f;
Standard_Boolean onl = Abs(l-param) < tolp; if (onl) param = l;
return Standard_True;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonE(const gp_Pnt& P,const TopoDS_Edge& E,
Standard_Real& param,Standard_Real& dist)
{
Standard_Real tole = BRep_Tool::Tolerance(E);
Standard_Boolean ok = FUN_tool_projPonE(P,tole,E,param,dist);
return ok;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonboundedF(const gp_Pnt& P,const TopoDS_Face& F,
gp_Pnt2d& UV,Standard_Real& dist)
{
dist = 1.;
// ! projecting point on surf does not take into account the face's
// restriction
BRepLib_MakeVertex mv(P); TopoDS_Vertex V = mv.Vertex();
BRepExtrema_ExtPF PonF(V,F);
if (!PonF.IsDone()) return Standard_False;
Standard_Integer npt = PonF.NbExt();
if (npt == 0) return Standard_False;
// tri
Standard_Real dmin2 = 1.e14; Standard_Integer imin = 0;
for (Standard_Integer i=1; i <=npt; i++){
Standard_Real d2 = PonF.SquareDistance(i);
if (d2 < dmin2) {imin = i; dmin2 = d2;}
}
if (imin == 0) return Standard_False;
Standard_Real u,v; PonF.Parameter(imin,u,v);
dist = sqrt (dmin2);
UV = gp_Pnt2d(u,v);
return Standard_True;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonF(const gp_Pnt& P,const TopoDS_Face& F,
gp_Pnt2d& UV,Standard_Real& dist)
{
dist = 1.;
Handle(Geom_Surface) S = BRep_Tool::Surface(F);
Standard_Boolean ok = FUN_tool_projPonS(P,S,UV,dist);
return ok;
}

View File

@@ -0,0 +1,41 @@
// File: TopOpeBRepTool_PROJECT.hxx
// Created: Fri Nov 28 15:47:56 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_PROJECT_HeaderFile
#define _TopOpeBRepTool_PROJECT_HeaderFile
#include <TopOpeBRepTool_define.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <Extrema_ExtPC.hxx>
#include <Extrema_ExtPC2d.hxx>
// ----------------------------------------------------------------------
// project point <P> on geometries (curve <C>,surface <S>)
// ----------------------------------------------------------------------
Standard_EXPORT void FUN_tool_bounds(const TopoDS_Edge& E,Standard_Real& f,Standard_Real& l);
Standard_EXPORT Standard_Integer FUN_tool_getindex(const Extrema_ExtPC& ponc);
Standard_EXPORT Standard_Integer FUN_tool_getindex(const Extrema_ExtPC2d& ponc);
Standard_EXPORT Standard_Boolean FUN_tool_projPonC(const gp_Pnt& P,const Standard_Real tole,const BRepAdaptor_Curve& BAC,const Standard_Real pmin,const Standard_Real pmax,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonC(const gp_Pnt& P,const BRepAdaptor_Curve& BAC,const Standard_Real pmin,const Standard_Real pmax,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonC(const gp_Pnt& P,const BRepAdaptor_Curve& BAC,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,const Standard_Real tole,const BRepAdaptor_Curve2d& BAC2D,const Standard_Real pmin,const Standard_Real pmax,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,const BRepAdaptor_Curve2d& BAC2D,const Standard_Real pmin,const Standard_Real pmax,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonC2D(const gp_Pnt& P,const BRepAdaptor_Curve2d& BAC2D,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonS(const gp_Pnt& P,const Handle(Geom_Surface)& S,gp_Pnt2d& UV,Standard_Real& dist);
// ----------------------------------------------------------------------
// project point <P> on topologies (edge <E>,face <F>)
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_projPonE(const gp_Pnt& P,const Standard_Real tole,const TopoDS_Edge& E,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonE(const gp_Pnt& P,const TopoDS_Edge& E,Standard_Real& param,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonboundedF(const gp_Pnt& P,const TopoDS_Face& F,gp_Pnt2d& UV,Standard_Real& dist);
Standard_EXPORT Standard_Boolean FUN_tool_projPonF(const gp_Pnt& P,const TopoDS_Face& F,gp_Pnt2d& UV,Standard_Real& dist);
#endif

View File

@@ -0,0 +1,879 @@
// File: TopOpeBRepTool_PURGE.cxx
// Created: Thu Nov 13 13:45:48 1997
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_CORRISO.hxx>
#include <TopOpeBRepTool_C2DF.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Vec2d.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_Line.hxx>
#include <Geom_Surface.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <BRep_Tool.hxx>
#include <Precision.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Builder.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <Standard_Failure.hxx>
#include <TopOpeBRepTool_PURGE.hxx>
#ifdef DEB
//Standard_EXPORT Standard_Integer STATIC_PURGE_iwi = 0;
//Standard_EXPORT TopTools_IndexedMapOfShape STATIC_PURGE_mapw, STATIC_PURGE_mapv;
//Standard_EXPORT TopTools_IndexedMapOfOrientedShape STATIC_PURGE_mapeds, STATIC_CORR_mapeds;
Standard_EXPORT void debcorrUV(){};
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettracePURGE();
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCORRISO();
#endif
// DEB
// Unused :
#ifdef DEB
static void FUN_RaiseError()
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettracePURGE();
// Standard_Failure::Raise("TopOpeBRepTool::PurgeClosingEdges");
FUN_REINIT();
if (trc) cout <<"*********failure in TopOpeBRepTool::PurgeClosingEdges***********\n";
#endif
}
static void FUN_Raise()
{
#ifdef DEB
// cout <<"*********failure in TopOpeBRepTool::CorrectONUVISO***********\n";
// Standard_Failure::Raise("TopOpeBRepTool::CorrectONUVISO");
#endif
}
#endif
#define SPLITEDGE (0)
#define INCREASE (1)
#define DECREASE (-1)
#define M_FORWARD(sta) (sta == TopAbs_FORWARD)
#define M_REVERSED(sta) (sta == TopAbs_REVERSED)
#define M_INTERNAL(sta) (sta == TopAbs_INTERNAL)
#define M_EXTERNAL(sta) (sta == TopAbs_EXTERNAL)
static void FUN_addtomap(TopTools_DataMapOfShapeListOfShape& map, const TopoDS_Shape& key, const TopoDS_Shape& item)
{
if (map.IsBound(key)) map.ChangeFind(key).Append(item);
else {TopTools_ListOfShape los; los.Append(item); map.Bind(key,los);}
}
static Standard_Boolean FUN_getv(const TopAbs_Orientation& orivine, const TopoDS_Shape& e, TopoDS_Shape& v)
{
v.Nullify();
// gets <v> oriented <orivine> in <e>
TopAbs_Orientation oe = e.Orientation();
Standard_Boolean isnonO = M_INTERNAL(oe) || M_EXTERNAL(oe);
TopoDS_Shape eO;
if (isnonO) {
eO = e.Oriented(TopAbs_FORWARD);
}
else {
eO = e;
}
TopExp_Explorer exv(eO, TopAbs_VERTEX);
for (; exv.More(); exv.Next()) {
const TopoDS_Shape& vcur = exv.Current();
if (vcur.Orientation() == orivine) {v = vcur; return Standard_True;}
} // exv
return Standard_False;
}
Standard_EXPORT Standard_Boolean FUN_tool_ClosedW(const TopoDS_Wire& W)
{
// !! an edge oriented INTERNAL/EXTERNAL has all its vertices
// oriented INTERNAL/EXTERNAL.
// <mapvedsO> = {(v,loe)} / e is oriented :
// <mapvedsO> = {(v,loe)} / e is not oriented (INTERNAL/EXTERNAL) :
TopTools_DataMapOfShapeListOfShape mapvFine,mapvRine, mapvIine;
TopExp_Explorer exe(W, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Shape& e = exe.Current();
TopAbs_Orientation oe = e.Orientation();
Standard_Boolean isnonO = M_INTERNAL(oe) || M_EXTERNAL(oe);
TopoDS_Shape eO;
if (isnonO) {
eO = e.Oriented(TopAbs_FORWARD);
}
else {
eO = e;
}
TopExp_Explorer exv(eO, TopAbs_VERTEX);
for (; exv.More(); exv.Next()) {
const TopoDS_Shape& v = exv.Current();
TopAbs_Orientation oriv = v.Orientation();
if (M_FORWARD(oriv)) FUN_addtomap(mapvFine,v,e);
if (M_REVERSED(oriv)) FUN_addtomap(mapvRine,v,e);
if (M_INTERNAL(oriv)) FUN_addtomap(mapvIine,v,e);
}
}
if (mapvFine.Extent() == 0) return Standard_False; // empty wire
TopTools_MapOfShape mapvok;
// a vertex is found valid if is - an internal vertex
// - found FORWARD and REVERSED.
TopTools_MapOfShape mapvonlyFine; // {(v,e)} v F in e, v belongs to only one e
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itvFine(mapvFine);
for (; itvFine.More(); itvFine.Next()){
const TopoDS_Shape& vFine = itvFine.Key();
#ifdef DEB
const TopTools_ListOfShape& edsvFine =
#endif
itvFine.Value();
Standard_Boolean vIine = mapvIine.IsBound(vFine);
if (vIine) {mapvok.Add(vFine); continue;}
Standard_Boolean vRine = mapvRine.IsBound(vFine);
if (vRine) {mapvok.Add(vFine); continue;}
mapvonlyFine.Add(vFine);
}
// <mapvRinonee> = {(v,e)} v R in e, v belongs to only one e
TopTools_MapOfShape mapvonlyRine;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itvRine(mapvRine);
for (; itvRine.More(); itvRine.Next()){
const TopoDS_Shape& vRine = itvRine.Key();
#ifdef DEB
const TopTools_ListOfShape& edsvRine =
#endif
itvRine.Value();
Standard_Boolean vok = mapvok.Contains(vRine);
if (vok) continue;
Standard_Boolean vIine = mapvIine.IsBound(vRine);
if (vIine) {mapvok.Add(vRine); continue;}
mapvonlyRine.Add(vRine);
}
// checking vertices <mapvonlyFine> and <mapvonlyRine>
TopTools_MapIteratorOfMapOfShape itvonlyFRine;
Standard_Integer nmap = 0;
while (nmap <= 2) {
nmap++;
Standard_Boolean vFine = (nmap == 1);
if (vFine) itvonlyFRine.Initialize(mapvonlyFine);
else itvonlyFRine.Initialize(mapvonlyRine);
for (; itvonlyFRine.More(); itvonlyFRine.Next()){
const TopoDS_Shape& vtocheck = itvonlyFRine.Key();
TopTools_ListOfShape edsvFRine;
if (vFine) edsvFRine = mapvFine.Find(vtocheck);
else edsvFRine = mapvRine.Find(vtocheck);
if (edsvFRine.Extent() > 1) return Standard_False; // faulty wire
const TopoDS_Shape& e = edsvFRine.First();
TopAbs_Orientation ovori = vFine? TopAbs_REVERSED: TopAbs_FORWARD;
TopoDS_Shape ov; Standard_Boolean ovfound = FUN_getv(ovori,e,ov);
if (!ovfound) return Standard_False; // faulty edge
// <vtocheck> is on only one edge <e>,
// <vtocheck> is FORWARD/REVERSED in <e>,
// <ovfound> is REVERSED/FORWARD in <e>.
// <vtocheck> is ok if : - <ovfound> is INTERNAL in another edge
// - <ovfound> is FORWARD and REVERSED in
// one or two other edges.
// and e is not oriented
TopAbs_Orientation oe = e.Orientation();
if (M_FORWARD(oe) || M_REVERSED(oe)) return Standard_False;
if (!mapvok.Contains(ov)) return Standard_False;
Standard_Boolean ovIine = mapvIine.IsBound(ov); if (ovIine) continue;
Standard_Boolean ovFine = mapvRine.IsBound(ov); if (!ovFine) return Standard_False;
Standard_Boolean ovRine = mapvRine.IsBound(ov); if (!ovRine) return Standard_False;
const TopTools_ListOfShape& edsovFine = mapvFine.Find(ov);
const TopTools_ListOfShape& edsovRine = mapvRine.Find(ov);
if (edsovFine.Extent() > 1) continue;
if (edsovRine.Extent() > 1) continue;
if (edsovFine.First().IsEqual(e)) return Standard_False;
if (edsovRine.First().IsEqual(e)) return Standard_False;
}
} // nmap
return Standard_True;
}
//=======================================================================
//function : PurgeClosingEdges
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::PurgeClosingEdges(const TopoDS_Face& Fin, const TopoDS_Face& FF,
// const TopTools_DataMapOfShapeInteger& MWisOld,
const TopTools_DataMapOfShapeInteger& ,
TopTools_IndexedMapOfOrientedShape& MshNOK)
{
// Fin is the original face
// FF is the splitted face
// prequesitory : splitted edges, of edge ancestor a closing edge
// keep in memory the geometry of the ancestor edge,
// they answer True to BRep_Tool::IsClosed.
// elsewhere : we have to get this information using geometric
// criteriums (TopOpeBRepTool_TOOL::IsonCLO)
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettracePURGE();
if (trc) cout<<"\n* PurgeClosingEdges:\n\n";
#endif
TopOpeBRepTool_CORRISO CORRISO(Fin);
Standard_Real tolF = BRep_Tool::Tolerance(Fin);
Standard_Real uperiod; Standard_Boolean uclosed = CORRISO.Refclosed(1,uperiod);
Standard_Real vperiod; Standard_Boolean vclosed = CORRISO.Refclosed(2,vperiod);
if (!uclosed && !vclosed) return Standard_False;
Standard_Boolean inU = uclosed ? Standard_True : Standard_False;
Standard_Real xmin = inU ? (CORRISO.GASref().FirstUParameter()) :
(CORRISO.GASref().FirstVParameter());
Standard_Real xper = inU ? uperiod : vperiod;
Standard_Real tolx = inU ? (CORRISO.Tol(1,tolF)) : (CORRISO.Tol(2,tolF));
TopExp_Explorer exw(FF, TopAbs_WIRE);
for (; exw.More(); exw.Next()){
const TopoDS_Shape& W = exw.Current();
CORRISO.Init(W);
Standard_Boolean ok = CORRISO.UVClosed();
if (ok) continue;
TopTools_ListOfShape cEds;
TopTools_ListIteratorOfListOfShape ite(CORRISO.Eds());
for (; ite.More(); ite.Next()){
const TopoDS_Edge& E = TopoDS::Edge(ite.Value());
Standard_Boolean closing = BRep_Tool::IsClosed(E,Fin);
if (!closing) {// xpu231198 : pcurve modified, the information is lost
TopOpeBRepTool_C2DF C2DF; Standard_Boolean isb = CORRISO.UVRep(E,C2DF);
if (!isb) return Standard_False;//NYIRAISE
Standard_Boolean onclo = TopOpeBRepTool_TOOL::IsonCLO(C2DF,inU,xmin,xper,tolx);
if (onclo) closing=Standard_True;
}
if (closing) cEds.Append(E);
}
Standard_Integer ncE = cEds.Extent();
Standard_Boolean nopurge = (ncE <= 1);
if (nopurge) return Standard_True;
// Checking <W>
TopTools_ListOfShape fyEds; Standard_Boolean topurge = CORRISO.PurgeFyClosingE(cEds,fyEds);
if (topurge) {
TopTools_ListIteratorOfListOfShape it(fyEds);
for (; it.More(); it.Next()) MshNOK.Add(it.Value());
MshNOK.Add(W);
MshNOK.Add(FF);
}
#ifdef DEB
if (trc && topurge) cout<<"found FAULTY edge = ed"<<endl;
#endif
} // exw
return Standard_True;
}
//=======================================================================
//function : PurgeClosingEdges
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::PurgeClosingEdges(const TopoDS_Face& Fin, const TopTools_ListOfShape& LOF,
const TopTools_DataMapOfShapeInteger& MWisOld,
TopTools_IndexedMapOfOrientedShape& MshNOK)
{
Standard_Boolean uvclosed = FUN_tool_closedS(Fin);
if (!uvclosed) return Standard_True;
TopTools_ListIteratorOfListOfShape it(LOF);
for (; it.More(); it.Next()){
const TopoDS_Face& FF = TopoDS::Face(it.Value());
Standard_Boolean ok = TopOpeBRepTool::PurgeClosingEdges(Fin,FF,MWisOld,MshNOK);
if (!ok) return Standard_False;
}
return Standard_True;
}
/*static Standard_Boolean FUN_correctClosingE(TopoDS_Edge& newfE, TopoDS_Face& Fsp)
{
Standard_Real f,l,tol; Handle(Geom2d_Curve) PC = FUNTOOLC2D_CurveOnSurface(newfE,Fsp,f,l,tol);
gp_Dir2d d2d; gp_Pnt2d O2d; Standard_Boolean isuiso,isviso;
Standard_Boolean uviso = FUN_tool_IsUViso(PC,isuiso,isviso,d2d,O2d);
if (!uviso) return Standard_False;
Standard_Real period = 2*PI;
Standard_Real piso = isuiso? O2d.X(): O2d.Y();
Standard_Real tol2d = 1.e-6;
Standard_Boolean is0 = Abs(piso) < tol2d;
Standard_Boolean is2PI = Abs(period-piso) < tol2d;
// --------------------------------------------------
// prequesitory : Closed Surfaces have period 2PI
if (!is0 && !is2PI) return Standard_False;
// --------------------------------------------------
Standard_Real factor = is0? period: -period;
gp_Vec2d transl(1.,0.); if (isviso) transl = gp_Vec2d(0.,1.);
transl.Multiply(factor);
Standard_Integer ok = FUN_tool_translate(transl,Fsp,newfE);
return Standard_True;
}
static Standard_Boolean FUN_correctDegeneratedE
(const TopTools_IndexedDataMapOfShapeListOfShape& mve,TopoDS_Edge& Ein,TopoDS_Face& Fsp)
{
TopoDS_Vertex v1,v2; TopExp::Vertices(Ein,v1,v2);
TopAbs_Orientation ov1 = v1.Orientation();
TopAbs_Orientation ov2 = v2.Orientation();
Standard_Boolean ok1 = mve.Contains(v1); if (!ok1) return Standard_False;
Standard_Boolean ok2 = mve.Contains(v2); if (!ok2) return Standard_False;
const TopTools_ListOfShape& le= mve.FindFromKey(v1);
TopoDS_Edge e1,e2; Standard_Boolean fe1 = Standard_False; Standard_Boolean fe2 = Standard_False;
TopoDS_Vertex vfe1,vfe2;
Standard_Boolean fEin = Standard_False;
for(TopTools_ListIteratorOfListOfShape itle(le);itle.More();itle.Next()) {
const TopoDS_Shape& ecx = TopoDS::Edge(itle.Value());
if (ecx.IsEqual(Ein)) {
fEin = Standard_True;
}
else {
TopExp_Explorer exv;
for (exv.Init(ecx,TopAbs_VERTEX);exv.More();exv.Next()) {
// for (TopExp_Explorer exv(ecx,TopAbs_VERTEX);exv.More();exv.Next()) {
const TopoDS_Vertex& vecx = TopoDS::Vertex(exv.Current());
Standard_Boolean issam = vecx.IsSame(v1);
if (issam) {
Standard_Boolean iseq1 = vecx.IsEqual(v1);
Standard_Boolean iseq2 = vecx.IsEqual(v2);
if (!iseq1) {
e1 = TopoDS::Edge(ecx);
vfe1 = TopoDS::Vertex(vecx);
fe1 = Standard_True;
}
if (!iseq2) {
e2 = TopoDS::Edge(ecx);
vfe2 = TopoDS::Vertex(vecx);
fe2 = Standard_True;
}
}
if (fe1 && fe2) break;
}
if (fe1 && fe2) break;
}
if (fEin && fe1 && fe2) break;
} // itle.More()
Standard_Boolean ok = (fEin && fe1 && fe2);
if (!ok) return Standard_False;
#ifdef DEB
debcorrUV(); // call Draw_Call("av2d;dy fyf;fit;ppcu fyf")
#endif
Standard_Real f,l,tol; Handle(Geom2d_Curve) PC = FUNTOOLC2D_CurveOnSurface(Ein,Fsp,f,l,tol);
gp_Dir2d d2d; gp_Pnt2d O2d; Standard_Boolean isuiso = 0,isviso = 0;
Standard_Boolean uviso = FUN_tool_IsUViso(PC,isuiso,isviso,d2d,O2d);
if (!uviso) return Standard_False;
Standard_Real pfEin,plEin,tolEin; Handle(Geom2d_Curve) PCEin = FUNTOOLC2D_CurveOnSurface(Ein,Fsp,pfEin,plEin,tolEin);
if (PCEin.IsNull()) Standard_Failure::Raise(" FUN_correctDegeneratedE : no 2d curve Ein");
Standard_Real pf1,pl1,tol1; Handle(Geom2d_Curve) PC1 = FUNTOOLC2D_CurveOnSurface(e1,Fsp,pf1,pl1,tol1);
if (PC1.IsNull()) Standard_Failure::Raise(" FUN_correctDegeneratedE : no 2d curve e1");
Standard_Real pf2,pl2,tol2; Handle(Geom2d_Curve) PC2 = FUNTOOLC2D_CurveOnSurface(e2,Fsp,pf2,pl2,tol2);
if (PC2.IsNull()) Standard_Failure::Raise(" FUN_correctDegeneratedE : no 2d curve e2");
Standard_Real parv1 = BRep_Tool::Parameter(v1,Ein,Fsp);
Standard_Real parv2 = BRep_Tool::Parameter(v2,Ein,Fsp);
gp_Pnt2d pv1; PCEin->D0(parv1,pv1);
gp_Pnt2d pv2; PCEin->D0(parv2,pv2);
Standard_Real par1 = BRep_Tool::Parameter(vfe1,e1,Fsp);
Standard_Real par2 = BRep_Tool::Parameter(vfe2,e2,Fsp);
gp_Pnt2d p1; PC1->D0(par1,p1);
gp_Pnt2d p2; PC2->D0(par2,p2);
Standard_Real cv1 = (isuiso) ? pv1.Y() : pv1.X();
Standard_Real cv2 = (isuiso) ? pv2.Y() : pv2.X();
Standard_Real c1 = (isuiso) ? p1.Y() : p1.X();
Standard_Real c2 = (isuiso) ? p2.Y() : p2.X();
Standard_Real d1 = (c1 - cv1);
Standard_Real d2 = (c2 - cv2);
Standard_Real adc = Abs(c1 - c2);
Standard_Real adcv = Abs(cv1 - cv2);
Standard_Real tol2d = 1.e-6;
Standard_Boolean mmd = (Abs(adc-adcv) < tol2d);
if (mmd) { // correction de CTS20973
gp_Vec2d transl(0.,1.); if (isviso) transl = gp_Vec2d(1.,0.);
transl.Multiply(d1); // ou d2
ok = FUN_tool_translate(transl,Fsp,Ein);
}
else {
// redefinition des parametres de v1,v2 de Ein tels que des parametres de
#ifdef DEB
if (TopOpeBRepTool_GettraceCORRISO()) {
cout<<"FUN_correctDegeneratedE : !mmd NYI"<<endl;
}
#endif
ok = Standard_False;
}
return ok;
} //FUN_correctDegeneratedE*/
/*static Standard_Boolean FUN_tool_reguUV(const TopoDS_Face& FF, TopoDS_Face& fF)
{
const TopoDS_Face& F = TopoDS::Face(FF);
Standard_Boolean uclosed,vclosed; Standard_Real uperiod,vperiod;
Standard_Boolean closed = FUN_tool_closedS(F,uclosed,uperiod,vclosed,vperiod);
if (!closed) return Standard_False;
Standard_Real tolu,tolv; FUN_tool_tolUV(TopoDS::Face(fF),tolu,tolv);
TopTools_ListOfShape leko;
// --------
TopTools_IndexedMapOfOrientedShape mape;
TopExp_Explorer ex(fF, TopAbs_EDGE);
for (; ex.More(); ex.Next()){
const TopoDS_Edge& ee = TopoDS::Edge(ex.Current());
TopAbs_Orientation oee = ee.Orientation();
TopAbs_Orientation oe = TopAbs::Complement(oee);
TopoDS_Edge e = TopoDS::Edge(ee.Oriented(oe));
Standard_Boolean hasoppo = mape.Contains(e); // e with complement ori was added to mape
if (hasoppo) {
// ee :
Standard_Real ff,ll; Handle(Geom2d_Curve) PCee = BRep_Tool::CurveOnSurface(ee,F,ff,ll);
Standard_Boolean uisoee,visoee; gp_Dir2d d2dee; gp_Pnt2d O2dee;
Standard_Boolean uvisoee = FUN_tool_IsUViso(PCee,uisoee,visoee,d2dee,O2dee);
// e :
Standard_Real f,l; Handle(Geom2d_Curve) PCe = BRep_Tool::CurveOnSurface(e,F,f,l);
Standard_Boolean uisoe,visoe; gp_Dir2d d2de; gp_Pnt2d O2de;
Standard_Boolean uvisoe = FUN_tool_IsUViso(PCe,uisoe,visoe,d2de,O2de);
// isfaulty :
Standard_Boolean isfaulty = Standard_False;
Standard_Real dd = O2dee.Distance(O2de);
if (uisoee && uisoe) isfaulty = (dd < tolu);
if (visoee && visoe) isfaulty = (dd < tolv);
if (isfaulty) leko.Append(ee);
}
else mape.Add(ee);
}
Standard_Integer nko = leko.Extent();
if (nko != 1) return Standard_False;
// eko = edge with faulty pcurve :
const TopoDS_Shape& eko = leko.First();
TopAbs_Orientation oeko = eko.Orientation();
TopTools_ListOfShape edges; ex.Init(fF, TopAbs_EDGE);
for (; ex.More(); ex.Next()){
const TopoDS_Shape& ee = ex.Current();
if (!ee.IsSame(eko)) edges.Append(ee);
}
// fe = edge with vfe = vertex(ivfe) not uv-connexed :
TopoDS_Shape fe; Standard_Integer ivfe=0;
Standard_Boolean det = ::FUN_DetectEdgewithfaultyUV(FF,fF,edges,Standard_False,fe,ivfe);
if (!det) return Standard_False;
TopTools_Array1OfShape Vfe(1,2); FUN_Vertices(TopoDS::Edge(fe),Vfe);
TopAbs_Orientation ofe = fe.Orientation();
const TopoDS_Vertex& vfe = TopoDS::Vertex(Vfe(ivfe));
Standard_Real parfe = BRep_Tool::Parameter(vfe,TopoDS::Edge(fe));
gp_Pnt2d uvfe; Standard_Boolean ok = FUN_tool_paronEF(TopoDS::Edge(fe),parfe,F,uvfe);
if (!ok) return Standard_False;
// ivconnex :
Standard_Integer ivconnex = (ivfe == 1) ? 2 : 1;
// if (ofe == TopAbs_REVERSED) ivconnex = (ivconnex == 1) ? 2 : 1;
// vertex(ivconnex) of eko FORWARD
TopoDS_Edge ekoFOR = TopoDS::Edge(eko.Oriented(TopAbs_FORWARD));
TopTools_Array1OfShape Veko(1,2); FUN_Vertices(TopoDS::Edge(ekoFOR),Veko);
const TopoDS_Vertex& veko1 = TopoDS::Vertex(Veko(1));
const TopoDS_Vertex& veko2 = TopoDS::Vertex(Veko(2));
Standard_Integer iveko = 0;
if (veko1.IsSame(vfe)) iveko = 1;
if (veko2.IsSame(vfe)) iveko = 2;
if (iveko == 0) return Standard_False;
// ett : edge same eko with pcurve to translate
// isekoFOR=true : vfe should be connexed to vertex(ivconnex) of ekoFOR
Standard_Boolean isekoFOR = (iveko == ivconnex);
TopAbs_Orientation oett = isekoFOR ? TopAbs_FORWARD : TopAbs_REVERSED;
TopoDS_Edge ett = TopoDS::Edge(eko.Oriented(oett));
const TopoDS_Vertex& vtt = TopoDS::Vertex(Veko(iveko));
Standard_Real parett = BRep_Tool::Parameter(vtt,ett);
gp_Pnt2d uvtt; ok = FUN_tool_paronEF(ett,parett,F,uvtt);
if (!ok) return Standard_False;
Standard_Real du = uvfe.X()-uvtt.X();
Standard_Real dv = uvfe.Y()-uvtt.Y();
Standard_Boolean tru=Standard_False, trv=Standard_False;
if (uclosed) tru = (Abs(Abs(du)-uperiod) < tolu);
if (vclosed) trv = (Abs(Abs(dv)-vperiod) < tolv);
if (!tru && !trv) return Standard_False;
gp_Vec2d tt;
if (tru) tt = gp_Vec2d(du,0.);
if (trv) tt = gp_Vec2d(0.,dv);
Standard_Real f,l; Handle(Geom2d_Curve) PC1 = BRep_Tool::CurveOnSurface(ett,F,f,l);
Standard_Boolean uisoett,visoett; gp_Dir2d d2dett; gp_Pnt2d o2dett;
Standard_Boolean uvisoett = FUN_tool_IsUViso(PC1,uisoett,visoett,d2dett,o2dett);o2dett.Translate(tt);
Handle(Geom2d_Line) L2d = new Geom2d_Line(o2dett,d2dett);
Handle(Geom2d_TrimmedCurve) PC2 = new Geom2d_TrimmedCurve(L2d,f,l);
BRep_Builder BB;
Standard_Real toltt = BRep_Tool::Tolerance(ett);
// BB.UpdateEdge(TopoDS::Edge(ett),PC2,PC1,fF,toltt);
// xpu220998 : cto cylcong A1
Handle(Geom2d_Curve) nullc2d;
BB.UpdateEdge(TopoDS::Edge(ekoFOR),nullc2d,nullc2d,fF,toltt); // clear
if (isekoFOR) BB.UpdateEdge(TopoDS::Edge(ekoFOR),PC2,PC1,fF,toltt);
else BB.UpdateEdge(TopoDS::Edge(ekoFOR),PC1,PC2,fF,toltt);
return Standard_True;
}*/
static Standard_Boolean FUN_connexX(const Standard_Boolean onU, TopOpeBRepTool_CORRISO& CORRISO,
const TopTools_ListOfShape& EdstoCheck, TopTools_DataMapOfOrientedShapeInteger& fyEds)
// purpose : Fref is x-periodic,
// <fyEds>={(fye,recadre)}, recadre = INCREASE,DECREASE
// fye has its 2 bounds faulty
{
fyEds.Clear();
Standard_Real tolF = BRep_Tool::Tolerance(CORRISO.Fref());
Standard_Integer Index = onU ? 1 : 2;
Standard_Real xperiod; Standard_Boolean xclosed = CORRISO.Refclosed(Index,xperiod);
if (!xclosed) return Standard_False;
Standard_Real xtol = CORRISO.Tol(Index,tolF);
// fy has its 2 uvbounds non-connexed
//nyixpu300998 : iterative (while ko) + map of "static" edges
TopoDS_Shape fy; Standard_Integer Ify=0; Standard_Boolean hasfy = CORRISO.EdgeWithFaultyUV(EdstoCheck,2,fy,Ify);
if (!hasfy) return Standard_False;
TopOpeBRepTool_C2DF C2DF; Standard_Boolean isb = CORRISO.UVRep(TopoDS::Edge(fy),C2DF);
if (!isb) return Standard_False; // NYIRAISE
TopTools_Array1OfShape vfy(1,2); TopOpeBRepTool_TOOL::Vertices(TopoDS::Edge(fy),vfy);
for (Standard_Integer ii = 1; ii <=2; ii++) {
// vff = vertex[ii] of fy
const TopoDS_Vertex& vff = TopoDS::Vertex(vfy(ii));
Standard_Real parvff = TopOpeBRepTool_TOOL::ParE(ii,TopoDS::Edge(fy));gp_Pnt2d uvff = TopOpeBRepTool_TOOL::UVF(parvff,C2DF);
// loe list of edges connexed to faultE
TopTools_ListOfShape loe; isb = CORRISO.Connexity(vff,loe);
if (!isb) return Standard_False; // FUNRAISE
TopTools_ListIteratorOfListOfShape ite(loe); // iteration on connex edges of vff
for (; ite.More(); ite.Next()){
const TopoDS_Edge& ee = TopoDS::Edge(ite.Value());
TopTools_Array1OfShape vee(1,2); TopOpeBRepTool_TOOL::Vertices(ee,vee);
for (Standard_Integer ive = 1; ive <=2; ive++) {
// ve = vertex[ive] of ee
const TopoDS_Vertex& ve = TopoDS::Vertex(vee(ive));
Standard_Boolean samev = ve.IsSame(vff);
if (!samev) continue;
if (ive == ii) continue;
TopOpeBRepTool_C2DF C2DFe; isb = CORRISO.UVRep(ee,C2DFe);
if (!isb) return Standard_False; // FUNRAISE
Standard_Real paree = TopOpeBRepTool_TOOL::ParE(ive,ee); gp_Pnt2d uve = TopOpeBRepTool_TOOL::UVF(paree,C2DFe);
// xxtrsl :
Standard_Real dxx = onU ? uve.X()-uvff.X() : uve.Y()-uvff.Y();
Standard_Boolean isper =( Abs(xperiod-Abs(dxx)) < xtol);
if (!isper) continue;
Standard_Integer recadre = (dxx > 0) ? INCREASE : DECREASE;
fyEds.Bind(fy,recadre);
} //ive=1..2
}//ite(loe)
}//ii=1..2
return !fyEds.IsEmpty();
} // FUN_connexX
//=======================================================================
//function : CorrectONUVISO
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::CorrectONUVISO(const TopoDS_Face& Fin, TopoDS_Face& Fsp)
// <Fref> is x-periodic
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceCORRISO();
if (trc) cout<<"\n#### CorrectONUVISO ####\n\n";
debcorrUV();
#endif
Standard_Real tolF = BRep_Tool::Tolerance(Fin);
TopOpeBRepTool_CORRISO CORRISO(Fin);
Standard_Real uperiod,vperiod;
Standard_Boolean uclosed = CORRISO.Refclosed(1,uperiod);
Standard_Boolean vclosed = CORRISO.Refclosed(2,vperiod);
if (!uclosed && !vclosed) return Standard_False;
CORRISO.Init(Fsp);
Standard_Boolean ok = CORRISO.UVClosed();
if (ok) return Standard_True; // Fsp is valid
// 1. We check connexity among all edges of <Fsp>
// if we find on edge with 2 faulty UVbounds, we try to UVconnect it.
// for (Standard_Integer i=1; i<=2; i++) {
Standard_Integer i ;
for ( i=1; i<=2; i++) {
Standard_Boolean onU = (i==1) ? Standard_True : Standard_False;
const TopTools_ListOfShape& Tocheck = CORRISO.Eds();
TopTools_DataMapOfOrientedShapeInteger fyEds; ok =::FUN_connexX(onU,CORRISO,Tocheck,fyEds);
if (!ok) continue;
ok = CORRISO.TrslUV(onU,fyEds);
if (!ok) continue;
ok = CORRISO.UVClosed();
if (!ok) continue;
ok = CORRISO.GetnewS(Fsp);
if (!ok) return Standard_False; //NYIRAISE
return Standard_True;
}
// 2. x-2drep(edges) are in [xfirst,xfirst+xperiod]
for (i = 1; i <=2; i++) {
Standard_Boolean onU = (i==1);
Standard_Real xper=0.; Standard_Boolean xclosed = CORRISO.Refclosed(i,xper);
if (!xclosed) continue;
Standard_Real tolx = CORRISO.Tol(i,tolF);
tolx *= 1.e2; // BUC60380
TopTools_DataMapOfOrientedShapeInteger FyEds; Standard_Boolean hasfy = CORRISO.EdgesOUTofBoundsUV(CORRISO.Eds(),onU,tolx,FyEds);
if (!hasfy) continue;
ok = CORRISO.TrslUV(onU,FyEds);
if (!ok) return Standard_False;
ok = CORRISO.UVClosed();
if (!ok) continue;
ok = CORRISO.GetnewS(Fsp);
if (!ok) return Standard_False; //NYIRAISE
return Standard_True;
}
return Standard_False;
/*// xpu310898 : eC closing ff, ff sdm F(reference face), proj(eC,F) gives ee with
// !closing(ee,Fsp) -> 2drep(Fsp) is not closed.
// purpose : translate pceCFOR or pceCREV
// cto902B7 (ff=f7,eC=e9,F=f14)
ok = ::FUN_tool_reguUV(Fin,Fsp);*/
/*// JYL 980909 : reecriture complete
// 1/ traitement de TOUTES les aretes
// isou et isov fautives (et non la premiere trouvee);
// 2/ traitement des aretes degenerees fautives : CTS20973
TopTools_ListOfShape lisoe,ldege;
TopExp_Explorer exe(Fsp, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Edge& E = TopoDS::Edge(exe.Current());
Standard_Boolean degen = BRep_Tool::Degenerated(E);
if ( degen ) {
ldege.Append(E);
}
else {
Standard_Real f,l; Handle(Geom2d_Curve) PC = BRep_Tool::CurveOnSurface(E,Fin,f,l);
Standard_Boolean uiso,viso; gp_Dir2d d2d; gp_Pnt2d O2d;
Standard_Boolean uviso = FUN_tool_IsUViso(PC,uiso,viso,d2d,O2d);
Standard_Boolean onclosing = (uiso && uclosed) || (viso && vclosed);
if ( onclosing) {
lisoe.Append(E);
}
}
}
Standard_Integer nisoe = lisoe.Extent();
Standard_Integer ndege = ldege.Extent();
if (nisoe ==0 && ndege == 0) return Standard_False;
Standard_Integer tmpisoe;
Standard_Integer tmpdege;
TopTools_ListOfShape lfyisoe; Standard_Boolean tocorrectisoe = Standard_False;
tocorrectisoe = FUN_DetectEdgeswithfaultyUV(Fsp,Fsp,lisoe,Standard_True,lfyisoe,tmpisoe);
TopTools_ListOfShape lfydege; Standard_Boolean tocorrectdege = Standard_False;
tocorrectdege = FUN_DetectEdgeswithfaultyUV(Fsp,Fsp,ldege,Standard_True,lfydege,tmpdege);
tocorrect = (tocorrectisoe || tocorrectdege);
if (!tocorrect) {
return Standard_True;
}
#ifdef DEB
if (trc) {
cout<<"CorrectONUVISO ";
cout<<"iso faulty "<<tocorrectisoe<<" deg faulty "<<tocorrectdege<<endl;;
}
debcorrUV();
#endif
if (tocorrectisoe) {
for (TopTools_ListIteratorOfListOfShape itiso(lfyisoe);itiso.More();itiso.Next()) {
TopoDS_Edge& fyisoe = TopoDS::Edge(itiso.Value());
// !! if the faulty edge ON closing appears twice in <Eds>, NOTHING is done!
// -> see processing ::PurgeClosingEdges later called in WESMakeFaces
Standard_Integer nfoundisoe = 0;
for (exe.Init(Fsp, TopAbs_EDGE); exe.More(); exe.Next()) {
if (exe.Current().IsSame(fyisoe)) {
nfoundisoe++;
}
}
if (nfoundisoe > 1) {
continue;
}
#ifdef DRAW
if (trc) {
cout<<"TopOpeBRepTool correctONUVISO : faulty iso edge"<<endl;
FUN_tool_draw("fyf",Fsp);FUN_tool_draw("fyisoe",fyisoe);
}
#endif
Standard_Boolean ok = ::FUN_correctClosingE(fyisoe,Fsp);
if (!ok) {
FUN_Raise();
continue;
}
}
Standard_Integer tmpisoe;
TopTools_ListOfShape lffyisoe; tocorrectisoe = FUN_DetectEdgeswithfaultyUV(Fsp,Fsp,lfyisoe,Standard_False,lffyisoe,tmpisoe);
} // end lffyisoe process
if (tocorrectdege) {
TopTools_IndexedDataMapOfShapeListOfShape mve;
TopExp::MapShapesAndAncestors(Fsp,TopAbs_VERTEX,TopAbs_EDGE,mve);
for (TopTools_ListIteratorOfListOfShape itdeg(lfydege);itdeg.More();itdeg.Next()) {
TopoDS_Edge& fydege = TopoDS::Edge(itdeg.Value());
#ifdef DRAW
if (trc) {
cout<<"TopOpeBRepTool correctONUVISO : faulty deg edge"<<endl;
FUN_tool_draw("fyf",Fsp);FUN_tool_draw("fydege",fydege);
}
#endif
Standard_Boolean ok = ::FUN_correctDegeneratedE(mve,fydege,Fsp);
if (!ok) {
FUN_Raise();
continue;
}
} // itdeg
TopTools_ListOfShape lffydege; tocorrectdege = FUN_DetectEdgeswithfaultyUV(Fsp,Fsp,lfydege,Standard_False,lffydege,tmpdege);
} // end lfydege process
TopTools_ListOfShape eFsp; FUN_tool_shapes(Fsp,TopAbs_EDGE,eFsp);
TopTools_ListOfShape lffydege; tocorrect = FUN_DetectEdgeswithfaultyUV(Fsp,Fsp,eFsp,Standard_False,lffydege,tmpdege);
Standard_Boolean done = !tocorrect;
return done;*/
} // correctONUVISO
//=======================================================================
//function : MakeFaces
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::MakeFaces(const TopoDS_Face& Fin, const TopTools_ListOfShape& LOF,
const TopTools_IndexedMapOfOrientedShape& MshNOK,
TopTools_ListOfShape& LOFF)
{
// TopOpeBRepDS_BuildTool BT;
BRep_Builder BB;
LOFF.Clear();
TopTools_ListIteratorOfListOfShape it(LOF);
for (; it.More(); it.Next()){
const TopoDS_Face& FF = TopoDS::Face(it.Value());
Standard_Boolean valid = !MshNOK.Contains(FF);
if (valid) {LOFF.Append(FF); continue;}
TopoDS_Shape aLocalShape = Fin.EmptyCopied();
TopoDS_Face newFace = TopoDS::Face(aLocalShape);// BT.CopyFace(Fin,newFace);
// TopoDS_Face newFace = TopoDS::Face(Fin.EmptyCopied());// BT.CopyFace(Fin,newFace);
TopExp_Explorer exw(FF, TopAbs_WIRE);
for (; exw.More(); exw.Next()){
const TopoDS_Wire& W = TopoDS::Wire(exw.Current());
valid = !MshNOK.Contains(W);
// if (valid) {BT.AddFaceWire(newFace,W); continue;}
if (valid) {BB.Add(newFace,W); continue;}
TopoDS_Wire newWire; //BT.MakeWire(newWire);
BB.MakeWire(newWire);
TopExp_Explorer exe(W, TopAbs_EDGE);
Standard_Integer ne = 0;
for (; exe.More(); exe.Next()){
const TopoDS_Edge& E = TopoDS::Edge(exe.Current());
valid = !MshNOK.Contains(E);
if (!valid) continue;
// BT.AddWireEdge(newWire,E);
BB.Add(newWire,E);
ne++;
} // exe
if (ne == 0) continue;
Standard_Boolean closed = FUN_tool_ClosedW(newWire);
// BT.Closed(newWire,closed);
// BT.AddFaceWire(newFace,newWire);
newWire.Closed(closed);
BB.Add(newFace,newWire);
} // exw
LOFF.Append(newFace);
}
return Standard_True;
}
/*static Handle(Geom2d_TrimmedCurve) FUN_translate(const gp_Vec2d& tvector, const TopoDS_Face& fF, TopoDS_Edge& fyE)
{
Standard_Real f,l,tol; Handle(Geom2d_Curve) PC = FUNTOOLC2D_CurveOnSurface(fyE,fF,f,l,tol);
Standard_Boolean isou,isov; gp_Pnt2d o2d; gp_Dir2d d2d;
Standard_Boolean isouv = FUN_tool_IsUViso(PC,isou,isov,d2d,o2d); o2d.Translate(tvector);
Handle(Geom2d_Line) L2d = new Geom2d_Line(o2d,d2d);
Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(L2d,f,l);
return C2d;
}
Standard_EXPORT void FUN_tool_ttranslate(const gp_Vec2d& tvector, const TopoDS_Face& fF, TopoDS_Edge& fyE)
{
Handle(Geom2d_TrimmedCurve) C2d = ::FUN_translate(tvector,fF,fyE);
Standard_Real tole = BRep_Tool::Tolerance(fyE);
BRep_Builder BB;
// Handle(Geom2d_Curve) toclear; BB.UpdateEdge(fyE,toclear,fF,tole);
BB.UpdateEdge(fyE,C2d,fF,tole);
}
static Standard_Boolean FUN_tool_translate(const gp_Vec2d& tvector, TopoDS_Face& fF, TopoDS_Edge& fyE)
// prequesitory : <fF> is on periodic surface, translates edge
// <fyE>'s uorviso to have its uorvpar bounded in [0.,2PI].
{
Handle(Geom2d_TrimmedCurve) C2d = ::FUN_translate(tvector,fF,fyE);
Standard_Real tole = BRep_Tool::Tolerance(fyE);
//xpu040598 : CTS20280 f37 modified when its split is modified!
TopoDS_Face newf; Standard_Boolean ok = FUN_tool_pcurveonF(fF,fyE,C2d,newf);
if (ok) fF = newf;
return ok;
//xpu040598
}
*/

View File

@@ -0,0 +1,50 @@
// File: TopOpeBRepTool_PURGE.hxx
// Created: Tue Nov 24 11:18:31 1998
// Author: Prestataire Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_PURGE_HeaderFile
#define _TopOpeBRepTool_PURGE_HeaderFile
#include <TopOpeBRepTool_define.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <gp_Pnt2d.hxx>
#ifdef DEB
Standard_IMPORT void FUN_REINIT();
Standard_IMPORT Standard_Integer FUN_addepc(const TopoDS_Shape& ed,const TopoDS_Shape& f);
Standard_IMPORT Standard_Integer FUN_addcheckepc(const TopoDS_Shape& ed,const TopoDS_Shape& f);
Standard_IMPORT Standard_Integer FUN_adds(const TopoDS_Shape& s);
Standard_IMPORT void FUN_tool_trace(const Standard_Integer Index);
Standard_IMPORT void FUN_tool_trace(const gp_Pnt2d p2d);
#endif
// ----------------------------------------------------------------------
// TopOpeBRepTool_closing.cxx
// ----------------------------------------------------------------------
//Standard_IMPORT Standard_Boolean FUN_tool_UVonclosing(const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Boolean onU,
// const Standard_Real xfirst, const Standard_Real xperiod,
// const Standard_Real toluv);
Standard_IMPORT Standard_Boolean FUN_tool_correctCLO(TopoDS_Edge& E, const TopoDS_Face& F);
//Standard_IMPORT Standard_Boolean FUN_tool_getEclo(const TopoDS_Face& F, TopoDS_Edge& Eclo);
// ----------------------------------------------------------------------
// TopOpeBRepTool_faulty.cxx
// ----------------------------------------------------------------------
//Standard_IMPORT gp_Pnt2d FUN_GetVParonF(const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Integer Index);
//Standard_IMPORT Standard_Real FUN_toluv(const GeomAdaptor_Surface& GAS, const Standard_Real& tol3d);
//Standard_IMPORT void FUN_tool_Vertices(const TopoDS_Edge& E, TopTools_Array1OfShape& vertices);
//Standard_IMPORT void FUN_mapVloe(const TopoDS_Shape& F, TopTools_IndexedDataMapOfShapeListOfShape& mapVloe);
//Standard_IMPORT Standard_Boolean FUN_DetectEdgeswithfaultyUV(const TopoDS_Face& Fin, const TopoDS_Shape& fF, const TopTools_ListOfShape& ISOEds,
// const Standard_Boolean has2fybounds, TopTools_ListOfShape& lfyE, Standard_Integer& Ivfaulty,
// const Standard_Boolean& stopatfirst=Standard_False);
//Standard_IMPORT Standard_Boolean FUN_DetectEdgewithfaultyUV(const TopoDS_Face& Fin, const TopoDS_Shape& fF, const TopTools_ListOfShape& ISOEds,
// const Standard_Boolean has2fybounds, TopoDS_Shape& fyE, Standard_Integer& Ivfaulty);
//Standard_IMPORT Standard_Boolean FUN_DetectFaultyClosingEdge(const TopoDS_Face& Fin,const TopTools_ListOfShape& Eds,const TopTools_ListOfShape& cEds,TopTools_ListOfShape& fyE);
//Standard_IMPORT Standard_Boolean FUN_isUVClosed(const TopoDS_Face& F, const TopoDS_Face& fF);
// ----------------------------------------------------------------------
// TopOpeBRepTool_PURGE.cxx
// ----------------------------------------------------------------------
//Standard_IMPORT void FUN_tool_ttranslate(const gp_Vec2d& tvector, const TopoDS_Face& fF, TopoDS_Edge& fyE);
#endif

View File

@@ -0,0 +1,89 @@
-- File: TopOpeBRepTool_PurgeInternalEdges.cdl
-- Created: Thu Nov 19 15:23:38 1998
-- Author: Jean-Michel BOULCOURT
-- <jmb@coulox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class PurgeInternalEdges from TopOpeBRepTool
---Purpose: remove from a shape, the internal edges that are
-- not connected to any face in the shape. We can
-- get the list of the edges as a
-- DataMapOfShapeListOfShape with a Face of the Shape
-- as the key and a list of internal edges as the
-- value. The list of internal edges means edges
-- that are not connected to any face in the shape.
--
-- Example of use :
-- TopTools_DataMapOfShapeListOfShape mymap;
-- TopOpeBRepTool_PurgeInternalEdges
-- mypurgealgo(mysolid); mypurgealgo.GetFaces(mymap);
--
uses
Shape from TopoDS,
DataMapOfShapeListOfShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools
raises
ConstructionError from Standard,
NullObject from Standard
is
Create (theShape : Shape from TopoDS;
PerformNow : Boolean from Standard = Standard_True)
returns PurgeInternalEdges from TopOpeBRepTool
raises NullObject from Standard,
ConstructionError from Standard;
---Purpose: Initialize members and begin exploration of shape
-- depending of the value of PerformNow
Faces (me : in out ; theMapFacLstEdg : in out DataMapOfShapeListOfShape from TopTools);
---Purpose: returns the list internal edges associated with
-- the faces of the myShape. If PerformNow was False
-- when created, then call the private Perform method
-- that do the main job.
Shape (me : in out)
returns Shape from TopoDS
raises NullObject from Standard;
---Purpose: returns myShape modified with the list of internal
-- edges removed from it.
---C++: return &
NbEdges (me )
returns Integer from Standard
raises NullObject from Standard;
---Purpose: returns the number of edges candidate to be removed
---C++: return const
IsDone (me)
returns Boolean from Standard
---Purpose: returns False if the list of internal edges has
-- not been extracted
---C++: inline
is static;
Perform (me : in out);
---Purpose: Using the list of internal edge from each face,
-- rebuild myShape by removing thoses edges.
--
BuildList (me : in out)
---Purpose: Do the main job. Explore all the edges of myShape and
-- build a map with faces as a key and list of internal
-- edges(without connected faces) as value.
--
is private;
fields
myShape : Shape from TopoDS;
myIsDone : Boolean from Standard;
myMapFacLstEdg : DataMapOfShapeListOfShape from TopTools;
myMapEdgLstFac : IndexedDataMapOfShapeListOfShape from TopTools is protected;
end PurgeInternalEdges;

View File

@@ -0,0 +1,264 @@
// File: TopOpeBRepTool_PurgeInternalEdges.cxx
// Created: Thu Nov 19 15:23:38 1998
// Author: Jean-Michel BOULCOURT
// <jmb@coulox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_PurgeInternalEdges.ixx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <BRepTools_Substitution.hxx>
//=======================================================================
//function : TopOpeBRepTool_PurgeInternalEdges
//purpose : Initializes some variables for the algorithm and perform
// the computation of the internal edges of the shape
//=======================================================================
TopOpeBRepTool_PurgeInternalEdges::TopOpeBRepTool_PurgeInternalEdges(const TopoDS_Shape& theShape,const Standard_Boolean PerformNow):myShape(theShape),myIsDone(Standard_False)
{
// if (theShape.ShapeType() != TopAbs_SHELL && theShape.ShapeType() != TopAbs_SOLID)
// Standard_ConstructionError::Raise("PurgeInternalEdges");
Standard_NullObject_Raise_if(theShape.IsNull(),"PurgeInternalEdges");
if (PerformNow) {
Perform();
}
}
//=======================================================================
//function : Faces
//purpose :
//=======================================================================
void TopOpeBRepTool_PurgeInternalEdges::Faces(TopTools_DataMapOfShapeListOfShape& theMapFacLstEdg)
{
if (!myIsDone) {
BuildList();
}
theMapFacLstEdg = myMapFacLstEdg;
}
//=======================================================================
//function : NbEdges
//purpose :
//=======================================================================
const Standard_Integer TopOpeBRepTool_PurgeInternalEdges::NbEdges() const
{
Standard_NullObject_Raise_if(myShape.IsNull(),"PurgeInternalEdges : No Shape");
Standard_Integer nbedges = 0;
// if we have at least on internal (or external) edge to remove
if (myMapFacLstEdg.Extent() > 0) {
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itFacEdg;
// TopTools_ListIteratorOfListOfShape itEdg;
for (itFacEdg.Initialize(myMapFacLstEdg); itFacEdg.More(); itFacEdg.Next()) {
const TopoDS_Shape& facecur = itFacEdg.Key();
const TopTools_ListOfShape& LmapEdg = myMapFacLstEdg.Find(facecur);
nbedges += LmapEdg.Extent();
}
}
return nbedges;
}
//=======================================================================
//function : Shape
//purpose :
//=======================================================================
TopoDS_Shape& TopOpeBRepTool_PurgeInternalEdges::Shape()
{
Standard_NullObject_Raise_if(myShape.IsNull(),"PurgeInternalEdges : No Shape");
return myShape;
}
//=======================================================================
//function : BuildList
//purpose : Build the map of faces with the list of inernal edges.
//=======================================================================
void TopOpeBRepTool_PurgeInternalEdges::BuildList()
{
TopExp_Explorer ExpEdge;
TopAbs_Orientation orien;
//--------------------------------------------------------
// Step One : Build the map of the faces ancestor of edges
//--------------------------------------------------------
// Clear the maps
myMapEdgLstFac.Clear();
TopExp::MapShapesAndAncestors(myShape,TopAbs_EDGE,TopAbs_FACE,myMapEdgLstFac);
//----------------------------------------------------------------
// Step Two : Explore the map myMapFacLstEdg to keep only the internal
// or external edges which have no connex faces
//----------------------------------------------------------------
Standard_Boolean ToKeep;
Standard_Integer iEdg;
TopTools_ListIteratorOfListOfShape itFac,itFacToTreat;
TopTools_ListOfShape LstFacToTreat;
// for each edge of myMapEdgLstFac
for (iEdg = 1; iEdg <= myMapEdgLstFac.Extent(); iEdg++) {
const TopoDS_Shape& edgecur = myMapEdgLstFac.FindKey(iEdg);
const TopTools_ListOfShape& LmapFac = myMapEdgLstFac.FindFromKey(edgecur);
// if there are more than on face connex to the edge then examine the orientation of
// the edge in the faces to see it is only Internal or External. In that case the edge
// can be removed
itFac.Initialize(LmapFac);
LstFacToTreat.Clear();
if (LmapFac.Extent() > 1) {
ToKeep = Standard_False;
// for each face in the list of the edge
while (itFac.More() && !ToKeep) {
const TopoDS_Shape& facecur = itFac.Value();
// find the edge in the face to get its relative orientation to the face
for (ExpEdge.Init(facecur,TopAbs_EDGE); ExpEdge.More(); ExpEdge.Next()) {
const TopoDS_Shape& edge = ExpEdge.Current();
orien = edge.Orientation();
if (edge.IsSame(edgecur)) {
// we found the edge. Now check if its orientation is internal or external
// then the face is candidate to be modified. So put it in a temporary List of shapes
if (orien == TopAbs_INTERNAL || orien == TopAbs_EXTERNAL) {
LstFacToTreat.Append(facecur);
}
else {
// there is at least one face that contains that edge with a forward
// or reversed orientation. So we must keep that edge.
LstFacToTreat.Clear();
ToKeep = Standard_True;
}
break;
}
}
itFac.Next();
}
}
else {
if (edgecur.Orientation() == TopAbs_INTERNAL || edgecur.Orientation() == TopAbs_EXTERNAL) {
LstFacToTreat.Append(itFac.Value());
}
}
// at that point, we have in the list LstFacToTreat the faces in which edgecur is
// connex and is coded only Internal or External.
if (!LstFacToTreat.IsEmpty()) {
TopTools_MapOfShape mapUniqEdg;
for (itFacToTreat.Initialize(LstFacToTreat); itFacToTreat.More(); itFacToTreat.Next()) {
const TopoDS_Shape& face = itFacToTreat.Value();
//we build the resulting map with a face as a key and a list of internal (or external)
// edges to remove from the face.
if (!myMapFacLstEdg.IsBound(face)) {
TopTools_ListOfShape LmapEdg;
if (!mapUniqEdg.Contains(edgecur)) {
mapUniqEdg.Add(edgecur);
LmapEdg.Append(edgecur);
myMapFacLstEdg.Bind(face,LmapEdg);
}
}
else { // just append the edge to the list of edges of the face
TopTools_ListOfShape& LmapEdg = myMapFacLstEdg.ChangeFind(face);
if (!mapUniqEdg.Contains(edgecur)) {
mapUniqEdg.Add(edgecur);
LmapEdg.Append(edgecur);
}
}
}
}
}
myIsDone = Standard_True;
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void TopOpeBRepTool_PurgeInternalEdges::Perform()
{
// if the list has not been yet built then do it
if (!myIsDone) {
BuildList();
}
// if we have at least on internal (or external) edge to remove
if (myMapFacLstEdg.Extent() > 0) {
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itFacEdg;
TopTools_ListIteratorOfListOfShape itEdg;
TopTools_ListOfShape EmptyList;
BRepTools_Substitution Bsub;
for (itFacEdg.Initialize(myMapFacLstEdg); itFacEdg.More(); itFacEdg.Next()) {
const TopoDS_Shape& facecur = itFacEdg.Key();
const TopTools_ListOfShape& LmapEdg = myMapFacLstEdg.Find(facecur);
for (itEdg.Initialize(LmapEdg); itEdg.More(); itEdg.Next()) {
Bsub.Substitute(itEdg.Value(),EmptyList);
}
}
Bsub.Build(myShape);
if (Bsub.IsCopied(myShape)) {
myShape=(Bsub.Copy(myShape)).First();
}
}
}

View File

@@ -0,0 +1,6 @@
inline Standard_Boolean TopOpeBRepTool_PurgeInternalEdges::IsDone() const
{
return myIsDone;
}

View File

@@ -0,0 +1,109 @@
-- File: TopOpeBRepTool_REGUS.cdl
-- Created: Mon Jan 4 14:30:25 1999
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class REGUS from TopOpeBRepTool
uses
Shape from TopoDS,
Edge from TopoDS,
Face from TopoDS,
ListOfShape from TopTools,
MapOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools,
IndexedDataMapOfShapeListOfShape from TopTools,
IndexedMapOfShape from TopTools
is
Create
returns REGUS from TopOpeBRepTool;
Init (me : in out; S : Shape from TopoDS);
S(me) returns Shape from TopoDS;
---C++: return const &
-- <S> regularization
--
-- TopOpeBRepTool_REGUS REGUS;
--
-- REGUS.SetOshNsh(OshNsh); // optionnal
-- REGUS.SetFsplits(Fsplits); // optionnal
--
-- REGUS.Init(S);
-- REGUS.MapS();
-- REGUS.SplitFaces();
-- REGUS.REGU();
--
-- // OshNsh = {(Sh,splitsofSh) if Sh has splits}
-- REGUS.GetOshNsh(OshNsh);
-- // Fsplits ={(F,splitsofF) if F has splits}
-- REGUS.GetFsplits(Fsplits);
MapS(me : in out)
returns Boolean;
WireToFace(myclass; Fanc : Face from TopoDS; nWs : ListOfShape from TopTools;
nFs : out ListOfShape from TopTools)
returns Boolean;
-- Builds up a list of new faces <nFs> on <Fanc> geometry using the
-- list of wires <nWs>.
SplitF(myclass; Fanc : Face from TopoDS; FSplits : out ListOfShape from TopTools)
returns Boolean;
-- Splits face <Fanc> on its INTERNAL edges if any. Returns true if split succeeds.
SplitFaces(me : in out)
returns Boolean;
-- Splits all faces and updates the map of connexity.
REGU(me : in out)
returns Boolean;
-- <myS> gives <Splits> after complete regularization
SetFsplits(me : in out; Fsplits : in out DataMapOfShapeListOfShape from TopTools);
GetFsplits(me; Fsplits : out DataMapOfShapeListOfShape from TopTools);
SetOshNsh(me : in out; OshNsh : in out DataMapOfShapeListOfShape from TopTools);
GetOshNsh(me; OshNsh : out DataMapOfShapeListOfShape from TopTools);
--
-- INTERNAL methods
--
-- <S> = { Block }, Block = { ({edges of fi},fi) },
-- a Block starts with (e1,f1)
-- ends when all edges of { faces in Block } are touched.
InitBlock(me : in out)
returns Boolean;
-- Gets starts elements for a new block
NextinBlock(me : in out)
returns Boolean;
-- Go to next element in the block
NearestF(me; e : Edge from TopoDS; lof : ListOfShape from TopTools; ffound : out Face from TopoDS)
returns Boolean;
-- Gets nearest face Ang(myf,ffound)=Min{ Ang(myf,fi) , fi in lof }
-- <e> is shared by all faces of <lof>
fields
hasnewsplits : Boolean;
myFsplits : DataMapOfShapeListOfShape from TopTools;
myOshNsh : DataMapOfShapeListOfShape from TopTools;
myS : Shape from TopoDS;
mymapeFsstatic : DataMapOfShapeListOfShape from TopTools;
mymapeFs : DataMapOfShapeListOfShape from TopTools;
mymapemult : IndexedMapOfShape from TopTools;
-- BLOCK processing :
mynF : Integer; -- <myS> gives mynf faces to regularize.
myoldnF : Integer; -- <myS> has myoldnF faces.
myf : Shape from TopoDS; -- current face
myedstoconnect : MapOfShape from TopTools; -- edges to connect
mylFinBlock : ListOfShape from TopTools; -- list of faces stored in the current block
end REGUS;

View File

@@ -0,0 +1,781 @@
// File: TopOpeBRepTool_REGUS.cxx
// Created: Mon Jan 4 15:34:02 1999
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_REGUS.ixx>
#include <TopoDS_Shell.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_REGUW.hxx>
#include <TopOpeBRepTool_CLASSI.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_connexity.hxx>
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
#define M_FORWARD(ori) (ori == TopAbs_FORWARD)
#define M_REVERSED(ori) (ori == TopAbs_REVERSED)
#define M_INTERNAL(ori) (ori == TopAbs_INTERNAL)
#define M_EXTERNAL(ori) (ori == TopAbs_EXTERNAL)
#define FORWARD (1)
#define REVERSED (2)
#define INTERNAL (3)
#define EXTERNAL (4)
#define CLOSING (5)
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceREGUSO();
static TopTools_IndexedMapOfShape STATIC_mape, STATIC_mapf, STATIC_mapw, STATIC_mapsh;
static Standard_Integer FUN_adds(const TopoDS_Shape& s) {
TopAbs_ShapeEnum typ = s.ShapeType();
TCollection_AsciiString aa; Standard_Integer is = 0;
if (typ == TopAbs_SHELL) {aa = TCollection_AsciiString("s"); is = STATIC_mapsh.Add(s);}
if (typ == TopAbs_WIRE) {aa = TCollection_AsciiString("w"); is = STATIC_mapw.Add(s); }
if (typ == TopAbs_FACE) {aa = TCollection_AsciiString("f"); is = STATIC_mapf.Add(s); }
if (typ == TopAbs_EDGE) {aa = TCollection_AsciiString("e"); is = STATIC_mape.Add(s); }
#ifdef DRAW
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
if (trc) FUN_tool_draw(aa,s,is);
#endif
return is;
}
#endif
static void FUN_Raise()
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
if (trc) cout<<"***** Failure in REGUS **********"<<endl;
// Standard_Failure::Raise("REGUS");
#endif
}
//=======================================================================
//function : Create
//purpose :
//=======================================================================
TopOpeBRepTool_REGUS::TopOpeBRepTool_REGUS()
{
hasnewsplits = Standard_False;
mynF = myoldnF = 0;
myFsplits.Clear();
myOshNsh.Clear();
myS.Nullify();
mymapeFs.Clear();
mymapeFsstatic.Clear();
mymapemult.Clear();
myedstoconnect.Clear();
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUS::Init(const TopoDS_Shape& S)
{
hasnewsplits = Standard_False;
mynF = myoldnF = 0;
myS = S;
mymapeFs.Clear();
mymapeFsstatic.Clear();
mymapemult.Clear();
myedstoconnect.Clear();
}
//=======================================================================
//function : S
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepTool_REGUS::S() const
{
return myS;
}
//=======================================================================
//function : SetFsplits
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUS::SetFsplits(TopTools_DataMapOfShapeListOfShape& Fsplits)
{
myFsplits = Fsplits;
}
//=======================================================================
//function : GetFsplits
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUS::GetFsplits(TopTools_DataMapOfShapeListOfShape& Fsplits) const
{
Fsplits = myFsplits;
}
//=======================================================================
//function : SetOshNsh
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUS::SetOshNsh(TopTools_DataMapOfShapeListOfShape& OshNsh)
{
myOshNsh = OshNsh;
}
//=======================================================================
//function : GetOshNsh
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUS::GetOshNsh(TopTools_DataMapOfShapeListOfShape& OshNsh) const
{
OshNsh = myOshNsh;
}
//=======================================================================
//function : MapS
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::MapS()
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
Standard_Integer ish = FUN_adds(S());
if (trc) cout<<"** MAPPING ** shape"<<ish<<endl;
#endif
// mymapeFs, myoldnF :
myoldnF = 0;
TopExp_Explorer exf(myS, TopAbs_FACE);
for (; exf.More(); exf.Next()){
const TopoDS_Shape& f = exf.Current(); myoldnF++;
TopExp_Explorer exe(f, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Shape& e = exe.Current();
Standard_Boolean isb = mymapeFs.IsBound(e);
if (isb) {mymapeFs.ChangeFind(e).Append(f); mymapeFsstatic.ChangeFind(e).Append(f);}
else {TopTools_ListOfShape lof; lof.Append(f); mymapeFs.Bind(e,lof); mymapeFsstatic.Bind(e,lof);}
}//exe
}//exf
mynF = myoldnF;
// mymapemult :
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(mymapeFs);
for (; itm.More(); itm.Next()){
const TopoDS_Shape& e = itm.Key();
const TopTools_ListOfShape& lof = itm.Value();
Standard_Integer nf = lof.Extent();
if (nf > 2) mymapemult.Add(e);
#ifdef DEB
if (trc) {
cout <<"co(e"<<FUN_adds(e)<<")= ";
TopTools_ListIteratorOfListOfShape it(lof);
for (; it.More(); it.Next())cout<<" f"<<FUN_adds(it.Value());
cout<<endl;}
#endif
}//itm(mymapeFs)
return Standard_True;
}
//=======================================================================
//function : WireToFace
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::WireToFace(const TopoDS_Face& Fanc, const TopTools_ListOfShape& nWs, TopTools_ListOfShape& nFs)
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
#endif
nFs.Clear();
TopTools_DataMapOfShapeListOfShape mapWlow;
TopoDS_Shape aLocalShape = Fanc.Oriented(TopAbs_FORWARD);
TopoDS_Face aFace = TopoDS::Face(aLocalShape);
// TopoDS_Face aFace = TopoDS::Face(Fanc.Oriented(TopAbs_FORWARD));
TopOpeBRepTool_CLASSI classi; classi.Init2d(aFace);
Standard_Boolean classifok = classi.Classilist(nWs,mapWlow);
if (!classifok) {
#ifdef DEB
if (trc) cout<<"** classif fails"<<endl;
#endif
return Standard_False;
}
Standard_Boolean facesbuilt = TopOpeBRepTool_TOOL::WireToFace(Fanc, mapWlow, nFs);
if (!facesbuilt) {
#ifdef DEB
if (trc) cout<<"** facesbuilt fails"<<endl;
#endif
return Standard_False;
}
return Standard_True;
}
//=======================================================================
//function : SplitF
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::SplitF(const TopoDS_Face& Fanc, TopTools_ListOfShape& FSplits)
{
// prequesitory : All edges have already been splitted, there is no
// internal vertex on edge, except for internal edge.
TopAbs_Orientation oAnc = Fanc.Orientation();
TopoDS_Shape aLocalShape = Fanc.Oriented(TopAbs_FORWARD);
TopoDS_Face aFace = TopoDS::Face(aLocalShape);
// TopoDS_Face aFace = TopoDS::Face(Fanc.Oriented(TopAbs_FORWARD));
FSplits.Clear();
TopOpeBRepTool_REGUW REGUW(aFace);
TopTools_ListOfShape nWs; Standard_Boolean hassp = Standard_False;
TopExp_Explorer exw(aFace, TopAbs_WIRE);
for (; exw.More(); exw.Next()) {
const TopoDS_Shape& w = exw.Current();
REGUW.Init(w);
REGUW.MapS();
TopTools_ListOfShape eIs;
// --------
TopExp_Explorer exe(w, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Shape& e = exe.Current();
if (M_INTERNAL(e.Orientation())) eIs.Append(e);
}//exe
TopTools_ListIteratorOfListOfShape ite(eIs);
// if (!ite.More()) {nWs.Append(w); continue;}
while (ite.More()) {
const TopoDS_Edge& eI = TopoDS::Edge(ite.Value());
TopoDS_Vertex vf,vl;
TopoDS_Shape aLocalShape = eI.Oriented(TopAbs_FORWARD);
TopExp::Vertices(TopoDS::Edge(aLocalShape),vf,vl);
// TopExp::Vertices(TopoDS::Edge(eI.Oriented(TopAbs_FORWARD)),vf,vl);
TopOpeBRepTool_connexity cof; REGUW.Connexity(vf,cof); TopTools_ListOfShape lef; Standard_Integer nef = cof.AllItems(lef);
TopOpeBRepTool_connexity col; REGUW.Connexity(vl,col); TopTools_ListOfShape lel; Standard_Integer nel = col.AllItems(lel);
if ((nef <= 1)||(nel <= 1)) {eIs.Remove(ite);continue;}
// prequesitory : we do not have internal vertices in edges oriented FOR
aLocalShape = eI.Oriented(TopAbs_REVERSED);
TopoDS_Edge eR = TopoDS::Edge(aLocalShape);
aLocalShape = eI.Oriented(TopAbs_FORWARD);
TopoDS_Edge eF = TopoDS::Edge(aLocalShape);
// TopoDS_Edge eR = TopoDS::Edge(eI.Oriented(TopAbs_REVERSED));
// TopoDS_Edge eF = TopoDS::Edge(eI.Oriented(TopAbs_FORWARD));
TopExp_Explorer exv(eI, TopAbs_VERTEX);
for (; exv.More(); exv.Next()){
const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
Standard_Boolean ok = REGUW.RemoveOldConnexity(v,INTERNAL,eI);
if (!ok) return Standard_False;
Standard_Integer ivF = TopOpeBRepTool_TOOL::OriinSor(v,eF);
ok = REGUW.AddNewConnexity(v,ivF,eF);
if (!ok) return Standard_False;
Standard_Integer ivR = TopOpeBRepTool_TOOL::OriinSor(v,eR);
ok = REGUW.AddNewConnexity(v,ivR,eR);
if (!ok) return Standard_False;
ok = REGUW.UpdateMultiple(v);
if (!ok) return Standard_False;
}//exv
ite.Next();
}//ite(eIs)
// now all edges of <eIs> are INTERNAL edges of <w>
// their 2 bounds are of connexity > 1.
// if (eIs.IsEmpty()) {nWs.Append(w); continue;}
TopTools_ListOfShape spW;
// --------
Standard_Boolean spok = REGUW.REGU(); // only first step
if (!spok) {FUN_Raise(); return Standard_False;}
REGUW.GetSplits(spW);
if (!spW.IsEmpty()) {nWs.Append(spW); hassp = Standard_True;}
}//exw
if (!hassp) return Standard_False;
TopTools_ListOfShape nFs; Standard_Boolean ok = TopOpeBRepTool_REGUS::WireToFace(aFace, nWs,nFs);
if (!ok) {FUN_Raise(); return Standard_False;}
TopTools_ListIteratorOfListOfShape itf(nFs);
for (; itf.More(); itf.Next()) FSplits.Append(itf.Value().Oriented(oAnc));
return Standard_True;
}
//=======================================================================
//function : SplitFaces
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::SplitFaces()
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
Standard_Integer ish = FUN_adds(S());
if (trc) cout<<"** SPLITTING FACES ** shape"<<ish<<endl;
#endif
TopExp_Explorer exf(myS, TopAbs_FACE);
for (; exf.More(); exf.Next()){
// splitting face :
const TopoDS_Face& f = TopoDS::Face(exf.Current());
TopTools_ListOfShape lfsp; Standard_Boolean issp = TopOpeBRepTool_REGUS::SplitF(f,lfsp);
#ifdef DEB
Standard_Integer nf =
#endif
lfsp.Extent();
if (!issp) continue;
myFsplits.Bind(f,lfsp);
// updating the map of connexity :
// f -> lfsp = {fsp}
mynF--;
TopTools_ListIteratorOfListOfShape itf(lfsp);
for (; itf.More(); itf.Next()){
const TopoDS_Shape& fsp = itf.Value(); mynF++;
TopExp_Explorer exe(fsp, TopAbs_EDGE);
for (; exe.More(); exe.Next()) {
// fsp -> {e}
const TopoDS_Shape& e = exe.Current();
Standard_Boolean isb = mymapeFs.IsBound(e);
if (!isb) {FUN_Raise(); return Standard_False;}
// <mymapeFs>
TopTools_ListOfShape& lof = mymapeFs.ChangeFind(e);
TopOpeBRepTool_TOOL::Remove(lof,f);
lof.Append(fsp);
// <mymapemult>
Standard_Integer nf = lof.Extent();
if (nf > 2) mymapemult.Add(e);
}//exe(fsp)
}//itf(lfsp)
#ifdef DEB
if (trc) {
cout <<"split(f"<<FUN_adds(f)<<")= ";
TopTools_ListIteratorOfListOfShape it(lfsp);
for (; it.More(); it.Next()) cout<<" f"<<FUN_adds(it.Value());
cout<<endl;}
#endif
}//exf(myS)
return Standard_True;
}
static void FUN_update(const TopoDS_Shape& fcur, TopTools_MapOfShape& edstoconnect)
// purpose : <e> edge of <fcur>
// 1. <e> is INTERNAL or EXTERNAL -> nothing is done
// 2. <e> is closing edge of <fcur> -> nothing is done
// 3. <e> is already bound in <edstoconnect> -> remove it from the map
// (then has 2 ancestor faces stored in the current Block)
// 4. elsewhere, add it in the map.
//
// !! if <fcur> is INTERNAL/EXTERNAL -> nothing is done
{
TopAbs_Orientation ofcur = fcur.Orientation();
if (M_INTERNAL(ofcur) || M_EXTERNAL(ofcur)) return;
TopExp_Explorer exe(fcur, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Shape& e = exe.Current();
TopAbs_Orientation oe = e.Orientation();
if (M_INTERNAL(oe) || M_EXTERNAL(oe)) continue;
Standard_Boolean isclo = TopOpeBRepTool_TOOL::IsClosingE(TopoDS::Edge(e),TopoDS::Face(fcur));
if (isclo) continue;
Standard_Boolean isb = edstoconnect.Contains(e);
if (isb) edstoconnect.Remove(e);
else edstoconnect.Add(e);
}//exe
}
//=======================================================================
//function : REGU
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::REGU()
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
Standard_Integer ishe = FUN_adds(myS);
if (trc) cout<<"** REGU **"<<ishe<<endl;
#endif
TopTools_ListOfShape Splits;
Standard_Boolean toregu = !mymapemult.IsEmpty() || (mynF != myoldnF);
if (!toregu) return Standard_False;
// purpose : myS -> {Blocks},
// a Block is a closed shell with "valid" edges.
// - a valid edge in a Block has at most two ancestor faces -
//
// Give us the starting couple (<ei>, <fi>) :
// * If <ei> has only one untouched ancestor face <fj> left, fj+1 <- fj
// Else among the untouched ancestors faces, we choose the one for which
// angle (<veci>, <vecj>) is the smallest; providing face <fj> reduces
// the matter described by <fi>.
// * update <mymapeFs> for <ei> (<fj> as touched).
// * Update <mymapemult> for <fi>'s bound edges :
// - if bound edge is not in the map, add it.
// - else if bound edge has two ancestor faces in current list <mylFinBlock>,
// delete it form the map.
//
// TopTools_ListOfShape lFinBlock; // <lFinBlock> describes a valid closed shell when <myedstoconnect> is emptied.
mylFinBlock.Clear();
Standard_Integer nite = 0;
while (nite <= mynF) {
Standard_Boolean startBlock = mylFinBlock.IsEmpty();
Standard_Boolean endBlock = myedstoconnect.IsEmpty() && (!startBlock);
#ifdef DEB
Standard_Boolean tr=Standard_False;
if (tr) {
TopTools_MapIteratorOfMapOfShape it(myedstoconnect);
cout<<"still to connect : ";
for (; it.More(); it.Next()) cout<<" e"<<FUN_adds(it.Key());
cout<<endl;
}
#endif
//* endBlock
// ---------
if (endBlock) {
// building up shell on <mylFinBlock>
Standard_Integer nFcur = mylFinBlock.Extent();
Standard_Boolean unchanged = (nFcur==myoldnF) && (mynF==myoldnF);
if (unchanged) {
#ifdef DEB
if (trc) cout<<"#** shell"<<ishe<<" valid\n";
#endif
return Standard_False; // nyi analysis if we should raise or not
}
else {
TopoDS_Shell newShe; TopOpeBRepTool_TOOL::MkShell(mylFinBlock,newShe);
Splits.Append(newShe);
#ifdef DEB
if (trc) {cout<<"#** shell "<<ishe<<" gives new shell "<<FUN_adds(newShe)<<endl;
for (TopTools_ListIteratorOfListOfShape it(mylFinBlock); it.More(); it.Next()) cout <<";dins f"<<FUN_adds(it.Value());
cout<<endl<<endl;}
#endif
mylFinBlock.Clear();
startBlock = Standard_True;
}
}//endBlock
//* all faces touched
// ------------------
Standard_Boolean FINI = (nite == mynF);
if (FINI) break;
Standard_Integer advance=Standard_False;
//* initializing a new Block
// -------------------------
if (startBlock || endBlock) {
advance = InitBlock();
if (!advance) return Standard_False;
}//startBlock||endBlock
//* choosing next face
// -------------------
else {
advance = NextinBlock();
}
// ** updating connexity
::FUN_update(myf,myedstoconnect);
if (!advance) {
endBlock = myedstoconnect.IsEmpty() && (!startBlock);
if (!endBlock) return Standard_False;
else continue;
}
TopExp_Explorer exe(myf, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Shape& e = exe.Current();
Standard_Boolean isb = mymapeFs.IsBound(e);
if (!isb) continue; // ancestors faces of <e> are stored in Blocks
TopOpeBRepTool_TOOL::Remove(mymapeFs.ChangeFind(e),myf);
}//exe
mylFinBlock.Append(myf); nite++;
}//nite <= mynF
myOshNsh.Bind(S(), Splits);
return Standard_True;
}
//=======================================================================
//function : InitBlock
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::InitBlock()
{
Standard_Integer nec = myedstoconnect.Extent();
if (nec != 0) return Standard_False; // should be empty
TopTools_ListOfShape eds;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(mymapeFs);
for (; itm.More(); itm.Next()) eds.Append(itm.Key());
TopTools_ListIteratorOfListOfShape ite(eds);
for (; ite.More(); ite.Next()){
const TopoDS_Shape& e = ite.Value();
const TopTools_ListOfShape& lof = mymapeFs.Find(e);
if (lof.IsEmpty()) {mymapeFs.UnBind(e); continue;}
myf = lof.First();
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
if (trc) cout<<"* Block : first face = f"<<FUN_adds(myf)<<endl;
#endif
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : NextinBlock
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::NextinBlock()
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
#endif
// we try to connect first edge of <myf> bound in <myedstoconnect>
TopTools_ListOfShape eds;
TopExp_Explorer exe(myf, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Shape& e = exe.Current();
Standard_Boolean isb = myedstoconnect.Contains(e);
if (isb) eds.Append(e);
}//exe
Standard_Boolean alleftouched = eds.IsEmpty();
if (alleftouched) {
TopTools_MapIteratorOfMapOfShape itc(myedstoconnect);
for (; itc.More(); itc.Next()){
const TopoDS_Shape& e = itc.Key();
Standard_Boolean isb = mymapeFs.IsBound(e);
// all ancestor faces of <e> have been stored
if (!isb) {myedstoconnect.Remove(e); continue;}
const TopTools_ListOfShape& lof = mymapeFs.Find(e); Standard_Integer nf = lof.Extent();
if (nf == 0) {myedstoconnect.Remove(e); mymapeFs.UnBind(e);
continue;}
// myf = lof.First(); 130499
if (lof.Extent() == 1) myf = lof.First();
else {
// looking for first face stored in the current block
// connexed to e
TopTools_ListIteratorOfListOfShape itff(mylFinBlock);
TopTools_MapOfShape mapf;for (; itff.More(); itff.Next()) mapf.Add(itff.Value());
// lofc : the list of faces connexed to e in <myS>
// lof : the list of untouched faces connexed to e in <myS>
const TopTools_ListOfShape& lofc = mymapeFsstatic.Find(e);
#ifdef DEB
Standard_Integer nfc =
#endif
lofc.Extent();
itff.Initialize(lofc);
TopoDS_Face fref;
for (; itff.More(); itff.Next()) {
const TopoDS_Face& fc = TopoDS::Face(itff.Value());
Standard_Boolean isb = mapf.Contains(fc);
if (isb) {fref = fc; break;}
} // itff(lofc)
if (fref.IsNull()) {
return Standard_False; // !!!!!!!!!! a revoir 130499
}
else {
myf = fref;
TopoDS_Face ffound; Standard_Boolean ok = NearestF(TopoDS::Edge(e),lof,ffound);
if (!ok) return Standard_False;
myf = ffound;
}
}
return Standard_True;
}
return Standard_False;
}
TopTools_ListIteratorOfListOfShape ite(eds);
for (; ite.More(); ite.Next()){
const TopoDS_Shape& e = ite.Value();
Standard_Boolean isb = mymapeFs.IsBound(e);
// all ancestor faces of <e> have been stored
if (!isb) {myedstoconnect.Remove(e); continue;}
const TopTools_ListOfShape& lof = mymapeFs.Find(e); Standard_Integer nf = lof.Extent();
if (nf == 0) {myedstoconnect.Remove(e); mymapeFs.UnBind(e);
continue;}
#ifdef DEB
if (trc) {cout<<"e"<<FUN_adds(e)<<" on "<<nf<<" untouched f:"<<endl;}
#endif
if (nf == 1) myf = lof.First();
else {
TopoDS_Face ffound; Standard_Boolean ok = NearestF(TopoDS::Edge(e),lof,ffound);
if (!ok) return Standard_False;
myf = ffound;
}
#ifdef DEB
if (trc) cout<<"->myf = f"<<FUN_adds(myf)<<endl;
#endif
return Standard_True;
}//itm(myedstoconnect)
return Standard_False;
}
static Standard_Boolean FUN_vectors(const TopoDS_Face& f, const TopoDS_Edge& e, const Standard_Real pare,
gp_Dir& nt, gp_Dir& xx, const Standard_Real tola, const Standard_Boolean approx)
{
// <nt> :
if (approx) {
Standard_Boolean ok = TopOpeBRepTool_TOOL::tryNgApp(pare,e,f,tola,nt);
if (!ok) return Standard_False;
}
else {
gp_Vec tmp; Standard_Boolean ok = FUN_tool_nggeomF(pare,e,f,tmp);
if (!ok) return Standard_False;
nt = gp_Dir(tmp);
}
if (M_REVERSED(f.Orientation())) nt.Reverse();
// <xx> :
Standard_Boolean ok = FUN_tool_getxx(f,e,pare,xx);
if (!ok) return Standard_False;
return Standard_True;
}
//=======================================================================
//function : NearestF
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUS::NearestF(const TopoDS_Edge& e, const TopTools_ListOfShape& lof, TopoDS_Face& ffound) const
// prequesitory : <e> is shared by <myf> and faces of <lof>.
//
// NYIXPU!!!!!!!! if (xx1 tg xx2) -> use curvatures
//
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUSO();
#endif
ffound.Nullify();
TopoDS_Face fref = TopoDS::Face(myf);
#ifdef DEB
Standard_Integer nf =
#endif
lof.Extent();//deb
// Give us egde <e>, and a reference face <fref> (= <myf>)
// - parameter on <e> = <pare>.
// - xxi = tangent fo face fi at pnt(e,pare) oriented INSIDE 2d(fi)
// normal to tge = tg(e,pare).
// purpose : looking for ffound /
// MatterAng(xxref, xxfound) = Min{ MatterAng(xxref, xxi), xxi for fi in <lof>
// providing fi reduces 3d(fref) }
// <parone> :
Standard_Real f,l; FUN_tool_bounds(e,f,l); Standard_Real eps = 0.45678; Standard_Real pare = (1-eps)*f+eps*l;
// RONd (x,y,z) = (xxref,ntref,x^y)
Standard_Real tola = Precision::Angular()*1.e3; //gp_Dir xapp,yapp; Standard_Boolean refapp = Standard_False;
gp_Dir x,y; Standard_Boolean ok = ::FUN_vectors(fref,e,pare,y,x,tola,Standard_False);
if (!ok) {FUN_Raise(); return Standard_False;}
#ifdef DEB
gp_Dir z = x^y;
#endif
// initializing
// ------------
Standard_Real angfound = 0;
TopTools_ListIteratorOfListOfShape itf(lof);
for (; itf.More(); itf.Next()){
ffound = TopoDS::Face(itf.Value());
gp_Dir ntfound,xxfound;
ok = ::FUN_vectors(ffound,e,pare,ntfound,xxfound,tola,Standard_False);
if (!ok) {FUN_Raise(); return Standard_False;}
Standard_Boolean oppo = TopOpeBRepTool_TOOL::Matter(x,y,xxfound,ntfound,tola, angfound);
#ifdef DEB
if (trc&&!oppo) cout<<" f"<<FUN_adds(fref)<<",f"<<FUN_adds(ffound)<<" not oppo"<<endl;
#endif
if (!oppo) {ffound.Nullify(); continue;}
if (angfound < tola) {
// refapp = Standard_True; ::FUN_vectors(fref,e,pare,yapp,xapp,tola,Standard_True);
// ::FUN_vectors(ffound,e,pare,ntfound,xxfound,tola,Standard_True);
// TopOpeBRepTool_TOOL::Matter(xapp,yapp,xxfound,ntfound,tola, angfound);
ok = TopOpeBRepTool_TOOL::MatterKPtg(fref,ffound,e,angfound);
if (!ok) {FUN_Raise(); return Standard_False;}
}
#ifdef DEB
if (trc) cout<<" ang("<<"f"<<FUN_adds(fref)<<",f"<<FUN_adds(ffound)<<")="<<angfound<<endl;
#endif
break;
}
if (ffound.IsNull()) {FUN_Raise(); return Standard_False;}
if (itf.More()) itf.Next();
else return Standard_True;
// selecting nearest face
// ----------------------
for (; itf.More(); itf.Next()){
gp_Dir nti,xxi;
const TopoDS_Face& fi = TopoDS::Face(itf.Value());
ok = ::FUN_vectors(fi,e,pare,nti,xxi,tola,Standard_False);
if (!ok) {FUN_Raise(); return Standard_False;}
Standard_Real angi = 0;
Standard_Boolean oppo = TopOpeBRepTool_TOOL::Matter(x,y,xxi,nti,tola, angi);
#ifdef DEB
if (trc&&!oppo) cout<<" f"<<FUN_adds(fref)<<",f"<<FUN_adds(fi)<<" not oppo"<<endl;
#endif
if (!oppo) continue;
if (angi < tola) {
// if (!refapp) ::FUN_vectors(fref,e,pare,yapp,xapp,tola,Standard_True);
// ::FUN_vectors(fi,e,pare,nti,xxi,tola,Standard_True);
// TopOpeBRepTool_TOOL::Matter(xapp,yapp,xxi,nti,tola, angi);
ok = TopOpeBRepTool_TOOL::MatterKPtg(fref,fi,e,angi);
if (!ok) {FUN_Raise(); return Standard_False;}
}
#ifdef DEB
if (trc) cout<<" ang("<<"f"<<FUN_adds(fref)<<",f"<<FUN_adds(fi)<<")="<<angi<<endl;
#endif
if (angi > angfound) continue;
angfound = angi;
ffound = fi;
}
return Standard_True;
}

View File

@@ -0,0 +1,178 @@
-- File: TopOpeBRepTool_REGUW.cdl
-- Created: Tue Dec 8 17:28:35 1998
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class REGUW from TopOpeBRepTool
-- purpose : Regularisation is computed in two steps :
-- 1. we split the face in areas of matter.
-- 2. we split wires to avoid any multiple point.
--
-- TopOpeBRepTool_REGUW REGUW(FRef);
--
-- // optionnal : setting Esplits,OwNw
-- REGUW.GetEsplits(Esplits);
-- REGUW.GetOwNw(OwNw);
--
--
uses
Pnt2d from gp,
Dir2d from gp,
Shape from TopoDS,
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
ListOfShape from TopTools,
MapOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools,
DataMapOfOrientedShapeC2DF from TopOpeBRepTool,
IndexedDataMapOfShapeconnexity from TopOpeBRepTool,
CORRISO from TopOpeBRepTool,
connexity from TopOpeBRepTool
is
Create (FRef : Face from TopoDS)
returns REGUW from TopOpeBRepTool;
Fref (me) returns Face from TopoDS;
---C++: return const &
SetEsplits(me : in out; Esplits : in out DataMapOfShapeListOfShape from TopTools);
GetEsplits(me; Esplits : out DataMapOfShapeListOfShape from TopTools);
SetOwNw(me : in out; OwNw : in out DataMapOfShapeListOfShape from TopTools);
GetOwNw(me; OwNw : out DataMapOfShapeListOfShape from TopTools);
SplitEds(me : in out)
returns Boolean;
-- Splits all edges on their internal vertices if any, and updates
-- map of connexity.
--
-- <S> processing on subshapes of complete shape to regularize
-- prequesitory : all these subshapes are not connexed.
--
-- TopOpeBRepTool_REGUW REGUW(Fref);
--
-- REGUW.SetOwNw(OwNw); // optionnal
-- REGUW.SetEsplits(Esplits); // optionnal
--
-- REGUW.Init(S);
-- REGUW.MapS();
-- REGUW.SplitEds();
-- REGUW.REGU();
--
-- REGUW.GetSplit(Splits); // do1
-- REGUW.GetOwNw(OwNw); Splits = OwNw.Find(S);// or do2
--
-- REGUW.GetOwNw(OwNw); // optionnal
-- REGUW.GetEsplits(Esplits); // optionnal
--
-- all methods -except initialization methods- Raise if (!HasInit())
Init (me : in out; S : Shape from TopoDS);
-- initializes <myS>
S(me) returns Shape from TopoDS;
-- returns <myS>
---C++: return const &
HasInit(me) returns Boolean;
InitStep (me : in out; S : Shape from TopoDS)
is static private;
MapS(me : in out)
returns Boolean;
REGU(me : in out; istep : Integer; Scur : Shape from TopoDS; Splits : out ListOfShape from TopTools)
returns Boolean;
-- <istep> step for regularization.
REGU(me : in out)
returns Boolean;
-- Fills up <myOwNw> for shape <myS>
GetSplits(me; Splits : out ListOfShape from TopTools)
returns Boolean;
-- <myS> gives <Splits> after complete regularization
--
-- INTERNAL methods
--
-- <S> = { Block }, Block = {(vi,ei)},
-- a Block starts with (v0,e1,p2d0)
-- ends when p2di equals p2d0.
InitBlock(me : in out)
returns Boolean;
-- Gets starts elements for a new block
NextinBlock(me : in out)
returns Boolean;
-- Go to next element in the block
NearestE(me; loe : ListOfShape from TopTools; efound : out Edge from TopoDS)
returns Boolean;
-- Gets nearest edge Ang(mye,efound)=Min{ Ang(mye,ei) , ei in loe }
-- iStep = 1 : Ang(e,ei) = 2d matter angle (e,ei)
-- ori(myv,mye) = 2
-- ori(myv,ei) = 1
--
-- iStep = 2 : Ang(e,ei) = 2d oppo matter angle (e,ei)
-- ori(myv,mye) = 1
-- ori(myv,ei) = 2
Connexity(me; v : Vertex from TopoDS; co : out connexity from TopOpeBRepTool)
returns Boolean;
-- returns false if v is not bound.
--
-- for external use : if the user wants to modify the mapping
-- for the input shape he can modify the connexity map.
-- IMPORTANT : after these changes, do NOT forget to update the
-- map for multiple vertices ( UpdateMultiple )
--
AddNewConnexity(me : in out; v : Vertex from TopoDS; OriKey : Integer; e : Edge from TopoDS)
returns Boolean;
-- Adds new connexity <e> to connexity(<v>,<e>),
-- updates <myCORRISO>, <mymapvEds>
-- prequesitory : <e> oriented FORWARD has no INTERNAL vertex
RemoveOldConnexity(me : in out; v : Vertex from TopoDS; OriKey : Integer; e : Edge from TopoDS)
returns Boolean;
UpdateMultiple(me : in out; v : Vertex from TopoDS)
returns Boolean;
-- updates map of multiple vertices
-- returns false if v is not bound.
fields
myS : Shape from TopoDS;
myCORRISO : CORRISO from TopOpeBRepTool;
hasnewsplits : Boolean;
myEsplits : DataMapOfShapeListOfShape from TopTools;
myOwNw : DataMapOfShapeListOfShape from TopTools;
mymapvEds : IndexedDataMapOfShapeconnexity from TopOpeBRepTool;
mymapvmultiple : MapOfShape from TopTools;
myListVmultiple: ListOfShape from TopTools;
iStep : Integer; -- 1 or 2
-- BLOCK processing :
mytol2d : Real;
isinit0 : Boolean;
-- starts elements
myv0 : Vertex from TopoDS;
myp2d0 : Pnt2d from gp;
-- current elements
myv : Vertex from TopoDS;
myed : Edge from TopoDS;
myp2d : Pnt2d from gp;
mytg2d : Dir2d from gp;
end REGUW;

View File

@@ -0,0 +1,984 @@
// File: TopOpeBRepTool_REGUW.cxx
// Created: Tue Dec 8 18:07:24 1998
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <Geom2d_Curve.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <Precision.hxx>
#include <TopExp_Explorer.hxx>
#include <TopOpeBRepTool_C2DF.hxx>
#include <TopOpeBRepTool_REGUW.ixx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_define.hxx>
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
#define FORWARD (1)
#define REVERSED (2)
#define INTERNAL (3)
#define EXTERNAL (4)
#define CLOSING (5)
#define M_FORWARD(ori) (ori == TopAbs_FORWARD)
#define M_REVERSED(ori) (ori == TopAbs_REVERSED)
#define M_INTERNAL(ori) (ori == TopAbs_INTERNAL)
#define M_EXTERNAL(ori) (ori == TopAbs_EXTERNAL)
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceREGUFA();
static TopTools_IndexedMapOfShape STATIC_mapf, STATIC_mapw, STATIC_mapv;
static TopTools_IndexedMapOfOrientedShape STATIC_mapeds;
void FUN_tro(const Standard_Integer i)
{
if (i==1) cout<<"FORWARD";
else if (i==2) cout<<"REVERSED";
else if (i==3) cout<<"INTERNAL";
else if (i==4) cout<<"EXTERNAL";
else if (i==5) cout<<"CLOSING";
}
Standard_EXPORT Standard_Integer FUN_adds(const TopoDS_Shape& s) {
TopAbs_ShapeEnum typ = s.ShapeType();
TCollection_AsciiString aa; Standard_Integer is = 0;
if (typ == TopAbs_VERTEX) {aa = TCollection_AsciiString("v"); is = STATIC_mapv.Add(s);}
if (typ == TopAbs_EDGE) {aa = TCollection_AsciiString("e"); is = STATIC_mapeds.Add(s);}
if (typ == TopAbs_WIRE) {aa = TCollection_AsciiString("wi"); is = STATIC_mapw.Add(s);}
if (typ == TopAbs_FACE) {aa = TCollection_AsciiString("f"); is = STATIC_mapf.Add(s);}
#ifdef DRAW
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) FUN_tool_draw(aa,s,is);
#endif
return is;
}
#endif
Standard_IMPORT void FUN_tool_tori(const TopAbs_Orientation Or);
void FUN_tool_Add(TopTools_DataMapOfShapeListOfShape& map,const TopoDS_Shape& key, const TopoDS_Shape& subitem)
{
if (map.IsBound(key)) map.ChangeFind(key).Append(subitem);
else {TopTools_ListOfShape los; los.Append(subitem); map.Bind(key,los);}
}
static void FUN_Raise() {
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<"*** Raise REGUW"<<endl;
// Standard_Failure::Raise("REGUW");
#endif
}
//=======================================================================
//function : CORRISO
//purpose :
//=======================================================================
TopOpeBRepTool_REGUW::TopOpeBRepTool_REGUW(const TopoDS_Face& Fref)
: myCORRISO(Fref)
{
myS.Nullify();
hasnewsplits = Standard_False;
myEsplits.Clear();
myOwNw.Clear();
mymapvEds.Clear();
mymapvmultiple.Clear();
myListVmultiple.Clear();
iStep = 0;
}
//=======================================================================
//function : Fref
//purpose :
//=======================================================================
const TopoDS_Face& TopOpeBRepTool_REGUW::Fref() const
{
return (myCORRISO.Fref());
}
//=======================================================================
//function : SetEsplits
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUW::SetEsplits(TopTools_DataMapOfShapeListOfShape& Esplits)
{
myEsplits = Esplits;
}
//=======================================================================
//function : GetEsplits
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUW::GetEsplits(TopTools_DataMapOfShapeListOfShape& Esplits) const
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
Esplits = myEsplits;
}
//=======================================================================
//function : SetOwNw
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUW::SetOwNw(TopTools_DataMapOfShapeListOfShape& OwNw)
{
myOwNw = OwNw;
}
//=======================================================================
//function : GetOwNw
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUW::GetOwNw(TopTools_DataMapOfShapeListOfShape& OwNw) const
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
OwNw = myOwNw;
}
//=======================================================================
//function : SplitEds
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::SplitEds()
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<"** SPLITTING EDGES **"<<endl;
#endif
TopTools_IndexedMapOfShape mehasIv;
Standard_Integer i;
for (i = 1; i <= mymapvEds.Extent(); i++) {
const TopOpeBRepTool_connexity& co = mymapvEds(i);
TopTools_ListOfShape loe; Standard_Integer ni = co.IsInternal(loe);
if (ni == 0) continue;
TopTools_ListIteratorOfListOfShape ite(loe);
for (; ite.More(); ite.Next()) mehasIv.Add(ite.Value());
}
for (i = 1; i <= mehasIv.Extent(); i++) {
const TopoDS_Edge& e = TopoDS::Edge(mehasIv.FindKey(i));
TopTools_ListOfShape splits; Standard_Boolean issp = Standard_False;
Standard_Boolean isdone = myEsplits.IsBound(e);
if (isdone) splits.Assign(myEsplits.Find(e));
else issp = TopOpeBRepTool_TOOL::SplitE(e,splits);
if (issp) hasnewsplits = Standard_True;
#ifdef DEB
if (trc) cout<<"e"<<FUN_adds(e)<<" gives splits ="<<endl;
#endif
if (!(issp || isdone)) continue; //nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnyi
// e gives splits = {esp has vertices {vv}}
TopTools_ListIteratorOfListOfShape ite(splits);
for (; ite.More(); ite.Next()){
const TopoDS_Shape& esp = ite.Value();
#ifdef DEB
if (trc) {cout<<" e"<<FUN_adds(esp);}
#endif
TopExp_Explorer exvv(esp, TopAbs_VERTEX);
for (; exvv.More(); exvv.Next()){
const TopoDS_Shape& vv = exvv.Current();
TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(vv);
Standard_Boolean isb = co.RemoveItem(INTERNAL,e);
if (!isb) continue;
Standard_Integer ivv = TopOpeBRepTool_TOOL::OriinSorclosed(vv,esp);
co.AddItem(ivv,esp);
}//exvv(exvv,VERTEX)
}//ite(splits)
#ifdef DEB
if (trc) cout<<endl;
#endif
}
return Standard_True;
}
//=======================================================================
//function : S
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepTool_REGUW::S() const
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
return myS;
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUW::Init(const TopoDS_Shape& S)
{
myS = S;
InitStep(S);
}
//=======================================================================
//function : HasInit
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::HasInit() const
{
return (!myS.IsNull());
}
//=======================================================================
//function : InitStep
//purpose :
//=======================================================================
void TopOpeBRepTool_REGUW::InitStep(const TopoDS_Shape& S)
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
TopoDS_Shape null;myCORRISO.Init(null); myCORRISO.Init(S);
mymapvEds.Clear();
mymapvmultiple.Clear();
myListVmultiple.Clear();
}
//=======================================================================
//function : MapS
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::MapS()
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<"** MAPPING **"<<endl;
#endif
// Prequesitories :
// 0) an edge with an INTERNAL vertex binded in <mapVedges> must be
// splitted
// After splitting such edges, we deal only with FORWARD and
// REVERSED vertices.
// 1) a vertex belonging to a CLOSING edge is represented by 2 distinct
// 2d points in the UV space.
// 2) a vertex belonging to a DEGENERATED edge has at least 2 UV rep.
// (if the original degenerated edge has been splitted).
// the bounds of the degenerated edge share the same TShape.
// 3) a CLOSED edge binds the same vertex oriented FORWARD and REVERSED.
// For each vertex get non-"singular" edges in which the vertex is oriented
// FORWARD and REVERSED.
// <mymapvmultiple(1)> binds v and ed if :
// v is FORWARD in ed FORWARD : oriFF(v,ed) = FORWARD
// v is REVERSED in ed REVERSED : oriFF(v,ed) = FORWARD
// oriFF(v,ed) = (ori(ed) == FORWARD) ? ori(ed) : ori(ed).Reverse.
// A "singular" edge is a closed, a closing or a degenerated edge.
// In <mymapvmultiple(5)>, we bind with the key <v>:
// - the FORWARD and the REVERSED CLOSING ancestor edges of <v>
// - the DEGENERATED ancestor edge of <v>
// - the CLOSED edge ancestor edge of <v>
// A MULTIPLE vertex has its single UV representation's connexity > 2
const TopoDS_Shape& CS = myCORRISO.S();
TopExp_Explorer exe(CS, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Edge& ed = TopoDS::Edge(exe.Current());
#ifdef DEB
TopAbs_Orientation oed =
#endif
ed.Orientation();
Standard_Boolean isdgE = BRep_Tool::Degenerated(ed);
Standard_Boolean iscE = TopOpeBRepTool_TOOL::IsClosingE(ed,myCORRISO.S(),Fref());
iscE = iscE && !isdgE; // closing ed
TopoDS_Shape vcl; Standard_Boolean isvcl = TopOpeBRepTool_TOOL::ClosedE(ed,TopoDS::Vertex(vcl)); isvcl = isvcl && !isdgE;
TopExp_Explorer exv(ed, TopAbs_VERTEX);
for (; exv.More(); exv.Next()){
const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
Standard_Boolean isb = mymapvEds.Contains(v);
TopOpeBRepTool_connexity theconnexity(v);
if (!isb) mymapvEds.Add(v, theconnexity);
TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(v);
if (isdgE) {
// avoid adding it twice
co.RemoveItem(CLOSING,ed);
co.AddItem(CLOSING,ed);
break;
}
else if (iscE) {
// FORWARD and REVERSED edge is added
co.AddItem(CLOSING,ed);
}
else if (isvcl && (v.IsSame(vcl))) {
// avoid adding it twice
co.RemoveItem(CLOSING,ed);
co.AddItem(CLOSING,ed);
}
else {
Standard_Integer iov = TopOpeBRepTool_TOOL::OriinSor(v,ed,Standard_False); //iov != 0
co.AddItem(iov,ed);
}
}//exv
}//exe
#ifdef DEB
if (trc) {
for (Standard_Integer iv = 1; iv <= mymapvEds.Extent(); iv++) {
const TopoDS_Vertex& v = TopoDS::Vertex(mymapvEds.FindKey(iv));
cout <<"#v"<<FUN_adds(v)<<" :\n";
const TopOpeBRepTool_connexity& co = mymapvEds(iv);
for (Standard_Integer i=1; i<=5; i++) {
TopTools_ListOfShape eds; Standard_Integer ieds = co.Item(i,eds);
if (ieds == 0) continue;
cout<<" is ";FUN_tro(i);cout<<" in ";
TopTools_ListIteratorOfListOfShape ite(eds);
for (; ite.More(); ite.Next())
{const TopoDS_Edge& e = TopoDS::Edge(ite.Value());
cout<<"e"<<FUN_adds(e);FUN_tool_tori(e.Orientation());
TopoDS_Vertex vclo; Standard_Boolean cloE = TopOpeBRepTool_TOOL::ClosedE(e,vclo); if (cloE) cout<<"closed";
Standard_Boolean dgE = BRep_Tool::Degenerated(e); if (dgE) cout<<"degenerated";
Standard_Boolean iscE = TopOpeBRepTool_TOOL::IsClosingE(e,myCORRISO.S(),Fref());
if (iscE) cout<<"closing";
cout<<" ";}
cout<<endl;
}//i=1..5
}
}//trc
#endif
Standard_Integer nV = mymapvEds.Extent();
if (nV < 1) return Standard_False;
Standard_Integer i;
for (i = 1; i <= mymapvEds.Extent(); i++) {
const TopoDS_Shape& v = mymapvEds.FindKey(i);
const TopOpeBRepTool_connexity& co = mymapvEds(i);
Standard_Boolean faulty = co.IsFaulty();
if (faulty) return Standard_False;
Standard_Boolean multiple = co.IsMultiple();
if (multiple)
if (mymapvmultiple.Add(v))
myListVmultiple.Append(v);
}
return Standard_True;
}//MapS
static void FUN_nextdata(const Standard_Integer iStep,const TopoDS_Edge& e,const Handle(Geom2d_Curve)& pc,
TopoDS_Vertex& v,gp_Pnt2d& p2d,gp_Dir2d& tg)
// prequesitory : pc = 2drep(e),
// ori(v,e)=iv1e1 -> v, p2d=pt2d(v,e), tg=tg2d(v,e).
{
Standard_Integer iv1e1 = (iStep == 1) ? FORWARD : REVERSED;
TopoDS_Shape aLocalShape = TopOpeBRepTool_TOOL::Vertex(iv1e1,e);
v = TopoDS::Vertex(aLocalShape);
// v = TopoDS::Vertex(TopOpeBRepTool_TOOL::Vertex(iv1e1,e));
Standard_Real par1 = TopOpeBRepTool_TOOL::ParE(iv1e1,e);
Standard_Boolean line = FUN_tool_line(pc);
Standard_Boolean quad = FUN_tool_quad(pc);// mytg2d is reapproximated if PCquad
Standard_Boolean approx = quad && (!line);
gp_Vec2d tg2d;
if (approx) {
p2d = pc->Value(par1);
Standard_Integer iv0e1 = (iStep == 1) ? REVERSED : FORWARD;
Standard_Real par0 = TopOpeBRepTool_TOOL::ParE(iv0e1,e);
// Getting a point near point<Index> of <E>
Standard_Real x = 0.2345; Standard_Real par = (1-x)*par1+x*par0;
gp_Pnt2d pmil; pc->D1(par,pmil,tg2d);
}
else {
pc->D1(par1,p2d,tg2d);
}
tg = gp_Dir2d(tg2d);
if (M_REVERSED(e.Orientation())) tg.Reverse();
}
//=======================================================================
//function : InitBlock
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::InitBlock()
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
#endif
myv0.Nullify(); myp2d0=gp_Pnt2d(1.e7,1.e7);
myed.Nullify();
Standard_Integer iv0e1 = (iStep == 1) ? REVERSED : FORWARD;
// updating <mymapvmultiple> and myListVmultiple
TopTools_ListIteratorOfListOfShape itmu(myListVmultiple);
while (itmu.More()) {
const TopoDS_Shape& vmu = itmu.Value();
const TopOpeBRepTool_connexity& cmu = mymapvEds.FindFromKey(vmu);
Standard_Boolean mult = cmu.IsMultiple();
if (!mult) {
myListVmultiple.Remove(itmu);
mymapvmultiple.Remove(vmu);
}
else itmu.Next();
}
// myv0 :
if (myListVmultiple.IsEmpty()) {
Standard_Integer i;
for (i = 1; i <= mymapvEds.Extent(); i++) {
const TopoDS_Vertex& v = TopoDS::Vertex(mymapvEds.FindKey(i));
const TopOpeBRepTool_connexity& co = mymapvEds(i);
TopTools_ListOfShape lea; Standard_Integer nea = co.Item(iv0e1,lea);
TopTools_ListOfShape leb; Standard_Integer neb = co.Item(CLOSING,leb);
TopTools_ListOfShape le; le.Append(lea); le.Append(leb); Standard_Integer ne = nea+neb;
if (ne != 0) {myv0 = v; break;}
}
}
else {
myv0 = TopoDS::Vertex(myListVmultiple.First());
}
if (myv0.IsNull()) return Standard_False;
// myed :
const TopOpeBRepTool_connexity& co = mymapvEds.FindFromKey(myv0);
TopTools_ListOfShape lea; Standard_Integer nea = co.Item(iv0e1,lea);
TopTools_ListOfShape leb; Standard_Integer neb = co.Item(CLOSING,leb);
TopTools_ListOfShape le; le.Append(lea); le.Append(leb); Standard_Integer ne = nea+neb;
if (ne == 0) return Standard_False;
if (nea > 0) myed = TopoDS::Edge(le.First());
else {// <myv0> CLOSING in <myed>
TopTools_ListIteratorOfListOfShape itb(le);
for (; itb.More(); itb.Next()){
const TopoDS_Edge& eb = TopoDS::Edge(itb.Value());
Standard_Boolean iscE = TopOpeBRepTool_TOOL::IsClosingE(myed,myCORRISO.S(),Fref());
if (!iscE) {myed = eb; break;}
Standard_Integer iov0 = TopOpeBRepTool_TOOL::OriinSorclosed(myv0,myed);
if (iov0 != iv0e1) continue;
}//itb(leb)
}
if (myed.IsNull()) return Standard_False;
TopExp_Explorer exv(myed, TopAbs_VERTEX);
for (; exv.More(); exv.Next()){
const TopoDS_Shape& vcur = exv.Current();
TopOpeBRepTool_connexity& cco = mymapvEds.ChangeFromKey(vcur);
#ifdef DEB
Standard_Boolean ok =
#endif
cco.RemoveItem(myed);
// if (!ok) return Standard_False; see for closing vertices
}
// myp2d0 :
TopOpeBRepTool_C2DF c2df;Standard_Boolean bound = myCORRISO.UVRep(myed,c2df);
if (!bound) return Standard_False;
Standard_Real f,l,tol; const Handle(Geom2d_Curve)& pc = c2df.PC(f,l,tol);
Standard_Real par0 = TopOpeBRepTool_TOOL::ParE(iv0e1,myed);
pc->D0(par0,myp2d0);
// myv, myp2d, mytg2d :
::FUN_nextdata(iStep,myed,pc, myv,myp2d,mytg2d);
#ifdef DEB
if (trc) {
cout<<endl<<" v0 = v"<<FUN_adds(myv0)<<" p2d0 = ("<<myp2d0.X()<<" "<<myp2d0.Y()<<")"<<endl;
cout<<" vcur = v"<<FUN_adds(myv)<<" p2d = ("<<myp2d.X()<<" "<<myp2d.Y()<<")"<<endl;
cout<<" ecur = e"<<FUN_adds(myed)<<endl;
}
#endif
return Standard_True;
}
//=======================================================================
//function : NearestE
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::NearestE(const TopTools_ListOfShape& loe, TopoDS_Edge& efound) const
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
#endif
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
efound.Nullify();
Standard_Real fac = 0.45678;
Standard_Real tola = Precision::Angular();
Standard_Integer iv0e1 = (iStep == 1) ? REVERSED : FORWARD;
#ifdef DEB
Standard_Integer iv1e1 = (iStep == 1) ? FORWARD : REVERSED;
#endif
// initializing
TopTools_ListIteratorOfListOfShape ite(loe);
efound = TopoDS::Edge(ite.Value());
if (ite.More()) ite.Next();
else return Standard_True;
TopOpeBRepTool_C2DF c2defound;Standard_Boolean isbfound = myCORRISO.UVRep(efound,c2defound);
if (!isbfound) return Standard_False;
gp_Vec2d tg2dfound = TopOpeBRepTool_TOOL::tryTg2dApp(iv0e1,efound,c2defound,fac);
if (M_REVERSED(efound.Orientation())) tg2dfound.Reverse();
Standard_Real angfound = 1.e7;
if (iStep == 1) angfound = TopOpeBRepTool_TOOL::Matter(mytg2d,tg2dfound);
else angfound = 2.*PI - TopOpeBRepTool_TOOL::Matter(tg2dfound,mytg2d);
#ifdef DEB
if (trc) cout<<"ang(e"<<FUN_adds(myed)<<",e"<<FUN_adds(efound)<<")="<<angfound<<endl;
#endif
// purpose : finding out <efound> /
// ecur is given by <tg2d>
// le = {ei}
// iStep=1 : matterang2d(efound,ecur) = min(ei,ecur)
// iStep=2 : oppomatterang2d(efound,ecur) = min(ei,ecur)
for (; ite.More(); ite.Next()){
const TopoDS_Edge& ei = TopoDS::Edge(ite.Value());
// for INTERNAL edge eI -> eF+eR
if (ei.IsSame(myed)) continue;
TopOpeBRepTool_C2DF c2dei;Standard_Boolean isbi = myCORRISO.UVRep(ei,c2dei);
if (!isbi) return Standard_False;
gp_Vec2d tg2di = TopOpeBRepTool_TOOL::tryTg2dApp(iv0e1,ei,c2dei,fac);
if (M_REVERSED(ei.Orientation())) tg2di.Reverse();
Standard_Real angi = 1.e7;
if (iStep == 1) angi = TopOpeBRepTool_TOOL::Matter(mytg2d,tg2di);
else angi = 2.*PI - TopOpeBRepTool_TOOL::Matter(tg2di,mytg2d);
Standard_Boolean eq = Abs(angi-angfound) < tola;
#ifdef DEB
if (trc) cout<<"ang(e"<<FUN_adds(myed)<<",e"<<FUN_adds(ei)<<")="<<angi<<endl;
#endif
if (eq) {
#ifdef DEB
Standard_Boolean dummy=Standard_True;//DEB
#endif
FUN_Raise();
return Standard_False;
}
if (angi < angfound) {efound = ei; angfound = angi;}
}
return Standard_True;
}
//=======================================================================
//function : NextinBlock
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::NextinBlock()
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<endl<<" vcur = v"<<FUN_adds(myv)<<" p2d = ("<<myp2d.X()<<" "<<myp2d.Y()<<")"<<endl;
#endif
Standard_Integer iv0e1 = (iStep == 1) ? REVERSED : FORWARD;
const TopOpeBRepTool_connexity& co = mymapvEds.FindFromKey(myv);
// {e} : e is connexed to <myv> && ori(<myv>,e)=iv0e1
TopTools_ListOfShape lea; Standard_Integer nea = co.Item(iv0e1,lea);
TopTools_ListOfShape leb; Standard_Integer neb = co.Item(CLOSING,leb);
TopTools_ListOfShape le; le.Append(lea); le.Append(leb); Standard_Integer ne = nea + neb;
TopTools_ListIteratorOfListOfShape ite(le);
while (ite.More()) {
const TopoDS_Edge& e = TopoDS::Edge(ite.Value());
#ifdef DEB
if (trc) cout<<" e"<<FUN_adds(e);
#endif
Standard_Boolean issame = e.IsSame(myed);
if (issame) {//xpu240299 FRA60275, fsp4
#ifdef DEB
if (trc) cout<<" is same : not valid"<<endl;
#endif
le.Remove(ite); continue;
}
TopOpeBRepTool_C2DF c2df;Standard_Boolean bound = myCORRISO.UVRep(e,c2df);
if (!bound) {FUN_Raise(); return Standard_False;}
Standard_Real f,l,tol; const Handle(Geom2d_Curve)& pc = c2df.PC(f,l,tol);
Standard_Real par = TopOpeBRepTool_TOOL::ParE(iv0e1,e);
gp_Pnt2d p2de; pc->D0(par,p2de);
// p2d(myv,ed)=p2d(myv,e)
Standard_Boolean samep2d = p2de.IsEqual(myp2d,mytol2d);
if (!samep2d) le.Remove(ite);
else ite.Next();
#ifdef DEB
if (trc) {if (samep2d) cout<<" valid"<<endl;
else cout<<" not valid"<<endl;}
#endif
}//ite(le)
ne = le.Extent();
if (ne == 0) {FUN_Raise(); return Standard_False;}
// myed :
ne = le.Extent();
if (ne == 1) myed = TopoDS::Edge(le.First());
else {
TopoDS_Edge efound; Standard_Boolean found = NearestE(le,efound);
if (!found) {FUN_Raise(); return Standard_False;}
myed = efound;
}
#ifdef DEB
TopOpeBRepTool_connexity& newco =
#endif
mymapvEds.ChangeFromKey(myv);
TopExp_Explorer exv(myed, TopAbs_VERTEX);
for (; exv.More(); exv.Next()){
TopOpeBRepTool_connexity& cco = mymapvEds.ChangeFromKey(exv.Current());
#ifdef DEB
Standard_Boolean ok =
#endif
cco.RemoveItem(myed);
// if (!ok) {FUN_Raise(); return Standard_False;} closed edges
}
TopOpeBRepTool_C2DF c2df; myCORRISO.UVRep(myed,c2df);
Standard_Real f,l,tol; const Handle(Geom2d_Curve)& pc = c2df.PC(f,l,tol);
::FUN_nextdata(iStep,myed,pc, myv,myp2d,mytg2d);
#ifdef DEB
if (trc) {
cout<<" vcur = v"<<FUN_adds(myv)<<" p2d = ("<<myp2d.X()<<" "<<myp2d.Y()<<")"<<endl;
cout<<" ecur = e"<<FUN_adds(myed)<<endl;
}
#endif
return Standard_True;
}//NextinBlock
//=======================================================================
//function : REGU
//purpose : step <iStep> for regularization
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::REGU(const Standard_Integer istep,
#ifdef DEB
const TopoDS_Shape& Scur,
#else
const TopoDS_Shape& ,
#endif
TopTools_ListOfShape& Splits)
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
iStep = istep;
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<endl<<"** REGU istep=**"<<iStep<<endl;
#endif
Splits.Clear();
// A valid face is built on "valid" wires.
// A valid wire has for UV representation a set of 2d edges of connexity = 2.
// Starting element is a vertex of single UV representation with connexity greater
// than 2.
// Given <v0m>, we get :
// - <e1> an edge where <v0m> is oriented REVERSED(step1)/FORWARD(step2)
// - <v1> the other vertex of <e1> oriented FORWARD(step1)/REVERSED(step2)
// - <p2d1> is <v1>'s UV representation attached to <e1>,
// - tg2d<e1> = Tgt(p2d1,e1) if <e1> FORWARD(step1)
// = -Tgt(p2d1,e1) if <e1> is REVERSED(step1) in the face with
// Tgt(p2d1,e1) = tangent to <e1>'s pcurve at point <p2d1>
// step1 :
// -------
// Given a starting couple (<vi>, <p2di>, tg2d<e1>, <ei>) with :
// - <vi> oriented FORWARD in <ei>,
// - <vi>'s 2d representation falling on an UV bound of <ei>'s pcurve (if <vi> is
// on a closing edge),
// We get the edge <ei+1> such that :
// - <ei+1> is not already touched,
// - <vi> is oriented REVERSED(step1) in <ei+1>,
// - <ei+1> has an UV bound falling into geometry <p2di>.
// - The oriented angle (-tg2d<ei>, tg2d<ei+1>) is the lowest,
// ( The angle is computed in the anti-trigonometric sense;
// the tangents's orientation are reversed if the edge is oriented REVERSED in the face )
// = Smaller oriented (following trigonometric sense) angle (tg2d<ei+1>, -tg2d<ei>)
//
// step2 : reverse the orientations and the angle describes non-matter.
// -------
// tol2d = 1.e-2*(lowest distance (p2df,p2dl) between all non-closed
// and non-degenerated pcurves seen during the regularization).
// This value is updated in method chkp2dFORinE.
// The comparision of p2d points is coupled with comparision of vertices
// We should in fact use bounding boxes on pcurves but this is too expensive!!!
mytol2d = 1.e-5;
isinit0 = Standard_True;
TopTools_ListOfShape loEcur, loW;
Standard_Integer nite = 0;
Standard_Integer nE = myCORRISO.Eds().Extent();// recall myCORRISO.Init(myS);
TopTools_ListIteratorOfListOfShape ite(myCORRISO.Eds());
for (; ite.More(); ite.Next()) {
TopAbs_Orientation oe = ite.Value().Orientation();
if (M_INTERNAL(oe) || M_EXTERNAL(oe)) nE--;
}
while (nite <= nE) {
Standard_Boolean FINI = (nite == nE);
//*** Getting starts elements if not defined
// -----------------------------------------
if (isinit0 && !FINI) {
Standard_Boolean ok = InitBlock();
if (!ok) {
#ifdef DEB
if (trc) cout<<"** InitBlock fails"<<endl;
#endif
{FUN_Raise(); return Standard_False;}
}
loEcur.Append(myed);// add it to the current wire
nite++; // increment nite
isinit0 = Standard_False;
continue;
}
//*** Checking the wire is not already closed
// ------------------------------------------
// If last vertex <v> is the first one <v0> and <p2d> == <p2d0>, the wire is closed
Standard_Boolean wireisclosed = myp2d.IsEqual(myp2d0,mytol2d);
if (wireisclosed) {
//* Adding INTERNAL/EXTERNAL edges to wires
// ----------------------------------------
TopTools_ListIteratorOfListOfShape ite1(loEcur);
for (; ite1.More(); ite1.Next()){
const TopoDS_Shape& e = ite1.Value();
TopExp_Explorer exv(e, TopAbs_VERTEX);
for (; exv.More(); exv.Next()){
const TopoDS_Shape& v = exv.Current();
TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(v);
TopTools_ListOfShape& le = co.ChangeItem(INTERNAL);
TopTools_ListIteratorOfListOfShape itte(le);
while (itte.More()) {
const TopoDS_Shape& ee = itte.Value();
TopAbs_Orientation oe = ee.Orientation();
if (M_INTERNAL(oe) || M_EXTERNAL(oe)) {loEcur.Append(ee);le.Remove(itte);}
else itte.Next();
}//itte(le)
}//exv(e)
}//ite(loEcur)
FINI = (nite == nE);
// if Scur = <currentW> gives only one new wire, and has no new splitted edges, <currentW>
// is valid and unchanged.
Standard_Boolean onewok = FINI && loW.IsEmpty() && !hasnewsplits;
if (onewok){
#ifdef DEB
if (trc) cout<<"wire "<<FUN_adds(Scur)<<" is found valid\n";
#endif
return Standard_True;
}//onewok
TopoDS_Wire newW; Standard_Boolean wiok = FUN_tool_MakeWire(loEcur, newW);
if (wiok) loW.Append(newW);
else {
#ifdef DEB
if (trc) cout<<"** FUN_tool_MakeWire fails"<<endl;
#endif
{FUN_Raise(); return Standard_False;}
}
#ifdef DEB
if (trc) {cout<<"#->new wire = wi"<<FUN_adds(newW)<<" = ";
for (TopTools_ListIteratorOfListOfShape it(loEcur); it.More(); it.Next())
cout<<" e"<<FUN_adds(it.Value());
cout<<"\n\n";}
#endif
isinit0 = Standard_True;
loEcur.Clear();
if (FINI) {
Splits.Append(loW);
return Standard_True;
}
continue;
} // wireisclosed
//*** Iteration on UV connexed edges
// ---------------------------------
// <v> is in <ed>, <p2d> = <v> current UV representation
Standard_Boolean gotonext = NextinBlock();
if (!gotonext) {
#ifdef DEB
if (trc) cout<<"** NextinBlock fails"<<endl;
#endif
{FUN_Raise(); return Standard_False;}
}
loEcur.Append(myed);
nite++;
} // nite
return Standard_True;
}
//=======================================================================
//function : REGU
//purpose : complete regularization
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::REGU()
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
TopTools_ListOfShape null;
Standard_Boolean toregu = !myListVmultiple.IsEmpty();
toregu = toregu || hasnewsplits;
TopTools_ListOfShape Splits;
if (!toregu) {
myOwNw.Bind(S(),Splits);
return Standard_True;
}
// iStep = 1;
TopTools_ListOfShape loS; Standard_Boolean ok = REGU(1,S(),loS);
if (!ok) {FUN_Raise(); return Standard_False;}
// iStep = 2;
if (loS.IsEmpty()) loS.Append(S());// no new shape
TopTools_ListIteratorOfListOfShape it(loS);
for (; it.More(); it.Next()){
const TopoDS_Shape& Scur = it.Value();
InitStep(Scur);
MapS();
Standard_Boolean toregu1 = !myListVmultiple.IsEmpty();
if (!toregu1) {Splits.Append(Scur); continue;}
TopTools_ListOfShape sp; ok = REGU(2,Scur,sp);
if (!ok) {FUN_Raise(); return Standard_False;}
if (sp.IsEmpty()) sp.Append(Scur);// no new shape
Splits.Append(sp);
}
myOwNw.Bind(S(),Splits);
return Standard_True;
}
//=======================================================================
//function : GetSplits
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::GetSplits(TopTools_ListOfShape& Splits) const
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
Standard_Boolean isb = myOwNw.IsBound(S());
if (!isb) return Standard_False;
Splits = myOwNw.Find(S());
return Standard_True;
}
//=======================================================================
//function : Connexity
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::Connexity(const TopoDS_Vertex& v, TopOpeBRepTool_connexity& co) const
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
Standard_Boolean isb = mymapvEds.Contains(v);
if (!isb) return Standard_False;
co = mymapvEds.FindFromKey(v);
return Standard_True;
}
//=======================================================================
//function : AddNewConnexity
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::AddNewConnexity(const TopoDS_Vertex& v, const Standard_Integer OriKey,const TopoDS_Edge& e)
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
Standard_Boolean isb = mymapvEds.Contains(v);
if (!isb) return Standard_False;
Standard_Boolean ok = myCORRISO.AddNewConnexity(v,e);
if (!ok) return Standard_False;
TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(v);
co.AddItem(OriKey,e);
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc)
{cout<<"** setting new connexity : v"<<FUN_adds(v)<<" is ";FUN_tro(OriKey);
cout<<" in "<<" e"<<FUN_adds(e);FUN_tool_tori(e.Orientation());
TopoDS_Vertex vclo; Standard_Boolean cloE = TopOpeBRepTool_TOOL::ClosedE(e,vclo); if (cloE) cout<<" closed";
Standard_Boolean dgE = BRep_Tool::Degenerated(e); if (dgE) cout<<" degenerated";cout<<endl;}
#endif
return Standard_True;
}
//=======================================================================
//function : RemoveOldConnexity
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::RemoveOldConnexity(const TopoDS_Vertex& v, const Standard_Integer OriKey,const TopoDS_Edge& e)
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
Standard_Boolean isb = mymapvEds.Contains(v);
if (!isb) return Standard_False;
Standard_Boolean ok = myCORRISO.RemoveOldConnexity(v,e);
// if (!ok) return Standard_False;
TopOpeBRepTool_connexity& co = mymapvEds.ChangeFromKey(v);
ok = co.RemoveItem(OriKey,e);
if (!ok) return Standard_False;
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc)
{cout<<"** removing old connexity : v"<<FUN_adds(v)<<" for e"<<FUN_adds(e);FUN_tool_tori(e.Orientation());
TopoDS_Vertex vclo; Standard_Boolean cloE = TopOpeBRepTool_TOOL::ClosedE(e,vclo); if (cloE) cout<<" closed";
Standard_Boolean dgE = BRep_Tool::Degenerated(e); if (dgE) cout<<" degenerated";cout<<endl;}
#endif
return Standard_True;
}
//=======================================================================
//function : UpdateMultiple
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_REGUW::UpdateMultiple(const TopoDS_Vertex& v)
{
if (!HasInit()) Standard_Failure::Raise("TopOpeBRepTool_REGUW : NO INIT");
Standard_Boolean isb = mymapvEds.Contains(v);
if (!isb) return Standard_False;
const TopOpeBRepTool_connexity& co = mymapvEds.FindFromKey(v);
Standard_Boolean ismult = co.IsMultiple();
if (ismult)
if (mymapvmultiple.Add(v))
myListVmultiple.Append(v);
return Standard_True;
}

View File

@@ -0,0 +1,50 @@
// File: TopOpeBRepTool_RegularizeS.cxx
// Created: Wed Jan 6 10:58:51 1999
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
#include <TopOpeBRepTool_REGUS.hxx>
#include <TopOpeBRepTool.hxx>
#include <TopoDS_Solid.hxx>
#include <TopExp_Explorer.hxx>
#include <TopOpeBRepTool_define.hxx>
//=======================================================================
//function : RegularizeShells
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::RegularizeShells(const TopoDS_Solid& theSolid,
TopTools_DataMapOfShapeListOfShape& OldSheNewShe,
TopTools_DataMapOfShapeListOfShape& FSplits)
{
OldSheNewShe.Clear();
FSplits.Clear();
TopOpeBRepTool_REGUS REGUS;
REGUS.SetOshNsh(OldSheNewShe);
REGUS.SetFsplits(FSplits);
// Standard_Boolean hastoregu = Standard_False;
TopExp_Explorer exsh(theSolid,TopAbs_SHELL);
for (; exsh.More(); exsh.Next()) {
const TopoDS_Shape& sh = exsh.Current();
REGUS.Init(sh);
Standard_Boolean ok = REGUS.MapS();
if (!ok) return Standard_False;
ok = REGUS.SplitFaces();
if (!ok) return Standard_False;
REGUS.REGU();
}//exsh(theSolid)
REGUS.GetOshNsh(OldSheNewShe); //??????????????????????????????
REGUS.GetFsplits(FSplits); //??????????????????????????????
return Standard_True;
}

View File

@@ -0,0 +1,794 @@
// File: TopOpeBRepTool_RegularizeW.cxx
// Created: Wed Dec 23 15:34:12 1998
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_CLASSI.hxx>
#include <TopOpeBRepTool_REGUW.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
#define SAME (-1)
#define DIFF (-2)
#define UNKNOWN ( 0)
#define oneINtwo ( 1)
#define twoINone ( 2)
#define M_FORWARD(sta) (sta == TopAbs_FORWARD)
#define M_REVERSED(sta) (sta == TopAbs_REVERSED)
#define M_INTERNAL(sta) (sta == TopAbs_INTERNAL)
#define M_EXTERNAL(sta) (sta == TopAbs_EXTERNAL)
#ifdef DEB
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceREGUFA();
static TopTools_IndexedMapOfShape STATIC_mapw,STATIC_mapf;
static Standard_Integer FUN_adds(const TopoDS_Shape& s) {
TopAbs_ShapeEnum typ = s.ShapeType();
TCollection_AsciiString aa; Standard_Integer is = 0;
if (typ == TopAbs_WIRE) {aa = TCollection_AsciiString("wi"); is = STATIC_mapw.Add(s); }
if (typ == TopAbs_FACE) {aa = TCollection_AsciiString("fa"); is = STATIC_mapf.Add(s); }
#ifdef DRAW
FUN_tool_draw(aa,s,is);
#endif
return is;
}
Standard_EXPORT void FUN_tool_coutsta(const Standard_Integer& sta, const Standard_Integer& i1, const Standard_Integer& i2)
{
switch (sta) {
case SAME:
cout<<i1<<" gives SAME bnd with "<<i2<<endl; break;
case DIFF:
cout<<i1<<" gives OUT bnd with "<<i2<<endl; break;
case oneINtwo:
cout<<i1<<" is IN "<<i2<<endl; break;
case twoINone:
cout<<i2<<" is IN "<<i1<<endl; break;
}
}
#endif
Standard_EXPORT void FUN_addOwlw(const TopoDS_Shape& Ow, const TopTools_ListOfShape& lw, TopTools_ListOfShape& lresu);
//=======================================================================
//function : RegularizeWires
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::RegularizeWires(const TopoDS_Face& theFace,
TopTools_DataMapOfShapeListOfShape& mapoldWnewW,
TopTools_DataMapOfShapeListOfShape& ESplits) // (e,esp); esp = splits of e
{
if (theFace.IsNull()) return Standard_False;
TopoDS_Shape aLocalShape = theFace.Oriented(TopAbs_FORWARD);
TopoDS_Face aFace = TopoDS::Face(aLocalShape);
// TopoDS_Face aFace = TopoDS::Face(theFace.Oriented(TopAbs_FORWARD));
TopOpeBRepTool_REGUW REGUW(aFace);
REGUW.SetOwNw(mapoldWnewW);
REGUW.SetEsplits(ESplits);
// Standard_Boolean hasregu = Standard_False;
TopExp_Explorer exw(aFace, TopAbs_WIRE);
for (; exw.More(); exw.Next()) {
const TopoDS_Shape& W = exw.Current();
REGUW.Init(W);
Standard_Boolean ok = REGUW.MapS();
if (!ok) return Standard_False;
ok = REGUW.SplitEds();
if (!ok) return Standard_False;
ok = REGUW.REGU();
if (!ok) return Standard_False;
}
REGUW.GetEsplits(ESplits);
REGUW.GetOwNw(mapoldWnewW);
return Standard_True;
}
//=======================================================================
//function : Regularize
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::Regularize(const TopoDS_Face& theFace,
TopTools_ListOfShape& aListOfFaces,
TopTools_DataMapOfShapeListOfShape& ESplits)
{
TopOpeBRepTool_REGUW REGUW(theFace);
aListOfFaces.Clear();
TopTools_DataMapOfShapeListOfShape mapoldWnewW;
Standard_Boolean regu = TopOpeBRepTool::RegularizeWires(theFace,mapoldWnewW,ESplits);
if (regu) {
regu = TopOpeBRepTool::RegularizeFace(theFace,mapoldWnewW,aListOfFaces);
}
return regu;
}
//**********************************************************************
// classifying wires
//**********************************************************************
// ------------------------------------------------------------
// ------------------ classifying wires -----------------------
// function : bFgreaterbFF (F,FF)
// purpose : returns False if <F>'s 3d bounding box smaller than <FF>'s
// function : mkBnd2d (W,F,B2d)
// purpose : get 2d bounding box <B2d> of wire <W>'s UV
// representation on face <F>.
// function : classiBnd2d (B,ismaller)
// purpose : compare the two 2d bounding boxes of array <B>
// if found, B<ismaller> is the smaller one and returns IN
// else if boxes are disjoint, returns OUT
// else return UNKNOWN
// function : classiBnd2d (B)
// purpose : returns SAME,DIFF,UNKNOWN,oneINtwo or twoINone
// function : mkboundedF(W,boundedF)
// purpose :
// function : FindAPointInTheFace(F,u,v)
// purpose :
// function : GetFP2d(W,boundedF,p2d)
// purpose : computes <boundedF> the bounded face built up with wire <W>
// and <p2d> a point in <boundedF>
//
// function : classiwithp2d(wi)
// purpose : classify wires (wi(k),k = 1,2)
// prequesitory : wires of <wi> are not intersecting each other.
// function : ClassifW(F,mapoldWnewW,mapWlow)
// purpose : all wires described in <mapoldWnewW> are on face <F>
// <mapoldWnewW> = map with :
// key = a wire of <F>
// item = the splits of the previous wire (can be an empty list)
// the aim is to get map <mapWlow> with :
// key = a new face's boundary
// item = wires dexcribing holes in the previous face
// (can be an empty list)
// ------------------------------------------------------------
/*static TopAbs_State FUN_tool_classiBnd2d(const Bnd_Array1OfBox2d& B,Standard_Integer& ismaller,
const Standard_Boolean chklarge = Standard_True)
{
// purpose :
// Getting <ismaller>, index of the smallest Bnd Box
// if B(i) is IN B(j): ismaller = i,
// return IN.
// else: ismaller = 1,
// if B(1) and B(2) are disjoint, return OUT
// if B(1) and B(2) are same, return ON
// else return UNKNOWN.
ismaller = 1;
TColStd_Array2OfReal UV(1,2, 1,4);
for (Standard_Integer i = 1; i <= 2; i++)
// (Umin(i), Vmin(i), Umax(i), Vmax(i))
B(i).Get(UV(i,1), UV(i,3), UV(i,2), UV(i,4));
#ifdef DEB
Standard_Boolean trc = Standard_False;
if (trc) {
for (Standard_Integer i = 1; i <= 2; i++)
cout<<"B("<<i<<") = ("<<UV(i,1)<<" "<<UV(i,3)<<" "<<UV(i,2)<<" "<<UV(i,4)<<")"<<endl;
}
#endif
Standard_Boolean smaller, same;
Standard_Integer ii, jj;
Standard_Real tol = 1.e-6;
Standard_Boolean disjoint = Standard_False;
for (Standard_Integer k = 1; k <= 3; k+=2) {
for (i = 1; i <= 2; i++) {
ii = i; jj = (i == 1) ? 2 : 1;
// diff = Umin<ii> - Umax<jj> : k = 1
// diff = Vmin<ii> - Vmax<jj> : k = 3
Standard_Real diff = UV(ii,k) - UV(jj,k+1);
// IMPORTANT : for splitted faces sharing same edge, use
// chklarge = True.
disjoint = chklarge ? (diff >= -tol) : (diff > 0.);
if (disjoint) {ismaller = 1; return TopAbs_OUT;}
}
}
for (i = 1; i <= 2; i++) {
ii = i; jj = (i == 1) ? 2 : 1;
smaller = same = Standard_True;
for (Standard_Integer k = 1; k <= 3; k += 2){
// diff = Umin<ii> - Umin<jj> : k = 1
// diff = Vmin<ii> - Vmin<jj> : k = 3
Standard_Real diff = UV(ii,k) - UV(jj,k);
smaller = chklarge ? (smaller && (diff > -tol)) : (smaller && (diff > 0.));
same = same && (Abs(diff) <= tol);
}
for (k = 2; k <= 4; k +=2){
// diff = Umax<ii> - Umax<jj> : k = 2
// diff = Vmax<ii> - Vmax<jj> : k = 4
Standard_Real diff = UV(ii,k) - UV(jj,k);
smaller = chklarge ? (smaller && (diff < tol)) : (smaller && (diff < 0.));
same = same && (Abs(diff) <= tol);
}
if (same) return TopAbs_ON;
if (smaller) {
ismaller = ii;
return TopAbs_IN;
}
}
return TopAbs_UNKNOWN;
}
#define SAME (-1)
#define DIFF (-2)
#define UNKNOWN ( 0)
#define oneINtwo ( 1)
#define twoINone ( 2)
Standard_EXPORT Standard_Integer FUN_tool_classiBnd2d(const Bnd_Array1OfBox2d& B,
const Standard_Boolean chklarge = Standard_True)
{
Standard_Integer ismaller;
TopAbs_State sta = FUN_tool_classiBnd2d(B, ismaller, chklarge);
Standard_Integer res = -10;
switch (sta) {
case TopAbs_IN :
res = ismaller; break;
case TopAbs_OUT :
res = DIFF; break;
case TopAbs_ON :
res = SAME; break;
case TopAbs_UNKNOWN :
res = UNKNOWN; break;
}
return res;
}
static Standard_Boolean FUN_tool_mkboundedF(const TopoDS_Wire& W, TopoDS_Face& boundedF)
{
BRepLib_MakeFace mf(W, Standard_False);
Standard_Boolean done = mf.IsDone();
if (done) boundedF = mf.Face();
return done;
}
Standard_Boolean FUN_tool_FindAPointInTheFace(const TopoDS_Face& F,
Standard_Real& u, Standard_Real& v)
{
Standard_Boolean ok = BRepClass3d_SolidExplorer::FindAPointInTheFace(F,u,v);
return ok;
}
static Standard_Boolean FUN_tool_GetFP2d(const TopoDS_Shape& W,
TopoDS_Shape& boundedF, gp_Pnt2d& p2d)
{
Standard_Boolean ok = FUN_tool_mkboundedF(TopoDS::Wire(W), TopoDS::Face(boundedF));
if (!ok) return Standard_False;
Standard_Real u,v; ok = FUN_tool_FindAPointInTheFace(TopoDS::Face(boundedF),u,v);
if (!ok) return Standard_False;
p2d = gp_Pnt2d(u,v);
return Standard_True;
}
static Standard_Integer FUN_tool_classiwithp2d(const TopTools_Array1OfShape& wi)
{
Standard_Integer stares = UNKNOWN;
TopTools_Array1OfShape fa(1,2);
TColgp_Array1OfPnt p3d(1,2);
for (Standard_Integer k = 1; k <= 2; k++) {
gp_Pnt2d p2d;
Standard_Boolean ok = FUN_tool_GetFP2d(wi(k), fa(k), p2d);
if (!ok) return UNKNOWN;
BRepAdaptor_Surface BS(TopoDS::Face(fa(k)));
p3d(k) = BS.Value(p2d.X(),p2d.Y());
}
TopAbs_State sta;
Standard_Integer i,j; i = j = 0;
for (Standard_Integer nite = 1; nite <= 2; nite++) {
i = nite;
j = (i == 1) ? 2 : 1;
TopoDS_Face f = TopoDS::Face(fa(j));
const gp_Pnt p = p3d(i);
Standard_Real tol = BRep_Tool::Tolerance(f);
BRepClass_FaceClassifier Fclass(f, p, tol);
sta = Fclass.State();
if (sta == TopAbs_IN) break;
}
switch (sta) {
case TopAbs_IN :
stares = i; break;
case TopAbs_OUT :
stares = DIFF; break;
case TopAbs_ON :
case TopAbs_UNKNOWN :
stares = UNKNOWN; break;
}
return stares;
}
Standard_EXPORT Standard_Boolean FUN_tool_ClassifW(const TopoDS_Face& F,
const TopTools_DataMapOfShapeListOfShape& mapoldWnewW,
TopTools_DataMapOfShapeListOfShape& mapWlow)
{
// NYI : create maps to store Bnd_Box2d, and faces.
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<"** ClassifW :"<<endl;
STATIC_mapw.Clear();
#endif
// Purpose :
// --------
// Filling the map <mapWlow> : with (key + item) = new face,
// item = (newface has holes) ? list of wires IN the wire key: empty list
// prequesitory : <mapoldWnewW> binds (non splitted wire of <F>, emptylos)
// (splitted wire of <F>, splits of the wire)
// Mapping :
// --------
// Filling <oldW> : list of wires of <F>
// Filling <mapWlow> : with (non-splitted old wire, emptylos),
// (split of old wire, emptylos)
TopTools_ListOfShape oldW;
Standard_Integer noldW = mapoldWnewW.Extent();
Standard_Boolean oneoldW = (noldW == 1);
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape ite(mapoldWnewW);
TopTools_ListOfShape emptylos;
// --------------
// * noldW == 1 :
// --------------
if (oneoldW) {
const TopoDS_Wire& oldwi = TopoDS::Wire(ite.Key());
const TopTools_ListOfShape& low = ite.Value();
Standard_Integer nw = low.Extent();
if (nw == 0) {mapWlow.Bind(oldwi,emptylos); return Standard_True;}
if (nw == 1) {mapWlow.Bind(low.First(),emptylos); return Standard_True;}
// <complWoldw> = {(newwire, emptylos)}
TopTools_DataMapOfShapeListOfShape complWoldw;
TopTools_ListIteratorOfListOfShape itlw(low);
for (; itlw.More(); itlw.Next()) complWoldw.Bind(itlw.Value(), emptylos);
// iteration on <complWoldw> :
Standard_Integer ncompl = complWoldw.Extent();
Standard_Boolean go = Standard_True;
Standard_Integer nite = 0, nitemax = Standard_Integer(ncompl*(ncompl-1)/2);
while (go && (nite <= nitemax)){
Bnd_Array1OfBox2d Bnd2d(1,2);
TopTools_Array1OfShape wi(1,2);
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itmap(complWoldw);
wi(1) = itmap.Key();
if (ncompl == 1) {
mapWlow.Bind(wi(1),itmap.Value());
break;
}
FUN_tool_mkBnd2d(wi(1), F, Bnd2d(1));
Standard_Boolean OUTall = Standard_False;
Standard_Boolean oneINother = Standard_False;
Standard_Integer sma,gre; // dummy if !oneINother
for (; itmap.More(); itmap.Next()) {
wi(2) = itmap.Key();
if (wi(1).IsSame(wi(2))) continue;
FUN_tool_mkBnd2d(wi(2), F, Bnd2d(2));
// sta : wi(1) / wi(2)
Standard_Integer sta = FUN_tool_classiBnd2d(Bnd2d);
nite++;
if ((sta == SAME)||(sta == UNKNOWN)) sta = FUN_tool_classiwithp2d(wi);
#ifdef DEB
if (trc) {cout<<"#wi :";FUN_tool_coutsta(sta,FUN_adds(wi(1)),FUN_adds(wi(2)));}
#endif
if ((sta == SAME)||(sta == UNKNOWN)) return Standard_False;
if ((sta == DIFF) && itmap.More()) {OUTall = Standard_True; continue;}// w(1) OUT w(2)
sma = (sta == oneINtwo) ? 1 : 2;
gre = (sta == oneINtwo) ? 2 : 1;
oneINother = Standard_True;
break;
} // itmap
if (oneINother) {
// Updating map <complWoldw> with :
// - key = wi(gre),
// item += wi(sma) && item += item(wi(sma))
// - unbinding key = (wi(sma))
TopTools_ListOfShape& lwgre = complWoldw.ChangeFind(wi(gre));
lwgre.Append(wi(sma));
TopTools_ListIteratorOfListOfShape itwsma(complWoldw.Find(wi(sma)));
for (; itwsma.More(); itwsma.Next()) lwgre.Append(itwsma.Value());
complWoldw.UnBind(wi(sma));
}
else if (OUTall) {mapWlow.Bind(wi(1),emptylos); complWoldw.UnBind(wi(1));}
else return Standard_False;
ncompl = complWoldw.Extent();
go = (ncompl >= 1);
}
return Standard_True;
} // oneoldW
// -------------
// * noldW > 1 :
// -------------
for (; ite.More(); ite.Next()){
const TopoDS_Wire& oldwi = TopoDS::Wire(ite.Key());
const TopTools_ListOfShape& low = ite.Value();
TopTools_ListIteratorOfListOfShape itlow(low);
if (low.IsEmpty()) mapWlow.Bind(oldwi, emptylos);
else
for (; itlow.More(); itlow.Next()) mapWlow.Bind(itlow.Value(), emptylos);
oldW.Append(oldwi);
}
// classifying wires of <mapoldWnewW> :
// -----------------------------------
// <Owi> : old wires
// <OBnd2d> : old wires' bounding boxes
// <Owhassp>(k) : Owi(k) has splits
TopTools_ListOfShape oldWcopy; oldWcopy.Assign(oldW);
for (TopTools_ListIteratorOfListOfShape itoldW(oldW); itoldW.More(); itoldW.Next()) {
TopTools_Array1OfShape Owi(1,2);
Bnd_Array1OfBox2d OBnd2d(1,2);
TColStd_Array1OfBoolean Owhassp(1,2);
Owi(1) = itoldW.Value();
if (oldWcopy.Extent() <1) break;
oldWcopy.RemoveFirst();
Owhassp(1) = !mapoldWnewW.Find(Owi(1)).IsEmpty();
Standard_Boolean Owi1notkey = !mapWlow.IsBound(Owi(1));
if (Owi1notkey && !Owhassp(1)) continue;
FUN_tool_mkBnd2d(Owi(1), F, OBnd2d(1));
// Classifying oldwire(i) with oldwires(j): j = i+1..nwiresofF
Standard_Integer osma,ogre,osta;
TopTools_ListIteratorOfListOfShape itoldWcopy(oldWcopy);
for (; itoldWcopy.More(); itoldWcopy.Next()) {
TopTools_Array1OfListOfShape newwi(1,2);
Owi(2) = TopoDS::Wire(itoldWcopy.Value());
Standard_Boolean Owi2notkey = !mapWlow.IsBound(Owi(2));
Owhassp(2) = !mapoldWnewW.Find(Owi(2)).IsEmpty();
if (Owi2notkey && !Owhassp(2)) continue;
FUN_tool_mkBnd2d(Owi(2), F, OBnd2d(2));
// <osma>, <ogre> :
// ----------------
// Classifying Ow<i> with Ow<j> :
osta = FUN_tool_classiBnd2d(OBnd2d);
if ((osta == SAME)||(osta == UNKNOWN)) osta = FUN_tool_classiwithp2d(Owi);
#ifdef DEB
if (trc) {cout<<"wi : "; FUN_tool_coutsta(osta,FUN_adds(Owi(1)),FUN_adds(Owi(2)));}
#endif
if ((osta == SAME)||(osta == UNKNOWN)) return Standard_False;
if (osta == DIFF) continue; // Ow(1), Ow(2) are disjoint
// Owi<sma> is IN Owi<grea>
osma = (osta == oneINtwo) ? 1 : 2;
ogre = (osta == oneINtwo) ? 2 : 1;
// Owhassp<k> : newwi<k> = splits (Owi<k>)
// !Owhassp<k> : newwi<k> = Owi<k>
for (Standard_Integer i = 1; i <= 2; i++) {
const TopoDS_Shape& owi = Owi(i);
if (!Owhassp(i)) newwi(i).Append(owi);
else newwi(i) = mapoldWnewW.Find(owi);
}
//
// classifying wires of newwi<sma> with wires of newwi<gre> :
//
Standard_Integer sta, sma, gre;
TopTools_ListIteratorOfListOfShape itnwi(newwi(osma));
for (; itnwi.More(); itnwi.Next()) {
// <wi> : new wires
// <Bnd2d> : new wires' bounding boxes
TopTools_Array1OfShape wi(1,2);
Bnd_Array1OfBox2d Bnd2d(1,2);
wi(1) = itnwi.Value(); // wi(1) in {newwi(osma)}
Standard_Boolean wi1notkey = !mapWlow.IsBound(wi(1));
if (wi1notkey) continue;
if (!Owhassp(osma)) Bnd2d(1).Add(OBnd2d(osma));
else FUN_tool_mkBnd2d(wi(1), F, Bnd2d(1));
TopTools_ListIteratorOfListOfShape itnwj(newwi(ogre));
for (; itnwj.More(); itnwj.Next()) {
wi(2) = itnwj.Value(); // wi(2) in {newwi(ogre)}
Standard_Boolean wi2notkey = !mapWlow.IsBound(wi(2));
if (wi2notkey) continue;
// empty the bounding box
Bnd_Box2d newB2d;
if (!Owhassp(ogre)) newB2d.Add(OBnd2d(ogre));
else FUN_tool_mkBnd2d(wi(2), F, newB2d);
FUN_tool_UpdateBnd2d(Bnd2d(2),newB2d);
// Classifying wi(1) with wi(2) :
sta = FUN_tool_classiBnd2d(Bnd2d);
#ifdef DEB
if (trc) {cout<<"wi : "; FUN_tool_coutsta(sta,STATIC_mapw.FindIndex(wi(1)),
STATIC_mapw.FindIndex(wi(2)));}
#endif
if ((sta == SAME)||(sta == UNKNOWN)) sta = FUN_tool_classiwithp2d(wi);
if ((sta == SAME)||(sta == UNKNOWN)) return Standard_False;
if (sta == DIFF) continue;
// wi<sma> is IN wi<grea>
sma = (sta == oneINtwo) ? 1 : 2;
gre = (sta == oneINtwo) ? 2 : 1;
// Updating map <mapWlow> with :
// - key = wi(gre),
// item += wi(sma) && item += item(wi(sma))
// - unbinding key = (wi(sma))
TopTools_ListOfShape& lwgre = mapWlow.ChangeFind(wi(gre));
lwgre.Append(wi(sma));
TopTools_ListIteratorOfListOfShape itwsma(mapWlow.Find(wi(sma)));
for (; itwsma.More(); itwsma.Next()) lwgre.Append(itwsma.Value());
mapWlow.UnBind(wi(sma));
break;
// wi<sma> IN wi<gre>, wi<sma> is OUT {newwi<gre>} / wi<gre>
// wi<sma> is classified / all newwires.
}
} // itnwi(newwi(sma))
}// itoldWcopy
} // itoldW
return Standard_True;
}
// ------------------------------------------------------------
// -------------------- building up faces ---------------------
// ------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_MakeFaces(const TopoDS_Face& theFace,
TopTools_DataMapOfShapeListOfShape& mapWlow,
TopTools_ListOfShape& aListOfFaces)
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<"** MakeFaces :"<<endl;
#endif
Standard_Boolean toreverse = M_REVERSED(theFace.Orientation());
TopoDS_Face F = TopoDS::Face(theFace.Oriented(TopAbs_FORWARD));
BRep_Builder BB;
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(mapWlow);
for (; itm.More(); itm.Next()) {
const TopoDS_Wire& wi = TopoDS::Wire(itm.Key());
TopoDS_Shape FF = F.EmptyCopied(); BB.Add(FF,wi);
// BB.MakeFace(FF); // put a TShape
TopTools_ListIteratorOfListOfShape itlow(itm.Value());
for (; itlow.More(); itlow.Next()) {
const TopoDS_Wire& wwi = TopoDS::Wire(itlow.Value());
BB.Add(FF,wwi);
}
if (toreverse) FF.Orientation(TopAbs_REVERSED);
aListOfFaces.Append(FF);
}
#ifdef DEB
if (trc) {
cout<<"sp(fa"<<FUN_adds(theFace)<<")=";
TopTools_ListIteratorOfListOfShape it(aListOfFaces);
for (; it.More(); it.Next()) cout<<" fa"<<FUN_adds(it.Value());
cout<<endl;
}
#endif
return Standard_True;
}*/
Standard_EXPORT Standard_Boolean FUN_tool_ClassifW(const TopoDS_Face& F,
const TopTools_DataMapOfShapeListOfShape& mapOwNw,
TopTools_DataMapOfShapeListOfShape& mapWlow)
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettraceREGUFA();
if (trc) cout<<"** ClassifW :"<<endl;
#endif
Standard_Real tolF = BRep_Tool::Tolerance(F);
Standard_Real toluv = TopOpeBRepTool_TOOL::TolUV(F,tolF);
TopoDS_Shape aLocalShape = F.Oriented(TopAbs_FORWARD);
TopoDS_Face FFOR = TopoDS::Face(aLocalShape);
// TopoDS_Face FFOR = TopoDS::Face(F.Oriented(TopAbs_FORWARD));
TopOpeBRepTool_CLASSI CLASSI; CLASSI.Init2d(FFOR);
TopTools_ListOfShape null;
TopTools_ListOfShape oldW;
Standard_Integer noldW = mapOwNw.Extent();
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itm(mapOwNw);
// noldW = 1
// ---------
if (noldW == 1) {
#ifdef DEB
const TopoDS_Shape& owi =
#endif
itm.Key(); // DEB
const TopTools_ListOfShape& low = itm.Value();
Standard_Boolean ok = CLASSI.Classilist(low,mapWlow);
if (!ok) return Standard_False;
return Standard_True;
}
// noldW > 1
// ---------
TopTools_ListOfShape lOws;
for (; itm.More(); itm.Next()){
const TopoDS_Shape& owi = itm.Key();
lOws.Append(owi);
const TopTools_ListOfShape& low = itm.Value();
TopTools_ListOfShape lwresu; FUN_addOwlw(owi,low,lwresu);
TopTools_ListIteratorOfListOfShape itw(lwresu);
for (; itw.More(); itw.Next()) mapWlow.Bind(itw.Value(), null);
}//itm(mapOwNw)
TopTools_MapOfShape mapdone;
Standard_Integer nOw = noldW;
Standard_Integer nite = 0, nitemax = Standard_Integer(nOw*(nOw-1)/2);
while (nite <= nitemax){
nOw = lOws.Extent();
if (nOw == 0) break;
TopTools_ListIteratorOfListOfShape itOw(lOws);
const TopoDS_Shape& Ow1 = itOw.Value();
Standard_Boolean isb1 = mapWlow.IsBound(Ow1);
isb1 = isb1 || !mapdone.Contains(Ow1);
if (!isb1) continue;
const TopTools_ListOfShape& lw1 = mapOwNw.Find(Ow1);
#ifdef DEB
Standard_Integer nw1 =
#endif
lw1.Extent();
if (nOw == 1) {
// all wires of <mapWs> have been treated, except the last one
// if (nw1 == 0) mapWlow binds already (Ow1,null);
// else {mapWlow binds already (w1k,null), w1k in lw1}
break;
}//nOw == 1
itOw.Next();
Standard_Boolean OUTall = Standard_False;
TopoDS_Shape Ow2;
Standard_Integer sta12 = UNKNOWN;
for (; itOw.More(); itOw.Next()){
Ow2 = itOw.Value();
Standard_Boolean isb2 = mapWlow.IsBound(Ow2);
isb2 = isb2 || !mapdone.Contains(Ow2);
if (!isb2) continue;
Standard_Integer stabnd2d12 = CLASSI.ClassiBnd2d(Ow1,Ow2,toluv,Standard_True);
sta12 = CLASSI.Classip2d(Ow1,Ow2, stabnd2d12);
if (sta12 == DIFF) {OUTall = Standard_True; continue;}
else if ((sta12 == UNKNOWN)||(sta12 == SAME)) return Standard_False;
break;
}
if (OUTall) {
// if (nw1 == 0) mapWlow binds already (Ow1,null);
// else {mapWlow binds already (w1k,null), w1k in lw1}
TopTools_ListOfShape ldone; FUN_addOwlw(Ow1,lw1,ldone);
TopTools_ListIteratorOfListOfShape itw(ldone);
for (; itw.More(); itw.Next()) mapdone.Add(itw.Value());
#ifdef DEB
if (trc) cout<<"old wires :wi"<<FUN_adds(Ow1)<<" is OUT all old wires"<<endl;
#endif
lOws.RemoveFirst();
}//OUTall
else {
#ifdef DEB
if (trc) {cout<<"old wires :wi -> ";
FUN_tool_coutsta(sta12,FUN_adds(Ow1),FUN_adds(Ow2));
cout<<endl;}
#endif
const TopTools_ListOfShape& lw2 = mapOwNw.Find(Ow2);
#ifdef DEB
Standard_Integer nw2 =
#endif
lw2.Extent();
TopTools_ListOfShape lw1r; FUN_addOwlw(Ow1,lw1,lw1r);
TopTools_ListOfShape lw2r; FUN_addOwlw(Ow2,lw2,lw2r);
TopTools_ListOfShape lgre,lsma;
if (sta12 == oneINtwo) {lgre.Append(lw2r); lsma.Append(lw1r);}
if (sta12 == twoINone) {lgre.Append(lw1r); lsma.Append(lw2r);}
TopTools_ListIteratorOfListOfShape itsma(lsma);
for (; itsma.More(); itsma.Next()){
const TopoDS_Shape& wsma = itsma.Value();
Standard_Boolean isbsma = mapWlow.IsBound(wsma);
isbsma = isbsma || !mapdone.Contains(wsma);
if (!isbsma) continue;
TopTools_ListIteratorOfListOfShape itgre(lgre);
for (; itgre.More(); itgre.Next()){
const TopoDS_Shape& wgre = itgre.Value();
Standard_Boolean isbgre = mapWlow.IsBound(wgre);
isbgre = isbgre || !mapdone.Contains(wgre);
if (!isbgre) continue;
Standard_Integer stabnd2d = CLASSI.ClassiBnd2d(wsma,wgre,toluv,Standard_True);
Standard_Integer sta = CLASSI.Classip2d(wsma,wgre, stabnd2d);
#ifdef DEB
if (trc) {cout<<" wires :wi -> ";
FUN_tool_coutsta(sta,FUN_adds(wsma),FUN_adds(wgre));
cout<<endl;}
#endif
if (sta == DIFF) continue;
else if (sta == oneINtwo) {// wsma IN wgre
mapWlow.ChangeFind(wgre).Append(mapWlow.ChangeFind(wsma));
mapWlow.UnBind(wsma);
}
else if (sta == twoINone) {// wgre IN wsma
mapWlow.ChangeFind(wsma).Append(mapWlow.ChangeFind(wgre));
mapWlow.UnBind(wgre);
}
else return Standard_False;
}//itgre
}//itsma
lOws.RemoveFirst();
} //!OUTall
}//nite
return Standard_True;
}
//=======================================================================
//function : RegularizeFace
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool::RegularizeFace(const TopoDS_Face& theFace,
const TopTools_DataMapOfShapeListOfShape& mapoldWnewW,
TopTools_ListOfShape& newFaces)
{
// <mapWlow>
// ---------
// key = wire <w>,
// item = if the new face has holes, the item contains wires
// classified IN the area described by the boundary <w>
// on <aFace>,
// else : the item is an empty list, <w> describes the
// whole new face.
TopTools_DataMapOfShapeListOfShape mapWlow;
// Classifying wires :
// -------------------
// Standard_Boolean classifok = FUN_tool_ClassifW(theFace, mapoldWnewW, mapWlow);
TopoDS_Shape aLocalShape = theFace.Oriented(TopAbs_FORWARD);
TopoDS_Face aFace = TopoDS::Face(aLocalShape);
// TopoDS_Face aFace = TopoDS::Face(theFace.Oriented(TopAbs_FORWARD));
Standard_Boolean classifok = FUN_tool_ClassifW(aFace, mapoldWnewW, mapWlow);
if (!classifok) return Standard_False;
// <aListOfFaces>
// -------------
Standard_Boolean facesbuilt = TopOpeBRepTool_TOOL::WireToFace(theFace, mapWlow, newFaces);
if (!facesbuilt) return Standard_False;
return Standard_True;
}

View File

@@ -0,0 +1,53 @@
// File: TopOpeBRepTool_SC.cxx
// Created: Wed Apr 1 15:22:42 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_SC.hxx>
// ----------------------------------------------------------------------
static TopOpeBRepTool_PShapeClassifier TopOpeBRepTool_PSC = NULL;
Standard_EXPORT TopOpeBRepTool_ShapeClassifier& FSC_GetPSC(void)
{
if (TopOpeBRepTool_PSC == NULL) TopOpeBRepTool_PSC = new TopOpeBRepTool_ShapeClassifier();
return *TopOpeBRepTool_PSC;
}
// ----------------------------------------------------------------------
Standard_EXPORT TopOpeBRepTool_ShapeClassifier& FSC_GetPSC(const TopoDS_Shape& S)
{
if (TopOpeBRepTool_PSC == NULL) TopOpeBRepTool_PSC = new TopOpeBRepTool_ShapeClassifier();
TopOpeBRepTool_PSC->SetReference(S);
return *TopOpeBRepTool_PSC;
}
// ----------------------------------------------------------------------
Standard_EXPORT TopAbs_State FSC_StatePonFace(const gp_Pnt& P,const TopoDS_Shape& F,
TopOpeBRepTool_ShapeClassifier& PSC)
{
// Projects <P> on the surface and classifies it in the face <F>
Handle(Geom_Surface) S = BRep_Tool::Surface(TopoDS::Face(F));
gp_Pnt2d UV; Standard_Real dist; Standard_Boolean ok = FUN_tool_projPonS(P,S,UV,dist);
if (!ok) return TopAbs_UNKNOWN;
PSC.SetReference(TopoDS::Face(F));
PSC.StateP2DReference(UV);
TopAbs_State state = PSC.State();
return state;
}
// ----------------------------------------------------------------------
Standard_EXPORT TopAbs_State FSC_StateEonFace(const TopoDS_Shape& E,const Standard_Real t,const TopoDS_Shape& F,
TopOpeBRepTool_ShapeClassifier& PSC)
{
BRepAdaptor_Curve BAC(TopoDS::Edge(E));
Standard_Real f,l; FUN_tool_bounds(TopoDS::Edge(E),f,l);
Standard_Real par = (1-t)*f + t*l;
gp_Pnt P;BAC.D0(par,P);
TopAbs_State state = FSC_StatePonFace(P,F,PSC);
return state;
}

View File

@@ -0,0 +1,24 @@
// File: TopOpeBRepTool_SC.hxx
// Created: Wed Apr 1 15:25:56 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_SC_HeaderFile
#define _TopOpeBRepTool_SC_HeaderFile
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_ShapeClassifier.hxx>
#include <TopOpeBRepTool_PShapeClassifier.hxx>
#define MTLsc TopOpeBRepTool_ShapeClassifier
#define MTLpsc TopOpeBRepTool_PShapeClassifier
Standard_EXPORT TopOpeBRepTool_ShapeClassifier& FSC_GetPSC(void);
Standard_EXPORT TopOpeBRepTool_ShapeClassifier& FSC_GetPSC(const TopoDS_Shape& S);
// ----------------------------------------------------------------------
// state point <P> on/in shapes (edge <E>,face <F>)
// ----------------------------------------------------------------------
Standard_EXPORT TopAbs_State FSC_StatePonFace(const gp_Pnt& P,const TopoDS_Shape& F,TopOpeBRepTool_ShapeClassifier& PSC);
Standard_EXPORT TopAbs_State FSC_StateEonFace(const TopoDS_Shape& E,const Standard_Real t,const TopoDS_Shape& F,TopOpeBRepTool_ShapeClassifier& PSC);
#endif

View File

@@ -0,0 +1,78 @@
// File: TopOpeBRepTool_STATE.cxx
// Created: Wed Oct 22 16:36:31 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#ifdef DEB
#include <TopOpeBRepTool_STATE.hxx>
TopOpeBRepTool_STATE::TopOpeBRepTool_STATE
(const char* name, const Standard_Boolean b) :
myin(Standard_False),myout(Standard_False),
myon(Standard_False),myunknown(Standard_False),
myonetrue(Standard_False)
{
strcpy(myname,name);
Set(b);
}
void TopOpeBRepTool_STATE::Set(const Standard_Boolean b)
{
Set(TopAbs_IN,b);
Set(TopAbs_OUT,b);
Set(TopAbs_ON,b);
Set(TopAbs_UNKNOWN,b);
}
void TopOpeBRepTool_STATE::Set
(const TopAbs_State S,const Standard_Boolean b)
{
switch(S) {
case TopAbs_IN : myin = b; break;
case TopAbs_OUT : myout = b; break;
case TopAbs_ON : myon = b; break;
case TopAbs_UNKNOWN : myunknown = b; break;
}
myonetrue = myin || myout || myon || myunknown;
}
void TopOpeBRepTool_STATE::Set(const Standard_Boolean b,
Standard_Integer n, char** a)
{
if (!n) Set(b);
else {
Set(Standard_False);
for (Standard_Integer i=0; i < n; i++) {
const char *p = a[i];
if ( !strcmp(p,"IN") ) Set(TopAbs_IN,b);
else if ( !strcmp(p,"OUT") ) Set(TopAbs_OUT,b);
else if ( !strcmp(p,"ON") ) Set(TopAbs_ON,b);
else if ( !strcmp(p,"UNKNOWN") ) Set(TopAbs_UNKNOWN,b);
}
Print();
}
}
Standard_Boolean TopOpeBRepTool_STATE::Get(const TopAbs_State S)
{
Standard_Boolean b;
switch(S) {
case TopAbs_IN : b = myin; break;
case TopAbs_OUT : b = myout; break;
case TopAbs_ON : b = myon; break;
case TopAbs_UNKNOWN : b = myunknown; break;
}
return b;
}
void TopOpeBRepTool_STATE::Print()
{
cout<<myname<<" : ";
cout<<"IN/OUT/ON/UNKNOWN = ";
cout<<Get(TopAbs_IN)<<Get(TopAbs_OUT)<<Get(TopAbs_ON)<<Get(TopAbs_UNKNOWN);
cout<<endl;
}
// #define DEB
#endif

View File

@@ -0,0 +1,41 @@
// File: TopOpeBRepTool_STATE.hxx
// Created: Wed Oct 22 16:36:31 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_STATE_HeaderFile
#define _TopOpeBRepTool_STATE_HeaderFile
#ifdef DEB
#include <Standard_Type.hxx>
#include <TopAbs_State.hxx>
// -----------------------------------------------------------------------
// TopOpeBRepTool_STATE : class of 4 booleans matching TopAbs_State values
// -----------------------------------------------------------------------
class TopOpeBRepTool_STATE {
public:
TopOpeBRepTool_STATE(const char* name,
const Standard_Boolean b = Standard_False);
void Set(const Standard_Boolean b);
void Set(const TopAbs_State S, const Standard_Boolean b);
void Set(const Standard_Boolean b, Standard_Integer n, char** a);
Standard_Boolean Get(const TopAbs_State S);
Standard_Boolean Get() { return myonetrue; }
void Print();
private:
Standard_Boolean myin,myout,myon,myunknown;
Standard_Boolean myonetrue;
char myname[100];
};
// #define DEB
#endif
// #define _TopOpeBRepTool_STATE_HeaderFile
#endif

View File

@@ -0,0 +1,163 @@
-- File: TopOpeBRepTool_ShapeClassifier.cdl
-- Created: Tue Feb 1 17:58:30 1994
-- Author: Jean Yves LEBEY
-- <jyl@phobox>
---Copyright: Matra Datavision 1994
class ShapeClassifier from TopOpeBRepTool
uses
State from TopAbs,
Shape from TopoDS,
Edge from TopoDS,
Face from TopoDS,
IndexedMapOfShape from TopTools,
ListOfShape from TopTools,
Pnt2d from gp,
Pnt from gp,
Plos from TopOpeBRepTool,
SolidClassifier from TopOpeBRepTool
is
Create returns ShapeClassifier;
Create(SRef : Shape from TopoDS) returns ShapeClassifier;
---Purpose:
-- SRef is the reference shape.
-- StateShapeShape(S) calls will classify S with SRef.
ClearAll(me : in out) is static;
---Purpose: reset all internal data (SolidClassifier included)
ClearCurrent(me : in out) is static;
---Purpose: reset all internal data (except SolidClassified)
SetReference(me : in out; SRef : Shape from TopoDS)
---Purpose:
-- Set SRef as reference shape
-- the next StateShapeReference(S,AvoidS) calls will classify S with SRef.
is static;
StateShapeShape(me : in out; S,SRef : Shape from TopoDS;
samedomain : Integer = 0)
---Purpose:
-- classify shape S compared with shape SRef.
-- samedomain = 0 : S1,S2 are not same domain
-- samedomain = 1 : S1,S2 are same domain
returns State from TopAbs is static;
SameDomain(me) returns Integer;
SameDomain(me : in out; samedomain : Integer)
---Purpose:
-- set mode for next StateShapeShape call
-- samedomain = true --> S,Sref are same domain --> point
-- on restriction (ON S) is used to classify S.
-- samedomain = false --> S,Sref are not domain --> point
-- not on restriction of S (IN S) is used to classify S.
-- samedomain value is used only in next StateShapeShape call
is static;
StateShapeShape(me : in out; S : Shape from TopoDS;
AvoidS : Shape from TopoDS;
SRef : Shape from TopoDS)
---Purpose:
-- classify shape S compared with shape SRef.
-- AvoidS is not used in classification; AvoidS may be IsNull().
-- (usefull to avoid ON or UNKNOWN state in special cases)
returns State from TopAbs is static;
StateShapeShape(me : in out; S :Shape from TopoDS;
LAvoidS : ListOfShape from TopTools;
SRef : Shape from TopoDS)
---Purpose:
-- classify shape S compared with shape SRef.
-- LAvoidS is list of S subshapes to avoid in classification
-- AvoidS is not used in classification; AvoidS may be IsNull().
-- (usefull to avoid ON or UNKNOWN state in special cases)
returns State from TopAbs is static;
StateShapeReference(me : in out; S,AvoidS : Shape from TopoDS)
---Purpose:
-- classify shape S compared with reference shape.
-- AvoidS is not used in classification; AvoidS may be IsNull().
-- (usefull to avoid ON or UNKNOWN state in special cases)
returns State from TopAbs is static;
StateShapeReference(me : in out; S : Shape from TopoDS;
LAvoidS : ListOfShape from TopTools)
---Purpose:
-- classify shape S compared with reference shape.
-- LAvoidS is list of S subshapes to avoid in classification
-- (usefull to avoid ON or UNKNOWN state in special cases)
returns State from TopAbs is static;
ChangeSolidClassifier(me:in out) returns SolidClassifier from TopOpeBRepTool;
---C++: return &
--- private
MapRef(me:in out) is static private;
FindEdge(me : in out)
is static private;
FindEdge(me : in out; S : Shape from TopoDS)
is static private;
FindFace(me : in out; S : Shape from TopoDS)
is static private;
Perform(me : in out)
is static private;
StateEdgeReference(me : in out)
---Purpose: classify myEdge with myRef
is static private;
StateP2DReference(me : in out; P2D : Pnt2d from gp)
---Purpose: classify point P2D with myRef
is static;
StateP3DReference(me : in out; P3D : Pnt from gp)
---Purpose: classify point P3D with myRef
is static;
State(me)
---Purpose: return field myState
returns State from TopAbs;
P2D(me) returns Pnt2d from gp
---C++: return const &
is static;
P3D(me) returns Pnt from gp
---C++: return const &
is static;
HasAvLS(me) returns Boolean from Standard is static private;
fields
myS : Shape from TopoDS;
myRef : Shape from TopoDS;
myAvS : Shape from TopoDS;
myPAvLS : Plos from TopOpeBRepTool; -- pointer to ListOfShape
myMapAvS : IndexedMapOfShape from TopTools;
mymre : IndexedMapOfShape from TopTools;
mymren : Integer;
mymredone : Boolean;
myState : State from TopAbs;
myEdge : Edge from TopoDS;
myFace : Face from TopoDS;
myP3Ddef : Boolean;
myP3D : Pnt from gp;
myP2Ddef : Boolean;
myP2D : Pnt2d from gp;
mySolidClassifier : SolidClassifier from TopOpeBRepTool;
mySameDomain : Integer; -- -1 undef, 0 not same domain, 1 same domain
end ShapeClassifier from TopOpeBRepTool;

View File

@@ -0,0 +1,789 @@
// File: TopOpeBRepTool_ShapeClassifier.cxx
// Created: Tue Feb 1 18:18:54 1994
// Author: Jean Yves LEBEY
// <jyl@phobox>
#include <TopOpeBRepTool_ShapeClassifier.ixx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <gp_Vec2d.hxx>
#include <Precision.hxx>
#include <Standard_ProgramError.hxx>
#include <BRepClass_FacePassiveClassifier.hxx>
#include <BRepClass3d_SolidExplorer.hxx>
#include <BRepClass_Edge.hxx>
#include <BRepAdaptor_Curve2d.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <TopOpeBRepTool_CurveTool.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_2d.hxx>
//=======================================================================
//function : TopOpeBRepTool_ShapeClassifier
//purpose :
//=======================================================================
TopOpeBRepTool_ShapeClassifier::TopOpeBRepTool_ShapeClassifier() :
myP3Ddef(Standard_False),myP2Ddef(Standard_False)
{
}
//=======================================================================
//function : TopOpeBRepTool_ShapeClassifier
//purpose :
//=======================================================================
TopOpeBRepTool_ShapeClassifier::TopOpeBRepTool_ShapeClassifier
(const TopoDS_Shape& SRef) :myP3Ddef(Standard_False),myP2Ddef(Standard_False)
{
myRef = SRef;
}
//=======================================================================
//function : ClearAll
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::ClearAll()
{
ClearCurrent();
mySolidClassifier.Clear();
}
//=======================================================================
//function : ClearCurrent
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::ClearCurrent()
{
mySameDomain = -1;
myS.Nullify();
myRef.Nullify();
myAvS.Nullify();
myMapAvS.Clear();
mymre.Clear();
mymren = 0;
mymredone = Standard_False;
myState = TopAbs_UNKNOWN;
myEdge.Nullify();
myFace.Nullify();
myP3Ddef = myP2Ddef = Standard_False;
}
//=======================================================================
//function : SameDomain
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_ShapeClassifier::SameDomain() const
{
return mySameDomain;
}
//=======================================================================
//function : SameDomain
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::SameDomain(const Standard_Integer sam)
{
mySameDomain = sam;
}
//=======================================================================
//function : SetReference
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::SetReference(const TopoDS_Shape& SRef)
{
myRef = SRef;
MapRef();
}
//=======================================================================
//function : MapRef
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::MapRef()
{
mymre.Clear();
mymren = 0;
if (myRef.ShapeType() == TopAbs_FACE && mySameDomain == 1) {
TopExp::MapShapes(myRef,TopAbs_EDGE,mymre);
mymren = mymre.Extent();
if (mymren == 1) {
TopExp_Explorer x(myRef,TopAbs_EDGE);
const TopoDS_Edge& E = TopoDS::Edge(x.Current());
TopoDS_Vertex v1,v2;TopExp::Vertices(E,v1,v2);
if (v1.IsSame(v2)) mymren = 0;
}
}
mymredone = Standard_True;
}
//=======================================================================
//function : StateShapeShape
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_ShapeClassifier::StateShapeShape
(const TopoDS_Shape& S,const TopoDS_Shape& SRef,const Standard_Integer samedomain)
{
ClearCurrent();
mySameDomain = samedomain;
myS = S;
myAvS.Nullify();
myPAvLS = NULL;
myRef = SRef;
Perform();
return myState;
}
//=======================================================================
//function : StateShapeShape
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_ShapeClassifier::StateShapeShape
(const TopoDS_Shape& S,const TopoDS_Shape& AvS,const TopoDS_Shape& SRef)
{
ClearCurrent();
myS = S;
myAvS = AvS;
myPAvLS = NULL;
myRef = SRef;
Perform();
return myState;
}
//=======================================================================
//function : StateShapeShape
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_ShapeClassifier::StateShapeShape
(const TopoDS_Shape& S, const TopTools_ListOfShape& AvLS,const TopoDS_Shape& SRef)
{
ClearCurrent();
myS = S;
myAvS.Nullify();
myPAvLS = (TopTools_ListOfShape*)&AvLS;
myRef = SRef;
Perform();
return myState;
}
//=======================================================================
//function : StateShapeReference
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_ShapeClassifier::StateShapeReference
(const TopoDS_Shape& S,const TopoDS_Shape& AvS)
{
myS = S;
myAvS = AvS;
myPAvLS = NULL;
Perform();
return myState;
}
//=======================================================================
//function : StateShapeReference
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_ShapeClassifier::StateShapeReference
(const TopoDS_Shape& S,const TopTools_ListOfShape& AvLS)
{
myS = S;
myAvS.Nullify();
myPAvLS = (TopTools_ListOfShape*)&AvLS;
Perform();
return myState;
}
//=======================================================================
//function : ChangeSolidClassifier
//purpose :
//=======================================================================
TopOpeBRepTool_SolidClassifier& TopOpeBRepTool_ShapeClassifier::ChangeSolidClassifier()
{
return mySolidClassifier;
}
//=======================================================================
//function : FindEdge
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::FindEdge()
{
myEdge.Nullify();
myFace.Nullify();
TopAbs_ShapeEnum t = myS.ShapeType();
if ( t < TopAbs_FACE ) { // compsolid .. shell
FindFace(myS);
FindEdge(myFace);
}
else {
FindEdge(myS);
}
}
//=======================================================================
//function : FindEdge
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::FindEdge(const TopoDS_Shape& S)
{
myEdge.Nullify();
Standard_Boolean isavls = HasAvLS();
Standard_Boolean isavs = (! myAvS.IsNull());
if (S.IsNull()) return;
TopAbs_ShapeEnum tS = S.ShapeType();
TopExp_Explorer eex;
if ( ! myFace.IsNull() ) eex.Init(myFace,TopAbs_EDGE);
else eex.Init(S,TopAbs_EDGE);
for(; eex.More(); eex.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(eex.Current());
Standard_Boolean toavoid = Standard_False;
if ( isavls || isavs ) {
toavoid = toavoid || myMapAvS.Contains(E);
if (!myAvS.IsNull()) toavoid = toavoid || E.IsSame(myAvS);
}
else if ( BRep_Tool::Degenerated(E) ) toavoid = ( tS != TopAbs_EDGE );
if ( toavoid ) continue;
myEdge = E;
break;
}
}
//=======================================================================
//function : FindFace
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::FindFace(const TopoDS_Shape& S)
{
myFace.Nullify();
Standard_Boolean isavls = HasAvLS();
Standard_Boolean isavs = (! myAvS.IsNull());
TopExp_Explorer fex(S,TopAbs_FACE);
for (; fex.More(); fex.Next()) {
const TopoDS_Face& F = TopoDS::Face(fex.Current());
Standard_Boolean toavoid = Standard_False;
if ( isavls || isavs ) {
toavoid = toavoid || myMapAvS.Contains(F);
if (!myAvS.IsNull()) toavoid = toavoid || F.IsSame(myAvS);
}
if ( toavoid ) continue;
myFace = F;
break;
}
}
//=======================================================================
//function : Perform
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::Perform()
{
myState = TopAbs_UNKNOWN;
if (myS.IsNull()) return;
if (myRef.IsNull()) return;
if (!mymredone) {
MapRef();
}
if ( !myAvS.IsNull() ) {
// tAvS = FACE,EDGE --> map(AvS,EDGE)
// rejet des aretes de myAvS comme arete de classification
// (le rejet simple de myAvS est insuffisant (connexite))
myMapAvS.Clear();
TopAbs_ShapeEnum tAvS = myAvS.ShapeType();
if ( tAvS == TopAbs_FACE ) {
myMapAvS.Add(myAvS);
TopExp::MapShapes(myAvS,TopAbs_EDGE,myMapAvS);
}
else if ( tAvS == TopAbs_EDGE ) {
TopExp::MapShapes(myAvS,TopAbs_EDGE,myMapAvS);
}
}
else if ( HasAvLS() ) {
// tAvS = FACE,EDGE --> map(AvS,EDGE)
// rejet des aretes de myPAvLS comme arete de classification
// (le rejet simple de myPAvLS est insuffisant (connexite))
myMapAvS.Clear();
TopAbs_ShapeEnum tAvS = myPAvLS->First().ShapeType();
if ( tAvS == TopAbs_FACE ) {
TopTools_ListIteratorOfListOfShape it((*myPAvLS));
for (; it.More(); it.Next() ) {
const TopoDS_Shape& S = it.Value();
myMapAvS.Add(S);
TopExp::MapShapes(S,TopAbs_EDGE,myMapAvS);
}
}
else if ( tAvS == TopAbs_EDGE ) {
TopTools_ListIteratorOfListOfShape it((*myPAvLS));
for (; it.More(); it.Next() ) {
const TopoDS_Shape& S = it.Value();
TopExp::MapShapes(S,TopAbs_EDGE,myMapAvS);
}
}
}
else {
if ( myS.ShapeType() == TopAbs_FACE ) {
myP3Ddef = BRepClass3d_SolidExplorer::FindAPointInTheFace
(TopoDS::Face(myS),myP3D);
}
}
TopAbs_ShapeEnum tS = myS.ShapeType();
TopAbs_ShapeEnum tR = myRef.ShapeType();
if ( tS == TopAbs_VERTEX ) {
if ( tR <= TopAbs_SOLID ) {
gp_Pnt P3D = BRep_Tool::Pnt(TopoDS::Vertex(myS));
StateP3DReference(P3D);
}
}
else if ( tS == TopAbs_EDGE ) {
if ( tR == TopAbs_FACE || tR <= TopAbs_SOLID ) {
FindEdge();
StateEdgeReference();
}
}
else if ( tS == TopAbs_WIRE ) {
if ( tR == TopAbs_FACE || tR <= TopAbs_SOLID ) {
FindEdge();
StateEdgeReference();
}
}
else if ( tS == TopAbs_FACE ) {
if ( tR == TopAbs_FACE ) {
FindEdge();
if ( mySameDomain == 1 ) {
StateEdgeReference();
}
else {
if (!myP3Ddef) {
myP3Ddef = BRepClass3d_SolidExplorer::FindAPointInTheFace
(TopoDS::Face(myS),myP3D);
}
if (myP3Ddef) {
StateP3DReference(myP3D);
}
else {
myState = TopAbs_UNKNOWN;
Standard_ProgramError::Raise("TopOpeBRepTool_ShapeClassifier !P3Ddef");
}
}
}
else if ( tR <= TopAbs_SOLID ) {
FindEdge();
if (myP3Ddef) {
StateP3DReference(myP3D);
}
else {
StateEdgeReference();
}
}
}
else if ( tS == TopAbs_SHELL ) {
if ( tR <= TopAbs_SOLID ) {
FindEdge();
StateEdgeReference();
}
}
else if ( tS == TopAbs_SOLID ) {
if ( tR <= TopAbs_SOLID ) {
FindEdge();
StateEdgeReference();
}
}
else {
Standard_ProgramError::Raise("StateShapeShape : bad operands");
}
// take orientation of reference shape in account
TopAbs_Orientation oriRef = myRef.Orientation();
if (oriRef == TopAbs_EXTERNAL || oriRef == TopAbs_INTERNAL ) {
if (myState == TopAbs_IN) myState = TopAbs_OUT;
}
}
//=======================================================================
//function : StateEdgeReference
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::StateEdgeReference()
{
myState = TopAbs_UNKNOWN;
if(myEdge.IsNull())
return;
if(myRef.IsNull())
return;
Handle(Geom_Curve) C3D;
gp_Pnt P3D;
Standard_Real f3d,l3d;
Handle(Geom2d_Curve) C2D;
gp_Pnt2d P2D;
Standard_Real f2d,l2d,tol2d;
TopAbs_ShapeEnum tR = myRef.ShapeType();
// myEdge est une arete de myS, pas de myRef
if( tR == TopAbs_FACE )
{
const TopoDS_Face& F = TopoDS::Face(myRef);
if(mySameDomain)
{
Standard_Boolean trimCurve = Standard_True;
C2D = FC2D_CurveOnSurface(myEdge,F,f2d,l2d,tol2d,trimCurve);
if(C2D.IsNull())
Standard_ProgramError::Raise("StateShapeShape : no 2d curve");
Standard_Real t = 0.127956477;
Standard_Real p = (1-t)*f2d + t*l2d;
P2D = C2D->Value(p);
#ifdef DEB
C3D = BRep_Tool::Curve(myEdge,f3d,l3d);
if(!C3D.IsNull())
P3D = C3D->Value(p);
#endif
StateP2DReference(P2D);
return;
}
else
{ // myEdge/myRef=face en 3d
C3D = BRep_Tool::Curve(myEdge,f3d,l3d);
if(C3D.IsNull())
Standard_ProgramError::Raise("StateShapeShape : no 3d curve");
Standard_Real t = 0.127956477;
Standard_Real p = (1-t)*f3d + t*l3d;
P3D = C3D->Value(p);
StateP3DReference(P3D);
return;
}
}
else if( tR <= TopAbs_SOLID )
{
Standard_Boolean degen = BRep_Tool::Degenerated(myEdge);
if( degen )
{
const TopoDS_Vertex& v = TopExp::FirstVertex(myEdge);
P3D = BRep_Tool::Pnt(v);
StateP3DReference(P3D);
return;
}
else
{
C3D = BRep_Tool::Curve(myEdge,f3d,l3d);
if (C3D.IsNull())
Standard_ProgramError::Raise("StateShapeShape : no 3d curve");
Standard_Real t = 0.127956477;
Standard_Real p = (1-t)*f3d + t*l3d;
P3D = C3D->Value(p);
StateP3DReference(P3D);
return;
}
}
else
Standard_ProgramError::Raise("StateShapeShape : bad operands");
}
//=======================================================================
//function : StateP2DReference
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::StateP2DReference
(const gp_Pnt2d& P2D)
{
myState = TopAbs_UNKNOWN;
if (myRef.IsNull()) return;
TopAbs_ShapeEnum tR = myRef.ShapeType();
if ( tR == TopAbs_FACE ) {
if (mymren == 1) {
TopExp_Explorer x;
for(x.Init(myRef,TopAbs_EDGE);x.More();x.Next()) {
// for(TopExp_Explorer x(myRef,TopAbs_EDGE);x.More();x.Next()) {
TopAbs_Orientation o = x.Current().Orientation();
// if (o == TopAbs_EXTERNAL) myState == TopAbs_OUT;
if (o == TopAbs_EXTERNAL) myState = TopAbs_OUT;
// else if (o == TopAbs_INTERNAL) myState == TopAbs_IN;
else if (o == TopAbs_INTERNAL) myState = TopAbs_IN;
else {
#ifdef DEB
cout<<"StateP2DReference o<>E,I"<<endl;
#endif
break;
}
}
}
else {
myP2D = P2D;
myP2Ddef = Standard_True;
TopoDS_Face F = TopoDS::Face(myRef);
F.Orientation(TopAbs_FORWARD);
#ifdef DEB
Standard_Real tol2d =
#endif
Precision::PConfusion();
Standard_Real TolClass = 1e-8;
BRepTopAdaptor_FClass2d FClass2d(F,TolClass);
myState = FClass2d.Perform(P2D);
}
}
else {
Standard_ProgramError::Raise("StateShapeShape : bad operands");
}
}
//=======================================================================
//function : StateP3DReference
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::StateP3DReference(const gp_Pnt& P3D)
{
myState = TopAbs_UNKNOWN;
if (myRef.IsNull()) return;
TopAbs_ShapeEnum tR = myRef.ShapeType();
if ( tR == TopAbs_SOLID ) {
myP3D = P3D;
myP3Ddef = Standard_True;
const TopoDS_Solid& SO = TopoDS::Solid(myRef);
Standard_Real tol3d = Precision::Confusion();
mySolidClassifier.Classify(SO,P3D,tol3d);
myState = mySolidClassifier.State();
}
else if ( tR < TopAbs_SOLID ) {
myP3D = P3D;
myP3Ddef = Standard_True;
TopExp_Explorer ex;
for (ex.Init(myRef,TopAbs_SOLID);ex.More();ex.Next()) {
// for (TopExp_Explorer ex(myRef,TopAbs_SOLID);ex.More();ex.Next()) {
const TopoDS_Solid& SO = TopoDS::Solid(ex.Current());
Standard_Real tol3d = Precision::Confusion();
mySolidClassifier.Classify(SO,P3D,tol3d);
myState = mySolidClassifier.State();
if (myState == TopAbs_IN || myState == TopAbs_ON) {
break;
}
}
}
else {
Standard_ProgramError::Raise("StateShapeShape : bad operands");
}
}
//=======================================================================
//function : State
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_ShapeClassifier::State() const
{
return myState;
}
//=======================================================================
//function : P3D
//purpose :
//=======================================================================
const gp_Pnt& TopOpeBRepTool_ShapeClassifier::P3D() const
{
if (myP3Ddef) {
return myP3D;
}
Standard_ProgramError::Raise("ShapeClassifier::P3D undefined");
return myP3D;
}
//=======================================================================
//function : P2D
//purpose :
//=======================================================================
const gp_Pnt2d& TopOpeBRepTool_ShapeClassifier::P2D() const
{
if (myP2Ddef) {
return myP2D;
}
Standard_ProgramError::Raise("ShapeClassifier::P2D undefined");
return myP2D;
}
//=======================================================================
//function : HasAvLS
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeClassifier::HasAvLS() const
{
Standard_Boolean hasavls = (myPAvLS) ? (!myPAvLS->IsEmpty()) : Standard_False;
return hasavls;
}
#if 0
//=======================================================================
//function : FindEdge
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeClassifier::FindEdge(const TopoDS_Shape& S)
{
myEdge.Nullify();
Standard_Boolean isavs = (! myAvS.IsNull());
Standard_Boolean isavls = HasAvLS();
Standard_Boolean isav = (isavs || isavls);
if (S.IsNull()) return;
TopAbs_ShapeEnum tS = S.ShapeType();
TopExp_Explorer eex;
if ( ! myFace.IsNull() ) eex.Init(myFace,TopAbs_EDGE);
else eex.Init(S,TopAbs_EDGE);
for(; eex.More(); eex.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(eex.Current());
if ( isav ) {
Standard_Boolean toavoid = Standard_False;
if ( isavls ) toavoid = myMapAvS.Contains(E);
else if ( isavs ) toavoid = E.IsSame(myAvS);
if ( toavoid ) continue;
}
else if ( BRep_Tool::Degenerated(E) ) {
if ( tS != TopAbs_EDGE ) continue;
}
myEdge = E;
break;
}
}
static Standard_Boolean FindAPointInTheFace
(const TopoDS_Face& _face,gp_Pnt& APoint,Standard_Real& u,Standard_Real& v)
{
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 nbiter=0;
Standard_Real myParamOnEdge = 0.5;
do {
nbiter++;
if(myParamOnEdge==0.5) 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; }
for (faceexplorer.Init(face,TopAbs_EDGE);
faceexplorer.More();
faceexplorer.Next()) {
TopoDS_Edge Edge = TopoDS::Edge(faceexplorer.Current());
c.Initialize(Edge,face);
Standard_Integer nbinterval = c.NbIntervals(GeomAbs_C1);
c.D1((c.LastParameter() - c.FirstParameter()) * myParamOnEdge + c.FirstParameter(),P,T);
Standard_Real x=T.X();
Standard_Real y=T.Y();
//-- cout<<"Param:"<<(c.IntervalFirst() + c.IntervalLast()) * param<<" U:"<<P.X()<<" V:"<<P.Y();
//-- cout<<" tguv x:"<<x<<" , y:"<<y<<endl;
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;
for (otherfaceexplorer.Init(face,TopAbs_EDGE);
otherfaceexplorer.More();
otherfaceexplorer.Next()) {
TopoDS_Edge OtherEdge = TopoDS::Edge(otherfaceexplorer.Current());
if((OtherEdge.Orientation() == TopAbs_EXTERNAL)) {
}
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;
}
}
}
}
if(APointExist) {
ParamInit*=0.5;
u = P.X() + ParamInit* T.X();
v = P.Y() + ParamInit* T.Y();
BRepAdaptor_Surface s;
Standard_Boolean computerestriction = Standard_False;
s.Initialize(face,computerestriction);
s.D0(u,v,APoint);
//-- cout<<" u="<<u<<" v="<<v<<" -> ("<<APoint.X()<<","<<APoint.Y()<<","<<APoint.Z()<<endl;
return(Standard_True);
}
}
}
while(nbiter<100);
return(Standard_False);
}
#endif

View File

@@ -0,0 +1,69 @@
-- File: TopOpeBRepTool_ShapeExplorer.cdl
-- Created: Thu Jul 13 17:17:04 1995
-- Author: Jean Yves LEBEY
-- <jyl@meteox>
---Copyright: Matra Datavision 1995
class ShapeExplorer from TopOpeBRepTool
uses
Explorer from TopExp,
ShapeEnum from TopAbs,
Shape from TopoDS
is
Create returns ShapeExplorer from TopOpeBRepTool;
---Purpose: Creates an empty explorer, becomes usefull after Init.
Create(S : Shape from TopoDS;
ToFind : ShapeEnum from TopAbs;
ToAvoid : ShapeEnum from TopAbs = TopAbs_SHAPE)
returns ShapeExplorer from TopOpeBRepTool;
---Purpose: Creates an Explorer on the Shape <S>.
--
-- <ToFind> is the type of shapes to search.
-- TopAbs_VERTEX, TopAbs_EDGE, ...
--
-- <ToAvoid> is the type of shape to skip in the
-- exploration. If <ToAvoid> is equal or less
-- complex than <ToFind> or if <ToAVoid> is SHAPE it
-- has no effect on the exploration.
--
Init(me : in out; S : Shape from TopoDS;
ToFind : ShapeEnum from TopAbs;
ToAvoid : ShapeEnum from TopAbs = TopAbs_SHAPE)
is static;
More(me) returns Boolean
---Purpose: Returns True if there are more shapes in the
-- exploration.
is static;
Next(me : in out)
---Purpose: Moves to the next Shape in the exploration.
is static;
Current(me) returns Shape from TopoDS
---Purpose: Returns the current shape in the exploration.
---C++: return const &
is static;
-- debug
NbShapes(me) returns Integer from Standard is static;
Index(me) returns Integer from Standard is static;
DumpCurrent(me; OS : in out OStream) returns OStream
---C++: return &
is static;
fields
myExplorer : Explorer from TopExp;
myIndex : Integer from Standard;
myNbShapes : Integer from Standard;
end ShapeExplorer from TopOpeBRepTool;

View File

@@ -0,0 +1,143 @@
// File: TopOpeBRepTool_ShapeExplorer.cxx
// Created: Thu Jul 13 17:26:39 1995
// Author: Jean Yves LEBEY
// <jyl@meteox>
#include <TopOpeBRepTool_ShapeExplorer.ixx>
#include <TopAbs.hxx>
#include <Standard_NoMoreObject.hxx>
#include <Standard_NoSuchObject.hxx>
//=======================================================================
//function : TopOpeBRepTool_ShapeExplorer
//purpose :
//=======================================================================
TopOpeBRepTool_ShapeExplorer::TopOpeBRepTool_ShapeExplorer() :
myIndex(0),
myNbShapes(0)
{
}
//=======================================================================
//function : TopOpeBRepTool_ShapeExplorer
//purpose :
//=======================================================================
TopOpeBRepTool_ShapeExplorer::TopOpeBRepTool_ShapeExplorer
(const TopoDS_Shape& S,
const TopAbs_ShapeEnum ToFind,
const TopAbs_ShapeEnum ToAvoid)
{
Init(S,ToFind,ToAvoid);
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeExplorer::Init(const TopoDS_Shape& S,
const TopAbs_ShapeEnum ToFind,
const TopAbs_ShapeEnum ToAvoid)
{
myExplorer.Init(S,ToFind,ToAvoid);
#ifdef DEB
myIndex = myNbShapes = 0;
for (;More();Next()) myNbShapes++;
myExplorer.ReInit();
if (More()) myIndex = 1;
#endif
}
//=======================================================================
//function : More
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeExplorer::More()const
{
Standard_Boolean b = myExplorer.More();
return b;
}
//=======================================================================
//function : Next
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeExplorer::Next()
{
myExplorer.Next();
#ifdef DEB
myIndex++;
#endif
}
//=======================================================================
//function : Current
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepTool_ShapeExplorer::Current()const
{
const TopoDS_Shape& S = myExplorer.Current();
return S;
}
//=======================================================================
//function : NbShapes
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_ShapeExplorer::NbShapes()const
{
Standard_Integer n = 0;
#ifdef DEB
n = myNbShapes;
#endif
return n;
}
//=======================================================================
//function : Index
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_ShapeExplorer::Index()const
{
Standard_Integer n = 0;
#ifdef DEB
n = myIndex;
#endif
return n;
}
//=======================================================================
//function : DumpCurrent
//purpose :
//=======================================================================
Standard_OStream& TopOpeBRepTool_ShapeExplorer::DumpCurrent
(Standard_OStream& OS)const
{
#ifdef DEB
if ( More() ) {
const TopoDS_Shape& S = Current();
TopAbs_ShapeEnum T = S.ShapeType();
TopAbs_Orientation O = S.Orientation();
Standard_Integer I = Index();
TopAbs::Print(T,cout);
cout<<"("<<I<<","; TopAbs::Print(O,cout); cout<<") ";
}
#endif
return OS;
}

View File

@@ -0,0 +1,115 @@
-- File: TopOpeBRepTool_ShapeTool.cdl
-- Created: Wed Feb 9 16:13:19 1994
-- Author: Jean Yves LEBEY
-- <jyl@phobox>
---Copyright: Matra Datavision 1994
class ShapeTool from TopOpeBRepTool
-- as TopOpeInter_ShapeTooltemp(Shape from TopoDS)
-- as TopOpeBRepDS_ShapeTooltemp(Shape from TopoDS)
uses
Shape from TopoDS,
Face from TopoDS,
Edge from TopoDS,
Pnt from gp,
Curve from Geom,
Surface from Geom,
Surface from BRepAdaptor,
Curve from BRepAdaptor,
Dir from gp
is
Tolerance(myclass; S : Shape from TopoDS )
---Purpose: Returns the tolerance of the shape <S>.
-- If the shape <S> is Null, returns 0.
returns Real from Standard;
Pnt(myclass; S : Shape from TopoDS )
---Purpose: Returns 3D point of vertex <S>.
returns Pnt from gp;
BASISCURVE(myclass; C : Curve from Geom)
returns Curve from Geom;
BASISCURVE(myclass; E : Edge from TopoDS)
returns Curve from Geom;
BASISSURFACE(myclass; S : Surface from Geom)
returns Surface from Geom;
BASISSURFACE(myclass; F : Face from TopoDS)
returns Surface from Geom;
UVBOUNDS(myclass; S : Surface from Geom;
UPeri, VPeri : in out Boolean from Standard;
Umin, Umax, Vmin, Vmax : in out Real from Standard);
UVBOUNDS(myclass; F : Face from TopoDS;
UPeri, VPeri : in out Boolean from Standard;
Umin, Umax, Vmin, Vmax : in out Real from Standard);
AdjustOnPeriodic(myclass; S : Shape from TopoDS;
u,v : in out Real from Standard);
---Purpose: ajust u,v values in UVBounds of the domain of the
-- geometric shape <S>, according to Uperiodicity and
-- VPeriodicity of the domain.
-- <S> is assumed to be a face.
-- u and/or v is/are not modified when the domain is
-- not periodic in U and/or V .
Closed(myclass; S1,S2 : Shape from TopoDS)
---Purpose: indicates wheter shape S1 is a closing shape on S2 or not.
returns Boolean from Standard;
PeriodizeParameter(myclass;
par : Real from Standard;
EE,FF : Shape from TopoDS)
returns Real from Standard;
ShapesSameOriented(myclass; S1,S2 : Shape from TopoDS)
returns Boolean from Standard;
SurfacesSameOriented(myclass; S1,S2 : Surface from BRepAdaptor)
returns Boolean from Standard;
FacesSameOriented(myclass; F1,F2 : Shape from TopoDS)
returns Boolean from Standard;
CurvesSameOriented(myclass; C1,C2 : Curve from BRepAdaptor)
returns Boolean from Standard;
EdgesSameOriented(myclass; E1,E2 : Shape from TopoDS)
returns Boolean from Standard;
EdgeData(myclass; BRAC : Curve from BRepAdaptor; P : Real from Standard;
T,N : out Dir from gp; -- tangent, normal
C : out Real from Standard) -- curvature
---Purpose :
-- Compute tangent T, normal N, curvature C at point of parameter
-- P on curve BRAC. Returns the tolerance indicating if T,N are null.
returns Real from Standard;
EdgeData(myclass; E : Shape from TopoDS; P : Real from Standard;
T,N : out Dir from gp; -- tangent, normal
C : out Real from Standard) -- curvature
---Purpose : Same as previous on edge E.
returns Real from Standard;
Resolution3dU(myclass; SU:Surface from Geom; Tol2d : Real from Standard)
returns Real from Standard;
Resolution3dV(myclass; SU:Surface from Geom; Tol2d : Real from Standard)
returns Real from Standard;
Resolution3d(myclass; SU:Surface from Geom; Tol2d : Real from Standard)
returns Real from Standard;
Resolution3d(myclass; F:Face from TopoDS; Tol2d : Real from Standard)
returns Real from Standard;
end ShapeTool from TopOpeBRepTool;

View File

@@ -0,0 +1,643 @@
// File: TopOpeBRepTool_ShapeTool.cxx
// Created: Wed Feb 9 16:24:57 1994
// Author: Jean Yves LEBEY
// <jyl@phobox>
#include <TopOpeBRepTool_ShapeTool.ixx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <ElCLib.hxx>
#include <Geom_Surface.hxx>
#include <TopLoc_Location.hxx>
#include <Precision.hxx>
#include <Standard_ProgramError.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS.hxx>
#include <gp_Dir2d.hxx>
#include <Geom2d_Line.hxx>
#include <BRepTools.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepLProp_CLProps.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_2d.hxx>
//=======================================================================
//function : Tolerance
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::Tolerance(const TopoDS_Shape& S)
{
if ( S.IsNull() ) return 0. ;
Standard_Real tol=0;
switch (S.ShapeType()) {
case TopAbs_FACE : tol = BRep_Tool::Tolerance(TopoDS::Face(S)); break;
case TopAbs_EDGE : tol = BRep_Tool::Tolerance(TopoDS::Edge(S)); break;
case TopAbs_VERTEX : tol = BRep_Tool::Tolerance(TopoDS::Vertex(S)); break;
default : Standard_ProgramError::Raise
("TopOpeBRepTool_ShapeTool : Shape has no tolerance"); break;
}
return tol;
}
//=======================================================================
//function : Pnt
//purpose :
//=======================================================================
gp_Pnt TopOpeBRepTool_ShapeTool::Pnt(const TopoDS_Shape& S)
{
if ( S.ShapeType() != TopAbs_VERTEX ) {
Standard_ProgramError::Raise("TopOpeBRepTool_ShapeTool::Pnt");
return gp_Pnt();
}
return BRep_Tool::Pnt(TopoDS::Vertex(S));
}
#include <Geom_OffsetCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
//=======================================================================
//function : BASISCURVE
//purpose :
//=======================================================================
Handle(Geom_Curve) TopOpeBRepTool_ShapeTool::BASISCURVE(const Handle(Geom_Curve)& C)
{
Handle(Standard_Type) T = C->DynamicType();
if ( T == STANDARD_TYPE(Geom_OffsetCurve) )
return BASISCURVE(Handle(Geom_OffsetCurve)::DownCast(C)->BasisCurve());
else if ( T == STANDARD_TYPE(Geom_TrimmedCurve) )
return BASISCURVE(Handle(Geom_TrimmedCurve)::DownCast(C)->BasisCurve());
else return C;
}
Handle(Geom_Curve) TopOpeBRepTool_ShapeTool::BASISCURVE(const TopoDS_Edge& E)
{
Standard_Real f, l;
Handle(Geom_Curve) C = BRep_Tool::Curve(E, f, l);
if ( C.IsNull() ) return C;
return BASISCURVE(C);
}
#include <Geom_OffsetSurface.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_SurfaceOfRevolution.hxx>
#include <Geom_SurfaceOfLinearExtrusion.hxx>
//=======================================================================
//function : BASISSURFACE
//purpose :
//=======================================================================
Handle(Geom_Surface) TopOpeBRepTool_ShapeTool::BASISSURFACE(const Handle(Geom_Surface)& S)
{
Handle(Standard_Type) T = S->DynamicType();
if ( T == STANDARD_TYPE(Geom_OffsetSurface) )
return BASISSURFACE(Handle(Geom_OffsetSurface)::DownCast(S)->BasisSurface());
else if ( T == STANDARD_TYPE(Geom_RectangularTrimmedSurface) )
return BASISSURFACE(Handle(Geom_RectangularTrimmedSurface)::DownCast(S)->BasisSurface());
else return S;
}
Handle(Geom_Surface) TopOpeBRepTool_ShapeTool::BASISSURFACE(const TopoDS_Face& F)
{
TopLoc_Location L;Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
return BASISSURFACE(S);
}
//=======================================================================
//function : UVBOUNDS
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeTool::UVBOUNDS
(const Handle(Geom_Surface)& S,
Standard_Boolean& UPeriodic,
Standard_Boolean& VPeriodic,
Standard_Real& Umin, Standard_Real& Umax,
Standard_Real& Vmin, Standard_Real& Vmax)
{
const Handle(Geom_Surface) BS = BASISSURFACE(S);
Handle(Standard_Type) T = BS->DynamicType();
if ( T == STANDARD_TYPE(Geom_SurfaceOfRevolution) ) {
Handle(Geom_SurfaceOfRevolution)
SR = Handle(Geom_SurfaceOfRevolution)::DownCast(BS);
Handle(Geom_Curve) C = BASISCURVE(SR->BasisCurve());
if (C->IsPeriodic()) {
UPeriodic = Standard_False;
VPeriodic = Standard_True;
Vmin = C->FirstParameter(); Vmax = C->LastParameter();
}
}
else if ( T == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion) ) {
Handle(Geom_SurfaceOfLinearExtrusion)
SE = Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(BS);
Handle(Geom_Curve) C = BASISCURVE(SE->BasisCurve());
if (C->IsPeriodic()) {
UPeriodic = Standard_True;
Umin = C->FirstParameter(); Umax = C->LastParameter();
VPeriodic = Standard_False;
}
}
else {
UPeriodic = BS->IsUPeriodic();
VPeriodic = BS->IsVPeriodic();
BS->Bounds(Umin,Umax,Vmin,Vmax);
}
}
void TopOpeBRepTool_ShapeTool::UVBOUNDS
(const TopoDS_Face& F,
Standard_Boolean& UPeriodic, Standard_Boolean& VPeriodic,
Standard_Real& Umin, Standard_Real& Umax,
Standard_Real& Vmin, Standard_Real& Vmax)
{
TopLoc_Location L;Handle(Geom_Surface) S = BRep_Tool::Surface(F,L);
UVBOUNDS(S, UPeriodic, VPeriodic, Umin, Umax, Vmin, Vmax);
}
//=======================================================================
//function : AdjustOnPeriodic
//purpose :
//=======================================================================
void TopOpeBRepTool_ShapeTool::AdjustOnPeriodic(const TopoDS_Shape& F,
Standard_Real& u,
Standard_Real& v)
{
TopoDS_Face FF = TopoDS::Face(F);
TopLoc_Location Loc;
const Handle(Geom_Surface) Surf = BRep_Tool::Surface(FF,Loc);
// Standard_Real Ufirst,Ulast,Vfirst,Vlast;
Standard_Boolean isUperio,isVperio;
isUperio = Surf->IsUPeriodic();
isVperio = Surf->IsVPeriodic();
// exit if surface supporting F is not periodic on U or V
if (!isUperio && !isVperio) return;
Standard_Real UFfirst,UFlast,VFfirst,VFlast;
BRepTools::UVBounds(FF,UFfirst,UFlast,VFfirst,VFlast);
Standard_Real tol = Precision::PConfusion();
if (isUperio) {
Standard_Real Uperiod = Surf->UPeriod();
#ifdef DEB
Standard_Real ubid = UFfirst;
#endif
// ElCLib::AdjustPeriodic(UFfirst,UFfirst + Uperiod,tol,ubid,u);
if (Abs(u - UFfirst-Uperiod) > tol)
u = ElCLib::InPeriod(u,UFfirst,UFfirst + Uperiod);
}
if (isVperio) {
Standard_Real Vperiod = Surf->VPeriod();
#ifdef DEB
Standard_Real vbid = VFfirst;
#endif
// ElCLib::AdjustPeriodic(VFfirst,VFfirst + Vperiod,tol,vbid,v);
if (Abs(v - VFfirst-Vperiod) > tol)
v = ElCLib::InPeriod(v,VFfirst,VFfirst + Vperiod);
}
}
//=======================================================================
//function : Closed
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeTool::Closed(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
{
const TopoDS_Edge& E = TopoDS::Edge(S1);
const TopoDS_Face& F = TopoDS::Face(S2);
Standard_Boolean brepclosed = BRep_Tool::IsClosed(E,F);
if ( brepclosed ) {
Standard_Integer n = 0;
for ( TopExp_Explorer x(F,TopAbs_EDGE); x.More(); x.Next() )
if ( x.Current().IsSame(E) ) n++;
if ( n < 2 ) return Standard_False;
else return Standard_True;
}
return Standard_False;
}
#ifdef DEB
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceVC();
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettraceNYI();
#endif
inline Standard_Boolean PARINBOUNDS(const Standard_Real par,
const Standard_Real first,
const Standard_Real last,
const Standard_Real tol)
{
Standard_Boolean b = ( ((first+tol) <= par) && (par <= (last-tol)) );
return b;
}
inline Standard_Boolean PARONBOUND(const Standard_Real par,
const Standard_Real bound,
const Standard_Real tol)
{
Standard_Boolean b = ( ((bound-tol) <= par) && (par <= (bound+tol)) );
return b;
}
Standard_Real ADJUST(const Standard_Real par,
const Standard_Real first,
const Standard_Real last,
const Standard_Real tol)
{
Standard_Real period = last - first, periopar = par;
if (PARINBOUNDS(par,first,last,tol)) {
periopar = par + period;
}
else if (PARONBOUND(par,first,tol)) {
periopar = par + period;
}
else if (PARONBOUND(par,last,tol)) {
periopar = par - period;
}
return periopar;
}
//=======================================================================
//function : PeriodizeParameter
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::PeriodizeParameter
(const Standard_Real par,
const TopoDS_Shape& EE,
const TopoDS_Shape& FF)
{
Standard_Real periopar = par;
if ( ! TopOpeBRepTool_ShapeTool::Closed(EE,FF) ) return periopar;
TopoDS_Edge E = TopoDS::Edge(EE);
TopoDS_Face F = TopoDS::Face(FF);
TopLoc_Location Loc;
const Handle(Geom_Surface) Surf = BRep_Tool::Surface(F,Loc);
Standard_Boolean isUperio = Surf->IsUPeriodic();
Standard_Boolean isVperio = Surf->IsVPeriodic();
if (!isUperio && !isVperio) return periopar;
Standard_Real Ufirst,Ulast,Vfirst,Vlast;
Surf->Bounds(Ufirst,Ulast,Vfirst,Vlast);
Standard_Real Uperiod = 0., Vperiod = 0.;
if (isUperio) Uperiod = Ulast - Ufirst;
if (isVperio) Vperiod = Vlast - Vfirst;
Standard_Real first,last,tolpc;
const Handle(Geom2d_Curve) PC = FC2D_CurveOnSurface(E,F,first,last,tolpc);
if (PC.IsNull()) Standard_ProgramError::Raise("ShapeTool::PeriodizeParameter : no 2d curve");
Handle(Standard_Type) TheType = PC->DynamicType();
if (TheType == STANDARD_TYPE(Geom2d_Line)) {
const Handle(Geom2d_Line)& HL = *((Handle(Geom2d_Line)*)&PC);
const gp_Dir2d& D = HL->Direction();
Standard_Real tol = Precision::Angular();
Standard_Boolean isoU = Standard_False, isoV = Standard_False;
if (D.IsParallel(gp_Dir2d(0.,1.),tol)) isoU = Standard_True;
else if (D.IsParallel(gp_Dir2d(1.,0.),tol)) isoV = Standard_True;
if (isoU) {
periopar = ADJUST(par,Ufirst,Ulast,tol);
}
else if (isoV) {
periopar = ADJUST(par,Vfirst,Vlast,tol);
}
#ifdef DEB
if (TopOpeBRepTool_GettraceVC()) {
cout<<"TopOpeBRepTool_ShapeTool PC on edge is ";
if (isoU) cout<<"isoU f,l "<<Ufirst<<" "<<Ulast<<endl;
else if (isoV) cout<<"isoV f,l "<<Vfirst<<" "<<Vlast<<endl;
else cout<<"not isoU, not isoV"<<endl;
cout<<"par = "<<par<<" --> "<<periopar<<endl;
}
#endif
}
// NYI : BSpline ...
return periopar;
}
//=======================================================================
//function : ShapesSameOriented
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeTool::ShapesSameOriented
(const TopoDS_Shape& S1, const TopoDS_Shape& S2)
{
Standard_Boolean so = Standard_True;
Standard_Boolean sam = S1.IsSame(S2);
if (sam) {
const TopAbs_Orientation o1 = S1.Orientation();
const TopAbs_Orientation o2 = S2.Orientation();
if ((o1 == TopAbs_FORWARD || o1 == TopAbs_REVERSED) &&
(o2 == TopAbs_FORWARD || o2 == TopAbs_REVERSED)) {
so = (o1 == o2);
return so;
}
}
TopAbs_ShapeEnum t1 = S1.ShapeType(), t2 = S2.ShapeType();
if ( (t1 == TopAbs_SOLID) && (t2 == TopAbs_SOLID) ) {
so = Standard_True;
}
else if ( (t1 == TopAbs_FACE) && (t2 == TopAbs_FACE) ) {
so = FacesSameOriented(S1,S2);
}
else if ( (t1 == TopAbs_EDGE) && (t2 == TopAbs_EDGE) ) {
so = EdgesSameOriented(S1,S2);
}
else if ( (t1 == TopAbs_VERTEX) && (t2 == TopAbs_VERTEX) ) {
TopAbs_Orientation o1 = S1.Orientation();
TopAbs_Orientation o2 = S2.Orientation();
if (o1==TopAbs_EXTERNAL||o1==TopAbs_INTERNAL||o2==TopAbs_EXTERNAL||o2==TopAbs_INTERNAL)
so = Standard_True;
else
so = ( o1 == o2 );
}
return so;
}
//=======================================================================
//function : SurfacesSameOriented
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeTool::SurfacesSameOriented
(const BRepAdaptor_Surface& S1,const BRepAdaptor_Surface& Sref)
{
const BRepAdaptor_Surface& S2 = Sref;
GeomAbs_SurfaceType ST1 = S1.GetType();
GeomAbs_SurfaceType ST2 = S2.GetType();
Standard_Boolean so = Standard_True;
if (ST1 == GeomAbs_Plane && ST2 == GeomAbs_Plane) {
Standard_Real u1 = S1.FirstUParameter();
Standard_Real v1 = S1.FirstVParameter();
gp_Pnt p1; gp_Vec d1u,d1v; S1.D1(u1,v1,p1,d1u,d1v);
gp_Vec n1 = d1u.Crossed(d1v);
Standard_Real u2 = S2.FirstUParameter();
Standard_Real v2 = S2.FirstVParameter();
gp_Pnt p2; gp_Vec d2u,d2v; S2.D1(u2,v2,p2,d2u,d2v);
gp_Vec n2 = d2u.Crossed(d2v);
Standard_Real d = n1.Dot(n2);
so = (d > 0.);
}
else if (ST1 == GeomAbs_Cylinder && ST2 == GeomAbs_Cylinder) {
// On peut projeter n'importe quel point.
// prenons donc l'origine
Standard_Real u1 = 0.;
Standard_Real v1 = 0.;
gp_Pnt p1; gp_Vec d1u,d1v; S1.D1(u1,v1,p1,d1u,d1v);
gp_Vec n1 = d1u.Crossed(d1v);
Handle(Geom_Surface) HS2 = S2.Surface().Surface();
HS2 = Handle(Geom_Surface)::DownCast(HS2->Transformed(S2.Trsf()));
gp_Pnt2d p22d; Standard_Real dp2;
Standard_Boolean ok = FUN_tool_projPonS(p1,HS2,p22d,dp2);
if ( !ok ) return so; // NYI : raise
Standard_Real u2 = p22d.X();
Standard_Real v2 = p22d.Y();
gp_Pnt p2; gp_Vec d2u,d2v; S2.D1(u2,v2,p2,d2u,d2v);
gp_Vec n2 = d2u.Crossed(d2v);
Standard_Real d = n1.Dot(n2);
so = (d > 0.);
}
else {
// prendre u1,v1 et projeter sur 2 pour calcul des normales
// au meme point 3d.
#ifdef DEB
if (TopOpeBRepTool_GettraceNYI()) {
cout<<"TopOpeBRepTool_ShapeTool::SurfacesSameOriented surfaces non traitees : NYI";
cout<<endl;
}
#endif
}
return so;
}
//=======================================================================
//function : FacesSameOriented
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeTool::FacesSameOriented
(const TopoDS_Shape& S1, const TopoDS_Shape& Sref)
{
const TopoDS_Shape& S2 = Sref;
const TopoDS_Face& F1 = TopoDS::Face(S1);
const TopoDS_Face& F2 = TopoDS::Face(S2);
TopAbs_Orientation o1 = F1.Orientation();
TopAbs_Orientation o2 = F2.Orientation();
if ( o1 == TopAbs_EXTERNAL || o1 == TopAbs_INTERNAL ||
o2 == TopAbs_EXTERNAL || o2 == TopAbs_INTERNAL ) {
return Standard_True;
}
Standard_Boolean computerestriction = Standard_False;
BRepAdaptor_Surface BAS1(F1,computerestriction);
BRepAdaptor_Surface BAS2(F2,computerestriction);
Standard_Boolean so = F1.IsSame(F2) || SurfacesSameOriented(BAS1,BAS2);
Standard_Boolean b = so;
if ( o1 != o2 ) b = !so;
return b;
}
//=======================================================================
//function : CurvesSameOriented
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeTool::CurvesSameOriented
(const BRepAdaptor_Curve& C1, const BRepAdaptor_Curve& Cref)
{
const BRepAdaptor_Curve& C2 = Cref;
GeomAbs_CurveType CT1 = C1.GetType();
GeomAbs_CurveType CT2 = C2.GetType();
Standard_Boolean so = Standard_True;
if (CT1 == GeomAbs_Line && CT2 == GeomAbs_Line) {
Standard_Real p1 = C1.FirstParameter();
gp_Dir t1,n1; Standard_Real c1; EdgeData(C1,p1,t1,n1,c1);
Standard_Real p2 = C2.FirstParameter();
gp_Dir t2,n2; Standard_Real c2; EdgeData(C2,p2,t2,n2,c2);
Standard_Real d = t1.Dot(t2);
so = (d > 0.);
}
else {
// prendre p1 et projeter sur 2 pour calcul des normales
// au meme point 3d.
#ifdef DEB
if (TopOpeBRepTool_GettraceNYI()) {
cout<<"TopOpeBRepTool_ShapeTool::CurvesSameOriented non lineaires : NYI";
cout<<endl;
}
#endif
}
return so;
}
//=======================================================================
//function : EdgesSameOriented
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_ShapeTool::EdgesSameOriented
(const TopoDS_Shape& S1, const TopoDS_Shape& Sref)
{
const TopoDS_Shape& S2 = Sref;
const TopoDS_Edge& E1 = TopoDS::Edge(S1);
const TopoDS_Edge& E2 = TopoDS::Edge(S2);
TopAbs_Orientation o1 = E1.Orientation();
TopAbs_Orientation o2 = E2.Orientation();
if ( o1 == TopAbs_EXTERNAL || o1 == TopAbs_INTERNAL ||
o2 == TopAbs_EXTERNAL || o2 == TopAbs_INTERNAL ) {
return Standard_True;
}
BRepAdaptor_Curve BAC1(E1);
BRepAdaptor_Curve BAC2(E2);
Standard_Boolean so = CurvesSameOriented(BAC1,BAC2);
Standard_Boolean b = so;
if ( o1 != o2 ) b = !so;
return b;
}
//=======================================================================
//function : EdgeData
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::EdgeData
(const BRepAdaptor_Curve& BAC, const Standard_Real P,
gp_Dir& T, gp_Dir& N, Standard_Real& C)
{
Standard_Real tol = Precision::Angular();
BRepLProp_CLProps BL(BAC,P,2,tol);
BL.Tangent(T);
C = BL.Curvature();
// xpu150399 cto900R4
Standard_Real tol1 = Epsilon(0.), tol2 = RealLast();
Standard_Real tolm = Max(tol,Max(tol1,tol2));
if ( Abs(C) > tolm ) BL.Normal(N);
return tol;
}
//=======================================================================
//function : EdgeData
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::EdgeData
(const TopoDS_Shape& E, const Standard_Real P,
gp_Dir& T, gp_Dir& N, Standard_Real& C)
{
BRepAdaptor_Curve BAC(TopoDS::Edge(E));
Standard_Real d = EdgeData(BAC,P,T,N,C);
return d;
}
//=======================================================================
//function : Resolution3dU
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::Resolution3dU(const Handle(Geom_Surface)& SU,
const Standard_Real Tol2d)
{
GeomAdaptor_Surface GAS(SU);
Standard_Real r3dunit = 0.00001; // petite valeur (1.0 -> RangeError sur un tore)
Standard_Real ru = GAS.UResolution(r3dunit);
Standard_Real r3du = r3dunit*(Tol2d/ru);
return r3du;
}
//=======================================================================
//function : Resolution3dV
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::Resolution3dV(const Handle(Geom_Surface)& SU,
const Standard_Real Tol2d)
{
GeomAdaptor_Surface GAS(SU);
Standard_Real r3dunit = 0.00001; // petite valeur (1.0 -> RangeError sur un tore)
Standard_Real rv = GAS.VResolution(r3dunit);
Standard_Real r3dv = r3dunit*(Tol2d/rv);
return r3dv;
}
//=======================================================================
//function : Resolution3d
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::Resolution3d(const Handle(Geom_Surface)& SU,
const Standard_Real Tol2d)
{
Standard_Real ru = Resolution3dU(SU,Tol2d);
Standard_Real rv = Resolution3dV(SU,Tol2d);
Standard_Real r = Max(ru,rv);
return r;
}
//=======================================================================
//function : Resolution3d
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_ShapeTool::Resolution3d(const TopoDS_Face& F,
const Standard_Real Tol2d)
{
TopLoc_Location L; const Handle(Geom_Surface)& SU = BRep_Tool::Surface(F,L);
Standard_Real r = Resolution3d(SU,Tol2d);
return r;
}

View File

@@ -0,0 +1,65 @@
-- File: TopOpeBRepTool_SolidClassifier.cdl
-- Created: Tue Aug 27 16:19:20 1996
-- Author: Jean Yves LEBEY
-- <jyl@bistrox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1996
class SolidClassifier from TopOpeBRepTool
uses
State from TopAbs,
Shell from TopoDS,
Solid from TopoDS,
Pnt from gp,
PSoClassif from TopOpeBRepTool,
--modified by NIZNHY-PKV Mon Dec 16 10:37:26 2002 f
-- IndexedDataMapOfSolidClassifier from TopOpeBRepTool,
IndexedDataMapOfShapeAddress from TopTools,
--modified by NIZNHY-PKV Mon Dec 16 10:37:30 2002 t
Builder from BRep
is
Create returns SolidClassifier from TopOpeBRepTool;
Clear(me : in out) is static;
--modified by NIZNHY-PKV Mon Dec 16 10:37:57 2002 f
Destroy(me: out);
---C++: alias "Standard_EXPORT ~TopOpeBRepTool_SolidClassifier() {Destroy();}"
--modified by NIZNHY-PKV Mon Dec 16 10:38:00 2002 t
LoadSolid(me : in out; S : Solid) is static;
Classify(me : in out; S : Solid; P : Pnt; Tol : Real)
---Purpose: compute the position of point <P> regarding with the
-- geometric domain of the solid <S>.
returns State from TopAbs
is static;
LoadShell(me : in out; S : Shell) is static;
Classify(me : in out; S : Shell; P : Pnt; Tol : Real)
---Purpose: compute the position of point <P> regarding with the
-- geometric domain of the shell <S>.
returns State from TopAbs
is static;
State(me) returns State from TopAbs
is static;
fields
myPClassifier : PSoClassif from TopOpeBRepTool; -- as BRepClass3d_SolidClassifier*
--modified by NIZNHY-PKV Mon Dec 16 10:59:22 2002 f
-- myClassifierMap : IndexedDataMapOfSolidClassifier from TopOpeBRepTool;
myShapeClassifierMap: IndexedDataMapOfShapeAddress from TopTools;
--modified by NIZNHY-PKV Mon Dec 16 10:59:28 2002 t
myState : State from TopAbs;
myShell : Shell from TopoDS;
mySolid : Solid from TopoDS;
myBuilder : Builder from BRep;
end SolidClassifier from TopOpeBRepTool;

View File

@@ -0,0 +1,200 @@
// File: TopOpeBRepTool_SolidClassifier.cxx
// Created: Tue Aug 27 16:28:52 1996
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_SolidClassifier.ixx>
#include <BRepClass3d_SolidClassifier.hxx>
//=======================================================================
//function : TopOpeBRepTool_SolidClassifier
//purpose :
//=======================================================================
TopOpeBRepTool_SolidClassifier::TopOpeBRepTool_SolidClassifier()
{
Clear();
}
//modified by NIZNHY-PKV Mon Dec 16 10:39:00 2002 f
//=======================================================================
//function : Destroy
//purpose : alias ~TopOpeBRepTool_SolidClassifier
//=======================================================================
void TopOpeBRepTool_SolidClassifier::Destroy()
{
Standard_Integer i, aNb;
aNb=myShapeClassifierMap.Extent();
for (i=1; i<=aNb; ++i) {
Standard_Address anAddr=myShapeClassifierMap(i);
BRepClass3d_SolidClassifier* pClsf=
(BRepClass3d_SolidClassifier*) anAddr;
delete pClsf;
}
myShapeClassifierMap.Clear();
}
//=======================================================================
//function : LoadSolid
//purpose :
//=======================================================================
void TopOpeBRepTool_SolidClassifier::LoadSolid(const TopoDS_Solid& SOL)
{
Standard_Boolean found = myShapeClassifierMap.Contains(SOL);
if ( !found ) {
myPClassifier = new BRepClass3d_SolidClassifier(SOL);
myShapeClassifierMap.Add(SOL, (Standard_Address)myPClassifier);
}
else {
myPClassifier =
(BRepClass3d_SolidClassifier*)myShapeClassifierMap.ChangeFromKey(SOL);
}
}
//=======================================================================
//function : LoadShell
//purpose :
//=======================================================================
void TopOpeBRepTool_SolidClassifier::LoadShell(const TopoDS_Shell& SHE)
{
Standard_Boolean found = myShapeClassifierMap.Contains(SHE);
if ( !found ) {
myBuilder.MakeSolid(mySolid);
myBuilder.Add(mySolid, SHE);
myPClassifier = new BRepClass3d_SolidClassifier(mySolid);
myShapeClassifierMap.Add(SHE, (Standard_Address)myPClassifier);
}
else {
myPClassifier =
(BRepClass3d_SolidClassifier*)myShapeClassifierMap.ChangeFromKey(SHE);
}
}
//modified by NIZNHY-PKV Mon Dec 16 10:53:41 2002 t
//=======================================================================
//function : Clear
//purpose :
//=======================================================================
void TopOpeBRepTool_SolidClassifier::Clear()
{
myPClassifier = NULL;
//modified by NIZNHY-PKV Mon Dec 16 10:46:04 2002 f
//myClassifierMap.Clear();
myShapeClassifierMap.Clear();
//modified by NIZNHY-PKV Mon Dec 16 10:46:06 2002 t
myState = TopAbs_UNKNOWN;
myShell.Nullify();
mySolid.Nullify();
}
//=======================================================================
//function : Classify
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_SolidClassifier::Classify (const TopoDS_Solid& SOL,
const gp_Pnt& P,
const Standard_Real Tol)
{
myPClassifier = NULL;
myState = TopAbs_UNKNOWN;
LoadSolid(SOL);
if (myPClassifier == NULL) return myState;
myPClassifier->Perform(P,Tol);
myState = myPClassifier->State();
const TopoDS_Shape& fres = myPClassifier->Face();
if (fres.IsNull()) {
// NYI : en cas d'elimination des faces EXTERNAL et INTERNAL par le
// classifier BRepClass3d_SolidClassifier, traiter quand meme ces faces
// pour generer l'etat ON/Solid quand le point est IN/face INTERNAL ou EXTERNAL
return myState;
}
TopAbs_Orientation ofres = fres.Orientation();
if ( ofres == TopAbs_EXTERNAL ) {
if ( myState == TopAbs_IN ) myState = TopAbs_OUT;
else if ( myState == TopAbs_OUT ) myState = TopAbs_OUT;
else if ( myState == TopAbs_ON ) myState = TopAbs_ON;
else if ( myState == TopAbs_UNKNOWN ) myState = TopAbs_OUT;
}
else if ( ofres == TopAbs_INTERNAL ) {
if ( myState == TopAbs_IN ) myState = TopAbs_IN;
else if ( myState == TopAbs_OUT) myState = TopAbs_IN;
else if ( myState == TopAbs_ON ) myState = TopAbs_ON;
else if ( myState == TopAbs_UNKNOWN ) myState = TopAbs_IN;
}
return myState;
}
//=======================================================================
//function : Classify
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_SolidClassifier::Classify(const TopoDS_Shell& SHE,
const gp_Pnt& P,
const Standard_Real Tol)
{
myPClassifier = NULL;
myState = TopAbs_UNKNOWN;
LoadShell(SHE);
if (myPClassifier == NULL) return myState;
myPClassifier->Perform(P,Tol);
myState = myPClassifier->State();
return myState;
}
//=======================================================================
//function : State
//purpose :
//=======================================================================
TopAbs_State TopOpeBRepTool_SolidClassifier::State() const
{
return myState;
}
//modified by NIZNHY-PKV Mon Dec 16 10:55:47 2002 f
/*
//=======================================================================
//function : LoadSolid
//purpose :
//=======================================================================
void TopOpeBRepTool_SolidClassifier::LoadSolid(const TopoDS_Solid& SOL)
{
Standard_Boolean found = myClassifierMap.Contains(SOL);
if ( !found ) {
myPClassifier = new BRepClass3d_SolidClassifier(SOL);
myClassifierMap.Add(SOL,*myPClassifier);
}
else {
myPClassifier = &myClassifierMap.ChangeFromKey(SOL);
}
#ifdef DEB
Standard_Integer i =
#endif
myClassifierMap.FindIndex(SOL); // DEB
}
//=======================================================================
//function : LoadShell
//purpose :
//=======================================================================
void TopOpeBRepTool_SolidClassifier::LoadShell(const TopoDS_Shell& SHE)
{
Standard_Boolean found = myClassifierMap.Contains(SHE);
if ( !found ) {
myBuilder.MakeSolid(mySolid);
myBuilder.Add(mySolid,SHE);
TopoDS_Shell* pshe = (TopoDS_Shell*)&SHE; (*pshe).Free(Standard_True);
myPClassifier = new BRepClass3d_SolidClassifier(mySolid);
myClassifierMap.Add(SHE,*myPClassifier);
}
else {
myPClassifier = &myClassifierMap.ChangeFromKey(SHE);
}
#ifdef DEB
Standard_Integer i =
#endif
myClassifierMap.FindIndex(SHE); // DEB
}
*/
//modified by NIZNHY-PKV Mon Dec 16 10:55:56 2002 t

View File

@@ -0,0 +1,344 @@
-- File: TopOpeBRepTool_TOOL.cdl
-- Created: Thu Nov 26 10:47:25 1998
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class TOOL from TopOpeBRepTool
uses
Pnt2d from gp,
Dir2d from gp,
Vec2d from gp,
Pnt from gp,
Vec from gp,
Dir from gp,
State from TopAbs,
Curve from Geom2d,
Shape from TopoDS,
Vertex from TopoDS,
Edge from TopoDS,
Face from TopoDS,
Curve from BRepAdaptor,
Array1OfShape from TopTools,
ListOfShape from TopTools,
DataMapOfShapeListOfShape from TopTools,
C2DF from TopOpeBRepTool
is
--
-- orientation in subshapes :
--
OriinSor(myclass; sub, S : Shape from TopoDS; checkclo : Boolean = Standard_False)
returns Integer;
-- returns 0 if <sub> is not subshape of <S>
-- returns 1 if <sub> is FORWARD in <S>
-- 2 REVERSED
-- 3 INTERNAL
-- 4 EXTERNAL
-- returns 5 CLOSING shape for <S>, if (checkclo=true)
OriinSorclosed(myclass; sub, S : Shape from TopoDS)
returns Integer;
-- returns 0 if <sub> is not subshape of <S>
-- returns 1 if <sub> is FORWARD in <S>
-- 2 REVERSED
--
-- is closing shape :
--
ClosedE(myclass; E : Edge from TopoDS; vclo : out Vertex from TopoDS)
returns Boolean;
ClosedS(myclass; F : Face from TopoDS)
returns Boolean;
IsClosingE(myclass; E : Edge from TopoDS; F : Face from TopoDS)
returns Boolean;
IsClosingE(myclass; E : Edge from TopoDS; W : Shape from TopoDS; F : Face from TopoDS)
returns Boolean;
--
-- parameters on edge / face :
--
Vertices(myclass; E : Edge from TopoDS; Vces : out Array1OfShape from TopTools);
Vertex(myclass; Iv : Integer; E : Edge from TopoDS)
returns Vertex from TopoDS;
ParE(myclass; Iv : Integer; E : Edge from TopoDS)
returns Real;
OnBoundary(myclass; par : Real; E : Edge from TopoDS)
returns Integer;
-- returns 0 : if par is not in [first,last] - <e>'s parameter range
-- 1 : on first par
-- 2 : on last par.
-- 3 : in [first,last] range
-- 5 : on first/ last and <e> is closed.
UVF(myclass; par : Real; C2DF : C2DF from TopOpeBRepTool)
returns Pnt2d from gp;
ParISO(myclass; p2d : Pnt2d from gp; e : Edge from TopoDS; f : Face from TopoDS;
pare : out Real)
returns Boolean;
-- <par> = parameter of Pt(<p2d>,<f>) on Iso(<e>,<f>)
-- returns false if 2drep(<e>,<f>) is null or is not iso.
ParE2d(myclass; p2d : Pnt2d from gp; e : Edge from TopoDS; f : Face from TopoDS;
par,dist : out Real)
returns Boolean;
-- <par> = parameter of projected point pproj2d of p2d on 2drep(e,f)
-- avoid projections if 2drep(e,f) is uviso.
-- returns false if the projection fails.
Getduv(myclass; f : Face from TopoDS; uv : Pnt2d from gp;
dir : Vec from gp; factor : Real; duv : out Dir2d from gp)
returns Boolean;
-- For <f> on quadratic surface. <dir> is normal to <f> at Pt(<f>,<uv>),
-- Pt( <uv>)+factor*<dir> ) is Pt( <uv>+factoruv*<duv> )
uvApp(myclass; f : Face from TopoDS; e : Edge from TopoDS; par,eps : Real;
uvapp : out Pnt2d from gp)
returns Boolean;
-- uvapp = uv+eps*dxx, (dxx=duvmax in direction dxx2d, uv=pt2d(par,e))
--
-- boundaries :
--
TolUV(myclass; F : Face from TopoDS; tol3d : Real)
returns Real;
TolP(myclass; E : Edge from TopoDS; F : Face from TopoDS)
returns Real;
minDUV(myclass; F : Face from TopoDS)
returns Real;
outUVbounds(myclass; uv : Pnt2d from gp; F : Face from TopoDS)
returns Boolean;
stuvF(myclass; uv : Pnt2d from gp; F : Face from TopoDS;
onU,onV : out Integer);
-- onX = -1 : if x < xf
-- onX = -2 : if x > xl
-- onX = 1 : if x = xf (a tolx de la face)
-- onX = 2 : if x = xl (a tolx de la face)
-- onX = 0 : RAS
--
-- tangents :
--
TggeomE(myclass; par : Real; BC : Curve from BRepAdaptor; Tg : out Vec from gp)
returns Boolean;
TggeomE(myclass; par : Real; E : Edge from TopoDS; Tg : out Vec from gp)
returns Boolean;
-- Computes tangent vector to <E> at <par>,
-- if <E> is degenerated returns null vector
-- else if <par> is boundary of <E> bspline, approximate vector
--
-- returns true if the compute succeeds.
TgINSIDE(myclass; v : Vertex from TopoDS; E : Edge from TopoDS;
Tg : out Vec from gp; OvinE : out Integer)
returns Boolean;
-- Computes tangent vector to <E> at <v>, oriented INSIDE 1d<E>,
-- if <OvinE> is CLOSING <Tg> is tg(vFORWARD,<E>)
Tg2d(myclass; iv : Integer; E : Edge from TopoDS;
C2DF : C2DF from TopOpeBRepTool)
returns Vec2d from gp;
-- Computes tangent vector at bound <iv>
-- ex : E is FORWARD, iv = 1 (vertex FORWARD in EFOR) -> tggeom2d(v,E)
-- REVERSED,iv = 1 (vertex REVERSED in EFOR)-> -tggeom2d(v,E)
Tg2dApp(myclass; iv : Integer; E : Edge from TopoDS;
C2DF : C2DF from TopOpeBRepTool; factor : Real)
returns Vec2d from gp;
-- Approximate tangent vector near bound <iv> of <C2DF>.
-- If <factor> is null computes tangent vector at bound
-- <iv> (iv=1..2)
tryTg2dApp(myclass; iv : Integer; E : Edge from TopoDS;
C2DF : C2DF from TopOpeBRepTool; factor : Real)
returns Vec2d from gp;
-- Approximates tangent vector only is <C2DF> gives quadratic pcurve.
--
-- normals :
--
XX(myclass; uv : Pnt2d from gp; f : Face from TopoDS;
par : Real; e : Edge from TopoDS;
xx : out Dir from gp)
returns Boolean;
Nt(myclass; uv : Pnt2d from gp; f : Face from TopoDS; normt : out Dir from gp)
returns Boolean;
NggeomF(myclass; uv : Pnt2d from gp; F : Face from TopoDS;
ng : out Vec from gp)
returns Boolean;
NgApp(myclass; par : Real; E : Edge from TopoDS; F : Face from TopoDS; tola : Real;
ngApp : out Dir from gp)
returns Boolean;
-- Approximates geometric normal <ngApp> to <F> at point(par,E),
-- purpose : !( ng.IsEqual(ngApp, tola) )
tryNgApp(myclass; par : Real; E : Edge from TopoDS; F : Face from TopoDS; tola : Real;
ng : out Dir from gp)
returns Boolean;
-- if ::NgApp fails, returns ng(par,E,F)
--
-- orientations of subshapes :
--
tryOriEinF(myclass; par : Real; E : Edge from TopoDS; F : Face from TopoDS)
returns Integer;
-- prequesitory : <E> has 2d rep on <F>
-- purpose : the compute of orientation(<E>, <F>)
-- if <E> is not edge of <F>, uses its pcurve and <par>
-- returns 0 if <sub> is not subshape of <S>
-- returns 1 if <sub> is FORWARD in <S>
-- 2 REVERSED
-- 3 INTERNAL
-- 4 EXTERNAL
-- returns 5 CLOSING shape for <S>, if (checkclo=true)
--
-- curvatures.. :
--
IsQuad(myclass; E : Edge from TopoDS)
returns Boolean;
-- returns true if <E>'s geometry is quadratic.
IsQuad(myclass; F : Face from TopoDS)
returns Boolean;
-- returns true if <E>'s geometry is quadratic.
CurvE(myclass; E : Edge from TopoDS; par : Real; tg0 : Dir from gp; Curv : out Real)
returns Boolean;
-- compute for <Curv> = curvature of <E> in the plane normal to Pt(par,E)
-- with normal direction <tg0>
-- NYI
CurvF(myclass; F : Face from TopoDS; uv : Pnt2d from gp; tg0 : Dir from gp;
Curv : out Real; direct : out Boolean)
returns Boolean;
-- compute for <Curv> = curvature of intersection curve
-- (<F>,plane normal to Pt(par,E) with normal direction <tg0>)
-- NYI
-- uviso
--
UVISO(myclass; PC : Curve from Geom2d;
isou,isov : out Boolean; d2d : out Dir2d from gp; o2d : out Pnt2d from gp)
returns Boolean;
UVISO(myclass; C2DF : C2DF from TopOpeBRepTool;
isou,isov : out Boolean; d2d : out Dir2d from gp; o2d : out Pnt2d from gp)
returns Boolean;
UVISO(myclass; E : Edge from TopoDS; F : Face from TopoDS;
isou,isov : out Boolean; d2d : out Dir2d from gp; o2d : out Pnt2d from gp)
returns Boolean;
-- closing
--
IsonCLO(myclass; PC : Curve from Geom2d;
onU : Boolean; xfirst,xperiod,xtol : Real)
returns Boolean;
IsonCLO(myclass; C2DF : C2DF from TopOpeBRepTool;
onU : Boolean; xfirst,xperiod,xtol : Real)
returns Boolean;
-- translation
--
TrslUV(myclass; t2d : Vec2d from gp; C2DF : in out C2DF from TopOpeBRepTool);
TrslUVModifE(myclass; t2d : Vec2d from gp; F : Face from TopoDS; E : in out Edge from TopoDS)
returns Boolean;
-- matter angles :
--
Matter(myclass; d1,d2,ref : Vec from gp)
returns Real;
-- prequesitory : e1,e2 are edges connexed by vertex v, oriented FORWARD
-- on the same face.
-- v is oriented FORWARD in e1 and REVERSED in e2
-- d1 = tggeom(v,e1), d2 = tggeom(v,e2)
-- return the 2d angle matter described between d1 and d2 (in range [0.2PI])
Matter(myclass; d1,d2 : Vec2d from gp)
returns Real;
Matter(myclass; xx1,nt1, xx2,nt2 : Dir from gp; tola : Real; Ang : out Real)
returns Boolean;
-- Give us faces f1,f2 sharing edge e, pt = point on e
-- xxi : tangent to face fi at pt oriented INSIDE 2d(fi)
-- normal to tg(pt,e)
-- nti : topological normal to fi at pt.
--
-- If [ 3d(f1,f2) is smaller than 3d(fi), i=1..2 ]
-- Ang = the 3d angle of matter described between f1 and f2
-- Elsewhere, returns false
Matter(myclass; f1,f2 : Face from TopoDS;
e : Edge from TopoDS; pare : Real;
tola : Real; Ang : out Real)
returns Boolean;
MatterKPtg(myclass; f1,f2 : Face from TopoDS; e : Edge from TopoDS;
Ang : out Real)
returns Boolean;
-- <f1> and <f2> are tangent on edge <e>, compute the matter angle
-- between the 2 faces (0. or 2PI)
--
-- general
--
Getstp3dF(myclass; p : Pnt from gp; f : Face from TopoDS;
uv : out Pnt2d from gp; st : out State from TopAbs)
returns Boolean;
-- expensive : uses projections
SplitE(myclass; Eanc : Edge from TopoDS; Splits : out ListOfShape from TopTools)
returns Boolean;
-- Splits edge <Eanc> on its INTERNAL vertices if any. Returns true if split succeeds.
MkShell(myclass; lF : ListOfShape from TopTools; She : out Shape from TopoDS);
Remove(myclass; loS : in out ListOfShape from TopTools;
toremove : Shape from TopoDS)
returns Boolean;
-- Removes all shapes equal to <toremove> from list <loS>
-- returns true if suceeds.
WireToFace(myclass; Fref : Face from TopoDS;
mapWlow : DataMapOfShapeListOfShape from TopTools;
lFs : out ListOfShape from TopTools)
returns Boolean;
-- <mapWlow> = {(W,low)}
-- Builds up <lFs> = {a face built on <Fref> with bounds W,low}
EdgeONFace(myclass; par : Real; ed : Edge from TopoDS;
uv : Pnt2d from gp; fa : Face from TopoDS;
isonfa : out Boolean)
returns Boolean;
-- !!! pas encore fini xpu100299
-- prequesitory : Pnt(<par>, <ed>) = Pnt(<uv>,<fa>)
-- <isonfa> is true if <ed> is IN <fa>'s geometry.
-- returns true if <isonfa>'s compute succeds.
end TOOL;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,148 @@
// File: TopOpeBRepTool_TOPOLOGY.hxx
// Created: Tue Oct 6 12:33:25 1998
// Author: Jean Yves LEBEY
// <jyl@langdox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_TOPOLOGY_HeaderFile
#define _TopOpeBRepTool_TOPOLOGY_HeaderFile
#include <TopOpeBRepTool_define.hxx>
#include <GeomAbs_CurveType.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
#include <gp_Pnt2d.hxx>
#include <gp_Pnt.hxx>
#include <gp_Dir.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Vec.hxx>
#include <Bnd_Box2d.hxx>
#include <TopoDS_Wire.hxx>
#include <BRepAdaptor_Curve.hxx>
//#include <BRepAdaptor_Curve2d.hxx>
Standard_EXPORT void FUN_tool_tolUV(const TopoDS_Face& F,Standard_Real& tolu,Standard_Real& tolv);
Standard_EXPORT Standard_Boolean FUN_tool_direct(const TopoDS_Face& F,Standard_Boolean& direct);
//Standard_EXPORT Standard_Boolean FUN_tool_IsUViso(const TopoDS_Shape& E,const TopoDS_Shape& F,Standard_Boolean& isoU,Standard_Boolean& isoV,gp_Dir2d& d2d,gp_Pnt2d& o2d);
Standard_EXPORT Standard_Boolean FUN_tool_bounds(const TopoDS_Shape& F,Standard_Real& u1,Standard_Real& u2,Standard_Real& v1,Standard_Real& v2);
Standard_EXPORT Standard_Boolean FUN_tool_geombounds(const TopoDS_Face& F,
Standard_Real& u1,Standard_Real& u2,Standard_Real& v1,Standard_Real& v2);
Standard_EXPORT Standard_Boolean FUN_tool_isobounds(const TopoDS_Shape& F,Standard_Real& u1,Standard_Real& u2,Standard_Real& v1,Standard_Real& v2);
Standard_EXPORT Standard_Boolean FUN_tool_outbounds(const TopoDS_Shape& Sh,Standard_Real& u1,Standard_Real& u2,Standard_Real& v1,Standard_Real& v2,Standard_Boolean& outbounds);
// ----------------------------------------------------------------------
// project point <P> on geometries (curve <C>,surface <S>)
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_PinC(const gp_Pnt& P,const BRepAdaptor_Curve& BAC,const Standard_Real pmin,const Standard_Real pmax,const Standard_Real tol);
Standard_EXPORT Standard_Boolean FUN_tool_PinC(const gp_Pnt& P,const BRepAdaptor_Curve& BAC,const Standard_Real tol);
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_value(const Standard_Real par,const TopoDS_Edge& E,gp_Pnt& P);
Standard_EXPORT Standard_Boolean FUN_tool_value(const gp_Pnt2d& UV,const TopoDS_Face& F,gp_Pnt& P);
Standard_EXPORT TopAbs_State FUN_tool_staPinE(const gp_Pnt& P,const TopoDS_Edge& E,const Standard_Real tol);
Standard_EXPORT TopAbs_State FUN_tool_staPinE(const gp_Pnt& P,const TopoDS_Edge& E);
// ----------------------------------------------------------------------
// subshape's orientation :
// - orientVinE : vertex orientation in edge
// - orientEinF : edge's orientation in face
// - tool_orientEinFFORWARD : edge's orientation in face oriented FORWARD
// - EboundF : true if vertex is oriented (FORWARD,REVERSED) in an edge
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Integer FUN_tool_orientVinE(const TopoDS_Vertex& v,const TopoDS_Edge& e);
Standard_EXPORT Standard_Boolean FUN_tool_orientEinF(const TopoDS_Edge& E,const TopoDS_Face& F,TopAbs_Orientation& oriEinF);
Standard_EXPORT Standard_Boolean FUN_tool_orientEinFFORWARD(const TopoDS_Edge& E,const TopoDS_Face& F,TopAbs_Orientation& oriEinF);
Standard_EXPORT Standard_Boolean FUN_tool_EboundF(const TopoDS_Edge& E,const TopoDS_Face& F);
// ----------------------------------------------------------------------
// derivatives :
// ----------------------------------------------------------------------
Standard_EXPORT gp_Vec FUN_tool_nggeomF(const gp_Pnt2d& p2d,const TopoDS_Face& F);
Standard_EXPORT Standard_Boolean FUN_tool_nggeomF(const Standard_Real& paronE,const TopoDS_Edge& E,const TopoDS_Face& F,gp_Vec& nggeomF);
Standard_EXPORT Standard_Boolean FUN_tool_nggeomF(const Standard_Real& paronE,const TopoDS_Edge& E,const TopoDS_Face& F,gp_Vec& nggeomF,const Standard_Real tol);
Standard_EXPORT Standard_Boolean FUN_tool_EtgF(const Standard_Real& paronE,const TopoDS_Edge& E,const gp_Pnt2d& p2d,const TopoDS_Face& F,const Standard_Real tola);
Standard_EXPORT Standard_Boolean FUN_tool_EtgOOE(const Standard_Real& paronE, const TopoDS_Edge& E,const Standard_Real& paronOOE,const TopoDS_Edge& OOE,const Standard_Real tola);
// ----------------------------------------------------------------------
// oriented vectors :
// ----------------------------------------------------------------------
Standard_EXPORT gp_Vec FUN_tool_getgeomxx(const TopoDS_Face& Fi,const TopoDS_Edge& Ei,const Standard_Real parOnEi,const gp_Dir& ngFi);
Standard_EXPORT gp_Vec FUN_tool_getgeomxx(const TopoDS_Face& Fi,const TopoDS_Edge& Ei,const Standard_Real parOnEi);
Standard_EXPORT Standard_Boolean FUN_nearestISO(const TopoDS_Face& F,const Standard_Real xpar,const Standard_Boolean isoU,Standard_Real& xinf,Standard_Real& xsup);
Standard_EXPORT Standard_Boolean FUN_tool_getxx(const TopoDS_Face& Fi,const TopoDS_Edge& Ei,const Standard_Real parOnEi,const gp_Dir& ngFi,gp_Dir& XX);
Standard_EXPORT Standard_Boolean FUN_tool_getxx(const TopoDS_Face& Fi,const TopoDS_Edge& Ei, const Standard_Real parOnEi,gp_Dir& XX);
Standard_EXPORT Standard_Boolean FUN_tool_getdxx(const TopoDS_Face& F,const TopoDS_Edge& E,const Standard_Real parE,gp_Vec2d& XX);
Standard_EXPORT Standard_Boolean FUN_tool_EitangenttoFe(const gp_Dir& ngFe,const TopoDS_Edge& Ei,const Standard_Real parOnEi);
// ----------------------------------------------------------------------
// curve type,surface type :
// ----------------------------------------------------------------------
Standard_EXPORT GeomAbs_CurveType FUN_tool_typ(const TopoDS_Edge& E);
Standard_EXPORT Standard_Boolean FUN_tool_line(const TopoDS_Edge& E);
Standard_EXPORT Standard_Boolean FUN_tool_plane(const TopoDS_Shape& F);
Standard_EXPORT Standard_Boolean FUN_tool_cylinder(const TopoDS_Shape& F);
Standard_EXPORT Standard_Boolean FUN_tool_closedS(const TopoDS_Shape& F,Standard_Boolean& uclosed,Standard_Real& uperiod,Standard_Boolean& vclosed,Standard_Real& vperiod);
Standard_EXPORT Standard_Boolean FUN_tool_closedS(const TopoDS_Shape& F);
Standard_EXPORT Standard_Boolean FUN_tool_closedS(const TopoDS_Shape& F,Standard_Boolean& inU, Standard_Real& xmin, Standard_Real& xper);
Standard_EXPORT void FUN_tool_mkBnd2d(const TopoDS_Shape& W,const TopoDS_Shape& FF,Bnd_Box2d& B2d);
// ----------------------------------------------------------------------
// closing topologies :
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_IsClosingE(const TopoDS_Edge& E,const TopoDS_Shape& S,const TopoDS_Face& F);
Standard_EXPORT Standard_Boolean FUN_tool_ClosingE(const TopoDS_Edge& E,const TopoDS_Wire& W,const TopoDS_Face& F);
Standard_EXPORT Standard_Boolean FUN_tool_ClosedE(const TopoDS_Edge& E,TopoDS_Shape& vclosing);
// ----------------------------------------------------------------------
// shared topologies :
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_inS(const TopoDS_Shape& subshape,const TopoDS_Shape& shape);
Standard_EXPORT Standard_Boolean FUN_tool_Eshared(const TopoDS_Shape& v,const TopoDS_Shape& F1,const TopoDS_Shape& F2,TopoDS_Shape& Eshared);
Standard_EXPORT Standard_Boolean FUN_tool_parVonE(const TopoDS_Vertex& v,const TopoDS_Edge& E,Standard_Real& par);
Standard_EXPORT Standard_Boolean FUN_tool_parE(const TopoDS_Edge& E0,const Standard_Real& par0,const TopoDS_Edge& E,Standard_Real& par,const Standard_Real tol);
Standard_EXPORT Standard_Boolean FUN_tool_parE(const TopoDS_Edge& E0,const Standard_Real& par0,const TopoDS_Edge& E,Standard_Real& par);
Standard_EXPORT Standard_Boolean FUN_tool_paronEF(const TopoDS_Edge& E,const Standard_Real& par,const TopoDS_Face& F,gp_Pnt2d& UV,const Standard_Real tol);
Standard_EXPORT Standard_Boolean FUN_tool_paronEF(const TopoDS_Edge& E,const Standard_Real& par,const TopoDS_Face& F,gp_Pnt2d& UV);
Standard_EXPORT Standard_Boolean FUN_tool_parF(const TopoDS_Edge& E,const Standard_Real& par,const TopoDS_Face& F,gp_Pnt2d& UV,const Standard_Real tol);
Standard_EXPORT Standard_Boolean FUN_tool_parF(const TopoDS_Edge& E,const Standard_Real& par,const TopoDS_Face& F,gp_Pnt2d& UV);
Standard_EXPORT gp_Dir FUN_tool_dirC(const Standard_Real par,const BRepAdaptor_Curve& BAC);
Standard_EXPORT gp_Vec FUN_tool_tggeomE(const Standard_Real paronE,const TopoDS_Edge& E);
Standard_EXPORT Standard_Boolean FUN_tool_line(const BRepAdaptor_Curve& BAC);
Standard_EXPORT Standard_Boolean FUN_tool_quad(const TopoDS_Edge& E);
Standard_EXPORT Standard_Boolean FUN_tool_quad(const BRepAdaptor_Curve& BAC);
Standard_EXPORT Standard_Boolean FUN_tool_quad(const TopoDS_Face& F);
Standard_EXPORT Standard_Boolean FUN_tool_findPinBAC(const BRepAdaptor_Curve& BAC,gp_Pnt& P,Standard_Real& par);
Standard_EXPORT Standard_Boolean FUN_tool_findparinBAC(const BRepAdaptor_Curve& BAC,Standard_Real& par);
Standard_EXPORT Standard_Boolean FUN_tool_findparinE(const TopoDS_Shape& E,Standard_Real& par);
Standard_EXPORT Standard_Boolean FUN_tool_findPinE(const TopoDS_Shape& E,gp_Pnt& P,Standard_Real& par);
Standard_EXPORT Standard_Boolean FUN_tool_maxtol(const TopoDS_Shape& S,const TopAbs_ShapeEnum& typ,Standard_Real& tol);
Standard_EXPORT Standard_Real FUN_tool_maxtol(const TopoDS_Shape& S);
Standard_EXPORT Standard_Integer FUN_tool_nbshapes(const TopoDS_Shape& S,const TopAbs_ShapeEnum& typ);
Standard_EXPORT void FUN_tool_shapes(const TopoDS_Shape& S,const TopAbs_ShapeEnum& typ,TopTools_ListOfShape& ltyp);
Standard_EXPORT Standard_Integer FUN_tool_comparebndkole(const TopoDS_Shape& sh1,const TopoDS_Shape& sh2);
Standard_EXPORT Standard_Boolean FUN_tool_SameOri(const TopoDS_Edge& E1,const TopoDS_Edge& E2);
Standard_EXPORT Standard_Boolean FUN_tool_haspc(const TopoDS_Edge& E,const TopoDS_Face& F);
Standard_EXPORT Standard_Boolean FUN_tool_pcurveonF(const TopoDS_Face& F,TopoDS_Edge& E);
Standard_EXPORT Standard_Boolean FUN_tool_pcurveonF(const TopoDS_Face& fF,TopoDS_Edge& faultyE,const Handle(Geom2d_Curve)& C2d,TopoDS_Face& newf);
// ----------------------------------------------------------------------
// shared geometry :
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_curvesSO(const TopoDS_Edge& E1,const Standard_Real p1,const TopoDS_Edge& E2,const Standard_Real p2,Standard_Boolean& so);
Standard_EXPORT Standard_Boolean FUN_tool_curvesSO(const TopoDS_Edge& E1,const Standard_Real p1,const TopoDS_Edge& E2,Standard_Boolean& so);
Standard_EXPORT Standard_Boolean FUN_tool_curvesSO(const TopoDS_Edge& E1,const TopoDS_Edge& E2,Standard_Boolean& so);
Standard_EXPORT Standard_Boolean FUN_tool_findAncestor(const TopTools_ListOfShape& lF,const TopoDS_Edge& E,TopoDS_Face& Fanc);
// ----------------------------------------------------------------------
// new topologies :
// ----------------------------------------------------------------------
Standard_EXPORT void FUN_ds_CopyEdge(const TopoDS_Shape& Ein,TopoDS_Shape& Eou);
Standard_EXPORT void FUN_ds_Parameter(const TopoDS_Shape& E,const TopoDS_Shape& V,const Standard_Real P);
Standard_EXPORT Standard_Boolean FUN_tool_MakeWire(const TopTools_ListOfShape& loE,TopoDS_Wire& newW);
Standard_EXPORT Standard_Boolean FUN_tool_getEclo(const TopoDS_Face& F, const Standard_Boolean UISO, TopoDS_Edge& Eclo);
#endif

View File

@@ -0,0 +1,43 @@
// File: TopOpeBRepTool_box.hxx
// Created: Tue Apr 1 11:22:56 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_box.hxx>
#include <TopOpeBRepTool_HBoxTool.hxx>
#include <Bnd_Box.hxx>
Standard_EXPORT void FBOX_Prepare()
{
Handle(TopOpeBRepTool_HBoxTool) hbt = FBOX_GetHBoxTool();
hbt->Clear();
#ifdef DEB
if (TopOpeBRepTool_GettraceBOX()) {
cout<<endl<<"TOOLBOX : Prepare"<<endl;
}
#endif
}
Standard_EXPORT Handle(TopOpeBRepTool_HBoxTool) FBOX_GetHBoxTool()
{
static Handle(TopOpeBRepTool_HBoxTool) GLOBAL_TOOLBOX_hboxtool;
if (GLOBAL_TOOLBOX_hboxtool.IsNull()) {
GLOBAL_TOOLBOX_hboxtool = new TopOpeBRepTool_HBoxTool();
}
return GLOBAL_TOOLBOX_hboxtool;
}
Standard_EXPORT const Bnd_Box& FBOX_Box(const TopoDS_Shape& S)
{
Handle(TopOpeBRepTool_HBoxTool) hbt = FBOX_GetHBoxTool();
const Bnd_Box& b = hbt->Box(S);
#ifdef DEB
if (TopOpeBRepTool_GettraceBOX()) {
Standard_Integer i = hbt->Index(S);
Standard_Integer n = hbt->Extent();
cout<<"TOOLBOX : "<<i<<"/"<<n<<endl;
}
#endif
return b;
}

View File

@@ -0,0 +1,20 @@
// File: TopOpeBRepTool_box.hxx
// Created: Tue Apr 1 11:22:56 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_box_HeaderFile
#define _TopOpeBRepTool_box_HeaderFile
#include <TopoDS_Shape.hxx>
#include <TopOpeBRepTool_HBoxTool.hxx>
#ifdef DEB
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceBOX();
#endif
Standard_EXPORT void FBOX_Prepare();
Standard_EXPORT Handle(TopOpeBRepTool_HBoxTool) FBOX_GetHBoxTool();
Standard_EXPORT const Bnd_Box& FBOX_Box(const TopoDS_Shape& S);
#endif

View File

@@ -0,0 +1,144 @@
// File: TopOpeBRepTool_closing.cxx
// Created: Tue Nov 24 14:08:03 1998
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <Geom2d_Curve.hxx>
#include <gp_Vec2d.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
//Standard_IMPORT void FUN_tool_ttranslate(const gp_Vec2d& tvector, const TopoDS_Face& fF, TopoDS_Edge& fyE);
Standard_EXPORT Standard_Boolean FUN_tool_UVonclosing(const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Boolean onU,
const Standard_Real xfirst, const Standard_Real xperiod,
const Standard_Real toluv)
// purpose : returns TRUE if E has UVrep on F, on closing UVrep
// prequesitory : F is x-closed, its x-2drep describes [xfirst,xfirst+xperiod]
// if (onU=1), F is u-closed
{
// E :
Standard_Real f,l,tol; Handle(Geom2d_Curve) PC = FC2D_CurveOnSurface(E,F,f,l,tol);
Standard_Boolean isou,isov; gp_Pnt2d o2d; gp_Dir2d d2d;
Standard_Boolean isouv = TopOpeBRepTool_TOOL::UVISO(PC,isou,isov,d2d,o2d);
if (!isouv) return Standard_False;
Standard_Boolean onX = (onU && isou) || ((!onU) && isov);
if (!onX) return Standard_False;
Standard_Real dxx=0;
if (onU) dxx = Abs(o2d.X()-xfirst);
else dxx = Abs(o2d.Y()-xfirst);
Standard_Boolean onclo = (dxx < toluv);
onclo = onclo || (Abs(xperiod-dxx) < toluv);
return onclo;
}//FUN_UVonclosing
/*Standard_EXPORT Standard_Boolean FUN_tool_getEclo(const TopoDS_Face& F, TopoDS_Edge& Eclo)
// purpose : get Eclo / closing edge of F
// rep(Eclo,F) is x-iso, parx=xmin/xmax
{
Eclo.Nullify();
TopExp_Explorer ex(F, TopAbs_EDGE);
for (; ex.More(); ex.Next()){
const TopoDS_Edge& e = TopoDS::Edge(ex.Current());
Standard_Boolean clo = BRep_Tool::IsClosed(e,F);
if (clo) {Eclo=e; return Standard_True;}
}
return Standard_False;
}*/
Standard_EXPORT Standard_Boolean FUN_tool_correctCLO(TopoDS_Edge& E, const TopoDS_Face& F)
// purpose : correcting "closing edges", returns Standard_True if E pcurve
// is translated
{
TopoDS_Shape aLocalShape = F.Oriented(TopAbs_FORWARD);
TopoDS_Face FFOR = TopoDS::Face(aLocalShape);
// TopoDS_Face FFOR = TopoDS::Face(F.Oriented(TopAbs_FORWARD));
// ************************************************************
// prequesitory : in process add(E,F), we'll keep original
// E orientation (orientation of E in FFORWARD)
// ************************************************************
Standard_Boolean inU; Standard_Real xmin,xper;
Standard_Boolean closed = FUN_tool_closedS(F,inU,xmin,xper);
if (!closed) return Standard_False; // F is not periodic
Standard_Real tolu,tolv; FUN_tool_tolUV(TopoDS::Face(F),tolu,tolv);
Standard_Real tolx = inU ? tolu : tolv;
Standard_Real dx=0.45678;
// Standard_Real f,l,tolpc; Standard_Boolean trim3d = Standard_True;
// Handle(Geom2d_Curve) PC = FC2D_CurveOnSurface(E,F,f,l,tolpc,trim3d);
Standard_Real f,l,tol; Handle(Geom2d_Curve) PC;
#ifdef DEB
Standard_Boolean hasold =
#endif
FC2D_HasOldCurveOnSurface(E,FFOR,PC);
#ifdef DEB
Standard_Boolean hasnew =
#endif
FC2D_HasNewCurveOnSurface(E,FFOR,PC);
PC = FC2D_EditableCurveOnSurface(E,FFOR,f,l,tol);
Standard_Boolean isoU,isoV; gp_Pnt2d o2d; gp_Dir2d d2d;
#ifdef DEB
Standard_Boolean ISO =
#endif
TopOpeBRepTool_TOOL::UVISO(PC,isoU,isoV,d2d,o2d);
Standard_Boolean xiso = (inU && isoU)||((!inU) && isoV);
if (!xiso) return Standard_False;
Standard_Real par = dx*f + (1-dx)*l; gp_Vec2d dxx;
#ifdef DEB
Standard_Boolean ok =
#endif
FUN_tool_getdxx(FFOR,E,par,dxx);
TopExp_Explorer ex(FFOR, TopAbs_EDGE);
for (; ex.More(); ex.Next()){
const TopoDS_Edge& e1 = TopoDS::Edge(ex.Current());
Standard_Boolean closing = BRep_Tool::IsClosed(e1,F);
if (!closing) continue;
// Standard_Real f1,l1; Handle(Geom2d_Curve) PC1 = BRep_Tool::CurveOnSurface(e1,F,f1,l1);
Standard_Real f1,l1,tol1; Handle(Geom2d_Curve) PC1;
#ifdef DEB
Standard_Boolean hasold1 =
#endif
FC2D_HasOldCurveOnSurface(e1,FFOR,PC1);
#ifdef DEB
Standard_Boolean hasnew1 =
#endif
FC2D_HasNewCurveOnSurface(e1,FFOR,PC1);
PC1 = FC2D_EditableCurveOnSurface(e1,FFOR,f1,l1,tol1);
Standard_Boolean isoU1,isoV1; gp_Pnt2d o2d1; gp_Dir2d d2d1;
#ifdef DEB
Standard_Boolean ISO1 =
#endif
TopOpeBRepTool_TOOL::UVISO(PC1,isoU1,isoV1,d2d1,o2d1);
// 2d(e1,FFOR) and 2d(E,FFOR) describe the same side of matter
Standard_Real par1 = dx*f1 + (1-dx)*l1; gp_Vec2d dxx1;
#ifdef DEB
Standard_Boolean ok1 =
#endif
FUN_tool_getdxx(FFOR,e1,par1,dxx1);
Standard_Real dot = dxx.Dot(dxx1);
if (dot < 0.) continue;
gp_Vec2d dxx; Standard_Real dd=0;
if (inU) {dd = o2d1.X()-o2d.X(); dxx = gp_Vec2d(dd,0.);}
else {dd = o2d1.Y()-o2d.Y(); dxx = gp_Vec2d(0.,dd);}
if (Abs(dd)<tolx) return Standard_False;
TopOpeBRepTool_TOOL::TrslUVModifE(dxx,FFOR,E); //FUN_tool_ttranslate(dxx,FFOR,E);
} // ex(FFOR)
return Standard_False;
}

View File

@@ -0,0 +1,60 @@
-- File: TopOpeBRepTool_connexity.cdl
-- Created: Wed Dec 9 14:19:52 1998
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1998
class connexity from TopOpeBRepTool
uses
Shape from TopoDS,
ListOfShape from TopTools,
Array1OfListOfShape from TopTools
is
Create returns connexity from TopOpeBRepTool;
Create (Key : Shape from TopoDS) returns connexity from TopOpeBRepTool;
SetKey (me : in out; Key : Shape from TopoDS);
Key (me) returns Shape from TopoDS;
---C++: return const &
Item(me; OriKey : Integer; Item : out ListOfShape from TopTools)
returns Integer;
-- if <theKey> is oriented <OriKey> in all shapes of <Item>, returns
-- the <Item>'s length.
AllItems(me; Item : out ListOfShape from TopTools)
returns Integer;
-- returns all items attached to <theKey>
AddItem(me : in out; OriKey : Integer; Item : ListOfShape from TopTools);
AddItem(me : in out; OriKey : Integer; Item : Shape from TopoDS);
RemoveItem(me : in out; OriKey : Integer; Item : Shape from TopoDS)
returns Boolean;
-- returns true if <Item> is stored in the list.
RemoveItem(me : in out; Item : Shape from TopoDS)
returns Boolean;
ChangeItem(me : in out; OriKey : Integer)
returns ListOfShape from TopTools;
---C++: return &
IsMultiple(me)
returns Boolean;
-- returns true if <theKey> is multiple.
IsFaulty(me)
returns Boolean;
IsInternal(me; Item : out ListOfShape from TopTools)
returns Integer;
-- <theKey> is INTERNAL in shapes of <Item> oriented FORWARD.
fields
theKey : Shape from TopoDS;
theItems : Array1OfListOfShape from TopTools;
-- <theKey> is FORWARD in shapes of theItems(1)
-- <theKey> is REVERSED in shapes of theItems(2)
-- <theKey> is INTERNAL in shapes of theItems(3)
-- <theKey> is EXTERNAL in shapes of theItems(4)
-- <theKey> appears FORWARD and REVERSED in shapes of theItems(5)
end connexity;

View File

@@ -0,0 +1,235 @@
// File: TopOpeBRepTool_connexity.cxx
// Created: Wed Dec 9 14:47:29 1998
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_connexity.ixx>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#define M_FORWARD(sta) (sta == TopAbs_FORWARD)
#define M_REVERSED(sta) (sta == TopAbs_REVERSED)
#define M_INTERNAL(sta) (sta == TopAbs_INTERNAL)
#define M_EXTERNAL(sta) (sta == TopAbs_EXTERNAL)
#define FORWARD (1)
#define REVERSED (2)
#define INTERNAL (3)
#define EXTERNAL (4)
#define CLOSING (5)
//=======================================================================
//function : TopOpeBRepTool_connexity
//purpose :
//=======================================================================
TopOpeBRepTool_connexity::TopOpeBRepTool_connexity()
: theItems(1,5)
{
}
//=======================================================================
//function : TopOpeBRepTool_connexity
//purpose :
//=======================================================================
TopOpeBRepTool_connexity::TopOpeBRepTool_connexity(const TopoDS_Shape& Key)
: theKey(Key), theItems(1,5)
{
}
//=======================================================================
//function : SetKey
//purpose :
//=======================================================================
void TopOpeBRepTool_connexity::SetKey(const TopoDS_Shape& Key)
{
theKey = Key;
}
//=======================================================================
//function : Key
//purpose :
//=======================================================================
const TopoDS_Shape& TopOpeBRepTool_connexity::Key() const
{
return theKey;
}
/*static Standard_Integer FUN_toI(const TopAbs_Orientation& O)
{
Standard_Integer Index = 0;
if (O == TopAbs_FORWARD) Index = 1;
else if (O == TopAbs_REVERSED) Index = 2;
else if (O == TopAbs_INTERNAL) Index = 3;
else if (O == TopAbs_EXTERNAL) Index = 0;
return Index;
}*/
//=======================================================================
//function : Item
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_connexity::Item(const Standard_Integer OriKey, TopTools_ListOfShape& Item) const
{
Item.Clear();
Item = theItems(OriKey);
return (Item.Extent());
}
//=======================================================================
//function : AllItems
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_connexity::AllItems(TopTools_ListOfShape& Item) const
{
Item.Clear();
for (Standard_Integer i = 1; i <=4; i++) {
TopTools_ListOfShape copy; copy.Assign(theItems.Value(i));
Item.Append(copy);
}
return Item.Extent();
}
//=======================================================================
//function : AddItem
//purpose :
//=======================================================================
void TopOpeBRepTool_connexity::AddItem(const Standard_Integer OriKey, const TopTools_ListOfShape& Item)
{
TopTools_ListOfShape copy; copy.Assign(Item);
theItems(OriKey).Append(copy);
}
void TopOpeBRepTool_connexity::AddItem(const Standard_Integer OriKey, const TopoDS_Shape& Item)
{
TopTools_ListOfShape copy; copy.Append(Item);
theItems(OriKey).Append(copy);
}
//=======================================================================
//function : RemoveItem
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_connexity::RemoveItem(const Standard_Integer OriKey, const TopoDS_Shape& Item)
{
TopTools_ListOfShape& item = theItems.ChangeValue(OriKey);
TopTools_ListIteratorOfListOfShape it(item);
while (it.More()) {
if (it.Value().IsEqual(Item)) {item.Remove(it); return Standard_True;}
else it.Next();
}
return Standard_False;
}
//=======================================================================
//function : RemoveItem
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_connexity::RemoveItem(const TopoDS_Shape& Item)
{
Standard_Boolean removed = Standard_False;
for (Standard_Integer i = 1; i<= 5; i++) {
Standard_Boolean found = RemoveItem(i,Item);
if (found) removed = Standard_True;
}
return removed;
}
//=======================================================================
//function : ChangeItem
//purpose :
//=======================================================================
TopTools_ListOfShape& TopOpeBRepTool_connexity::ChangeItem(const Standard_Integer OriKey)
{
return theItems.ChangeValue(OriKey);
}
//=======================================================================
//function : IsMultiple
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_connexity::IsMultiple() const
{
TopTools_ListOfShape lfound;
Standard_Integer nkeyitem = Item(FORWARD,lfound);
// nkeyRitem += Item(INTERNAL,lfound); NOT VALID
// if key is vertex : key appears F in closing E, only one time
nkeyitem += Item(CLOSING,lfound);
Standard_Boolean multiple = (nkeyitem > 1);
return multiple;
}
//=======================================================================
//function : IsFaulty
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_connexity::IsFaulty() const
{
TopTools_ListOfShape lfound;
Standard_Integer nkeyRintem = Item(FORWARD,lfound);
Standard_Integer nkeyFitem = Item(REVERSED,lfound);
Standard_Boolean faulty = (nkeyRintem != nkeyFitem);
return faulty;
}
//=======================================================================
//function : IsInternal
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_connexity::IsInternal(TopTools_ListOfShape& Item) const
{
Item.Clear();
// all subshapes of INTERNAL(EXTERNAL) are oriented INTERNAL(EXTERNAL)
TopTools_ListOfShape lINT; lINT.Assign(theItems.Value(INTERNAL));
#ifdef DEB
Standard_Integer n1 =
#endif
lINT.Extent();
TopTools_ListIteratorOfListOfShape it1(lINT);
while (it1.More()) {
const TopoDS_Shape& item1 = it1.Value();
TopAbs_Orientation o1 = item1.Orientation();
if (!M_INTERNAL(o1)) {it1.Next(); continue;}
Standard_Integer oKey1 = TopOpeBRepTool_TOOL::OriinSor(theKey,item1.Oriented(TopAbs_FORWARD));
if (oKey1 != INTERNAL) lINT.Remove(it1);
else it1.Next();
}
TopTools_ListOfShape lEXT; lEXT.Assign(theItems.Value(EXTERNAL));
#ifdef DEB
Standard_Integer n2 =
#endif
lEXT.Extent();
TopTools_ListIteratorOfListOfShape it2(lEXT);
while (it2.More()) {
const TopoDS_Shape& item2 = it2.Value();
TopAbs_Orientation o2 = item2.Orientation();
if (!M_EXTERNAL(o2)) {it2.Next(); continue;}
Standard_Integer oKey2 = TopOpeBRepTool_TOOL::OriinSor(theKey,item2.Oriented(TopAbs_FORWARD));
if (oKey2 == INTERNAL) lINT.Append(item2);
it2.Next();
}
Item.Append(lINT);
return Item.Extent();
}

View File

@@ -0,0 +1,68 @@
// File: TopOpeBRepTool_define.hxx
// Created: Wed Oct 8 11:39:45 1997
// Author: Prestataire Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_define_HeaderFile
#define _TopOpeBRepTool_define_HeaderFile
#include <TopAbs_ShapeEnum.hxx>
#include <TopAbs_Orientation.hxx>
#include <TopAbs_State.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedMapOfOrientedShape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_DataMapOfShapeInteger.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfOrientedShapeInteger.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfOrientedShapeInteger.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TCollection_AsciiString.hxx>
#define MTAse TopAbs_ShapeEnum
#define MTAo TopAbs_Orientation
#define MTAs TopAbs_State
#define MTTmiomos TopTools_MapIteratorOfMapOfShape
#define MTTmos TopTools_MapOfShape
#define MTTliolos TopTools_ListIteratorOfListOfShape
#define MTTlos TopTools_ListOfShape
#define MTTimos TopTools_IndexedMapOfShape
#define MTTimoos TopTools_IndexedMapOfOrientedShape
#define MTTdmoss TopTools_DataMapOfShapeShape
#define MTTdmosi TopTools_DataMapOfShapeInteger
#define MTTdmoosi TopTools_DataMapOfOrientedShapeInteger
#define MTTdmiodmoss TopTools_DataMapIteratorOfDataMapOfShapeShape
#define MTTdmiodmosi TopTools_DataMapIteratorOfDataMapOfShapeInteger
#define MTTdmoslos TopTools_DataMapOfShapeListOfShape
#define MTTdmiodmoslos TopTools_DataMapIteratorOfDataMapOfShapeListOfShape
#define MTTidmoslos TopTools_IndexedDataMapOfShapeListOfShape
#define MTTdmiodmoosi TopTools_DataMapIteratorOfDataMapOfOrientedShapeInteger
#define MTs TopoDS_Shape
#define MTf TopoDS_Face
#define MTe TopoDS_Edge
#define MTv TopoDS_Vertex
#define Msr Standard_Real
#define Msi Standard_Integer
#define Msb Standard_Boolean
#define Msf Standard_False
#define Mst Standard_True
#define Mso Standard_OStream
#define Mtcas TCollection_AsciiString
#define MTLsc TopOpeBRepTool_ShapeClassifier
#define MTLpsc TopOpeBRepTool_PShapeClassifier
#define MTLoct TopOpeBRepTool_OutCurveType
#define MTLc TopOpeBRepTool_connexity
#endif

View File

@@ -0,0 +1,24 @@
// File: TopOpeBRepTool_defineG.hxx
// Created: Wed Oct 8 11:39:45 1997
// Author: Prestataire Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_defineG_HeaderFile
#define _TopOpeBRepTool_defineG_HeaderFile
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom2d_Curve.hxx>
#include <Geom2d_TrimmedCurve.hxx>
#define Mhgc Handle(Geom_Curve)
#define Mhgtc Handle(Geom_TrimmedCurve)
#define Mhg2c Handle(Geom2d_Curve)
#define Mhg2tc Handle(Geom2d_TrimmedCurve)
#define Mgc Geom_Curve
#define Mgtc Geom_TrimmedCurve
#define Mg2c Geom2d_Curve
#define Mg2tc Geom_TrimmedCurve
#endif

View File

@@ -0,0 +1,36 @@
-- File: TopOpeBRepTool_face.cdl
-- Created: Thu Jan 14 10:07:21 1999
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class face from TopOpeBRepTool
uses
Wire from TopoDS,
Face from TopoDS
is
Create returns face from TopOpeBRepTool;
Init (me : in out; W : Wire from TopoDS; Fref : Face from TopoDS)
returns Boolean;
-- Builds face f for <myW> on <Fref>,
-- updates <myfinite> to true if f is finite,
-- <myFfinite> is finite.
-- returns false if the compute fails
W(me) returns Wire from TopoDS;
---C++: return const &
IsDone(me) returns Boolean;
Finite(me) returns Boolean;
Ffinite(me) returns Face from TopoDS;
---C++: return const &
RealF(me) returns Face from TopoDS;
-- Raises if !IsDone
fields
myW : Wire from TopoDS;
myfinite : Boolean;
myFfinite : Face from TopoDS;
end face;

View File

@@ -0,0 +1,124 @@
// File: TopOpeBRepTool_face.cxx
// Created: Thu Jan 14 10:20:08 1999
// Author: Prestataire Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_face.ixx>
#include <TopOpeBRepTool_define.hxx>
#include <Standard_Failure.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <Precision.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Iterator.hxx>
#include <BRepTopAdaptor_FClass2d.hxx>
//=======================================================================
//function : TopOpeBRepTool_face
//purpose :
//=======================================================================
TopOpeBRepTool_face::TopOpeBRepTool_face()
{
}
static void FUN_reverse(const TopoDS_Face& f, TopoDS_Face& frev)
{
BRep_Builder B;
TopoDS_Shape aLocalShape = f.EmptyCopied();
frev = TopoDS::Face(aLocalShape);
// frev = TopoDS::Face(f.EmptyCopied());
TopoDS_Iterator it(f);
while (it.More()) {
B.Add(frev,it.Value().Reversed());
it.Next();
}
}
//=======================================================================
//function : Init
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_face::Init(const TopoDS_Wire& W, const TopoDS_Face& Fref)
{
myFfinite.Nullify();
myW = W;
// fres :
// TopoDS_Face fres;
// Handle(Geom_Surface) su = BRep_Tool::Surface(Fref);
// BRep_Builder B; B.MakeFace(fres,su,Precision::Confusion());
TopoDS_Shape aLocalShape = Fref.EmptyCopied();
TopoDS_Face fres = TopoDS::Face(aLocalShape);
// TopoDS_Face fres = TopoDS::Face(Fref.EmptyCopied());
BRep_Builder B; B.Add(fres,W);
B.NaturalRestriction(fres,Standard_True);
// <myfinite> :
BRepTopAdaptor_FClass2d FClass(fres,0.);
Standard_Boolean infinite = ( FClass.PerformInfinitePoint() == TopAbs_IN);
myfinite = !infinite;
// <myFfinite> :
if (myfinite) myFfinite = fres;
else FUN_reverse(fres,myFfinite);
return Standard_True;
}
//=======================================================================
//function : IsDone
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_face::IsDone() const
{
return (!myFfinite.IsNull());
}
//=======================================================================
//function : Finite
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_face::Finite() const
{
if (!IsDone()) Standard_Failure::Raise("TopOpeBRepTool_face NOT DONE");
return myfinite;
}
//=======================================================================
//function : Ffinite
//purpose :
//=======================================================================
const TopoDS_Face& TopOpeBRepTool_face::Ffinite() const
{
if (!IsDone()) Standard_Failure::Raise("TopOpeBRepTool_face NOT DONE");
return myFfinite;
}
//=======================================================================
//function : W
//purpose :
//=======================================================================
const TopoDS_Wire& TopOpeBRepTool_face::W() const
{
return myW;
}
//=======================================================================
//function : TopoDS_Face&
//purpose :
//=======================================================================
TopoDS_Face TopOpeBRepTool_face::RealF() const
{
if (myfinite) return myFfinite;
TopoDS_Face realf; FUN_reverse(myFfinite,realf);
return realf;
}

View File

@@ -0,0 +1,453 @@
// File: TopOpeBRepTool_faulty.cxx
// Created: Tue Nov 24 11:15:13 1998
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_2d.hxx>
#include <TopExp_Explorer.hxx>
#include <BRep_Tool.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#define M_FORWARD(sta) (sta == TopAbs_FORWARD)
#define M_REVERSED(sta) (sta == TopAbs_REVERSED)
#define M_INTERNAL(sta) (sta == TopAbs_INTERNAL)
#define M_EXTERNAL(sta) (sta == TopAbs_EXTERNAL)
#ifdef DRAW
#include <TopOpeBRepTool_DRAW.hxx>
#endif
#ifdef DEB
//Standard_IMPORT extern TopTools_IndexedMapOfShape STATIC_PURGE_mapv;
Standard_IMPORT TopTools_IndexedMapOfShape STATIC_PURGE_mapv;
//Standard_IMPORT extern TopTools_IndexedMapOfOrientedShape STATIC_PURGE_mapeds;
Standard_IMPORT TopTools_IndexedMapOfOrientedShape STATIC_PURGE_mapeds;
Standard_IMPORT Standard_Boolean TopOpeBRepTool_GettracePURGE();
Standard_EXPORT void FUN_REINIT()
{STATIC_PURGE_mapv.Clear(); STATIC_PURGE_mapeds.Clear();}
static void FUN_RaiseError()
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettracePURGE();
// Standard_Failure::Raise("TopOpeBRepTool::PurgeClosingEdges");
FUN_REINIT();
if (trc) cout <<"*********failure in TopOpeBRepTool::PurgeClosingEdges***********\n";
#endif
}
Standard_EXPORT Standard_Integer FUN_addepc(const TopoDS_Shape& ed,const TopoDS_Shape& f){
Standard_Integer ie = STATIC_PURGE_mapeds.Add(ed);
#ifdef DRAW
// TCollection_AsciiString aa = TCollection_AsciiString("pc_"); FUN_tool_draw(aa,TopoDS::Edge(ed),TopoDS::Face(f),ie);
// TCollection_AsciiString bb = TCollection_AsciiString("ed_"); FUN_tool_draw(bb,ed,ie);
#endif
return ie;
}
Standard_EXPORT Standard_Integer FUN_addcheckepc(const TopoDS_Shape& ed,const TopoDS_Shape& f) {
Standard_Integer ie = 0;
ie = STATIC_PURGE_mapeds.FindIndex(ed);
if (ie == 0) ie = FUN_addepc(ed,f);
return ie;
}
/*Standard_EXPORT Standard_Integer FUN_adds(const TopoDS_Shape& s) {
TopAbs_ShapeEnum typ = s.ShapeType();
TCollection_AsciiString aa; Standard_Integer is;
if (typ == TopAbs_VERTEX) {aa = TCollection_AsciiString("v_"); is = STATIC_PURGE_mapv.Add(s);}
#ifdef DRAW
Standard_Boolean trc = TopOpeBRepTool_GettracePURGE();
if (trc) FUN_tool_draw(aa,s,is);
#endif
return is;
}*/
Standard_IMPORT Standard_Integer FUN_adds(const TopoDS_Shape& s);
Standard_EXPORT void FUN_tool_tori(const TopAbs_Orientation Or)
{
switch (Or) {
case TopAbs_FORWARD:
cout<<"FOR";break;
case TopAbs_REVERSED:
cout<<"REV";break;
case TopAbs_INTERNAL:
cout<<"INT";break;
case TopAbs_EXTERNAL:
cout<<"EXT";break;
}
}
#endif
Standard_EXPORT void FUN_tool_trace(const Standard_Integer Index)
{if (Index == 1) cout <<"FORWARD ";
if (Index == 2) cout <<"REVERSED ";}
Standard_EXPORT void FUN_tool_trace(const gp_Pnt2d p2d)
{cout<<" = ("<<p2d.X()<<" "<<p2d.Y()<<")"<<endl;}
/*Standard_IMPORT Standard_Real FUN_tool_parOnE(const Standard_Integer Index,const TopoDS_Edge& E,const TopoDS_Face& F);
Standard_IMPORT void FUN_tool_addTomap
(const TopoDS_Shape& key,const TopoDS_Shape& elementOfitem,TopTools_DataMapOfShapeListOfShape& map,const Standard_Integer check);
Standard_IMPORT void FUN_tool_addTomap(const TopoDS_Shape& key,const TopoDS_Shape& elementOfitem,
TopTools_IndexedDataMapOfShapeListOfShape& map,const Standard_Integer check);
// ----------------------------------------------------------------------
Standard_EXPORT gp_Pnt2d FUN_GetVParonF(const TopoDS_Edge& E, const TopoDS_Face& F, const Standard_Integer Index)
// ----------------------------------------------------------------------
{
Standard_Real par = FUN_tool_parOnE(Index, E, F);
Standard_Real pf,pl,tol; Handle(Geom2d_Curve) PC = FUNTOOLC2D_CurveOnSurface(E,F,pf,pl,tol);
if (PC.IsNull()) Standard_Failure::Raise(" FUN_GetVParonF : no 2d curve");
gp_Pnt2d p2d; PC->D0(par,p2d);
return p2d;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Real FUN_toluv(const GeomAdaptor_Surface& GAS, const Standard_Real& tol3d)
// ----------------------------------------------------------------------
{
Standard_Real tolu = GAS.UResolution(tol3d);
Standard_Real tolv = GAS.VResolution(tol3d);
Standard_Real toluv = Max(tolu,tolv);
return toluv;
}
// ----------------------------------------------------------------------
Standard_EXPORT void FUN_tool_Vertices(const TopoDS_Edge& E, TopTools_Array1OfShape& vertices)
// ----------------------------------------------------------------------
{
// Returns vertices (F,R) if E is FORWARD
// (R,V) if E is REVERSED
TopAbs_Orientation oriE = E.Orientation();
TopoDS_Vertex vF, vR; TopExp::Vertices(E,vF,vR);
Standard_Integer iF, iR;
if (oriE == TopAbs_FORWARD) {iF = 1; iR = 2;}
else {iF = 2; iR = 1;}
vertices.ChangeValue(iF) = vF;
vertices.ChangeValue(iR) = vR;
}
// ----------------------------------------------------------------------
Standard_EXPORT void FUN_mapVloe(const TopoDS_Shape& F, TopTools_IndexedDataMapOfShapeListOfShape& mapVloe)
// ----------------------------------------------------------------------
{
mapVloe.Clear();
// TopExp::MapShapesAndAncestors(F,TopAbs_VERTEX,TopAbs_EDGE,mapVloe);
TopExp_Explorer exe(F, TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Shape e = exe.Current();
TopExp_Explorer exv(e, TopAbs_VERTEX);
for (; exv.More(); exv.Next()){
const TopoDS_Shape& v = exv.Current();
FUN_tool_addTomap(v, e, mapVloe, 0);
}
}
}*/
//======================================================================
/*Standard_EXPORT Standard_Boolean FUN_DetectEdgeswithfaultyUV
(const TopoDS_Face& Fin, const TopoDS_Shape& fF, const TopTools_ListOfShape& ISOEds,
const Standard_Boolean has2fybounds, TopTools_ListOfShape& lfyE, Standard_Integer& Ivfaulty,
const Standard_Boolean& stopatfirst=Standard_False)
// purpose : finding out edges <lfyE> / its UV rep. on <Fin>
// is unconnected to the other pcurves.
// if (has2fybounds), the 2 bounds of the pcurve are faulty.
// else : Ivfaulty is index of faulty vertex.
// return True if at least one edge is faulty
{
// <ISOEds> : list of pcurves to check among <fF>'s 2d rep. edges.
// <ISOEds> are edges of <fF>
lfyE.Clear();
Ivfaulty = 0; // dummy if has2faultybounds
TopTools_ListOfShape Eds;
TopExp_Explorer exe(fF, TopAbs_EDGE);
for (; exe.More(); exe.Next()) Eds.Append(exe.Current());
// <mapVloe> :
// ----------
// key = a vertex boundary of a closing edge,
// item = the list of edges connexed to the vertex.
TopTools_IndexedDataMapOfShapeListOfShape mapVloe; ::FUN_mapVloe(fF,mapVloe);
const Handle(Geom_Surface)& SU = BRep_Tool::Surface(Fin);
GeomAdaptor_Surface GAS(SU);
Standard_Real tttol = 1.e-8;
Standard_Real tttolF = BRep_Tool::Tolerance(Fin);
Standard_Real tttuvF = FUN_toluv(GAS,tttolF);
// fF's checking :
// -----------------
// An edge is valid if the first and last vertices are valid:
// vertex <vISOe> is valid if there is an edge with bound <ve> such that :
// <vISOe> and <ve> share same UV geometry
// <vISOe> and <ve> are of opposite orientation.
TopTools_ListIteratorOfListOfShape itISOEd(ISOEds);
for (; itISOEd.More(); itISOEd.Next()) {
const TopoDS_Edge& ISOe = TopoDS::Edge(itISOEd.Value());
TopAbs_Orientation oriISO = ISOe.Orientation();
if (M_INTERNAL(oriISO) || M_EXTERNAL(oriISO)) continue;
Standard_Real tttolISOe = BRep_Tool::Tolerance(ISOe);
Standard_Real tttuvISOe = FUN_toluv(GAS,tttolISOe);
TopTools_Array1OfShape vISOE(1,2); FUN_tool_Vertices(ISOe, vISOE);
Standard_Boolean closed = vISOE(1).IsSame(vISOE(2));
if (closed) continue; // closed edge is ass
Standard_Integer nfyv = 0;
for (Standard_Integer ivISOe = 1; ivISOe <=2; ivISOe++) {
// <vISOe> (boundary of <ISOe>):
const TopoDS_Vertex& vISOe = TopoDS::Vertex(vISOE(ivISOe));
gp_Pnt2d UVvISOe = FUN_GetVParonF(ISOe, Fin, ivISOe);
Standard_Real tttolvISOe = BRep_Tool::Tolerance(vISOe);
Standard_Real tttuvvISOe = FUN_toluv(GAS,tttolvISOe);
Standard_Boolean isbound = mapVloe.Contains(vISOe);
if (!isbound) {FUN_RaiseError(); return Standard_False;}
// <vISOeok> :
Standard_Boolean vISOeok = Standard_False;
const TopTools_ListOfShape& loe = mapVloe.FindFromKey(vISOe);
Standard_Integer nloe = loe.Extent();
for (TopTools_ListIteratorOfListOfShape ite(loe); ite.More(); ite.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(ite.Value());
if (E.IsSame(ISOe)) continue;
Standard_Real tttolE = BRep_Tool::Tolerance(E);
Standard_Real tttuvE = FUN_toluv(GAS,tttolE);
TopTools_Array1OfShape vE(1,2); FUN_tool_Vertices(E,vE);
for (Standard_Integer ive = 1; ive <=2; ive++) {
const TopoDS_Vertex& ve = TopoDS::Vertex(vE(ive));
Standard_Boolean samev = ve.IsSame(vISOe);
if (!samev) continue;
if (ive == ivISOe) continue;
gp_Pnt2d UVve = FUN_GetVParonF(E, Fin, ive);
Standard_Real tttolve = BRep_Tool::Tolerance(ve);
Standard_Real tttuvve = FUN_toluv(GAS,tttolve);
tttol = Max(tttol,Max(tttuvF,Max(tttuvE,Max(tttuvISOe,Max(tttuvve,tttuvvISOe)))));
Standard_Boolean isequal = UVvISOe.IsEqual(UVve,tttol);
if (isequal) {vISOeok = Standard_True; break;}
} // ive
if (vISOeok) break;
} // ite(loe)
if (!vISOeok) nfyv++;
Standard_Boolean stop = (!has2fybounds && (nfyv > 0));
if (stop) {
if (Ivfaulty == 0) Ivfaulty = ivISOe;//xpu121098 (cto900J4,f4ou) : first faulty edge
break;
}
} // ivISOe = 1..2
Standard_Boolean found = has2fybounds && (nfyv == 2);
found = found || (!has2fybounds && (nfyv == 1));
if (found) {
lfyE.Append(ISOe);
}
}
Standard_Integer n = lfyE.Extent();
Standard_Boolean det = (n != 0);
return det;
} // FUN_DetectEdgeswithfaultyUV
Standard_EXPORT Standard_Boolean FUN_DetectEdgewithfaultyUV
(const TopoDS_Face& Fin, const TopoDS_Shape& fF, const TopTools_ListOfShape& ISOEds,
const Standard_Boolean has2fybounds, TopoDS_Shape& fyE, Standard_Integer& Ivfaulty)
// purpose : finding out first edge <fyE> / its UV rep. on <Fin>
// is unconnected to the other pcurves.
// if (has2fybounds), the 2 bounds of the pcurve are faulty.
// else : Ivfaulty is index of faulty vertex.
// return True if at least one edge is faulty
{
// <ISOEds> : list of pcurves to check among <fF>'s 2d rep. edges.
// <ISOEds> are edges of <fF>
TopTools_ListOfShape lfyE;
Standard_Boolean det = FUN_DetectEdgeswithfaultyUV(Fin,fF,ISOEds,has2fybounds,lfyE,Ivfaulty);
if (det) fyE = lfyE.First();
return det;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_DetectFaultyClosingEdge
(const TopoDS_Face& Fin,const TopTools_ListOfShape& Eds,const TopTools_ListOfShape& cEds,TopTools_ListOfShape& fyE)
// ----------------------------------------------------------------------
{
#ifdef DEB
Standard_Boolean trc = TopOpeBRepTool_GettracePURGE();
for (TopTools_ListIteratorOfListOfShape it(Eds); it.More(); it.Next()){
const TopoDS_Shape& ed = it.Value();
TopExp_Explorer ex;
for (ex.Init(ed, TopAbs_VERTEX); ex.More(); ex.Next())
// for (TopExp_Explorer ex(ed, TopAbs_VERTEX); ex.More(); ex.Next())
FUN_adds(ex.Current());}
#endif
// <cEds> and <Eds> are the lists of closed and non-"closing" edges
// describing a wire boundary on face <Fin>.
// ("closing" edge = edge built on the geometry of a closing edge of <Fin> )
// If <W> has UV non-connexed edges, returns <True> if <fyE> is the list of faulty cEds
// fyE = {e / e has its 2 bounds non-UVconnexed}
// Returns <False> elsewhere.
// prequesitory : wire <W> is 3d-connexed, so a faulty edge must be a
// closing edge.
// <mapVloe> :
// ----------
// key = a vertex boundary of a closing edge,
// item = the list of edges connexed to the vertex.
TopTools_DataMapOfShapeListOfShape mapVloe;
for (TopTools_ListIteratorOfListOfShape itEd(Eds); itEd.More(); itEd.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(itEd.Value());
TopExp_Explorer ex;
for (ex.Init(E, TopAbs_VERTEX); ex.More(); ex.Next()) {
// for (TopExp_Explorer ex(E, TopAbs_VERTEX); ex.More(); ex.Next()) {
const TopoDS_Shape& v = ex.Current();
FUN_tool_addTomap(v, E, mapVloe, 0);
}
}
const Handle(Geom_Surface)& SU = BRep_Tool::Surface(TopoDS::Face(Fin));
GeomAdaptor_Surface GAS(SU);
Standard_Real tttol = 1.e-8;
Standard_Real tttolF = BRep_Tool::Tolerance(TopoDS::Face(Fin));
Standard_Real tttuvF = FUN_toluv(GAS,tttolF);
Standard_Boolean uclosed,vclosed; Standard_Real uperiod,vperiod;
Standard_Boolean uvclosed = FUN_tool_closedS(Fin,uclosed,uperiod,vclosed,vperiod);
// wire's checking :
// -----------------
// An edge is valid if the first and last vertices are valid:
// vertex <vce> is valid if there is an edge with bound <ve> verifying :
// <vce> and <ve> share same UV geometry
// <vce> and <ve> are of opposite orientation.
TopTools_ListIteratorOfListOfShape itCEd(cEds);
for (; itCEd.More(); itCEd.Next()) {
const TopoDS_Edge& cE = TopoDS::Edge(itCEd.Value());
Standard_Boolean isou,isov; gp_Pnt2d o2d; gp_Dir2d d2d;
Standard_Real f,l,tol; Handle(Geom2d_Curve) PC = FUNTOOLC2D_CurveOnSurface(cE,Fin,f,l,tol);
Standard_Boolean isouv = FUN_tool_IsUViso(PC,isou,isov,d2d,o2d);
#ifdef DEB
Standard_Integer icE = FUN_addcheckepc(cE,Fin);
if (trc) {cout<<"closing edge "<<icE<<" "; TopAbs::Print(cE.Orientation(),cout);
cout<<" : \n";}
#endif
Standard_Real tttolcE = BRep_Tool::Tolerance(cE);
Standard_Real tttuvcE = FUN_toluv(GAS,tttolcE);
Standard_Boolean cEKO = Standard_True;
TopTools_Array1OfShape vcE(1,2); FUN_tool_Vertices(cE, vcE);
for (Standard_Integer ivce = 1; ivce <=2; ivce++) {
// <vce> (boundary of <cE>):
const TopoDS_Vertex& vce = TopoDS::Vertex(vcE(ivce));
gp_Pnt2d UVvce = FUN_GetVParonF(cE, Fin, ivce);
#ifdef DEB
// recall in one wire, there are 2 vertices for one non-degenerated closing edge
Standard_Integer ivmapv = STATIC_PURGE_mapv.Add(vce);
if (trc) {
cout<<"v"<<ivmapv<<" ";FUN_tool_trace(ivce);cout<<" in closing edge "<<icE;
FUN_tool_trace(UVvce);
#ifdef DRAW
TCollection_AsciiString bb("uv_");bb += TCollection_AsciiString(ivmapv);FUN_tool_draw(bb,UVvce);
#endif
}
#endif
Standard_Real tttolvce = BRep_Tool::Tolerance(vce);
Standard_Real tttuvvce = FUN_toluv(GAS,tttolvce);
Standard_Boolean isbound = mapVloe.IsBound(vce);
if (!isbound) continue; //xpu201198 cto016E2 (e3on)
// <vceok> :
Standard_Boolean vceok = Standard_False;
const TopTools_ListOfShape& loe = mapVloe.Find(vce);
Standard_Integer nloe = loe.Extent();
#ifdef DRAW
Standard_Boolean tdr = Standard_False;
if (tdr) {
Standard_Integer inde = 1;
for (TopTools_ListIteratorOfListOfShape ite(loe); ite.More(); ite.Next()) {
const TopoDS_Shape& eee = ite.Value(); FUN_drawe(eee,inde); inde++;
}
}
#endif
for (TopTools_ListIteratorOfListOfShape ite(loe); ite.More(); ite.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(ite.Value());
// if (E.IsSame(cE)) continue; // closing FORWARD and REVERSED EDGES are UV disjoint
#ifdef DEB
Standard_Integer iE = FUN_addcheckepc(E,Fin);
#endif
Standard_Real tttolE = BRep_Tool::Tolerance(E);
Standard_Real tttuvE = FUN_toluv(GAS,tttolE);
TopTools_Array1OfShape vE(1,2); FUN_tool_Vertices(E,vE);
for (Standard_Integer ive = 1; ive <=2; ive++) {
const TopoDS_Vertex& ve = TopoDS::Vertex(vE(ive));
Standard_Boolean samev = ve.IsSame(vce);
if (!samev) continue;
if (ive == ivce) continue;
gp_Pnt2d UVve = FUN_GetVParonF(E, Fin, ive);
Standard_Real tttolve = BRep_Tool::Tolerance(ve);
Standard_Real tttuvve = FUN_toluv(GAS,tttolve);
tttol = Max(tttol,Max(tttuvF,Max(tttuvE,Max(tttuvcE,Max(tttuvve,tttuvvce)))));
// Standard_Boolean isequal = UVvce.IsEqual(UVve,tttol);
Standard_Real dd=0., xperiod=0.;
if (uclosed && isou) {dd = UVve.X()-UVvce.X(); xperiod = uperiod;}
if (vclosed && isov) {dd = UVve.Y()-UVvce.Y(); xperiod = vperiod;}
Standard_Boolean xok = (Abs(dd)<tttol) || (Abs(Abs(dd)-xperiod)<tttol);
Standard_Boolean isequal = xok;
if (isequal) {
vceok = Standard_True;
#ifdef DEB
if (trc)
{cout<<"vertex ";FUN_tool_trace(ivce);cout<<" of closing edge "<<icE;
cout<<" is connexed to vertex ";FUN_tool_trace(ive);cout<<" of edge "<<iE<<endl;}
#endif
}
break;
} // ive
if (vceok) break;
} // ite(loe)
#ifdef DEB
if (trc && !vceok) {cout<<" vertex ";FUN_tool_trace(ivce);
cout<<"of closing edge "<<icE<<" is faulty"<<endl;}
#endif
cEKO = cEKO && (!vceok);
} // ivce
#ifdef DEB
if (trc) {if (!cEKO) cout<<"-> valid edge"<<endl;
else cout<<"-> faulty edge"<<endl;}
#endif
if (cEKO) {fyE.Append(cE);}
}
return (!fyE.IsEmpty());
}
Standard_EXPORT Standard_Boolean FUN_isUVClosed(const TopoDS_Face& Fin, const TopoDS_Face& fF)
// purpose : returns true is fF is UV connexed
{
TopTools_ListOfShape efF;
TopExp_Explorer ex(fF, TopAbs_EDGE);
for (; ex.More(); ex.Next()) efF.Append(ex.Current());
Standard_Integer Ivfaulty; TopTools_ListOfShape lfyE; Standard_Boolean stopatfirst = Standard_True;
Standard_Boolean foundfaulty = FUN_DetectEdgeswithfaultyUV(Fin,fF,efF,Standard_False,lfyE,Ivfaulty,stopatfirst);
return !foundfaulty;
}*/

View File

@@ -0,0 +1,72 @@
-- File: TopOpeBRepTool_makeTransition.cdl
-- Created: Thu Feb 11 11:41:08 1999
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class makeTransition from TopOpeBRepTool
uses
Pnt2d from gp,
Edge from TopoDS,
Face from TopoDS,
State from TopAbs
is
Create returns makeTransition from TopOpeBRepTool;
Initialize(me : in out;
E : Edge from TopoDS; pbef,paft,parE : Real;
FS : Face from TopoDS; uv : Pnt2d from gp;
factor : Real)
returns Boolean;
-- <E> interfers with <FS> at point :
-- Pt(parE,E) = Pt(uv,FS)
-- <pbef>,<paft> greater and lower <parE>.
Setfactor(me : in out; factor : Real); -- 0 < factor < 1
Getfactor(me) returns Real;
IsT2d(me) returns Boolean;
SetRest(me : in out;
ES : Edge from TopoDS; parES : Real)
returns Boolean;
-- Pt(parES,ES) = Pt(uv,FS)
-- Transition is computed vs <ES>, restrition on <FS>
HasRest(me) returns Boolean;
MkT2donE(me; stb,sta : out State from TopAbs)
returns Boolean;
-- returns false if (!isT2d)
-- computes transition on <myE>, using tangent vectors.
MkT3onE(me; stb,sta : out State from TopAbs)
returns Boolean;
-- returns false if (isT2d)
-- return states in/out/on
MkT3dproj(me; stb,sta : out State from TopAbs)
returns Boolean;
-- using projections.
-- return states in/out/on
MkTonE(me : in out; stb,sta : out State from TopAbs)
returns Boolean;
-- Compute for <T> = transition on <E> vs <FS>.
-- return states in/out/on.
-- modifies field myfactor.
fields
myE : Edge from TopoDS;
mypb,mypa,mypE : Real;
myFS : Face from TopoDS;
myuv : Pnt2d from gp;
hasES : Boolean;
myES : Edge from TopoDS;
mypES : Real;
isT2d : Boolean;
myfactor : Real;
end makeTransition;

View File

@@ -0,0 +1,600 @@
// File: TopOpeBRepTool_makeTransition.cxx
// Created: Thu Feb 11 12:30:17 1999
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_makeTransition.ixx>
#include <TopOpeBRepTool_define.hxx>
#include <BRep_Tool.hxx>
#include <Precision.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#define BEFORE (1)
#define AFTER (2)
#define isINifh1 (1)
#define isINifh2 (2)
#define isON2 (21)
#define isON2ifss (10)
#define isIN2ifss (11)
#define isOU2ifss (12)
#define INFFIRST (-1)
#define SUPLAST (-2)
#define ONFIRST (1)
#define ONLAST (2)
#define FORWARD (1)
#define REVERSED (2)
#define INTERNAL (3)
#define EXTERNAL (4)
#define CLOSING (5)
#define M_ON(sta) (sta == TopAbs_ON)
#define M_IN(sta) (sta == TopAbs_IN)
#define M_FORWARD(sta) (sta == TopAbs_FORWARD)
#define M_REVERSED(sta) (sta == TopAbs_REVERSED)
#define M_INTERNAL(sta) (sta == TopAbs_INTERNAL)
#define M_EXTERNAL(sta) (sta == TopAbs_EXTERNAL)
#define M_UNKNOWN(sta) (sta == TopAbs_UNKNOWN)
static Standard_Real FUN_tolang()
{
return Precision::Angular()*1.e6;//=1.e-6 NYITOLXPU
}
//=======================================================================
//function : TopOpeBRepTool_makeTransition
//purpose :
//=======================================================================
TopOpeBRepTool_makeTransition::TopOpeBRepTool_makeTransition()
{
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::Initialize
(const TopoDS_Edge& E,const Standard_Real pbef,const Standard_Real paft,const Standard_Real parE,
const TopoDS_Face& FS, const gp_Pnt2d& uv,
const Standard_Real factor)
{
Standard_Boolean isdge = BRep_Tool::Degenerated(E);
if (isdge) return Standard_False;
myE = E;
mypb = pbef; mypa = paft; mypE = parE;
myFS = FS; myuv = uv;
myfactor = factor;
hasES = Standard_False;
Standard_Boolean facko = (factor < 0.) || (factor > 1.);
if (facko) return Standard_False;
Standard_Boolean ok = TopOpeBRepTool_TOOL::EdgeONFace(mypE,myE,myuv,FS,isT2d);
return ok;
}
//=======================================================================
//function : Setfactor
//purpose :
//=======================================================================
void TopOpeBRepTool_makeTransition::Setfactor(const Standard_Real factor)
{
myfactor = factor;
}
//=======================================================================
//function : Getfactor
//purpose :
//=======================================================================
Standard_Real TopOpeBRepTool_makeTransition::Getfactor() const
{
return myfactor;
}
//=======================================================================
//function : IsT2d
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::IsT2d() const
{
return isT2d;
}
//=======================================================================
//function : SetRest
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::SetRest(const TopoDS_Edge& ES, const Standard_Real parES)
{
Standard_Boolean isdge = BRep_Tool::Degenerated(ES);
if (isdge) return Standard_False;
hasES = Standard_True;
myES = ES;
mypES = parES;
// nyi check <ES> is edge of <myFS>
return Standard_True;
}
//=======================================================================
//function : HasRest
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::HasRest() const
{
return hasES;
}
static Standard_Boolean FUN_nullcurv(const Standard_Real curv)
{
Standard_Real tol = Precision::Confusion()*1.e+2;//NYITOLXPU
return (curv < tol);
}
static Standard_Integer FUN_mkT2dquad(const Standard_Real curvC1, const Standard_Real curvC2)
{
// !!! only for quadratic geometries :
// prequesitory : C1 and C2 are ON given plane; they are tangent
// at point pt, where curvatures are respectively curvC1,curvC2
// stb = state of point on C1 before pt / C2
// = sta = state of point on C1 after pt / C2
Standard_Boolean nullc1 = FUN_nullcurv(curvC1);
Standard_Boolean nullc2 = FUN_nullcurv(curvC2);
if (nullc2 && nullc1) return isON2;
if (nullc2) return isINifh1;//is IN if (dot=tg1(pt after).xx2 > 0)
if (nullc1) return isINifh2;//is IN if (dot=tg2(pt after).xx2 < 0)
Standard_Boolean samec = (Abs(curvC2-curvC1) < 1.e-2); //NYITOLXPU kpartkoletge
if (samec) return isON2ifss;//is ON if curves are on same side/tg line
if (curvC1 > curvC2) return isIN2ifss;//is IN if curves are on same side/tg line
else return isOU2ifss;//is OU if curves are on same side/tg line
return 0;
}
static Standard_Boolean FUN_getnearpar(const TopoDS_Edge& e,const Standard_Real par,const Standard_Real f,const Standard_Real l,
const Standard_Real factor,const Standard_Integer sta, Standard_Real& nearpar)
{
// hyp : f < par < l
BRepAdaptor_Curve bc(e);
Standard_Real tol1d = bc.Resolution( bc.Tolerance() );
Standard_Boolean onf = (Abs(par-f) < tol1d);
Standard_Boolean onl = (Abs(par-l) < tol1d);
if (onf && (sta == BEFORE)) return Standard_False;
if (onl && (sta == AFTER)) return Standard_False;
//nearpar = (sta == BEFORE) ? ((1-factor)*par - factor*f) : ((1-factor)*par - factor*l);
nearpar = (sta == BEFORE) ? (par - factor*(l-f)) : (par + factor*(l-f));
return Standard_True;
}
static Standard_Boolean FUN_tg(const TopoDS_Edge& e,const Standard_Real par,const Standard_Real f,const Standard_Real l,const Standard_Real factor,
gp_Dir& tg, Standard_Integer& st)
{
st = BEFORE;
for (Standard_Integer nite = 1; nite <= 2; nite++) {
if (nite == 2) st = AFTER;
Standard_Real pn; Standard_Boolean mkp = FUN_getnearpar(e,par,f,l,factor,st,pn);
if (!mkp) continue;
gp_Vec tmp; Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(pn,e,tmp);
if (!ok) continue;
tg = gp_Dir(tmp);
return Standard_True;
}
return Standard_False;
}
static Standard_Boolean FUN_getsta(const Standard_Integer mkt,const gp_Dir& tga1,const gp_Dir& tga2,const gp_Dir& xx2,
TopAbs_State& sta)
{
if (mkt == isINifh1) {
// curv(e1) > 0.
//is IN if (dot=tg1(pt after).xx2 > 0)
Standard_Real dot = tga1.Dot(xx2);
sta = (dot > 0) ? TopAbs_IN : TopAbs_OUT;
return Standard_True;
}
else if (mkt == isINifh2) {
// curv(e2) > 0.
//is IN if (dot=tg2(pt after).xx2 < 0)
Standard_Real dot = tga2.Dot(xx2);
sta = (dot < 0) ? TopAbs_IN : TopAbs_OUT;
return Standard_True;
}
else if (mkt == isON2ifss) {
// curv(e1), curv(e2) > 0.
//is ON if curves are on same side/tg line
Standard_Boolean ssided = (tga1.Dot(tga2) > 0);
sta = ssided ? TopAbs_ON : TopAbs_IN;
return Standard_True;
}
else if (mkt == isIN2ifss) {
//stag = IN if curves are on same side/tg line
Standard_Real dot = tga1.Dot(xx2);
sta = (dot < 0) ? TopAbs_OUT : TopAbs_IN;
return Standard_True;
}
else if (mkt == isOU2ifss) {
//stag = OU if curves are on same side/tg line
Standard_Real dot = tga2.Dot(xx2);
sta = (dot < 0) ? TopAbs_IN : TopAbs_OUT;
return Standard_True;
}
else {//mkt == isON2
sta = TopAbs_ON;
return Standard_True;
}
return Standard_False;
}
static Standard_Boolean FUN_mkT2dquad(const TopoDS_Edge& e1,const Standard_Real par1,const Standard_Real f1,const Standard_Real l1,
const TopoDS_Edge& e2,const Standard_Real par2,
const Standard_Integer mkt,const gp_Dir& xx2,const Standard_Real factor,
TopAbs_State& sta)
{
sta = TopAbs_UNKNOWN;
// !!! only for quadratic geometries :
// stb = state of point on e1 before pt / e2
// = sta = state of point on e1 after pt / e2
gp_Dir tga1,tga2;
Standard_Boolean mk1 = isINifh1 || isON2ifss || isIN2ifss;
if (mk1) {
Standard_Integer st1 = 0; gp_Dir tgnear1;
Standard_Boolean ok = FUN_tg(e1,par1,f1,l1,factor,tgnear1,st1);
if (!ok) return Standard_False;
tga1 = (st1 == AFTER) ? tgnear1 : tgnear1.Reversed();
}
Standard_Boolean mk2 = isINifh2 || isON2ifss || isOU2ifss;
if (mk2) {
Standard_Real f2,l2; FUN_tool_bounds(e2,f2,l2);
Standard_Integer st2 = 0; gp_Dir tgnear2;
Standard_Boolean ok = FUN_tg(e2,par2,f2,l2,factor,tgnear2,st2);
if (!ok) return Standard_False;
tga2 = (st2 == AFTER) ? tgnear2 : tgnear2.Reversed();
}
return (FUN_getsta(mkt,tga1,tga2,xx2, sta));
}
//=======================================================================
//function : MkT2donE
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::MkT2donE(TopAbs_State& Stb,TopAbs_State& Sta) const
{
if (!isT2d) return Standard_False;
// E is IN 2d(FS), meets no restriction at given point :
if (!hasES) {Stb = Sta = TopAbs_IN; return Standard_True;}
// E is IN 2d(FS), meets restriction ES at given point :
Standard_Integer oriESFS = TopOpeBRepTool_TOOL::OriinSor(myES,myFS, Standard_True);
if (oriESFS == 0) return Standard_False;
// ES is closing edge for FS, or ES is INTERNAL in FS :
if (oriESFS == INTERNAL) {Stb = Sta = TopAbs_IN; return Standard_True;}
else if (oriESFS == CLOSING) {Stb = Sta = TopAbs_IN; return Standard_True;}
gp_Vec tmp; Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(mypE,myE,tmp);
if (!ok) return Standard_False;
gp_Dir tgE(tmp);
gp_Dir xxES; ok = TopOpeBRepTool_TOOL::XX(myuv,myFS, mypES,myES, xxES);
if (!ok) return Standard_False;
Standard_Real tola = FUN_tolang();
Standard_Real dot = tgE.Dot(xxES);
// E and ES are not tangent at interference point :
Standard_Boolean tgts = (Abs(dot) < tola);
if (!tgts) {
Standard_Boolean dotpos = (dot > 0.);
if (dotpos) {Stb = TopAbs_OUT; Sta = TopAbs_IN;}
else {Stb = TopAbs_IN; Sta = TopAbs_OUT;}
return Standard_True;
}
// E and ES are tangent, curves are quadratic :transition is INTERNAL/EXTERNAL,
// elsewhere : transition is FOR/REV/INT/EXT
// we then use curvatures to compute transition T :
// xpu090299 PRO13455(E=e7, ES=e9, FS=f11)
gp_Dir ntFS; ok = TopOpeBRepTool_TOOL::Nt(myuv,myFS,ntFS);
if (!ok) return Standard_False;
Standard_Real curvE; ok = TopOpeBRepTool_TOOL::CurvE(myE,mypE,ntFS,curvE);
if (!ok) return Standard_False;
Standard_Real curvES; ok = TopOpeBRepTool_TOOL::CurvE(myES,mypES,ntFS,curvES);
if (!ok) return Standard_False;
Standard_Boolean quadE = TopOpeBRepTool_TOOL::IsQuad(myE);
Standard_Boolean quadES = TopOpeBRepTool_TOOL::IsQuad(myES);
if (quadE && quadES) { // should return INT/EXT
TopAbs_State sta = TopAbs_UNKNOWN;
Standard_Integer mkt = FUN_mkT2dquad(curvE,curvES);
Standard_Boolean ok = FUN_mkT2dquad(myE,mypb,mypa,mypE, myES,mypES, mkt,xxES,myfactor,sta);
if (ok) {
Stb = Sta = sta;
return Standard_True;
}
}
// !!!NYI: general case :
// ----------------------
// NYIKPART quadquad, only one state
return Standard_False;
}
static Standard_Boolean FUN_getnearuv(const TopoDS_Face& f,const gp_Pnt2d& uv,
const Standard_Real factor,const Standard_Integer sta,const gp_Dir2d& duv,
gp_Pnt2d& nearuv)
{
BRepAdaptor_Surface bs(f);
gp_Vec2d xuv = gp_Vec2d(duv).Multiplied(factor);
if (sta == BEFORE) xuv.Reverse();
nearuv = uv.Translated(xuv) ;
Standard_Integer onu,onv; TopOpeBRepTool_TOOL::stuvF(uv,f, onu,onv);
Standard_Boolean uok = (onu == 0);
Standard_Boolean vok = (onv == 0);
if (uok && vok) return Standard_True;
Standard_Real nearu = nearuv.X(), nearv = nearuv.Y();
if ((onu == INFFIRST)||(onu == SUPLAST)) {
Standard_Boolean ucl = bs.IsUClosed();
if (!ucl) return Standard_False;
Standard_Real uper = bs.UPeriod();
if (onu == INFFIRST) nearu += uper;
else nearu -= uper;
}
if ((onv == INFFIRST)||(onv == SUPLAST)) {
Standard_Boolean vcl = bs.IsVClosed();
if (!vcl) return Standard_False;
Standard_Real vper = bs.VPeriod();
if (onv == INFFIRST) nearv += vper;
else nearv -= vper;
}
nearuv = gp_Pnt2d(nearu,nearv);
return Standard_True;
}//FUN_getnearuv
static Standard_Boolean FUN_tgef(const TopoDS_Face& f,
const gp_Pnt2d& uv,
const gp_Dir2d& duv,
const Standard_Real factor,
// const gp_Dir& tge,
const gp_Dir& ,
const gp_Dir& tg0,
gp_Dir& tgef,
Standard_Integer& st)
{
st = BEFORE;
for (Standard_Integer nite = 1; nite <= 2; nite++) {
if (nite == 2) st = AFTER;
gp_Pnt2d nearuv;
// Standard_Real pn;
Standard_Boolean mkp = FUN_getnearuv(f,uv,factor,st,duv, nearuv);
if (!mkp) continue;
gp_Dir nt; Standard_Boolean ok = TopOpeBRepTool_TOOL::Nt(nearuv,f,nt);
if (!ok) return Standard_False;
// recall : ntf^tge = tg0, (tgef(uv) = tge)
// => near interference point, we assume nt^tgef(nearuv) = tg0
tgef = tg0.Crossed(nt);
return Standard_True;
}
return Standard_False;
}//FUN_tgef
static Standard_Boolean FUN_mkT3dquad(const TopoDS_Edge& e,const Standard_Real pf,const Standard_Real pl,const Standard_Real par,
const TopoDS_Face& f,const gp_Pnt2d& uv,
const gp_Dir& tge,const gp_Dir& ntf,
const Standard_Integer mkt,const Standard_Real factor, TopAbs_State& sta)
{
// stb = state of point on e before pt / ef
// = sta = state of point on e after pt / ef
sta = TopAbs_UNKNOWN;
gp_Dir xxef = ntf.Reversed();
gp_Dir tg0 = ntf.Crossed(tge);
gp_Dir tgae,tgaef;
Standard_Boolean mke = (mkt==isINifh1) || (mkt==isON2ifss) || (mkt==isIN2ifss);
if (mke) {
Standard_Integer st = 0; gp_Dir tgnear; Standard_Boolean ok = FUN_tg(e,par,pf,pl,factor,tgnear,st);
if (!ok) return Standard_False;
tgae = (st == AFTER) ? tgnear : tgnear.Reversed();
}
Standard_Boolean mkef = (mkt==isINifh2) || (mkt==isON2ifss) || (mkt==isOU2ifss);
if (mkef) {
// choice : tgdir(ef,uv) = tgdir(e,pare)
Standard_Real fac3d = 0.01; //0.12345; not only planar faces
gp_Dir2d duv; Standard_Boolean ok = TopOpeBRepTool_TOOL::Getduv(f,uv,tge,fac3d, duv);
if (!ok) return Standard_False;
gp_Dir tgnear; Standard_Integer st = 0; ok = FUN_tgef(f,uv,duv,factor, tge,tg0, tgnear,st);
if (!ok) return Standard_False;
tgaef = (st == AFTER) ? tgnear : tgnear.Reversed();
}
return (FUN_getsta(mkt,tgae,tgaef,xxef, sta));
}
static TopAbs_State FUN_stawithES(const gp_Dir& tgE,const gp_Dir& xxES,const Standard_Integer st)
{
// prequesitory : FS and E are tangent at interference point
// ---------------------------------------------------------
// xxES : normal to ES oriented INSIDE 2d(FS)
// tgE : tangent to E at Pt
// pt(st,E) (st=BEFORE,AFTER) has been found IN 3dFS()
TopAbs_State sta;
Standard_Real prod = tgE.Dot(xxES);
Standard_Real tola = FUN_tolang();
if (Abs(prod) < tola) return TopAbs_UNKNOWN;
Standard_Boolean positive = (prod > 0.);
if (positive) sta = (st == BEFORE) ? TopAbs_OUT : TopAbs_IN; //T.Set(TopAbs_FORWARD);
else sta = (st == BEFORE) ? TopAbs_IN : TopAbs_OUT;//T.Set(TopAbs_REVERSED);
// sta = (iP == BEFORE) ? T.Before() : T.After();
return sta;
}//FUN_stawithES
static TopAbs_State FUN_stawithES(const gp_Dir& tgE,const gp_Dir& xxES,const Standard_Integer st,const TopAbs_State stt)
{
TopAbs_State str = TopAbs_UNKNOWN;
if (M_UNKNOWN(stt)) return str;
TopAbs_State stES = FUN_stawithES(tgE,xxES,st);
// we keep statx as IN or ON if xwithline is IN
if (M_IN(stt) || M_ON(stt)) str = M_IN(stES) ? stt : TopAbs_OUT;
return str;
}
static Standard_Boolean FUN_staproj(const TopoDS_Edge& e,const Standard_Real pf,const Standard_Real pl,const Standard_Real pe,
const Standard_Real factor, const Standard_Integer st, const TopoDS_Face& f,
TopAbs_State& sta)
{
Standard_Real par;Standard_Boolean ok = FUN_getnearpar(e,pe,pf,pl,factor,st, par);
if (!ok) return Standard_False;
gp_Pnt pt; ok = FUN_tool_value(par,e, pt);
if (!ok) return Standard_False;
gp_Pnt2d uv; ok = TopOpeBRepTool_TOOL::Getstp3dF(pt,f,uv,sta);
return ok;
}
//=======================================================================
//function : MkT3dproj
//purpose : can return in,out,on
//=======================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::MkT3dproj(TopAbs_State& Stb,TopAbs_State& Sta) const
{
Stb = Sta = TopAbs_UNKNOWN;
Standard_Boolean okb = FUN_staproj(myE,mypb,mypa,mypE, myfactor,BEFORE,myFS, Stb);
if (!okb) return Standard_False;
Standard_Boolean oka = FUN_staproj(myE,mypb,mypa,mypE, myfactor,AFTER,myFS, Sta);
if (!oka) return Standard_False;
return Standard_True;
}
//=======================================================================
//function : MkT3donE
//purpose :
// <myE> is tangent to <myFS> at point P = Pt(<myuv>,<myFS>) = Pt(<mypE>,<myE>)
// <tgE> = E's tangent at P,
// <ntF> = <F>'s topological normal at P.
// These define a plane Pln = (O = P, XY = (<ntF>,<tgE>)),
// the projection of <F> in Pln describes an bounding edge eF in 2dspace(Pln)
// In thePlane :
// P -> myuv
// <ntF> -> 2d axis x
// <tgE> -> 2d axis y
// ================================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::MkT3onE(TopAbs_State& Stb,TopAbs_State& Sta) const
{
if (isT2d) return Standard_False;
gp_Vec tmp; Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(mypE,myE,tmp);
if (!ok) return Standard_False;
gp_Dir tgE(tmp);
gp_Dir ntFS; ok = TopOpeBRepTool_TOOL::Nt(myuv,myFS,ntFS);
if (!ok) return Standard_False;
Standard_Real tola = FUN_tolang();
Standard_Real dot = tgE.Dot(ntFS);
if (Abs(dot) > tola) {
Stb = (dot > 0) ? TopAbs_IN : TopAbs_OUT;
Sta = (dot > 0) ? TopAbs_OUT : TopAbs_IN;
// TopAbs_Orientation oE = (dot > 0) ? TopAbs_REVERSED : TopAbs_FORWARD;
// T.Set(oE);
return Standard_True;
}
//E is tangent to FS at interference point
gp_Dir tg0 = ntFS.Crossed(tgE);
Standard_Real curE; ok = TopOpeBRepTool_TOOL::CurvE(myE,mypE,tg0, curE);
if (!ok) return Standard_False;
Standard_Real curFS; Standard_Boolean direct; ok = TopOpeBRepTool_TOOL::CurvF(myFS,myuv,tg0, curFS,direct);
if (!ok) return Standard_False;
Standard_Boolean quadE = TopOpeBRepTool_TOOL::IsQuad(myE);
Standard_Boolean quadFS = TopOpeBRepTool_TOOL::IsQuad(myFS);
if (quadE && quadFS) { // should return INT/EXT
Standard_Integer mkt = FUN_mkT2dquad(curE,curFS);
TopAbs_State sta = TopAbs_UNKNOWN;
ok = FUN_mkT3dquad(myE,mypb,mypa,mypE, myFS,myuv, tgE,ntFS, mkt,myfactor,sta);
if (ok) {
if (hasES) {
gp_Dir xxES; Standard_Boolean ok = TopOpeBRepTool_TOOL::XX(myuv,myFS, mypES,myES, xxES);
if (!ok) return Standard_False;
Stb = FUN_stawithES(tgE,xxES,BEFORE,sta);
Sta = FUN_stawithES(tgE,xxES,AFTER,sta);
}
else {
Stb = Sta = sta;
}
return Standard_True;
}
}
// NYIGENERALCASE;
// NYIKPART quadquad, only one state
return Standard_False;
}
//=======================================================================
//function : MkTonE
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_makeTransition::MkTonE(TopAbs_State& Stb,TopAbs_State& Sta)
{
Stb = Sta = TopAbs_UNKNOWN;
if (isT2d) return (MkT2donE(Stb,Sta));
Standard_Boolean ok = MkT3onE(Stb,Sta);
if (!ok) ok = MkT3dproj(Stb, Sta);
// if (!ok) return Standard_False;
gp_Vec tmp; ok = TopOpeBRepTool_TOOL::TggeomE(mypE,myE,tmp);
if (!ok) return Standard_False;
gp_Dir tgE(tmp);
gp_Dir xxES;
if (hasES && ok) {ok = TopOpeBRepTool_TOOL::XX(myuv,myFS, mypES,myES, xxES);
if (!ok) return Standard_False;}
Standard_Real delta = (1. - myfactor)/5.;
Standard_Boolean kob=Standard_False, koa=Standard_False;
for (Standard_Integer nite = 1; nite <= 5; nite++) {
kob = (Stb == TopAbs_ON)||(Stb == TopAbs_UNKNOWN);
koa = (Sta == TopAbs_ON)||(Sta == TopAbs_UNKNOWN);
if (!koa && !kob) return Standard_True;
Standard_Boolean okb=Standard_True, oka=Standard_True;
if (kob) {
okb = FUN_staproj(myE,mypb,mypa,mypE, myfactor,BEFORE,myFS, Stb);
if (okb && hasES) {TopAbs_State stb = Stb; Stb = FUN_stawithES(tgE,xxES,BEFORE,stb);}
}
if (koa) {
oka = FUN_staproj(myE,mypb,mypa,mypE, myfactor,AFTER,myFS, Sta);
if (oka && hasES) {TopAbs_State sta = Sta; Sta = FUN_stawithES(tgE,xxES,AFTER,sta);}
}
myfactor += delta;
}//nite=1..5
return Standard_False;
}

View File

@@ -0,0 +1,155 @@
// File: TopOpeBRepTool_matter.cxx
// Created: Fri Nov 20 10:35:10 1998
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <gp_Dir.hxx>
#include <gp_Dir2d.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt2d.hxx>
#include <BRep_Tool.hxx>
#include <TopOpeBRepTool_define.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#define M_FORWARD(ori) (ori == TopAbs_FORWARD)
#define M_REVERSED(ori) (ori == TopAbs_REVERSED)
#define M_INTERNAL(ori) (ori == TopAbs_INTERNAL)
#define M_EXTERNAL(ori) (ori == TopAbs_EXTERNAL)
// ----------------------------------------------------------------------
// oriented vectors :
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
Standard_EXPORT gp_Dir FUN_tool_nCinsideS(const gp_Dir& tgC,const gp_Dir& ngS)
{
// Give us a curve C on suface S,<parOnC>,a parameter
// Purpose : compute normal vector to C,tangent to S at
// given point,oriented INSIDE S
// <tgC> : geometric tangent at point of <parOnC>
// <ngS> : geometric normal at point of <parOnC>
gp_Dir XX(ngS^tgC);
return XX;
}
// ----------------------------------------------------------------------
Standard_EXPORT gp_Dir2d FUN_tool_nC2dINSIDES(const gp_Dir2d& tgC2d)
{
// ------------------------------------------------------------
// Give us an edge E of 2d rep. on a face F C2d.
// E is oriented FORWARD in F,then the matter described by
// the restriction of E on the surface of F is on the left.
// Give us UV on S,<ngS> is the normal to S at point given by UV
// <tgC2d> is the tangent to C2d at point UV,
// (X,Y,Z) describes a RONd with :
// X = (tgC2d,0),Y = (xx,0),Z =(0,0,1)
// ------------------------------------------------------------
gp_Dir X,Y,Z;
Z = gp_Dir(0.,0.,1.);
X = gp_Dir(tgC2d.X(),tgC2d.Y(),0.);
Y = Z^X;
gp_Dir2d xx(Y.X(),Y.Y());
return xx;
}
// ----------------------------------------------------------------------
//Standard_EXPORT gp_Vec FUN_tool_getgeomxx(const TopoDS_Face& Fi,
Standard_EXPORT gp_Vec FUN_tool_getgeomxx(const TopoDS_Face& ,
const TopoDS_Edge& Ei,
const Standard_Real parEi,
const gp_Dir& ngFi)
{
// <Ei> is an edge of <Fi>,
// computing XX a vector normal to <ngFi>,
// oriented IN the face <Fi>.
// (<ngFi> normal geometric to <Fi> at point of parameter
// <parEi> on edge <Ei>)
// <XX> is oriented inside 2d <F> if <E> is FORWARD in <F>
gp_Vec tgEi; Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(parEi,Ei,tgEi);
if (!ok) return gp_Vec(0.,0.,0.); //NYIRAISE
gp_Dir XX = FUN_tool_nCinsideS(tgEi,ngFi);
return XX;
}
// ----------------------------------------------------------------------
Standard_EXPORT gp_Vec FUN_tool_getgeomxx(const TopoDS_Face& Fi,const TopoDS_Edge& Ei,
const Standard_Real parOnEi)
{
gp_Vec xx(1.,0.,0.);
gp_Pnt2d uvi; Standard_Boolean ok = FUN_tool_paronEF(Ei,parOnEi,Fi,uvi);
if (!ok) return xx; // nyiRaise
gp_Vec ngFi = FUN_tool_nggeomF(uvi,Fi);
xx = FUN_tool_getgeomxx(Fi,Ei,parOnEi,ngFi);
return xx;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_getxx(const TopoDS_Face& Fi,const TopoDS_Edge& Ei,
const Standard_Real parEi,const gp_Dir& ngFi,
gp_Dir& XX)
{
gp_Vec xx = FUN_tool_getgeomxx(Fi,Ei,parEi,ngFi);
if (xx.Magnitude() < gp::Resolution()) return Standard_False;
XX = gp_Dir(xx);
TopAbs_Orientation oriEinF; Standard_Boolean ok = FUN_tool_orientEinFFORWARD(Ei,Fi,oriEinF);
if (!ok) return Standard_False;
if (M_REVERSED(oriEinF)) XX.Reverse();
return Standard_True;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_getxx(const TopoDS_Face& Fi,const TopoDS_Edge& Ei, const Standard_Real parEi,
gp_Dir& XX)
{
Standard_Real tolFi = BRep_Tool::Tolerance(Fi)*1.e2; // nyitol
gp_Pnt2d uv; Standard_Boolean ok = FUN_tool_parF(Ei,parEi,Fi,uv,tolFi);
if (!ok) return Standard_False;
gp_Vec ng = FUN_tool_nggeomF(uv,Fi);
ok = FUN_tool_getxx(Fi,Ei,parEi,ng,XX);
return ok;
}
// ----------------------------------------------------------------------
Standard_EXPORT Standard_Boolean FUN_tool_getdxx(const TopoDS_Face& F,
const TopoDS_Edge& E,
// const Standard_Real parE,
const Standard_Real ,
gp_Vec2d& dxx)
// E xiso (x=u,v)
// points between uvparE and uvparE+dxx are IN F2d
{
dxx = gp_Vec2d(0.,0.);
TopAbs_Orientation oEinFF; Standard_Boolean ok = FUN_tool_orientEinFFORWARD(E,F,oEinFF);
if (!ok) return Standard_False;
if (M_INTERNAL(oEinFF) || M_EXTERNAL(oEinFF)) return Standard_False;
Standard_Boolean isoU,isoV; gp_Dir2d d2d; gp_Pnt2d o2d;
Standard_Boolean iso = TopOpeBRepTool_TOOL::UVISO(E,F,isoU,isoV,d2d,o2d);
if (!iso) return Standard_False;
Standard_Real u1,u2,v1,v2; ok = FUN_tool_isobounds(F,u1,u2,v1,v2);
if (!ok) return Standard_False;
Standard_Real xpar = isoU ? o2d.X() : o2d.Y();
Standard_Real xinf = isoU ? u1 : v1;
Standard_Real xsup = isoU ? u2 : v2;
ok = ::FUN_nearestISO(F,xpar,isoU,xinf,xsup);
if (!ok) return Standard_False;
Standard_Real ypar = isoU? d2d.Y() : d2d.X();
Standard_Boolean matterAFTERxpar = Standard_False;
if (isoU) matterAFTERxpar = (ypar < 0.);
if (isoV) matterAFTERxpar = (ypar > 0.);
if (oEinFF == TopAbs_REVERSED) matterAFTERxpar = !matterAFTERxpar;
Standard_Real dx = 0.;
if (matterAFTERxpar) dx = xsup-xpar;
else dx = xinf-xpar;
if (isoU) dxx = gp_Vec2d(dx,0.);
if (isoV) dxx = gp_Vec2d(0.,dx);
return Standard_True;
}

View File

@@ -0,0 +1,88 @@
-- File: TopOpeBRepTool_mkTondgE.cdl
-- Created: Mon Mar 22 17:58:04 1999
-- Author: Xuan PHAM PHU
-- <xpu@poulopox.paris1.matra-dtv.fr>
---Copyright: Matra Datavision 1999
class mkTondgE from TopOpeBRepTool
uses
Pnt2d from gp,
Dir from gp,
Edge from TopoDS,
Face from TopoDS,
ListOfShape from TopTools,
DataMapOfShapeReal from TopTools
is
Create returns mkTondgE from TopOpeBRepTool;
Initialize(me : in out;
dgE : Edge from TopoDS;
F : Face from TopoDS;
uvi : Pnt2d from gp; Fi : Face from TopoDS)
returns Boolean;
-- <dgE> degenerated edge interfers with <Fi> at <uvi>.
-- purpose : the compute of interferences on <dgE> / <Fi>
SetclE(me : in out; clE : Edge from TopoDS)
returns Boolean;
IsT2d(me) returns Boolean;
SetRest(me : in out;
pari : Real; Ei : Edge from TopoDS)
returns Boolean;
-- <dgE> interfers with <Ei> at <pari>
-- returns false if <Ei> has no impact on the output transitions.
GetAllRest(me : in out; lEi : out ListOfShape from TopTools)
returns Integer;
-- finds out <lEi> = {ei / uvi is IN1d(ei)}
-- fills up field <mylEi>; these edges impact on the output transitions.
-- (!!!!!!!!!!!! works only for uvi on isos )
Par(me; index : Integer; pari : out Real) returns Boolean;
Ei(me; index : Integer; ei : out Edge from TopoDS) returns Boolean;
-- returns false if myEpari<index> is dummy.
MkTonE(me : in out; mkT : out Integer; par1,par2 : out Real)
returns Boolean;
-- purpose : the compute of transitions on <dgE> vs <myFi>.
-- call the method if ( !IsT2d() )
--
-- set mkT to 0 : no transition is to compute
-- 1 : compute transition FORWARD on <dgE> at Par(1)
-- 2 : REVERSED on <dgE> at Par(2)
-- 3 : compute transitions at Par(1) and Par(2)
-- returns false if the compute fails.
MkTonE(me : in out; Ei : Edge from TopoDS; mkT : out Integer; par1,par2 : out Real)
returns Boolean;
-- purpose : the compute of transitions on <dgE> vs <Ei> of <myFi>.
-- Ei is in list lEi /
-- SetRest(..Ei..) has been called before, and returned tru.
--
-- !!!! NYIXPU240399 : returns 0 if <myf> has no closing edge connexed to <myed>
-- interference
fields
mydgE : Edge from TopoDS; -- in
myF : Face from TopoDS; -- in
myclE : Edge from TopoDS;
mydirINcle : Dir from gp;
myFi : Face from TopoDS; -- in
myuvi : Pnt2d from gp; -- in
isT2d : Boolean; -- out
myEpari : DataMapOfShapeReal from TopTools;
hasRest : Boolean; -- out
myngf : Dir from gp;
myngfi : Dir from gp;
end mkTondgE from TopOpeBRepTool;

View File

@@ -0,0 +1,378 @@
// File: TopOpeBRepTool_mkTondgE.cxx
// Created: Tue Mar 23 16:26:45 1999
// Author: Xuan PHAM PHU
// <xpu@poulopox.paris1.matra-dtv.fr>
#include <Precision.hxx>
#include <gp_Pnt.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt2d.hxx>
#include <TopoDS.hxx>
#include <BRep_Tool.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <TopExp_Explorer.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_TOOL.hxx>
#include <TopOpeBRepTool_mkTondgE.ixx>
#include <TopOpeBRepTool_define.hxx>
#define M_FORWARD(sta) (sta == TopAbs_FORWARD)
#define M_REVERSED(sta) (sta == TopAbs_REVERSED)
#define M_INTERNAL(sta) (sta == TopAbs_INTERNAL)
#define M_EXTERNAL(sta) (sta == TopAbs_EXTERNAL)
#define FORWARD (1)
#define REVERSED (2)
#define INTERNAL (3)
#define EXTERNAL (4)
#define CLOSING (5)
#define NOI (0)
#define MKI1 (1)
#define MKI2 (2)
#define MKI12 (3)
static Standard_Real FUN_tola()
{
Standard_Real tola = Precision::Angular();
return tola;
}
//=======================================================================
//function : TopOpeBRepTool_mkTondgE
//purpose :
//=======================================================================
TopOpeBRepTool_mkTondgE::TopOpeBRepTool_mkTondgE()
{
}
//=======================================================================
//function : Initialize
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_mkTondgE::Initialize(const TopoDS_Edge& dgE, const TopoDS_Face& F,
const gp_Pnt2d& uvi, const TopoDS_Face& Fi)
{
isT2d = Standard_False; hasRest = Standard_False;
myclE.Nullify(); myEpari.Clear();
mydgE = dgE;
myF = F;
TopExp_Explorer exv(mydgE, TopAbs_VERTEX);const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
Standard_Real par = BRep_Tool::Parameter(v,mydgE);
gp_Pnt2d uv; Standard_Boolean ok = FUN_tool_paronEF(mydgE,par,myF,uv);
if (!ok) return Standard_False;
gp_Vec tmp; ok = TopOpeBRepTool_TOOL::NggeomF(uv,myF,tmp); myngf = gp_Dir(tmp);
if (!ok) return Standard_False;
myuvi = uvi;
myFi = Fi;
Standard_Boolean oki = TopOpeBRepTool_TOOL::NggeomF(myuvi,myFi,tmp); myngfi = gp_Dir(tmp);
if (!oki) return Standard_False;
Standard_Real dot = myngf.Dot(myngfi);
isT2d = (Abs(1-Abs(dot)) < FUN_tola());
return Standard_True;
}
//=======================================================================
//function : SetclE
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_mkTondgE::SetclE(const TopoDS_Edge& clE)
{
myclE = clE;
return Standard_True;
}
//=======================================================================
//function : IsT2d
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_mkTondgE::IsT2d() const
{
return isT2d;
}
//=======================================================================
//function : SetRest
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_mkTondgE::SetRest(const Standard_Real pari, const TopoDS_Edge& Ei)
{
hasRest = Standard_True;
Standard_Boolean clEi = TopOpeBRepTool_TOOL::IsClosingE(Ei,myFi);
if (clEi) {hasRest = Standard_False; return Standard_False;}
myEpari.Bind(Ei,pari);
return Standard_True;
}
//=======================================================================
//function : GetAllRest
//purpose :
//=======================================================================
Standard_Integer TopOpeBRepTool_mkTondgE::GetAllRest(TopTools_ListOfShape& lEi)
{
lEi.Clear();
BRepAdaptor_Surface bs(myFi);
Standard_Real tol3d = bs.Tolerance();
Standard_Real tolu = bs.UResolution(tol3d);
Standard_Real tolv = bs.VResolution(tol3d);
TopExp_Explorer ex(myFi, TopAbs_EDGE);
for (; ex.More(); ex.Next()){
const TopoDS_Edge& ei = TopoDS::Edge(ex.Current());
Standard_Boolean cli = TopOpeBRepTool_TOOL::IsClosingE(ei,myFi);
if (cli) continue;
Standard_Boolean isbi = myEpari.IsBound(ei);
if (isbi) {lEi.Append(ei); continue;}
Standard_Boolean isou,isov; gp_Dir2d d2d; gp_Pnt2d o2d;
Standard_Boolean uviso = TopOpeBRepTool_TOOL::UVISO(ei,myFi, isou,isov, d2d,o2d);
if (!uviso) continue;
Standard_Boolean ok = Standard_False;
if (isou) ok = Abs(o2d.X()-myuvi.X()) < tolu;
if (isov) ok = Abs(o2d.Y()-myuvi.Y()) < tolv;
if (!ok) continue;
Standard_Real parei;
#ifdef DEB
Standard_Boolean oki =
#endif
TopOpeBRepTool_TOOL::ParISO(myuvi,ei,myFi, parei);
myEpari.Bind(ei,parei);
lEi.Append(ei);
}
Standard_Integer nEi = lEi.Extent();
return nEi;
}
static Standard_Boolean FUN_getEc(const TopoDS_Face& f, const TopoDS_Vertex& v, TopoDS_Edge& cle)
{
TopExp_Explorer exe(f,TopAbs_EDGE);
for (; exe.More(); exe.Next()){
const TopoDS_Edge& e = TopoDS::Edge(exe.Current());
Standard_Boolean closed = TopOpeBRepTool_TOOL::IsClosingE(e,f);
if (!closed) continue;
TopExp_Explorer exv(e,TopAbs_VERTEX);
for (; exv.More(); exv.Next()){
if (exv.Current().IsSame(v)) {cle = e; return Standard_True;}
}
}
return Standard_False;
}
static Standard_Boolean FUN_MkTonE(const gp_Vec& faxis, const gp_Vec& dirINcle, const gp_Vec& xxi,
const gp_Vec& /*ngf*/, Standard_Real& par1, Standard_Real& par2, Standard_Boolean& outin)
{
// tgi / (tgi,xxi,faxis) is direct :
gp_Vec tgi = xxi.Crossed(faxis);
// ******************** getting par1, par2
// at par1 : tr(dge, ei/fi) = forward
// at par2 : tr(dge, ei/fi) = forward
Standard_Real tola = FUN_tola();
Standard_Real dot1 = dirINcle.Dot(xxi);
Standard_Boolean isONi = (Abs(dot1) < tola);
// par1 = ang -> inout
// par2 = Cang -> outin
Standard_Real ang = 1.e7;
if (isONi) {
Standard_Real dot = dirINcle.Dot(tgi);
ang = (dot > 0) ? 0 : PI;
// outin = (ang > 0); -xpu190499
outin = Standard_True;
}
else {
if (!isONi) ang = TopOpeBRepTool_TOOL::Matter(dirINcle,tgi.Reversed(),faxis);
//Standard_Real dot = isONi ? 0 : (dirINcle^tgi).Dot(ngf);
Standard_Real dot = isONi ? 0 : (dirINcle^tgi).Dot(faxis);
if (dot1 < 0) outin = (dot > 0);
else outin = (dot < 0);
}//!isONi
Standard_Real Cang = (ang > PI) ? ang-PI : ang+PI;
par1 = outin ? ang : Cang;
par2 = outin ? Cang : ang;
return Standard_True;
}//FUN_MkTonE
//=======================================================================
//function : MkTonE
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_mkTondgE::MkTonE(Standard_Integer& mkT, Standard_Real& par1, Standard_Real& par2)
{
if (isT2d) return Standard_False;
mkT = NOI; par1=par2=1.e7;
// v :
TopExp_Explorer exv(mydgE, TopAbs_VERTEX);
const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
// myclE :
if (myclE.IsNull()) {
Standard_Boolean find = FUN_getEc(myF,v,myclE);
if (!find) return Standard_False;
}
// dirINcle : tangent to cle at v oriented INSIDE 1d(cle)
Standard_Integer ovcle; gp_Vec dirINcle; Standard_Boolean ok = TopOpeBRepTool_TOOL::TgINSIDE(v,myclE,dirINcle,ovcle);
if (!ok) return NOI;
// faxis : describes f's axis for parametrization of <dgE>
gp_Vec faxis = myngf;
if (ovcle == FORWARD) faxis.Reverse();
// xxi : normal to fi oriented INSIDE 3d(fi)
gp_Vec xxi; ok = TopOpeBRepTool_TOOL::NggeomF(myuvi,myFi,xxi);
if (!ok) return Standard_False;
if (M_FORWARD(myFi.Orientation())) xxi.Reverse();
// mkT, par1, par2 :
Standard_Boolean outin; ok = FUN_MkTonE(faxis,dirINcle,xxi,myngf, par1,par2,outin);
if (ok) mkT = MKI12;
return ok;
}
//=======================================================================
//function : MkTonE
//purpose :
//=======================================================================
Standard_Boolean TopOpeBRepTool_mkTondgE::MkTonE(const TopoDS_Edge& ei, Standard_Integer& mkT, Standard_Real& par1, Standard_Real& par2)
// isT2d = true :
// prequesitory : f,fi are tangent on v
// dge interfers on v with ei
// purpose : the compute of transition on dge / ei
// at par1 : Tr(dge,e)= ou/in,
// at par2 : Tr(dge,e)= in/ou
//
// isT2d = false :
// prequesitory : dge interfers on v with fi
// purpose : the compute of transition on dge / fi
// at par1 : Tr(dge,e)= ou/in,
// at par2 : Tr(dge,e)= in/ou
//
{
mkT = NOI; par1=par2=1.e7;
hasRest = myEpari.IsBound(ei);
if (!hasRest) return Standard_False;
const Standard_Real pari = myEpari.Find(ei);
Standard_Real pfi,pli; FUN_tool_bounds(ei,pfi,pli);
Standard_Real tolpi = TopOpeBRepTool_TOOL::TolP(ei,myFi);
Standard_Boolean onfi = (Abs(pari-pfi) < tolpi), onli = (Abs(pari-pli) < tolpi);
gp_Vec tgin1di;Standard_Boolean ok = TopOpeBRepTool_TOOL::TggeomE(pari,ei, tgin1di);
if (!ok) return Standard_False;
if (onli) tgin1di.Reverse();
// v :
TopExp_Explorer exv(mydgE, TopAbs_VERTEX);
const TopoDS_Vertex& v = TopoDS::Vertex(exv.Current());
// myclE :
if (myclE.IsNull()) {
Standard_Boolean find = FUN_getEc(myF,v,myclE);
if (!find) return Standard_False;
}
// dirINcle : tangent to cle at v oriented INSIDE 1d(cle)
Standard_Integer ovcle; gp_Vec dirINcle; ok = TopOpeBRepTool_TOOL::TgINSIDE(v,myclE,dirINcle,ovcle);
if (!ok) return NOI;
if (isT2d && !hasRest) return Standard_False; // no transition to compute
// faxis : describes f's axis for parametrization of <dgE>
gp_Vec faxis = myngf;
if (ovcle == FORWARD) faxis.Reverse();
gp_Dir xxi; //isT2d=true : normal to ei oriented INSIDE 2d(fi)
// normal to fi oriented INSIDE 3d(fi)
gp_Dir xxri;//isT2d=true : oriented inside 1d(ei)
// oriented inside 2d(fi)
TopoDS_Vertex vclo; Standard_Boolean closedi = TopOpeBRepTool_TOOL::ClosedE(ei,vclo);//@190499
Standard_Boolean outin;
if (isT2d) {
// xxi :
ok = TopOpeBRepTool_TOOL::XX(myuvi,myFi,pari,ei,xxi);
if (!ok) return Standard_False;
// mkT,par1,par2
ok = FUN_MkTonE(faxis,dirINcle,xxi,myngf, par1,par2, outin);
if (!ok) return Standard_False;
if (!onfi && !onli) {mkT = MKI12; return Standard_True;}// => the same for all edges of lei @190499
if (closedi) {mkT = MKI12; return Standard_True;}// onfi || onli @190499
// xxri :
xxri = tgin1di;
}//isT2d
else {
// xxi :
gp_Vec tmp; ok = TopOpeBRepTool_TOOL::NggeomF(myuvi,myFi,tmp); xxi = gp_Dir(tmp);
if (!ok) return Standard_False;
if (M_FORWARD(myFi.Orientation())) xxi.Reverse();
// mkT,par1,par2
ok = FUN_MkTonE(faxis,dirINcle,xxi,myngf, par1,par2, outin);
if (!ok) return Standard_False;
//// modified by jgv, 21.11.01 for BUC61053 ////
ok = TopOpeBRepTool_TOOL::XX(myuvi,myFi, pari,ei, xxri);
if (!ok) return Standard_False;
mkT = MKI12; // without restrictions.
gp_Vec tgi = xxi.Crossed(faxis);//tgi /(tgi,xxi,faxis) is direct :
Standard_Real dot = tgi.Dot(xxri);
if (Abs(dot) < FUN_tola())
{
if (!onfi && !onli || closedi)
{ mkT = MKI12; return Standard_True; }
else
dot = tgi.Dot(tgin1di);
}
Standard_Boolean keepang = (dot > 0);
if (keepang) mkT = outin ? MKI1 : MKI2;
else mkT = outin ? MKI2 : MKI1;
return Standard_True;
////////////////////////////////////////////////
// xxri :
Standard_Real ddot = tgin1di.Dot(faxis);
Standard_Boolean tgaxis = Abs(1-(Abs(ddot))) < FUN_tola(); //=true : edge is tangent to sphere's axis
if (tgaxis) {
ok = TopOpeBRepTool_TOOL::XX(myuvi,myFi, pari,ei, xxri);
if (!ok) return Standard_False;
}
else {
if ((!onfi) && (!onli)) {mkT = MKI12; return Standard_True;} // @190499
if (closedi) {mkT = MKI12; return Standard_True;}// onfi || onli @190499
xxri = tgin1di;
}
}//!isT2d
mkT = MKI12; // without restrictions.
gp_Vec tgi = xxi.Crossed(faxis);//tgi /(tgi,xxi,faxis) is direct :
Standard_Real dot = tgi.Dot(xxri);
Standard_Boolean keepang = (dot > 0);
if (keepang) mkT = outin ? MKI1 : MKI2;
else mkT = outin ? MKI2 : MKI1;
return Standard_True;
}

View File

@@ -0,0 +1,226 @@
// File: TopOpeBRepTool_tol.cxx
// Created: Tue Apr 1 11:22:56 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#include <TopOpeBRepTool_tol.hxx>
#include <TopoDS.hxx>
#include <TopExp_Explorer.hxx>
#include <Precision.hxx>
#include <BRep_Tool.hxx>
#include <TopOpeBRepTool_HBoxTool.hxx>
#include <Bnd_Box.hxx>
#include <TopOpeBRepTool_box.hxx>
#include <TopOpeBRepTool_define.hxx>
Standard_EXPORT void FTOL_FaceTolerances
(const Bnd_Box& B1, const Bnd_Box& B2,
const TopoDS_Face& myFace1, const TopoDS_Face& myFace2,
const BRepAdaptor_Surface& mySurface1, const BRepAdaptor_Surface& mySurface2,
Standard_Real& myTol1, Standard_Real& myTol2,
Standard_Real& Deflection, Standard_Real& MaxUV)
{
// ============================================================
// == t o l e r a n c e s d I n t e r s e c t i o n ==
// ============================================================
Standard_Real x0,y0,z0,x1,y1,z1,dx,dy,dz;
Standard_Boolean Box1OK,Box2OK;
if( !B1.IsOpenXmin() && !B1.IsOpenXmax()
&& !B1.IsOpenYmin() && !B1.IsOpenYmax()
&& !B1.IsOpenZmin() && !B1.IsOpenZmax()
&& !B1.IsVoid()) {
Box1OK=Standard_True;
}
else {
Box1OK=Standard_False;
}
if( !B2.IsOpenXmin() && !B2.IsOpenXmax()
&& !B2.IsOpenYmin() && !B2.IsOpenYmax()
&& !B2.IsOpenZmin() && !B2.IsOpenZmax()
&& !B2.IsVoid()) {
Box2OK=Standard_True;
}
else {
Box2OK=Standard_False;
}
if(Box1OK) {
B1.Get(x0,y0,z0,x1,y1,z1);
dx=x1-x0;
dy=y1-y0;
dz=z1-z0;
if(Box2OK) {
B2.Get(x0,y0,z0,x1,y1,z1);
Standard_Real _dx=x1-x0;
Standard_Real _dy=y1-y0;
Standard_Real _dz=z1-z0;
if(_dx>dx) dx=_dx;
if(_dy>dy) dy=_dy;
if(_dz>dz) dz=_dz;
}
}
else {
if(Box2OK) {
B2.Get(x0,y0,z0,x1,y1,z1);
dx=x1-x0;
dy=y1-y0;
dz=z1-z0;
}
else {
dx=dy=dz=1.0;
}
}
if(dx<dy) dx=dy;
if(dx<dz) dx=dz;
if(dx>1000000.0) dx=1000000.0; //-- if(dx>10000.0) dx=10000.0;
TopExp_Explorer ex;
Standard_Real tolef1 = Precision::Confusion();
for (ex.Init(myFace1,TopAbs_EDGE);ex.More();ex.Next()) {
Standard_Real tole=BRep_Tool::Tolerance(TopoDS::Edge(ex.Current()));
if (tole>tolef1) tolef1=tole;
}
Standard_Real tolef2 = Precision::Confusion();
for (ex.Init(myFace2,TopAbs_EDGE);ex.More();ex.Next()) {
Standard_Real tole=BRep_Tool::Tolerance(TopoDS::Edge(ex.Current()));
if (tole>tolef2) tolef2=tole;
}
Standard_Real tolef= tolef1;
if (tolef2>tolef) tolef=tolef2;
//jmb le 30 juillet 99. on ne multiplie pas la tolerance par la dimension de la piece
// Standard_Real tolbox = tolef*dx;
Standard_Real tolbox = tolef;
myTol1 = tolbox;
myTol2 = tolbox;
Standard_Real tolmin = Precision::Confusion();
if (tolmin>myTol1) myTol1 = tolmin;
if (tolmin>myTol2) myTol2 = tolmin;
Deflection=0.01;
MaxUV=0.01;
Deflection*=dx;
Standard_Real MTOL1 = Max(myTol1,1e-8);
Standard_Real MTOL2 = Max(myTol2,1e-8);
Standard_Real MDEFLECTION = Deflection;
Standard_Real MMAXUV=0.01;
Standard_Real MU0,MU1,MV0,MV1,DP1,DP2,DP;
MU0=mySurface1.FirstUParameter();
MU1=mySurface1.LastUParameter();
MV0=mySurface1.FirstVParameter();
MV1=mySurface1.LastVParameter();
DP1 = MU1-MU0;
DP2 = MV1-MV0;
if(DP2<DP1) DP=DP2; else DP=DP1; //-- DP + petit
MU0=mySurface2.FirstUParameter();
MU1=mySurface2.LastUParameter();
MV0=mySurface2.FirstVParameter();
MV1=mySurface2.LastVParameter();
DP1 = MU1-MU0;
DP2 = MV1-MV0;
if(DP2>DP1) DP1=DP2; //-- DP1 + petit
if(DP1<DP) DP=DP1; //-- DP + petit
DP*=0.01;
//jmb le 30 juillet 99
// non ! laisser MMAXUV a 0.01
// MMAXUV=DP;
#ifdef DEB
// printf("\n FaceTolerances3d : TOL1 = %5.5eg TOL2=%5.5eg DEFL=%5.5eg MAXUV=%5.5eg\n",MTOL1,MTOL2,MDEFLECTION,0.01);
#endif
if(MTOL1>1e-4*dx) MTOL1=1e-4*dx;
if(MTOL2>1e-4*dx) MTOL2=1e-4*dx;
if(MTOL1<1e-8) MTOL1=1e-8;
if(MTOL2<1e-8) MTOL2=1e-8;
if(MMAXUV<1e-3) MMAXUV=1e-3;
if(MDEFLECTION<1e-3) MDEFLECTION = 1e-3;
if(MTOL1>0.5) MTOL1=0.5;
if(MTOL2>0.5) MTOL2=0.5;
if(MMAXUV>0.01) MMAXUV=0.01;
if(MDEFLECTION>0.1) MDEFLECTION = 0.1;
#ifdef DEB
// printf("TOL1 = %5.5eg TOL2=%5.5eg DEFL=%5.5eg MAXUV=%5.5eg\n",MTOL1,MTOL2,MDEFLECTION,MMAXUV);
#endif
myTol1 = MTOL1;
myTol2 = MTOL2;
Deflection = MDEFLECTION;
MaxUV = MMAXUV;
} // FTOL_FaceTolerances
Standard_EXPORT void FTOL_FaceTolerances3d
(const TopoDS_Face& myFace1,
const TopoDS_Face& myFace2,
Standard_Real& Tol)
{
const Handle(TopOpeBRepTool_HBoxTool)& hbt = FBOX_GetHBoxTool();
Bnd_Box B1, B2;
if(hbt->HasBox(myFace1)) {
B1 = hbt->Box(myFace1);
}
else {
B1.Update(0., 0., 0., 1., 1., 1.);
}
if(hbt->HasBox(myFace2)) {
B2 = hbt->Box(myFace2);
}
else {
B2.Update(0., 0., 0., 1., 1., 1.);
}
BRepAdaptor_Surface mySurface1;
BRepAdaptor_Surface mySurface2;
mySurface1.Initialize(myFace1);
mySurface2.Initialize(myFace2);
Standard_Real Deflection=0.01,MaxUV=0.01;
Standard_Real myTol1,myTol2;
FTOL_FaceTolerances(B1,B2,
myFace1,myFace2,
mySurface1,mySurface2,
myTol1,myTol2,Deflection,MaxUV);
myTol1 = (myTol1 > 1.e-4)? 1.e-4: myTol1;
myTol2 = (myTol2 > 1.e-4)? 1.e-4: myTol2;
Tol = Max(myTol1,myTol2);
}
Standard_EXPORT void FTOL_FaceTolerances3d
(const Bnd_Box& B1, const Bnd_Box& B2,
const TopoDS_Face& myFace1, const TopoDS_Face& myFace2,
const BRepAdaptor_Surface& mySurface1, const BRepAdaptor_Surface& mySurface2,
Standard_Real& myTol1, Standard_Real& myTol2,
Standard_Real& Deflection, Standard_Real& MaxUV)
{
FTOL_FaceTolerances(B1,B2,
myFace1,myFace2,
mySurface1,mySurface2,
myTol1,myTol2,
Deflection,MaxUV);
}
Standard_EXPORT void FTOL_FaceTolerances2d
(const Bnd_Box& B1,
const Bnd_Box& B2,
const TopoDS_Face& myFace1,
const TopoDS_Face& myFace2,
const BRepAdaptor_Surface& mySurface1,
const BRepAdaptor_Surface& mySurface2,
Standard_Real& myTol1, Standard_Real& myTol2)
{
Standard_Real BIDDeflection,BIDMaxUV;
FTOL_FaceTolerances(B1,B2,
myFace1,myFace2,
mySurface1,mySurface2,
myTol1,myTol2,
BIDDeflection,BIDMaxUV);
}

View File

@@ -0,0 +1,37 @@
// File: TopOpeBRepTool_tol.hxx
// Created: Tue Apr 1 11:22:56 1997
// Author: Jean Yves LEBEY
// <jyl@bistrox.paris1.matra-dtv.fr>
#ifndef _TopOpeBRepTool_tol_HeaderFile
#define _TopOpeBRepTool_tol_HeaderFile
#include <Bnd_Box.hxx>
#include <TopoDS_Face.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <TopOpeBRepTool_define.hxx>
Standard_EXPORT void FTOL_FaceTolerances
(const Bnd_Box& B1,const Bnd_Box& B2,
const TopoDS_Face& myFace1,const TopoDS_Face& myFace2,
const BRepAdaptor_Surface& mySurface1,const BRepAdaptor_Surface& mySurface2,
Standard_Real& myTol1,Standard_Real& myTol2,
Standard_Real& Deflection,Standard_Real& MaxUV);
Standard_EXPORT void FTOL_FaceTolerances3d
(const TopoDS_Face& myFace1,const TopoDS_Face& myFace2,Standard_Real& Tol);
Standard_EXPORT void FTOL_FaceTolerances3d
(const Bnd_Box& B1,const Bnd_Box& B2,
const TopoDS_Face& myFace1,const TopoDS_Face& myFace2,
const BRepAdaptor_Surface& mySurface1,const BRepAdaptor_Surface& mySurface2,
Standard_Real& myTol1,Standard_Real& myTol2,
Standard_Real& Deflection,Standard_Real& MaxUV);
Standard_EXPORT void FTOL_FaceTolerances2d
(const Bnd_Box& B1,const Bnd_Box& B2,
const TopoDS_Face& myFace1,const TopoDS_Face& myFace2,
const BRepAdaptor_Surface& mySurface1,const BRepAdaptor_Surface& mySurface2,
Standard_Real& myTol1,Standard_Real& myTol2);
#endif

View File

@@ -0,0 +1,101 @@
// File: TopOpeBRepTool.cxx
// Created: Thu Mar 10 12:13:09 1994
// Author: Jean Yves LEBEY
// <jyl@phobox>
#ifdef DEB
#include <Standard_Type.hxx>
Standard_EXPORT Standard_Integer TopOpeBRepTool_BOOOPE_CHECK_DEB = 1;
static Standard_Boolean TopOpeBRepTool_traceBOXPERSO = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceBOXPERSO(const Standard_Boolean b)
{ TopOpeBRepTool_traceBOXPERSO = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceBOXPERSO()
{ return TopOpeBRepTool_traceBOXPERSO; }
static Standard_Boolean TopOpeBRepTool_traceBOX = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceBOX(const Standard_Boolean b)
{ TopOpeBRepTool_traceBOX = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceBOX()
{ return TopOpeBRepTool_traceBOX; }
static Standard_Boolean TopOpeBRepTool_traceVC = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceVC(const Standard_Boolean b)
{ TopOpeBRepTool_traceVC = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceVC()
{ return TopOpeBRepTool_traceVC; }
static Standard_Boolean TopOpeBRepTool_traceNYI = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceNYI(const Standard_Boolean b)
{ TopOpeBRepTool_traceNYI = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceNYI()
{ return TopOpeBRepTool_traceNYI; }
static Standard_Boolean TopOpeBRepTool_tracePCURV = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettracePCURV(const Standard_Boolean b)
{ TopOpeBRepTool_tracePCURV = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettracePCURV()
{ return TopOpeBRepTool_tracePCURV; }
static Standard_Boolean TopOpeBRepTool_traceCLOV = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceCLOV(const Standard_Boolean b)
{ TopOpeBRepTool_traceCLOV = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCLOV()
{ return TopOpeBRepTool_traceCLOV; }
static Standard_Boolean TopOpeBRepTool_traceCHKBSPL = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceCHKBSPL(const Standard_Boolean b)
{ TopOpeBRepTool_traceCHKBSPL = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCHKBSPL()
{ return TopOpeBRepTool_traceCHKBSPL; }
static Standard_Boolean TopOpeBRepTool_tracePURGE = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettracePURGE(const Standard_Boolean b)
{ TopOpeBRepTool_tracePURGE = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettracePURGE()
{ return TopOpeBRepTool_tracePURGE; }
static Standard_Boolean TopOpeBRepTool_traceREGUFA = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceREGUFA(const Standard_Boolean b)
{ TopOpeBRepTool_traceREGUFA = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceREGUFA()
{ return TopOpeBRepTool_traceREGUFA; }
static Standard_Boolean TopOpeBRepTool_traceREGUSO = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceREGUSO(const Standard_Boolean b)
{ TopOpeBRepTool_traceREGUSO = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceREGUSO()
{ return TopOpeBRepTool_traceREGUSO; }
static Standard_Boolean TopOpeBRepTool_traceC2D = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceC2D(const Standard_Boolean b)
{ TopOpeBRepTool_traceC2D = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceC2D()
{ return TopOpeBRepTool_traceC2D; }
static Standard_Boolean TopOpeBRepTool_traceCORRISO = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceCORRISO(const Standard_Boolean b)
{ TopOpeBRepTool_traceCORRISO = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCORRISO()
{ return TopOpeBRepTool_traceCORRISO; }
static Standard_Boolean TopOpeBRepTool_traceKRO = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceKRO(const Standard_Boolean b)
{ TopOpeBRepTool_traceKRO = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceKRO()
{ return TopOpeBRepTool_traceKRO; }
static Standard_Boolean TopOpeBRepTool_traceEND = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SettraceEND(const Standard_Boolean b) { TopOpeBRepTool_traceEND = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceEND() { return TopOpeBRepTool_traceEND; }
static Standard_Boolean TopOpeBRepTool_contextNOSEW = Standard_False;
Standard_EXPORT void TopOpeBRepTool_SetcontextNOSEW(const
Standard_Boolean b) { TopOpeBRepTool_contextNOSEW = b; }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GetcontextNOSEW() {
return TopOpeBRepTool_contextNOSEW; }
// #ifdef DEB
#endif

View File

@@ -0,0 +1,49 @@
// File: TopOpeBRepTool.cxx
// Created: Thu Mar 10 12:13:09 1994
// Author: Jean Yves LEBEY
// <jyl@phobox>
#ifdef DEB
#include <Standard_Type.hxx>
#include <TopOpeBRepTool_STATE.hxx>
static TopOpeBRepTool_STATE TopOpeBRepTool_CL3DDR("draw 3d classification states");
static TopOpeBRepTool_STATE TopOpeBRepTool_CL3DPR("print 3d classification states");
static TopOpeBRepTool_STATE TopOpeBRepTool_CL2DDR("draw 2d classification states");
static TopOpeBRepTool_STATE TopOpeBRepTool_CL2DPR("print 2d classification states");
Standard_EXPORT void TopOpeBRepTool_SettraceCL3DDR
(const Standard_Boolean b, Standard_Integer narg, char** a)
{ TopOpeBRepTool_CL3DDR.Set(b,narg,a); }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL3DDR(const TopAbs_State S)
{ return TopOpeBRepTool_CL3DDR.Get(S); }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL3DDR()
{ return TopOpeBRepTool_CL3DDR.Get(); }
Standard_EXPORT void TopOpeBRepTool_SettraceCL3DPR
(const Standard_Boolean b, Standard_Integer narg, char** a)
{ TopOpeBRepTool_CL3DPR.Set(b,narg,a); }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL3DPR(const TopAbs_State S)
{ return TopOpeBRepTool_CL3DPR.Get(S); }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL3DPR()
{ return TopOpeBRepTool_CL3DPR.Get(); }
Standard_EXPORT void TopOpeBRepTool_SettraceCL2DDR
(const Standard_Boolean b, Standard_Integer narg, char** a)
{ TopOpeBRepTool_CL2DDR.Set(b,narg,a); }
Standard_EXPORT Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL2DDR(const TopAbs_State S)
{ return TopOpeBRepTool_CL2DDR.Get(S); }
Standard_EXPORT Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL2DDR()
{ return TopOpeBRepTool_CL2DDR.Get(); }
Standard_EXPORT void TopOpeBRepTool_SettraceCL2DPR
(const Standard_Boolean b, Standard_Integer narg, char** a)
{ TopOpeBRepTool_CL2DPR.Set(b,narg,a); }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL2DPR(const TopAbs_State S)
{ return TopOpeBRepTool_CL2DPR.Get(S); }
Standard_EXPORT Standard_Boolean TopOpeBRepTool_GettraceCL2DPR()
{ return TopOpeBRepTool_CL2DPR.Get(); }
// #ifdef DEB
#endif