#include <TopTools_MapOfShape.hxx>
//
-static void Correct2dPoint(const Adaptor3d_Surface& theS, gp_Pnt2d& theP2d);
+static void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d);
//
static BRepOffset_Type DefineConnectType(const TopoDS_Edge& E,
const TopoDS_Face& F1,
//function : Correct2dPoint
//purpose :
//=======================================================================
-void Correct2dPoint(const Adaptor3d_Surface& theS, gp_Pnt2d& theP2d)
+void Correct2dPoint(const TopoDS_Face& theF, gp_Pnt2d& theP2d)
{
+ BRepAdaptor_Surface aBAS(theF, Standard_False);
+ if (aBAS.GetType() < GeomAbs_BezierSurface) {
+ return;
+ }
+ //
const Standard_Real coeff = 0.01;
Standard_Real eps;
Standard_Real u1, u2, v1, v2;
- if(theS.GetType() >= GeomAbs_BezierSurface)
+ //
+ aBAS.Initialize(theF, Standard_True);
+ u1 = aBAS.FirstUParameter();
+ u2 = aBAS.LastUParameter();
+ v1 = aBAS.FirstVParameter();
+ v2 = aBAS.LastVParameter();
+ if (!(Precision::IsInfinite(u1) || Precision::IsInfinite(u2)))
{
- u1 = theS.FirstUParameter();
- u2 = theS.LastUParameter();
- v1 = theS.FirstVParameter();
- v2 = theS.LastVParameter();
- if(!(Precision::IsInfinite(u1) || Precision::IsInfinite(u2)))
+ eps = Max(coeff*(u2 - u1), Precision::PConfusion());
+ if (Abs(theP2d.X() - u1) < eps)
{
- eps = Max(coeff*(u2-u1), Precision::PConfusion());
- if(Abs(theP2d.X()-u1) < eps)
- {
- theP2d.SetX(u1 + eps);
- }
- if(Abs(theP2d.X()-u2) < eps)
- {
- theP2d.SetX(u2 - eps);
- }
+ theP2d.SetX(u1 + eps);
}
- if(!(Precision::IsInfinite(v1) || Precision::IsInfinite(v2)))
+ if (Abs(theP2d.X() - u2) < eps)
{
- eps = Max(coeff*(v2-v1), Precision::PConfusion());
- if(Abs(theP2d.Y()-v1) < eps)
- {
- theP2d.SetY(v1 + eps);
- }
- if(Abs(theP2d.Y()-v2) < eps)
- {
- theP2d.SetY(v2 - eps);
- }
+ theP2d.SetX(u2 - eps);
+ }
+ }
+ if (!(Precision::IsInfinite(v1) || Precision::IsInfinite(v2)))
+ {
+ eps = Max(coeff*(v2 - v1), Precision::PConfusion());
+ if (Abs(theP2d.Y() - v1) < eps)
+ {
+ theP2d.SetY(v1 + eps);
+ }
+ if (Abs(theP2d.Y() - v2) < eps)
+ {
+ theP2d.SetY(v2 - eps);
}
}
}
//function : DefineConnectType
//purpose :
//=======================================================================
-BRepOffset_Type DefineConnectType(const TopoDS_Edge& E,
- const TopoDS_Face& F1,
- const TopoDS_Face& F2,
- const Standard_Real SinTol,
- const Standard_Boolean CorrectPoint)
+BRepOffset_Type DefineConnectType(const TopoDS_Edge& E,
+ const TopoDS_Face& F1,
+ const TopoDS_Face& F2,
+ const Standard_Real SinTol,
+ const Standard_Boolean CorrectPoint)
{
TopLoc_Location L;
Standard_Real f,l;
- BRepAdaptor_Surface S1(F1), S2(F2);
+ const Handle(Geom_Surface)& S1 = BRep_Tool::Surface(F1);
+ const Handle(Geom_Surface)& S2 = BRep_Tool::Surface(F2);
+ //
Handle (Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E,F1,f,l);
Handle (Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E,F2,f,l);
gp_Vec D1U,D1V;
if(CorrectPoint)
- Correct2dPoint(S1, P);
+ Correct2dPoint(F1, P);
//
- S1.D1(P.X(),P.Y(),P3,D1U,D1V);
+ S1->D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN1(D1U^D1V);
if (F1.Orientation() == TopAbs_REVERSED) DN1.Reverse();
P = C2->Value(ParOnC);
if(CorrectPoint)
- Correct2dPoint(S2, P);
- S2.D1(P.X(),P.Y(),P3,D1U,D1V);
+ Correct2dPoint(F2, P);
+ S2->D1(P.X(),P.Y(),P3,D1U,D1V);
gp_Vec DN2(D1U^D1V);
if (F2.Orientation() == TopAbs_REVERSED) DN2.Reverse();
#include <BOPAlgo_Builder.hxx>
#include <BOPAlgo_Section.hxx>
#include <BOPAlgo_MakerVolume.hxx>
+#include <BOPAlgo_BuilderFace.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BOPCol_DataMapOfShapeShape.hxx>
#include <BOPTools.hxx>
#include <BOPTools_AlgoTools3D.hxx>
#include <BOPTools_AlgoTools.hxx>
+#include <BOPTools_AlgoTools2D.hxx>
#include <IntTools_Context.hxx>
#include <IntTools_ShrunkRange.hxx>
TopoDS_Shape& theEdges,
TopTools_IndexedMapOfShape& theInv);
+static
+ void BuildSplitsOfTrimmedFace(const TopoDS_Face& theFace,
+ const TopoDS_Shape& theEdges,
+ TopTools_ListOfShape& theLFImages);
+
static
void BuildSplitsOfFace(const TopoDS_Face& theFace,
const TopoDS_Shape& theEdges,
- Standard_Boolean bTrimmed,
TopTools_DataMapOfShapeShape& theOrigins,
TopTools_ListOfShape& theLFImages);
const TopoDS_Shape& theSolids,
const TopTools_IndexedMapOfShape& theInvEdges,
const TopTools_MapOfShape& theInvertedEdges,
+ const TopTools_MapOfShape& theMEInvOnArt,
TopTools_MapOfShape& theMECheckExt,
TopTools_IndexedMapOfShape& theEdgesToAvoid,
TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
const TopTools_DataMapOfShapeListOfShape& theMELF,
const TopTools_DataMapOfShapeListOfShape& theEImages,
const TopTools_MapOfShape& theMECheckExt,
+ const TopTools_MapOfShape& theMEInvOnArt,
TopTools_MapOfShape& theVertsToAvoid,
TopTools_MapOfShape& theMEInv);
continue;
}
//
- BuildSplitsOfFace(aF, aCE, Standard_True, anEmptyDMSS, aLFImages);
+ BuildSplitsOfTrimmedFace(aF, aCE, aLFImages);
aDMFFIm.Add(aF, aLFImages);
}
// Fill history for faces and edges
//
// build splits
TopTools_ListOfShape aLFImages;
- BuildSplitsOfFace(aF, aCE, Standard_False, theFacesOrigins, aLFImages);
+ BuildSplitsOfFace(aF, aCE, theFacesOrigins, aLFImages);
//
if (aMapEInv.Extent()) {
// check if all possible faces are built
}
//
TopTools_ListOfShape aLFImages1;
- BuildSplitsOfFace(aF, aCE1, Standard_False, theFacesOrigins, aLFImages1);
+ BuildSplitsOfFace(aF, aCE1, theFacesOrigins, aLFImages1);
//
// check if the rebuilding has added some new faces to the splits
for (TopTools_ListIteratorOfListOfShape aItLFIm(aLFImages1); aItLFIm.More();)
//=======================================================================
void BuildSplitsOfFace(const TopoDS_Face& theFace,
const TopoDS_Shape& theEdges,
- Standard_Boolean bTrimmed,
TopTools_DataMapOfShapeShape& theFacesOrigins,
TopTools_ListOfShape& theLFImages)
+{
+ theLFImages.Clear();
+ //
+ // take edges to split the face
+ BOPCol_ListOfShape aLE;
+ TopExp_Explorer aExp(theEdges, TopAbs_EDGE);
+ for (; aExp.More(); aExp.Next()) {
+ TopoDS_Edge aE = TopoDS::Edge(aExp.Current());
+ aE.Orientation(TopAbs_FORWARD);
+ aLE.Append(aE);
+ aE.Orientation(TopAbs_REVERSED);
+ aLE.Append(aE);
+ }
+ //
+ TopoDS_Face aFF = theFace;
+ TopAbs_Orientation anOr = theFace.Orientation();
+ aFF.Orientation(TopAbs_FORWARD);
+ //
+ // build pcurves for edges on the face
+ BOPTools_AlgoTools2D::BuildPCurveForEdgesOnPlane(aLE, aFF);
+ //
+ // build splits of faces
+ BOPAlgo_BuilderFace aBF;
+ aBF.SetFace(aFF);
+ aBF.SetShapes(aLE);
+ aBF.Perform();
+ //
+ const BOPCol_ListOfShape& aLFSp = aBF.Areas();
+ BOPCol_ListIteratorOfListOfShape aItLF(aLFSp);
+ for (; aItLF.More(); aItLF.Next()) {
+ TopoDS_Shape& aFSp = aItLF.ChangeValue();
+ aFSp.Orientation(anOr);
+ theLFImages.Append(aFSp);
+ //
+ theFacesOrigins.Bind(aFSp, theFace);
+ }
+}
+
+//=======================================================================
+//function : BuildSplitsOfFace
+//purpose : Building the splits of offset face
+//=======================================================================
+void BuildSplitsOfTrimmedFace(const TopoDS_Face& theFace,
+ const TopoDS_Shape& theEdges,
+ TopTools_ListOfShape& theLFImages)
{
BOPAlgo_Builder aGF;
//
//
// splits of the offset shape
theLFImages = aGF.Modified(theFace);
- if (theLFImages.IsEmpty()) {
- return;
- }
- //
- if (!bTrimmed) {
- // get the real splits of faces by removing the faces
- // containing boundaries of the extended faces
-
- // get edges to map
- TopTools_IndexedMapOfShape aME;
- TopExp::MapShapes(theEdges, TopAbs_EDGE, aME);
- //
- TopTools_ListIteratorOfListOfShape aItLE(theLFImages);
- for (; aItLE.More();) {
- const TopoDS_Face& aFIm = *(TopoDS_Face*)&aItLE.Value();
- //
- TopExp_Explorer aExp(aFIm, TopAbs_EDGE);
- for (; aExp.More(); aExp.Next()) {
- const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExp.Current();
- if (!aME.Contains(aE)) {
- break;
- }
- }
- //
- if (!aExp.More()) {
- aItLE.Next();
- }
- else {
- theLFImages.Remove(aItLE);
- }
- }
- }
- // update origins
- TopTools_ListIteratorOfListOfShape aIt(theLFImages);
- for (; aIt.More(); aIt.Next()) {
- const TopoDS_Shape& aFIm = aIt.Value();
- theFacesOrigins.Bind(aFIm, theFace);
- }
}
//=======================================================================
!(bHasValid || bAllValid) &&
!(bAllInvNeutral && (aNbChecked == 1)))) {
theInvFaces.Append(aFIm);
+ aItLF.Next();
+ continue;
}
//
if (!bAllInvNeutral) {
BOPTools_AlgoTools::MakeConnexityBlocks(aCFArt, TopAbs_VERTEX, TopAbs_FACE, aLCBArt);
//
// alone edges
- TopTools_MapOfShape aMEAlone;
+ TopTools_MapOfShape aMEAlone, aMEInvOnArt;
//
TopTools_ListIteratorOfListOfShape aItLCBArt(aLCBArt);
for (; aItLCBArt.More(); aItLCBArt.Next()) {
for (; aExpE.More(); aExpE.Next()) {
const TopoDS_Shape& aE = aExpE.Current();
if (theInvEdges.Contains(aE)) {
+ aMEInvOnArt.Add(aE);
for (TopoDS_Iterator aItV(aE); aItV.More(); aItV.Next()) {
aMVEInv.Add(aItV.Value());
}
}
//
// filter the obtained edges
- UpdateValidEdges(theFImages, aFLE, aMVBounds, theSolids, theInvEdges, theInvertedEdges,
+ UpdateValidEdges(theFImages, aFLE, aMVBounds, theSolids, theInvEdges, theInvertedEdges, aMEInvOnArt,
aMECheckExt, theEdgesToAvoid, theEdgesOrigins, theOEImages, theOEOrigins,
theVertsToAvoid, theETrimEInf, aEImages, aDMEETrim, theModifiedEdges, theAsDes);
}
const TopoDS_Shape& theSolids,
const TopTools_IndexedMapOfShape& theInvEdges,
const TopTools_MapOfShape& theInvertedEdges,
+ const TopTools_MapOfShape& theMEInvOnArt,
TopTools_MapOfShape& theMECheckExt,
TopTools_IndexedMapOfShape& theEdgesToAvoid,
TopTools_DataMapOfShapeListOfShape& theEdgesOrigins,
TopTools_MapOfShape aMEInv;
GetInvalidEdgesByBounds(aSplits1, aFilterBounds, theFImages, theSolids,
theInvEdges, aMVOld, aMENew, aDMEOr, aMELF, theEImages,
- theMECheckExt, theVertsToAvoid, aMEInv);
+ theMECheckExt, theMEInvOnArt, theVertsToAvoid, aMEInv);
//
// get valid edges only
TopoDS_Shape aSplits;
TopoDS_Shape aCEIm;
TopTools_MapOfShape aMEVBounds;
//
- if (aLEIm.Extent() > 2) {
+ if (aLEIm.Extent() > 1) {
TopTools_IndexedMapOfShape aMV;
// fuse these parts
BOPAlgo_Builder aGFE;
const TopTools_DataMapOfShapeListOfShape& theMELF,
const TopTools_DataMapOfShapeListOfShape& theEImages,
const TopTools_MapOfShape& theMECheckExt,
+ const TopTools_MapOfShape& theMEInvOnArt,
TopTools_MapOfShape& theVertsToAvoid,
TopTools_MapOfShape& theMEInv)
{
+ // map splits to check the vertices of edges
+ TopTools_IndexedDataMapOfShapeListOfShape aDMVE;
+ TopExp::MapShapesAndAncestors(theSplits, TopAbs_VERTEX, TopAbs_EDGE, aDMVE);
+ //
BOPAlgo_Section aSec;
aSec.AddArgument(theSplits);
aSec.AddArgument(theBounds);
theMEInv.Add(aE1);
}
//
+ if (theMEInvOnArt.Contains(aE2)) {
+ // avoid checking of the vertices of the split edge intersected by
+ // the invalid edge from artificial face
+ TopoDS_Vertex aV1, aV2;
+ TopExp::Vertices(TopoDS::Edge(aE2), aV1, aV2);
+ if (aDMVE.Contains(aV1) && aDMVE.Contains(aV2)) {
+ continue;
+ }
+ }
+ //
// add vertices of all images of the edge from splits for checking
const TopTools_ListOfShape& aLEOr = theDMEOr.Find(aE1);
TopTools_ListIteratorOfListOfShape aItLEOr(aLEOr);
}
}
//
- // map to check the vertices of edges
- TopTools_IndexedDataMapOfShapeListOfShape aDMVE;
- TopExp::MapShapesAndAncestors(theSplits, TopAbs_VERTEX, TopAbs_EDGE, aDMVE);
- //
// to avoid unnecessary filling of parts due to extra trim of the edges
// process Edge/Edge interferences of type EDGE, i.e. common blocks and check
// not the bounding vertices of the edges, but check the edge itself