#include <TopExp.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TDataStd_Integer.hxx>
//#define DEB_CALCULATION 1
#ifdef DEB_CALCULATION
QString aCalculName = GetObjPyName();
+ AssignmentMode aMode = GetAssignmentMode();
+ QString aModeStr = aMode==MANUAL ? "MANUAL" : "AUTOMATIC";
+ aResList << QString( "%0.SetAssignmentMode( %1 )" ).arg( aCalculName ).arg( aModeStr );
+
HYDROData_SequenceOfObjects aGeomObjects = GetGeometryObjects();
HYDROData_SequenceOfObjects::Iterator anIter( aGeomObjects );
for ( ; anIter.More(); anIter.Next() )
setPythonReferenceObject( theTreatedObjects, aResList, aBoundaryPolyline, "SetBoundaryPolyline" );
aResList << QString( "" );
+ if( aMode==AUTOMATIC )
+ DumpRulesToPython( aCalculName, aResList );
+
+ aResList << QString( "" );
aResList << QString( "%1.Update();" ).arg( aCalculName );
aResList << QString( "" );
- // Now we restore the regions and zones order
- HYDROData_SequenceOfObjects aRegions = GetRegions();
- anIter.Init( aRegions );
- for ( ; anIter.More(); anIter.Next() )
+ if( aMode==MANUAL )
{
- Handle(HYDROData_Region) aRegion =
- Handle(HYDROData_Region)::DownCast( anIter.Value() );
- if ( aRegion.IsNull() )
- continue;
-
- QString aRegionName = aRegion->GetName();
-
- HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
- HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
- for ( ; aZonesIter.More(); aZonesIter.Next() )
+ // Now we restore the regions and zones order
+ HYDROData_SequenceOfObjects aRegions = GetRegions();
+ anIter.Init( aRegions );
+ for ( ; anIter.More(); anIter.Next() )
{
- Handle(HYDROData_Zone) aRegZone =
- Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
- if ( aRegZone.IsNull() )
+ Handle(HYDROData_Region) aRegion =
+ Handle(HYDROData_Region)::DownCast( anIter.Value() );
+ if ( aRegion.IsNull() )
continue;
- // TODO
+ QString aRegionName = aRegion->GetName();
+
+ HYDROData_SequenceOfObjects aZones = aRegion->GetZones();
+ HYDROData_SequenceOfObjects::Iterator aZonesIter( aZones );
+ for ( ; aZonesIter.More(); aZonesIter.Next() )
+ {
+ Handle(HYDROData_Zone) aRegZone =
+ Handle(HYDROData_Zone)::DownCast( aZonesIter.Value() );
+ if ( aRegZone.IsNull() )
+ continue;
+
+ // TODO
+ }
}
}
- aResList << QString( "" );
+ aResList << QString( "" );
return aResList;
}
anEdgesList.append( aSplitData );
}
- //CreateRegionsDef( aDocument, aZonesList );
- CreateRegionsAuto( aDocument, aZonesList );
+ switch( GetAssignmentMode() )
+ {
+ case MANUAL:
+ CreateRegionsDef( aDocument, aZonesList );
+ break;
+ case AUTOMATIC:
+ CreateRegionsAuto( aDocument, aZonesList );
+ break;
+ }
CreateEdgeGroupsDef( aDocument, anEdgesList );
}
TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
return HYDROData_PriorityQueue::DumpRules( aRulesLab );
}
+
+void HYDROData_CalculationCase::SetAssignmentMode( AssignmentMode theMode )
+{
+ TDF_Label aModeLab = myLab.FindChild( DataTag_AssignmentMode );
+ TDataStd_Integer::Set( aModeLab, ( int ) theMode );
+}
+
+HYDROData_CalculationCase::AssignmentMode HYDROData_CalculationCase::GetAssignmentMode() const
+{
+ Handle(TDataStd_Integer) aModeAttr;
+ bool isOK = myLab.FindChild( DataTag_AssignmentMode ).FindAttribute( TDataStd_Integer::GetID(), aModeAttr );
+ if( isOK )
+ return ( AssignmentMode ) aModeAttr->Get();
+ else
+ return MANUAL;
+}
+
+void HYDROData_CalculationCase::DumpRulesToPython( const QString& theCalcCaseName,
+ QStringList& theScript ) const
+{
+ TDF_Label aRulesLab = myLab.FindChild( DataTag_CustomRules );
+ HYDROData_PriorityQueue::DumpRulesToPython( aRulesLab, theCalcCaseName, theScript );
+}
POINT_ON ///< point is on the edge of zone face
};
+ enum AssignmentMode
+ {
+ MANUAL = 0,
+ AUTOMATIC,
+ };
+
public:
/**
DataTag_GeometryGroup, ///< reference geometry groups
DataTag_SplittedGroups, ///< reference splitted groups
DataTag_CustomRules, ///< custom rules
+ DataTag_AssignmentMode, ///< assignment mode
};
public:
const gp_XY& thePoint,
const Handle(HYDROData_Zone)& theZone ) const;
+ HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
+ HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
+
HYDRODATA_EXPORT void ClearRules();
HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Object)& theObject1,
HYDROData_PriorityType thePriority,
void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
+ void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
+
protected:
friend class HYDROData_Iterator;
}
return aDump;
}
+
+void HYDROData_PriorityQueue::DumpRulesToPython( const TDF_Label& theRulesLab,
+ const QString& theCalcCaseName,
+ QStringList& theScript )
+{
+ HYDROData_ListOfRules aRules = GetRules( theRulesLab );
+ HYDROData_ListOfRules::const_iterator anIt = aRules.begin(), aLast = aRules.end();
+ for( ; anIt!=aLast; anIt++ )
+ {
+ QString anObj1 = anIt->Object1->GetObjPyName();
+ QString anObj2 = anIt->Object2->GetObjPyName();
+ QString aPriority = anIt->Priority == LESS ? "LESS" : "GREATER";
+ QString aMergeType;
+
+ switch( anIt->MergeType )
+ {
+ case HYDROData_Zone::Merge_UNKNOWN:
+ aMergeType = "Merge_UNKNOWN";
+ break;
+ case HYDROData_Zone::Merge_ZMIN:
+ aMergeType = "Merge_ZMIN";
+ break;
+ case HYDROData_Zone::Merge_ZMAX:
+ aMergeType = "Merge_ZMAX";
+ break;
+ case HYDROData_Zone::Merge_Object:
+ aMergeType = "Merge_Object";
+ break;
+ }
+
+ QString aRule = QString( "%0.AddRule( %1, %2, %3, %4 )" ).
+ arg( theCalcCaseName ).arg( anObj1 ).arg( aPriority ).arg( anObj2 ).arg( aMergeType );
+
+ theScript << aRule;
+ }
+}