X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_SplitToZonesTool.cxx;h=94d57ea7b5647713be2d65eae0fb0b370f2707fe;hb=a4ddb8bafa510cc57431846ed83623fdb860c580;hp=16062cf5b19877fd96cb7f8a74be1b6e9aa15890;hpb=c9d7c382c6cbf049d56cd27a8155376ffcd89175;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_SplitToZonesTool.cxx b/src/HYDROData/HYDROData_SplitToZonesTool.cxx index 16062cf5..94d57ea7 100644 --- a/src/HYDROData/HYDROData_SplitToZonesTool.cxx +++ b/src/HYDROData/HYDROData_SplitToZonesTool.cxx @@ -1,3 +1,20 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include "HYDROData_SplitToZonesTool.h" @@ -17,12 +34,18 @@ #include #include #include +#include #include #include #include #include #include +#include +#include +#include +#include + //#define DEB_SPLIT_TO_ZONES 1 //#define DEB_SPLIT_TO_ZONES_CHECK_PARTITION 1 #if (defined (DEB_SPLIT_TO_ZONES) || defined(DEB_SPLIT_TO_ZONES_CHECK_PARTITION)) @@ -30,6 +53,9 @@ static TCollection_AsciiString fileNameBefore("BeforeTranslation"); #endif +//#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + TopoDS_Face HYDROData_SplitToZonesTool::SplitData::Face() const { TopoDS_Face aResFace; @@ -93,7 +119,7 @@ void HYDROData_SplitToZonesTool::SetFileNames(const QString& theNameBefore, cons #endif } //====================================================================================== -Standard_Integer HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& theComp, +bool HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& theComp, HYDROData_Transform& theTool) { theTool.Clear(); @@ -102,18 +128,23 @@ Standard_Integer HYDROData_SplitToZonesTool::SplitFaces(const TopoDS_Compound& t const Standard_Boolean bToTransform = theTool.ToTransform(); theTool.SetToTransform(bToTransform); theTool.Perform(); - Standard_Integer anErr = theTool.ErrorStatus(); - return anErr; + return theTool.HasErrors(); } //====================================================================================== HYDROData_SplitToZonesTool::SplitDataList HYDROData_SplitToZonesTool::Split( const HYDROData_SequenceOfObjects& theObjectList, const HYDROData_SequenceOfObjects& theGroupsList, - const Handle(HYDROData_PolylineXY)& thePolyline ) + const Handle(HYDROData_PolylineXY)& thePolyline, + const HYDROData_SequenceOfObjects& InterPolys) { +#ifndef NDEBUG + DEBTRACE("Split"); +#endif SplitDataList anOutputSplitDataList; - if(theObjectList.IsEmpty()) return anOutputSplitDataList; + NCollection_DataMap 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; @@ -122,16 +153,18 @@ HYDROData_SplitToZonesTool::SplitDataList #endif for( int anIndex = 1, aLength = theObjectList.Length(); anIndex <= aLength; anIndex++ ) { - Handle(HYDROData_Object) aGeomObj = - Handle(HYDROData_Object)::DownCast( theObjectList.Value( anIndex ) ); - if( aGeomObj.IsNull() ) - continue; + Handle(HYDROData_Entity) anObj = theObjectList.Value( anIndex ); + TopoDS_Shape aShape; + + Handle(HYDROData_Object) aGeomObj = Handle(HYDROData_Object)::DownCast( anObj ); + if( !aGeomObj.IsNull() ) { + aShape = aGeomObj->GetTopShape(); + } - TopoDS_Shape aShape = aGeomObj->GetTopShape(); if ( aShape.IsNull() ) continue; #ifdef DEB_SPLIT_TO_ZONES - TCollection_AsciiString aName = aNam + anIndex + ".brep"; + TCollection_AsciiString aName = aNam + anIndex + "_a.brep"; BRepTools::Write(aShape, aName.ToCString()); #endif if ( aShape.ShapeType() == TopAbs_COMPOUND ) { @@ -140,12 +173,12 @@ HYDROData_SplitToZonesTool::SplitDataList for ( ; anExp.More(); anExp.Next() ) { const TopoDS_Face& aFace = TopoDS::Face( anExp.Current() ); if ( !aFace.IsNull() ) { - SplitData aSplitData( SplitData::Data_Zone, aFace, aGeomObj->GetName() ); + SplitData aSplitData( SplitData::Data_Zone, aFace, anObj->GetName() ); anInputSplitDataList.append( aSplitData ); } } } else { - SplitData aSplitData( SplitData::Data_Zone, aShape, aGeomObj->GetName() ); + SplitData aSplitData( SplitData::Data_Zone, aShape, anObj->GetName() ); anInputSplitDataList.append( aSplitData ); } } @@ -179,7 +212,7 @@ HYDROData_SplitToZonesTool::SplitDataList anInputGroupList.append( aSplitData ); #ifdef DEB_SPLIT_TO_ZONES QString aStr = aSplitData.ObjectNames.join(" "); - cout << "Group# = " < 1) { HYDROData_Transform splitTool; - const Standard_Integer anErr = SplitFaces(aCmp, splitTool); + bool anErr = SplitFaces(aCmp, splitTool); if(anErr) return anOutputSplitDataList; aResult = splitTool.Shape(); @@ -239,7 +354,7 @@ HYDROData_SplitToZonesTool::SplitDataList BRepCheck_Analyzer aCheck (aResult); if(!aCheck.IsValid()) { #ifdef DEB_SPLIT_TO_ZONES - cout << "result is not valid" < temporary solution is used - const TopTools_ListOfShape& aListOfGen = splitTool.Generated(anIt.Value()); - if(!aListOfGen.IsEmpty()) - foundF = Standard_True; - it.Initialize(aListOfGen); - for(;it.More();it.Next()) - aList.Append(it.Value()); + //const TopTools_ListOfShape& aListOfGen = splitTool.Generated(anIt.Value()); + //if(!aListOfGen.IsEmpty()) + //foundF = Standard_True; + //it.Initialize(aListOfGen); + //for(;it.More();it.Next()) + // aList.Append(it.Value()); + ********************************************************************* */ if(!foundF) // face is not modified aList.Append (anIt.Value()); - aDM1.Bind(anIt.Value(), aList); + aDM1.Add(anIt.Value(), aList); #ifdef DEB_SPLIT_TO_ZONES TCollection_AsciiString aName; #endif @@ -284,32 +401,36 @@ HYDROData_SplitToZonesTool::SplitDataList for (int j =1;exp.More();exp.Next(),j++) { aList.Clear(); Standard_Boolean foundE(Standard_False); - const TopTools_ListOfShape& aListM = splitTool.Modified(exp.Current()); - //cout << "NB_EDGE_M = " << aListM.Extent() <GetShape()); + if (! thePolyline.IsNull()) { + Handle(TopTools_HSequenceOfShape) aConnectedWires = new TopTools_HSequenceOfShape; + int nbWires = thePolyline->GetNbConnectedWires(aConnectedWires); + const TopoDS_Wire aBndWire = TopoDS::Wire(aConnectedWires->Value(1)); if(!aBndWire.IsNull()) { TopoDS_Face limFace; if(buildLimFace(aBndWire, limFace)) { @@ -348,10 +471,10 @@ HYDROData_SplitToZonesTool::SplitDataList aBndView.Add(anEdge); QStringList aListOfNames; aListOfNames.append(aBndName); - aDM3.Bind(anEdge, aListOfNames); + aDM3.Add(anEdge, aListOfNames); TopTools_ListOfShape aList; aList.Append(anEdge); - aDM1.Bind(anEdge,aList); + aDM1.Add(anEdge,aList); } HYDROData_MapOfShape aView; exp.Init (aResult, TopAbs_FACE); @@ -359,28 +482,30 @@ HYDROData_SplitToZonesTool::SplitDataList const TopoDS_Shape& aFace = exp.Current(); if(!aFace.IsNull()) { const TopTools_ListOfShape& aListOfNew = mkCom.Modified(aFace); - //cout << "Modified: " << aListOfNew.Extent() <::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 TCollection_AsciiString aNam4 ("SC_"); @@ -532,7 +669,7 @@ HYDROData_SplitToZonesTool::SplitDataList else { aDestSplitData.Type = SplitData::Data_Edge; #ifdef DEB_SPLIT_TO_ZONES - TCollection_AsciiString aName = aNam4 + i + ".brep"; + TCollection_AsciiString aName = aNam4 + i + "_k.brep"; BRepTools::Write(aKey,aName.ToCString()); #endif } @@ -542,23 +679,23 @@ HYDROData_SplitToZonesTool::SplitDataList TopTools_ListIteratorOfListOfShape it(aListOfOld); for(int j =1;it.More();it.Next(),j++) { const TopoDS_Shape& aSh = it.Value(); //old - if(aDM3.IsBound(aSh)) { - const QStringList& ObjectNames = aDM3.Find(aSh); + if(aDM3.Contains(aSh)) { + const QStringList& ObjectNames = aDM3.FindFromKey(aSh); aListOfNames.append(ObjectNames); #ifdef DEB_SPLIT_TO_ZONES - TCollection_AsciiString aName = aNam4 + i +"_" + j + ".brep"; + TCollection_AsciiString aName = aNam4 + i +"_" + j + "_l.brep"; BRepTools::Write(aSh ,aName.ToCString()); #endif } else { #ifdef DEB_SPLIT_TO_ZONES - TCollection_AsciiString aName = aNam4 +"__" + i +"_" + j + ".brep"; + TCollection_AsciiString aName = aNam4 +"__" + i +"_" + j + "_m.brep"; BRepTools::Write(aSh ,aName.ToCString()); - cout <