HYDROData_Projection.h
HYDROData_Region.h
HYDROData_River.h
+ HYDROData_SplittedEdgesGroup.h
HYDROData_SplitToZonesTool.h
HYDROData_Stream.h
HYDROData_Tool.h
HYDROData_Projection.cxx
HYDROData_Region.cxx
HYDROData_River.cxx
+ HYDROData_SplittedEdgesGroup.cxx
HYDROData_SplitToZonesTool.cxx
HYDROData_Stream.cxx
HYDROData_Tool.cxx
#include "HYDROData_NaturalObject.h"
#include "HYDROData_PolylineXY.h"
#include "HYDROData_SplitToZonesTool.h"
+#include "HYDROData_SplittedEdgesGroup.h"
#include "HYDROData_Region.h"
#include "HYDROData_Tool.h"
#include "HYDROData_Zone.h"
#include <TopoDS.hxx>
#include <TopoDS_Shell.hxx>
+#include <TopoDS_Edge.hxx>
+
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
+#include <BRepTopAdaptor_FClass2d.hxx>
+
+#include <TopAbs.hxx>
#include <TopExp_Explorer.hxx>
#include <TopExp.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
-#include <BRepTopAdaptor_FClass2d.hxx>
-#include <TopAbs.hxx>
+
#define CALCULATION_REGIONS_PREF GetName() + "_Reg"
#define CALCULATION_ZONES_PREF GetName() + "_Zone"
{
HYDROData_Entity::Update();
- // At first we remove previously created regions
+ // At first we remove previously created objects
RemoveRegions();
+ RemoveSplittedGroups();
Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
if ( aDocument.IsNull() )
if ( aGeomObjects.IsEmpty() )
return;
- HYDROData_SplitToZonesTool::SplitDataList aSplitedZones =
- HYDROData_SplitToZonesTool::SplitToZones( aGeomObjects, aBoundaryPolyline );
- if ( aSplitedZones.isEmpty() )
+ HYDROData_SequenceOfObjects aGeomGroups = GetGeometryGroups();
+
+ HYDROData_SplitToZonesTool::SplitDataList aSplitedObjects =
+ HYDROData_SplitToZonesTool::Split( aGeomObjects, aGeomGroups, aBoundaryPolyline );
+ if ( aSplitedObjects.isEmpty() )
return;
QString aRegsPref = CALCULATION_REGIONS_PREF;
QString aZonesPref = CALCULATION_ZONES_PREF;
+ QMap<QString,Handle(HYDROData_SplittedEdgesGroup)> aSplittedEdgesGroupsMap;
+
// Create result regions for case, by default one zone for one region
- HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitedZones );
+ HYDROData_SplitToZonesTool::SplitDataListIterator anIter( aSplitedObjects );
while( anIter.hasNext() )
{
const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
- // Create new region
- Handle(HYDROData_Region) aRegion = addNewRegion();
+ if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
+ {
+ // Create new region
+ Handle(HYDROData_Region) aRegion = addNewRegion();
- QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
- aRegion->SetName( aRegionName );
+ QString aRegionName = HYDROData_Tool::GenerateObjectName( aDocument, aRegsPref );
+ aRegion->SetName( aRegionName );
- // Add the zone for region
- Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone();
+ // Add the zone for region
+ Handle(HYDROData_Zone) aRegionZone = aRegion->addNewZone();
- QString aZoneName = HYDROData_Tool::GenerateObjectName( aDocument, aZonesPref );
- aRegionZone->SetName( aZoneName );
+ QString aZoneName = HYDROData_Tool::GenerateObjectName( aDocument, aZonesPref );
+ aRegionZone->SetName( aZoneName );
- aRegionZone->SetShape( aSplitData.Face() );
+ aRegionZone->SetShape( aSplitData.Face() );
- // Add the reference object for zone
- for ( int i = 0, n = aSplitData.ObjectNames.length(); i < n; ++i )
+ // Add the reference object for zone
+ for ( int i = 0, n = aSplitData.ObjectNames.length(); i < n; ++i )
+ {
+ const QString& anObjName = aSplitData.ObjectNames.at( i );
+
+ Handle(HYDROData_Object) aRefObject = Handle(HYDROData_Object)::DownCast(
+ HYDROData_Tool::FindObjectByName( aDocument, anObjName ) );
+ if ( aRefObject.IsNull() )
+ continue;
+
+ aRegionZone->AddGeometryObject( aRefObject );
+ }
+ }
+ else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
{
- const QString& anObjName = aSplitData.ObjectNames.at( i );
-
- Handle(HYDROData_Object) aRefObject = Handle(HYDROData_Object)::DownCast(
- HYDROData_Tool::FindObjectByName( aDocument, anObjName ) );
- if ( aRefObject.IsNull() )
+ // Create new edges group
+ if ( aSplitData.ObjectNames.isEmpty() ||
+ aSplitData.Shape.IsNull() || aSplitData.Shape.ShapeType() != TopAbs_EDGE )
+ continue;
+
+ QString anObjName = aSplitData.ObjectNames.first();
+ if ( anObjName.isEmpty() )
continue;
- aRegionZone->AddGeometryObject( aRefObject );
+ if ( !aSplittedEdgesGroupsMap.contains( anObjName ) )
+ aSplittedEdgesGroupsMap.insert( anObjName, addNewSplittedGroup() );
+
+ Handle(HYDROData_SplittedEdgesGroup) aSplittedGroup = aSplittedEdgesGroupsMap[ anObjName ];
+ if ( aSplittedGroup.IsNull() )
+ continue;
+
+ TopoDS_Edge anEdge = TopoDS::Edge( aSplitData.Shape );
+ aSplittedGroup->AddEdge( anEdge );
}
}
}
void HYDROData_CalculationCase::RemoveRegions()
{
- ClearReferenceObjects( DataTag_Region );
- myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes( true );
+ myLab.FindChild( DataTag_ChildRegion ).ForgetAllAttributes();
}
-Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion()
+HYDROData_SequenceOfObjects HYDROData_CalculationCase::GetSplittedGroups() const
{
- TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
-
- Handle(HYDROData_Region) aNewRegion =
- Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
- AddRegion( aNewRegion );
+ return GetReferenceObjects( DataTag_SplittedGroups );
+}
- return aNewRegion;
+void HYDROData_CalculationCase::RemoveSplittedGroups()
+{
+ myLab.FindChild( DataTag_SplittedGroups ).ForgetAllAttributes();
}
TopoDS_Shell HYDROData_CalculationCase::GetShell()
return aResZone;
}
+
HYDROData_CalculationCase::PointClassification HYDROData_CalculationCase::GetPointClassification(
const gp_XY& thePoint,
const Handle(HYDROData_Zone)& theZone ) const
aRes = POINT_ON;
return aRes;
}
+
+Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion()
+{
+ TDF_Label aNewLab = myLab.FindChild( DataTag_ChildRegion ).NewChild();
+
+ Handle(HYDROData_Region) aNewRegion =
+ Handle(HYDROData_Region)::DownCast( HYDROData_Iterator::CreateObject( aNewLab, KIND_REGION ) );
+ AddRegion( aNewRegion );
+
+ return aNewRegion;
+}
+
+Handle(HYDROData_SplittedEdgesGroup) HYDROData_CalculationCase::addNewSplittedGroup()
+{
+ TDF_Label aNewLab = myLab.FindChild( DataTag_SplittedGroups ).NewChild();
+
+ Handle(HYDROData_SplittedEdgesGroup) aNewGroup =
+ Handle(HYDROData_SplittedEdgesGroup)::DownCast(
+ HYDROData_Iterator::CreateObject( aNewLab, KIND_SPLITTED_GROUP ) );
+ AddReferenceObject( aNewGroup, DataTag_SplittedGroups );
+
+ return aNewGroup;
+}
+
+
class Handle(HYDROData_Zone);
class Handle(HYDROData_PolylineXY);
class Handle(HYDROData_EdgesGroup);
+class Handle(HYDROData_SplittedEdgesGroup);
DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
*/
HYDRODATA_EXPORT virtual void RemoveRegions();
+
+ /**
+ * Returns all reference geometry groups of calculation case.
+ */
+ HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
+
+ /**
+ * Removes all reference geometry groups from calculation case.
+ */
+ HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
+
+
/**
* Returns shell containing faces which correspond to regions.
* \return shell as TopoDS_Shell
*/
HYDRODATA_EXPORT virtual Handle(HYDROData_Region) addNewRegion();
+ /**
+ * Add new one splitted edges group for calculation case.
+ */
+ HYDRODATA_EXPORT virtual Handle(HYDROData_SplittedEdgesGroup) addNewSplittedGroup();
protected:
const ObjectKind KIND_NATURAL_OBJECT = 20;
const ObjectKind KIND_DUMMY_3D = 21;
const ObjectKind KIND_EDGES_GROUP = 22;
-const ObjectKind KIND_LAST = KIND_EDGES_GROUP;
+const ObjectKind KIND_SPLITTED_GROUP = 23;
+const ObjectKind KIND_LAST = KIND_SPLITTED_GROUP;
DEFINE_STANDARD_HANDLE(HYDROData_Entity, MMgt_TShared)
#include "HYDROData_VisualState.h"
#include "HYDROData_Region.h"
#include "HYDROData_River.h"
+#include "HYDROData_SplittedEdgesGroup.h"
#include "HYDROData_Stream.h"
#include "HYDROData_Zone.h"
case KIND_VISUAL_STATE: aResult = new HYDROData_VisualState(); break;
case KIND_DUMMY_3D: aResult = new HYDROData_DummyObject3D(); break;
case KIND_EDGES_GROUP: aResult = new HYDROData_EdgesGroup(); break;
+ case KIND_SPLITTED_GROUP: aResult = new HYDROData_SplittedEdgesGroup();break;
default: break;
}
}
HYDROData_SplitToZonesTool::SplitDataList
-HYDROData_SplitToZonesTool::SplitToZones( const HYDROData_SequenceOfObjects& theObjectList,
- const Handle(HYDROData_PolylineXY)& thePolyline )
+ HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects& theObjectList,
+ const HYDROData_SequenceOfObjects& theGroupsList,
+ const Handle(HYDROData_PolylineXY)& thePolyline )
{
SplitDataList anOutputSplitDataList;
for ( ; anExp.More(); anExp.Next() ) {
TopoDS_Face aFace = TopoDS::Face( anExp.Current() );
if ( !aFace.IsNull() ) {
- SplitData aSplitData( aFace, aGeomObj->GetName() );
+ SplitData aSplitData( SplitData::Data_Zone, aFace, aGeomObj->GetName() );
anInputSplitDataList.append( aSplitData );
}
}
} else {
- SplitData aSplitData( aShape, aGeomObj->GetName() );
+ SplitData aSplitData( SplitData::Data_Zone, aShape, aGeomObj->GetName() );
anInputSplitDataList.append( aSplitData );
}
}
aMakeFace.Build();
if( aMakeFace.IsDone() )
{
- SplitData aBoundarySplitData( aMakeFace.Face(), "" );
+ SplitData aBoundarySplitData( SplitData::Data_Zone, aMakeFace.Face(), "" );
SplitDataList aCutSplitDataList;
SplitDataListIterator anOutputIter( anOutputSplitDataList );
BRepAlgoAPI_Cut aCut2( aShape2, aShape1 );
TopoDS_Shape aCut2Shape = aCut2.Shape();
- theData1Subtracted = SplitData( aCut1Shape, anObjectNames1 );
- theData2Subtracted = SplitData( aCut2Shape, anObjectNames2 );
- theDataIntersected = SplitData( aCommonShape, anObjectNames1 + anObjectNames2 );
+ theData1Subtracted = SplitData( SplitData::Data_Zone, aCut1Shape, anObjectNames1 );
+ theData2Subtracted = SplitData( SplitData::Data_Zone, aCut2Shape, anObjectNames2 );
+ theDataIntersected = SplitData( SplitData::Data_Zone, aCommonShape, anObjectNames1 + anObjectNames2 );
return true;
}
TopoDS_Face aFace = TopoDS::Face( aShape );
if( !aFace.IsNull() )
{
- SplitData aSplitData( aFace, theData.ObjectNames );
+ SplitData aSplitData( SplitData::Data_Zone, aFace, theData.ObjectNames );
aSplitDataList.append( aSplitData );
}
}
public:
struct HYDRODATA_EXPORT SplitData
{
- TopoDS_Shape Shape;
- QStringList ObjectNames;
-
- SplitData() {}
+ enum SplitObjectType
+ {
+ Data_None,
+ Data_Zone,
+ Data_Edge
+ };
+
+ TopoDS_Shape Shape;
+ QStringList ObjectNames;
+ SplitObjectType Type;
+
+ SplitData() :
+ Type( Data_None ) {}
- SplitData( const TopoDS_Shape& theShape,
- const QStringList& theObjectNames ) :
- Shape( theShape ), ObjectNames( theObjectNames ) {}
+ SplitData( const SplitObjectType& theType,
+ const TopoDS_Shape& theShape,
+ const QStringList& theObjectNames ) :
+ Type( theType ), Shape( theShape ), ObjectNames( theObjectNames ) {}
- SplitData( const TopoDS_Shape& theShape,
- const QString& theObjectNames ) :
- Shape( theShape ), ObjectNames( theObjectNames ) {}
+ SplitData( const SplitObjectType& theType,
+ const TopoDS_Shape& theShape,
+ const QString& theObjectName ) :
+ Type( theType ), Shape( theShape ), ObjectNames( theObjectName ) {}
TopoDS_Face Face() const;
};
public:
- static SplitDataList SplitToZones( const HYDROData_SequenceOfObjects& theObjectList,
- const Handle(HYDROData_PolylineXY)& thePolyline );
+ static SplitDataList Split( const HYDROData_SequenceOfObjects& theObjectList,
+ const HYDROData_SequenceOfObjects& theGroupsList,
+ const Handle(HYDROData_PolylineXY)& thePolyline );
private:
--- /dev/null
+
+#include "HYDROData_SplittedEdgesGroup.h"
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_SplittedEdgesGroup,HYDROData_EdgesGroup)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_SplittedEdgesGroup,HYDROData_EdgesGroup)
+
+HYDROData_SplittedEdgesGroup::HYDROData_SplittedEdgesGroup()
+: HYDROData_EdgesGroup()
+{
+}
+
+HYDROData_SplittedEdgesGroup::~HYDROData_SplittedEdgesGroup()
+{
+}
+
+
--- /dev/null
+
+#ifndef HYDROData_SplittedEdgesGroup_HeaderFile
+#define HYDROData_SplittedEdgesGroup_HeaderFile
+
+#include <HYDROData_EdgesGroup.h>
+
+DEFINE_STANDARD_HANDLE(HYDROData_SplittedEdgesGroup, HYDROData_EdgesGroup)
+
+
+/**\class HYDROData_SplittedEdgesGroup
+ * \brief The artificial objects are objects created or planned for creation by human.
+ *
+ */
+class HYDROData_SplittedEdgesGroup : public HYDROData_EdgesGroup
+{
+protected:
+ /**
+ * Enumeration of tags corresponding to the persistent object parameters.
+ */
+ enum DataTag
+ {
+ DataTag_First = HYDROData_EdgesGroup::DataTag_First + 100 ///< first tag, to reserve
+ };
+
+public:
+ DEFINE_STANDARD_RTTI(HYDROData_SplittedEdgesGroup);
+
+ /**
+ * Returns the kind of this object. Must be redefined in all objects of known type.
+ */
+ HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_SPLITTED_GROUP; }
+
+protected:
+
+ friend class HYDROData_Iterator;
+
+ /**
+ * Creates new object in the internal data structure. Use higher level objects
+ * to create objects with real content.
+ */
+ HYDRODATA_EXPORT HYDROData_SplittedEdgesGroup();
+
+ /**
+ * Destructs properties of the object and object itself, removes it from the document.
+ */
+ virtual HYDRODATA_EXPORT ~HYDROData_SplittedEdgesGroup();
+};
+
+#endif