const HYDROData_SplitToZonesTool::SplitData& aSplitData = anIter.next();
if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Zone )
aZonesList.append( aSplitData );
- else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge )
+ else if ( aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_Edge ||
+ aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_IntEdge)
anEdgesList.append( aSplitData );
}
}
continue;
aSplitGroup->AddShape( aSplitData.Shape );
+
+ TopTools_SequenceOfShape theShapes;
+ aSplitGroup->GetShapes(theShapes);
+
+ if (aSplitData.Type == HYDROData_SplitToZonesTool::SplitData::Data_IntEdge)
+ aSplitGroup->SetInternal(true);
}
}
// Get groups definitions
HYDROData_SequenceOfObjects aSplitGroups = GetSplitGroups();
+ TopTools_SequenceOfShape IntSh; //internal edges
HYDROData_SequenceOfObjects::Iterator anIter( aSplitGroups );
for ( ; anIter.More(); anIter.Next() )
{
aGroup->GetShapes( aGroupDef.Shapes );
aSeqOfGroupsDefs.Append( aGroupDef );
+
+ Handle(HYDROData_SplitShapesGroup) aSSGroup = Handle(HYDROData_SplitShapesGroup)::DownCast( anIter.Value() );
+ TopTools_SequenceOfShape dummy;
+ if (!aSSGroup.IsNull())
+ if (aSSGroup->GetInternal())
+ {
+ aSSGroup->GetShapes(dummy);
+ IntSh.Append(dummy);
+ }
+
}
// Get faces
if ( isAllNotSubmersible )
isAllNotSubmersible = false;
- TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs );
+ TopoDS_Shape aRegionShape = aRegion->GetShape( &aSeqOfGroupsDefs, &IntSh );
aShToNames.Add( aRegionShape, aRegion->GetName() );
}
TCollection_AsciiString aNam("Sh_");
int i=1;
#endif
+ TopTools_DataMapOfShapeListOfShape SH2M;
for ( int i = 1; i <= aShToName.Extent(); i++ )
{
const TopoDS_Shape& aShape = aShToName.FindKey(i);
if ( aShape.IsNull() )
continue;
-
- if ( aShape.ShapeType() == TopAbs_FACE )
+
+ SH2M.Bind(aShape, TopTools_ListOfShape());
+ TopTools_ListOfShape& LM = SH2M.ChangeFind(aShape);
+ if ( aShape.ShapeType() == TopAbs_FACE || aShape.ShapeType() == TopAbs_SHELL )
{
aSewing.Add( aShape );
-#ifdef DEB_CALCULATION
- TCollection_AsciiString aName = aNam + ++i + ".brep";
- BRepTools::Write(aShape ,aName.ToCString());
-#endif
+ LM.Append(aShape);
}
- else
+ else if (aShape.ShapeType() == TopAbs_COMPOUND)
{
-#ifdef DEB_CALCULATION
- int j = 1;
-#endif
- TopExp_Explorer anExp( aShape, TopAbs_FACE );
- for (; anExp.More(); anExp.Next() ) {
+ TopExp_Explorer anExp( aShape, TopAbs_SHELL );
+ for (; anExp.More(); anExp.Next() )
+ {
aSewing.Add( anExp.Current() );
-#ifdef DEB_CALCULATION
-
- TCollection_AsciiString aName = aNam + i + "_" + ++j + ".brep";
- BRepTools::Write(anExp.Current() ,aName.ToCString());
-#endif
+ LM.Append(anExp.Current());
+ }
+ anExp.Init( aShape, TopAbs_FACE, TopAbs_SHELL );
+ {
+ aSewing.Add( anExp.Current() );
+ LM.Append(anExp.Current());
}
}
} // faces iterator
{
const TopoDS_Shape& CurShape = aShToName.FindKey(i);
const QString& Qstr = aShToName.FindFromIndex(i);
- for (TopExp_Explorer Exp(CurShape, TopAbs_FACE); Exp.More(); Exp.Next())
+ const TopTools_ListOfShape& LM = SH2M(CurShape);
+ for (TopTools_ListIteratorOfListOfShape it(LM); it.More(); it.Next())
{
- const TopoDS_Face& cf = TopoDS::Face(Exp.Current());
- if (aSewing.IsModified(cf))
- aFacesToNameModif.Add(aSewing.Modified(cf), Qstr);
+ const TopoDS_Shape& csh = it.Value();
+ if (aSewing.IsModified(csh))
+ aFacesToNameModif.Add(aSewing.Modified(csh), Qstr);
else
- aFacesToNameModif.Add(cf, Qstr);
+ aFacesToNameModif.Add(csh, Qstr);
}
}
return anAttr->Get();
}
+
+void HYDROData_Entity::SetInteger( int theTag, int theValue )
+{
+ Handle(TDataStd_Integer) anAttr;
+ TDF_Label aLabel = myLab.FindChild( theTag );
+ if( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+ aLabel.AddAttribute( anAttr = new TDataStd_Integer() );
+ anAttr->Set( theValue );
+}
+
+int HYDROData_Entity::GetInteger( int theTag, int theDefValue ) const
+{
+ Handle(TDataStd_Integer) anAttr;
+ TDF_Label aLabel = myLab.FindChild( theTag );
+ if( !aLabel.FindAttribute( TDataStd_Integer::GetID(), anAttr ) )
+ return 0;
+
+ return anAttr->Get();
+}
void SetDouble( int theTag, double theValue );
double GetDouble( int theTag, double theDefValue = 0.0 ) const;
+ void SetInteger( int theTag, int theValue );
+ int GetInteger( int theTag, int theDefValue = 0 ) const;
+
+
int GetGeomChangeFlag() const;
protected:
TopTools_MapOfShape mapShape;
+ NCollection_IndexedDataMap<TopoDS_Shape, QString, TopTools_ShapeMapHasher> aFF2N;
+ for (int i = 1; i <= aFacesToNameModif.Extent(); i++)
+ {
+ TopExp_Explorer exp (aFacesToNameModif.FindKey(i), TopAbs_FACE);
+ for (;exp.More(); exp.Next())
+ aFF2N.Add(exp.Current(), aFacesToNameModif.FindFromIndex(i));
+ }
+
TopExp_Explorer exp (theShape, TopAbs_FACE);
QVector<QString> Names;
for (; exp.More(); exp.Next())
if (mapShape.Add(csh))
{
//listShape.Append(csh);
- QString Qstr = aFacesToNameModif.FindFromKey(csh);
+ QString Qstr = aFF2N.FindFromKey(csh);
Names.push_back(Qstr);
}
}
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
+
#include <BRep_Builder.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <QStringList>
#include <QColor>
+#include "Handle_Geom_Plane.hxx"
+#include "Geom_Plane.hxx"
+#include "gp_Pln.hxx"
+#include "BRepTools_ReShape.hxx"
+
//#define DEB_GET_REGION_SHAPE
IMPLEMENT_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
}
}
-TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups ) const
+
+
+TopoDS_Shape HYDROData_Region::GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups, const TopTools_SequenceOfShape* IntSh ) const
{
HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfGroups;
HYDROData_ShapesGroup::SeqOfGroupsDefs aSeqOfUsedGroups;
HYDROData_SequenceOfObjects aZones = GetZones();
HYDROData_SequenceOfObjects::Iterator aZoneIter( aZones );
+ TopTools_IndexedMapOfShape AllE;
+ TopTools_IndexedMapOfShape IE; //int edges
+
for ( ; aZoneIter.More(); aZoneIter.Next() )
{
Handle(HYDROData_Zone) aZone =
TopoDS_Face aZoneFace = TopoDS::Face( aZoneShape );
aRegionFacesList.Append( aZoneFace );
-
+ TopExp::MapShapes(aZoneFace, TopAbs_EDGE, AllE); // collect all edges
getUsedGroups( aZoneFace, aSeqOfGroups, aSeqOfUsedGroups );
} // zones iterator
+
+ for (int i = 1; i <= IntSh->Length(); i++)
+ {
+ const TopoDS_Shape& CS = (*IntSh)(i);
+ if (AllE.Contains(CS))
+ IE.Add(CS);
+ }
if ( aRegionFacesList.IsEmpty() )
return aResShape;
- // The unite region face
TopoDS_Face aRegionFace;
if ( aRegionFacesList.Extent() == 1 )
{
- aRegionFace = TopoDS::Face( aRegionFacesList.First() );
+ aResShape = TopoDS::Face( aRegionFacesList.First() );
}
else
{
}
aFuseShape = aFuse.Shape();
+
+ //update history of internal edges
+ TopTools_IndexedMapOfShape DIE;
+ TopTools_ListOfShape newSh1, newSh2;
+ for (int i = 1; i <= IE.Extent(); i++)
+ {
+ const TopoDS_Shape& CSH = IE(i);
+ newSh1.Clear();
+ newSh2.Clear();
+ newSh1 = aFuse.Modified(CSH);
+ if (newSh1.IsEmpty())
+ {
+ newSh2 = aFuse.Generated(CSH);
+ if (newSh2.IsEmpty())
+ DIE.Add(CSH);
+ else
+ for (TopTools_ListIteratorOfListOfShape lt(newSh2); lt.More(); lt.Next())
+ if (!lt.Value().IsNull())
+ DIE.Add(lt.Value());
+ }
+ else
+ {
+ for (TopTools_ListIteratorOfListOfShape lt(newSh1); lt.More(); lt.Next())
+ if (!lt.Value().IsNull())
+ DIE.Add(lt.Value());
+ }
+ }
+ IE = DIE;
+ //update groups
HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &aFuse );
} // faces iterator
HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Fused face edges:", aFuseShape, TopAbs_EDGE );
#endif
- // Check the result of fuse operation
- if ( !aFuseShape.IsNull() )
+ BRep_Builder BB;
+ TopoDS_Face DF;
+ if (!IE.IsEmpty())
{
- ShapeUpgrade_UnifySameDomain anUnifier( aFuseShape );
- anUnifier.Build();
+ //add dummy face to existing shell
+ //this face contains all internal edges
+ //USD algo will skip such edges and will not perform unifying through them
+ //(more than 2 faces are connected to one edge + non same domain surfaces)
+ TopoDS_Wire DW;
+ Handle_Geom_Plane DPl = new Geom_Plane(gp_Pln (gp_Pnt(0,0,0), gp_Dir(0,1,0))); //non same domain with the main surf
+ BB.MakeFace(DF, DPl, Precision::Confusion());
+ BB.MakeWire(DW);
+ for (int i = 1; i <= IE.Extent(); i++)
+ BB.Add(DW, IE(i));
+ BB.Add(DF, DW);
+ BB.Add(aFuseShape, DF);
+ }
- const TopoDS_Shape& anUnitedShape = anUnifier.Shape();
+ ShapeUpgrade_UnifySameDomain unif( aFuseShape );
+ unif.Build();
+ TopoDS_Shape anUnitedShape;
+ const TopoDS_Shape& out = unif.Shape();
- TopTools_SequenceOfShape aShapeFaces;
- HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_FACE, aShapeFaces );
- if ( aShapeFaces.Length() == 1 )
- {
- aRegionFace = TopoDS::Face( aShapeFaces.Value( 1 ) );
+ HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &unif );
-#ifdef DEB_GET_REGION_SHAPE
- HYDROData_ShapesTool::DumpShapeSubShapes( std::cout, "Result face edges:", aRegionFace, TopAbs_EDGE );
-#endif
+ if (!IE.IsEmpty())
+ {
+ //remove dummy face from shell; shell becomes valid
+ const TopoDS_Shape& NDF = unif.Generated(DF);
+ BRepTools_ReShape ReShaper;
+ ReShaper.Remove(NDF);
+ anUnitedShape = ReShaper.Apply(out);
+ HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &ReShaper );
+ }
+ else
+ anUnitedShape = out;
- HYDROData_ShapesGroup::GroupDefinition::Update( &aSeqOfUsedGroups, &anUnifier );
+ TopTools_SequenceOfShape aShapeFaces;
+ HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_FACE, aShapeFaces );
+ if ( aShapeFaces.Length() == 1 ) //it should be either face or compound of faces (?)
+ {
+ const TopoDS_Face& CF = TopoDS::Face( aShapeFaces.Value( 1 ));
+ aResShape = CF;
+ }
+ else
+ {
+ TopTools_SequenceOfShape aShapeShells;
+ HYDROData_ShapesTool::ExploreShapeToShapes( anUnitedShape, TopAbs_SHELL, aShapeShells );
+ if (aShapeShells.Length() == 1)
+ aResShape = TopoDS::Shell(aShapeShells(1));
+ else
+ aResShape = anUnitedShape;
+ }
- // Update the sequence of groups
- if ( theSeqOfGroups )
+ // Update the sequence of groups
+ if ( theSeqOfGroups )
+ {
+ HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator aUsedIter( aSeqOfUsedGroups );
+ for ( ; aUsedIter.More(); aUsedIter.Next() )
+ {
+ const HYDROData_ShapesGroup::GroupDefinition& aUsedGroupDef = aUsedIter.Value();
+ if ( aUsedGroupDef.Shapes.IsEmpty() )
+ continue;
+
+ HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator anOriIter( aSeqOfGroups );
+ for ( ; anOriIter.More(); anOriIter.Next() )
{
- HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator aUsedIter( aSeqOfUsedGroups );
- for ( ; aUsedIter.More(); aUsedIter.Next() )
- {
- const HYDROData_ShapesGroup::GroupDefinition& aUsedGroupDef = aUsedIter.Value();
- if ( aUsedGroupDef.Shapes.IsEmpty() )
- continue;
-
- HYDROData_ShapesGroup::SeqOfGroupsDefs::Iterator anOriIter( aSeqOfGroups );
- for ( ; anOriIter.More(); anOriIter.Next() )
- {
- HYDROData_ShapesGroup::GroupDefinition& anOriGroupDef = anOriIter.ChangeValue();
- if ( anOriGroupDef.Name != aUsedGroupDef.Name )
- continue;
-
- HYDROData_ShapesTool::AddShapes( anOriGroupDef.Shapes, aUsedGroupDef.Shapes );
- break;
- }
- }
-
- *theSeqOfGroups = aSeqOfGroups;
+ HYDROData_ShapesGroup::GroupDefinition& anOriGroupDef = anOriIter.ChangeValue();
+ if ( anOriGroupDef.Name != aUsedGroupDef.Name )
+ continue;
+
+ HYDROData_ShapesTool::AddShapes( anOriGroupDef.Shapes, aUsedGroupDef.Shapes );
+ break;
}
}
- }
- }
- if ( !aRegionFace.IsNull() )
- {
- // result shape is a face
- aResShape = aRegionFace;
+ *theSeqOfGroups = aSeqOfGroups;
+ }
}
- else
- {
- // result shape is a shell
- TopoDS_Shell aShell;
- BRep_Builder aBuilder;
- aBuilder.MakeShell( aShell );
- TopTools_ListIteratorOfListOfShape aFaceIter( aRegionFacesList );
- for ( ; aFaceIter.More(); aFaceIter.Next() )
- aBuilder.Add( aShell, aFaceIter.Value() );
-
- aResShape = aShell;
- }
-
return aResShape;
}
* - a shell if the zones faces can't be united into one face
* \return shape as TopoDS_Shape
*/
- HYDRODATA_EXPORT virtual TopoDS_Shape GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups = 0 ) const;
+ HYDRODATA_EXPORT virtual TopoDS_Shape GetShape( HYDROData_ShapesGroup::SeqOfGroupsDefs* theSeqOfGroups = 0,
+ const TopTools_SequenceOfShape* IntSh = NULL ) const;
HYDRODATA_EXPORT bool IsSubmersible() const;
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <BRepTools_ReShape.hxx>
IMPLEMENT_STANDARD_HANDLE(HYDROData_ShapesGroup,HYDROData_Entity)
IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ShapesGroup,HYDROData_Entity)
}
}
+void HYDROData_ShapesGroup::GroupDefinition::Update( SeqOfGroupsDefs* theGroupsDefs,
+ BRepTools_ReShape* theAlgo )
+{
+ if ( !theGroupsDefs || !theAlgo )
+ return;
+
+ SeqOfGroupsDefs::Iterator anIter( *theGroupsDefs );
+ for ( ; anIter.More(); anIter.Next() )
+ {
+ GroupDefinition& aGroupDef = anIter.ChangeValue();
+ if ( aGroupDef.Shapes.IsEmpty() )
+ continue;
+
+ TopTools_ListOfShape aShapesToAdd;
+ for ( int i = 1; i <= aGroupDef.Shapes.Length(); ++i )
+ {
+ TopoDS_Shape aShape = aGroupDef.Shapes.Value( i );
+
+ TopoDS_Shape aGeneratedByAlgo = theAlgo->Value( aShape );
+ if ( aGeneratedByAlgo.IsNull() )
+ {
+ // Edge has been removed
+ aGroupDef.Shapes.Remove( i );
+ --i;
+ }
+ else if ( !aShape.IsEqual( aGeneratedByAlgo ) )
+ {
+ // Edge has been modified
+ aShapesToAdd.Append( aGeneratedByAlgo );
+ aGroupDef.Shapes.Remove( i );
+ --i;
+ }
+ }
+
+ HYDROData_ShapesTool::AddShapes( aGroupDef.Shapes, aShapesToAdd );
+ }
+}
+
void HYDROData_ShapesGroup::GroupDefinition::Dump( std::ostream& theStream ) const
{
theStream << "Name: " << Name.ToCString() << "\n";
class TopTools_ListOfShape;
class BRepBuilderAPI_MakeShape;
class ShapeUpgrade_UnifySameDomain;
+class BRepTools_ReShape;
DEFINE_STANDARD_HANDLE(HYDROData_ShapesGroup, HYDROData_Entity)
static void Update( NCollection_Sequence<GroupDefinition>* theGroupsDefs,
ShapeUpgrade_UnifySameDomain* theAlgo );
+ static void Update( NCollection_Sequence<GroupDefinition>* theGroupsDefs,
+ BRepTools_ReShape* theAlgo );
+
+
void Dump( std::ostream& theStream ) const;
static void Dump( std::ostream& theStream,
{
}
+void HYDROData_SplitShapesGroup::SetInternal(bool flag)
+{
+ SetInteger(DataTag_InternalEdge, (int)flag);
+}
+
+bool HYDROData_SplitShapesGroup::GetInternal() const
+{
+ return (bool)GetInteger(DataTag_InternalEdge);
+}
*/
enum DataTag
{
- DataTag_First = HYDROData_ShapesGroup::DataTag_First + 100 ///< first tag, to reserve
+ DataTag_First = HYDROData_ShapesGroup::DataTag_First + 100, ///< first tag, to reserve
+ DataTag_InternalEdge
};
public:
*/
HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_SPLIT_GROUP; }
+ void SetInternal(bool flag);
+ bool GetInternal() const;
+
protected:
friend class HYDROData_Iterator;
#include <BRepCheck_Analyzer.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_IndexedMapOfShape.hxx>
#include <gp_Pln.hxx>
#include <BRepGProp.hxx>
#include <GProp_GProps.hxx>
#include <BOPAlgo_BOP.hxx>
#include <BOPAlgo_Builder.hxx>
+#include <TopExp.hxx>
//#define DEB_SPLIT_TO_ZONES 1
//#define DEB_SPLIT_TO_ZONES_CHECK_PARTITION 1
{
DEBTRACE("Split");
SplitDataList anOutputSplitDataList;
- if(theObjectList.IsEmpty()) return anOutputSplitDataList;
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher> OutNE;
+ if(theObjectList.IsEmpty())
+ return anOutputSplitDataList;
// Preparation.
// Collect the object shapes to split. InputDataList will contain elements which will hold shape & name_of_shape.
SplitDataList anInputSplitDataList;
// If only one shape is given we don't split it
// algorithm just returns the unpacked input data
bool limplus1Object(false);
- if(theObjectList.Size() == 1 ) {
- if(thePolyline.IsNull()) {
- anOutputSplitDataList.append(anInputSplitDataList);
+ if(theObjectList.Size() == 1 )
+ {
+ if(thePolyline.IsNull())
+ {
+ //anOutputSplitDataList.append(anInputSplitDataList);
+ SplitData SD = anInputSplitDataList.at(0);
+ TopTools_ListOfShape newshs;
+ CutFaceByEdges(SD.Face(), newshs, InterPolys, &OutNE);
+ for (TopTools_ListIteratorOfListOfShape it(newshs); it.More(); it.Next())
+ {
+ SplitData NSD = SD;
+ NSD.Shape = it.Value();
+ anOutputSplitDataList.append(NSD);
+ }
+
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>::Iterator spit(OutNE);
+ for (;spit.More();spit.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(spit.Key());
+ if (E.IsNull())
+ continue;
+ SplitData SDI(SplitData::Data_IntEdge, E, spit.Value()->GetName());
+ anOutputSplitDataList.append(SDI);
+ }
+
if(!theGroupsList.IsEmpty() )
anOutputSplitDataList.append(anInputGroupList);
return anOutputSplitDataList;
- } else
- limplus1Object = true;// size =1 && hasLimits
+ }
+ else
+ limplus1Object = true;// size =1 && hasLimits
}
HYDROData_DataMapOfShapeListOfString aDM3;
if(!anInputGroupList.isEmpty()) {// Old edge ==> List_Of_Names
}
}
- AddInternalEdges(aDM2, InterPolys);
+ AddInternalEdges(aDM2, InterPolys, &OutNE);
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>::Iterator spit(OutNE);
+ for (;spit.More();spit.Next())
+ {
+ const TopoDS_Edge& E = TopoDS::Edge(spit.Key());
+ if (E.IsNull())
+ continue;
+ SplitData SDI(SplitData::Data_IntEdge, E, spit.Value()->GetName());
+ anOutputSplitDataList.append(SDI);
+ }
// Step 4. Fill output structure.
#ifdef DEB_SPLIT_TO_ZONES
}
void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOfShape& DM,
- const HYDROData_SequenceOfObjects& thePolylines)
+ const HYDROData_SequenceOfObjects& thePolylines,
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE)
{
HYDROData_SequenceOfObjects::Iterator it(thePolylines);
TopTools_ListOfShape Wires;
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher> W2P;
for (;it.More();it.Next())
{
Handle(HYDROData_PolylineXY) P = Handle(HYDROData_PolylineXY)::DownCast(it.Value());
- Wires.Append(P->GetShape());
- //Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape;
- //if (P->GetNbConnectedWires(aConnectedWires) > 0)
- // Wires.Append(aConnectedWires->Value(1));
+ const TopoDS_Shape& CW = P->GetShape();
+ Wires.Append(CW);
+ W2P.Bind(CW, P);
}
HYDROData_DataMapOfShapeListOfShape newDM;
-
+ TopTools_IndexedDataMapOfShapeShape OutNE1;
for (int i = 1; i <= DM.Extent();i++)
{
const TopoDS_Shape& K = DM.FindKey(i);
TopTools_ListOfShape out;
if (K.ShapeType() == TopAbs_FACE)
{
- CutByEdges(K, Wires, out);
+ CutByEdges(K, Wires, out, &OutNE1);
TopTools_ListIteratorOfListOfShape it(out);
for (;it.More(); it.Next())
{
newDM.Add(K, V); // ignore edges, wires...
}
+ for (int i = 1; i <= OutNE1.Extent(); i++)
+ OutNE->Bind(OutNE1.FindKey(i), W2P(OutNE1.FindFromIndex(i)));
+
DM = newDM;
}
+void HYDROData_SplitToZonesTool::CutFaceByEdges(const TopoDS_Face& in,
+ TopTools_ListOfShape& out,
+ const HYDROData_SequenceOfObjects& thePolylines,
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE)
+{
-int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InEdges,
- TopTools_ListOfShape& outShs)
+ HYDROData_SequenceOfObjects::Iterator it(thePolylines);
+ TopTools_ListOfShape Wires;
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher> W2P;
+ for (;it.More();it.Next())
+ {
+ Handle(HYDROData_PolylineXY) P = Handle(HYDROData_PolylineXY)::DownCast(it.Value());
+ const TopoDS_Shape& CW = P->GetShape();
+ Wires.Append(CW);
+ W2P.Bind(CW, P);
+ }
+
+ TopTools_IndexedDataMapOfShapeShape OutNE1;
+ CutByEdges(in, Wires, out, &OutNE1);
+
+ for (int i = 1; i <= OutNE1.Extent(); i++)
+ OutNE->Bind(OutNE1.FindKey(i), W2P(OutNE1.FindFromIndex(i)));
+
+}
+
+int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW,
+ TopTools_ListOfShape& outShs, TopTools_IndexedDataMapOfShapeShape* OutNE)
{
int anError;
if (InSh.IsNull())
return -1;
- if (InEdges.IsEmpty())
+ if (InW.IsEmpty())
{
outShs.Clear();
outShs.Append(InSh);
TopTools_ListIteratorOfListOfShape anIt;
BOPAlgo_Builder anAlgo;
anAlgo.AddArgument(InSh);
- anIt.Initialize( InEdges );
+
+ anIt.Initialize( InW );
for( ; anIt.More(); anIt.Next() )
anAlgo.AddArgument( anIt.Value() );
outShs = anAlgo.Modified( InSh );
if (outShs.IsEmpty())
outShs.Append(InSh);
+
+ if (OutNE)
+ {
+ TopTools_IndexedDataMapOfShapeShape NonFOutNE;
+ anIt.Initialize( InW );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ const TopoDS_Shape& OSH = anIt.Value();
+ TopExp_Explorer exp(OSH, TopAbs_EDGE);
+ for (;exp.More();exp.Next())
+ {
+ const TopoDS_Edge& OE = TopoDS::Edge(exp.Current());
+ const TopTools_ListOfShape& ls = anAlgo.Modified(OE);
+ TopTools_ListIteratorOfListOfShape itls(ls);
+ for (;itls.More();itls.Next())
+ NonFOutNE.Add(itls.Value(), OSH);
+ }
+ }
+
+ //filter edges; if face contain an edge => keep it
+ TopTools_IndexedMapOfShape AllEdges; //edges from output shape
+ for (anIt.Initialize(outShs); anIt.More();anIt.Next())
+ TopExp::MapShapes(anIt.Value(), TopAbs_EDGE, AllEdges);
+
+ for (int i = 1; i <= NonFOutNE.Extent(); i++)
+ {
+ const TopoDS_Shape& CE = NonFOutNE.FindKey(i);
+ const TopoDS_Shape& V = NonFOutNE.FindFromIndex(i);
+ if (AllEdges.Contains(CE))
+ OutNE->Add(CE, V);
+ }
+
+ }
+
return 0;
}
#include <TopoDS_Face.hxx>
#include <TopTools_ShapeMapHasher.hxx>
#include <NCollection_IndexedMap.hxx>
-#include <NCollection_IndexedDataMap.hxx>
+#include <TopTools_IndexedDataMapOfShapeShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <QStringList>
+#include <NCollection_DataMap.hxx>
class Handle(HYDROData_PolylineXY);
{
Data_None,
Data_Zone,
- Data_Edge
+ Data_Edge,
+ Data_IntEdge
};
TopoDS_Shape Shape;
static SplitDataList Split( const HYDROData_SequenceOfObjects& theObjectList );
static void AddInternalEdges(HYDROData_DataMapOfShapeListOfShape& DM,
- const HYDROData_SequenceOfObjects& thePolylines);
+ const HYDROData_SequenceOfObjects& thePolylines,
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE);
- static int CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InEdges,
- TopTools_ListOfShape& outShs);
+ static void CutFaceByEdges(const TopoDS_Face& in,
+ TopTools_ListOfShape& out,
+ const HYDROData_SequenceOfObjects& thePolylines,
+ NCollection_DataMap<TopoDS_Shape, Handle(HYDROData_PolylineXY), TopTools_ShapeMapHasher>* OutNE);
+
+ static int CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW,
+ TopTools_ListOfShape& outShs,
+ TopTools_IndexedDataMapOfShapeShape* OutNE2OE);
static void SetFileNames(const QString& theNameBefore, const QString& theNameAfter);
Wires.Append(InP);
TopTools_ListOfShape OutSh;
- HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh);
+ TopTools_IndexedDataMapOfShapeShape ls;
+ HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
+
CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent());
TopoDS_Compound cmp;
B.MakeCompound(cmp);
Wires.Append(InP);
TopTools_ListOfShape OutSh;
- HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh);
+ TopTools_IndexedDataMapOfShapeShape ls;
+ HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" );
//CPPUNIT_ASSERT_IMAGES
Wires.Append(InP);
TopTools_ListOfShape OutSh;
- HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh);
+ TopTools_IndexedDataMapOfShapeShape ls;
+ HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls);
CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent());
TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3" );
CPPUNIT_ASSERT_IMAGES