-// File: BRep_Tool.cxx
-// Created: Wed Jul 7 15:35:57 1993
-// Author: Remi LEQUETTE
-// <rle@phylox>
+// File: BRep_Tool.cxx
+// Created: Wed Jul 7 15:35:57 1993
+// Author: Remi LEQUETTE
+// <rle@phylox>
#include <BRep_Tool.ixx>
//=======================================================================
const Handle(Geom_Surface)& BRep_Tool::Surface(const TopoDS_Face& F,
- TopLoc_Location& L)
+ TopLoc_Location& L)
{
Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &F.TShape());
L = F.Location() * TF->Location();
const Handle(Poly_Triangulation)&
BRep_Tool::Triangulation(const TopoDS_Face& F,
- TopLoc_Location& L)
+ TopLoc_Location& L)
{
L = F.Location();
return (*((Handle(BRep_TFace)*)&F.TShape()))->Triangulation();
static Handle(Poly_Polygon3D) nullPolygon3D;
const Handle(Geom_Curve)& BRep_Tool::Curve(const TopoDS_Edge& E,
- TopLoc_Location& L,
- Standard_Real& First,
- Standard_Real& Last)
+ TopLoc_Location& L,
+ Standard_Real& First,
+ Standard_Real& Last)
{
// find the representation
BRep_ListIteratorOfListOfCurveRepresentation itcr
//=======================================================================
Handle(Geom_Curve) BRep_Tool::Curve(const TopoDS_Edge& E,
- Standard_Real& First,
- Standard_Real& Last)
+ Standard_Real& First,
+ Standard_Real& Last)
{
TopLoc_Location L;
Handle(Geom_Curve) C = Curve(E,L,First,Last);
//=======================================================================
const Handle(Poly_Polygon3D)& BRep_Tool::Polygon3D(const TopoDS_Edge& E,
- TopLoc_Location& L)
+ TopLoc_Location& L)
{
// find the representation
BRep_ListIteratorOfListOfCurveRepresentation itcr
//=======================================================================
Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
- const TopoDS_Face& F,
- Standard_Real& First,
- Standard_Real& Last)
+ const TopoDS_Face& F,
+ Standard_Real& First,
+ Standard_Real& Last)
{
TopLoc_Location l;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
static Handle(Geom2d_Curve) nullPCurve;
Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L,
- Standard_Real& First,
- Standard_Real& Last)
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L,
+ Standard_Real& First,
+ Standard_Real& Last)
{
TopLoc_Location loc = L.Predivided(E.Location());
Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
GC->Range(First,Last);
if (GC->IsCurveOnClosedSurface() && Eisreversed)
- return GC->PCurve2();
+ return GC->PCurve2();
else
- return GC->PCurve();
+ return GC->PCurve();
}
itcr.Next();
}
if (!GP.IsNull()) {
- static Handle(GeomAdaptor_HCurve) HC;
- static Handle(GeomAdaptor_HSurface) HS;
- if (HC.IsNull()) {
- HC = new GeomAdaptor_HCurve();
- HS = new GeomAdaptor_HSurface();
- }
+ Handle(GeomAdaptor_HCurve) HC;
+ Handle(GeomAdaptor_HSurface) HS;
+
+ HC = new GeomAdaptor_HCurve();
+ HS = new GeomAdaptor_HSurface();
TopLoc_Location LC;
Handle(Geom_Curve) ProjOnPlane =
GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l),
- Plane,
- Plane->Position().Direction(),
- Standard_True);
+ Plane,
+ Plane->Position().Direction(),
+ Standard_True);
GeomAdaptor_Curve& GAC = HC->ChangeCurve();
GAC.Load(ProjOnPlane);
if (pc->DynamicType() == STANDARD_TYPE(Geom2d_TrimmedCurve)) {
Handle(Geom2d_TrimmedCurve) TC =
- (*((Handle(Geom2d_TrimmedCurve)*)&pc));
+ (*((Handle(Geom2d_TrimmedCurve)*)&pc));
pc = TC->BasisCurve();
}
First = f; Last = l;
//=======================================================================
void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
- Handle(Geom2d_Curve)& C,
- Handle(Geom_Surface)& S,
- TopLoc_Location& L,
- Standard_Real& First,
- Standard_Real& Last)
+ Handle(Geom2d_Curve)& C,
+ Handle(Geom_Surface)& S,
+ TopLoc_Location& L,
+ Standard_Real& First,
+ Standard_Real& Last)
{
// find the representation
BRep_ListIteratorOfListOfCurveRepresentation itcr
//=======================================================================
void BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
- Handle(Geom2d_Curve)& C,
- Handle(Geom_Surface)& S,
- TopLoc_Location& L,
- Standard_Real& First,
- Standard_Real& Last,
- const Standard_Integer Index)
+ Handle(Geom2d_Curve)& C,
+ Handle(Geom_Surface)& S,
+ TopLoc_Location& L,
+ Standard_Real& First,
+ Standard_Real& Last,
+ const Standard_Integer Index)
{
Standard_Integer i = 0;
Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
i++;
if (i > Index) break;
if (i == Index) {
- // JMB le 21 Mai 1999
- // on fait comme dans les autres methodes CurveOnSurface. c.a.d on tient
- // compte de l'orientation dans le cas des aretes de coutures (renvoi de PCurve2)
- // sinon on risque de louper des curves ou de ne pas obtenir la bonne.
- if (GC->IsCurveOnClosedSurface() && Eisreversed)
- C = GC->PCurve2();
- else
- C = GC->PCurve();
- S = GC->Surface();
- L = E.Location() * GC->Location();
- GC->Range(First,Last);
- return;
+ // JMB le 21 Mai 1999
+ // on fait comme dans les autres methodes CurveOnSurface. c.a.d on tient
+ // compte de l'orientation dans le cas des aretes de coutures (renvoi de PCurve2)
+ // sinon on risque de louper des curves ou de ne pas obtenir la bonne.
+ if (GC->IsCurveOnClosedSurface() && Eisreversed)
+ C = GC->PCurve2();
+ else
+ C = GC->PCurve();
+ S = GC->Surface();
+ L = E.Location() * GC->Location();
+ GC->Range(First,Last);
+ return;
}
}
itcr.Next();
//=======================================================================
Handle(Poly_Polygon2D) BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
- const TopoDS_Face& F)
+ const TopoDS_Face& F)
{
TopLoc_Location l;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
Handle(Poly_Polygon2D)
BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L)
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L)
{
TopLoc_Location l = L.Predivided(E.Location());
Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsPolygonOnSurface(S,l)) {
if (cr->IsPolygonOnClosedSurface() && Eisreversed )
- return cr->Polygon2();
+ return cr->Polygon2();
else
- return cr->Polygon();
+ return cr->Polygon();
}
itcr.Next();
}
//=======================================================================
void BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
- Handle(Poly_Polygon2D)& P,
- Handle(Geom_Surface)& S,
- TopLoc_Location& L)
+ Handle(Poly_Polygon2D)& P,
+ Handle(Geom_Surface)& S,
+ TopLoc_Location& L)
{
// find the representation
BRep_ListIteratorOfListOfCurveRepresentation itcr
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsPolygonOnSurface()) {
const Handle(BRep_PolygonOnSurface)& PS =
- *((Handle(BRep_PolygonOnSurface)*)&cr);
+ *((Handle(BRep_PolygonOnSurface)*)&cr);
P = PS->Polygon();
S = PS->Surface();
L = E.Location() * PS->Location();
//=======================================================================
void BRep_Tool::PolygonOnSurface(const TopoDS_Edge& E,
- Handle(Poly_Polygon2D)& P,
- Handle(Geom_Surface)& S,
- TopLoc_Location& L,
- const Standard_Integer Index)
+ Handle(Poly_Polygon2D)& P,
+ Handle(Geom_Surface)& S,
+ TopLoc_Location& L,
+ const Standard_Integer Index)
{
Standard_Integer i = 0;
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsPolygonOnSurface()) {
const Handle(BRep_PolygonOnSurface)& PS =
- *((Handle(BRep_PolygonOnSurface)*)&cr);
+ *((Handle(BRep_PolygonOnSurface)*)&cr);
i++;
if (i > Index) break;
if (i == Index) {
- P = PS->Polygon();
- S = PS->Surface();
- L = E.Location() * PS->Location();
- return;
+ P = PS->Polygon();
+ S = PS->Surface();
+ L = E.Location() * PS->Location();
+ return;
}
}
itcr.Next();
const Handle(Poly_PolygonOnTriangulation)&
BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& E,
- const Handle(Poly_Triangulation)& T,
- const TopLoc_Location& L)
+ const Handle(Poly_Triangulation)& T,
+ const TopLoc_Location& L)
{
TopLoc_Location l = L.Predivided(E.Location());
Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if ( cr->IsPolygonOnTriangulation(T,l)) {
if ( cr->IsPolygonOnClosedTriangulation() && Eisreversed )
- return cr->PolygonOnTriangulation2();
+ return cr->PolygonOnTriangulation2();
else
- return cr->PolygonOnTriangulation();
+ return cr->PolygonOnTriangulation();
}
itcr.Next();
}
void
BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& E,
- Handle(Poly_PolygonOnTriangulation)& P,
- Handle(Poly_Triangulation)& T,
- TopLoc_Location& L)
+ Handle(Poly_PolygonOnTriangulation)& P,
+ Handle(Poly_Triangulation)& T,
+ TopLoc_Location& L)
{
// find the representation
BRep_ListIteratorOfListOfCurveRepresentation itcr
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsPolygonOnTriangulation()) {
const Handle(BRep_PolygonOnTriangulation)& PT =
- *((Handle(BRep_PolygonOnTriangulation)*)&cr);
+ *((Handle(BRep_PolygonOnTriangulation)*)&cr);
P = PT->PolygonOnTriangulation();
T = PT->Triangulation();
L = E.Location() * PT->Location();
void
BRep_Tool::PolygonOnTriangulation(const TopoDS_Edge& E,
- Handle(Poly_PolygonOnTriangulation)& P,
- Handle(Poly_Triangulation)& T,
- TopLoc_Location& L,
- const Standard_Integer Index)
+ Handle(Poly_PolygonOnTriangulation)& P,
+ Handle(Poly_Triangulation)& T,
+ TopLoc_Location& L,
+ const Standard_Integer Index)
{
Standard_Integer i = 0;
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsPolygonOnTriangulation()) {
const Handle(BRep_PolygonOnTriangulation)& PT =
- *((Handle(BRep_PolygonOnTriangulation)*)&cr);
+ *((Handle(BRep_PolygonOnTriangulation)*)&cr);
i++;
if (i > Index) break;
if (i == Index) {
- T = PT->Triangulation();
- P = PT->PolygonOnTriangulation();
- L = E.Location() * PT->Location();
- return;
+ T = PT->Triangulation();
+ P = PT->PolygonOnTriangulation();
+ L = E.Location() * PT->Location();
+ return;
}
}
itcr.Next();
//=======================================================================
Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
- const TopoDS_Face& F)
+ const TopoDS_Face& F)
{
TopLoc_Location l;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,l);
//=======================================================================
Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L)
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L)
{
//modified by NIZNHY-PKV Fri Oct 17 12:16:58 2008f
if (IsPlane(S)) {
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurveOnSurface(S,l) &&
- cr->IsCurveOnClosedSurface())
+ cr->IsCurveOnClosedSurface())
return Standard_True;
itcr.Next();
}
//=======================================================================
Standard_Boolean BRep_Tool::IsClosed(const TopoDS_Edge& E,
- const Handle(Poly_Triangulation)& T)
+ const Handle(Poly_Triangulation)& T)
{
TopLoc_Location l = E.Location();
while (itcr.More()) {
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsPolygonOnTriangulation(T,l) &&
- cr->IsPolygonOnClosedTriangulation())
+ cr->IsPolygonOnClosedTriangulation())
return Standard_True;
itcr.Next();
}
//=======================================================================
void BRep_Tool::Range(const TopoDS_Edge& E,
- Standard_Real& First,
- Standard_Real& Last)
+ Standard_Real& First,
+ Standard_Real& Last)
{
// set the range to all the representations
BRep_ListIteratorOfListOfCurveRepresentation itcr
if (cr->IsCurve3D()) {
const Handle(BRep_Curve3D)& CR = *((Handle(BRep_Curve3D)*)&cr);
if (!CR->Curve3D().IsNull()) {
- First = CR->First();
- Last = CR->Last();
- break;
+ First = CR->First();
+ Last = CR->Last();
+ break;
}
}
else if (cr->IsCurveOnSurface()) {
//=======================================================================
void BRep_Tool::Range(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L,
- Standard_Real& First,
- Standard_Real& Last)
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L,
+ Standard_Real& First,
+ Standard_Real& Last)
{
TopLoc_Location l = L.Predivided(E.Location());
//=======================================================================
void BRep_Tool::Range(const TopoDS_Edge& E,
- const TopoDS_Face& F,
- Standard_Real& First,
- Standard_Real& Last)
+ const TopoDS_Face& F,
+ Standard_Real& First,
+ Standard_Real& Last)
{
TopLoc_Location L;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
//=======================================================================
void BRep_Tool::UVPoints(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L,
- gp_Pnt2d& PFirst,
- gp_Pnt2d& PLast)
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L,
+ gp_Pnt2d& PFirst,
+ gp_Pnt2d& PLast)
{
TopLoc_Location l = L.Predivided(E.Location());
Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurveOnSurface(S,l)) {
if (cr->IsCurveOnClosedSurface() && Eisreversed)
- (*((Handle(BRep_CurveOnClosedSurface)*)&cr))->UVPoints2(PFirst,PLast);
+ (*((Handle(BRep_CurveOnClosedSurface)*)&cr))->UVPoints2(PFirst,PLast);
else
- (*((Handle(BRep_CurveOnSurface)*)&cr))->UVPoints(PFirst,PLast);
+ (*((Handle(BRep_CurveOnSurface)*)&cr))->UVPoints(PFirst,PLast);
return;
}
itcr.Next();
//=======================================================================
void BRep_Tool::UVPoints(const TopoDS_Edge& E,
- const TopoDS_Face& F,
- gp_Pnt2d& PFirst,
- gp_Pnt2d& PLast)
+ const TopoDS_Face& F,
+ gp_Pnt2d& PFirst,
+ gp_Pnt2d& PLast)
{
TopLoc_Location L;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
//=======================================================================
void BRep_Tool::SetUVPoints(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L,
- const gp_Pnt2d& PFirst,
- const gp_Pnt2d& PLast)
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L,
+ const gp_Pnt2d& PFirst,
+ const gp_Pnt2d& PLast)
{
TopLoc_Location l = L.Predivided(E.Location());
Standard_Boolean Eisreversed = (E.Orientation() == TopAbs_REVERSED);
const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
if (cr->IsCurveOnSurface(S,l)) {
if (cr->IsCurveOnClosedSurface() && Eisreversed)
- (*((Handle(BRep_CurveOnClosedSurface)*) &cr))->
- SetUVPoints2(PFirst,PLast);
+ (*((Handle(BRep_CurveOnClosedSurface)*) &cr))->
+ SetUVPoints2(PFirst,PLast);
else
- (*((Handle(BRep_CurveOnSurface)*) &cr))->
- SetUVPoints(PFirst,PLast);
+ (*((Handle(BRep_CurveOnSurface)*) &cr))->
+ SetUVPoints(PFirst,PLast);
}
itcr.Next();
}
//=======================================================================
void BRep_Tool::SetUVPoints(const TopoDS_Edge& E,
- const TopoDS_Face& F,
- const gp_Pnt2d& PFirst,
- const gp_Pnt2d& PLast)
+ const TopoDS_Face& F,
+ const gp_Pnt2d& PFirst,
+ const gp_Pnt2d& PLast)
{
TopLoc_Location L;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
//=======================================================================
Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E,
- const TopoDS_Face& F1,
- const TopoDS_Face& F2)
+ const TopoDS_Face& F1,
+ const TopoDS_Face& F2)
{
TopLoc_Location l1,l2;
const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1,l1);
//=======================================================================
GeomAbs_Shape BRep_Tool::Continuity(const TopoDS_Edge& E,
- const TopoDS_Face& F1,
- const TopoDS_Face& F2)
+ const TopoDS_Face& F1,
+ const TopoDS_Face& F2)
{
TopLoc_Location l1,l2;
const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1,l1);
//=======================================================================
Standard_Boolean BRep_Tool::HasContinuity(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S1,
- const Handle(Geom_Surface)& S2,
- const TopLoc_Location& L1,
- const TopLoc_Location& L2)
+ const Handle(Geom_Surface)& S1,
+ const Handle(Geom_Surface)& S2,
+ const TopLoc_Location& L1,
+ const TopLoc_Location& L2)
{
const TopLoc_Location& Eloc = E.Location();
TopLoc_Location l1 = L1.Predivided(Eloc);
//=======================================================================
GeomAbs_Shape BRep_Tool::Continuity(const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S1,
- const Handle(Geom_Surface)& S2,
- const TopLoc_Location& L1,
- const TopLoc_Location& L2)
+ const Handle(Geom_Surface)& S1,
+ const Handle(Geom_Surface)& S2,
+ const TopLoc_Location& L1,
+ const TopLoc_Location& L2)
{
TopLoc_Location l1 = L1.Predivided(E.Location());
TopLoc_Location l2 = L2.Predivided(E.Location());
//=======================================================================
Standard_Real BRep_Tool::Parameter(const TopoDS_Vertex& V,
- const TopoDS_Edge& E)
+ const TopoDS_Edge& E)
{
// Search the vertex in the edge
const TopoDS_Shape& Vcur = itv.Value();
if (V.IsSame(Vcur)) {
if (VF.IsNull()) {
- VF = Vcur;
+ VF = Vcur;
}
else {
- rev = E.Orientation() == TopAbs_REVERSED;
- if (Vcur.Orientation() == V.Orientation()) {
- VF = Vcur;
- }
+ rev = E.Orientation() == TopAbs_REVERSED;
+ if (Vcur.Orientation() == V.Orientation()) {
+ VF = Vcur;
+ }
}
}
itv.Next();
L = L.Predivided(V.Location());
if (!C.IsNull() || Degenerated(E)) {
BRep_ListIteratorOfListOfPointRepresentation itpr
- ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
+ ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
while (itpr.More()) {
- const Handle(BRep_PointRepresentation)& pr = itpr.Value();
- if (pr->IsPointOnCurve(C,L)) {
- Standard_Real p = pr->Parameter();
- Standard_Real res = p;// SVV 4 nov 99 - to avoid warnings on Linux
- if (!C.IsNull()) {
- // Closed curves RLE 16 june 94
- if (Precision::IsNegativeInfinite(f)) return pr->Parameter();//p;
- if (Precision::IsPositiveInfinite(l)) return pr->Parameter();//p;
- gp_Pnt Pf = C->Value(f).Transformed(L.Transformation());
- gp_Pnt Pl = C->Value(l).Transformed(L.Transformation());
- Standard_Real tol = BRep_Tool::Tolerance(V);
- if (Pf.Distance(Pl) < tol) {
- if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) {
- if (V.Orientation() == TopAbs_FORWARD) res = f;//p = f;
- else res = l;//p = l;
- }
- }
- }
- return res;//p;
- }
- itpr.Next();
+ const Handle(BRep_PointRepresentation)& pr = itpr.Value();
+ if (pr->IsPointOnCurve(C,L)) {
+ Standard_Real p = pr->Parameter();
+ Standard_Real res = p;// SVV 4 nov 99 - to avoid warnings on Linux
+ if (!C.IsNull()) {
+ // Closed curves RLE 16 june 94
+ if (Precision::IsNegativeInfinite(f)) return pr->Parameter();//p;
+ if (Precision::IsPositiveInfinite(l)) return pr->Parameter();//p;
+ gp_Pnt Pf = C->Value(f).Transformed(L.Transformation());
+ gp_Pnt Pl = C->Value(l).Transformed(L.Transformation());
+ Standard_Real tol = BRep_Tool::Tolerance(V);
+ if (Pf.Distance(Pl) < tol) {
+ if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) {
+ if (V.Orientation() == TopAbs_FORWARD) res = f;//p = f;
+ else res = l;//p = l;
+ }
+ }
+ }
+ return res;//p;
+ }
+ itpr.Next();
}
}
else {
BRep_Tool::CurveOnSurface(E,PC,S,L,f,l);
L = L.Predivided(V.Location());
BRep_ListIteratorOfListOfPointRepresentation itpr
- ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
+ ((*((Handle(BRep_TVertex)*) &V.TShape()))->Points());
while (itpr.More()) {
- const Handle(BRep_PointRepresentation)& pr = itpr.Value();
- if (pr->IsPointOnCurveOnSurface(PC,S,L)) {
- Standard_Real p = pr->Parameter();
- // Closed curves RLE 16 june 94
- if (PC->IsClosed()) {
- if ((p == PC->FirstParameter()) ||
- (p == PC->LastParameter())) {
- if (V.Orientation() == TopAbs_FORWARD) p = PC->FirstParameter();
- else p = PC->LastParameter();
- }
- }
- return p;
- }
- itpr.Next();
+ const Handle(BRep_PointRepresentation)& pr = itpr.Value();
+ if (pr->IsPointOnCurveOnSurface(PC,S,L)) {
+ Standard_Real p = pr->Parameter();
+ // Closed curves RLE 16 june 94
+ if (PC->IsClosed()) {
+ if ((p == PC->FirstParameter()) ||
+ (p == PC->LastParameter())) {
+ if (V.Orientation() == TopAbs_FORWARD) p = PC->FirstParameter();
+ else p = PC->LastParameter();
+ }
+ }
+ return p;
+ }
+ itpr.Next();
}
}
}
//=======================================================================
Standard_Real BRep_Tool::Parameter(const TopoDS_Vertex& V,
- const TopoDS_Edge& E,
- const TopoDS_Face& F)
+ const TopoDS_Edge& E,
+ const TopoDS_Face& F)
{
TopLoc_Location L;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
//=======================================================================
Standard_Real BRep_Tool::Parameter(const TopoDS_Vertex& V,
- const TopoDS_Edge& E,
- const Handle(Geom_Surface)& S,
- const TopLoc_Location& L)
+ const TopoDS_Edge& E,
+ const Handle(Geom_Surface)& S,
+ const TopLoc_Location& L)
{
// Search the vertex in the edge
if (V.IsSame(itv.Value())) {
if (VF.IsNull()) VF = itv.Value();
else {
- rev = E.Orientation() == TopAbs_REVERSED;
- if (itv.Value().Orientation() == V.Orientation())
- VF = itv.Value();
+ rev = E.Orientation() == TopAbs_REVERSED;
+ if (itv.Value().Orientation() == V.Orientation())
+ VF = itv.Value();
}
}
itv.Next();
while (itpr.More()) {
const Handle(BRep_PointRepresentation)& pr = itpr.Value();
if (pr->IsPointOnCurve(C,L1)) {
- Standard_Real p = pr->Parameter();
- Standard_Real res = p;
- if (!C.IsNull()) {
- // Closed curves RLE 16 june 94
- if (Precision::IsNegativeInfinite(f)) return res;
- if (Precision::IsPositiveInfinite(l)) return res;
- gp_Pnt Pf = C->Value(f).Transformed(L1.Transformation());
- gp_Pnt Pl = C->Value(l).Transformed(L1.Transformation());
- Standard_Real tol = BRep_Tool::Tolerance(V);
- if (Pf.Distance(Pl) < tol) {
- if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) {
- if (V.Orientation() == TopAbs_FORWARD) res = f;
- else res = l;
- }
- }
- }
- return res;
+ Standard_Real p = pr->Parameter();
+ Standard_Real res = p;
+ if (!C.IsNull()) {
+ // Closed curves RLE 16 june 94
+ if (Precision::IsNegativeInfinite(f)) return res;
+ if (Precision::IsPositiveInfinite(l)) return res;
+ gp_Pnt Pf = C->Value(f).Transformed(L1.Transformation());
+ gp_Pnt Pl = C->Value(l).Transformed(L1.Transformation());
+ Standard_Real tol = BRep_Tool::Tolerance(V);
+ if (Pf.Distance(Pl) < tol) {
+ if (Pf.Distance(BRep_Tool::Pnt(V)) < tol) {
+ if (V.Orientation() == TopAbs_FORWARD) res = f;
+ else res = l;
+ }
+ }
+ }
+ return res;
}
itpr.Next();
}
//=======================================================================
gp_Pnt2d BRep_Tool::Parameters(const TopoDS_Vertex& V,
- const TopoDS_Face& F)
+ const TopoDS_Face& F)
{
TopLoc_Location L;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(F,L);
while (itpr.More()) {
if (itpr.Value()->IsPointOnSurface(S,L)) {
return gp_Pnt2d(itpr.Value()->Parameter(),
- itpr.Value()->Parameter2());
+ itpr.Value()->Parameter2());
}
itpr.Next();
}
--- File: BRepMesh.cdl
--- Created: Wed Sep 22 17:34:57 1993
--- Author: Didier PIFFAULT
--- <dpf@zerox>
----Copyright: Matra Datavision 1993, 1994
+-- File: BRepMesh.cdl
+-- Created: Wed Sep 22 17:34:57 1993
+-- Author: Didier PIFFAULT
+-- <dpf@zerox>
+---Copyright: Matra Datavision 1993, 1994
-package BRepMesh
+package BRepMesh
- ---Purpose: Instantiated package for the class of packages
- -- MeshAlgo, and so on ...
+ ---Purpose: Instantiated package for the class of packages
+ -- MeshAlgo, and so on ...
---Level : Advanced.
-- All methods of all classes will be advanced.
uses Standard,
- gp,
- Bnd,
- TColStd,
- TColgp,
- GCPnts,
- BRepAdaptor,
- BRepTopAdaptor,
- MeshDS,
- MeshAlgo,
- TCollection,
- MMgt,
- TopoDS,
- TopAbs,
- TopExp,
- TopTools,
- Poly,
- Geom2d,
- GeomAbs,
- GeomAdaptor
+ gp,
+ Bnd,
+ TColStd,
+ TColgp,
+ GCPnts,
+ BRepAdaptor,
+ BRepTopAdaptor,
+ MeshDS,
+ MeshAlgo,
+ TCollection,
+ MMgt,
+ TopoDS,
+ TopAbs,
+ TopExp,
+ TopTools,
+ Poly,
+ Geom2d,
+ GeomAbs,
+ GeomAdaptor,
+ TopLoc
is
- enumeration Status is
- ---Purpose: Discribes the wires discretisation.
- NoError,
- OpenWire,
- SelfIntersectingWire,
- Failure,
- ReMesh
-
- end Status;
-
- enumeration FactoryError is
- FE_NOERROR,
- FE_LIBRARYNOTFOUND,
- FE_FUNCTIONNOTFOUND,
- FE_CANNOTCREATEALGO
- end FactoryError;
-
- class Vertex;
-
- class Edge;
-
- class Triangle;
-
- class ShapeTool;
-
- deferred class DiscretRoot;
- class DiscretFactory;
- --
- pointer PDiscretRoot to DiscretRoot from BRepMesh;
- --
-
- class Delaun instantiates Delaunay from MeshAlgo(Vertex from BRepMesh,
- Edge from BRepMesh,
- Triangle from BRepMesh);
-
- class DataMapOfVertexInteger instantiates DataMap from TCollection
- (Vertex from TopoDS, Integer from Standard, ShapeMapHasher from TopTools);
-
- class ListOfVertex instantiates List from TCollection
- (Vertex from BRepMesh);
+ enumeration Status is
+ ---Purpose: Discribes the wires discretisation.
+ NoError,
+ OpenWire,
+ SelfIntersectingWire,
+ Failure,
+ ReMesh
+ end Status;
+
+ enumeration FactoryError is
+ FE_NOERROR,
+ FE_LIBRARYNOTFOUND,
+ FE_FUNCTIONNOTFOUND,
+ FE_CANNOTCREATEALGO
+ end FactoryError;
+
+ class Vertex;
+
+ class Edge;
+
+ class Triangle;
+
+ class ShapeTool;
+
+ deferred class DiscretRoot;
+ class DiscretFactory;
+ --
+ pointer PDiscretRoot to DiscretRoot from BRepMesh;
+ --
+
+ class Delaun instantiates Delaunay from MeshAlgo(Vertex from BRepMesh,
+ Edge from BRepMesh,
+ Triangle from BRepMesh);
+
+ class DataMapOfVertexInteger instantiates DataMap from TCollection
+ (Vertex from TopoDS, Integer from Standard, ShapeMapHasher from TopTools);
+
+ class ListOfVertex instantiates List from TCollection
+ (Vertex from BRepMesh);
class ListOfXY instantiates List from TCollection (XY from gp);
- class DataMapOfIntegerListOfXY instantiates DataMap from TCollection
- (Integer from Standard, ListOfXY from BRepMesh, MapIntegerHasher from TColStd);
+ class DataMapOfIntegerListOfXY instantiates DataMap from TCollection
+ (Integer from Standard, ListOfXY from BRepMesh, MapIntegerHasher from TColStd);
- class VertexHasher instantiates MapHasher from TCollection(Vertex from BRepMesh);
+ class VertexHasher instantiates MapHasher from TCollection(Vertex from BRepMesh);
- class IndexedMapOfVertex instantiates IndexedMap from TCollection
- (Vertex from BRepMesh, VertexHasher from BRepMesh);
+ class IndexedMapOfVertex instantiates IndexedMap from TCollection
+ (Vertex from BRepMesh, VertexHasher from BRepMesh);
- class DataMapOfShapeReal instantiates DataMap from TCollection
- (Shape from TopoDS,
- Real from Standard,
- ShapeMapHasher from TopTools);
+ class DataMapOfShapeReal instantiates DataMap from TCollection
+ (Shape from TopoDS,
+ Real from Standard,
+ ShapeMapHasher from TopTools);
- class BiPoint;
-
- class Array1OfBiPoint instantiates Array1 from TCollection
- (BiPoint from BRepMesh);
+ class BiPoint;
+
+ class Array1OfBiPoint instantiates Array1 from TCollection(BiPoint from BRepMesh);
- class FastDiscret;
-
- class FaceAttribute;
-
- class DataMapOfFaceAttribute instantiates DataMap from TCollection
- (Face from TopoDS,
- FaceAttribute from BRepMesh,
- ShapeMapHasher from TopTools);
+ private class FastDiscretFace;
+
+ class FastDiscret;
+
+ class FaceAttribute;
+
+ class DataMapOfFaceAttribute instantiates DataMap from TCollection
+ (Face from TopoDS,
+ FaceAttribute from BRepMesh,
+ ShapeMapHasher from TopTools);
+
+ private class Classifier;
+ imported ClassifierPtr; -- smart pointer on Classifier
- private class FastDiscretFace;
-
- private class Classifier;
- imported ClassifierPtr; -- smart pointer on Classifier
+ class IncrementalMesh from BRepMesh;
+ ---Purpose: meshes faces from a Shape only if necessary.
- class IncrementalMesh from BRepMesh;
- ---Purpose: meshes faces from a Shape only if necessary.
+ ---- classes moved from MeshShape
+ class GeomTool;
- ---- classes moved from MeshShape
- class GeomTool;
+ class DataMapOfIntegerPnt instantiates
+ DataMap from TCollection (Integer from Standard,
+ Pnt from gp,
+ MapIntegerHasher from TColStd);
- class DataMapOfIntegerPnt instantiates
- DataMap from TCollection (Integer from Standard,
- Pnt from gp,
- MapIntegerHasher from TColStd);
+ class PairOfPolygon;
- class PairOfPolygon;
+ class DataMapOfShapePairOfPolygon instantiates
+ DataMap from TCollection(Shape from TopoDS,
+ PairOfPolygon from BRepMesh,
+ ShapeMapHasher from TopTools);
- class DataMapOfShapePairOfPolygon instantiates
- DataMap from TCollection(Shape from TopoDS,
- PairOfPolygon from BRepMesh,
- ShapeMapHasher from TopTools);
+ Mesh(S: Shape from TopoDS; d: Real from Standard);
+ ---Purpose: call to incremental mesh.
- Mesh(S: Shape from TopoDS; d: Real from Standard);
- ---Purpose: call to incremental mesh.
-
-
+
end BRepMesh;
--- File: BRepMesh_FastDiscret.cdl
--- Created: Tue Feb 27 14:21:35 1996
--- Author: Laurent PAINNOT
--- <lpa@nonox>
----Copyright: Matra Datavision 1996
+-- File: BRepMesh_FastDiscret.cdl
+-- Created: Tue Feb 27 14:21:35 1996
+-- Author: Laurent PAINNOT
+-- <lpa@nonox>
+---Copyright: Matra Datavision 1996
class FastDiscret from BRepMesh inherits TShared from MMgt
- ---Purpose: Algorithm to mesh a shape with respect of the
- -- frontier the deflection and by option the shared
- -- components.
+ ---Purpose: Algorithm to mesh a shape with respect of the
+ -- frontier the deflection and by option the shared
+ -- components.
uses Boolean from Standard,
- Integer from Standard,
- Box from Bnd,
- Real from Standard,
- Shape from TopoDS,
- Face from TopoDS,
- Edge from TopoDS,
- FaceAttribute from BRepMesh,
- Vertex from TopoDS,
- Triangle from BRepMesh,
- Vertex from BRepMesh,
- Edge from BRepMesh,
- ListOfInteger from TColStd,
- MapOfInteger from TColStd,
- SequenceOfInteger from TColStd,
- ListOfReal from TColStd,
- IndexedMapOfInteger from TColStd,
- SequenceOfPnt2d from TColgp,
- Dir from gp,
- Pnt from gp,
+ Integer from Standard,
+ Box from Bnd,
+ Real from Standard,
+ Shape from TopoDS,
+ Face from TopoDS,
+ Edge from TopoDS,
+ FaceAttribute from BRepMesh,
+ Vertex from TopoDS,
+ Triangle from BRepMesh,
+ Vertex from BRepMesh,
+ Edge from BRepMesh,
+ ListOfInteger from TColStd,
+ MapOfInteger from TColStd,
+ SequenceOfInteger from TColStd,
+ ListOfReal from TColStd,
+ IndexedMapOfInteger from TColStd,
+ SequenceOfPnt2d from TColgp,
+ Dir from gp,
+ Pnt from gp,
XY from gp,
- Pnt2d from gp,
- DataMapOfIntegerPnt from BRepMesh,
- DataMapOfIntegerListOfXY from BRepMesh,
- DataMapOfShapePairOfPolygon from BRepMesh,
- Delaun from BRepMesh,
- DataMapOfVertexInteger from BRepMesh,
- DataStructureOfDelaun from BRepMesh,
- ListOfVertex from BRepMesh,
- MapOfShape from TopTools,
- HSurface from BRepAdaptor,
- ClassifierPtr from BRepMesh,
+ Pnt2d from gp,
+ DataMapOfIntegerPnt from BRepMesh,
+ DataMapOfIntegerListOfXY from BRepMesh,
+ DataMapOfShapePairOfPolygon from BRepMesh,
+ Delaun from BRepMesh,
+ DataMapOfVertexInteger from BRepMesh,
+ DataStructureOfDelaun from BRepMesh,
+ ListOfVertex from BRepMesh,
+ MapOfShape from TopTools,
+ HSurface from BRepAdaptor,
+ ClassifierPtr from BRepMesh,
IndexedMapOfReal from TColStd,
- Status from BRepMesh,
- DataMapOfShapeReal from TopTools,
- ListOfShape from TopTools,
- Curve from Geom2d,
- MapOfInteger from MeshDS,
- BaseAllocator from MeshDS,
- DataMapOfFaceAttribute from BRepMesh
-
+ Status from BRepMesh,
+ DataMapOfShapeReal from TopTools,
+ ListOfShape from TopTools,
+ Curve from Geom2d,
+ MapOfInteger from MeshDS,
+ BaseAllocator from MeshDS,
+ DataMapOfFaceAttribute from BRepMesh
+
+
+is
+
+ Create (defle : Real from Standard;
+ angle : Real from Standard;
+ B : Box from Bnd;
+ withShare : Boolean from Standard=Standard_True;
+ inshape : Boolean from Standard=Standard_False;
+ relative : Boolean from Standard=Standard_False;
+ shapetrigu: Boolean from Standard=Standard_False)
+ returns mutable FastDiscret from BRepMesh;
-is
Create (defle : Real from Standard;
- angle : Real from Standard;
- B : Box from Bnd;
- withShare : Boolean from Standard=Standard_True;
- inshape : Boolean from Standard=Standard_False;
- relative : Boolean from Standard=Standard_False;
- shapetrigu: Boolean from Standard=Standard_False)
- returns mutable FastDiscret from BRepMesh;
-
-
- Create (defle : Real from Standard;
- shape : Shape from TopoDS;
- B : Box from Bnd;
- angle : Real from Standard;
- withShare : Boolean from Standard=Standard_True;
- inshape : Boolean from Standard=Standard_False;
- relative : Boolean from Standard=Standard_False;
- shapetrigu: Boolean from Standard=Standard_False)
- ---Purpose: if the boolean <relative> is True, the
- -- deflection used for the polygonalisation of
- -- each edge will be <defle> * Size of Edge.
- -- the deflection used for the faces will be the maximum
- -- deflection of their edges.
- --
- -- if <shapetrigu> is True, the triangulation, if exists
- -- with a correct deflection, can be used to re-triangulate
- -- the shape.
- --
- -- if <inshape> is True, the calculated
- -- triangulation will be stored in the shape.
- returns mutable FastDiscret from BRepMesh;
-
-
- Perform (me: mutable; shape: Shape from TopoDS) is static;
- ---Purpose: Build triangulation on the whole shape
-
- Add (me: mutable; face: Face from TopoDS) is static;
- ---Purpose: Record a face for further processing.
-
- Process (me; face: Face from TopoDS) is static;
- ---Purpose: Triangulate a face previously recorded for
- -- processing by call to Add(). Can be executed in
- -- parallel threads.
- ---C++: alias operator ()
-
- InternalVerticesMode(me: mutable) returns Boolean from Standard;
- ---Purpose: Returns mode defining if internal vertices on faces
- -- are taken into consideration or not. If this mode is equal to true
- -- that internal vertices on faces are considered during triangulation.
- -- Default value is equal to false (old behaviour).
- ---C++: return &
- ---C++: inline
-
- CurrentFaceStatus(me)
- returns Status from BRepMesh;
-
- Add (me : mutable;
- edge : Edge from TopoDS;
- face : Face from TopoDS;
- S : HSurface from BRepAdaptor;
- C : Curve from Geom2d;
- defedge: Real from Standard;
+ shape : Shape from TopoDS;
+ B : Box from Bnd;
+ angle : Real from Standard;
+ withShare : Boolean from Standard=Standard_True;
+ inshape : Boolean from Standard=Standard_False;
+ relative : Boolean from Standard=Standard_False;
+ shapetrigu: Boolean from Standard=Standard_False)
+ ---Purpose: if the boolean <relative> is True, the
+ -- deflection used for the polygonalisation of
+ -- each edge will be <defle> * Size of Edge.
+ -- the deflection used for the faces will be the maximum
+ -- deflection of their edges.
+ --
+ -- if <shapetrigu> is True, the triangulation, if exists
+ -- with a correct deflection, can be used to re-triangulate
+ -- the shape.
+ --
+ -- if <inshape> is True, the calculated
+ -- triangulation will be stored in the shape.
+ returns mutable FastDiscret from BRepMesh;
+
+
+ Perform (me: mutable; shape: Shape from TopoDS) is static;
+ ---Purpose: Build triangulation on the whole shape
+
+ Add (me: mutable; face: Face from TopoDS) is static;
+ ---Purpose: Record a face for further processing.
+
+ Process (me; face: Face from TopoDS) is static;
+ ---Purpose: Triangulate a face previously recorded for
+ -- processing by call to Add(). Can be executed in
+ -- parallel threads.
+ ---C++: alias operator ()
+
+ CurrentFaceStatus(me)
+ returns Status from BRepMesh;
+
+ Add (me : mutable;
+ edge : Edge from TopoDS;
+ face : Face from TopoDS;
+ S : HSurface from BRepAdaptor;
+ C : Curve from Geom2d;
+ defedge: Real from Standard;
first : Real from Standard;
last : Real from Standard)
- is static private;
-
- Add (me : mutable;
+ is static private;
+
+ Add (me : mutable;
theVert: Vertex from TopoDS;
- face : Face from TopoDS;
- S : HSurface from BRepAdaptor) is private;
+ face : Face from TopoDS;
+ S : HSurface from BRepAdaptor) is private;
- Update (me: mutable;
- Edge: Edge from TopoDS;
- Face: Face from TopoDS;
+ Update (me: mutable;
+ Edge : Edge from TopoDS;
+ Face : Face from TopoDS;
C : Curve from Geom2d;
- defedge: Real from Standard;
- first : Real from Standard;
- last : Real from Standard)
-
- returns Boolean is private;
-
-
- InternalVertices
- (me : mutable;
- caro : HSurface from BRepAdaptor;
- inter : in out ListOfVertex from BRepMesh;
- defedge : Real from Standard;
- classifier : ClassifierPtr from BRepMesh)
- is static private;
-
-
- Control
- (me : mutable;
- caro : HSurface from BRepAdaptor;
- defface : Real from Standard;
- inter : in out ListOfVertex from BRepMesh;
- badTri : in out ListOfInteger from TColStd;
- nulTri : in out ListOfInteger from TColStd;
- trigu : in out Delaun from BRepMesh;
- isfirst : Boolean from Standard)
- returns Real from Standard is static private;
-
-
- FindUV(me: mutable; V: Vertex from TopoDS;
- XY: Pnt2d from gp;
- ip: Integer from Standard;
- S : HSurface from BRepAdaptor;
- mindist: Real from Standard)
- returns XY from gp is private;
-
- AddInShape(me: mutable; face : Face from TopoDS;
- defedge: Real from Standard)
- is static private;
+ defedge: Real from Standard;
+ first : Real from Standard;
+ last : Real from Standard)
+ returns Boolean is private;
+
+
+ InternalVertices
+ (me : mutable;
+ caro : HSurface from BRepAdaptor;
+ inter : in out ListOfVertex from BRepMesh;
+ defedge : Real from Standard;
+ classifier : ClassifierPtr from BRepMesh)
+ is static private;
+
+
+ Control (me : mutable;
+ caro : HSurface from BRepAdaptor;
+ defface : Real from Standard;
+ inter : in out ListOfVertex from BRepMesh;
+ badTri : in out ListOfInteger from TColStd;
+ nulTri : in out ListOfInteger from TColStd;
+ trigu : in out Delaun from BRepMesh;
+ isfirst : Boolean from Standard)
+ returns Real from Standard is static private;
+
+ AddInShape(me: mutable;
+ face : Face from TopoDS;
+ defedge: Real from Standard)
+ is static private;
-- Output :
- NbTriangles(me)
- ---Purpose: Gives the number of built triangles.
- returns Integer from Standard
- is static;
+ NbTriangles(me)
+ ---Purpose: Gives the number of built triangles.
+ returns Integer from Standard
+ is static;
+
+ Triangle (me;
+ Index : Integer from Standard)
+ ---Purpose: Gives the triangle of <Index>.
+ ---C++: return const &
+ returns Triangle from BRepMesh
+ is static;
+
- Triangle (me;
- Index : Integer from Standard)
- ---Purpose: Gives the triangle of <Index>.
- ---C++: return const &
- returns Triangle from BRepMesh
- is static;
+ NbEdges (me)
+ ---Purpose: Gives the number of built Edges
+ returns Integer from Standard
+ is static;
+ Edge (me;
+ Index : Integer from Standard)
+ ---Purpose: Gives the edge of index <Index>.
+ ---C++: return const &
+ returns Edge from BRepMesh
+ is static;
- NbEdges (me)
- ---Purpose: Gives the number of built Edges
- returns Integer from Standard
- is static;
+ NbVertices (me)
+ ---Purpose: Gives the number of built Vertices.
+ returns Integer from Standard
+ is static;
- Edge (me;
- Index : Integer from Standard)
- ---Purpose: Gives the edge of index <Index>.
- ---C++: return const &
- returns Edge from BRepMesh
- is static;
+ Vertex (me;
+ Index : Integer from Standard)
+ ---Purpose: Gives the vertex of <Index>.
+ ---C++: return const &
+ returns Vertex from BRepMesh
+ is static;
+ Pnt (me;
+ Index : Integer from Standard)
+ ---Purpose: Gives the location3d of the vertex of <Index>.
+ ---C++: return const &
+ returns Pnt from gp
+ is static;
- NbVertices (me)
- ---Purpose: Gives the number of built Vertices.
- returns Integer from Standard
- is static;
+ VerticesOfDomain
+ (me; Indices : in out MapOfInteger from MeshDS)
+ ---Purpose: Gives the list of indices of the vertices
+ is static;
- Vertex (me;
- Index : Integer from Standard)
- ---Purpose: Gives the vertex of <Index>.
- ---C++: return const &
- returns Vertex from BRepMesh
- is static;
- Pnt (me;
- Index : Integer from Standard)
- ---Purpose: Gives the location3d of the vertex of <Index>.
- ---C++: return const &
- returns Pnt from gp
- is static;
+ EdgesOfDomain
+ (me; Indices : in out MapOfInteger from MeshDS)
+ ---Purpose: Gives the list of indices of the edges
+ ---C++: inline
+ is static;
- VerticesOfDomain
- (me; Indices : in out MapOfInteger from MeshDS)
- ---Purpose: Gives the list of indices of the vertices
- is static;
+ TrianglesOfDomain(me; Indices: in out MapOfInteger from MeshDS)
+ ---Purpose: Gives the list of indices of the triangles
+ ---C++: inline
+ is static;
- EdgesOfDomain
- (me; Indices : in out MapOfInteger from MeshDS)
- ---Purpose: Gives the list of indices of the edges
- ---C++: inline
- is static;
+ NbPoint3d (me)
+ ---Purpose: Gives the number of different location in 3d
+ -- space. It is different of the number of
+ -- vertices if there is more than one surface.
+ -- Even for one surface, the number can be different
+ -- if an edge is shared.
+ ---C++: inline
+ returns Integer from Standard
+ is static;
- TrianglesOfDomain(me; Indices: in out MapOfInteger from MeshDS)
- ---Purpose: Gives the list of indices of the triangles
- ---C++: inline
+ Point3d (me;
+ Index : Integer from Standard)
+ ---Purpose: Gives the 3d space location of the vertex <Index>.
+ ---C++: return const &
+ ---C++: inline
+ returns Pnt from gp
is static;
-
-
- NbPoint3d (me)
- ---Purpose: Gives the number of different location in 3d
- -- space. It is different of the number of
- -- vertices if there is more than one surface.
- -- Even for one surface, the number can be different
- -- if an edge is shared.
- ---C++: inline
- returns Integer from Standard
- is static;
-
- Point3d (me;
- Index : Integer from Standard)
- ---Purpose: Gives the 3d space location of the vertex <Index>.
- ---C++: return const &
- ---C++: inline
- returns Pnt from gp
- is static;
-
-
- GetDeflection(me)
- ---Purpose: returns the deflection value.
- ---C++: inline
- returns Real from Standard;
-
- GetAngle(me)
- ---Purpose: returns the deflection value.
- ---C++: inline
- returns Real from Standard;
-
- WithShare(me)
- ---C++: inline
- returns Boolean from Standard;
-
- InShape(me)
- ---C++: inline
- returns Boolean from Standard;
-
+
+
+ GetDeflection(me)
+ ---Purpose: returns the deflection value.
+ ---C++: inline
+ returns Real from Standard;
+
+ GetAngle(me)
+ ---Purpose: returns the deflection value.
+ ---C++: inline
+ returns Real from Standard;
+
+ WithShare(me)
+ ---C++: inline
+ returns Boolean from Standard;
+
+ InShape(me)
+ ---C++: inline
+ returns Boolean from Standard;
+
ShapeTrigu(me)
- ---C++: inline
- returns Boolean from Standard;
-
- GetFaceAttribute(me;
- face : Face from TopoDS;
- fattrib : in out FaceAttribute from BRepMesh)
- ---Purpose: returns the face deflection value.
- returns Boolean from Standard;
-
- RemoveFaceAttribute(me : mutable;
- face : Face from TopoDS);
- ---Purpose: remove face attribute as useless to free locate memory
-
+ ---C++: inline
+ returns Boolean from Standard;
+
+ GetFaceAttribute(me;
+ face : Face from TopoDS;
+ fattrib : in out FaceAttribute from BRepMesh)
+ ---Purpose: returns the face deflection value.
+ returns Boolean from Standard;
+
+ RemoveFaceAttribute(me : mutable;
+ face : Face from TopoDS);
+ ---Purpose: remove face attribute as useless to free locate memory
+
GetMapOfDefEdge(me)
- ---C++: return const &
- ---C++: inline
- returns DataMapOfShapeReal from TopTools;
-
+ ---C++: return const &
+ ---C++: inline
+ returns DataMapOfShapeReal from TopTools;
+
fields
- myangle : Real from Standard;
- mydeflection : Real from Standard;
- mydtotale : Real from Standard;
- myWithShare : Boolean from Standard;
- vertices : DataMapOfVertexInteger from BRepMesh;
- edges : DataMapOfShapePairOfPolygon from BRepMesh;
- internaledges: DataMapOfShapePairOfPolygon from BRepMesh;
- nbLocat : Integer from Standard;
- Location3d : DataMapOfIntegerPnt from BRepMesh;
- structure : DataStructureOfDelaun from BRepMesh;
- mapattrib : DataMapOfFaceAttribute from BRepMesh;
- myvemap : IndexedMapOfInteger from TColStd;
- mylocation2d : DataMapOfIntegerListOfXY from BRepMesh;
- myrelative : Boolean from Standard;
- myshapetrigu : Boolean from Standard;
- myinshape : Boolean from Standard;
- myInternalVerticesMode : Boolean from Standard; --mode to accounting internal vertices
- myfacestate : Status from BRepMesh;
- mapdefle : DataMapOfShapeReal from TopTools;
- mynottriangulated : ListOfShape from TopTools;
- myAllocator : BaseAllocator from MeshDS;
-
+ myAngle : Real from Standard;
+ myDeflection : Real from Standard;
+ myDtotale : Real from Standard;
+ myWithShare : Boolean from Standard;
+ myVertices : DataMapOfVertexInteger from BRepMesh;
+ myEdges : DataMapOfShapePairOfPolygon from BRepMesh;
+ myInternaledges: DataMapOfShapePairOfPolygon from BRepMesh;
+ myNbLocat : Integer from Standard;
+ myLocation3d : DataMapOfIntegerPnt from BRepMesh;
+ myStructure : DataStructureOfDelaun from BRepMesh;
+ myMapattrib : DataMapOfFaceAttribute from BRepMesh;
+ myVemap : IndexedMapOfInteger from TColStd;
+ myLocation2d : DataMapOfIntegerListOfXY from BRepMesh;
+ myRelative : Boolean from Standard;
+ myShapetrigu : Boolean from Standard;
+ myInshape : Boolean from Standard;
+ myFacestate : Status from BRepMesh;
+ myMapdefle : DataMapOfShapeReal from TopTools;
+ myNottriangulated : ListOfShape from TopTools;
+ myAllocator : BaseAllocator from MeshDS;
+
end FastDiscret;
-// File: BRepMesh_FastDiscret.cxx
-// Created: Tue Feb 27 16:39:53 1996
-// Author: Ekaterina SMIRNOVA
+// File: BRepMesh_FastDiscret.cxx
+// Created: Tue Feb 27 16:39:53 1996
+// Author: Ekaterina SMIRNOVA
// Copyright: Open CASCADE SAS 2008
#include <BRepMesh_FastDiscret.ixx>
//function : BRepMesh_FastDiscret
//purpose :
//=======================================================================
-BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real defle,
- const Standard_Real angl,
- const Bnd_Box& Box,
- const Standard_Boolean ws,
- const Standard_Boolean inshape,
- const Standard_Boolean relative,
- const Standard_Boolean shapetrigu):
- myangle(angl), mydeflection(defle),myWithShare(ws), nbLocat(0),
- myrelative(relative), myshapetrigu(shapetrigu), myinshape(inshape),
- myInternalVerticesMode(Standard_True)
+BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
+ const Standard_Real theAngl,
+ const Bnd_Box& theBox,
+ const Standard_Boolean theWithShare,
+ const Standard_Boolean theInshape,
+ const Standard_Boolean theRelative,
+ const Standard_Boolean theShapetrigu) :
+ myAngle(theAngl), myDeflection(theDefle),myWithShare(theWithShare),
+ myNbLocat(0), myRelative(theRelative), myShapetrigu(theShapetrigu),
+ myInshape(theInshape)
{
myAllocator = new NCollection_IncAllocator(64000);
- if (relative)
+ if (theRelative)
{
Standard_Real TXmin, TYmin, TZmin, TXmax, TYmax, TZmax;
- Box.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
- mydtotale = TXmax-TXmin;
+ theBox.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
+ myDtotale = TXmax-TXmin;
const Standard_Real dy = TYmax-TYmin;
const Standard_Real dz = TZmax-TZmin;
- if (dy > mydtotale) mydtotale = dy;
- if (dz > mydtotale) mydtotale = dz;
+ if (dy > myDtotale) myDtotale = dy;
+ if (dz > myDtotale) myDtotale = dz;
}
}
//purpose :
//=======================================================================
-BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real defle,
- const TopoDS_Shape& shape,
- const Bnd_Box& Box,
- const Standard_Real angl,
- const Standard_Boolean ws,
- const Standard_Boolean inshape,
- const Standard_Boolean relative,
- const Standard_Boolean shapetrigu):
- myangle(angl), mydeflection(defle),myWithShare(ws), nbLocat(0),
- myrelative(relative), myshapetrigu(shapetrigu), myinshape(inshape),
- myInternalVerticesMode(Standard_True)
+BRepMesh_FastDiscret::BRepMesh_FastDiscret(const Standard_Real theDefle,
+ const TopoDS_Shape& theShape,
+ const Bnd_Box& theBox,
+ const Standard_Real theAngl,
+ const Standard_Boolean theWithShare,
+ const Standard_Boolean theInshape,
+ const Standard_Boolean theRelative,
+ const Standard_Boolean theShapetrigu):
+ myAngle(theAngl), myDeflection(theDefle),myWithShare(theWithShare),
+ myNbLocat(0), myRelative(theRelative), myShapetrigu(theShapetrigu),
+ myInshape(theInshape)
{
myAllocator = new NCollection_IncAllocator(64000);
- if (relative)
+ if (theRelative)
{
Standard_Real TXmin, TYmin, TZmin, TXmax, TYmax, TZmax;
- Box.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
- mydtotale = TXmax-TXmin;
+ theBox.Get(TXmin, TYmin, TZmin, TXmax, TYmax, TZmax);
+ myDtotale = TXmax-TXmin;
const Standard_Real dy = TYmax-TYmin;
const Standard_Real dz = TZmax-TZmin;
- if (dy > mydtotale) mydtotale = dy;
- if (dz > mydtotale) mydtotale = dz;
+ if (dy > myDtotale) myDtotale = dy;
+ if (dz > myDtotale) myDtotale = dz;
}
- Perform(shape);
+ Perform(theShape);
}
//=======================================================================
//purpose :
//=======================================================================
-void BRepMesh_FastDiscret::Perform(const TopoDS_Shape& shape)
+void BRepMesh_FastDiscret::Perform(const TopoDS_Shape& theShape)
{
std::vector<TopoDS_Face> aFaces;
- for (TopExp_Explorer ex(shape, TopAbs_FACE); ex.More(); ex.Next()) {
+ for (TopExp_Explorer ex(theShape, TopAbs_FACE); ex.More(); ex.Next()) {
TopoDS_Face aF = TopoDS::Face(ex.Current());
Add(aF);
aFaces.push_back(aF);
Handle(BRepMesh_FaceAttribute) fattribute;
if ( GetFaceAttribute (theFace, fattribute) )
{
- BRepMesh_FastDiscretFace aTool (GetAngle(), WithShare(), InShape(), ShapeTrigu());
+ BRepMesh_FastDiscretFace aTool (GetAngle(), WithShare());
aTool.Add (theFace, fattribute, GetMapOfDefEdge());
}
//cout << "END face " << theFace.TShape().operator->() << endl << flush;
#define MESH_FAILURE(theface) \
{ \
- myfacestate = BRepMesh_Failure; \
- mynottriangulated.Append(theface); \
+ myFacestate = BRepMesh_Failure; \
+ myNottriangulated.Append(theface); \
return; \
}
TopoDS_Face face = theface;
BRepTools::Update(face);
face.Orientation(TopAbs_FORWARD);
- structure.Nullify();
+ myStructure.Nullify();
Handle(NCollection_IncAllocator) anAlloc = Handle(NCollection_IncAllocator)::DownCast(myAllocator);
anAlloc->Reset(Standard_False);
- structure=new BRepMesh_DataStructureOfDelaun(anAlloc);
+ myStructure=new BRepMesh_DataStructureOfDelaun(anAlloc);
BRepAdaptor_Surface BS(face, Standard_False);
Handle(BRepAdaptor_HSurface) gFace = new BRepAdaptor_HSurface(BS);
TopLoc_Location loc;
if (!myWithShare) {
- vertices.Clear();
- edges.Clear();
+ myVertices.Clear();
+ myEdges.Clear();
}
- myvemap.Clear();
- mylocation2d.Clear();
- internaledges.Clear();
+ myVemap.Clear();
+ myLocation2d.Clear();
+ myInternaledges.Clear();
Standard_Integer i;
i = 1;
Standard_Real defedge, defface;
Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax, dx, dy, dz;
Standard_Integer nbEdge = 0;
- Standard_Real savangle = myangle;
+ Standard_Real savangle = myAngle;
Standard_Real cdef;
Standard_Real maxdef = 2.* MaxFaceTol(theface);
defface = 0.;
- if (!myrelative) defface = Max(mydeflection, maxdef);
+ if (!myRelative) defface = Max(myDeflection, maxdef);
TColStd_SequenceOfReal aFSeq, aLSeq;
TColGeom2d_SequenceOfCurve aCSeq;
for(; ex.More(); ex.Next()) {
const TopoDS_Edge& edge = TopoDS::Edge(ex.Value());
nbEdge++;
- if (!mapdefle.IsBound(edge)) {
- if (myrelative) {
- if (edges.IsBound(edge)) {
- const BRepMesh_PairOfPolygon& pair = edges.Find(edge);
- const Handle(Poly_PolygonOnTriangulation)& P = pair.First();
- defedge = P->Deflection();
- }
+ if (!myMapdefle.IsBound(edge)) {
+ if (myRelative) {
+ if (myEdges.IsBound(edge)) {
+ const BRepMesh_PairOfPolygon& pair = myEdges.Find(edge);
+ const Handle(Poly_PolygonOnTriangulation)& P = pair.First();
+ defedge = P->Deflection();
+ }
else {
Bnd_Box B;
BRepBndLib::Add(edge, B);
if (defedge < dy) defedge = dy;
if (defedge < dz) defedge = dz;
// adjusted in relation to the total size:
- cdef = mydtotale/(2*defedge);
+ cdef = myDtotale/(2*defedge);
if (cdef < 0.5) cdef = 0.5;
if (cdef > 2.) cdef = 2.;
- defedge = cdef * defedge * mydeflection;
- myangle = savangle * cdef;
+ defedge = cdef * defedge * myDeflection;
+ myAngle = savangle * cdef;
}
defface = defface + defedge;
- defface = Max(maxdef, defface);
+ defface = Max(maxdef, defface);
}
- else defedge = mydeflection;
+ else defedge = myDeflection;
defedge = Max(maxdef, defedge);
defedge = Max(1.e-05 , defedge);
- mapdefle.Bind(edge, defedge);
+ myMapdefle.Bind(edge, defedge);
}
else{
- defedge = mapdefle(edge);
- if (myrelative) {defface = defface + defedge; defface = Max(maxdef, defface);}
+ defedge = myMapdefle(edge);
+ if (myRelative) {defface = defface + defedge; defface = Max(maxdef, defface);}
}
Standard_Real f1,l1;
Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(edge, face, f1, l1);
aCSeq.Append(C);
aShSeq.Append(edge);
Add(edge, face, gFace, C, defedge, f1, l1);
- myangle = savangle;
+ myAngle = savangle;
}
}
- if (nbEdge == 0 || myvemap.Extent() < 3)
+ if (nbEdge == 0 || myVemap.Extent() < 3)
{
MESH_FAILURE(theface);
}
- if (myrelative ) defface = defface / nbEdge;
- else defface = mydeflection;
+ if (myRelative ) defface = defface / nbEdge;
+ else defface = myDeflection;
if (myWithShare) defface = Max(maxdef, defface);
T = BRep_Tool::Triangulation(face, loc);
- if (!myshapetrigu || T.IsNull()) {
+ if (!myShapetrigu || T.IsNull()) {
Standard_Real xCur, yCur;
Standard_Real maxX, minX, maxY, minY;
Standard_Integer ipn = 0;
Standard_Integer i1 =1;
- for (i1 = 1; i1 <= myvemap.Extent(); i1++) {
- const BRepMesh_Vertex& aV = structure->GetNode(myvemap.FindKey(i1));
+ for (i1 = 1; i1 <= myVemap.Extent(); i1++) {
+ const BRepMesh_Vertex& aV = myStructure->GetNode(myVemap.FindKey(i1));
ipn++;
xCur=aV.Coord().X();
yCur=aV.Coord().Y();
Standard_Real deltaX = 1.0;
Standard_Real deltaY = 1.0;
- Standard_Integer nbVertices = myvemap.Extent();
+ Standard_Integer nbVertices = myVemap.Extent();
const Standard_Real tolclass = Precision::PConfusion(); //0.03*Max(myumax-myumin, myvmax-myvmin);
BRepMesh_ClassifierPtr classifier (
- new BRepMesh_Classifier(face, tolclass, internaledges, myvemap,
- structure, myumin, myumax, myvmin, myvmax) );
+ new BRepMesh_Classifier(face, tolclass, myInternaledges, myVemap,
+ myStructure, myumin, myumax, myvmin, myvmax) );
- myfacestate = classifier->State();
- if (myfacestate == BRepMesh_SelfIntersectingWire)
+ myFacestate = classifier->State();
+ if (myFacestate == BRepMesh_SelfIntersectingWire)
{
Standard_Integer nbmaill = 0;
Standard_Real eps = Precision::Confusion();
- while (nbmaill < 5 && myfacestate != BRepMesh_ReMesh)
+ while (nbmaill < 5 && myFacestate != BRepMesh_ReMesh)
{
nbmaill++;
//clear the structure of links
- structure.Nullify();
- structure = new BRepMesh_DataStructureOfDelaun(anAlloc);
+ myStructure.Nullify();
+ myStructure = new BRepMesh_DataStructureOfDelaun(anAlloc);
- myvemap.Clear();
- mylocation2d.Clear();
- internaledges.Clear();
+ myVemap.Clear();
+ myLocation2d.Clear();
+ myInternaledges.Clear();
Standard_Integer j1;
for(j1 = 1; j1 <= aShSeq.Length(); j1++)
{
const TopoDS_Edge& edge = TopoDS::Edge(aShSeq.Value(j1));
- if (edges.IsBound(edge))
+ if (myEdges.IsBound(edge))
{
- edges.UnBind(edge);
- internaledges.UnBind(edge);
+ myEdges.UnBind(edge);
+ myInternaledges.UnBind(edge);
}
}
for( j1 = 1; j1 <= aShSeq.Length(); j1++)
{
const TopoDS_Edge& edge = TopoDS::Edge(aShSeq.Value(j1));
- defedge = mapdefle(edge) / 3.;
+ defedge = myMapdefle(edge) / 3.;
defedge = Max(defedge, eps);
- mapdefle.Bind(edge, defedge);
+ myMapdefle.Bind(edge, defedge);
const Handle(Geom2d_Curve)& C = aCSeq.Value(j1);
Add(edge, face, gFace, C, defedge, aFSeq.Value(j1), aLSeq.Value(j1));
}
-
+
classifier.Nullify();
- classifier = new BRepMesh_Classifier(face, tolclass, internaledges, myvemap,
- structure, myumin, myumax, myvmin, myvmax);
+ classifier = new BRepMesh_Classifier(face, tolclass, myInternaledges, myVemap,
+ myStructure, myumin, myumax, myvmin, myvmax);
if (classifier->State() == BRepMesh_NoError)
{
- myfacestate = BRepMesh_ReMesh;
- }
- nbVertices = myvemap.Extent();
+ myFacestate = BRepMesh_ReMesh;
+ }
+ nbVertices = myVemap.Extent();
}
}
- if (myfacestate != BRepMesh_NoError && myfacestate != BRepMesh_ReMesh)
+ if (myFacestate != BRepMesh_NoError && myFacestate != BRepMesh_ReMesh)
{
- mynottriangulated.Append(face);
+ myNottriangulated.Append(face);
classifier.Nullify();
return;
}
- //??
- //add internal vertices after self-intersection check
- /*if(myInternalVerticesMode) {
- for(TopExp_Explorer ex(face,TopAbs_VERTEX ,TopAbs_EDGE); ex.More(); ex.Next()) {
- const TopoDS_Vertex& aVert = TopoDS::Vertex(ex.Current());
- Add(aVert,face,gFace);
- }
- nbVertices = myvemap.Extent();
- }*/
-
-
-
// try to find the real length:
// akm (bug OCC16) : We must calculate these measures in non-singular
// parts of face. Let's try to compute average value of three
// akm (bug OCC16) ^^^^^
if (longu <= 1.e-16 || longv <= 1.e-16) {
- //yes, it is seen!!!
+ //yes, it is seen!!
#ifdef DEB_MESH_CHRONO
chMaillEdges.Stop();
MESH_CHRONO_TSTOP(thetype);
Dv = Max(1.0e0 - (defface/r),0.0e0) ;
Standard_Real oldDv = 2.0 * ACos (Dv);
- oldDv = Min(oldDv, myangle);
+ oldDv = Min(oldDv, myAngle);
Dv = 0.9*oldDv; //TWOTHIRD * oldDv;
Dv = oldDv;
if (ru > 1.e-16) {
Du = Max(1.0e0 - (defface/ru),0.0e0);
Du = (2.0 * ACos (Du));
- Du = Min(Du, myangle);
+ Du = Min(Du, myAngle);
Standard_Real aa = sqrt(Du*Du + oldDv*oldDv);
if(aa < gp::Resolution())
return;
Du = Du * Min(oldDv, Du) / aa;
}
else Du = Dv;
-
+
Standard_Integer nbU = Max((Standard_Integer)((myumax-myumin)/Du), 2);
nbU = Max(nbU, (Standard_Integer)(nbV*(myumax-myumin)*R/((myvmax-myvmin)*r)/5.));
deltaY = (myvmax-myvmin)/longv;
}
- if(!mapattrib.IsBound(theface))
+ if(!myMapattrib.IsBound(theface))
{
Handle(BRepMesh_FaceAttribute) aFA = new BRepMesh_FaceAttribute();
aFA->GetDefFace() = defface;
aFA->GetMinX() = minX;
aFA->GetMinY() = minY;
aFA->GetClassifier() = classifier;
- mapattrib.Bind(theface, aFA);
+ myMapattrib.Bind(theface, aFA);
}
- //Standard_Integer nbVertices = myvemap.Extent();
+ //Standard_Integer nbVertices = myVemap.Extent();
T = new Poly_Triangulation(nbVertices, 1, Standard_True);
TColgp_Array1OfPnt& Nodes = T->ChangeNodes();
TColgp_Array1OfPnt2d& Nodes2d = T->ChangeUVNodes();
Standard_Integer index;
for (i = 1; i <= nbVertices; i++) {
- index = myvemap.FindKey(i);
+ index = myVemap.FindKey(i);
Nodes(i) = Pnt(index);
Nodes2d(i).SetXY(Vertex(index).Coord());
}
gp_Trsf tr = loc.Transformation();
tr.Invert();
for (i = Nodes.Lower(); i <= Nodes.Upper(); i++)
- Nodes(i).Transform(tr);
+ Nodes(i).Transform(tr);
}
BRep_Builder B;
B.UpdateFace(face, T);
- BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon It(internaledges);
+ BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon It(myInternaledges);
for (; It.More(); It.Next()) {
const BRepMesh_PairOfPolygon& pair = It.Value();
const Handle(Poly_PolygonOnTriangulation)& NOD1 = pair.First();
const Handle(Poly_PolygonOnTriangulation)& NOD2 = pair.Last();
if ( NOD1 == NOD2 )
- B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, T, loc);
+ B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, T, loc);
else
- B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, NOD2, T, loc);
+ B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, NOD2, T, loc);
}
}
MESH_FAILURE(theface);
}
#endif // DEB_MESH
- structure.Nullify();
+ myStructure.Nullify();
}
//function : Add
//purpose :
//=======================================================================
-void BRepMesh_FastDiscret::Add(const TopoDS_Edge& edge,
- const TopoDS_Face& face,
- const Handle(BRepAdaptor_HSurface)& gFace,
- const Handle(Geom2d_Curve)& C2d,
- const Standard_Real defedge,
- const Standard_Real first,
- const Standard_Real last)
+void BRepMesh_FastDiscret::Add( const TopoDS_Edge& theEdge,
+ const TopoDS_Face& theFace,
+ const Handle(BRepAdaptor_HSurface)& theGFace,
+ const Handle(Geom2d_Curve)& theC2d,
+ const Standard_Real theDefEdge,
+ const Standard_Real theFirst,
+ const Standard_Real theLast)
{
- const TopAbs_Orientation orEdge = edge.Orientation();
+ const TopAbs_Orientation orEdge = theEdge.Orientation();
if (orEdge == TopAbs_EXTERNAL) return;
- const Standard_Boolean isEdgeBound = edges.IsBound(edge);
+ const Standard_Boolean isEdgeBound = myEdges.IsBound(theEdge);
if (!isEdgeBound)
{
- if (Update(edge, face, C2d, defedge, first, last))
+ if (Update(theEdge, theFace, theC2d, theDefEdge, theFirst, theLast))
{
return;
}
}
TopoDS_Vertex pBegin, pEnd;
- TopExp::Vertices(edge, pBegin, pEnd);
+ TopExp::Vertices(theEdge, pBegin, pEnd);
if (pBegin.IsNull() || pEnd.IsNull())
{
return;
}
Standard_Real wFirst, wLast;
- BRep_Tool::Range(edge, face, wFirst, wLast);
+ BRep_Tool::Range(theEdge, theFace, wFirst, wLast);
gp_Pnt2d uvFirst, uvLast;
- BRep_Tool::UVPoints(edge, face, uvFirst, uvLast);
+ BRep_Tool::UVPoints(theEdge, theFace, uvFirst, uvLast);
const Standard_Boolean sameUV = uvFirst.IsEqual(uvLast, Precision::PConfusion());
//Control vertexes tolerances
- gp_Pnt pFirst = gFace->Value(uvFirst.X(), uvFirst.Y());
- gp_Pnt pLast = gFace->Value(uvLast.X(), uvLast.Y());
+ gp_Pnt pFirst = theGFace->Value(uvFirst.X(), uvFirst.Y());
+ gp_Pnt pLast = theGFace->Value(uvLast.X(), uvLast.Y());
Standard_Real mindist = 10. * Max(pFirst.Distance(BRep_Tool::Pnt(pBegin)),
- pLast.Distance(BRep_Tool::Pnt(pEnd)));
+ pLast.Distance(BRep_Tool::Pnt(pEnd)));
if(mindist < BRep_Tool::Tolerance(pBegin) ||
- mindist < BRep_Tool::Tolerance(pEnd) ) mindist = defedge;
+ mindist < BRep_Tool::Tolerance(pEnd) ) mindist = theDefEdge;
// control of degenerated non-coded edges.
- Standard_Boolean degener = BRep_Tool::Degenerated(edge);
+ Standard_Boolean degener = BRep_Tool::Degenerated(theEdge);
if (!degener)
{
Standard_Real longueur = 0.0;
Standard_Real du = (wLast-wFirst)/20;
gp_Pnt P1, P2;
- BRepAdaptor_Curve BC(edge);
+ BRepAdaptor_Curve BC(theEdge);
BC.D0(wFirst, P1);
Standard_Real tolV = BRep_Tool::Tolerance(pBegin);
Standard_Real tolV2 = 1.2*tolV;
for (Standard_Integer l = 1; l <= 20; l++) {
- BC.D0(wFirst + l*du, P2);
- longueur += P1.Distance(P2);
- if (longueur > tolV2) break;
- P1 = P2;
+ BC.D0(wFirst + l*du, P2);
+ longueur += P1.Distance(P2);
+ if (longueur > tolV2) break;
+ P1 = P2;
}
if (longueur < tolV2)
{
- degener = Standard_True;
+ degener = Standard_True;
}
}
}
{
// 1. is it really sameUV without being degenerated
gp_Pnt2d uvF, uvL;
- C2d->D0(first, uvF);
- C2d->D0(last, uvL);
+ theC2d->D0(theFirst, uvF);
+ theC2d->D0(theLast, uvL);
if (!uvFirst.IsEqual(uvF, Precision::PConfusion()))
{
uvFirst = uvF;
// Process first vertex
Standard_Integer ipf;
- if (vertices.IsBound(pBegin))
+ if (myVertices.IsBound(pBegin))
{
- ipf = vertices.Find(pBegin);
+ ipf = myVertices.Find(pBegin);
}
else
{
- if (sameUV && vertices.IsBound(pEnd))
+ if (sameUV && myVertices.IsBound(pEnd))
{
- ipf = vertices.Find(pEnd);
+ ipf = myVertices.Find(pEnd);
}
else
{
- nbLocat++;
- ipf = nbLocat;
- Location3d.Bind(ipf, BRep_Tool::Pnt(pBegin));
+ myNbLocat++;
+ ipf = myNbLocat;
+ myLocation3d.Bind(ipf, BRep_Tool::Pnt(pBegin));
}
- vertices.Bind(pBegin, ipf);
+ myVertices.Bind(pBegin, ipf);
}
- theUV = FindUV(pBegin, uvFirst, ipf, gFace, mindist);
+ theUV = BRepMesh_FastDiscretFace::FindUV(pBegin, uvFirst, ipf, theGFace, mindist, myLocation2d);
BRepMesh_Vertex vf(theUV, ipf, MeshDS_Frontier);
- Standard_Integer ivf = structure->AddNode(vf);
+ Standard_Integer ivf = myStructure->AddNode(vf);
// Process last vertex
Standard_Integer ipl;
}
else
{
- if (vertices.IsBound(pEnd))
+ if (myVertices.IsBound(pEnd))
{
- ipl = vertices.Find(pEnd);
+ ipl = myVertices.Find(pEnd);
}
else
{
}
else
{
- nbLocat++;
- ipl = nbLocat;
- Location3d.Bind(ipl, BRep_Tool::Pnt(pEnd));
+ myNbLocat++;
+ ipl = myNbLocat;
+ myLocation3d.Bind(ipl, BRep_Tool::Pnt(pEnd));
}
- vertices.Bind(pEnd,ipl);
+ myVertices.Bind(pEnd,ipl);
}
}
- theUV = FindUV(pEnd, uvLast, ipl, gFace, mindist);
+ theUV = BRepMesh_FastDiscretFace::FindUV(pEnd, uvLast, ipl, theGFace, mindist, myLocation2d);
BRepMesh_Vertex vl(theUV, ipl, MeshDS_Frontier);
- Standard_Integer ivl= structure->AddNode(vl);
+ Standard_Integer ivl= myStructure->AddNode(vl);
- Standard_Integer isvf = myvemap.FindIndex(ivf);
- if (isvf == 0) isvf = myvemap.Add(ivf);
- Standard_Integer isvl = myvemap.FindIndex(ivl);
- if (isvl == 0) isvl = myvemap.Add(ivl);
+ Standard_Integer isvf = myVemap.FindIndex(ivf);
+ if (isvf == 0) isvf = myVemap.Add(ivf);
+ Standard_Integer isvl = myVemap.FindIndex(ivl);
+ if (isvl == 0) isvl = myVemap.Add(ivl);
- Standard_Real otherdefedge = 0.5*defedge;
+ Standard_Real otherdefedge = 0.5*theDefEdge;
gp_Pnt2d uv;
BRepMesh_Vertex v2;
gp_Pnt P3d;
if (orEdge == TopAbs_INTERNAL) otherdefedge *= 0.5;
BRepAdaptor_Curve cons;
- if (BRep_Tool::SameParameter(edge))
+ if (BRep_Tool::SameParameter(theEdge))
{
- cons.Initialize(edge);
+ cons.Initialize(theEdge);
}
else
{
- cons.Initialize(edge, face);
+ cons.Initialize(theEdge, theFace);
}
TopLoc_Location L;
Standard_Integer nbpmin = 2;
if (cons.GetType() == GeomAbs_Circle) nbpmin = 4; //OCC287
- BRepMesh_GeomTool GT(cons, wFirst, wLast, 0.5*myangle, otherdefedge, nbpmin);
+ BRepMesh_GeomTool GT(cons, wFirst, wLast, 0.5*myAngle, otherdefedge, nbpmin);
// PTv, chl/922/G9, Take into account internal vertices
- // it is necessary for internal edges, which does not split other edges, by their vertex
- TopoDS_Iterator exV(edge);
+ // it is necessary for internal edges, which do not split other edges, by their vertex
+ TopoDS_Iterator exV(theEdge);
for ( ; exV.More(); exV.Next() )
{
- TopoDS_Vertex aIntV = TopoDS::Vertex(exV.Value());
- if ( aIntV.Orientation() == TopAbs_INTERNAL )
+ TopoDS_Vertex aIntV = TopoDS::Vertex(exV.Value());
+ if ( aIntV.Orientation() == TopAbs_INTERNAL )
GT.AddPoint(BRep_Tool::Pnt(aIntV),
- BRep_Tool::Parameter(aIntV, edge),
- Standard_True);
+ BRep_Tool::Parameter(aIntV, theEdge),
+ Standard_True);
}
- // Creation of polygons on triangulation:
+ // Creation des polygones sur triangulation:
Standard_Real puv;
Standard_Integer i;
Standard_Real aEdgeLen = 0., a2dEdgeLen = 0.;
gp_Pnt P3dPrev;
gp_Pnt2d uvPrev;
- GT.Value(cons, gFace, 1, puv, P3dPrev, uvPrev);
+ GT.Value(cons, theGFace, 1, puv, P3dPrev, uvPrev);
for (i = 2; i <= GT.NbPoints(); i++)
{
// Record 3d point
- GT.Value(cons, gFace, i, puv, P3d, uv);
+ GT.Value(cons, theGFace, i, puv, P3d, uv);
aEdgeLen += P3d.SquareDistance(P3dPrev);
a2dEdgeLen += uv.SquareDistance(uvPrev);
P3dPrev = P3d;
}
Standard_Integer nbnodes = GT.NbPoints();
- Standard_Real aMinToler = Min(defedge, mydeflection);
+ Standard_Real aMinToler = Min(theDefEdge, myDeflection);
if(aEdgeLen < aMinToler*aMinToler)
{
//check 2D resolution
- Standard_Real ddu = gFace->UResolution(aMinToler);
- Standard_Real ddv = gFace->VResolution(aMinToler);
+ Standard_Real ddu = theGFace->UResolution(aMinToler);
+ Standard_Real ddv = theGFace->VResolution(aMinToler);
Standard_Real aMin = Min(ddu, ddv);
if(a2dEdgeLen < aMin*aMin)
TColStd_Array1OfInteger Nodes(1, nbnodes);
TColStd_Array1OfInteger NodInStruct(1, nbnodes);
TColStd_Array1OfReal Param(1, nbnodes);
-
+
// processing of the 1st point:
Nodes(1) = isvf;
NodInStruct(1) = ipf;
for (i = 2; i < GT.NbPoints(); i++)
{
// Record 3d point
- GT.Value(cons, gFace, i, puv, P3d, uv);
- nbLocat++;
- Location3d.Bind(nbLocat, P3d);
- NodInStruct(i) = nbLocat;
+ GT.Value(cons, theGFace, i, puv, P3d, uv);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P3d);
+ NodInStruct(i) = myNbLocat;
// Record 2d point
- v2.Initialize(uv.Coord(), nbLocat, MeshDS_OnCurve);
- iv2=structure->AddNode(v2);
+ v2.Initialize(uv.Coord(), myNbLocat, MeshDS_OnCurve);
+ iv2=myStructure->AddNode(v2);
- Standard_Integer isv = myvemap.FindIndex(iv2);
- if (isv == 0) isv = myvemap.Add(iv2);
+ Standard_Integer isv = myVemap.FindIndex(iv2);
+ if (isv == 0) isv = myVemap.Add(iv2);
Nodes(i) = isv;
- NodInStruct(i) = nbLocat;
+ NodInStruct(i) = myNbLocat;
Param(i) = puv;
-
+
if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
ivf = iv2;
}
}
P2->Deflection(otherdefedge);
BRepMesh_PairOfPolygon pair;
pair.Append(P2);
- edges.Bind(edge, pair);
+ myEdges.Bind(theEdge, pair);
if (ivf != ivl) {
if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Frontier));
else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(ivl, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivl, ivf, MeshDS_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Fixed));
}
else
{
// retrieve the polygone:
- const BRepMesh_PairOfPolygon& pair = edges.Find(edge);
+ const BRepMesh_PairOfPolygon& pair = myEdges.Find(theEdge);
const Handle(Poly_PolygonOnTriangulation)& P = pair.First();
const TColStd_Array1OfInteger& NOD = P->Nodes();
Handle(TColStd_HArray1OfReal) Par = P->Parameters();
if (nbnodes > 2)
{
Standard_Integer i;
- if (BRep_Tool::SameParameter(edge))
+ if (BRep_Tool::SameParameter(theEdge))
{
- for (i = 2; i < nbnodes; i++)
+ for (i = 2; i < nbnodes; i++)
{
const Standard_Real puv = Par->Value(i);
- C2d->D0(puv, uv);
- v2.Initialize(uv.Coord(), NOD(i), MeshDS_OnCurve);
- iv2 = structure->AddNode(v2);
-
- Standard_Integer isv = myvemap.FindIndex(iv2);
- if (isv == 0) isv = myvemap.Add(iv2);
+ theC2d->D0(puv, uv);
+ v2.Initialize(uv.Coord(), NOD(i), MeshDS_OnCurve);
+ iv2 = myStructure->AddNode(v2);
+
+ Standard_Integer isv = myVemap.FindIndex(iv2);
+ if (isv == 0) isv = myVemap.Add(iv2);
Nodes(i) = isv;
- PPar(i) = puv;
+ PPar(i) = puv;
if (orEdge==TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
+ else if (orEdge == TopAbs_REVERSED)
+ myStructure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
-
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
+
ivf = iv2;
- }
- }
+ }
+ }
else
{
- const Standard_Real wFold = Par->Value(Par->Lower());
- const Standard_Real wLold = Par->Value(Par->Upper());
+ const Standard_Real wFold = Par->Value(Par->Lower());
+ const Standard_Real wLold = Par->Value(Par->Upper());
- Standard_Real wKoef = 1.;
- if ((wFold != wFirst || wLold != wLast) && wLold != wFold)
+ Standard_Real wKoef = 1.;
+ if ((wFold != wFirst || wLold != wLast) && wLold != wFold)
{
- wKoef = (wLast - wFirst) / (wLold - wFold);
- }
-
- BRepAdaptor_Curve cons(edge, face);
- Extrema_LocateExtPC pcos;
- pcos.Initialize(cons, cons.FirstParameter(),
- cons.LastParameter(), Precision::PConfusion());
-
- Standard_Real wPrev;
- Standard_Real wCur = wFirst;
- Standard_Real wCurFound = wFirst;
- for (i = 2; i < nbnodes; i++)
+ wKoef = (wLast - wFirst) / (wLold - wFold);
+ }
+
+ BRepAdaptor_Curve cons(theEdge, theFace);
+ Extrema_LocateExtPC pcos;
+ pcos.Initialize(cons, cons.FirstParameter(),
+ cons.LastParameter(), Precision::PConfusion());
+
+ Standard_Real wPrev;
+ Standard_Real wCur = wFirst;
+ Standard_Real wCurFound = wFirst;
+ for (i = 2; i < nbnodes; i++)
{
- P3d = Location3d(NOD(i));
+ P3d = myLocation3d(NOD(i));
// Record 2d point
- wPrev = wCur;
- wCur = wFirst + wKoef*(Par->Value(i) - wFold);
- wCurFound += (wCur - wPrev);
- pcos.Perform(P3d, wCurFound);
- if (pcos.IsDone()) wCurFound = pcos.Point().Parameter();
- C2d->D0(wCurFound, uv);
- v2.Initialize(uv.Coord(), NOD(i), MeshDS_OnCurve);
- iv2 = structure->AddNode(v2);
-
- Standard_Integer isv = myvemap.FindIndex(iv2);
- if (isv == 0) isv = myvemap.Add(iv2);
- Nodes(i) = isv;
- PPar(i) = wCurFound;
-
+ wPrev = wCur;
+ wCur = wFirst + wKoef*(Par->Value(i) - wFold);
+ wCurFound += (wCur - wPrev);
+ pcos.Perform(P3d, wCurFound);
+ if (pcos.IsDone()) wCurFound = pcos.Point().Parameter();
+ theC2d->D0(wCurFound, uv);
+ v2.Initialize(uv.Coord(), NOD(i), MeshDS_OnCurve);
+ iv2 = myStructure->AddNode(v2);
+
+ Standard_Integer isv = myVemap.FindIndex(iv2);
+ if (isv == 0) isv = myVemap.Add(iv2);
+ Nodes(i) = isv;
+ PPar(i) = wCurFound;
+
if (orEdge==TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Frontier));
else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(iv2, ivf, MeshDS_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
-
+ myStructure->AddLink(BRepMesh_Edge(ivf, iv2, MeshDS_Fixed));
+
ivf = iv2;
- }
- }
+ }
+ }
}
- P1 = new Poly_PolygonOnTriangulation(Nodes, PPar);
+ P1 = new Poly_PolygonOnTriangulation(Nodes, PPar);
if (ivf != ivl) {
if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Frontier));
else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(ivl, ivf, MeshDS_Frontier));
+ myStructure->AddLink(BRepMesh_Edge(ivl, ivf, MeshDS_Frontier));
else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Fixed));
+ myStructure->AddLink(BRepMesh_Edge(ivf, ivl, MeshDS_Fixed));
}
}
}
- P1->Deflection(defedge);
- if (internaledges.IsBound(edge))
+ P1->Deflection(theDefEdge);
+ if (myInternaledges.IsBound(theEdge))
{
- BRepMesh_PairOfPolygon& pair = internaledges.ChangeFind(edge);
+ BRepMesh_PairOfPolygon& pair = myInternaledges.ChangeFind(theEdge);
if (orEdge == TopAbs_REVERSED)
pair.Append(P1);
else
{
BRepMesh_PairOfPolygon pair1;
pair1.Append(P1);
- internaledges.Bind(edge, pair1);
+ myInternaledges.Bind(theEdge, pair1);
}
}
//function : Update(edge)
//purpose :
//=======================================================================
-Standard_Boolean BRepMesh_FastDiscret::Update(const TopoDS_Edge& edge,
- const TopoDS_Face& face,
- const Handle(Geom2d_Curve)& C2d,
- const Standard_Real defedge,
- const Standard_Real first,
- const Standard_Real last)
+Standard_Boolean BRepMesh_FastDiscret::Update(const TopoDS_Edge& theEdge,
+ const TopoDS_Face& theFace,
+ const Handle(Geom2d_Curve)& theC2d,
+ const Standard_Real theDefEdge,
+ const Standard_Real theFirst,
+ const Standard_Real theLast)
{
- TopLoc_Location l;
+ TopLoc_Location Loc;
Handle(Poly_Triangulation) T, TNull;
Handle(Poly_PolygonOnTriangulation) Poly, NullPoly;
Standard_Boolean found = Standard_False;
do
{
- BRep_Tool::PolygonOnTriangulation(edge,Poly,T,l,i);
+ BRep_Tool::PolygonOnTriangulation(theEdge,Poly,T,Loc,i);
i++;
if (!found && !T.IsNull() && T->HasUVNodes() &&
- !Poly.IsNull() && Poly->HasParameters())
+ !Poly.IsNull() && Poly->HasParameters())
{
- if (Poly->Deflection() <= 1.1*defedge)
+ if (Poly->Deflection() <= 1.1*theDefEdge)
{
// 2d vertex indices
- TopAbs_Orientation orEdge = edge.Orientation();
+ TopAbs_Orientation orEdge = theEdge.Orientation();
Standard_Integer iv1, iv2, ivl;
Standard_Integer isv1, isv, isvl;
// Get range on 2d curve
- Standard_Real wFirst, wLast;
- BRep_Tool::Range(edge, face, wFirst, wLast);
-
+ Standard_Real wFirst, wLast;
+ BRep_Tool::Range(theEdge, theFace, wFirst, wLast);
+
// Get end points on 2d curve
- gp_Pnt2d uvFirst, uvLast;
- BRep_Tool::UVPoints(edge, face, uvFirst, uvLast);
+ gp_Pnt2d uvFirst, uvLast;
+ BRep_Tool::UVPoints(theEdge, theFace, uvFirst, uvLast);
// Get vertices
- TopoDS_Vertex pBegin, pEnd;
- TopExp::Vertices(edge,pBegin,pEnd);
-
- const Standard_Boolean sameUV =
+ TopoDS_Vertex pBegin, pEnd;
+ TopExp::Vertices(theEdge,pBegin,pEnd);
+
+ const Standard_Boolean sameUV =
uvFirst.IsEqual(uvLast, Precision::PConfusion());
-
- //Controle vertice tolerances
- BRepAdaptor_Surface BS(face, Standard_False);
+
+ //Controle vertice tolerances
+ BRepAdaptor_Surface BS(theFace, Standard_False);
Handle(BRepAdaptor_HSurface) gFace = new BRepAdaptor_HSurface(BS);
+
+ gp_Pnt pFirst = gFace->Value(uvFirst.X(), uvFirst.Y());
+ gp_Pnt pLast = gFace->Value(uvLast.X(), uvLast.Y());
+
+ Standard_Real mindist = 10. * Max(pFirst.Distance(BRep_Tool::Pnt(pBegin)),
+ pLast.Distance(BRep_Tool::Pnt(pEnd)));
- gp_Pnt pFirst = gFace->Value(uvFirst.X(), uvFirst.Y());
- gp_Pnt pLast = gFace->Value(uvLast.X(), uvLast.Y());
-
- Standard_Real mindist = 10. * Max(pFirst.Distance(BRep_Tool::Pnt(pBegin)),
- pLast.Distance(BRep_Tool::Pnt(pEnd)));
-
- if (mindist < BRep_Tool::Tolerance(pBegin) ||
- mindist < BRep_Tool::Tolerance(pEnd) ) mindist = defedge;
-
- if (sameUV)
+ if (mindist < BRep_Tool::Tolerance(pBegin) ||
+ mindist < BRep_Tool::Tolerance(pEnd) ) mindist = theDefEdge;
+
+ if (sameUV)
{
- // 1. is it really sameUV without being degenerated
- gp_Pnt2d uvF, uvL;
- C2d->D0(first, uvF);
- C2d->D0(last, uvL);
- if (!uvFirst.IsEqual(uvF, Precision::PConfusion())) {
- uvFirst = uvF;
- }
- if (!uvLast.IsEqual(uvL, Precision::PConfusion())) {
- uvLast = uvL;
- }
- }
-
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
- const TColStd_Array1OfInteger& Indices = Poly->Nodes();
- Handle(TColStd_HArray1OfReal) Param = Poly->Parameters();
-
- const Standard_Integer nbnodes = Indices.Length();
- TColStd_Array1OfInteger NewNodes(1, nbnodes);
- TColStd_Array1OfInteger NewNodInStruct(1, nbnodes);
+ // 1. is it really sameUV without being degenerated
+ gp_Pnt2d uvF, uvL;
+ theC2d->D0(theFirst, uvF);
+ theC2d->D0(theLast, uvL);
+ if (!uvFirst.IsEqual(uvF, Precision::PConfusion())) {
+ uvFirst = uvF;
+ }
+ if (!uvLast.IsEqual(uvL, Precision::PConfusion())) {
+ uvLast = uvL;
+ }
+ }
+ const TColgp_Array1OfPnt& Nodes = T->Nodes();
+ const TColStd_Array1OfInteger& Indices = Poly->Nodes();
+ Handle(TColStd_HArray1OfReal) Param = Poly->Parameters();
+
+ const Standard_Integer nbnodes = Indices.Length();
+ TColStd_Array1OfInteger NewNodes(1, nbnodes);
+ TColStd_Array1OfInteger NewNodInStruct(1, nbnodes);
+
gp_Pnt P3d;
- gp_XY theUV;
-
+ gp_XY theUV;
+
// Process first vertex
Standard_Integer ipf;
- if (vertices.IsBound(pBegin))
+ if (myVertices.IsBound(pBegin))
{
- ipf = vertices.Find(pBegin);
- }
+ ipf = myVertices.Find(pBegin);
+ }
else
{
- if (sameUV && vertices.IsBound(pEnd))
+ if (sameUV && myVertices.IsBound(pEnd))
{
- ipf = vertices.Find(pEnd);
- }
- else
+ ipf = myVertices.Find(pEnd);
+ }
+ else
{
- P3d = Nodes(Indices(1));
- if (!l.IsIdentity())
- P3d.Transform(l.Transformation());
- nbLocat++;
- Location3d.Bind(nbLocat,P3d);
- ipf = nbLocat;
- }
- vertices.Bind(pBegin,ipf);
- }
- NewNodInStruct(1) = ipf;
- theUV = FindUV(pBegin, uvFirst, ipf, gFace, mindist);
- BRepMesh_Vertex vf(theUV,ipf,MeshDS_Frontier);
- iv1 = structure->AddNode(vf);
- isv1 = myvemap.FindIndex(iv1);
- if (isv1 == 0) isv1 = myvemap.Add(iv1);
- NewNodes(1) = isv1;
-
+ P3d = Nodes(Indices(1));
+ if (!Loc.IsIdentity())
+ P3d.Transform(Loc.Transformation());
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat,P3d);
+ ipf = myNbLocat;
+ }
+ myVertices.Bind(pBegin,ipf);
+ }
+ NewNodInStruct(1) = ipf;
+ theUV = BRepMesh_FastDiscretFace::FindUV(pBegin, uvFirst, ipf, gFace, mindist, myLocation2d);
+ BRepMesh_Vertex vf(theUV,ipf,MeshDS_Frontier);
+ iv1 = myStructure->AddNode(vf);
+ isv1 = myVemap.FindIndex(iv1);
+ if (isv1 == 0) isv1 = myVemap.Add(iv1);
+ NewNodes(1) = isv1;
+
// Process last vertex
Standard_Integer ipl;
if (pEnd.IsSame(pBegin))
}
else
{
- if (vertices.IsBound(pEnd))
+ if (myVertices.IsBound(pEnd))
{
- ipl = vertices.Find(pEnd);
+ ipl = myVertices.Find(pEnd);
}
else
{
}
else
{
- nbLocat++;
- Location3d.Bind(nbLocat,Nodes(Indices(nbnodes)).Transformed(l.Transformation()));
- ipl = nbLocat;
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat,Nodes(Indices(nbnodes)).Transformed(Loc.Transformation()));
+ ipl = myNbLocat;
}
- vertices.Bind(pEnd,ipl);
+ myVertices.Bind(pEnd,ipl);
}
}
- NewNodInStruct(nbnodes) = ipl;
- theUV = FindUV(pEnd, uvLast, ipl, gFace, mindist);
- BRepMesh_Vertex vl(theUV,ipl,MeshDS_Frontier);
+ NewNodInStruct(nbnodes) = ipl;
+ theUV = BRepMesh_FastDiscretFace::FindUV(pEnd, uvLast, ipl, gFace, mindist, myLocation2d);
+ BRepMesh_Vertex vl(theUV,ipl,MeshDS_Frontier);
- ivl = structure->AddNode(vl);
- isvl = myvemap.FindIndex(ivl);
- if (isvl == 0) isvl = myvemap.Add(ivl);
+ ivl = myStructure->AddNode(vl);
+ isvl = myVemap.FindIndex(ivl);
+ if (isvl == 0) isvl = myVemap.Add(ivl);
- NewNodes(nbnodes) = isvl;
-
- gp_Pnt2d uv;
- BRepMesh_Vertex v;
-
- if (BRep_Tool::SameParameter(edge))
+ NewNodes(nbnodes) = isvl;
+
+ gp_Pnt2d uv;
+ BRepMesh_Vertex v;
+
+ if (BRep_Tool::SameParameter(theEdge))
{
- for (i = 2; i < Indices.Length(); i++)
+ for (i = 2; i < Indices.Length(); i++)
{
// Record 3d point
- P3d = Nodes(Indices(i));
- if (!l.IsIdentity())
- P3d.Transform(l.Transformation());
- nbLocat++;
- Location3d.Bind(nbLocat, P3d);
- NewNodInStruct(i) = nbLocat;
+ P3d = Nodes(Indices(i));
+ if (!Loc.IsIdentity())
+ P3d.Transform(Loc.Transformation());
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P3d);
+ NewNodInStruct(i) = myNbLocat;
// Record 2d point
- uv = C2d->Value(Param->Value(i));
- v.Initialize(uv.Coord(), nbLocat, MeshDS_Frontier);
- iv2 = structure->AddNode(v);
- isv = myvemap.FindIndex(iv2);
- if (isv == 0) isv = myvemap.Add(iv2);
- NewNodes(i) = isv;
+ uv = theC2d->Value(Param->Value(i));
+ v.Initialize(uv.Coord(), myNbLocat, MeshDS_Frontier);
+ iv2 = myStructure->AddNode(v);
+ isv = myVemap.FindIndex(iv2);
+ if (isv == 0) isv = myVemap.Add(iv2);
+ NewNodes(i) = isv;
//add links
if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
- iv1 = iv2;
- }
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
+ else if (orEdge == TopAbs_REVERSED)
+ myStructure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
+ else if (orEdge == TopAbs_INTERNAL)
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
+ iv1 = iv2;
+ }
// last point
if (iv1 != ivl) {
- if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
- }
-
+ if (orEdge == TopAbs_FORWARD)
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
+ else if (orEdge == TopAbs_REVERSED)
+ myStructure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
+ else if (orEdge == TopAbs_INTERNAL)
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
+ }
+
- }
+ }
else
{
- const Standard_Real wFold = Param->Value(Param->Lower());
- const Standard_Real wLold = Param->Value(Param->Upper());
-
- Standard_Real wKoef = 1.;
- if ((wFold != wFirst || wLold != wLast) && wLold != wFold)
+ const Standard_Real wFold = Param->Value(Param->Lower());
+ const Standard_Real wLold = Param->Value(Param->Upper());
+
+ Standard_Real wKoef = 1.;
+ if ((wFold != wFirst || wLold != wLast) && wLold != wFold)
{
- wKoef = (wLast - wFirst) / (wLold - wFold);
- }
-
- BRepAdaptor_Curve cons(edge, face);
- Extrema_LocateExtPC pcos;
- pcos.Initialize(cons, cons.FirstParameter(),
- cons.LastParameter(), Precision::PConfusion());
-
- Standard_Real wPrev;
- Standard_Real wCur = wFirst;
- Standard_Real wCurFound = wFirst;
- for (i = 2; i < Indices.Length(); i++)
+ wKoef = (wLast - wFirst) / (wLold - wFold);
+ }
+
+ BRepAdaptor_Curve cons(theEdge, theFace);
+ Extrema_LocateExtPC pcos;
+ pcos.Initialize(cons, cons.FirstParameter(),
+ cons.LastParameter(), Precision::PConfusion());
+
+ Standard_Real wPrev;
+ Standard_Real wCur = wFirst;
+ Standard_Real wCurFound = wFirst;
+ for (i = 2; i < Indices.Length(); i++)
{
// Record 3d point
- P3d = Nodes(Indices(i));
- if (!l.IsIdentity())
- P3d.Transform(l.Transformation());
- nbLocat++;
- Location3d.Bind(nbLocat, P3d);
- NewNodInStruct(i) = nbLocat;
+ P3d = Nodes(Indices(i));
+ if (!Loc.IsIdentity())
+ P3d.Transform(Loc.Transformation());
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P3d);
+ NewNodInStruct(i) = myNbLocat;
// Record 2d point
- wPrev = wCur;
- wCur = wFirst + wKoef*(Param->Value(i) - wFold);
+ wPrev = wCur;
+ wCur = wFirst + wKoef*(Param->Value(i) - wFold);
wCurFound += (wCur - wPrev);
- pcos.Perform(P3d, wCurFound);
- if (pcos.IsDone()) wCurFound = pcos.Point().Parameter();
- C2d->D0(wCurFound, uv);
- v.Initialize(uv.Coord(), nbLocat, MeshDS_Frontier);
- iv2 = structure->AddNode(v);
- isv = myvemap.FindIndex(iv2);
- if (isv == 0) isv = myvemap.Add(iv2);
- NewNodes(i) = isv;
+ pcos.Perform(P3d, wCurFound);
+ if (pcos.IsDone()) wCurFound = pcos.Point().Parameter();
+ theC2d->D0(wCurFound, uv);
+ v.Initialize(uv.Coord(), myNbLocat, MeshDS_Frontier);
+ iv2 = myStructure->AddNode(v);
+ isv = myVemap.FindIndex(iv2);
+ if (isv == 0) isv = myVemap.Add(iv2);
+ NewNodes(i) = isv;
//add links
if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
- iv1 = iv2;
- }
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
+ else if (orEdge == TopAbs_REVERSED)
+ myStructure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
+ else if (orEdge == TopAbs_INTERNAL)
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
+ iv1 = iv2;
+ }
// last point
if (iv1 != ivl) {
- if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
- }
- }
-
- Handle(Poly_PolygonOnTriangulation) P1 =
+ if (orEdge == TopAbs_FORWARD)
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
+ else if (orEdge == TopAbs_REVERSED)
+ myStructure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
+ else if (orEdge == TopAbs_INTERNAL)
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
+ }
+ }
+
+ Handle(Poly_PolygonOnTriangulation) P1 =
new Poly_PolygonOnTriangulation(NewNodes, Param->Array1());
- P1->Deflection(defedge);
- if (internaledges.IsBound(edge))
+ P1->Deflection(theDefEdge);
+ if (myInternaledges.IsBound(theEdge))
{
- BRepMesh_PairOfPolygon& pair = internaledges.ChangeFind(edge);
- if (edge.Orientation() == TopAbs_REVERSED)
+ BRepMesh_PairOfPolygon& pair = myInternaledges.ChangeFind(theEdge);
+ if (theEdge.Orientation() == TopAbs_REVERSED)
pair.Append(P1);
else
pair.Prepend(P1);
- }
- else
+ }
+ else
{
- BRepMesh_PairOfPolygon pair1;
- pair1.Append(P1);
- internaledges.Bind(edge, pair1);
- }
-
- Handle(Poly_PolygonOnTriangulation) P2 =
+ BRepMesh_PairOfPolygon pair1;
+ pair1.Append(P1);
+ myInternaledges.Bind(theEdge, pair1);
+ }
+
+ Handle(Poly_PolygonOnTriangulation) P2 =
new Poly_PolygonOnTriangulation(NewNodInStruct, Param->Array1());
- P2->Deflection(defedge);
- BRepMesh_PairOfPolygon pair;
- pair.Append(P2);
- edges.Bind(edge, pair);
-
- found = Standard_True;
+ P2->Deflection(theDefEdge);
+ BRepMesh_PairOfPolygon pair;
+ pair.Append(P2);
+ myEdges.Bind(theEdge, pair);
+
+ found = Standard_True;
}
else
{
- BRep_Builder B;
- B.UpdateEdge(edge,NullPoly,T,l);
- B.UpdateFace(face,TNull);
+ BRep_Builder B;
+ B.UpdateEdge(theEdge,NullPoly,T,Loc);
+ B.UpdateFace(theFace,TNull);
}
}
else if (!T.IsNull() && !T->HasUVNodes())
{
BRep_Builder B;
- B.UpdateEdge(edge,NullPoly,T,l);
- B.UpdateFace(face,TNull);
+ B.UpdateEdge(theEdge,NullPoly,T,Loc);
+ B.UpdateFace(theFace,TNull);
}
}
while (!Poly.IsNull());
//=======================================================================
Standard_Integer BRepMesh_FastDiscret::NbTriangles() const
{
- return structure->NbElements();
+ return myStructure->NbElements();
}
//=======================================================================
const BRepMesh_Triangle& BRepMesh_FastDiscret::Triangle
(const Standard_Integer Index) const
{
- return structure->GetElement(Index);
+ return myStructure->GetElement(Index);
}
//=======================================================================
Standard_Integer BRepMesh_FastDiscret::NbEdges() const
{
- return structure->NbLinks();
+ return myStructure->NbLinks();
}
//=======================================================================
const BRepMesh_Edge& BRepMesh_FastDiscret::Edge(const Standard_Integer Index) const
{
- return structure->GetLink(Index);
+ return myStructure->GetLink(Index);
}
//=======================================================================
Standard_Integer BRepMesh_FastDiscret::NbVertices() const
{
- return structure->NbNodes();
+ return myStructure->NbNodes();
}
//=======================================================================
const BRepMesh_Vertex& BRepMesh_FastDiscret::Vertex
(const Standard_Integer Index) const
{
- return structure->GetNode(Index);
+ return myStructure->GetNode(Index);
}
//=======================================================================
const gp_Pnt& BRepMesh_FastDiscret::Pnt(const Standard_Integer Index) const
{
- return Location3d(structure->GetNode(Index).Location3d());
+ return myLocation3d(myStructure->GetNode(Index).Location3d());
}
//=======================================================================
Indices.Clear();
// recuperate from the map of edges.
- const MeshDS_MapOfInteger& edmap = structure->LinkOfDomain();
+ const MeshDS_MapOfInteger& edmap = myStructure->LinkOfDomain();
// iterator on edges.
MeshDS_MapOfInteger::Iterator iter(edmap);
}
}
-//=======================================================================
-//function : FindUV
-//purpose :
-//=======================================================================
-
-gp_XY BRepMesh_FastDiscret::FindUV(const TopoDS_Vertex& V,
- const gp_Pnt2d& XY,
- const Standard_Integer ip,
- const Handle(BRepAdaptor_HSurface)& S,
- const Standard_Real mindist)
-{
- gp_XY theUV;
- if (mylocation2d.IsBound(ip))
- {
- BRepMesh_ListOfXY& L = mylocation2d.ChangeFind(ip);
- theUV = L.First();
- if (L.Extent() != 1)
- {
- BRepMesh_ListIteratorOfListOfXY it(L);
- it.Next();
- Standard_Real dd, dmin = XY.Distance(gp_Pnt2d(theUV));
- for (; it.More(); it.Next())
- {
- dd = XY.Distance(gp_Pnt2d(it.Value()));
- if (dd < dmin)
- {
- theUV = it.Value();
- dmin = dd;
- }
- }
- }
-
- const Standard_Real tol = Min(2. * BRep_Tool::Tolerance(V), mindist);
-
- const Standard_Real Utol2d = .5 * (S->LastUParameter() - S->FirstUParameter());
- const Standard_Real Vtol2d = .5 * (S->LastVParameter() - S->FirstVParameter());
-
- const gp_Pnt p1 = S->Value(theUV.X(), theUV.Y());
- const gp_Pnt p2 = S->Value(XY.X(), XY.Y());
-
- if (Abs(theUV.X() - XY.X()) > Utol2d ||
- Abs(theUV.Y() - XY.Y()) > Vtol2d ||
- !p1.IsEqual(p2, tol))
- {
- theUV = XY.Coord();
- L.Append(theUV);
- }
- }
- else
- {
- theUV = XY.Coord();
- BRepMesh_ListOfXY L;
- L.Append(theUV);
- mylocation2d.Bind(ip, L);
- }
- return theUV;
-}
-
-
BRepMesh_Status BRepMesh_FastDiscret::CurrentFaceStatus() const
{
- return myfacestate;
+ return myFacestate;
}
//=======================================================================
//purpose :
//=======================================================================
-Standard_Boolean BRepMesh_FastDiscret::GetFaceAttribute(const TopoDS_Face& theFace,
- Handle(BRepMesh_FaceAttribute)& fattrib) const
+Standard_Boolean BRepMesh_FastDiscret::GetFaceAttribute(const TopoDS_Face& theFace,
+ Handle(BRepMesh_FaceAttribute)& theFattrib) const
{
- if(mapattrib.IsBound(theFace))
+ if(myMapattrib.IsBound(theFace))
{
- fattrib = mapattrib(theFace);
+ theFattrib = myMapattrib(theFace);
return Standard_True;
}
return Standard_False;
void BRepMesh_FastDiscret::RemoveFaceAttribute(const TopoDS_Face& theFace)
{
- if(mapattrib.IsBound(theFace))
- mapattrib.UnBind(theFace);
+ if(myMapattrib.IsBound(theFace))
+ myMapattrib.UnBind(theFace);
}
-// File: BRepMesh_FastDiscret.lxx
-// Created: Fri Sep 26 16:39:53 2003
-// Author: Open CASCADE Support
-// <support@opencascade.com>
-// Copyright: Open CASCADE 2003
+// File: BRepMesh_FastDiscret.lxx
+// Created: Fri Sep 26 16:39:53 2003
+// Author: Open CASCADE Support
+// <support@opencascade.com>
+// Copyright: Open CASCADE 2003
#include <BRepMesh_DataStructureOfDelaun.hxx>
-//=======================================================================
-//function : InternalVerticesMode
-//purpose :
-//=======================================================================
-
-inline Standard_Boolean& BRepMesh_FastDiscret::InternalVerticesMode ()
-{
- return myInternalVerticesMode;
-}
-
//=======================================================================
//function : GetDeflection
//purpose :
inline Standard_Real BRepMesh_FastDiscret::GetDeflection() const
{
- return mydeflection;
+ return myDeflection;
}
//=======================================================================
inline Standard_Real BRepMesh_FastDiscret::GetAngle() const
{
- return myangle;
+ return myAngle;
}
//=======================================================================
inline const TopTools_DataMapOfShapeReal& BRepMesh_FastDiscret::GetMapOfDefEdge() const
{
- return mapdefle;
+ return myMapdefle;
}
//=======================================================================
inline void BRepMesh_FastDiscret::EdgesOfDomain(MeshDS_MapOfInteger& Indices) const
{
- Indices = structure->LinkOfDomain();
+ Indices = myStructure->LinkOfDomain();
}
//=======================================================================
inline void BRepMesh_FastDiscret::TrianglesOfDomain(MeshDS_MapOfInteger& Indices) const
{
- Indices = structure->ElemOfDomain();
+ Indices = myStructure->ElemOfDomain();
}
//=======================================================================
inline Standard_Integer BRepMesh_FastDiscret::NbPoint3d() const
{
- return nbLocat;
+ return myNbLocat;
}
//=======================================================================
inline const gp_Pnt& BRepMesh_FastDiscret::Point3d(const Standard_Integer Index) const
{
- return Location3d(Index);
+ return myLocation3d(Index);
}
//=======================================================================
inline Standard_Boolean BRepMesh_FastDiscret::InShape() const
{
- return myinshape;
+ return myInshape;
}
//=======================================================================
inline Standard_Boolean BRepMesh_FastDiscret::ShapeTrigu() const
{
- return myshapetrigu;
+ return myShapetrigu;
}
--- File: BRepMesh_FastDiscretFace.cdl
--- Created: Tue Oct 28 14:10:54 2008
--- Author:
--- <epa@TOSTEX>
----Copyright: Matra Datavision 2008
+-- File: BRepMesh_FastDiscretFace.cdl
+-- Created: Tue Oct 28 14:10:54 2008
+-- Author:
+-- <epa@TOSTEX>
+---Copyright: Matra Datavision 2008
private class FastDiscretFace from BRepMesh inherits TShared from MMgt
- ---Purpose: Algorithm to mesh a face with respect of the
- -- frontier the deflection and by option the shared
- -- components.
+ ---Purpose: Algorithm to mesh a face with respect of the
+ -- frontier the deflection and by option the shared
+ -- components.
uses Boolean from Standard,
- Integer from Standard,
- Real from Standard,
- Face from TopoDS,
- Edge from TopoDS,
- Vertex from TopoDS,
- ListOfShape from TopTools,
- Dir from gp,
- Pnt from gp,
- Pnt2d from gp,
+ Integer from Standard,
+ Real from Standard,
+ Face from TopoDS,
+ Edge from TopoDS,
+ Vertex from TopoDS,
+ Pnt from gp,
+ Pnt2d from gp,
XY from gp,
- HSurface from BRepAdaptor,
- Delaun from BRepMesh,
- DataStructureOfDelaun from BRepMesh,
- DataMapOfVertexInteger from BRepMesh,
- DataMapOfIntegerListOfXY from BRepMesh,
- DataMapOfShapeReal from TopTools,
- ListOfVertex from BRepMesh,
- ClassifierPtr from BRepMesh,
- Triangle from BRepMesh,
- Edge from BRepMesh,
- Vertex from BRepMesh,
- Status from BRepMesh,
- FaceAttribute from BRepMesh,
- Curve from Geom2d,
- ListOfInteger from TColStd,
- BaseAllocator from MeshDS,
- MapOfInteger from MeshDS,
- DataMapOfIntegerPnt from BRepMesh,
- IndexedMapOfInteger from TColStd,
+ HSurface from BRepAdaptor,
+ Delaun from BRepMesh,
+ DataStructureOfDelaun from BRepMesh,
+ DataMapOfVertexInteger from BRepMesh,
+ DataMapOfIntegerListOfXY from BRepMesh,
+ DataMapOfShapeReal from TopTools,
+ ListOfVertex from BRepMesh,
+ ClassifierPtr from BRepMesh,
+ Triangle from BRepMesh,
+ Edge from BRepMesh,
+ Vertex from BRepMesh,
+ FaceAttribute from BRepMesh,
+ ListOfInteger from TColStd,
+ BaseAllocator from MeshDS,
+ DataMapOfIntegerPnt from BRepMesh,
+ IndexedMapOfInteger from TColStd,
IndexedMapOfReal from TColStd,
- DataMapOfShapePairOfPolygon from BRepMesh
-
+ DataMapOfShapePairOfPolygon from BRepMesh,
+ Triangulation from Poly,
+ Location from TopLoc
+
is
- Create (angle : Real from Standard;
- withShare : Boolean from Standard=Standard_True;
- inshape : Boolean from Standard=Standard_False;
- shapetrigu : Boolean from Standard=Standard_False)
- returns mutable FastDiscretFace from BRepMesh;
-
-
-
-
- Add (me : mutable;
- face : Face from TopoDS;
- attrib : FaceAttribute from BRepMesh;
- mapdefle : DataMapOfShapeReal from TopTools)
- is static;
-
-
- Add (me : mutable;
- theVert: Vertex from TopoDS;
- face : Face from TopoDS;
- S : HSurface from BRepAdaptor) is private;
-
- Update (me: mutable;
- Edge: Edge from TopoDS;
- Face: Face from TopoDS;
- C : Curve from Geom2d;
- defedge: Real from Standard;
- first : Real from Standard;
- last : Real from Standard)
-
- returns Boolean;
-
+ Create (theAngle : Real from Standard;
+ theWithShare : Boolean from Standard=Standard_True)
+ returns mutable FastDiscretFace from BRepMesh;
+
+
+
+
+ Add (me : mutable;
+ theFace : Face from TopoDS;
+ theAttrib : FaceAttribute from BRepMesh;
+ theMapDefle : DataMapOfShapeReal from TopTools)
+ is static;
+
+
+ Add (me : mutable;
+ theVert : Vertex from TopoDS;
+ theFace : Face from TopoDS;
+ theSFace : HSurface from BRepAdaptor) is private;
+
+ RestoreStructureFromTriangulation
+ (me: mutable;
+ theEdge : Edge from TopoDS;
+ theFace : Face from TopoDS;
+ theSurf : HSurface from BRepAdaptor;
+ theTrigu : Triangulation from Poly;
+ theDefEdge : Real from Standard;
+ theLoc : Location from TopLoc)
+ returns Boolean from Standard is protected;
+
- InternalVertices
- (me : mutable;
- caro : HSurface from BRepAdaptor;
- inter : in out ListOfVertex from BRepMesh;
- defedge : Real from Standard;
- classifier : ClassifierPtr from BRepMesh)
- is static private;
-
-
- Control
- (me : mutable;
- caro : HSurface from BRepAdaptor;
- defface : Real from Standard;
- inter : in out ListOfVertex from BRepMesh;
- badTri : in out ListOfInteger from TColStd;
- nulTri : in out ListOfInteger from TColStd;
- trigu : in out Delaun from BRepMesh;
- isfirst : Boolean from Standard)
- returns Real from Standard is static;
-
- FindUV(me: mutable; V: Vertex from TopoDS;
- XY: Pnt2d from gp;
- ip: Integer from Standard;
- S : HSurface from BRepAdaptor;
- mindist: Real from Standard)
- returns XY from gp;
-
- AddInShape(me: mutable; face : Face from TopoDS;
- defedge: Real from Standard)
- is static private;
+ InternalVertices (me : mutable;
+ theCaro : HSurface from BRepAdaptor;
+ theInternalV : in out ListOfVertex from BRepMesh;
+ theDefFace : Real from Standard;
+ theClassifier : ClassifierPtr from BRepMesh)
+ is static private;
+
+
+ Control (me : mutable;
+ theCaro : HSurface from BRepAdaptor;
+ theDefFace : Real from Standard;
+ theInternalV : in out ListOfVertex from BRepMesh;
+ theBadTriangles : in out ListOfInteger from TColStd;
+ theNulTriangles : in out ListOfInteger from TColStd;
+ theTrigu : in out Delaun from BRepMesh;
+ theIsFirst : Boolean from Standard)
+ returns Real from Standard is static;
+
+ FindUV (myclass;
+ theV : Vertex from TopoDS;
+ theXY : Pnt2d from gp;
+ theIp : Integer from Standard;
+ theSFace : HSurface from BRepAdaptor;
+ theMinDist : Real from Standard;
+ theLocation2dMap: in out DataMapOfIntegerListOfXY from BRepMesh)
+ returns XY from gp;
+
+ AddInShape (me: mutable;
+ theFace : Face from TopoDS;
+ theDefFace: Real from Standard)
+ is static private;
-- Output :
- Triangle (me;
- Index : Integer from Standard)
- ---Purpose: Gives the triangle of <Index>.
- ---C++: return const &
- returns Triangle from BRepMesh
- is static;
-
- Edge (me;
- Index : Integer from Standard)
- ---Purpose: Gives the edge of index <Index>.
- ---C++: return const &
- returns Edge from BRepMesh
- is static;
-
-
- Vertex (me;
- Index : Integer from Standard)
- ---Purpose: Gives the vertex of <Index>.
- ---C++: return const &
- returns Vertex from BRepMesh
- is static;
-
- Pnt (me;
- Index : Integer from Standard)
- ---Purpose: Gives the location3d of the vertex of <Index>.
- ---C++: return const &
- returns Pnt from gp
- is static;
+ Triangle (me;
+ theIndex : Integer from Standard)
+ ---Purpose: Gives the triangle of <Index>.
+ ---C++: return const &
+ returns Triangle from BRepMesh
+ is static;
+
+ Edge (me;
+ theIndex : Integer from Standard)
+ ---Purpose: Gives the edge of index <Index>.
+ ---C++: return const &
+ returns Edge from BRepMesh
+ is static;
+
+
+ Vertex (me;
+ theIndex : Integer from Standard)
+ ---Purpose: Gives the vertex of <Index>.
+ ---C++: return const &
+ returns Vertex from BRepMesh
+ is static;
+
+ Pnt (me;
+ theIndex : Integer from Standard)
+ ---Purpose: Gives the location3d of the vertex of <Index>.
+ ---C++: return const &
+ returns Pnt from gp
+ is static;
fields
- angle : Real from Standard;
- WithShare : Boolean from Standard;
- vertices : DataMapOfVertexInteger from BRepMesh;
- edges : DataMapOfShapePairOfPolygon from BRepMesh;
- internaledges: DataMapOfShapePairOfPolygon from BRepMesh;
- nbLocat : Integer from Standard;
- Location3d : DataMapOfIntegerPnt from BRepMesh;
- structure : DataStructureOfDelaun from BRepMesh;
- mylistver : ListOfVertex from BRepMesh;
- myvemap : IndexedMapOfInteger from TColStd;
- mylocation2d : DataMapOfIntegerListOfXY from BRepMesh;
- myattrib : FaceAttribute from BRepMesh;
- myshapetrigu : Boolean from Standard;
- myinshape : Boolean from Standard;
- myInternalVerticesMode : Boolean from Standard; --mode to accounting internal vertices
- myUParam : IndexedMapOfReal from TColStd;
- myVParam : IndexedMapOfReal from TColStd;
- myAllocator : BaseAllocator from MeshDS;
+ myAngle : Real from Standard;
+ myWithShare : Boolean from Standard;
+ myVertices : DataMapOfVertexInteger from BRepMesh;
+ myInternaledges : DataMapOfShapePairOfPolygon from BRepMesh;
+ myNbLocat : Integer from Standard;
+ myLocation3d : DataMapOfIntegerPnt from BRepMesh;
+ myStructure : DataStructureOfDelaun from BRepMesh;
+ myListver : ListOfVertex from BRepMesh;
+ myVemap : IndexedMapOfInteger from TColStd;
+ myLocation2d : DataMapOfIntegerListOfXY from BRepMesh;
+ myAttrib : FaceAttribute from BRepMesh;
+ myInternalVerticesMode : Boolean from Standard; --mode to accounting internal vertices
+ myUParam : IndexedMapOfReal from TColStd;
+ myVParam : IndexedMapOfReal from TColStd;
+ myAllocator : BaseAllocator from MeshDS;
end FastDiscretFace;
-// File: BRepMesh_FastDiscretFace.cxx
-// Created:
-// Author: Ekaterina SMIRNOVA
+// File: BRepMesh_FastDiscretFace.cxx
+// Created:
+// Author: Ekaterina SMIRNOVA
// Copyright: Open CASCADE SAS 2008
#include <BRepMesh_FastDiscretFace.ixx>
#include <BRep_Tool.hxx>
#include <Geom_Surface.hxx>
#include <ElSLib.hxx>
-#include <Extrema_LocateExtPC.hxx>
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
-#include <SortTools_ShellSortOfReal.hxx>
-#include <Poly_Connect.hxx>
#include <Poly_PolygonOnTriangulation.hxx>
#include <Poly_Triangulation.hxx>
-#include <TCollection_CompareOfReal.hxx>
#include <TColStd_Array1OfReal.hxx>
-#include <TColStd_DataMapOfIntegerInteger.hxx>
#include <TColStd_SequenceOfReal.hxx>
#include <TColStd_Array1OfInteger.hxx>
-#include <TColStd_MapOfInteger.hxx>
-#include <TColStd_ListOfTransient.hxx>
#include <TColStd_HArray1OfReal.hxx>
-#include <TColGeom2d_SequenceOfCurve.hxx>
#include <TopExp_Explorer.hxx>
-#include <TopTools_SequenceOfShape.hxx>
#include <TopoDS.hxx>
#include <TopExp.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
//function : BRepMesh_FastDiscretFace
//purpose :
//=======================================================================
-BRepMesh_FastDiscretFace::BRepMesh_FastDiscretFace(const Standard_Real angl,
- const Standard_Boolean ws,
- const Standard_Boolean inshape,
- const Standard_Boolean shapetrigu):
- angle(angl), WithShare(ws), nbLocat(0),
- myshapetrigu(shapetrigu), myinshape(inshape),
+BRepMesh_FastDiscretFace::BRepMesh_FastDiscretFace
+ (const Standard_Real theAngle,
+ const Standard_Boolean theWithShare) :
+ myAngle(theAngle), myWithShare(theWithShare), myNbLocat(0),
myInternalVerticesMode(Standard_True)
{
myAllocator = new NCollection_IncAllocator(64000);
//purpose :
//=======================================================================
-void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theface,
- const Handle(BRepMesh_FaceAttribute)& attrib,
- const TopTools_DataMapOfShapeReal& mapdefle)
+void BRepMesh_FastDiscretFace::Add(const TopoDS_Face& theFace,
+ const Handle(BRepMesh_FaceAttribute)& theAttrib,
+ const TopTools_DataMapOfShapeReal& theMapDefle)
{
#ifndef DEB_MESH
try
{
OCC_CATCH_SIGNALS
#endif
- TopoDS_Face face = theface;
- myattrib = attrib;
+ TopoDS_Face face = theFace;
+ TopLoc_Location loc;
+
+ const Handle(Poly_Triangulation)& aFaceTrigu = BRep_Tool::Triangulation(face, loc);
+ if ( aFaceTrigu.IsNull() )
+ return;
+
+ myAttrib = theAttrib;
face.Orientation(TopAbs_FORWARD);
- structure.Nullify();
+ myStructure.Nullify();
Handle(NCollection_IncAllocator) anAlloc = Handle(NCollection_IncAllocator)::DownCast(myAllocator);
anAlloc->Reset(Standard_False);
- structure=new BRepMesh_DataStructureOfDelaun(anAlloc);
+ myStructure=new BRepMesh_DataStructureOfDelaun(anAlloc);
BRepAdaptor_Surface BS(face, Standard_False);
Handle(BRepAdaptor_HSurface) gFace = new BRepAdaptor_HSurface(BS);
GeomAbs_SurfaceType thetype;
thetype = BS.GetType();
- gp_Pnt2d uvFirst, uvLast;
-
TopAbs_Orientation orFace = face.Orientation();
- TopLoc_Location loc;
- if (!WithShare) {
- vertices.Clear();
- edges.Clear();
- }
+ if (!myWithShare)
+ myVertices.Clear();
- mylistver.Clear();
- myvemap.Clear();
- mylocation2d.Clear();
- internaledges.Clear();
+ myListver.Clear();
+ myVemap.Clear();
+ myLocation2d.Clear();
+ myInternaledges.Clear();
Standard_Integer i = 1;
- Standard_Integer nbEdge = 0;
- Standard_Real savangle = angle;
Standard_Integer ipn = 0;
-
- TColStd_SequenceOfReal aFSeq, aLSeq;
- TColGeom2d_SequenceOfCurve aCSeq;
- TopTools_SequenceOfShape aShSeq;
- Standard_Real defedge = 0;
-
+
TopoDS_Iterator exW(face);
for (; exW.More(); exW.Next()) {
const TopoDS_Shape& aWire = exW.Value();
if (aWire.ShapeType() != TopAbs_WIRE)
- continue;
+ continue;
TopoDS_Iterator ex(aWire);
for(; ex.More(); ex.Next()) {
- const TopoDS_Edge& edge = TopoDS::Edge(ex.Value());
- nbEdge++;
- Standard_Real f,l;
- if(edge.IsNull()) continue;
- Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(edge, face, f, l);
- if (C.IsNull()) continue;
-
- aFSeq.Append(f);
- aLSeq.Append(l);
- aCSeq.Append(C);
- aShSeq.Append(edge);
-
- Update(edge, face, C, mapdefle(edge), f, l);
- angle = savangle;
+ const TopoDS_Edge& edge = TopoDS::Edge(ex.Value());
+ if(edge.IsNull())
+ continue;
+
+ RestoreStructureFromTriangulation(edge, face, gFace, aFaceTrigu, theMapDefle(edge), loc);
}
}
Standard_Integer nbVertices = 0;
if(myInternalVerticesMode) {
for(TopExp_Explorer ex(face,TopAbs_VERTEX ,TopAbs_EDGE); ex.More(); ex.Next()) {
- const TopoDS_Vertex& aVert = TopoDS::Vertex(ex.Current());
- Add(aVert,face,gFace);
+ const TopoDS_Vertex& aVert = TopoDS::Vertex(ex.Current());
+ Add(aVert,face,gFace);
}
- nbVertices = myvemap.Extent();
+ nbVertices = myVemap.Extent();
}
// essai de determination de la longueur vraie:
//Standard_Real longu = 0.0, longv = 0.0; //, last , first;
//gp_Pnt P11, P12, P21, P22, P31, P32;
- Standard_Real umax = myattrib->GetUMax();
- Standard_Real umin = myattrib->GetUMin();
- Standard_Real vmax = myattrib->GetVMax();
- Standard_Real vmin = myattrib->GetVMin();
+ Standard_Real umax = myAttrib->GetUMax();
+ Standard_Real umin = myAttrib->GetUMin();
+ Standard_Real vmax = myAttrib->GetVMax();
+ Standard_Real vmin = myAttrib->GetVMin();
TColStd_Array1OfInteger tabvert_corr(1, nbVertices);
gp_Pnt2d p2d;
// Check the necessity to fill the map of parameters
const Standard_Boolean useUVParam = (thetype == GeomAbs_Torus ||
- thetype == GeomAbs_BezierSurface ||
- thetype == GeomAbs_BSplineSurface);
+ thetype == GeomAbs_BezierSurface ||
+ thetype == GeomAbs_BSplineSurface);
myUParam.Clear();
myVParam.Clear();
- BRepMesh_IDMapOfNodeOfDataStructureOfDelaun aMoveNodes(myvemap.Extent());
+ BRepMesh_IDMapOfNodeOfDataStructureOfDelaun aMoveNodes(myVemap.Extent());
- for (i = 1; i <= structure->NbNodes(); i++)
+ for (i = 1; i <= myStructure->NbNodes(); i++)
{
- const BRepMesh_Vertex& v = structure->GetNode(i);
+ const BRepMesh_Vertex& v = myStructure->GetNode(i);
p2d = v.Coord();
if (useUVParam) {
- myUParam.Add(p2d.X());
- myVParam.Add(p2d.Y());
+ myUParam.Add(p2d.X());
+ myVParam.Add(p2d.Y());
}
gp_XY res;
- res.SetCoord((p2d.X()-(myattrib->GetMinX()))/(myattrib->GetDeltaX()),
- (p2d.Y()-(myattrib->GetMinY()))/(myattrib->GetDeltaY()));
+ res.SetCoord((p2d.X()-(myAttrib->GetMinX()))/(myAttrib->GetDeltaX()),
+ (p2d.Y()-(myAttrib->GetMinY()))/(myAttrib->GetDeltaY()));
BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
- const MeshDS_ListOfInteger& alist = structure->GetNodeList(i);
+ const MeshDS_ListOfInteger& alist = myStructure->GetNodeList(i);
aMoveNodes.Add(v_new,alist);
tabvert_corr(i) = i;
- }
- structure->ReplaceNodes(aMoveNodes);
+ }
+ myStructure->ReplaceNodes(aMoveNodes);
Standard_Boolean rajout;
- BRepMesh_ClassifierPtr& classifier = attrib->GetClassifier();
+ BRepMesh_ClassifierPtr& classifier = theAttrib->GetClassifier();
switch (thetype)
{
rajout = Standard_False;
}
- BRepMesh_Delaun trigu(structure, tabvert_corr, orFace==TopAbs_FORWARD);
+ BRepMesh_Delaun trigu(myStructure, tabvert_corr, orFace==TopAbs_FORWARD);
//removed all free edges from triangulation
- Standard_Integer nbLinks = structure->NbNodes();
+ Standard_Integer nbLinks = myStructure->NbNodes();
for(i = 1; i <= nbLinks; i++)
{
- if(structure->ElemConnectedTo(i).Extent() < 1)
+ if(myStructure->ElemConnectedTo(i).Extent() < 1)
{
BRepMesh_Edge& anEdge = (BRepMesh_Edge&)trigu.GetEdge(i);
if(anEdge.Movability()==MeshDS_Deleted)
continue;
anEdge.SetMovability(MeshDS_Free);
- structure->RemoveLink(i);
+ myStructure->RemoveLink(i);
}
}
isaline = ((umax-umin)<1.e-05) || ((vmax-vmin)<1.e-05);
Standard_Real aDef = -1;
- if (!isaline && structure->ElemOfDomain().Extent() > 0) {
+ if (!isaline && myStructure->ElemOfDomain().Extent() > 0) {
TColStd_ListOfInteger badTri, nulTri;
if(!rajout)
{
- aDef = Control(gFace, attrib->GetDefFace(), mylistver, badTri, nulTri, trigu, Standard_True);
- if( aDef > attrib->GetDefFace() || aDef < 0.)
- rajout = Standard_True;
+ aDef = Control(gFace, theAttrib->GetDefFace(), myListver, badTri, nulTri, trigu, Standard_True);
+ if( aDef > theAttrib->GetDefFace() || aDef < 0.)
+ rajout = Standard_True;
}
if(!rajout) {
- if(useUVParam) {
- if(BS.IsUClosed()) {
- if(myVParam.Extent() > 2) {
- rajout = Standard_True;
- }
- }
- if(BS.IsVClosed()) {
- if(myUParam.Extent() > 2) {
- rajout = Standard_True;
- }
- }
- }
+ if(useUVParam) {
+ if(BS.IsUClosed()) {
+ if(myVParam.Extent() > 2) {
+ rajout = Standard_True;
+ }
+ }
+ if(BS.IsVClosed()) {
+ if(myUParam.Extent() > 2) {
+ rajout = Standard_True;
+ }
+ }
+ }
}
if(rajout){
- InternalVertices(gFace, mylistver, attrib->GetDefFace(), classifier);
-
- if (mylistver.Extent() > 0) {
- BRepMesh_Array1OfVertexOfDelaun verttab(1, mylistver.Extent());
- BRepMesh_ListIteratorOfListOfVertex itVer(mylistver);
- ipn = 1;
- for (; itVer.More(); itVer.Next())
- verttab(ipn++) = itVer.Value();
- trigu.AddVertices(verttab);
- }
- //control internal points
- BRepMesh_ListOfVertex vvlist;
- aDef = Control(gFace, attrib->GetDefFace(), vvlist, badTri, nulTri, trigu, Standard_False);
- mylistver.Append(vvlist);
+ InternalVertices(gFace, myListver, theAttrib->GetDefFace(), classifier);
+
+ if (myListver.Extent() > 0) {
+ BRepMesh_Array1OfVertexOfDelaun verttab(1, myListver.Extent());
+ BRepMesh_ListIteratorOfListOfVertex itVer(myListver);
+ ipn = 1;
+ for (; itVer.More(); itVer.Next())
+ verttab(ipn++) = itVer.Value();
+ trigu.AddVertices(verttab);
+ }
+ //control internal points
+ BRepMesh_ListOfVertex vvlist;
+ aDef = Control(gFace, theAttrib->GetDefFace(), vvlist, badTri, nulTri, trigu, Standard_False);
+ myListver.Append(vvlist);
}
}
- //modify structure back
+ //modify myStructure back
aMoveNodes.Clear();
- Standard_Real deltaX = myattrib->GetDeltaX();
- Standard_Real deltaY = myattrib->GetDeltaY();
- for (i = 1; i <= structure->NbNodes(); i++)
+ Standard_Real deltaX = myAttrib->GetDeltaX();
+ Standard_Real deltaY = myAttrib->GetDeltaY();
+ for (i = 1; i <= myStructure->NbNodes(); i++)
{
- const BRepMesh_Vertex& v = structure->GetNode(i);
+ const BRepMesh_Vertex& v = myStructure->GetNode(i);
p2d = v.Coord();
gp_XY res;
res.SetCoord(p2d.X()*deltaX+umin,p2d.Y()*deltaY+vmin);
BRepMesh_Vertex v_new(res,v.Location3d(),v.Movability());
- const MeshDS_ListOfInteger& alist = structure->GetNodeList(i);
+ const MeshDS_ListOfInteger& alist = myStructure->GetNodeList(i);
aMoveNodes.Add(v_new,alist);
}
- structure->ReplaceNodes(aMoveNodes);
+ myStructure->ReplaceNodes(aMoveNodes);
- AddInShape(face, (aDef < 0.0)? attrib->GetDefFace() : aDef);
+ AddInShape(face, (aDef < 0.0)? theAttrib->GetDefFace() : aDef);
#ifndef DEB_MESH
}
catch(Standard_Failure)
{
BRep_Builder B;
Handle(Poly_Triangulation) TNull;
- B.UpdateFace(theface,TNull);
+ B.UpdateFace(theFace,TNull);
}
#endif // DEB_MESH
- structure.Nullify();
- myattrib.Nullify();
+ myStructure.Nullify();
+ myAttrib.Nullify();
}
//=======================================================================
-//function : Update(edge)
-//purpose :
+//function : RestoreStructureFromTriangulation(edge)
+//purpose : Restore structure of Delaun from triangulation on face
//=======================================================================
-Standard_Boolean BRepMesh_FastDiscretFace::Update(const TopoDS_Edge& edge,
- const TopoDS_Face& face,
- const Handle(Geom2d_Curve)& C2d,
- const Standard_Real defedge,
- const Standard_Real first,
- const Standard_Real last)
+Standard_Boolean BRepMesh_FastDiscretFace::RestoreStructureFromTriangulation
+ (const TopoDS_Edge& theEdge,
+ const TopoDS_Face& theFace,
+ const Handle(BRepAdaptor_HSurface)& theSurf,
+ const Handle(Poly_Triangulation)& theTrigu,
+ const Standard_Real theDefEdge,
+ const TopLoc_Location& theLoc)
{
- TopLoc_Location l;
- Handle(Poly_Triangulation) T, TNull;
- Handle(Poly_PolygonOnTriangulation) Poly, NullPoly;
+ // oan: changes for right restoring of triangulation data from face & edges
+ Handle(Poly_PolygonOnTriangulation) Poly;
+ Poly = BRep_Tool::PolygonOnTriangulation(theEdge, theTrigu, theLoc);
- Standard_Integer i = 1;
- Standard_Boolean found = Standard_False;
- do
+ if (Poly.IsNull() || !Poly->HasParameters())
{
- BRep_Tool::PolygonOnTriangulation(edge,Poly,T,l,i);
- i++;
- if (!found && !T.IsNull() && T->HasUVNodes() &&
- !Poly.IsNull() && Poly->HasParameters())
- {
- if (Poly->Deflection() <= 1.1*defedge)
- {
- // 2d vertex indices
- TopAbs_Orientation orEdge = edge.Orientation();
- Standard_Integer iv1, iv2, ivl;
- Standard_Integer isv1, isv, isvl;
-
- // Get range on 2d curve
- Standard_Real wFirst, wLast;
- BRep_Tool::Range(edge, face, wFirst, wLast);
-
- // Get end points on 2d curve
- gp_Pnt2d uvFirst, uvLast;
- BRep_Tool::UVPoints(edge, face, uvFirst, uvLast);
-
- // Get vertices
- TopoDS_Vertex pBegin, pEnd;
- TopExp::Vertices(edge,pBegin,pEnd);
-
- const Standard_Boolean sameUV =
- uvFirst.IsEqual(uvLast, Precision::PConfusion());
-
- //Controle vertice tolerances
- BRepAdaptor_Surface BS(face, Standard_False);
- Handle(BRepAdaptor_HSurface) gFace = new BRepAdaptor_HSurface(BS);
+ return Standard_False;
+ }
+
+ // 2d vertex indices
+ TopAbs_Orientation orEdge = theEdge.Orientation();
+ // Get end points on 2d curve
+ gp_Pnt2d uvFirst, uvLast;
+ BRep_Tool::UVPoints(theEdge, theFace, uvFirst, uvLast);
+ // Get vertices
+ TopoDS_Vertex pBegin, pEnd;
+ TopExp::Vertices(theEdge,pBegin,pEnd);
- gp_Pnt pFirst = gFace->Value(uvFirst.X(), uvFirst.Y());
- gp_Pnt pLast = gFace->Value(uvLast.X(), uvLast.Y());
-
- Standard_Real mindist = 10. * Max(pFirst.Distance(BRep_Tool::Pnt(pBegin)),
- pLast.Distance(BRep_Tool::Pnt(pEnd)));
+ const Standard_Boolean sameUV =
+ uvFirst.IsEqual(uvLast, Precision::PConfusion());
- if (mindist < BRep_Tool::Tolerance(pBegin) ||
- mindist < BRep_Tool::Tolerance(pEnd) ) mindist = defedge;
+ const TColgp_Array1OfPnt2d& UVNodes = theTrigu->UVNodes();
+ const TColgp_Array1OfPnt& Nodes = theTrigu->Nodes();
+ const TColStd_Array1OfInteger& Indices = Poly->Nodes();
- if (sameUV)
- {
- // 1. est-ce vraiment sameUV sans etre denegere
- gp_Pnt2d uvF, uvL;
- C2d->D0(first, uvF);
- C2d->D0(last, uvL);
- if (!uvFirst.IsEqual(uvF, Precision::PConfusion())) {
- uvFirst = uvF;
- }
- if (!uvLast.IsEqual(uvL, Precision::PConfusion())) {
- uvLast = uvL;
- }
- }
-
- const TColgp_Array1OfPnt& Nodes = T->Nodes();
- const TColStd_Array1OfInteger& Indices = Poly->Nodes();
- Handle(TColStd_HArray1OfReal) Param = Poly->Parameters();
-
- const Standard_Integer nbnodes = Indices.Length();
- TColStd_Array1OfInteger NewNodes(1, nbnodes);
- TColStd_Array1OfInteger NewNodInStruct(1, nbnodes);
-
- gp_Pnt P3d;
- gp_XY theUV;
-
- // Process first vertex
- Standard_Integer ipf;
- if (vertices.IsBound(pBegin))
- {
- ipf = vertices.Find(pBegin);
- }
- else
- {
- if (sameUV && vertices.IsBound(pEnd))
- {
- ipf = vertices.Find(pEnd);
- }
- else
- {
- P3d = Nodes(Indices(1));
- if (!l.IsIdentity())
- P3d.Transform(l.Transformation());
- nbLocat++;
- Location3d.Bind(nbLocat,P3d);
- ipf = nbLocat;
- }
- vertices.Bind(pBegin,ipf);
- }
- NewNodInStruct(1) = ipf;
- theUV = FindUV(pBegin, uvFirst, ipf, gFace, mindist);
- BRepMesh_Vertex vf(theUV,ipf,MeshDS_Frontier);
- iv1 = structure->AddNode(vf);
- isv1 = myvemap.FindIndex(iv1);
- if (isv1 == 0) isv1 = myvemap.Add(iv1);
- NewNodes(1) = isv1;
-
- // Process last vertex
- Standard_Integer ipl;
- if (pEnd.IsSame(pBegin))
- {
- ipl = ipf;
- }
- else
- {
- if (vertices.IsBound(pEnd))
- {
- ipl = vertices.Find(pEnd);
- }
- else
- {
- if (sameUV)
- {
- ipl = ipf;
- ivl = iv1;
- isv1 = isv1;
- }
- else
- {
- nbLocat++;
- Location3d.Bind(nbLocat,Nodes(Indices(nbnodes)).Transformed(l.Transformation()));
- ipl = nbLocat;
- }
- vertices.Bind(pEnd,ipl);
- }
- }
- NewNodInStruct(nbnodes) = ipl;
- theUV = FindUV(pEnd, uvLast, ipl, gFace, mindist);
- BRepMesh_Vertex vl(theUV,ipl,MeshDS_Frontier);
-
- ivl = structure->AddNode(vl);
- isvl = myvemap.FindIndex(ivl);
- if (isvl == 0) isvl = myvemap.Add(ivl);
-
- NewNodes(nbnodes) = isvl;
-
- gp_Pnt2d uv;
- BRepMesh_Vertex v;
-
- if (BRep_Tool::SameParameter(edge))
- {
- for (i = 2; i < Indices.Length(); i++)
- {
- // Record 3d point
- P3d = Nodes(Indices(i));
- if (!l.IsIdentity())
- P3d.Transform(l.Transformation());
- nbLocat++;
- Location3d.Bind(nbLocat, P3d);
- NewNodInStruct(i) = nbLocat;
- // Record 2d point
- uv = C2d->Value(Param->Value(i));
- v.Initialize(uv.Coord(), nbLocat, MeshDS_Frontier);
- iv2 = structure->AddNode(v);
- isv = myvemap.FindIndex(iv2);
- if (isv == 0) isv = myvemap.Add(iv2);
- NewNodes(i) = isv;
-
- //add links
- if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
- iv1 = iv2;
- }
-
- // last point
- if (iv1 != ivl) {
- if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
- }
-
-
- }
- else
- {
- const Standard_Real wFold = Param->Value(Param->Lower());
- const Standard_Real wLold = Param->Value(Param->Upper());
+ const Standard_Integer nbnodes = Indices.Length();
+ TColStd_Array1OfInteger NewNodes(1, nbnodes);
+
+ gp_Pnt P3d;
+ gp_XY anUV;
- Standard_Real wKoef = 1.;
- if ((wFold != wFirst || wLold != wLast) && wLold != wFold)
- {
- wKoef = (wLast - wFirst) / (wLold - wFold);
- }
-
- BRepAdaptor_Curve cons(edge, face);
- Extrema_LocateExtPC pcos;
- pcos.Initialize(cons, cons.FirstParameter(),
- cons.LastParameter(), Precision::PConfusion());
-
- Standard_Real wPrev;
- Standard_Real wCur = wFirst;
- Standard_Real wCurFound = wFirst;
- for (i = 2; i < Indices.Length(); i++)
- {
- // Record 3d point
- P3d = Nodes(Indices(i));
- if (!l.IsIdentity())
- P3d.Transform(l.Transformation());
- nbLocat++;
- Location3d.Bind(nbLocat, P3d);
- NewNodInStruct(i) = nbLocat;
- // Record 2d point
- wPrev = wCur;
- wCur = wFirst + wKoef*(Param->Value(i) - wFold);
- wCurFound += (wCur - wPrev);
- pcos.Perform(P3d, wCurFound);
- if (pcos.IsDone()) wCurFound = pcos.Point().Parameter();
- C2d->D0(wCurFound, uv);
- v.Initialize(uv.Coord(), nbLocat, MeshDS_Frontier);
- iv2 = structure->AddNode(v);
- isv = myvemap.FindIndex(iv2);
- if (isv == 0) isv = myvemap.Add(iv2);
- NewNodes(i) = isv;
+ // Process first vertex
+ Standard_Integer ipf;
+ if (myVertices.IsBound(pBegin))
+ {
+ ipf = myVertices.Find(pBegin);
+ }
+ else
+ {
+ if (sameUV && myVertices.IsBound(pEnd))
+ {
+ ipf = myVertices.Find(pEnd);
+ }
+ else
+ {
+ P3d = Nodes(Indices(1));
+ if (!theLoc.IsIdentity())
+ P3d.Transform(theLoc.Transformation());
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P3d);
+ ipf = myNbLocat;
+ }
+ myVertices.Bind(pBegin,ipf);
+ }
+
+ //Controle vertice tolerances
+ gp_Pnt pFirst = theSurf->Value(uvFirst.X(), uvFirst.Y());
+ gp_Pnt pLast = theSurf->Value(uvLast.X(), uvLast.Y());
+
+ Standard_Real mindist = 10. * Max(pFirst.Distance(BRep_Tool::Pnt(pBegin)),
+ pLast.Distance(BRep_Tool::Pnt(pEnd)));
-
- //add links
- if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
- iv1 = iv2;
- }
-
- // last point
- if (iv1 != ivl) {
- if (orEdge == TopAbs_FORWARD)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
- else if (orEdge == TopAbs_REVERSED)
- structure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
- else if (orEdge == TopAbs_INTERNAL)
- structure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
- }
- }
-
- Handle(Poly_PolygonOnTriangulation) P1 =
- new Poly_PolygonOnTriangulation(NewNodes, Param->Array1());
- P1->Deflection(defedge);
- if (internaledges.IsBound(edge))
- {
- BRepMesh_PairOfPolygon& pair = internaledges.ChangeFind(edge);
- if (edge.Orientation() == TopAbs_REVERSED)
- pair.Append(P1);
- else
- pair.Prepend(P1);
- }
- else
- {
- BRepMesh_PairOfPolygon pair1;
- pair1.Append(P1);
- internaledges.Bind(edge, pair1);
- }
-
- Handle(Poly_PolygonOnTriangulation) P2 =
- new Poly_PolygonOnTriangulation(NewNodInStruct, Param->Array1());
- P2->Deflection(defedge);
- BRepMesh_PairOfPolygon pair;
- pair.Append(P2);
- edges.Bind(edge, pair);
-
- found = Standard_True;
+ if (mindist < BRep_Tool::Tolerance(pBegin) ||
+ mindist < BRep_Tool::Tolerance(pEnd) ) mindist = theDefEdge;
+
+ anUV = FindUV(pBegin, uvFirst, ipf, theSurf, mindist, myLocation2d);
+ Standard_Integer iv1, isv1;
+ BRepMesh_Vertex vf(anUV, ipf, MeshDS_Frontier);
+ iv1 = myStructure->AddNode(vf);
+ isv1 = myVemap.FindIndex(iv1);
+ if (isv1 == 0)
+ isv1 = myVemap.Add(iv1);
+ NewNodes(1) = isv1;
+
+ // Process last vertex
+ Standard_Integer ipl, ivl;
+ if (pEnd.IsSame(pBegin))
+ {
+ ipl = ipf;
+ }
+ else
+ {
+ if (myVertices.IsBound(pEnd))
+ {
+ ipl = myVertices.Find(pEnd);
+ }
+ else
+ {
+ if (sameUV)
+ {
+ ipl = ipf;
+ ivl = iv1;
}
else
{
- BRep_Builder B;
- B.UpdateEdge(edge,NullPoly,T,l);
- B.UpdateFace(face,TNull);
+ P3d = Nodes(Indices(nbnodes));
+ if (!theLoc.IsIdentity())
+ P3d.Transform(theLoc.Transformation());
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P3d);
+ ipl = myNbLocat;
}
- }
- else if (!T.IsNull() && !T->HasUVNodes())
- {
- BRep_Builder B;
- B.UpdateEdge(edge,NullPoly,T,l);
- B.UpdateFace(face,TNull);
+ myVertices.Bind(pEnd,ipl);
}
}
- while (!Poly.IsNull());
- return found;
-}
+ anUV = FindUV(pEnd, uvLast, ipl, theSurf, mindist, myLocation2d);
+ BRepMesh_Vertex vl(anUV, ipl, MeshDS_Frontier);
+
+ Standard_Integer isvl;
+ ivl = myStructure->AddNode(vl);
+ isvl = myVemap.FindIndex(ivl);
+ if (isvl == 0)
+ isvl = myVemap.Add(ivl);
+ NewNodes(nbnodes) = isvl;
+
+ BRepMesh_Vertex v;
+ Standard_Integer i;
+ for (i = 2; i < nbnodes; i++)
+ {
+ // Record 3d point
+ P3d = Nodes(Indices(i));
+ if (!theLoc.IsIdentity())
+ P3d.Transform(theLoc.Transformation());
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P3d);
+
+ // Record 2d point
+ anUV = UVNodes(Indices(i)).Coord();
+
+ Standard_Integer iv2, isv;
+ v.Initialize(anUV, myNbLocat, MeshDS_Frontier);
+ iv2 = myStructure->AddNode(v);
+ isv = myVemap.FindIndex(iv2);
+ if (isv == 0)
+ isv = myVemap.Add(iv2);
+ NewNodes(i) = isv;
+
+ //add links
+ if (orEdge == TopAbs_FORWARD)
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Frontier));
+ else if (orEdge == TopAbs_REVERSED)
+ myStructure->AddLink(BRepMesh_Edge(iv2,iv1,MeshDS_Frontier));
+ else if (orEdge == TopAbs_INTERNAL)
+ myStructure->AddLink(BRepMesh_Edge(iv1,iv2,MeshDS_Fixed));
+ iv1 = iv2;
+ }
+
+ // last point
+ if (iv1 != ivl) {
+ if (orEdge == TopAbs_FORWARD)
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Frontier));
+ else if (orEdge == TopAbs_REVERSED)
+ myStructure->AddLink(BRepMesh_Edge(ivl,iv1,MeshDS_Frontier));
+ else if (orEdge == TopAbs_INTERNAL)
+ myStructure->AddLink(BRepMesh_Edge(iv1,ivl,MeshDS_Fixed));
+ }
+
+ Handle(Poly_PolygonOnTriangulation) P1 =
+ new Poly_PolygonOnTriangulation(NewNodes, Poly->Parameters()->Array1());
+ P1->Deflection(theDefEdge);
+ if (myInternaledges.IsBound(theEdge))
+ {
+ BRepMesh_PairOfPolygon& pair = myInternaledges.ChangeFind(theEdge);
+ if (theEdge.Orientation() == TopAbs_REVERSED)
+ pair.Append(P1);
+ else
+ pair.Prepend(P1);
+ }
+ else
+ {
+ BRepMesh_PairOfPolygon pair1;
+ pair1.Append(P1);
+ myInternaledges.Bind(theEdge, pair1);
+ }
+ return Standard_True;
+}
//=======================================================================
//function : InternalVertices
//purpose :
//=======================================================================
-void BRepMesh_FastDiscretFace::InternalVertices ( const Handle(BRepAdaptor_HSurface)& caro,
- BRepMesh_ListOfVertex& InternalV,
- const Standard_Real defface,
- const BRepMesh_ClassifierPtr& classifier)
+void BRepMesh_FastDiscretFace::InternalVertices(const Handle(BRepAdaptor_HSurface)& theCaro,
+ BRepMesh_ListOfVertex& theInternalV,
+ const Standard_Real theDefFace,
+ const BRepMesh_ClassifierPtr& theClassifier)
{
BRepMesh_Vertex newV;
gp_Pnt2d p2d;
gp_Pnt p3d;
// travail suivant le type de surface
+ const BRepAdaptor_Surface& BS = *(BRepAdaptor_Surface*)&(theCaro->Surface());
+ GeomAbs_SurfaceType thetype = theCaro->GetType();
+ Standard_Real umax = myAttrib->GetUMax();
+ Standard_Real umin = myAttrib->GetUMin();
+ Standard_Real vmax = myAttrib->GetVMax();
+ Standard_Real vmin = myAttrib->GetVMin();
+ Standard_Real deltaX = myAttrib->GetDeltaX();
+ Standard_Real deltaY = myAttrib->GetDeltaY();
- const BRepAdaptor_Surface& BS = *(BRepAdaptor_Surface*)&(caro->Surface());
- GeomAbs_SurfaceType thetype = caro->GetType();
-
- Standard_Real umax = myattrib->GetUMax();
- Standard_Real umin = myattrib->GetUMin();
- Standard_Real vmax = myattrib->GetVMax();
- Standard_Real vmin = myattrib->GetVMin();
- Standard_Real deltaX = myattrib->GetDeltaX();
- Standard_Real deltaY = myattrib->GetDeltaY();
-
- if (thetype == GeomAbs_Plane && !classifier->NaturalRestriction())
+ if (thetype == GeomAbs_Plane && !theClassifier->NaturalRestriction())
{
// rajout d`un seul point au milieu.
const Standard_Real U = 0.5*(umin+umax);
const Standard_Real V = 0.5*(vmin+vmax);
- if (classifier->Perform(gp_Pnt2d(U, V)) == TopAbs_IN)
+ if (theClassifier->Perform(gp_Pnt2d(U, V)) == TopAbs_IN)
{
// Record 3d point
- BRepMesh_GeomTool::D0(caro, U, V, p3d);
- nbLocat++;
- Location3d.Bind(nbLocat, p3d);
+ BRepMesh_GeomTool::D0(theCaro, U, V, p3d);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
p2d.SetCoord((U-umin)/deltaX, (V-vmin)/deltaY);
- newV.Initialize(p2d.XY(), nbLocat, MeshDS_Free);
- InternalV.Append(newV);
+ newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ theInternalV.Append(newV);
}
}
else if (thetype == GeomAbs_Sphere)
const Standard_Real R = S.Radius();
// Calculate parameters for iteration in V direction
- Standard_Real Dv = 1.0 - (defface/R);
+ Standard_Real Dv = 1.0 - (theDefFace/R);
if (Dv < 0.0) Dv = 0.0;
Standard_Real oldDv = 2.0 * ACos (Dv);
Dv = .7 * oldDv; //.7 ~= sqrt(2.) - Dv is hypotenuse of triangle when oldDv is legs
const Standard_Real pasumax = umax-Du*0.5 + d;
for (pasu = umin + Du - d; pasu < pasumax; pasu += Du)
{
- if (classifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
+ if (theClassifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
{
// Record 3d point
#ifdef DEB_MESH_CHRONO
- D0Internal++;
+ D0Internal++;
#endif
- ElSLib::D0(pasu, pasv, S, p3d);
- nbLocat++;
- Location3d.Bind(nbLocat, p3d);
+ ElSLib::D0(pasu, pasv, S, p3d);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
- p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), nbLocat, MeshDS_Free);
- InternalV.Append(newV);
- }
+ p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
+ newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ theInternalV.Append(newV);
+ }
}
}
}
const Standard_Real R = S.Radius();
// Calculate parameters for iteration in U direction
- Standard_Real Du = 1.0 - (defface/R);
+ Standard_Real Du = 1.0 - (theDefFace/R);
if (Du < 0.0) Du = 0.0;
Du = 2.0 * ACos (Du);
- if (Du > angle) Du = angle;
+ if (Du > myAngle) Du = myAngle;
const Standard_Real su = umax - umin;
const Standard_Integer nbU = (Standard_Integer)(su/Du);
Du = su/(nbU+1);
Standard_Real pasu, pasv, pasvmax = vmax-Dv*0.5, pasumax = umax-Du*0.5;
for (pasv = vmin + Dv; pasv < pasvmax; pasv += Dv) {
for (pasu = umin + Du; pasu < pasumax; pasu += Du) {
- if (classifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
+ if (theClassifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
{
// Record 3d point
- ElSLib::D0(pasu, pasv, S, p3d);
- nbLocat++;
- Location3d.Bind(nbLocat, p3d);
+ ElSLib::D0(pasu, pasv, S, p3d);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
- p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), nbLocat, MeshDS_Free);
- InternalV.Append(newV);
- }
+ p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
+ newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ theInternalV.Append(newV);
+ }
}
}
}
SAng = C.SemiAngle();
R = Max(Abs(RefR+vmin*Sin(SAng)), Abs(RefR+vmax*Sin(SAng)));
Standard_Real Du, Dv, pasu, pasv;
- Du = Max(1.0e0 - (defface/R),0.0e0);
+ Du = Max(1.0e0 - (theDefFace/R),0.0e0);
Du = (2.0 * ACos (Du));
Standard_Integer nbU = (Standard_Integer) ( (umax-umin)/Du );
Standard_Integer nbV = (Standard_Integer) ( nbU*(vmax-vmin)/((umax-umin)*R) );
Standard_Real pasvmax = vmax-Dv*0.5, pasumax = umax-Du*0.5;
for (pasv = vmin + Dv; pasv < pasvmax; pasv += Dv) {
for (pasu = umin + Du; pasu < pasumax; pasu += Du) {
- if (classifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
+ if (theClassifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
{
// Record 3d point
- ElSLib::D0(pasu, pasv, C, p3d);
- nbLocat++;
- Location3d.Bind(nbLocat, p3d);
+ ElSLib::D0(pasu, pasv, C, p3d);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), nbLocat, MeshDS_Free);
- InternalV.Append(newV);
- }
+ newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ theInternalV.Append(newV);
+ }
}
}
}
TColStd_SequenceOfReal ParamU, ParamV;
Standard_Real Du, Dv;//, pasu, pasv;
- Dv = Max(1.0e0 - (defface/r),0.0e0) ;
+ Dv = Max(1.0e0 - (theDefFace/r),0.0e0) ;
Standard_Real oldDv = 2.0 * ACos (Dv);
- oldDv = Min(oldDv, angle);
+ oldDv = Min(oldDv, myAngle);
Dv = 0.9*oldDv; //TWOTHIRD * oldDv;
Dv = oldDv;
Standard_Real ru = R + r;
if (ru > 1.e-16)
{
- Du = 2.0 * ACos(Max(1.0 - (defface/ru),0.0));
- if (angle < Du) Du = angle;
+ Du = 2.0 * ACos(Max(1.0 - (theDefFace/ru),0.0));
+ if (myAngle < Du) Du = myAngle;
Standard_Real aa = sqrt(Du*Du + oldDv*oldDv);
if(aa < gp::Resolution())
return;
pasu = ParamU.Value(i);
if (pasu >= uminnew && pasu < umaxnew)
{
- for (j = 1; j <= Lv; j++)
+ for (j = 1; j <= Lv; j++)
{
- pasv = ParamV.Value(j);
- if (pasv >= vminnew && pasv < vmaxnew)
+ pasv = ParamV.Value(j);
+ if (pasv >= vminnew && pasv < vmaxnew)
{
- if (classifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
+ if (theClassifier->Perform(gp_Pnt2d(pasu, pasv)) == TopAbs_IN)
{
// Record 3d point
- ElSLib::D0(pasu, pasv, T, p3d);
- nbLocat++;
- Location3d.Bind(nbLocat, p3d);
+ ElSLib::D0(pasu, pasv, T, p3d);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, p3d);
// Record 2d point
- p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
- newV.Initialize(p2d.XY(), nbLocat, MeshDS_Free);
- InternalV.Append(newV);
- }
- }
- }
+ p2d.SetCoord((pasu-umin)/deltaX, (pasv-vmin)/deltaY);
+ newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ theInternalV.Append(newV);
+ }
+ }
+ }
}
}
}
aSurf->VKnots(anVKnots->ChangeArray1());
}
- Standard_Real ddu = caro->UResolution(defface)*5.;
-
+ Standard_Real ddu = theCaro->UResolution(theDefFace)*5.;
Standard_Real aDUmin = (umax-umin)/5.;
if(ddu > aDUmin)
ddu = aDUmin;
+
// Sort sequence of U parameters
TColStd_SequenceOfReal ParamU;
- Standard_Integer anUdegree = caro->UDegree();
-
+ Standard_Integer anUdegree = theCaro->UDegree();
+
Standard_Real aU1 = anUKnots->Value(1);
for( i = 1; i < aNbUNkots; i++)
{
Standard_Real aEnd = anUKnots->Value(i+1);
Standard_Integer aNbPoints = anUdegree-1;
Standard_Real aStep = (aEnd-aStart)/(aNbPoints+1);
+
for( Standard_Integer anInd = 0; anInd<= aNbPoints; anInd++)
{
Standard_Real aU2 = aStart+anInd*aStep;
ParamU.Append(anUKnots->Value(aNbUNkots));
Standard_Integer ParamULength = ParamU.Length();
- Standard_Real ddv = caro->VResolution(defface)*5.;
-
+ Standard_Real ddv = theCaro->VResolution(theDefFace)*5.;
Standard_Real aDVmin = (vmax-vmin)/5.;
if(ddv > aDVmin)
ddv = aDVmin;
// Sort sequence of V parameters
TColStd_SequenceOfReal ParamV;
- Standard_Integer anVdegree = caro->VDegree();
-
+ Standard_Integer anVdegree = theCaro->VDegree();
+
Standard_Real aV1 = anVKnots->Value(1);
for( i = 1; i < aNbVNkots; i++)
{
Standard_Real aEnd = anVKnots->Value(i+1);
Standard_Integer aNbPoints = anVdegree-1;
Standard_Real aStep = (aEnd-aStart)/(aNbPoints+1);
+
for( Standard_Integer anInd = 0; anInd<= aNbPoints; anInd++)
{
Standard_Real aV2 = aStart+anInd*aStep;
V2 = ParamV.Value(j);
P2 = IsoU->Value(V2);
v = 0.5*(V1+V2);
- PControl = IsoU->Value(v);
+ PControl = IsoU->Value(v);
// 23.03.2010 skl for OCC21645 - change precision for comparison
if( P1.SquareDistance(P2) > dPreci ) {
gp_Lin L (P1, gp_Dir(gp_Vec(P1, P2)));
dist = L.Distance(PControl);
}
- else {
+ else {
dist = P1.Distance(PControl);
}
- if (dist > defface) {
+ if (dist > theDefFace) {
// insertion
ParamV.InsertBefore(j, v);
ParamVLength++;
V1 = V2;
P1 = P2;
j++;
- }
+ }
}
}
P1 = IsoV->Value(U1);
for (j = 2; j <= ParamULength;) {
U2 = ParamU.Value(j);
- P2 = IsoV->Value(U2);
- u = 0.5*(U1+U2);
- PControl = IsoV->Value(u);
+ P2 = IsoV->Value(U2);
+ u = 0.5*(U1+U2);
+ PControl = IsoV->Value(u);
// 23.03.2010 skl for OCC21645 - change precision for comparison
if( P1.SquareDistance(P2) > dPreci ) {
gp_Lin L (P1, gp_Dir(gp_Vec(P1, P2)));
else {
dist = P1.Distance(PControl);
}
- if (dist > defface) {
+ if (dist > theDefFace) {
// insertion
ParamU.InsertBefore(j, u);
ParamULength++;
P1 = P2;
if (j < ParamULength) {
// Classify intersection point
- if (classifier->Perform(gp_Pnt2d(U1, v)) == TopAbs_IN)
+ if (theClassifier->Perform(gp_Pnt2d(U1, v)) == TopAbs_IN)
{
// Record 3d point
- nbLocat++;
- Location3d.Bind(nbLocat, P1);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P1);
// Record 2d point
p2d.SetCoord((U1-umin)/deltaX, (v-vmin)/deltaY);
- newV.Initialize(p2d.XY(), nbLocat, MeshDS_Free);
- InternalV.Append(newV);
+ newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ theInternalV.Append(newV);
}
}
j++;
- }
+ }
}
}
}
else {
- const Standard_Real theangle = 0.35;
+ const Standard_Real anAngle = 0.35;
Standard_Integer i, j, nbpointsU = 10, nbpointsV = 10;
Adaptor3d_IsoCurve tabu[10], tabv[10];
for (iu = 1; iu <= nbpointsU; iu++) {
u = umin + iu*du;
- tabu[iu-1].Load(caro);
+ tabu[iu-1].Load(theCaro);
tabu[iu-1].Load(GeomAbs_IsoU, u);
}
for (iv = 1; iv <= nbpointsV; iv++) {
v = vmin + iv*dv;
- tabv[iv-1].Load(caro);
+ tabv[iv-1].Load(theCaro);
tabv[iv-1].Load(GeomAbs_IsoV, v);
}
for (i = 0; i <= nbpointsU-1; i++) {
f = Max(vmin, tabu[i].FirstParameter());
l = Min(vmax, tabu[i].LastParameter());
- GCPnts_TangentialDeflection theDeflection(tabu[i], f, l, theangle, 0.7*defface, 2);
+ GCPnts_TangentialDeflection theDeflection(tabu[i], f, l, anAngle, 0.7*theDefFace, 2);
tabGU[i] = theDeflection;
if (tabGU[i].NbPoints() > MaxV) {
- MaxV = tabGU[i].NbPoints();
- imax = i;
+ MaxV = tabGU[i].NbPoints();
+ imax = i;
}
}
for (i = 0; i <= nbpointsV-1; i++) {
f = Max(umin, tabv[i].FirstParameter());
l = Min(umax, tabv[i].LastParameter());
- GCPnts_TangentialDeflection thedeflection2(tabv[i], f, l, theangle, 0.7*defface, 2);
+ GCPnts_TangentialDeflection thedeflection2(tabv[i], f, l, anAngle, 0.7*theDefFace, 2);
tabGV[i] = thedeflection2;
if (tabGV[i].NbPoints() > MaxU) {
- MaxU = tabGV[i].NbPoints();
- imax = i;
+ MaxU = tabGV[i].NbPoints();
+ imax = i;
}
}
gp_Pnt P1;
Adaptor3d_IsoCurve IsoV;
- IsoV.Load(caro);
+ IsoV.Load(theCaro);
Standard_Integer Lu = ParamU.Length(), Lv = ParamV.Length();
v = ParamV.Value(i);
IsoV.Load(GeomAbs_IsoV, v);
for (j = 2; j < Lu; j++) {
- u = ParamU.Value(j);
- if (classifier->Perform(gp_Pnt2d(u, v)) == TopAbs_IN)
+ u = ParamU.Value(j);
+ if (theClassifier->Perform(gp_Pnt2d(u, v)) == TopAbs_IN)
{
// Record 3d point
- P1 = IsoV.Value(u);
- nbLocat++;
- Location3d.Bind(nbLocat, P1);
+ P1 = IsoV.Value(u);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, P1);
// Record 2d point
- p2d.SetCoord((u-umin)/deltaX, (v-vmin)/deltaY);
- newV.Initialize(p2d.XY(), nbLocat, MeshDS_Free);
- InternalV.Append(newV);
- }
+ p2d.SetCoord((u-umin)/deltaX, (v-vmin)/deltaY);
+ newV.Initialize(p2d.XY(), myNbLocat, MeshDS_Free);
+ theInternalV.Append(newV);
+ }
}
}
}
public:
BRepMesh_Couple() { myI1 = myI2 = 0; }
BRepMesh_Couple(const Standard_Integer I1,
- const Standard_Integer I2)
+ const Standard_Integer I2)
{ myI1 = I1; myI2 = I2; }
Standard_Integer myI1;
//function : Control
//purpose :
//=======================================================================
-Standard_Real BRepMesh_FastDiscretFace::Control (const Handle(BRepAdaptor_HSurface)& caro,
- const Standard_Real defface,
- BRepMesh_ListOfVertex& InternalV,
- TColStd_ListOfInteger& badTriangles,
- TColStd_ListOfInteger& nulTriangles,
- BRepMesh_Delaun& trigu,
- const Standard_Boolean isfirst)
+Standard_Real BRepMesh_FastDiscretFace::Control(const Handle(BRepAdaptor_HSurface)& theCaro,
+ const Standard_Real theDefFace,
+ BRepMesh_ListOfVertex& theInternalV,
+ TColStd_ListOfInteger& theBadTriangles,
+ TColStd_ListOfInteger& theNulTriangles,
+ BRepMesh_Delaun& theTrigu,
+ const Standard_Boolean theIsFirst)
{
//IMPORTANT: Constants used in calculations
const Standard_Real MinimalArea2d = 1.e-9;
const Standard_Real MinimalSqLength3d = 1.e-12;
- const Standard_Real aDef2 = defface*defface;
+ const Standard_Real aDef2 = theDefFace*theDefFace;
// Define the number of iterations
Standard_Integer myNbIterations = 11;
- const Standard_Integer nbPasses = (isfirst? 1 : myNbIterations);
+ const Standard_Integer nbPasses = (theIsFirst? 1 : myNbIterations);
// Initialize stop condition
Standard_Boolean allDegenerated = Standard_False;
Standard_Integer nbInserted = 1;
// Create map of links to skip already processed
- Standard_Integer nbtriangles;
-
- nbtriangles = structure->ElemOfDomain().Extent();
+ Standard_Integer nbtriangles = myStructure->ElemOfDomain().Extent();
if (nbtriangles <= 0) return -1.0;
BRepMesh_MapOfCouple theCouples(3*nbtriangles);
gp_Pnt pDef;
Standard_Real dv = 0, defl = 0, maxdef = -1;
Standard_Integer pass = 1, nf = 0, nl = 0;
- Standard_Integer v1, v2, v3, e1, e2, e3;
- Standard_Boolean o1, o2, o3;
- Standard_Boolean m1, m2, m3;
BRepMesh_Vertex InsVertex;
Standard_Boolean caninsert;
- Standard_Real sqdefface = defface * defface;
- Standard_Real ddu = caro->UResolution(defface);
- Standard_Real ddv = caro->VResolution(defface);
+ Standard_Real sqdefface = theDefFace * theDefFace;
+ Standard_Real ddu = theCaro->UResolution(theDefFace);
+ Standard_Real ddv = theCaro->VResolution(theDefFace);
- GeomAbs_SurfaceType thetype = caro->GetType();
+ GeomAbs_SurfaceType thetype = theCaro->GetType();
Handle(Geom_Surface) BSpl;
Standard_Boolean isSpline = Standard_False;
if (thetype == GeomAbs_BezierSurface || thetype == GeomAbs_BSplineSurface)
{
isSpline = Standard_True;
if (thetype == GeomAbs_BezierSurface)
- BSpl = caro->Bezier();
+ BSpl = theCaro->Bezier();
else
- BSpl = caro->BSpline();
+ BSpl = theCaro->BSpline();
}
-
+
NCollection_DataMap<Standard_Integer,gp_Dir> aNorMap;
NCollection_DataMap<Standard_Integer,Standard_Integer> aStatMap;
// Perform refinement passes
for (; pass <= nbPasses && nbInserted && !allDegenerated; pass++)
{
- InternalV.Clear();
- badTriangles.Clear();
+ theInternalV.Clear();
+ theBadTriangles.Clear();
// Reset stop condition
allDegenerated = Standard_True;
maxdef = -1.0;
// Do not insert nodes in last pass in non-SharedMode
- caninsert = (WithShare || pass < nbPasses);
+ caninsert = (myWithShare || pass < nbPasses);
// Read mesh size
- nbtriangles = structure->ElemOfDomain().Extent();
+ nbtriangles = myStructure->ElemOfDomain().Extent();
if (nbtriangles <= 0) break;
// Iterate on current triangles
MeshDS_MapOfInteger::Iterator triDom;
- const MeshDS_MapOfInteger& TriMap = structure->ElemOfDomain();
+ const MeshDS_MapOfInteger& TriMap = myStructure->ElemOfDomain();
triDom.Initialize(TriMap);
Standard_Integer aNbPnt = 0;
- Standard_Real umin = myattrib->GetUMin();
- Standard_Real vmin = myattrib->GetVMin();
- Standard_Real deltaX = myattrib->GetDeltaX();
- Standard_Real deltaY = myattrib->GetDeltaY();
+ Standard_Real umin = myAttrib->GetUMin();
+ Standard_Real vmin = myAttrib->GetVMin();
+ Standard_Real deltaX = myAttrib->GetDeltaX();
+ Standard_Real deltaY = myAttrib->GetDeltaY();
for (; triDom.More(); triDom.Next())
{
Standard_Integer TriId = triDom.Key();
const BRepMesh_Triangle& curTri=Triangle(TriId);
if (curTri.Movability()==MeshDS_Deleted) continue;
+
Standard_Boolean o1, o2, o3;
Standard_Integer v1 = 0, v2 = 0, v3 = 0, e1 = 0, e2 = 0, e3 = 0;
curTri.Edges(e1, e2, e3, o1, o2, o3);
Standard_Boolean m2 = (edg2.Movability() == MeshDS_Frontier);
Standard_Boolean m3 = (edg3.Movability() == MeshDS_Frontier);
if (o1) {
- v1=edg1.FirstNode();
- v2=edg1.LastNode();
+ v1=edg1.FirstNode();
+ v2=edg1.LastNode();
}
else {
- v1=edg1.LastNode();
- v2=edg1.FirstNode();
+ v1=edg1.LastNode();
+ v2=edg1.FirstNode();
}
if (o2)
- v3=edg2.LastNode();
+ v3=edg2.LastNode();
else
- v3=edg2.FirstNode();
+ v3=edg2.FirstNode();
const BRepMesh_Vertex& vert1=Vertex(v1);
const BRepMesh_Vertex& vert2=Vertex(v2);
const BRepMesh_Vertex& vert3=Vertex(v3);
- const gp_XYZ& p1=Location3d(vert1.Location3d()).Coord();
- const gp_XYZ& p2=Location3d(vert2.Location3d()).Coord();
- const gp_XYZ& p3=Location3d(vert3.Location3d()).Coord();
+ const gp_XYZ& p1=myLocation3d(vert1.Location3d()).Coord();
+ const gp_XYZ& p2=myLocation3d(vert2.Location3d()).Coord();
+ const gp_XYZ& p3=myLocation3d(vert3.Location3d()).Coord();
vecEd1 = p2 - p1;
vecEd2 = p3 - p2;
vecEd2.SquareModulus() < MinimalSqLength3d ||
vecEd3.SquareModulus() < MinimalSqLength3d)
{
- nulTriangles.Append(TriId);
+ theNulTriangles.Append(TriId);
continue;
}
// Check triangle area in 2d
if (Abs((xy2-xy1)^(xy3-xy1)) < MinimalArea2d)
{
- nulTriangles.Append(TriId);
+ theNulTriangles.Append(TriId);
continue;
}
dv = normal.Modulus();
if (dv < Precision::Confusion())
{
- nulTriangles.Append(TriId);
+ theNulTriangles.Append(TriId);
continue;
}
normal /= dv;
// Check deflection on triangle
mi2d = (xy1+xy2+xy3)/3.0;
- caro->D0(mi2d.X(), mi2d.Y(), pDef);
+ theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
defl = pDef.SquareDistance((p1+p2+p3)/3.);
if (defl > maxdef) maxdef = defl;
if (defl > sqdefface)
{
- if (isfirst) break;
+ if (theIsFirst) break;
if (caninsert)
{
// Record new vertex
aNbPnt++;
- nbLocat++;
- Location3d.Bind(nbLocat,pDef);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,nbLocat,MeshDS_Free);
- InternalV.Append(InsVertex);
+ InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ theInternalV.Append(InsVertex);
}
- badTriangles.Append(TriId);
+ theBadTriangles.Append(TriId);
}
if (!m2) // Not a boundary
{
// Check deflection on edge 1
mi2d = (xy2+xy3)*0.5;
- caro->D0(mi2d.X(), mi2d.Y(), pDef);
+ theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
defl = pDef.SquareDistance((p2+p3)/2.);
if (defl > maxdef) maxdef = defl;
if (defl > sqdefface)
{
- if (isfirst) break;
+ if (theIsFirst) break;
if (caninsert)
{
// Record new vertex
aNbPnt++;
- nbLocat++;
- Location3d.Bind(nbLocat,pDef);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,nbLocat,MeshDS_Free);
- InternalV.Append(InsVertex);
+ InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ theInternalV.Append(InsVertex);
}
- badTriangles.Append(TriId);
+ theBadTriangles.Append(TriId);
}
}
}
{
// Check deflection on edge 2
mi2d = (xy3+xy1)*0.5;
- caro->D0(mi2d.X(), mi2d.Y(), pDef);
+ theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
defl = pDef.SquareDistance((p1+p3)/2.);
if (defl > maxdef) maxdef = defl;
if (defl > sqdefface)
{
- if (isfirst) break;
+ if (theIsFirst) break;
if (caninsert)
{
// Record new vertex
aNbPnt++;
- nbLocat++;
- Location3d.Bind(nbLocat,pDef);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,nbLocat,MeshDS_Free);
- InternalV.Append(InsVertex);
+ InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ theInternalV.Append(InsVertex);
}
- badTriangles.Append(TriId);
+ theBadTriangles.Append(TriId);
}
}
}
{
// Check deflection on edge 3
mi2d = (xy1+xy2)*0.5;
- caro->D0(mi2d.X(), mi2d.Y(), pDef);
+ theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
defl = pDef.SquareDistance((p1+p2)/2.);
if (defl > maxdef) maxdef = defl;
if (defl > sqdefface)
{
- if (isfirst) break;
+ if (theIsFirst) break;
if (caninsert)
{
// Record new vertex
aNbPnt++;
- nbLocat++;
- Location3d.Bind(nbLocat,pDef);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,nbLocat,MeshDS_Free);
- InternalV.Append(InsVertex);
+ InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ theInternalV.Append(InsVertex);
}
- badTriangles.Append(TriId);
+ theBadTriangles.Append(TriId);
}
}
}
//check normal
- if(isSpline && !BSpl.IsNull() && (badTriangles.IsEmpty() || badTriangles.Last() != TriId))
+ if(isSpline && !BSpl.IsNull() && (theBadTriangles.IsEmpty() || theBadTriangles.Last() != TriId))
{
- gp_Dir N1(0,0,1), N2(0,0,1), N3(0,0,1);
+ gp_Dir N1(0,0,1), N2(0,0,1), N3(0,0,1);
Standard_Integer aSt1, aSt2, aSt3;
if(aNorMap.IsBound(v1)) {
aSt1 = aStatMap.Find(v1);
aStatMap.Bind(v3,aSt3);
aNorMap.Bind(v3,N3.XYZ());
}
-
- Standard_Real anAngle1 = N2.Angle(N1);
+
+ Standard_Real anAngle1 = N2.Angle(N1);
Standard_Real anAngle2 = N3.Angle(N2);
Standard_Real anAngle3 = N1.Angle(N3);
- if(aSt1 < 1 && aSt2 < 1 && aSt3 < 1 &&
- (anAngle1 > angle || anAngle2 > angle || anAngle3 > angle)) {
- if (isfirst) {
+ if(aSt1 < 1 && aSt2 < 1 && aSt3 < 1 &&
+ (anAngle1 > myAngle || anAngle2 > myAngle || anAngle3 > myAngle)) {
+
+ if (theIsFirst) {
maxdef = -1;
break;
}
- // Record new vertex
+ // Record new vertex
aNbPnt++;
- nbLocat++;
+ myNbLocat++;
mi2d = (xy1+xy2+xy3)/3.;
- caro->D0(mi2d.X(), mi2d.Y(), pDef);
- Location3d.Bind(nbLocat,pDef);
+ theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
+ myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,nbLocat,MeshDS_Free);
- InternalV.Append(InsVertex);
- badTriangles.Append(TriId);
- }
+ InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ theInternalV.Append(InsVertex);
+ theBadTriangles.Append(TriId);
+ }
//In case if triangle is considerd as OK, we have to check three intermediate
//points to be sure that we free from wave effect. If it is OK triangle passed if not split in middle point
- if(badTriangles.IsEmpty() || badTriangles.Last() != TriId)
+ if(theBadTriangles.IsEmpty() || theBadTriangles.Last() != TriId)
{
+
Bnd_Box2d aB2d;
aB2d.Add(gp_Pnt2d(xy1)); aB2d.Add(gp_Pnt2d(xy2)); aB2d.Add(gp_Pnt2d(xy3));
if(aXMax1 - aXMin1 < ddu && aYMax1 - aYMin1 < ddv)
continue;
-
+
mi2d = (xy1+xy2+xy3)/3.;
gp_Pnt2d aP[3] = {mi2d+(xy1-mi2d)*2/3., mi2d+(xy2-mi2d)*2/3, mi2d+(xy3-mi2d)*2/3.};
gp_Dir midDir(0,0,1);
anAngle[i] = dir.Angle(midDir);
}
- caro->D0(mi2d.X(), mi2d.Y(), pDef);
-
+ theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
aB2d.Add(gp_Pnt2d(xy1)); aB2d.Add(gp_Pnt2d(xy2)); aB2d.Add(gp_Pnt2d(xy3));
-
if(aSt[0] < 1 && aSt[1] < 1 && aSt[2] < 1 && aSt[3] < 1 &&
- (anAngle[0] > angle || anAngle[1] > angle || anAngle[2] > angle) &&
+ (anAngle[0] > myAngle || anAngle[1] > myAngle || anAngle[2] > myAngle) &&
(aXMax1 - aXMin1 > ddu || aYMax1 - aYMin1 > ddv))
{
- if (isfirst) {
+ if (theIsFirst) {
maxdef = -1;
break;
}
aNbPnt++;
- nbLocat++;
- caro->D0(mi2d.X(), mi2d.Y(), pDef);
- Location3d.Bind(nbLocat,pDef);
+ myNbLocat++;
+ theCaro->D0(mi2d.X(), mi2d.Y(), pDef);
+ myLocation3d.Bind(myNbLocat,pDef);
mi2d.SetCoord((mi2d.X()-umin)/deltaX,(mi2d.Y()-vmin)/deltaY);
- InsVertex.Initialize(mi2d,nbLocat,MeshDS_Free);
- InternalV.Append(InsVertex);
- badTriangles.Append(TriId);
+ InsVertex.Initialize(mi2d,myNbLocat,MeshDS_Free);
+ theInternalV.Append(InsVertex);
+ theBadTriangles.Append(TriId);
}
}
}
}
- if (!isfirst && InternalV.Extent() > 0)
+ if (!theIsFirst && theInternalV.Extent() > 0)
{
- BRepMesh_Array1OfVertexOfDelaun verttab(1, InternalV.Extent());
- BRepMesh_ListIteratorOfListOfVertex itVer(InternalV);
+ BRepMesh_Array1OfVertexOfDelaun verttab(1, theInternalV.Extent());
+ BRepMesh_ListIteratorOfListOfVertex itVer(theInternalV);
Standard_Integer ipn = 1;
for (; itVer.More(); itVer.Next())
verttab(ipn++) = itVer.Value();
- trigu.AddVertices(verttab);
+ theTrigu.AddVertices(verttab);
nbInserted++;
}
}
-
- if (maxdef < 0)
+ if (maxdef < 0)
return maxdef;
return Sqrt(maxdef);
}
//function : AddInShape
//purpose :
//=======================================================================
-void BRepMesh_FastDiscretFace::AddInShape(const TopoDS_Face& face,
- const Standard_Real defface)
+void BRepMesh_FastDiscretFace::AddInShape(const TopoDS_Face& theFace,
+ const Standard_Real theDefFace)
{
// gp_Pnt Pt;
BRep_Builder B;
- TopLoc_Location loc = face.Location();
- Handle(Poly_Triangulation) TOld = BRep_Tool::Triangulation(face, loc);
+ TopLoc_Location loc = theFace.Location();
+ Handle(Poly_Triangulation) TOld = BRep_Tool::Triangulation(theFace, loc);
Handle(Poly_Triangulation) TNull;
Handle(Poly_PolygonOnTriangulation) NullPoly;
- B.UpdateFace(face,TNull);
+ B.UpdateFace(theFace,TNull);
try{
MeshDS_MapOfInteger::Iterator it;
Standard_Integer v1, v2, v3, iv1, iv2, iv3;
Standard_Integer i, index;
Standard_Boolean o1, o2, o3;
- TopAbs_Orientation orFace = face.Orientation();
+ TopAbs_Orientation orFace = theFace.Orientation();
- const MeshDS_MapOfInteger& TriMap = structure->ElemOfDomain();
+ const MeshDS_MapOfInteger& TriMap = myStructure->ElemOfDomain();
it.Initialize(TriMap);
nTri = TriMap.Extent();
i = 1;
for (; it.More(); it.Next()) {
- structure->GetElement(it.Key()).Edges(e1, e2, e3, o1, o2, o3);
+ myStructure->GetElement(it.Key()).Edges(e1, e2, e3, o1, o2, o3);
- const BRepMesh_Edge& ve1=structure->GetLink(e1);
- const BRepMesh_Edge& ve2=structure->GetLink(e2);
- const BRepMesh_Edge& ve3=structure->GetLink(e3);
+ const BRepMesh_Edge& ve1=myStructure->GetLink(e1);
+ const BRepMesh_Edge& ve2=myStructure->GetLink(e2);
+ const BRepMesh_Edge& ve3=myStructure->GetLink(e3);
if (o1) {
- v1=ve1.FirstNode();
+ v1=ve1.FirstNode();
}
else {
- v1=ve1.LastNode();
+ v1=ve1.LastNode();
}
if (o2)
{
v2=ve2.FirstNode();
- v3=ve2.LastNode();
+ v3=ve2.LastNode();
}
else
{
- v3=ve2.FirstNode();
- v2=ve2.LastNode();
+ v3=ve2.FirstNode();
+ v2=ve2.LastNode();
}
- iv1 = myvemap.FindIndex(v1);
- if (iv1 == 0) iv1 = myvemap.Add(v1);
- iv2 = myvemap.FindIndex(v2);
- if (iv2 == 0) iv2 = myvemap.Add(v2);
- iv3 = myvemap.FindIndex(v3);
- if (iv3 == 0) iv3 = myvemap.Add(v3);
+ iv1 = myVemap.FindIndex(v1);
+ if (iv1 == 0) iv1 = myVemap.Add(v1);
+ iv2 = myVemap.FindIndex(v2);
+ if (iv2 == 0) iv2 = myVemap.Add(v2);
+ iv3 = myVemap.FindIndex(v3);
+ if (iv3 == 0) iv3 = myVemap.Add(v3);
if (orFace == TopAbs_REVERSED) Tri(i++).Set(iv1, iv3, iv2);
else Tri(i++).Set(iv1, iv2, iv3);
}
- Standard_Integer nbVertices = myvemap.Extent();
+ Standard_Integer nbVertices = myVemap.Extent();
Handle(Poly_Triangulation) T = new Poly_Triangulation(nbVertices, nTri, Standard_True);
Poly_Array1OfTriangle& Trian = T->ChangeTriangles();
Trian = Tri;
TColgp_Array1OfPnt2d& Nodes2d = T->ChangeUVNodes();
for (i = 1; i <= nbVertices; i++) {
- index = myvemap.FindKey(i);
+ index = myVemap.FindKey(i);
Nodes(i) = Pnt(index);
Nodes2d(i).SetXY(Vertex(index).Coord());
}
- T->Deflection(defface);
+ T->Deflection(theDefFace);
// stockage de la triangulation dans la BRep.
BRep_Builder B1;
- //TopLoc_Location loc = face.Location();
+ //TopLoc_Location loc = theFace.Location();
if (!loc.IsIdentity()) {
gp_Trsf tr = loc.Transformation();
tr.Invert();
for (i = Nodes.Lower(); i <= Nodes.Upper(); i++)
- Nodes(i).Transform(tr);
+ Nodes(i).Transform(tr);
}
- B1.UpdateFace(face, T);
+ B1.UpdateFace(theFace, T);
// mise en place des polygones sur triangulation dans la face:
- BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon It(internaledges);
+ BRepMesh_DataMapIteratorOfDataMapOfShapePairOfPolygon It(myInternaledges);
for (; It.More(); It.Next()) {
const BRepMesh_PairOfPolygon& pair = It.Value();
const Handle(Poly_PolygonOnTriangulation)& NOD1 = pair.First();
const Handle(Poly_PolygonOnTriangulation)& NOD2 = pair.Last();
if ( NOD1 == NOD2 ) {
- B.UpdateEdge(TopoDS::Edge(It.Key()), NullPoly, TOld,loc);
- B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, T, loc);
+ B.UpdateEdge(TopoDS::Edge(It.Key()), NullPoly, TOld,loc);
+ B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, T, loc);
}
else {
- B.UpdateEdge(TopoDS::Edge(It.Key()), NullPoly, TOld,loc);
- B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, NOD2, T, loc);
+ B.UpdateEdge(TopoDS::Edge(It.Key()), NullPoly, TOld,loc);
+ B.UpdateEdge(TopoDS::Edge(It.Key()), NOD1, NOD2, T, loc);
}
}
}
}
catch(Standard_Failure)
{
- // MESH_FAILURE(face);
+ // MESH_FAILURE(theFace);
}
}
//purpose :
//=======================================================================
-const BRepMesh_Triangle& BRepMesh_FastDiscretFace::Triangle
- (const Standard_Integer Index) const
+const BRepMesh_Triangle& BRepMesh_FastDiscretFace::Triangle(const Standard_Integer Index) const
{
- return structure->GetElement(Index);
+ return myStructure->GetElement(Index);
}
//=======================================================================
/*Standard_Integer BRepMesh_FastDiscretFace::NbEdges() const
{
- return structure->NbLinks();
+ return myStructure->NbLinks();
}*/
//=======================================================================
const BRepMesh_Edge& BRepMesh_FastDiscretFace::Edge(const Standard_Integer Index) const
{
- return structure->GetLink(Index);
+ return myStructure->GetLink(Index);
}
//purpose :
//=======================================================================
-const BRepMesh_Vertex& BRepMesh_FastDiscretFace::Vertex
- (const Standard_Integer Index) const
+const BRepMesh_Vertex& BRepMesh_FastDiscretFace::Vertex(const Standard_Integer Index) const
{
- return structure->GetNode(Index);
+ return myStructure->GetNode(Index);
}
//=======================================================================
const gp_Pnt& BRepMesh_FastDiscretFace::Pnt(const Standard_Integer Index) const
{
- return Location3d(structure->GetNode(Index).Location3d());
+ return myLocation3d(myStructure->GetNode(Index).Location3d());
}
//=======================================================================
//purpose :
//=======================================================================
-gp_XY BRepMesh_FastDiscretFace::FindUV(const TopoDS_Vertex& V,
- const gp_Pnt2d& XY,
- const Standard_Integer ip,
- const Handle(BRepAdaptor_HSurface)& S,
- const Standard_Real mindist)
+gp_XY BRepMesh_FastDiscretFace::FindUV(const TopoDS_Vertex& theV,
+ const gp_Pnt2d& theXY,
+ const Standard_Integer theIp,
+ const Handle(BRepAdaptor_HSurface)& theSFace,
+ const Standard_Real theMinDist,
+ BRepMesh_DataMapOfIntegerListOfXY& theLocation2dMap)
{
- gp_XY theUV;
- if (mylocation2d.IsBound(ip))
+ gp_XY anUV;
+ if (theLocation2dMap.IsBound(theIp))
{
- BRepMesh_ListOfXY& L = mylocation2d.ChangeFind(ip);
- theUV = L.First();
+ BRepMesh_ListOfXY& L = theLocation2dMap.ChangeFind(theIp);
+ anUV = L.First();
if (L.Extent() != 1)
{
BRepMesh_ListIteratorOfListOfXY it(L);
it.Next();
- Standard_Real dd, dmin = XY.Distance(gp_Pnt2d(theUV));
+ Standard_Real dd, dmin = theXY.Distance(gp_Pnt2d(anUV));
for (; it.More(); it.Next())
{
- dd = XY.Distance(gp_Pnt2d(it.Value()));
- if (dd < dmin)
+ dd = theXY.Distance(gp_Pnt2d(it.Value()));
+ if (dd < dmin)
{
- theUV = it.Value();
- dmin = dd;
- }
+ anUV = it.Value();
+ dmin = dd;
+ }
}
}
- const Standard_Real tol = Min(2. * BRep_Tool::Tolerance(V), mindist);
+ const Standard_Real tol = Min(2. * BRep_Tool::Tolerance(theV), theMinDist);
- const Standard_Real Utol2d = .5 * (S->LastUParameter() - S->FirstUParameter());
- const Standard_Real Vtol2d = .5 * (S->LastVParameter() - S->FirstVParameter());
+ const Standard_Real Utol2d = .5 * (theSFace->LastUParameter() - theSFace->FirstUParameter());
+ const Standard_Real Vtol2d = .5 * (theSFace->LastVParameter() - theSFace->FirstVParameter());
- const gp_Pnt p1 = S->Value(theUV.X(), theUV.Y());
- const gp_Pnt p2 = S->Value(XY.X(), XY.Y());
+ const gp_Pnt p1 = theSFace->Value(anUV.X(), anUV.Y());
+ const gp_Pnt p2 = theSFace->Value(theXY.X(), theXY.Y());
- if (Abs(theUV.X() - XY.X()) > Utol2d ||
- Abs(theUV.Y() - XY.Y()) > Vtol2d ||
- !p1.IsEqual(p2, tol))
+ if (Abs(anUV.X() - theXY.X()) > Utol2d ||
+ Abs(anUV.Y() - theXY.Y()) > Vtol2d ||
+ !p1.IsEqual(p2, tol))
{
- theUV = XY.Coord();
- L.Append(theUV);
+ anUV = theXY.Coord();
+ L.Append(anUV);
}
}
else
{
- theUV = XY.Coord();
+ anUV = theXY.Coord();
BRepMesh_ListOfXY L;
- L.Append(theUV);
- mylocation2d.Bind(ip, L);
+ L.Append(anUV);
+ theLocation2dMap.Bind(theIp, L);
}
- return theUV;
+ return anUV;
}
static Standard_Boolean GetVertexParameters(const TopoDS_Vertex& theVert,
- const TopoDS_Face& theFace,
- gp_Pnt2d& thePoint)
+ const TopoDS_Face& theFace,
+ gp_Pnt2d& thePoint)
{
TopLoc_Location L;
const Handle(Geom_Surface)& S = BRep_Tool::Surface(theFace,L);
while (itpr.More()) {
if (itpr.Value()->IsPointOnSurface(S,L)) {
thePoint.SetCoord(itpr.Value()->Parameter(),
- itpr.Value()->Parameter2());
+ itpr.Value()->Parameter2());
return Standard_True;
}
itpr.Next();
}
return Standard_False;
}
+
//=======================================================================
//function : Add
-//purpose : method intended to addition internav vertices in triangulation.
+//purpose : method intended to addition internal myVertices in triangulation.
//=======================================================================
-
void BRepMesh_FastDiscretFace::Add(const TopoDS_Vertex& theVert,
- const TopoDS_Face& theFace,
- const Handle(BRepAdaptor_HSurface)& thegFace)
-
+ const TopoDS_Face& theFace,
+ const Handle(BRepAdaptor_HSurface)& thegFace)
{
const TopAbs_Orientation anOrient = theVert.Orientation();
gp_Pnt2d uvXY;
if( anOrient != TopAbs_INTERNAL || !GetVertexParameters(theVert,theFace,uvXY))
return;
Standard_Integer indVert =0;
- if (vertices.IsBound(theVert))
- indVert = vertices.Find(theVert);
+ if (myVertices.IsBound(theVert))
+ indVert = myVertices.Find(theVert);
else
{
- nbLocat++;
- Location3d.Bind(nbLocat, BRep_Tool::Pnt(theVert));
- indVert = nbLocat;
- vertices.Bind(theVert, indVert);
+ myNbLocat++;
+ myLocation3d.Bind(myNbLocat, BRep_Tool::Pnt(theVert));
+ indVert = myNbLocat;
+ myVertices.Bind(theVert, indVert);
}
Standard_Real mindist = BRep_Tool::Tolerance(theVert);
// gp_Pnt2d uvXY = BRep_Tool::Parameters(theVert,theFace);
- gp_XY anUV = FindUV(theVert, uvXY, indVert, thegFace, mindist);
+ gp_XY anUV = FindUV(theVert, uvXY, indVert, thegFace, mindist, myLocation2d);
BRepMesh_Vertex vf(anUV, indVert, MeshDS_Fixed);
- Standard_Integer ivff = structure->AddNode(vf);
- Standard_Integer isvf = myvemap.FindIndex(ivff);
- if (isvf == 0) isvf = myvemap.Add(ivff);
+ Standard_Integer ivff = myStructure->AddNode(vf);
+ Standard_Integer isvf = myVemap.FindIndex(ivff);
+ if (isvf == 0) isvf = myVemap.Add(ivff);
}