#include <BRepFill_FaceAndOrder.hxx>
#include <BRepFill_Filling.hxx>
#include <BRepLib.hxx>
+#include <BRepLib_MakeVertex.hxx>
#include <BRepLib_MakeEdge.hxx>
#include <BRepLib_MakeEdge2d.hxx>
#include <BRepLib_MakeFace.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <Geom_Surface.hxx>
static gp_Vec MakeFinVec( const TopoDS_Wire aWire, const TopoDS_Vertex aVertex )
{
static TopoDS_Wire WireFromList(TopTools_ListOfShape& Edges)
{
- BRepLib_MakeWire MW;
+ BRep_Builder BB;
+ TopoDS_Wire aWire;
+ BB.MakeWire(aWire);
TopoDS_Edge anEdge = TopoDS::Edge(Edges.First());
- MW.Add(anEdge);
+ BB.Add(aWire, anEdge);
Edges.RemoveFirst();
+ TopoDS_Vertex V1, V2;
+ TopExp::Vertices(anEdge, V1, V2, Standard_True); //with orientation
+
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);
+ TopExp::Vertices(anEdge, V3, V4, Standard_True); //with orientation
if (V1.IsSame(V3) || V1.IsSame(V4) ||
V2.IsSame(V3) || V2.IsSame(V4))
+ {
+ if (V1.IsSame(V3))
+ {
+ anEdge.Reverse();
+ V1 = V4;
+ }
+ else if (V1.IsSame(V4))
+ V1 = V3;
+ else if (V2.IsSame(V3))
+ V2 = V4;
+ else
+ {
+ anEdge.Reverse();
+ V2 = V3;
+ }
break;
+ }
}
- MW.Add(anEdge);
+ BB.Add(aWire, anEdge);
Edges.Remove(itl);
}
- return (MW.Wire());
+ aWire.Closed(Standard_True);
+ return aWire;
}
//=======================================================================
if (IsBound)
{
myBoundary.Append( EdgeFaceAndOrder );
- TopTools_ListOfShape EmptyList;
- myOldNewMap.Bind(anEdge, EmptyList);
return myBoundary.Length();
}
else
if (IsBound)
{
myBoundary.Append( EdgeFaceAndOrder );
- TopTools_ListOfShape EmptyList;
- myOldNewMap.Bind(anEdge, EmptyList);
return myBoundary.Length();
}
else
Standard_Real f, l;
BRep_Tool::CurveOnSurface( CurEdge, C2d, Surface, loc, f, l);
if (Surface.IsNull()) {
- Standard_Failure::Raise( "Add" );
+ throw Standard_Failure( "Add" );
return;
}
Surface = Handle(Geom_Surface)::DownCast(Surface->Copy());
aDist < BRep_Tool::Tolerance(V_edge[j]))
{
MW.Add(CurEdge);
- myOldNewMap(CurEdge).Append(MW.Edge());
+ TopoDS_Edge NewEdge = MW.Edge();
+ myOldNewMap.Bind(CurEdge.Oriented(TopAbs_FORWARD),
+ NewEdge.Oriented(TopAbs_FORWARD));
EdgeList.Remove(Itl);
found = Standard_True;
break;
theWire = TopoDS::Wire(WireSeq(1));
WireSeq.Remove(1);
- if (theWire.Closed())
+ if (BRep_Tool::IsClosed(theWire))
return;
TopoDS_Vertex Vfirst, Vlast;
TopExp::Vertices( theWire, Vfirst, Vlast );
+
+ if (Vfirst.IsSame(Vlast))
+ {
+ // The Wire is closed indeed despite its
+ // being not detected earlier.
+
+ return;
+ }
+
gp_Vec FinVec = MakeFinVec( theWire, Vlast );
TopoDS_Vertex theVertex = Vlast;
VerSeq.Append( Vlast );
for (j = 1; j <= myFreeConstraints.Length(); j++)
{
GeomAPI_ProjectPointOnSurf Projector;
- Quantity_Parameter U1, V1, U2, V2;
+ Standard_Real U1, V1, U2, V2;
CurFace = myFreeConstraints(j).myFace;
Handle( BRepAdaptor_HSurface ) HSurf = new BRepAdaptor_HSurface();
{
GeomPlate_MakeApprox Approx( GPlate, myTol3d, myMaxSegments, myMaxDeg, dmax, 0 ); //?????????????
//GeomConvert_ApproxSurface Approx( GPlate, myTol3d, GeomAbs_C1, GeomAbs_C1, myMaxDeg, myMaxDeg, myMaxSegments, 1 );
- //Approx.Dump( cout );
+ //Approx.Dump( std::cout );
Surface = Approx.Surface();
}
{
const TopoDS_Edge& InitEdge = myBoundary(i).myEdge;
TopoDS_Edge anEdge = InitEdge;
- if (!myOldNewMap(anEdge).IsEmpty())
- anEdge = TopoDS::Edge( myOldNewMap(anEdge).First() );
+ anEdge.Orientation(TopAbs_FORWARD);
+ if (myOldNewMap.IsBound(anEdge))
+ anEdge = TopoDS::Edge(myOldNewMap(anEdge));
+
Handle(Geom2d_Curve) aCurveOnPlate = CurvesOnPlate->Value(i);
TopoDS_Edge NewEdge = TopoDS::Edge(anEdge.EmptyCopied());
- 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);
+ TopoDS_Vertex V1, V2, NewV1, NewV2;
+ TopExp::Vertices(anEdge, V1, V2);
+
+ if (myOldNewMap.IsBound(V1))
+ NewV1 = TopoDS::Vertex(myOldNewMap(V1));
+ else
+ {
+ gp_Pnt aPnt = BRep_Tool::Pnt(V1);
+ NewV1 = BRepLib_MakeVertex(aPnt);
+ BB.UpdateVertex(NewV1, dmax);
+ }
+
+ if (myOldNewMap.IsBound(V2))
+ NewV2 = TopoDS::Vertex(myOldNewMap(V2));
+ else
+ {
+ gp_Pnt aPnt = BRep_Tool::Pnt(V2);
+ NewV2 = BRepLib_MakeVertex(aPnt);
+ BB.UpdateVertex(NewV2, dmax);
+ }
+
+ NewV1.Orientation(TopAbs_FORWARD);
+ BB.Add(NewEdge, NewV1);
+ NewV2.Orientation(TopAbs_REVERSED);
+ BB.Add(NewEdge, NewV2);
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);
+ myOldNewMap.Bind(InitEdge.Oriented(TopAbs_FORWARD), NewEdge.Oriented(TopAbs_FORWARD));
+ myOldNewMap.Bind(V1.Oriented(TopAbs_FORWARD), NewV1.Oriented(TopAbs_FORWARD));
+ if (!V1.IsSame(V2))
+ myOldNewMap.Bind(V2.Oriented(TopAbs_FORWARD), NewV2.Oriented(TopAbs_FORWARD));
}
TopoDS_Wire FinalWire = WireFromList(FinalEdges);
- if (!(FinalWire.Closed()))
- Standard_Failure::Raise("Wire is not closed");
myFace = BRepLib_MakeFace( Surface, FinalWire );
}