// Modified by skv - Fri Jul 8 11:21:38 2005 OCC9145
-#include <stdio.h>
-
-#include <BRepFill_OffsetWire.ixx>
-
+#include <Adaptor3d_Curve.hxx>
+#include <Adaptor2d_OffsetCurve.hxx>
+#include <Bisector_Bisec.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_CurveRepresentation.hxx>
+#include <BRep_GCurve.hxx>
+#include <BRep_TEdge.hxx>
+#include <BRep_Tool.hxx>
+#include <BRep_TVertex.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
-
#include <BRepFill_DataMapOfNodeShape.hxx>
+#include <BRepFill_DataMapOfOrientedShapeListOfShape.hxx>
#include <BRepFill_DataMapOfShapeSequenceOfPnt.hxx>
-#include <BRepFill_DataMapOfShapeSequenceOfReal.hxx>
-#include <BRepFill_DataMapOfOrientedShapeListOfShape.hxx>
+#include <BRepFill_DataMapOfShapeSequenceOfReal.hxx>
+#include <BRepFill_OffsetWire.hxx>
#include <BRepFill_TrimEdgeTool.hxx>
#include <BRepLib.hxx>
-#include <BRepLib_MakeVertex.hxx>
+#include <BRepLib_MakeEdge.hxx>
#include <BRepLib_MakeFace.hxx>
+#include <BRepLib_MakeVertex.hxx>
#include <BRepLib_MakeWire.hxx>
-#include <BRepLib_MakeEdge.hxx>
+#include <BRepMAT2d_BisectingLocus.hxx>
+#include <BRepMAT2d_Explorer.hxx>
+#include <BRepMAT2d_LinkTopoBilo.hxx>
#include <BRepTools.hxx>
-#include <BRep_Builder.hxx>
-#include <BRep_Tool.hxx>
-#include <BRep_TEdge.hxx>
-#include <BRep_CurveRepresentation.hxx>
-#include <BRep_GCurve.hxx>
+#include <BRepTools_Substitution.hxx>
#include <BRepTools_WireExplorer.hxx>
-#include <BRepMAT2d_Explorer.hxx>
-#include <Geom2dAdaptor_Curve.hxx>
-#include <Geom2dAdaptor_HCurve.hxx>
-#include <Adaptor3d_OffsetCurve.hxx>
-#include <Adaptor3d_Curve.hxx>
-#include <Geom_Surface.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom2d_Curve.hxx>
+#include <Geom2d_BSplineCurve.hxx>
#include <Geom2d_Circle.hxx>
+#include <Geom2d_Curve.hxx>
#include <Geom2d_Line.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
#include <Geom2d_OffsetCurve.hxx>
-#include <GeomAPI.hxx>
-#include <Geom_TrimmedCurve.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dAdaptor_HCurve.hxx>
+#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
+#include <Geom2dLProp_CLProps2d.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Line.hxx>
#include <Geom_OffsetCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <GeomAPI.hxx>
+#include <gp.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Dir2d.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Vec.hxx>
+#include <MAT2d_CutCurve.hxx>
#include <MAT_Arc.hxx>
-#include <MAT_Node.hxx>
#include <MAT_Graph.hxx>
-#include <MAT2d_CutCurve.hxx>
+#include <MAT_Node.hxx>
#include <Precision.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_ErrorHandler.hxx>
+#include <Standard_NoSuchObject.hxx>
#include <Standard_NotImplemented.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_SequenceOfPnt.hxx>
-#include <TColStd_SequenceOfReal.hxx>
-#include <TopAbs.hxx>
+#include <TColStd_Array1OfInteger.hxx>
+#include <TColStd_Array1OfReal.hxx>
+#include <TColStd_SequenceOfReal.hxx>
+#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
-#include <TopoDS_Wire.hxx>
#include <TopoDS_Compound.hxx>
+#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx>
-#include <TopTools_MapOfShape.hxx>
-#include <TopTools_MapIteratorOfMapOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Wire.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
-#include <TopTools_SequenceOfShape.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_DataMapOfShapeSequenceOfShape.hxx>
-
-#include <gp.hxx>
-#include <gp_Vec.hxx>
-#include <gp_Ax2.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Dir2d.hxx>
-
-#include <BRep_TVertex.hxx>
+#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
-#include <Geom2d_BSplineCurve.hxx>
-#include <TColgp_Array1OfPnt2d.hxx>
-#include <TColStd_Array1OfReal.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <BRepTools_Substitution.hxx>
-#include <BRepLib_MakeVertex.hxx>
-#include <Geom2dLProp_CLProps2d.hxx>
-#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
-#include <Standard_ErrorHandler.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_MapIteratorOfMapOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+
+#include <stdio.h>
#ifdef OCCT_DEBUG
//#define DRAW
#ifdef DRAW
#include <DrawTrSurf.hxx>
#include <DrawTrSurf_Curve2d.hxx>
#include <DBRep.hxx>
+#include <Geom_Curve.hxx>
static Standard_Boolean AffichGeom = Standard_False;
static Standard_Boolean Affich2d = Standard_False;
static Standard_Boolean AffichEdge = Standard_False;
const GeomAbs_JoinType theJoinType,
const TopoDS_Vertex * Ends);
+Standard_Boolean CheckSmallParamOnEdge(const TopoDS_Edge& anEdge);
+
//=======================================================================
//function : KPartCircle
//purpose :
BRepFill_IndexedDataMapOfOrientedShapeListOfShape& myMap,
Standard_Boolean& myIsDone)
{
- // The only contour which is a closed circle
- TopExp_Explorer exp(mySpine,TopAbs_EDGE);
- Standard_Integer NbEdges = 0;
- TopoDS_Edge E;
-
- for (; exp.More(); exp.Next()) {
- NbEdges++;
- E = TopoDS::Edge(exp.Current());
- if (NbEdges > 1) return Standard_False;
+ TopoDS_Edge E;
+ for (TopExp_Explorer anEdgeIter (mySpine, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
+ {
+ if (!E.IsNull())
+ {
+ return Standard_False;
+ }
+ E = TopoDS::Edge (anEdgeIter.Current());
+ }
+ if (E.IsNull())
+ {
+ return Standard_False;
}
Standard_Real f,l;
TopLoc_Location L;
Handle(Geom_Curve) C = BRep_Tool::Curve(E,L,f,l);
+ if (C.IsNull())
+ {
+ return Standard_False;
+ }
if (C->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle(Geom_TrimmedCurve) Ct = Handle(Geom_TrimmedCurve)::DownCast(C);
Handle(Geom2d_Curve) OC;
if (AHC->GetType() == GeomAbs_Line)
{
- if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1;
- Adaptor3d_OffsetCurve Off(AHC,anOffset);
+ if (E.Orientation() == TopAbs_FORWARD)
+ anOffset *= -1;
+ Adaptor2d_OffsetCurve Off(AHC, anOffset);
OC = new Geom2d_Line(Off.Line());
}
else if (AHC->GetType() == GeomAbs_Circle)
{
- if (E.Orientation() == TopAbs_FORWARD) anOffset *= -1;
+ if (E.Orientation() == TopAbs_FORWARD)
+ anOffset *= -1;
gp_Circ2d theCirc = AHC->Circle();
if (anOffset > 0. || Abs(anOffset) < theCirc.Radius())
OC = new Geom2d_Circle (theCirc.Position(), theCirc.Radius() + anOffset);
}
else
{
- if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1;
+ if (E.Orientation() == TopAbs_FORWARD)
+ anOffset *= -1;
Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(aPCurve, f, l);
- OC = new Geom2d_OffsetCurve( G2dT, anOffset);
+ OC = new Geom2d_OffsetCurve(G2dT, anOffset);
}
Handle(Geom_Surface) aSurf = BRep_Tool::Surface(mySpine);
Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf);
myShape.Orientation(E.Orientation());
myShape.Location(L);
- if (Alt != 0.) {
+ if (fabs(Alt) > gp::Resolution()) {
BRepAdaptor_Surface S(mySpine,0);
gp_Ax1 Nor = S.Plane().Axis();
gp_Trsf T;
}
if ( !it.Value().IsSame(it.Key())) {
myMap.ChangeFromKey(it.Value()).Append(myMap.ChangeFromKey(it.Key()));
- //myMap.UnBind(it.Key());
- TopoDS_Shape LastShape = myMap.FindKey(myMap.Extent());
- TopTools_ListOfShape LastList;
- LastList.Append(myMap(myMap.Extent()));
- myMap.RemoveLast();
- if (myMap.FindIndex(it.Key()) != 0)
- myMap.Substitute(myMap.FindIndex(it.Key()), LastShape, LastList);
+ myMap.RemoveKey(it.Key());
}
}
if (myMap.Contains(it.Key().Reversed())) {
}
if ( !it.Value().IsSame(it.Key())) {
myMap.ChangeFromKey(it.Value().Reversed()).Append(myMap.ChangeFromKey(it.Key().Reversed()));
- //myMap.UnBind(it.Key().Reversed());
- TopoDS_Shape LastShape = myMap.FindKey(myMap.Extent());
- TopTools_ListOfShape LastList;
- LastList.Append(myMap(myMap.Extent()));
- myMap.RemoveLast();
- if (myMap.FindIndex(it.Key().Reversed()) != 0)
- myMap.Substitute(myMap.FindIndex(it.Key().Reversed()), LastShape, LastList);
+ myMap.RemoveKey(it.Key().Reversed());
}
}
}
if(!BadEdges.IsEmpty())
{
// Modification of myWorkSpine;
- //cout << "Modification of myWorkSpine : " << BadEdges.Extent() << endl;
+ //std::cout << "Modification of myWorkSpine : " << BadEdges.Extent() << std::endl;
BRepTools_Substitution aSubst;
TopTools_ListIteratorOfListOfShape it(BadEdges);
TopTools_ListOfShape aL;
Standard_Integer NPnts = Points.Length();
if(NPnts > 2)
{
- //cout << NPnts << " points " << endl;
+ //std::cout << NPnts << " points " << std::endl;
TopoDS_Vertex FV = Vf;
TopoDS_Vertex LV;
TopoDS_Edge newE;
}
else
{
- //cout << " 2 points " << endl;
+ //std::cout << " 2 points " << std::endl;
TopoDS_Edge newE = BRepLib_MakeEdge(Vf, Vl);
aL.Append(newE);
}
PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt);
}
}
- catch (Standard_Failure)//Every exception was caught.
- {
- myShape.Nullify();
- myIsDone = Standard_False;
+ catch (Standard_Failure const& anException) {
#ifdef OCCT_DEBUG
- cout<<"An exception was caught in BRepFill_OffsetWire::Perform : ";
- Standard_Failure::Caught()->Print(cout);
- cout<<endl;
+ std::cout<<"An exception was caught in BRepFill_OffsetWire::Perform : ";
+ anException.Print(std::cout);
+ std::cout<<std::endl;
#endif
+ (void)anException;
+ myShape.Nullify();
+ myIsDone = Standard_False;
return;
}
if (!aWire.Closed()) {
myShape.Nullify();
myIsDone = Standard_False;
- Standard_ConstructionError::Raise("Offset wire is not closed.");
+ throw Standard_ConstructionError("Offset wire is not closed.");
}
}
}
const Standard_Real Alt)
{
myIsDone = Standard_False;
- TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
- myWorkSpine = TopoDS::Face(aLocalShape);
+ TopoDS_Shape aLocalShapeWork = Spine.Oriented(TopAbs_FORWARD);
+ myWorkSpine = TopoDS::Face(aLocalShapeWork);
// myWorkSpine = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
myJoinType = Join;
myOffset = Offset ;
return;
BRep_Builder myBuilder;
- myBuilder.MakeCompound(TopoDS::Compound(myShape));
//---------------------------------------------------------------------
// MapNodeVertex : associate to each node of the map (key1) and to
TopTools_ListOfShape EmptyList;
TColStd_SequenceOfReal EmptySeqOfReal;
- Standard_Real ALT = Alt;
Handle(Geom_Plane) RefPlane =
Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(myWorkSpine));
- if ( myWorkSpine.Orientation() == TopAbs_REVERSED) ALT = -Alt;
- RefPlane = Handle(Geom_Plane)::DownCast
- (RefPlane->Translated( ALT * gp_Vec(RefPlane->Axis().Direction() )));
+ if (fabs(Alt) > gp::Resolution()) {
+ Standard_Real anAlt = Alt;
+ if ( myWorkSpine.Orientation() == TopAbs_REVERSED) anAlt = -Alt;
+ RefPlane = Handle(Geom_Plane)::DownCast
+ (RefPlane->Translated( anAlt * gp_Vec(RefPlane->Axis().Direction() )));
+ }
//---------------------------------------------------------------
// Construction of Circles and OffsetCurves
TopExp::Vertices(theWire, Ends[0], Ends[1]);
}
+ if (Locus.NumberOfContours() == 0)
+ {
+ return;
+ }
+
for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) {
TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic)));
TopoDS_Shape& PE = PEE ;
}
}
+ //Remove possible hanging arcs on vertices
+ if (myIsOpenResult && myJoinType == GeomAbs_Arc)
+ {
+ if (!myMap.IsEmpty() &&
+ myMap.FindKey(1).ShapeType() == TopAbs_VERTEX)
+ {
+ myMap.RemoveFromIndex(1);
+ }
+ if (!myMap.IsEmpty() &&
+ myMap.FindKey(myMap.Extent()).ShapeType() == TopAbs_VERTEX)
+ myMap.RemoveLast();
+ }
#ifdef OCCT_DEBUG
#ifdef DRAW
if (AffichEdge) {
- cout << " End Construction of geometric primitives "<<endl;
+ std::cout << " End Construction of geometric primitives "<<std::endl;
}
#endif
#endif
// MapNodeVertex,VE);
}
+ if (myJoinType == GeomAbs_Intersection)
+ StartOnEdge = EndOnEdge = 0;
+
//---------------------------------------------
// Construction of geometries.
//---------------------------------------------
// Construction of vertices on edges parallel to the spine.
//-----------------------------------------------------------
- Trim.IntersectWith(E [0], E [1], Params);
+ Trim.IntersectWith(E[0], E[1], S[0], S[1], Ends[0], Ends[1],
+ myJoinType, myIsOpenResult, Params);
for (Standard_Integer s = 1; s <= Params.Length(); s++) {
TopoDS_Vertex VC;
#ifdef OCCT_DEBUG
#ifdef DRAW
if (AffichEdge) {
- cout << " End Construction of vertices on offsets"<<endl;
+ std::cout << " End Construction of vertices on offsets"<<std::endl;
}
#endif
#endif
myMap(j).Clear();
if (MapBis.IsBound(CurrentEdge)) {
- TopTools_SequenceOfShape S;
+ TopTools_SequenceOfShape aSeqOfShape;
if (!MapBis(CurrentEdge).IsEmpty()) {
Standard_Integer IndOfE = 0;
if (myIsOpenResult)
Detromp (CurrentSpine),
MapBis (CurrentEdge) ,
MapVerPar(CurrentEdge) ,
- S, MapVV, IndOfE);
- for ( k = 1; k <= S.Length(); k++) {
- myMap(j).Append(S.Value(k));
+ aSeqOfShape, MapVV, IndOfE);
+ for ( k = 1; k <= aSeqOfShape.Length(); k++) {
+ myMap(j).Append(aSeqOfShape.Value(k));
}
}
else {
TopExp_Explorer Explo( myShape, TopAbs_EDGE );
for (; Explo.More(); Explo.Next())
{
- TopoDS_Edge E = TopoDS::Edge( Explo.Current() );
+ TopoDS_Edge anEdge = TopoDS::Edge( Explo.Current() );
TopoDS_Vertex V1, V2;
- TopExp::Vertices( E, V1, V2 );
+ TopExp::Vertices(anEdge, V1, V2 );
Handle(BRep_TVertex)& TV1 = *((Handle(BRep_TVertex)*) &(V1).TShape());
Handle(BRep_TVertex)& TV2 = *((Handle(BRep_TVertex)*) &(V2).TShape());
TopLoc_Location loc;
Standard_Real f, l;
- Handle( Geom_Curve ) theCurve = BRep_Tool::Curve( E, loc, f, l );
+ Handle( Geom_Curve ) theCurve = BRep_Tool::Curve(anEdge, loc, f, l );
theCurve = Handle( Geom_Curve )::DownCast( theCurve->Copy() );
theCurve->Transform( loc.Transformation() );
gp_Pnt f3d = theCurve->Value( f );
TV2->UpdateTolerance( 1.5*dist2 );
}
- FixHoles();
+ if (!myIsOpenResult)
+ FixHoles();
myIsDone = Standard_True;
}
const BRepFill_TrimEdgeTool& Trim) const
{
Standard_Integer ii = 1;
- Standard_Real U1,U2;
- TopoDS_Vertex V1,V2;
- Handle(Geom2d_Curve) Bis = Bisec.Value();
+ if (myJoinType == GeomAbs_Intersection)
+ {
+ for (; ii <= Vertices.Length(); ii++)
+ {
+ const TopoDS_Vertex& aVertex = TopoDS::Vertex(Vertices.Value(ii));
+ Detromp(Shape1).Append(aVertex);
+ Detromp(Shape2).Append(aVertex);
+ }
+ }
+ else //myJoinType == GeomAbs_Arc
+ {
+ Standard_Real U1,U2;
+ TopoDS_Vertex V1,V2;
+
+ const Handle(Geom2d_Curve)& Bis = Bisec.Value();
+ Standard_Boolean ForceAdd = Standard_False;
+ Handle(Geom2d_TrimmedCurve) aTC = Handle(Geom2d_TrimmedCurve)::DownCast(Bis);
+ if(!aTC.IsNull() && aTC->BasisCurve()->IsPeriodic())
+ {
+ gp_Pnt2d Pf = Bis->Value(Bis->FirstParameter());
+ gp_Pnt2d Pl = Bis->Value(Bis->LastParameter());
+ ForceAdd = Pf.Distance(Pl) <= Precision::Confusion();
+ }
- U1 = Bis->FirstParameter();
-
- if (SOnE) {
- // the first point of the bissectrice is on the offset
- V1 = TopoDS::Vertex(Vertices.Value(ii));
- ii++;
- }
-
- while (ii <= Vertices.Length()) {
- U2 = Params.Value(ii).X();
- V2 = TopoDS::Vertex(Vertices.Value(ii));
-
- gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
- Standard_Boolean IsP_inside = Standard_True;
- if ((myJoinType != GeomAbs_Intersection) || EOnE)
- IsP_inside = Trim.IsInside(P);
- if (!IsP_inside) {
- if (!V1.IsNull()) {
- Detromp(Shape1).Append(V1);
- Detromp(Shape2).Append(V1);
- }
- Detromp(Shape1).Append(V2);
- Detromp(Shape2).Append(V2);
- }
- U1 = U2;
- V1 = V2;
- ii ++;
- }
-
- // test medium point between the last parameter and the end of the bissectrice.
- U2 = Bis->LastParameter();
- if (!EOnE) {
- if (!Precision::IsInfinite(U2)) {
- gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
- Standard_Boolean IsP_inside = Standard_False;
- if (myJoinType == GeomAbs_Arc)
- IsP_inside = Trim.IsInside(P);
- if (!IsP_inside) {
+ U1 = Bis->FirstParameter();
+
+ if (SOnE) {
+ // the first point of the bissectrice is on the offset
+ V1 = TopoDS::Vertex(Vertices.Value(ii));
+ ii++;
+ }
+
+ while (ii <= Vertices.Length()) {
+ U2 = Params.Value(ii).X();
+ V2 = TopoDS::Vertex(Vertices.Value(ii));
+
+ gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
+ if (!Trim.IsInside(P) || ForceAdd) {
if (!V1.IsNull()) {
Detromp(Shape1).Append(V1);
Detromp(Shape2).Append(V1);
}
+ Detromp(Shape1).Append(V2);
+ Detromp(Shape2).Append(V2);
}
+ U1 = U2;
+ V1 = V2;
+ ii ++;
}
- else {
- if (!V1.IsNull()) {
- Detromp(Shape1).Append(V1);
- Detromp(Shape2).Append(V1);
+
+ // test medium point between the last parameter and the end of the bissectrice.
+ U2 = Bis->LastParameter();
+ if (!EOnE) {
+ if (!Precision::IsInfinite(U2)) {
+ gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);
+ if (!Trim.IsInside(P) || ForceAdd) {
+ if (!V1.IsNull()) {
+ Detromp(Shape1).Append(V1);
+ Detromp(Shape2).Append(V1);
+ }
+ }
}
- }
- }
- //else if(myJoinType != GeomAbs_Arc)
- //{
- // if (!V1.IsNull()) {
- // Detromp(Shape1).Append(V1);
- // Detromp(Shape2).Append(V1);
- // }
- //}
+ else {
+ if (!V1.IsNull()) {
+ Detromp(Shape1).Append(V1);
+ Detromp(Shape2).Append(V1);
+ }
+ }
+ }
+ //else if(myJoinType != GeomAbs_Arc)
+ //{
+ // if (!V1.IsNull()) {
+ // Detromp(Shape1).Append(V1);
+ // Detromp(Shape2).Append(V1);
+ // }
+ //}
+ } //end of else (myJoinType==GeomAbs_Arc)
}
//=======================================================================
TopExp::Vertices (E,V1,V2);
if (V1.IsSame(V2) && IsSmallClosedEdge(E, V1))
continue; //remove small closed edges
+ if (!CheckSmallParamOnEdge(E))
+ continue;
if (!MVE.Contains(V1)) {
TopTools_ListOfShape empty;
MVE.Add(V1,empty);
CV = VF = TopoDS::Vertex(MVE.FindKey(i));
CE = TopoDS::Edge(MVE(i).First());
End = Standard_False;
- MVE.ChangeFromKey(CV).RemoveFirst();
+ MVE.ChangeFromKey(CV).RemoveFirst();
+
+ if (myIsOpenResult && MVE.FindFromKey(CV).IsEmpty())
+ {
+ MVE.RemoveKey(CV);
+ }
+
// Modified by Sergey KHROMOV - Thu Mar 14 11:29:59 2002 Begin
Standard_Boolean isClosed = Standard_False;
isClosed = VF.IsSame(CV);
// Modified by Sergey KHROMOV - Thu Mar 14 11:30:15 2002 End
End = Standard_True;
- //MVE.UnBind(VF);
- TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent());
- TopTools_ListOfShape LastList;
- LastList.Append(MVE(MVE.Extent()));
- MVE.RemoveLast();
- if (MVE.FindIndex(VF) != 0)
- MVE.Substitute(MVE.FindIndex(VF), LastShape, LastList);
+ MVE.RemoveKey(VF);
}
if (!End) {
if (MVE.FindFromKey(CV).Extent() > 2) {
- //cout <<"vertex on more that 2 edges in a face."<<endl;
+ //std::cout <<"vertex on more that 2 edges in a face."<<std::endl;
}
for ( itl.Initialize(MVE.FindFromKey(CV)); itl.More(); itl.Next()) {
if (itl.Value().IsSame(CE)) {
CE = TopoDS::Edge(MVE.FindFromKey(CV).First());
MVE.ChangeFromKey(CV).RemoveFirst();
}
+ else if (myIsOpenResult)//CV was a vertex with one edge
+ End = Standard_True;
+
if (MVE.FindFromKey(CV).IsEmpty())
{
- //MVE.UnBind(CV);
- TopoDS_Shape LastShape = MVE.FindKey(MVE.Extent());
- TopTools_ListOfShape LastList;
- LastList.Append(MVE(MVE.Extent()));
- MVE.RemoveLast();
- if (MVE.FindIndex(CV) != 0)
- MVE.Substitute(MVE.FindIndex(CV), LastShape, LastList);
+ MVE.RemoveKey(CV);
}
}
}
TopTools_SequenceOfShape ClosedWires, UnclosedWires, IsolatedWires;
Standard_Real MaxTol = 0.;
- Standard_Integer i;
BRep_Builder BB;
TopExp_Explorer Explo( mySpine, TopAbs_VERTEX );
TopExp::Vertices( Base, Vf, Vl );
if(Vf.IsNull() || Vl.IsNull())
{
- Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
-#ifdef OCCT_DEBUG
- BRepTools::Write(Base, "Base");
-#endif
+ throw Standard_Failure("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
}
gp_Pnt Pf, Pl;
Pf = BRep_Tool::Pnt(Vf);
Pl = BRep_Tool::Pnt(Vl);
Standard_Real DistF = RealLast(), DistL = RealLast();
- Standard_Integer IndexF = 1, IndexL = 1;
+ Standard_Integer IndexF = 0, IndexL = 0;
Standard_Boolean IsFirstF = Standard_False, IsFirstL = Standard_False;
for (Standard_Integer i = 2; i <= UnclosedWires.Length(); i++)
{
if(V1.IsNull() || V2.IsNull())
{
- Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
-#ifdef OCCT_DEBUG
- BRepTools::Write(Base, "Base");
- char name[128];
- sprintf(name,"Wire_%d",i);
- BRepTools::Write(aWire, name);
-#endif
+ throw Standard_Failure("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
}
gp_Pnt P1, P2;
IsFirstL = Standard_False;
}
}
+ if (DistF > MaxTol)
+ IndexF = 0;
+ if (DistL > MaxTol)
+ IndexL = 0;
TopoDS_Wire theWire;
TopoDS_Edge theEdge;
TopoDS_Vertex theVertex;
{
TopoDS_Compound R;
BB.MakeCompound( R );
+ Standard_Integer i;
for (i = 1; i <= ClosedWires.Length(); i++)
BB.Add( R, ClosedWires(i) );
for (i = 1; i <= IsolatedWires.Length(); i++)
Standard_Real f,l;
Standard_Real anOffset = Offset;
- if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1;
+ if (E.Orientation() == TopAbs_FORWARD) anOffset *= -1;
Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l);
Handle(Geom2d_Curve) G2dOC;
gp_Dir2d Xd = axes.XDirection();
gp_Dir2d Yd = axes.YDirection();
Standard_Real Crossed = Xd.X()*Yd.Y()-Xd.Y()*Yd.X();
- Standard_Real Signe = ( Crossed > 0.) ? 1. : -1.;
+ Standard_Real Signe = ( Crossed > 0.) ? -1. : 1.;
if (anOffset*Signe < AC.Circle().Radius() - Precision::Confusion()) {
Handle(Geom2dAdaptor_HCurve) AHC =
new Geom2dAdaptor_HCurve(G2d);
- Adaptor3d_OffsetCurve Off(AHC,-anOffset);
- Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle());
+ Adaptor2d_OffsetCurve Off(AHC, anOffset);
+ Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle());
Standard_Real Delta = 2*M_PI - l + f;
if (theJoinType == GeomAbs_Arc)
else if (AC.GetType() == GeomAbs_Line) {
Handle(Geom2dAdaptor_HCurve) AHC =
new Geom2dAdaptor_HCurve(G2d);
- Adaptor3d_OffsetCurve Off(AHC,anOffset);
+ Adaptor2d_OffsetCurve Off(AHC, anOffset);
Handle(Geom2d_Line) CC = new Geom2d_Line(Off.Line());
Standard_Real Delta = (l - f);
if (ToExtendFirstPar)
}
else {
- anOffset = -anOffset;
Handle(Geom2d_TrimmedCurve) G2dT = new Geom2d_TrimmedCurve(G2d,f,l);
G2dOC = new Geom2d_OffsetCurve( G2dT, anOffset);
// otherwise preserve only one of its representations.
//----------------------------------------------------------
if (!BRep_Tool::Degenerated(E)) {
+ Standard_Real aParTol = 2.0 * Precision::PConfusion();
for (Standard_Integer k = 1; k < TheVer.Length(); k ++) {
if (TheVer.Value(k).IsSame(TheVer.Value(k+1)) ||
-
- Abs(ThePar.Value(k)-ThePar.Value(k+1)) <= Precision::PConfusion()) {
+ Abs(ThePar.Value(k)-ThePar.Value(k+1)) <= aParTol) {
if(k+1 == TheVer.Length()) {
StoreInMap(TheVer(k), TheVer(k+1), MapVV);
if (aMap.Contains(SE)) {
- //cout << "Edge is treated second time" << endl;
+ //std::cout << "Edge is treated second time" << std::endl;
continue;
}
}
}
+Standard_Boolean CheckSmallParamOnEdge(const TopoDS_Edge& anEdge)
+{
+ const BRep_ListOfCurveRepresentation& aList = ((Handle(BRep_TEdge)::DownCast(anEdge.TShape()))->Curves());
+ if (!aList.IsEmpty())
+ {
+ Handle( BRep_CurveRepresentation ) CRep = ((Handle(BRep_TEdge)::DownCast(anEdge.TShape()))->Curves()).First();
+ Standard_Real f = (Handle(BRep_GCurve)::DownCast(CRep))->First();
+ Standard_Real l = (Handle(BRep_GCurve)::DownCast(CRep))->Last();
+ if (Abs (l - f) < Precision::PConfusion())
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+