mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0022783: Improvement of BRepOffsetAPI_MakeFilling: keep old and new boundary edges with all pcurves
This commit is contained in:
parent
c2b143174b
commit
01697018a3
@ -50,7 +50,9 @@ uses
|
||||
SequenceOfEdgeFaceAndOrder from BRepFill,
|
||||
SequenceOfFaceAndOrder from BRepFill,
|
||||
SequenceOfPointConstraint from GeomPlate,
|
||||
MapOfShape from TopTools,
|
||||
SequenceOfShape from TopTools,
|
||||
ListOfShape from TopTools,
|
||||
DataMapOfShapeListOfShape from TopTools,
|
||||
SequenceOfPnt from TColgp
|
||||
|
||||
raises
|
||||
@ -176,13 +178,13 @@ is
|
||||
---Purpose: Adds constraints to builder
|
||||
is private;
|
||||
|
||||
BuildWires( me; EdgeMap : in out MapOfShape from TopTools;
|
||||
WireList : out MapOfShape from TopTools )
|
||||
BuildWires( me : in out; EdgeList : in out ListOfShape from TopTools;
|
||||
WireList : out ListOfShape from TopTools )
|
||||
---Purpose: Builds wires of maximum length
|
||||
is private;
|
||||
|
||||
FindExtremitiesOfHoles( me; WireMap : in out MapOfShape from TopTools;
|
||||
PntSeq : out SequenceOfPnt from TColgp )
|
||||
FindExtremitiesOfHoles( me; WireList : ListOfShape from TopTools;
|
||||
VerSeq : out SequenceOfShape from TopTools )
|
||||
---Purpose: Finds extremities of future edges to fix the holes between wires.
|
||||
-- Can properly operate only with convex contour
|
||||
is private;
|
||||
@ -195,6 +197,12 @@ is
|
||||
Face(me) returns Face from TopoDS;
|
||||
-- returns the resulting face
|
||||
|
||||
Generated (me: in out; S : Shape from TopoDS)
|
||||
---Purpose: Returns the list of shapes generated from the
|
||||
-- shape <S>.
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
returns ListOfShape from TopTools;
|
||||
|
||||
G0Error(me) returns Real from Standard;
|
||||
-- returns the max distance between the result and the constraints
|
||||
@ -223,6 +231,9 @@ fields
|
||||
myFreeConstraints : SequenceOfFaceAndOrder from BRepFill;
|
||||
myPoints : SequenceOfPointConstraint from GeomPlate;
|
||||
|
||||
myOldNewMap : DataMapOfShapeListOfShape from TopTools;
|
||||
myGenerated : ListOfShape from TopTools;
|
||||
|
||||
myFace : Face from TopoDS;
|
||||
|
||||
myInitFace : Face from TopoDS;
|
||||
|
@ -43,9 +43,10 @@
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <TColgp_SequenceOfPnt.hxx>
|
||||
#include <TopTools_MapIteratorOfMapOfShape.hxx>
|
||||
#include <TopTools_ListIteratorOfListOfShape.hxx>
|
||||
#include <BRepTools_WireExplorer.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColGeom2d_HArray1OfCurve.hxx>
|
||||
|
||||
#include <Geom2d_BezierCurve.hxx>
|
||||
#include <Geom2d_TrimmedCurve.hxx>
|
||||
@ -76,6 +77,39 @@ static gp_Vec MakeFinVec( const TopoDS_Wire aWire, const TopoDS_Vertex aVertex )
|
||||
return gp_Vec( BRep_Tool::Pnt( Origin ), BRep_Tool::Pnt( aVertex ) );
|
||||
}
|
||||
|
||||
static TopoDS_Wire WireFromList(TopTools_ListOfShape& Edges)
|
||||
{
|
||||
BRepLib_MakeWire MW;
|
||||
TopoDS_Edge anEdge = TopoDS::Edge(Edges.First());
|
||||
MW.Add(anEdge);
|
||||
Edges.RemoveFirst();
|
||||
|
||||
while (!Edges.IsEmpty())
|
||||
{
|
||||
TopoDS_Wire CurWire = MW.Wire();
|
||||
TopoDS_Vertex V1, V2;
|
||||
TopExp::Vertices(CurWire, V1, V2);
|
||||
TopTools_ListIteratorOfListOfShape itl(Edges);
|
||||
for (; itl.More(); itl.Next())
|
||||
{
|
||||
anEdge = TopoDS::Edge(itl.Value());
|
||||
TopoDS_Vertex V3, V4;
|
||||
TopExp::Vertices(anEdge, V3, V4);
|
||||
if (V1.IsSame(V3) || V1.IsSame(V4) ||
|
||||
V2.IsSame(V3) || V2.IsSame(V4))
|
||||
break;
|
||||
}
|
||||
MW.Add(anEdge);
|
||||
Edges.Remove(itl);
|
||||
}
|
||||
|
||||
return (MW.Wire());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//======================================================================
|
||||
BRepFill_Filling::BRepFill_Filling( const Standard_Integer Degree,
|
||||
const Standard_Integer NbPtsOnCur,
|
||||
const Standard_Integer NbIter,
|
||||
@ -105,6 +139,10 @@ BRepFill_Filling::BRepFill_Filling( const Standard_Integer Degree,
|
||||
myIsDone = Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetConstrParam
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepFill_Filling::SetConstrParam( const Standard_Real Tol2d,
|
||||
const Standard_Real Tol3d,
|
||||
const Standard_Real TolAng,
|
||||
@ -116,6 +154,10 @@ void BRepFill_Filling::SetConstrParam( const Standard_Real Tol2d,
|
||||
myTolCurv = TolCurv;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetResolParam
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepFill_Filling::SetResolParam( const Standard_Integer Degree,
|
||||
const Standard_Integer NbPtsOnCur,
|
||||
const Standard_Integer NbIter,
|
||||
@ -127,6 +169,10 @@ void BRepFill_Filling::SetResolParam( const Standard_Integer Degree,
|
||||
myAnisotropie = Anisotropie;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetApproxParam
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepFill_Filling::SetApproxParam( const Standard_Integer MaxDeg,
|
||||
const Standard_Integer MaxSegments )
|
||||
{
|
||||
@ -134,12 +180,20 @@ void BRepFill_Filling::SetApproxParam( const Standard_Integer MaxDeg,
|
||||
myMaxSegments = MaxSegments;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadInitSurface
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepFill_Filling::LoadInitSurface( const TopoDS_Face& aFace )
|
||||
{
|
||||
myInitFace = aFace;
|
||||
myIsInitFaceGiven = Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds an edge as a constraint
|
||||
//======================================================================
|
||||
Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
|
||||
const GeomAbs_Shape Order,
|
||||
const Standard_Boolean IsBound )
|
||||
@ -149,6 +203,8 @@ Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
|
||||
if (IsBound)
|
||||
{
|
||||
myBoundary.Append( EdgeFaceAndOrder );
|
||||
TopTools_ListOfShape EmptyList;
|
||||
myOldNewMap.Bind(anEdge, EmptyList);
|
||||
return myBoundary.Length();
|
||||
}
|
||||
else
|
||||
@ -158,6 +214,10 @@ Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds an edge with supporting face as a constraint
|
||||
//======================================================================
|
||||
Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
|
||||
const TopoDS_Face& Support,
|
||||
const GeomAbs_Shape Order,
|
||||
@ -167,6 +227,8 @@ Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
|
||||
if (IsBound)
|
||||
{
|
||||
myBoundary.Append( EdgeFaceAndOrder );
|
||||
TopTools_ListOfShape EmptyList;
|
||||
myOldNewMap.Bind(anEdge, EmptyList);
|
||||
return myBoundary.Length();
|
||||
}
|
||||
else
|
||||
@ -176,6 +238,10 @@ Standard_Integer BRepFill_Filling::Add( const TopoDS_Edge& anEdge,
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds a "free constraint": face without edge
|
||||
//======================================================================
|
||||
Standard_Integer BRepFill_Filling::Add( const TopoDS_Face& Support,
|
||||
const GeomAbs_Shape Order )
|
||||
{
|
||||
@ -184,6 +250,10 @@ Standard_Integer BRepFill_Filling::Add( const TopoDS_Face& Support,
|
||||
return (myBoundary.Length() + myFreeConstraints.Length());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds a point constraint
|
||||
//======================================================================
|
||||
Standard_Integer BRepFill_Filling::Add( const gp_Pnt& Point )
|
||||
{
|
||||
Handle( GeomPlate_PointConstraint ) aPC = new GeomPlate_PointConstraint( Point, GeomAbs_C0, myTol3d );
|
||||
@ -191,6 +261,10 @@ Standard_Integer BRepFill_Filling::Add( const gp_Pnt& Point )
|
||||
return (myBoundary.Length() + myFreeConstraints.Length() + myConstraints.Length() + myPoints.Length());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds a point constraint on a face
|
||||
//======================================================================
|
||||
Standard_Integer BRepFill_Filling::Add( const Standard_Real U,
|
||||
const Standard_Real V,
|
||||
const TopoDS_Face& Support,
|
||||
@ -206,6 +280,10 @@ Standard_Integer BRepFill_Filling::Add( const Standard_Real U,
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddConstraints
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepFill_Filling::AddConstraints( const BRepFill_SequenceOfEdgeFaceAndOrder& SeqOfConstraints )
|
||||
{
|
||||
TopoDS_Edge CurEdge;
|
||||
@ -213,7 +291,8 @@ void BRepFill_Filling::AddConstraints( const BRepFill_SequenceOfEdgeFaceAndOrder
|
||||
GeomAbs_Shape CurOrder;
|
||||
|
||||
Handle(GeomPlate_CurveConstraint) Constr;
|
||||
for (Standard_Integer i = 1; i <= SeqOfConstraints.Length(); i++)
|
||||
Standard_Integer i;
|
||||
for (i = 1; i <= SeqOfConstraints.Length(); i++)
|
||||
{
|
||||
CurEdge = SeqOfConstraints(i).myEdge;
|
||||
CurFace = SeqOfConstraints(i).myFace;
|
||||
@ -233,11 +312,8 @@ void BRepFill_Filling::AddConstraints( const BRepFill_SequenceOfEdgeFaceAndOrder
|
||||
// On prend une representation Geometrique : au pif !
|
||||
Handle( Geom_Surface ) Surface;
|
||||
Handle( Geom2d_Curve ) C2d;
|
||||
// Class BRep_Tool without fields and without Constructor :
|
||||
// BRep_Tool BT;
|
||||
TopLoc_Location loc;
|
||||
Standard_Real f, l;
|
||||
// BT.CurveOnSurface( CurEdge, C2d, Surface, loc, f, l);
|
||||
BRep_Tool::CurveOnSurface( CurEdge, C2d, Surface, loc, f, l);
|
||||
if (Surface.IsNull()) {
|
||||
Standard_Failure::Raise( "Add" );
|
||||
@ -293,90 +369,105 @@ void BRepFill_Filling::AddConstraints( const BRepFill_SequenceOfEdgeFaceAndOrder
|
||||
}
|
||||
}
|
||||
|
||||
void BRepFill_Filling::BuildWires( TopTools_MapOfShape& EdgeMap, TopTools_MapOfShape& WireMap ) const
|
||||
//=======================================================================
|
||||
//function : BuildWires
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepFill_Filling::BuildWires( TopTools_ListOfShape& EdgeList, TopTools_ListOfShape& WireList )
|
||||
{
|
||||
TopoDS_Wire CurWire;
|
||||
TopoDS_Edge CurEdge;
|
||||
TopoDS_Vertex Wfirst, Wlast, Efirst, Elast;
|
||||
gp_Pnt Wp1, Wp2;
|
||||
TopTools_MapIteratorOfMapOfShape MapIt;
|
||||
TopTools_ListIteratorOfListOfShape Itl;
|
||||
Standard_Integer i, j;
|
||||
|
||||
while (! EdgeMap.IsEmpty())
|
||||
while (! EdgeList.IsEmpty())
|
||||
{
|
||||
BRepLib_MakeWire MW;
|
||||
MapIt.Initialize( EdgeMap );
|
||||
MW.Add( TopoDS::Edge( MapIt.Key() ) );
|
||||
EdgeMap.Remove( MapIt.Key() );
|
||||
CurWire = MW.Wire();
|
||||
TopExp::Vertices( CurWire, Wfirst, Wlast );
|
||||
Wp1 = BRep_Tool::Pnt( Wfirst );
|
||||
Wp2 = BRep_Tool::Pnt( Wlast );
|
||||
|
||||
Standard_Boolean IsFound = Standard_True;
|
||||
while (IsFound)
|
||||
{
|
||||
IsFound = Standard_False;
|
||||
for (MapIt.Initialize( EdgeMap ); MapIt.More(); MapIt.Next())
|
||||
{
|
||||
CurEdge = TopoDS::Edge( MapIt.Key() );
|
||||
TopExp::Vertices( CurEdge, Efirst, Elast );
|
||||
|
||||
Standard_Real dist = Wp1.Distance( BRep_Tool::Pnt( Efirst ) );
|
||||
if (dist < BRep_Tool::Tolerance( Wfirst ) || dist < BRep_Tool::Tolerance( Efirst ))
|
||||
{
|
||||
MW.Add( CurEdge );
|
||||
CurWire = MW.Wire();
|
||||
Wfirst = Elast;
|
||||
Wp1 = BRep_Tool::Pnt( Wfirst );
|
||||
EdgeMap.Remove( CurEdge );
|
||||
IsFound = Standard_True;
|
||||
break;
|
||||
}
|
||||
dist = Wp1.Distance( BRep_Tool::Pnt( Elast ) );
|
||||
if (dist < BRep_Tool::Tolerance( Wfirst ) || dist < BRep_Tool::Tolerance( Elast ))
|
||||
{
|
||||
MW.Add( CurEdge );
|
||||
CurWire = MW.Wire();
|
||||
Wfirst = Efirst;
|
||||
Wp1 = BRep_Tool::Pnt( Wfirst );
|
||||
EdgeMap.Remove( CurEdge );
|
||||
IsFound = Standard_True;
|
||||
break;
|
||||
}
|
||||
dist = Wp2.Distance( BRep_Tool::Pnt( Efirst ) );
|
||||
if (dist < BRep_Tool::Tolerance( Wlast ) || dist < BRep_Tool::Tolerance( Efirst ))
|
||||
{
|
||||
MW.Add( CurEdge );
|
||||
CurWire = MW.Wire();
|
||||
Wlast = Elast;
|
||||
Wp2 = BRep_Tool::Pnt( Wlast );
|
||||
EdgeMap.Remove( CurEdge );
|
||||
IsFound = Standard_True;
|
||||
break;
|
||||
}
|
||||
dist = Wp2.Distance( BRep_Tool::Pnt( Elast ) );
|
||||
if (dist < BRep_Tool::Tolerance( Wlast ) || dist < BRep_Tool::Tolerance( Elast ))
|
||||
{
|
||||
MW.Add( CurEdge );
|
||||
CurWire = MW.Wire();
|
||||
Wlast = Efirst;
|
||||
Wp2 = BRep_Tool::Pnt( Wlast );
|
||||
EdgeMap.Remove( CurEdge );
|
||||
IsFound = Standard_True;
|
||||
break;
|
||||
}
|
||||
} //for (MapIt.Init...
|
||||
} //while (IsFound)
|
||||
WireMap.Add( CurWire );
|
||||
} //while (! EdgeMap.IsEmpty())
|
||||
TopoDS_Edge FirstEdge = TopoDS::Edge(EdgeList.First());
|
||||
MW.Add(FirstEdge);
|
||||
EdgeList.RemoveFirst();
|
||||
TopoDS_Vertex V_wire[2], V_edge[2];
|
||||
|
||||
for (;;)
|
||||
{
|
||||
TopoDS_Wire CurWire = MW.Wire();
|
||||
TopExp::Vertices(CurWire, V_wire[0], V_wire[1]);
|
||||
Standard_Boolean found = Standard_False;
|
||||
for (Itl.Initialize( EdgeList ); Itl.More(); Itl.Next())
|
||||
{
|
||||
TopoDS_Edge CurEdge = TopoDS::Edge(Itl.Value());
|
||||
TopExp::Vertices(CurEdge, V_edge[0], V_edge[1]);
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
for (j = 0; j < 2; j++)
|
||||
if (V_wire[i].IsSame(V_edge[j]))
|
||||
{
|
||||
MW.Add(CurEdge);
|
||||
EdgeList.Remove(Itl);
|
||||
found = Standard_True;
|
||||
break;
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
if (!found) //try to find geometric coincidence
|
||||
{
|
||||
gp_Pnt P_wire[2];
|
||||
P_wire[0] = BRep_Tool::Pnt(V_wire[0]);
|
||||
P_wire[1] = BRep_Tool::Pnt(V_wire[1]);
|
||||
for (Itl.Initialize( EdgeList ); Itl.More(); Itl.Next())
|
||||
{
|
||||
TopoDS_Edge CurEdge = TopoDS::Edge(Itl.Value());
|
||||
TopExp::Vertices(CurEdge, V_edge[0], V_edge[1]);
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
for (j = 0; j < 2; j++)
|
||||
{
|
||||
Standard_Real aDist = P_wire[i].Distance(BRep_Tool::Pnt(V_edge[j]));
|
||||
if (aDist < BRep_Tool::Tolerance(V_wire[i]) &&
|
||||
aDist < BRep_Tool::Tolerance(V_edge[j]))
|
||||
{
|
||||
MW.Add(CurEdge);
|
||||
myOldNewMap(CurEdge).Append(MW.Edge());
|
||||
EdgeList.Remove(Itl);
|
||||
found = Standard_True;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) //end of current wire, begin next wire
|
||||
{
|
||||
WireList.Append( MW.Wire() );
|
||||
break;
|
||||
}
|
||||
} //end of for (;;)
|
||||
} //end of while (! EdgeList.IsEmpty())
|
||||
}
|
||||
|
||||
void BRepFill_Filling::FindExtremitiesOfHoles( TopTools_MapOfShape& WireMap, TColgp_SequenceOfPnt& PntSeq ) const
|
||||
//=======================================================================
|
||||
//function : FindExtremitiesOfHoles
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepFill_Filling::FindExtremitiesOfHoles(const TopTools_ListOfShape& WireList,
|
||||
TopTools_SequenceOfShape& VerSeq ) const
|
||||
{
|
||||
TopoDS_Wire theWire, CurWire;
|
||||
TopTools_MapIteratorOfMapOfShape MapIt( WireMap );
|
||||
theWire = TopoDS::Wire( MapIt.Key() );
|
||||
WireMap.Remove( MapIt.Key() );
|
||||
TopTools_SequenceOfShape WireSeq;
|
||||
TopTools_ListIteratorOfListOfShape Itl(WireList);
|
||||
for (; Itl.More(); Itl.Next())
|
||||
WireSeq.Append(Itl.Value());
|
||||
|
||||
TopoDS_Wire theWire;
|
||||
theWire = TopoDS::Wire(WireSeq(1));
|
||||
WireSeq.Remove(1);
|
||||
|
||||
if (theWire.Closed())
|
||||
return;
|
||||
@ -384,98 +475,83 @@ void BRepFill_Filling::FindExtremitiesOfHoles( TopTools_MapOfShape& WireMap, TCo
|
||||
TopoDS_Vertex Vfirst, Vlast;
|
||||
TopExp::Vertices( theWire, Vfirst, Vlast );
|
||||
gp_Vec FinVec = MakeFinVec( theWire, Vlast );
|
||||
gp_Pnt thePoint = BRep_Tool::Pnt( Vlast );
|
||||
PntSeq.Append( thePoint );
|
||||
TopoDS_Vertex theVertex = Vlast;
|
||||
VerSeq.Append( Vlast );
|
||||
|
||||
while (! WireMap.IsEmpty())
|
||||
while (! WireSeq.IsEmpty())
|
||||
{
|
||||
gp_Pnt MinPnt;
|
||||
TopoDS_Wire MinWire;
|
||||
#ifndef DEB
|
||||
TopoDS_Vertex MinVtx;
|
||||
Standard_Integer i, MinInd;
|
||||
Standard_Boolean IsLast = Standard_False;
|
||||
#else
|
||||
Standard_Boolean IsLast ;
|
||||
#endif
|
||||
Standard_Real MinAngle = M_PI;
|
||||
|
||||
for (MapIt.Initialize( WireMap ); MapIt.More(); MapIt.Next())
|
||||
for (i = 1; i <= WireSeq.Length(); i++)
|
||||
{
|
||||
CurWire = TopoDS::Wire( MapIt.Key() );
|
||||
const TopoDS_Wire& CurWire = TopoDS::Wire( WireSeq(i) );
|
||||
TopExp::Vertices( CurWire, Vfirst, Vlast );
|
||||
|
||||
Standard_Real angle = FinVec.Angle( gp_Vec( thePoint, BRep_Tool::Pnt( Vfirst ) ) );
|
||||
Standard_Real angle =
|
||||
FinVec.Angle(gp_Vec(BRep_Tool::Pnt(theVertex), BRep_Tool::Pnt(Vfirst)));
|
||||
if (angle < MinAngle)
|
||||
{
|
||||
MinAngle = angle;
|
||||
MinPnt = BRep_Tool::Pnt( Vfirst );
|
||||
MinWire = CurWire;
|
||||
MinVtx = Vfirst;
|
||||
MinInd = i;
|
||||
IsLast = Standard_True;
|
||||
}
|
||||
angle = FinVec.Angle( gp_Vec( thePoint, BRep_Tool::Pnt( Vlast ) ) );
|
||||
angle = FinVec.Angle(gp_Vec(BRep_Tool::Pnt(theVertex), BRep_Tool::Pnt(Vlast)));
|
||||
if (angle < MinAngle)
|
||||
{
|
||||
MinAngle = angle;
|
||||
MinPnt = BRep_Tool::Pnt( Vlast );
|
||||
MinWire = CurWire;
|
||||
MinVtx = Vlast;
|
||||
MinInd = i;
|
||||
IsLast = Standard_False;
|
||||
}
|
||||
}
|
||||
PntSeq.Append( MinPnt );
|
||||
VerSeq.Append( MinVtx );
|
||||
const TopoDS_Wire& MinWire = TopoDS::Wire(WireSeq(MinInd));
|
||||
TopExp::Vertices( MinWire, Vfirst, Vlast );
|
||||
if (IsLast)
|
||||
{
|
||||
FinVec = MakeFinVec( MinWire, Vlast );
|
||||
thePoint = BRep_Tool::Pnt( Vlast );
|
||||
theVertex = Vlast;
|
||||
}
|
||||
else
|
||||
{
|
||||
FinVec = MakeFinVec( MinWire, Vfirst );
|
||||
thePoint = BRep_Tool::Pnt( Vfirst );
|
||||
theVertex = Vfirst;
|
||||
}
|
||||
PntSeq.Append( thePoint );
|
||||
WireMap.Remove( MinWire );
|
||||
VerSeq.Append( theVertex );
|
||||
WireSeq.Remove(MinInd);
|
||||
}
|
||||
TopExp::Vertices( theWire, Vfirst, Vlast );
|
||||
PntSeq.Append( BRep_Tool::Pnt( Vfirst ) );
|
||||
VerSeq.Append( Vfirst );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose : builds the resulting face
|
||||
//======================================================================
|
||||
void BRepFill_Filling::Build()
|
||||
{
|
||||
GeomPlate_BuildPlateSurface thebuild( myDegree, myNbPtsOnCur, myNbIter,
|
||||
myTol2d, myTol3d, myTolAng, myTolCurv, myAnisotropie );
|
||||
myTol2d, myTol3d, myTolAng, myTolCurv, myAnisotropie );
|
||||
|
||||
myBuilder = thebuild;
|
||||
TopoDS_Edge CurEdge;
|
||||
TopoDS_Face CurFace;
|
||||
Standard_Integer i, j;
|
||||
|
||||
//Creating array of points: extremities of wires
|
||||
TColgp_SequenceOfPnt PntSeq;
|
||||
|
||||
//????????????
|
||||
//Setting tollerance
|
||||
for (i = 1; i <= myBoundary.Length(); i++)
|
||||
{
|
||||
TopoDS_Edge E (myBoundary(i).myEdge);
|
||||
TopoDS_Vertex V1 (TopExp::FirstVertex( E ));
|
||||
Handle(BRep_TVertex)& TV1 = *((Handle(BRep_TVertex)*) &V1.TShape());
|
||||
if (TV1->Tolerance() > 0.001)
|
||||
TV1->Tolerance( 0.001 );
|
||||
TV1->Modified( Standard_True );
|
||||
TopoDS_Vertex V2 (TopExp::LastVertex( E ));
|
||||
Handle(BRep_TVertex)& TV2 = *((Handle(BRep_TVertex)*) &V2.TShape());
|
||||
if (TV2->Tolerance() > 0.001)
|
||||
TV2->Tolerance( 0.001 );
|
||||
TV2->Modified( Standard_True );
|
||||
}
|
||||
//Creating array of vertices: extremities of wires
|
||||
TopTools_SequenceOfShape VerSeq;
|
||||
|
||||
//Building missing bounds
|
||||
TopTools_MapOfShape EdgeMap, WireMap;
|
||||
TopTools_ListOfShape EdgeList, WireList;
|
||||
for (i = 1; i <= myBoundary.Length(); i++)
|
||||
EdgeMap.Add( myBoundary(i).myEdge );
|
||||
EdgeList.Append( myBoundary(i).myEdge );
|
||||
|
||||
BuildWires( EdgeMap, WireMap );
|
||||
FindExtremitiesOfHoles( WireMap, PntSeq );
|
||||
BuildWires( EdgeList, WireList );
|
||||
FindExtremitiesOfHoles( WireList, VerSeq );
|
||||
|
||||
//Searching for surfaces for missing bounds
|
||||
for (j = 1; j <= myFreeConstraints.Length(); j++)
|
||||
@ -489,9 +565,13 @@ void BRepFill_Filling::Build()
|
||||
Handle( Geom_Surface ) CurSurface = BRep_Tool::Surface( HSurf->ChangeSurface().Face() );
|
||||
//BRepTopAdaptor_FClass2d Classifier( CurFace, Precision::Confusion() );
|
||||
|
||||
for (i = 1; i <= PntSeq.Length(); i += 2)
|
||||
for (i = 1; i <= VerSeq.Length(); i += 2)
|
||||
{
|
||||
Projector.Init( PntSeq.Value(i), CurSurface );
|
||||
const TopoDS_Vertex& FirstVtx = TopoDS::Vertex(VerSeq(i));
|
||||
const TopoDS_Vertex& LastVtx = TopoDS::Vertex(VerSeq(i+1));
|
||||
|
||||
gp_Pnt FirstPnt = BRep_Tool::Pnt(FirstVtx);
|
||||
Projector.Init( FirstPnt, CurSurface );
|
||||
if (Projector.LowerDistance() > Precision::Confusion())
|
||||
continue;
|
||||
Projector.LowerDistanceParameters( U1, V1 );
|
||||
@ -502,8 +582,9 @@ void BRepFill_Filling::Build()
|
||||
if (State == TopAbs_OUT || State == TopAbs_UNKNOWN)
|
||||
continue;
|
||||
*/
|
||||
|
||||
Projector.Init( PntSeq.Value(i+1), CurSurface );
|
||||
|
||||
gp_Pnt LastPnt = BRep_Tool::Pnt(LastVtx);
|
||||
Projector.Init( LastPnt, CurSurface );
|
||||
if (Projector.LowerDistance() > Precision::Confusion())
|
||||
continue;
|
||||
Projector.LowerDistanceParameters( U2, V2 );
|
||||
@ -520,11 +601,11 @@ void BRepFill_Filling::Build()
|
||||
Points(1) = gp_Pnt2d( U1, V1 );
|
||||
Points(2) = gp_Pnt2d( U2, V2 );
|
||||
Handle( Geom2d_BezierCurve ) Line2d = new Geom2d_BezierCurve( Points );
|
||||
TopoDS_Edge E = BRepLib_MakeEdge( Line2d, CurSurface, Line2d->FirstParameter(), Line2d->LastParameter() );
|
||||
TopoDS_Edge E = BRepLib_MakeEdge( Line2d, CurSurface, FirstVtx, LastVtx );
|
||||
Add( E, CurFace, myFreeConstraints(j).myOrder );
|
||||
PntSeq.Remove( i, i+1 );
|
||||
VerSeq.Remove( i, i+1 );
|
||||
break;
|
||||
} //for (i = 1; i <= PntSeq.Length(); i += 2)
|
||||
} //for (i = 1; i <= VerSeq.Length(); i += 2)
|
||||
} //for (j = 1; j <= myFreeConstraints.Length(); j++)
|
||||
|
||||
//Load initial surface to myBuilder if it is given
|
||||
@ -562,8 +643,6 @@ void BRepFill_Filling::Build()
|
||||
|
||||
TColgp_SequenceOfXY S2d;
|
||||
TColgp_SequenceOfXYZ S3d;
|
||||
S2d.Clear();
|
||||
S3d.Clear();
|
||||
myBuilder.Disc2dContour(4,S2d);
|
||||
myBuilder.Disc3dContour(4,0,S3d);
|
||||
seuil = Max( myTol3d, 10*myBuilder.G0Error() ); //????????
|
||||
@ -578,103 +657,129 @@ void BRepFill_Filling::Build()
|
||||
//Approx.Dump( cout );
|
||||
Surface = Approx.Surface();
|
||||
}
|
||||
|
||||
TopoDS_Wire W;
|
||||
//Preparing EdgeMap for method BuildWires
|
||||
EdgeMap.Clear();
|
||||
WireMap.Clear();
|
||||
PntSeq.Clear();
|
||||
BRep_Builder B;
|
||||
for (i = 1; i <= myBoundary.Length(); i++)
|
||||
{
|
||||
TopoDS_Edge E;
|
||||
Handle( GeomPlate_CurveConstraint ) CC = myBuilder.CurveConstraint(i);
|
||||
E = BRepLib_MakeEdge( CC->Curve2dOnSurf(),
|
||||
Surface,
|
||||
CC->FirstParameter(),
|
||||
CC->LastParameter());
|
||||
|
||||
B.UpdateVertex( TopExp::FirstVertex(E), dmax );
|
||||
B.UpdateVertex( TopExp::LastVertex(E), dmax );
|
||||
BRepLib::BuildCurve3d( E );
|
||||
EdgeMap.Add( E );
|
||||
}
|
||||
//Fixing the holes
|
||||
TopTools_MapOfShape EdgeMap2;
|
||||
TopTools_MapIteratorOfMapOfShape MapIt( EdgeMap );
|
||||
for (; MapIt.More(); MapIt.Next())
|
||||
EdgeMap2.Add( MapIt.Key() );
|
||||
BuildWires( EdgeMap2, WireMap );
|
||||
FindExtremitiesOfHoles( WireMap, PntSeq );
|
||||
|
||||
for (i = 1; i <= PntSeq.Length(); i += 2)
|
||||
{
|
||||
GeomAPI_ProjectPointOnSurf Projector;
|
||||
Quantity_Parameter U1, V1, U2, V2;
|
||||
|
||||
Projector.Init( PntSeq.Value(i), Surface );
|
||||
Projector.LowerDistanceParameters( U1, V1 );
|
||||
Projector.Init( PntSeq.Value(i+1), Surface );
|
||||
Projector.LowerDistanceParameters( U2, V2 );
|
||||
|
||||
//Making the edge on the resulting surface
|
||||
TColgp_Array1OfPnt2d Points( 1, 2 );
|
||||
Points(1) = gp_Pnt2d( U1, V1 );
|
||||
Points(2) = gp_Pnt2d( U2, V2 );
|
||||
Handle( Geom2d_BezierCurve ) Line2d = new Geom2d_BezierCurve( Points );
|
||||
TopoDS_Edge E = BRepLib_MakeEdge( Line2d, Surface, Line2d->FirstParameter(), Line2d->LastParameter() );
|
||||
|
||||
B.UpdateVertex( TopExp::FirstVertex(E), dmax );
|
||||
B.UpdateVertex( TopExp::LastVertex(E), dmax );
|
||||
BRepLib::BuildCurve3d( E );
|
||||
EdgeMap.Add( E );
|
||||
}
|
||||
WireMap.Clear();
|
||||
BuildWires( EdgeMap, WireMap );
|
||||
MapIt.Initialize( WireMap );
|
||||
W = TopoDS::Wire( MapIt.Key() );
|
||||
//Build the final wire and final face
|
||||
TopTools_ListOfShape FinalEdges;
|
||||
Handle(TColGeom2d_HArray1OfCurve) CurvesOnPlate = myBuilder.Curves2d();
|
||||
BRep_Builder BB;
|
||||
for (i = 1; i <= myBoundary.Length(); i++)
|
||||
{
|
||||
const TopoDS_Edge& InitEdge = myBoundary(i).myEdge;
|
||||
TopoDS_Edge anEdge = InitEdge;
|
||||
if (!myOldNewMap(anEdge).IsEmpty())
|
||||
anEdge = TopoDS::Edge( myOldNewMap(anEdge).First() );
|
||||
Handle(Geom2d_Curve) aCurveOnPlate = CurvesOnPlate->Value(i);
|
||||
|
||||
TopoDS_Edge NewEdge = TopoDS::Edge(anEdge.EmptyCopied());
|
||||
NewEdge.Closed(anEdge.Closed());
|
||||
TopoDS_Vertex V1, V2;
|
||||
TopExp::Vertices(anEdge, V1, V2, Standard_True); //with orientation
|
||||
BB.UpdateVertex(V1, dmax);
|
||||
BB.UpdateVertex(V2, dmax);
|
||||
BB.Add(NewEdge, V1);
|
||||
BB.Add(NewEdge, V2);
|
||||
TopLoc_Location Loc;
|
||||
BB.UpdateEdge(NewEdge, aCurveOnPlate, Surface, Loc, dmax);
|
||||
//BRepLib::SameRange(NewEdge);
|
||||
BRepLib::SameParameter(NewEdge, dmax, Standard_True);
|
||||
FinalEdges.Append(NewEdge);
|
||||
myOldNewMap(InitEdge).Clear();
|
||||
myOldNewMap(InitEdge).Append(NewEdge);
|
||||
}
|
||||
|
||||
if (!(W.Closed()))
|
||||
TopoDS_Wire FinalWire = WireFromList(FinalEdges);
|
||||
if (!(FinalWire.Closed()))
|
||||
Standard_Failure::Raise("Wire is not closed");
|
||||
|
||||
myFace = BRepLib_MakeFace( Surface, W );
|
||||
|
||||
myFace = BRepLib_MakeFace( Surface, FinalWire );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//======================================================================
|
||||
Standard_Boolean BRepFill_Filling::IsDone() const
|
||||
{
|
||||
return myIsDone;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Face
|
||||
//purpose : returns the result
|
||||
//======================================================================
|
||||
TopoDS_Face BRepFill_Filling::Face() const
|
||||
{
|
||||
return myFace;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Generated
|
||||
//purpose : returns the new edge (first in list) made from old edge "S"
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BRepFill_Filling::Generated(const TopoDS_Shape& S)
|
||||
{
|
||||
myGenerated.Clear();
|
||||
|
||||
if (myOldNewMap.IsBound(S))
|
||||
myGenerated.Append(myOldNewMap(S));
|
||||
|
||||
return myGenerated;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G0Error
|
||||
//purpose : returns maximum distance from boundary to the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepFill_Filling::G0Error() const
|
||||
{
|
||||
return myBuilder.G0Error();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : G1Error
|
||||
//purpose : returns maximum angle between the resulting surface
|
||||
// and constraint surfaces at boundaries
|
||||
//======================================================================
|
||||
Standard_Real BRepFill_Filling::G1Error() const
|
||||
{
|
||||
return myBuilder.G1Error();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : G2Error
|
||||
//purpose : returns maximum difference of curvature between
|
||||
// the resulting surface and constraint surfaces at boundaries
|
||||
//======================================================================
|
||||
Standard_Real BRepFill_Filling::G2Error() const
|
||||
{
|
||||
return myBuilder.G2Error();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G0Error
|
||||
//purpose : returns maximum distance between the constraint number Index
|
||||
// and the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepFill_Filling::G0Error( const Standard_Integer Index )
|
||||
{
|
||||
return myBuilder.G0Error( Index );
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G1Error
|
||||
//purpose : returns maximum angle between the constraint number Index
|
||||
// and the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepFill_Filling::G1Error( const Standard_Integer Index )
|
||||
{
|
||||
return myBuilder.G1Error( Index );
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G2Error
|
||||
//purpose : returns maximum difference of curvature between
|
||||
// the constraint number Index and the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepFill_Filling::G2Error( const Standard_Integer Index )
|
||||
{
|
||||
return myBuilder.G2Error( Index );
|
||||
|
@ -46,6 +46,7 @@ uses
|
||||
Face from TopoDS,
|
||||
Pnt from gp,
|
||||
Shape from GeomAbs,
|
||||
ListOfShape from TopTools,
|
||||
Filling from BRepFill
|
||||
|
||||
raises
|
||||
@ -202,6 +203,14 @@ is
|
||||
is redefined;
|
||||
--- Purpose: Tests whether computation of the filling plate has been completed.
|
||||
|
||||
Generated (me: in out; S : Shape from TopoDS)
|
||||
---Purpose: Returns the list of shapes generated from the
|
||||
-- shape <S>.
|
||||
---C++: return const &
|
||||
---Level: Public
|
||||
returns ListOfShape from TopTools
|
||||
is redefined;
|
||||
|
||||
G0Error(me) returns Real from Standard;
|
||||
--- Purpose: Returns the maximum distance between the result and
|
||||
-- the constraints. This is set at construction time.
|
||||
|
@ -7,6 +7,10 @@
|
||||
#include <BRepOffsetAPI_MakeFilling.ixx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//======================================================================
|
||||
BRepOffsetAPI_MakeFilling::BRepOffsetAPI_MakeFilling( const Standard_Integer Degree,
|
||||
const Standard_Integer NbPtsOnCur,
|
||||
const Standard_Integer NbIter,
|
||||
@ -21,6 +25,10 @@ myFilling( Degree, NbPtsOnCur, NbIter, Anisotropie, Tol2d, Tol3d, TolAng, TolCur
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetConstrParam
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepOffsetAPI_MakeFilling::SetConstrParam( const Standard_Real Tol2d,
|
||||
const Standard_Real Tol3d,
|
||||
const Standard_Real TolAng,
|
||||
@ -29,6 +37,10 @@ void BRepOffsetAPI_MakeFilling::SetConstrParam( const Standard_Real Tol2d,
|
||||
myFilling.SetConstrParam( Tol2d, Tol3d, TolAng, TolCurv );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetResolParam
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepOffsetAPI_MakeFilling::SetResolParam( const Standard_Integer Degree,
|
||||
const Standard_Integer NbPtsOnCur,
|
||||
const Standard_Integer NbIter,
|
||||
@ -37,17 +49,29 @@ void BRepOffsetAPI_MakeFilling::SetResolParam( const Standard_Integer Degree,
|
||||
myFilling.SetResolParam( Degree, NbPtsOnCur, NbIter, Anisotropie );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetApproxParam
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepOffsetAPI_MakeFilling::SetApproxParam( const Standard_Integer MaxDeg,
|
||||
const Standard_Integer MaxSegments )
|
||||
{
|
||||
myFilling.SetApproxParam( MaxDeg, MaxSegments );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LoadInitSurface
|
||||
//purpose :
|
||||
//======================================================================
|
||||
void BRepOffsetAPI_MakeFilling::LoadInitSurface( const TopoDS_Face& Surf )
|
||||
{
|
||||
myFilling.LoadInitSurface( Surf );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds an edge as a constraint
|
||||
//======================================================================
|
||||
Standard_Integer BRepOffsetAPI_MakeFilling::Add( const TopoDS_Edge& Constr,
|
||||
const GeomAbs_Shape Order,
|
||||
const Standard_Boolean IsBound )
|
||||
@ -55,6 +79,10 @@ Standard_Integer BRepOffsetAPI_MakeFilling::Add( const TopoDS_Edge& Constr,
|
||||
return myFilling.Add( Constr, Order, IsBound );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds an edge with supporting face as a constraint
|
||||
//======================================================================
|
||||
Standard_Integer BRepOffsetAPI_MakeFilling::Add( const TopoDS_Edge& Constr,
|
||||
const TopoDS_Face& Support,
|
||||
const GeomAbs_Shape Order,
|
||||
@ -63,17 +91,29 @@ Standard_Integer BRepOffsetAPI_MakeFilling::Add( const TopoDS_Edge& Constr,
|
||||
return myFilling.Add( Constr, Support, Order, IsBound );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds a "free constraint": face without edge
|
||||
//======================================================================
|
||||
Standard_Integer BRepOffsetAPI_MakeFilling::Add( const TopoDS_Face& Support,
|
||||
const GeomAbs_Shape Order )
|
||||
{
|
||||
return myFilling.Add( Support, Order );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds a point constraint
|
||||
//======================================================================
|
||||
Standard_Integer BRepOffsetAPI_MakeFilling::Add( const gp_Pnt& Point )
|
||||
{
|
||||
return myFilling.Add( Point );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Add
|
||||
//purpose : adds a point constraint on a face
|
||||
//======================================================================
|
||||
Standard_Integer BRepOffsetAPI_MakeFilling::Add( const Standard_Real U,
|
||||
const Standard_Real V,
|
||||
const TopoDS_Face& Support,
|
||||
@ -83,42 +123,88 @@ Standard_Integer BRepOffsetAPI_MakeFilling::Add( const Standard_Real U,
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Build
|
||||
//purpose : builds the resulting face
|
||||
//======================================================================
|
||||
void BRepOffsetAPI_MakeFilling::Build()
|
||||
{
|
||||
myFilling.Build();
|
||||
myShape = myFilling.Face();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDone
|
||||
//purpose :
|
||||
//======================================================================
|
||||
Standard_Boolean BRepOffsetAPI_MakeFilling::IsDone() const
|
||||
{
|
||||
return myFilling.IsDone();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Generated
|
||||
//purpose : returns the new edge (first in list) made from old edge "S"
|
||||
//=======================================================================
|
||||
const TopTools_ListOfShape& BRepOffsetAPI_MakeFilling::Generated(const TopoDS_Shape& S)
|
||||
{
|
||||
return myFilling.Generated(S);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G0Error
|
||||
//purpose : returns maximum distance from boundary to the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepOffsetAPI_MakeFilling::G0Error() const
|
||||
{
|
||||
return myFilling.G0Error();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : G1Error
|
||||
//purpose : returns maximum angle between the resulting surface
|
||||
// and constraint surfaces at boundaries
|
||||
//======================================================================
|
||||
Standard_Real BRepOffsetAPI_MakeFilling::G1Error() const
|
||||
{
|
||||
return myFilling.G1Error();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : G2Error
|
||||
//purpose : returns maximum difference of curvature between
|
||||
// the resulting surface and constraint surfaces at boundaries
|
||||
//======================================================================
|
||||
Standard_Real BRepOffsetAPI_MakeFilling::G2Error() const
|
||||
{
|
||||
return myFilling.G2Error();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G0Error
|
||||
//purpose : returns maximum distance between the constraint number Index
|
||||
// and the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepOffsetAPI_MakeFilling::G0Error( const Standard_Integer Index )
|
||||
{
|
||||
return myFilling.G0Error( Index );
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G1Error
|
||||
//purpose : returns maximum angle between the constraint number Index
|
||||
// and the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepOffsetAPI_MakeFilling::G1Error( const Standard_Integer Index )
|
||||
{
|
||||
return myFilling.G1Error( Index );
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//function : G2Error
|
||||
//purpose : returns maximum difference of curvature between
|
||||
// the constraint number Index and the resulting surface
|
||||
//==========================================================================
|
||||
Standard_Real BRepOffsetAPI_MakeFilling::G2Error( const Standard_Integer Index )
|
||||
{
|
||||
return myFilling.G2Error( Index );
|
||||
|
@ -1679,6 +1679,29 @@ Standard_Integer build3d(Draw_Interpretor& di,
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : reducepcurves
|
||||
//purpose : remove pcurves that are unused in this shape
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer reducepcurves(Draw_Interpretor& di,
|
||||
Standard_Integer n, const char** a)
|
||||
{
|
||||
if (n < 2) return 1;
|
||||
|
||||
Standard_Integer i;
|
||||
for (i = 1; i < n; i++)
|
||||
{
|
||||
TopoDS_Shape aShape = DBRep::Get(a[i]);
|
||||
if (aShape.IsNull())
|
||||
//cout << a[i] << " is not a valid shape" << endl;
|
||||
di << a[i] << " is not a valid shape" << "\n";
|
||||
else
|
||||
BRepTools::RemoveUnusedPCurves(aShape);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : CurveCommands
|
||||
@ -1786,6 +1809,10 @@ void BRepTest::CurveCommands(Draw_Interpretor& theCommands)
|
||||
"build3d S [tol]",
|
||||
build3d, g);
|
||||
|
||||
theCommands.Add("reducepcurves",
|
||||
"reducepcurves shape1 shape2 ...",
|
||||
reducepcurves, g);
|
||||
|
||||
theCommands.Add("concatwire",
|
||||
"concatwire result wire [option](G1/C1)",
|
||||
__FILE__,
|
||||
|
@ -469,9 +469,9 @@ static Standard_Integer filling( Draw_Interpretor & di, Standard_Integer n, cons
|
||||
TolCurv,
|
||||
MaxDeg,
|
||||
MaxSegments );
|
||||
TopoDS_Shape aLocalFace(DBRep::Get( a[5], TopAbs_FACE ) );
|
||||
TopoDS_Face InitFace = TopoDS::Face( aLocalFace);
|
||||
// TopoDS_Face InitFace = TopoDS::Face( DBRep::Get( a[5], TopAbs_FACE ) );
|
||||
//TopoDS_Shape aLocalFace(DBRep::Get( a[5], TopAbs_FACE ) );
|
||||
//TopoDS_Face InitFace = TopoDS::Face( aLocalFace);
|
||||
TopoDS_Face InitFace = TopoDS::Face( DBRep::Get(a[5], TopAbs_FACE) );
|
||||
if (! InitFace.IsNull())
|
||||
MakeFilling.LoadInitSurface( InitFace );
|
||||
|
||||
@ -484,14 +484,14 @@ static Standard_Integer filling( Draw_Interpretor & di, Standard_Integer n, cons
|
||||
{
|
||||
E.Nullify();
|
||||
F.Nullify();
|
||||
TopoDS_Shape aLocalEdge(DBRep::Get( a[i], TopAbs_EDGE ));
|
||||
E = TopoDS::Edge(aLocalEdge);
|
||||
// E = TopoDS::Edge( DBRep::Get( a[i], TopAbs_EDGE ) );
|
||||
//TopoDS_Shape aLocalEdge(DBRep::Get( a[i], TopAbs_EDGE ));
|
||||
//E = TopoDS::Edge(aLocalEdge);
|
||||
E = TopoDS::Edge( DBRep::Get(a[i], TopAbs_EDGE) );
|
||||
if (! E.IsNull())
|
||||
i++;
|
||||
aLocalFace = DBRep::Get( a[i], TopAbs_FACE ) ;
|
||||
F = TopoDS::Face(aLocalFace);
|
||||
// F = TopoDS::Face( DBRep::Get( a[i], TopAbs_FACE ) );
|
||||
//aLocalFace = DBRep::Get( a[i], TopAbs_FACE ) ;
|
||||
//F = TopoDS::Face(aLocalFace);
|
||||
F = TopoDS::Face( DBRep::Get(a[i], TopAbs_FACE) );
|
||||
if (! F.IsNull())
|
||||
i++;
|
||||
|
||||
@ -517,18 +517,18 @@ static Standard_Integer filling( Draw_Interpretor & di, Standard_Integer n, cons
|
||||
{
|
||||
E.Nullify();
|
||||
F.Nullify();
|
||||
TopoDS_Shape aLocalEdge(DBRep::Get( a[i++], TopAbs_EDGE ));
|
||||
E = TopoDS::Edge( aLocalEdge);
|
||||
// E = TopoDS::Edge( DBRep::Get( a[i++], TopAbs_EDGE ) );
|
||||
//TopoDS_Shape aLocalEdge(DBRep::Get( a[i++], TopAbs_EDGE ));
|
||||
//E = TopoDS::Edge( aLocalEdge);
|
||||
E = TopoDS::Edge( DBRep::Get(a[i++], TopAbs_EDGE) );
|
||||
if (E.IsNull())
|
||||
{
|
||||
//cout<<"Wrong parameters"<<endl;
|
||||
di<<"Wrong parameters"<<"\n";
|
||||
return 1;
|
||||
}
|
||||
TopoDS_Shape alocalFace(DBRep::Get( a[i], TopAbs_FACE ) );
|
||||
F = TopoDS::Face( aLocalFace);
|
||||
// F = TopoDS::Face( DBRep::Get( a[i], TopAbs_FACE ) );
|
||||
//TopoDS_Shape alocalFace(DBRep::Get( a[i], TopAbs_FACE ) );
|
||||
//F = TopoDS::Face( alocalFace);
|
||||
F = TopoDS::Face( DBRep::Get(a[i], TopAbs_FACE) );
|
||||
if (! F.IsNull())
|
||||
i++;
|
||||
|
||||
@ -549,9 +549,9 @@ static Standard_Integer filling( Draw_Interpretor & di, Standard_Integer n, cons
|
||||
else
|
||||
{
|
||||
Standard_Real U = atof( a[i++] ), V = atof( a[i++] );
|
||||
aLocalFace = DBRep::Get( a[i++], TopAbs_FACE );
|
||||
F = TopoDS::Face( aLocalFace);
|
||||
// F = TopoDS::Face( DBRep::Get( a[i++], TopAbs_FACE ));
|
||||
//aLocalFace = DBRep::Get( a[i++], TopAbs_FACE );
|
||||
//F = TopoDS::Face( aLocalFace);
|
||||
F = TopoDS::Face( DBRep::Get(a[i++], TopAbs_FACE));
|
||||
if (F.IsNull())
|
||||
{
|
||||
//cout<<"Wrong parameters"<<endl;
|
||||
|
@ -196,6 +196,9 @@ is
|
||||
-- and removes all polygons on triangulations of the
|
||||
-- edges.
|
||||
|
||||
RemoveUnusedPCurves(S: Shape from TopoDS);
|
||||
---Purpose: Removes all the pcurves of the edges of <S> that
|
||||
-- refer to surfaces not belonging to any face of <S>
|
||||
|
||||
Triangulation(S: Shape from TopoDS; deflec: Real)
|
||||
returns Boolean from Standard;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <Poly_Triangulation.hxx>
|
||||
#include <Poly_PolygonOnTriangulation.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_MapOfTransient.hxx>
|
||||
|
||||
#include <gp_Lin2d.hxx>
|
||||
#include <ElCLib.hxx>
|
||||
@ -747,7 +748,58 @@ void BRepTools::Clean(const TopoDS_Shape& S)
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveUnusedPCurves
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void BRepTools::RemoveUnusedPCurves(const TopoDS_Shape& S)
|
||||
{
|
||||
TColStd_MapOfTransient UsedSurfaces;
|
||||
|
||||
TopExp_Explorer Explo(S, TopAbs_FACE);
|
||||
for (; Explo.More(); Explo.Next())
|
||||
{
|
||||
TopoDS_Face aFace = TopoDS::Face(Explo.Current());
|
||||
TopLoc_Location aLoc;
|
||||
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace, aLoc);
|
||||
UsedSurfaces.Add(aSurf);
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape Emap;
|
||||
TopExp::MapShapes(S, TopAbs_EDGE, Emap);
|
||||
|
||||
Standard_Integer i;
|
||||
for (i = 1; i <= Emap.Extent(); i++)
|
||||
{
|
||||
const Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &Emap(i).TShape());
|
||||
BRep_ListOfCurveRepresentation& lcr = TE -> ChangeCurves();
|
||||
BRep_ListIteratorOfListOfCurveRepresentation itrep(lcr );
|
||||
while (itrep.More())
|
||||
{
|
||||
Standard_Boolean ToRemove = Standard_False;
|
||||
|
||||
Handle(BRep_CurveRepresentation) CurveRep = itrep.Value();
|
||||
if (CurveRep->IsCurveOnSurface())
|
||||
{
|
||||
Handle(Geom_Surface) aSurface = CurveRep->Surface();
|
||||
if (!UsedSurfaces.Contains(aSurface))
|
||||
ToRemove = Standard_True;
|
||||
}
|
||||
else if (CurveRep->IsRegularity())
|
||||
{
|
||||
Handle(Geom_Surface) Surf1 = CurveRep->Surface();
|
||||
Handle(Geom_Surface) Surf2 = CurveRep->Surface2();
|
||||
ToRemove = (!UsedSurfaces.Contains(Surf1) || !UsedSurfaces.Contains(Surf2));
|
||||
}
|
||||
|
||||
if (ToRemove)
|
||||
lcr.Remove(itrep);
|
||||
else
|
||||
itrep.Next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Triangulation
|
||||
|
Loading…
x
Reference in New Issue
Block a user