X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_TopoCurve.cxx;h=c08d6bf6d84d324194718d02d6a16912092935be;hb=d398a8be8e0b0259b476b358d53d234ce4c82379;hp=9183b3556aa1361eccec6806b5e1b92d8ecc5b29;hpb=2c701f7ccb7e83e06eb3ed6af61739ee46c07392;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_TopoCurve.cxx b/src/HYDROData/HYDROData_TopoCurve.cxx index 9183b355..c08d6bf6 100644 --- a/src/HYDROData/HYDROData_TopoCurve.cxx +++ b/src/HYDROData/HYDROData_TopoCurve.cxx @@ -1,8 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// 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 @@ -43,6 +39,10 @@ #include #include +#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" +#include + //! The type is intended to traverse the container //! either from the begin to the end or vice versa. template @@ -134,7 +134,7 @@ static TopoDS_Edge ReplaceVertex( } // Projects the point to the curve. -static double ProjectPointToCurve( +double ProjectPointToCurve( const gp_XYZ& thePoint, const Adaptor3d_Curve& theCurve, double& theParameter) @@ -367,12 +367,13 @@ static bool Interpolate( bool HYDROData_TopoCurve::Initialize(const TopoDS_Wire& theWire) { - // Check for nonemptiness. + // Check for non-emptiness. myEdges.clear(); TopTools_IndexedDataMapOfShapeListOfShape aVertexToEdges; TopExp::MapShapesAndAncestors(theWire, TopAbs_VERTEX, TopAbs_EDGE, aVertexToEdges); const int aVCount = aVertexToEdges.Extent(); + DEBTRACE("initialize VCount= "<< aVCount); if (aVCount == 0) { return false; @@ -458,22 +459,24 @@ bool HYDROData_TopoCurve::Initialize(const TopoDS_Wire& theWire) TopoDS_Wire HYDROData_TopoCurve::Wire() const { TopoDS_Wire aWire; - BRep_Builder aBulder; - aBulder.MakeWire(aWire); + BRep_Builder aBuilder; + aBuilder.MakeWire(aWire); std::list::const_iterator aEItLast = myEdges.end(); std::list::const_iterator aEIt = myEdges.begin(); for (; aEIt != aEItLast; ++aEIt) { - aBulder.Add(aWire, *aEIt); + aBuilder.Add(aWire, *aEIt); } return aWire; } -void HYDROData_TopoCurve::Cut( +bool HYDROData_TopoCurve::Cut( const std::list::iterator& theEdgePosition, const double theParameter, HYDROData_TopoCurve& theCurve) { + bool aResult = false; + // Locate the edge. std::list::iterator aFirstEIt = myEdges.begin(); std::list::iterator aEIt = aFirstEIt; @@ -498,6 +501,8 @@ void HYDROData_TopoCurve::Cut( { aParamI ^= 1; } + const bool isClosed = IsClosed(); + DEBTRACE("aParamI: " << aParamI << " isClosed: "<< isClosed); if (aParamI < 0) { aEdge.Orientation(TopAbs_FORWARD); @@ -529,19 +534,41 @@ void HYDROData_TopoCurve::Cut( *aEIt = aEParts[aFirstPI]; InsertAfter(aEIt, aEParts[1 - aFirstPI], myEdges); ++aEIt; + + aResult = true; } - else if (aParamI > 0) + else { - ++aEIt; + TopoDS_Edge aNewEdge = ReplaceVertex(aEdge, (aParamI == 0) ? false : true); + *aEIt = aNewEdge; + if (aParamI > 0) + { + ++aEIt; + + std::list::iterator aEdgePosition = theEdgePosition; + if (isClosed || ++aEdgePosition != myEdges.end()) + { + aResult = true; + } + } + else + { + if (isClosed || theEdgePosition != aFirstEIt) + { + aResult = true; + } + } } // Calculate the curve parts. std::list::iterator aLastEIt = myEdges.end(); if (aEIt != aFirstEIt && aEIt != aLastEIt) { - std::list* aEdges = !IsClosed() ? &theCurve.myEdges : &myEdges; + std::list* aEdges = !isClosed ? &theCurve.myEdges : &myEdges; aEdges->splice(aEdges->begin(), myEdges, aEIt, aLastEIt); } + + return aResult; } void HYDROData_TopoCurve::Cut( @@ -557,23 +584,34 @@ void HYDROData_TopoCurve::Cut( theCurve1.Cut(aEPos1, theParameter, theCurve2); } -void HYDROData_TopoCurve::Cut( +bool HYDROData_TopoCurve::Cut( const std::deque >& theParameters, std::deque& theCurves) const { + bool aResult = false; HYDROData_TopoCurve aCurves[2]; aCurves[0] = *this; int aCI = 0; std::list::iterator aEIt = aCurves[0].myEdges.begin(); std::deque >::const_iterator aPLIt = theParameters.begin(); for (std::deque >::const_iterator aLastPLIt = - theParameters.end(); aPLIt != aLastPLIt; ++aEIt, ++aPLIt) + theParameters.end(); aPLIt != aLastPLIt; ++aPLIt) { + TopoDS_Edge aNextEdge; + { + std::list::iterator aNextEIt = aEIt; + ++aNextEIt; + if (aNextEIt != aCurves[aCI].myEdges.end()) + { + aNextEdge = *aNextEIt; + } + } + for (Iterator, std::list::const_iterator> aPIt( *aPLIt, (aEIt->Orientation() != TopAbs_REVERSED)); aPIt.More(); ++aPIt) { const int aCI1 = 1 - aCI; - aCurves[aCI].Cut(aEIt, **aPIt, aCurves[aCI1]); + aResult |= aCurves[aCI].Cut(aEIt, **aPIt, aCurves[aCI1]); if (!aCurves[aCI1].IsEmpty()) { theCurves.push_back(HYDROData_TopoCurve()); @@ -586,8 +624,14 @@ void HYDROData_TopoCurve::Cut( aEIt = aCurves[aCI].myEdges.begin(); } } + + if (!aNextEdge.IsNull() && !aEIt->IsEqual(aNextEdge)) + { + ++aEIt; + } } theCurves.push_back(aCurves[aCI]); + return aResult; } double HYDROData_TopoCurve::Project( @@ -616,6 +660,10 @@ int HYDROData_TopoCurve::Intersect( const TopoDS_Wire& theWire, std::deque >& theParameters) const { + //std::string brepName = "theWireToIntersect"; + //brepName += ".brep"; + //BRepTools::Write( theWire, brepName.c_str() ); + int aIntCount = 0; theParameters.resize(myEdges.size()); std::list::const_iterator aEIt = myEdges.begin(); @@ -631,6 +679,7 @@ int HYDROData_TopoCurve::Intersect( aIntCount += IntersectEdge(aEdge,TopoDS::Edge(aEIt2.Current()), aParams); } } + DEBTRACE("aIntCount " << aIntCount); return aIntCount; }