+ if (theDBFValues.size() != theStricklerTypes.size())
+ return DBFStatus_DIFF_SIZE_ERROR;
+ HYDROData_ShapeFile aDBFImporter;
+ if (!aDBFImporter.DBF_OpenDBF(theDBFFileName))
+ return DBFStatus_OPEN_FILE_ERROR; //cant open file
+
+ QStringList FieldList = aDBFImporter.DBF_GetFieldList();
+ int FieldNameIndex = FieldList.indexOf(theFieldName);
+ if (FieldNameIndex == -1)
+ return DBFStatus_NO_SUCH_FIELD_ERROR; //no such field
+
+ std::vector<HYDROData_ShapeFile::DBF_AttrValue> theAttrV;
+ aDBFImporter.DBF_GetAttributeList(FieldNameIndex, theAttrV );
+
+ bool allOK = true;
+ Explorer anIt( *this );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ int CurIndex = anIt.Index();
+ HYDROData_ShapeFile::DBF_AttrValue AValue = theAttrV[theIndices[CurIndex]];
+ int StricklerTypesInd = theDBFValues.indexOf(QString(AValue.myStrVal));
+ if ( StricklerTypesInd != -1)
+ anIt.SetStricklerType(theStricklerTypes[StricklerTypesInd]);
+ else
+ allOK = false;
+ }
+ if (allOK)
+ return DBFStatus_OK;
+ else
+ return DBFStatus_NO_DBFVALUES_CORRESPONDENCE_WARNING;
+}
+
+/**
+ Export attributes to DBF File
+///
+*/
+void HYDROData_LandCoverMap::ExportDBF( const QString& theDBFFileName,
+ const QString& theFieldName,
+ const QStringList& theDBFValues,
+ const QStringList& theStricklerTypes) const
+{
+ if (theDBFValues.size() != theStricklerTypes.size())
+ return;
+ HYDROData_ShapeFile anExporter;
+ std::vector<HYDROData_ShapeFile::DBF_AttrValue> theAttrV;
+ Explorer anIt( *this );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ QString CurST = anIt.StricklerType();
+ HYDROData_ShapeFile::DBF_AttrValue aCurAttrV;
+ aCurAttrV.myIsNull = false;
+ int StricklerTypesInd = theStricklerTypes.indexOf(CurST);
+ if (StricklerTypesInd != -1)
+ {
+ aCurAttrV.myStrVal = theDBFValues[StricklerTypesInd];
+ aCurAttrV.myFieldType = HYDROData_ShapeFile::DBF_FieldType_String;
+ theAttrV.push_back(aCurAttrV);
+ }
+ else
+ aCurAttrV.myIsNull = true;
+ }
+ //use actual str value; not the raw value
+ anExporter.DBF_WriteFieldAndValues(theDBFFileName, theFieldName, HYDROData_ShapeFile::DBF_FieldType_String, theAttrV, false);
+
+}
+
+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 )
+{
+ 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;