#include <TopoDS_Iterator.hxx>
#include <TopoDS_Shell.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <BOPAlgo_PaveFiller.hxx>
+#include <BRepTools.hxx>
+#include <TopExp_Explorer.hxx>
+#include <ShapeUpgrade_UnifySameDomain.hxx>
#include <QString>
Remove( theFaces );
// 2. to fuse the faces into the new face
- BOPAlgo_PaveFiller aPF;
+ /*BOPAlgo_PaveFiller aPF;
aPF.SetArguments( theFaces );
aPF.SetFuzzyValue( 1E-2 );
aPF.SetRunParallel( Standard_False );
TopoDS_Shape aMergedShape = aBOP.Shape();
if( aMergedShape.ShapeType()!=TopAbs_FACE )
- return false;
+ return false;*/
+
+
+ ////
+ TopoDS_Shape MergedFace;
+ MergeFaces(theFaces, true, MergedFace);
+ //BRepTools::Write(aMergedShape, "c:/sh_.brep");
// 3. to add the face into the map
- return LocalPartition( TopoDS::Face( aMergedShape ), theType );
+ return LocalPartition( TopoDS_Face( /*aMergedShape*/ ), theType );
+}
+
+bool HYDROData_LandCoverMap::MergeFaces(const TopTools_ListOfShape& theFaces, bool IsToUnify, TopoDS_Shape& outSh)
+{
+ int iErr;
+ TopTools_ListIteratorOfListOfShape aIt;
+ BOPCol_ListOfShape aLC;
+ aIt.Initialize(theFaces);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS=aIt.Value();
+ aLC.Append(aS);
+ }
+ BOPAlgo_PaveFiller aPF;
+ aPF.SetArguments(aLC);
+ aPF.SetRunParallel(Standard_False);
+ aPF.SetFuzzyValue(1e-02);
+
+ aPF.Perform();
+ iErr=aPF.ErrorStatus();
+ if (iErr)
+ return false;
+
+ BOPAlgo_Builder aBuilder;
+ aIt.Initialize(theFaces);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS=aIt.Value();
+ aBuilder.AddArgument(aS);
+ }
+
+ aBuilder.PerformWithFiller(aPF);
+ iErr = aBuilder.ErrorStatus();
+ if (iErr)
+ return false;
+ const TopoDS_Shape& aMergedShape=aBuilder.Shape();
+
+ //
+ BRep_Builder BB;
+ TopoDS_Shell she;
+ BB.MakeShell(she);
+ she.Closed(Standard_False);
+ TopExp_Explorer ff(aMergedShape, TopAbs_FACE);
+ for(; ff.More(); ff.Next())
+ {
+ const TopoDS_Face& F = TopoDS::Face(ff.Current());
+ if (F.IsNull())
+ continue;
+ if (F.ShapeType() == TopAbs_FACE) {
+ BB.Add(she, F);
+ she.Closed (Standard_False);
+ }
+ }
+
+ if (IsToUnify)
+ {
+ ShapeUpgrade_UnifySameDomain USD;
+ USD.Initialize(she);
+ USD.Build();
+ outSh = USD.Shape();
+ }
+ else
+ {
+ outSh = she;
+ }
+
+ ff.Init(outSh, TopAbs_FACE);
+ int i = 0;
+ TopoDS_Face OneF;
+ for(; ff.More(); ff.Next(), i++)
+ OneF = TopoDS::Face(ff.Current());
+ if (i == 1)
+ outSh = OneF;
+
+ return true;
+
}
/**
QString aType1, aType2;
gp_Pnt2d aPnt1( 25, 35 );
gp_Pnt2d aPnt2( 45, 55 );
+ //gp_Pnt2d aPnt3( 45, 10 );
+ //gp_Pnt2d aPnt4( 45, 80 );
TopTools_ListOfShape aList;
aList.Append( aMap->FindByPoint( aPnt1, aType1 ) );
aList.Append( aMap->FindByPoint( aPnt2, aType2 ) );
+ //aList.Append( aMap->FindByPoint( aPnt3, aType1 ) );
+ //aList.Append( aMap->FindByPoint( aPnt4, aType2 ) );
CPPUNIT_ASSERT_EQUAL( true, aMap->Merge( aList, "new" ) );
TestViewer::show( aMap->GetShape(), AIS_Shaded, true );
- //TestViewer::show( BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge(), QColor( Qt::black ), AIS_Shaded );
+ //TestViewer::show( BRepBuilderAPI_MakeEdge( gp_Pnt(aPnt1.X(), aPnt1.Y(), 0), gp_Pnt(aPnt2.X(), aPnt2.Y(), 0) ).Edge(), QColor( Qt::blue ), AIS_Shaded );
TestViewer::AssertEqual( "LandCoverMap_Merge_1" );
aDoc->Close();