#include <Handle_Geom_Line.hxx>
#include <Handle_Geom_TrimmedCurve.hxx>
#include <Geom_TrimmedCurve.hxx>
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <NCollection_DoubleMap.hxx>
#include <QFile>
aTypesMap.insert( anIt.Face().TShape(), anIt.StricklerType() );
}
- TopoDS_Shape aShape = MergeFaces( aListOfFaces, false );
+ TopoDS_Shape aShape = MergeFaces( aListOfFaces, false, NULL );
NCollection_IndexedMap<gp_Pnt> aVerticesMap;
NCollection_IndexedDataMap< TopoDS_Edge, QList<int> > anEdgesMap;
bool HYDROData_LandCoverMap::Merge( const TopTools_ListOfShape& theFaces, const QString& theType )
{
// 1. to fuse the faces into the new face
- TopoDS_Shape aMergedFace = MergeFaces( theFaces, true );
+ TopoDS_Shape aMergedFace = MergeFaces( theFaces, true, NULL );
bool aStat = true;
if( !aMergedFace.IsNull() )
{
@param theTolerance the operation's tolerance
@return result shape (face or shell)
*/
+
TopoDS_Shape HYDROData_LandCoverMap::MergeFaces( const TopTools_ListOfShape& theFaces,
- bool IsToUnify, double theTolerance )
+ bool IsToUnify,
+ TopTools_IndexedDataMapOfShapeListOfShape* theShHistory,
+ double theTolerance)
{
int anError;
TopTools_ListIteratorOfListOfShape anIt;
const TopoDS_Shape& aMergedShape = anAlgo.Shape();
+ // retrieve history of modifications
+ if (theShHistory)
+ {
+ theShHistory->Clear();
+ anIt.Initialize(theFaces);
+ for( ; anIt.More(); anIt.Next() )
+ {
+ const TopTools_ListOfShape aMLS = anAlgo.Modified( anIt.Value() );
+ theShHistory->Add(anIt.Value(), aMLS);
+ }
+ }
+ //
+
BRep_Builder aBuilder;
TopoDS_Shell aShell;
aBuilder.MakeShell( aShell );
{
TopTools_ListOfShape aListOfFaces;
- int n = theMap.Size();
-
- Handle( TDataStd_ExtStringArray ) aTypes =
- TDataStd_ExtStringArray::Set( myLab.FindChild( DataTag_Types ), 0, n-1, Standard_True );
-
- HYDROData_MapOfFaceToStricklerType::Iterator aNFIt( theMap );
- for( int i=0; aNFIt.More(); aNFIt.Next(), i++ )
+ for( int i = 1; i <= theMap.Extent(); i++ )
{
- TopoDS_Face aFace = aNFIt.Key();
+ TopoDS_Face aFace = theMap.FindKey(i);
if( aFace.IsNull() )
continue;
- QString aType = aNFIt.Value();
aListOfFaces.Append(aFace);
- aTypes->SetValue( i, HYDROData_Tool::toExtString( aType ) );
}
+ TopTools_IndexedDataMapOfShapeListOfShape ShHistory;
+
TopoDS_Shape aResult;
if( aListOfFaces.Extent() == 1 )
aResult = aListOfFaces.First();
else if( aListOfFaces.Extent() > 1 )
- aResult = MergeFaces( aListOfFaces, false );
+ aResult = MergeFaces( aListOfFaces, false, &ShHistory );
//remove internal edges
+ //if nothing changes => the result shape should be the same
+ //in any other case the history of modifications may be broken
aResult = RemoveInternal(aResult);
+
+ //one face => mark as unchanged
+ if( aListOfFaces.Extent() == 1 )
+ ShHistory.Add(aResult, TopTools_ListOfShape());
+
+ NCollection_IndexedDataMap<TopoDS_Face, QString> aChF2ST;
+ QStringList aSTypes;
+ //
+ for( int i = 1; i <= theMap.Extent(); i++ )
+ {
+ TopoDS_Face aFF = theMap.FindKey(i);
+ if( aFF.IsNull() )
+ continue;
+ TopTools_ListOfShape aLS = ShHistory.FindFromKey(aFF);
+ if (aLS.IsEmpty())
+ {
+ QString SType = theMap.FindFromKey(aFF);
+ aChF2ST.Add(aFF, SType);
+ }
+ else
+ {
+ TopTools_ListIteratorOfListOfShape anIt(aLS);
+ for (; anIt.More(); anIt.Next())
+ {
+ QString aSType = theMap.FindFromKey(aFF);
+ aChF2ST.Add(TopoDS::Face(anIt.Value()), aSType);
+ }
+ }
+ }
+ //
SetShape( aResult );
+ //
+ //Explorer Exp(*this);
+ TopExp_Explorer FExp(aResult, TopAbs_FACE);
+ for( ; FExp.More(); FExp.Next() )
+ {
+ TopoDS_Face aFace = TopoDS::Face(FExp.Current());
+ QString aST = "";
+ if (aChF2ST.Contains(aFace))
+ aST = aChF2ST.FindFromKey(aFace);
+ aSTypes << aST;
+ }
+
+ Handle( TDataStd_ExtStringArray ) aTypes = TDataStd_ExtStringArray::Set( myLab.FindChild( DataTag_Types ), 0, aSTypes.size() - 1, Standard_True );
+ int k = 0;
+ foreach (QString aST, aSTypes)
+ {
+ aTypes->SetValue( k, HYDROData_Tool::toExtString( aST ) );
+ k++;
+ }
+
}
/**
anEdgesToRemove.Append(CurEdge);
}
- Handle_ShapeBuild_ReShape aReshape = new ShapeBuild_ReShape();
- TopoDS_Shape OutSh = aReshape->Apply(InSh);
- TopTools_ListIteratorOfListOfShape aIt(anEdgesToRemove);
- for (; aIt.More(); aIt.Next())
- aReshape->Remove(aIt.Value());
- OutSh = aReshape->Apply(InSh);
-
- Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
- sfs->Init(OutSh);
- sfs->Perform();
- return sfs->Shape();
-
+ if (!anEdgesToRemove.IsEmpty())
+ {
+ Handle_ShapeBuild_ReShape aReshape = new ShapeBuild_ReShape();
+ TopoDS_Shape OutSh = aReshape->Apply(InSh);
+ TopTools_ListIteratorOfListOfShape aIt(anEdgesToRemove);
+ for (; aIt.More(); aIt.Next())
+ aReshape->Remove(aIt.Value());
+ OutSh = aReshape->Apply(InSh);
+
+ Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
+ sfs->Init(OutSh);
+ sfs->Perform();
+ return sfs->Shape();
+ }
+ else
+ return InSh;
}
void HYDROData_LandCoverMap::SetTransparency( double theTransparency )