#include <BOPAlgo_PaveFiller.hxx>
#include <BOPCol_ListOfShape.hxx>
#include <BRep_Builder.hxx>
+#include <BRepAdaptor_Curve.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
#include <NCollection_IndexedMap.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Compound.hxx>
return false;
}
-void EdgeDiscretization( const TopoDS_Edge& theEdge,
+int HashCode( const gp_Pnt& thePoint, const Standard_Integer theUpper )
+{
+ int aHashX = HashCode( thePoint.X(), theUpper );
+ int aHashY = HashCode( thePoint.Y(), theUpper );
+ return (aHashX^aHashY)%theUpper;
+}
+
+bool operator == ( const gp_Pnt& thePoint1, const gp_Pnt& thePoint2 )
+{
+ return thePoint1.IsEqual( thePoint2, Precision::Confusion() );
+}
+
+bool EdgeDiscretization( const TopoDS_Edge& theEdge,
+ Standard_Real theDeflection,
NCollection_IndexedMap<gp_Pnt>& theVerticesMap,
QList<int>& theVerticesIds )
{
- //TODO
+ BRepAdaptor_Curve aCurve( theEdge );
+ GCPnts_QuasiUniformDeflection aDiscrete( aCurve, theDeflection );
+ if( !aDiscrete.IsDone() )
+ return false;
+
+ int n = aDiscrete.NbPoints();
+ for( int i=1; i<=n; i++ )
+ {
+ gp_Pnt aPnt = aDiscrete.Value( i );
+ int anId;
+ if( theVerticesMap.Contains( aPnt ) )
+ anId = theVerticesMap.FindIndex( aPnt );
+ else
+ {
+ anId = theVerticesMap.Size();
+ theVerticesMap.Add( aPnt );
+ }
+ theVerticesIds.append( anId );
+ }
+ return true;
}
/**
@param theFileName the name of file
@return if the export is successful
*/
-bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName ) const
+bool HYDROData_LandCoverMap::ExportTelemac( const QString& theFileName, Standard_Real theDeflection ) const
{
TopoDS_Shell aShell; //TODO: unite all the faces of land covers into the shell
{
TopoDS_Edge anEdge = TopoDS::Edge( anExp1.Current() );
QList<int> aVerticesIdsList;
- EdgeDiscretization( anEdge, aVerticesMap, aVerticesIdsList );
- anEdgesMap.Add( anEdge, aVerticesIdsList );
+ if( EdgeDiscretization( anEdge, theDeflection, aVerticesMap, aVerticesIdsList ) )
+ anEdgesMap.Add( anEdge, aVerticesIdsList );
}
// add into the map all faces existing in the shell and correspondence between face and edges ids
// 2. to fuse the faces into the new face
/*BOPAlgo_PaveFiller aPF;
aPF.SetArguments( theFaces );
- aPF.SetFuzzyValue( 1E-2 );
+ aPF.SetFuzzyValue( 1E-5 );
aPF.SetRunParallel( Standard_False );
aPF.Perform();
int iErr = aPF.ErrorStatus();