From 0ab6498891199b5f91386efd55b73c078a55475a Mon Sep 17 00:00:00 2001 From: isn Date: Wed, 21 Nov 2018 20:35:16 +0300 Subject: [PATCH] debug of Group Definition p.2 --- src/HYDROData/HYDROData_ShapesTool.cxx | 2 +- src/HYDROData/HYDROData_SplitToZonesTool.cxx | 58 ++++++++++++++++---- src/HYDROData/HYDROData_SplitToZonesTool.h | 1 + src/HYDRO_tests/test_HYDROData_CalcCase.cxx | 6 +- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/HYDROData/HYDROData_ShapesTool.cxx b/src/HYDROData/HYDROData_ShapesTool.cxx index 51867ce6..d8779030 100644 --- a/src/HYDROData/HYDROData_ShapesTool.cxx +++ b/src/HYDROData/HYDROData_ShapesTool.cxx @@ -192,6 +192,6 @@ void HYDROData_ShapesTool::DumpSequenceOfShapes( std::ostream& for ( int i = 1, n = theShapes.Length(); i <= n; ++i ) { const TopoDS_Shape& aShape = theShapes.Value( i ); - theStream << "Shape " << i << " : " << 0 /*aShape.TShape()*/ << "\n"; + theStream << "Shape " << i << " : " << aShape.TShape().get() << "\n"; } } diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx index 94d57ea7..29d93734 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.cxx +++ b/src/HYDROData/HYDROData_SplitToZonesTool.cxx @@ -644,6 +644,19 @@ HYDROData_SplitToZonesTool::SplitDataList } } + +#ifdef DEB_SPLIT_TO_ZONES + BRep_Builder B; + TopoDS_Compound cmp2; + B.MakeCompound(cmp2); + HYDROData_DataMapIteratorOfDataMapOfShapeListOfShape dIt(aDM2); + for(int i =1;dIt.More();dIt.Next(),i++) + { + const TopoDS_Shape& aKey = dIt.Key(); + B.Add(cmp2, aKey); + } +#endif + AddInternalEdges(aDM2, InterPolys, &OutNE); NCollection_DataMap::Iterator spit(OutNE); for (;spit.More();spit.Next()) @@ -740,15 +753,29 @@ void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOf HYDROData_DataMapOfShapeListOfShape newDM; TopTools_IndexedDataMapOfShapeShape OutNE1; + + BRep_Builder BB; + TopoDS_Compound cmpDM; + BB.MakeCompound(cmpDM); + TopTools_ListOfShape out; + + for (int i = 1; i <= DM.Extent();i++) + { + const TopoDS_Shape& K = DM.FindKey(i); + BB.Add(cmpDM, K); + } + + TopTools_IndexedDataMapOfShapeListOfShape OInSH2MSH; + CutByEdges(cmpDM, Wires, out, true, &OutNE1, &OInSH2MSH); + for (int i = 1; i <= DM.Extent();i++) { const TopoDS_Shape& K = DM.FindKey(i); - const TopTools_ListOfShape& V = DM.FindFromIndex(i); - TopTools_ListOfShape out; - if (K.ShapeType() == TopAbs_FACE) + const TopTools_ListOfShape& V = DM.FindFromIndex(i); + TopTools_ListOfShape modifSh = OInSH2MSH.FindFromKey(K); + if (!modifSh.IsEmpty()) { - CutByEdges(K, Wires, out, &OutNE1, NULL); - TopTools_ListIteratorOfListOfShape it(out); + TopTools_ListIteratorOfListOfShape it(modifSh); for (;it.More(); it.Next()) { const TopoDS_Shape& NF = it.Value(); @@ -757,9 +784,11 @@ void HYDROData_SplitToZonesTool::AddInternalEdges(HYDROData_DataMapOfShapeListOf } } else - newDM.Add(K, V); // ignore edges, wires... + newDM.Add(K, V); //was not modified by bop (CutByEdges) } + + for (int i = 1; i <= OutNE1.Extent(); i++) OutNE->Bind(OutNE1.FindKey(i), W2P(OutNE1.FindFromIndex(i))); @@ -785,7 +814,7 @@ void HYDROData_SplitToZonesTool::CutFaceByEdges(const TopoDS_Face& in, } TopTools_IndexedDataMapOfShapeShape OutNE1; - CutByEdges(in, Wires, out, &OutNE1, OutOrSh2M); + CutByEdges(in, Wires, out, false, &OutNE1, OutOrSh2M); for (int i = 1; i <= OutNE1.Extent(); i++) OutNE->Bind(OutNE1.FindKey(i), W2P(OutNE1.FindFromIndex(i))); @@ -794,6 +823,7 @@ void HYDROData_SplitToZonesTool::CutFaceByEdges(const TopoDS_Face& in, int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW, TopTools_ListOfShape& outShs, + bool OutShapeAsRes, TopTools_IndexedDataMapOfShapeShape* OutNE, TopTools_IndexedDataMapOfShapeListOfShape* OInSH2MSH) { @@ -818,9 +848,17 @@ int HYDROData_SplitToZonesTool::CutByEdges(const TopoDS_Shape& InSh, const TopTo if (anAlgo.HasErrors()) return -1; - outShs = anAlgo.Modified( InSh ); - if (outShs.IsEmpty()) - outShs.Append(InSh); + if (!OutShapeAsRes) + { + outShs = anAlgo.Modified( InSh ); + if (outShs.IsEmpty()) + outShs.Append(InSh); + } + else + { + TopoDS_Shape Res = anAlgo.Shape(); + outShs.Append(Res); + } if (OutNE) { diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.h b/src/HYDROData/HYDROData_SplitToZonesTool.h index 665f35a0..b4e092eb 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.h +++ b/src/HYDROData/HYDROData_SplitToZonesTool.h @@ -107,6 +107,7 @@ public: static int CutByEdges(const TopoDS_Shape& InSh, const TopTools_ListOfShape& InW, TopTools_ListOfShape& outShs, + bool OutShapeAsRes, TopTools_IndexedDataMapOfShapeShape* OutNE2OE, TopTools_IndexedDataMapOfShapeListOfShape* OInSH2MSH); diff --git a/src/HYDRO_tests/test_HYDROData_CalcCase.cxx b/src/HYDRO_tests/test_HYDROData_CalcCase.cxx index 2719ca7b..1ea686c7 100644 --- a/src/HYDRO_tests/test_HYDROData_CalcCase.cxx +++ b/src/HYDRO_tests/test_HYDROData_CalcCase.cxx @@ -50,7 +50,7 @@ void test_HYDROData_CalcCase::test_add_int_wires() TopTools_ListOfShape OutSh; TopTools_IndexedDataMapOfShapeShape ls; - HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL); + HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, false, &ls, NULL); CPPUNIT_ASSERT_EQUAL(2, OutSh.Extent()); TopoDS_Compound cmp; @@ -74,7 +74,7 @@ void test_HYDROData_CalcCase::test_add_int_wires() TopTools_ListOfShape OutSh; TopTools_IndexedDataMapOfShapeShape ls; - HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL); + HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, false, &ls, NULL); CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent()); TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_2" ); //CPPUNIT_ASSERT_IMAGES @@ -93,7 +93,7 @@ void test_HYDROData_CalcCase::test_add_int_wires() TopTools_ListOfShape OutSh; TopTools_IndexedDataMapOfShapeShape ls; - HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, &ls, NULL); + HYDROData_SplitToZonesTool::CutByEdges(InF, Wires, OutSh, false, &ls, NULL); CPPUNIT_ASSERT_EQUAL(1, OutSh.Extent()); TestViewer::show( OutSh.First(), AIS_WireFrame, true, "cc_int_w_3", 1, 1 ); CPPUNIT_ASSERT_IMAGES -- 2.39.2