From: isn Date: Wed, 5 Oct 2016 15:24:03 +0000 (+0300) Subject: new algo of stream pres X-Git-Tag: v1.6~66 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=eff53137afb6aae0943b1ec135485f83a5000af5;p=modules%2Fhydro.git new algo of stream pres --- diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index ec4969fd..1d76a26a 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -1032,12 +1032,74 @@ void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination, } } } +#include +#include +#include +#include +static void ProjEdgeOnPlane(const TopoDS_Edge& inpEdge, const Handle_Geom_Plane& RefPlane, TopoDS_Edge& outSh, TopoDS_Vertex V1, TopoDS_Vertex V2) +{ + double f, l; + Handle(Geom_Curve) C3d = BRep_Tool::Curve(inpEdge, f, l); + Handle(Geom_Curve) ProjectedCurve = GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d, f, l), RefPlane, RefPlane->Position().Direction(), Standard_True); + if (V1.IsNull() || V2.IsNull()) + outSh = BRepLib_MakeEdge(ProjectedCurve); //create new vertices + else + outSh = BRepLib_MakeEdge(ProjectedCurve, V1, V2); +} + bool HYDROData_Stream::CreatePresentations( const TopoDS_Edge& theLeftBank, const TopoDS_Edge& theRightBank, - const TopTools_ListOfShape& theProfiles3d, + const std::vector& theProfiles3d, PrsDefinition& thePrs ) { + thePrs.myLeftBank = theLeftBank; + thePrs.myRightBank = theRightBank; + + BRep_Builder aBB; + TopoDS_Compound aCmp; + aBB.MakeCompound(aCmp); + for (size_t i = 0; i < theProfiles3d.size(); i++ ) + aBB.Add(aCmp, theProfiles3d[i]); + + aBB.Add(aCmp, theLeftBank); + aBB.Add(aCmp, theRightBank); + + thePrs.myPrs3D = aCmp; //3d pres + + + Handle_Geom_Plane RefPlane = new Geom_Plane(gp_Pnt(0,0,0), gp_Dir(0,0,1)); + std::vector internProf; + internProf.reserve(theProfiles3d.size() - 2); + + //project internal edges/profiles + for (size_t i = 1; i < theProfiles3d.size() - 1; i++ ) + { + TopoDS_Edge ProjEdge; + ProjEdgeOnPlane(theProfiles3d[i], RefPlane, ProjEdge, TopoDS_Vertex(), TopoDS_Vertex()); + internProf.push_back (TopoDS::Edge(ProjEdge.Oriented(TopAbs_INTERNAL))); + } + + TopoDS_Edge ProjEdgeIn, ProjEdgeOut; + TopoDS_Vertex V1In, V2In, V1Out, V2Out; + + ProjEdgeOnPlane(theProfiles3d.front(), RefPlane, ProjEdgeIn, TopoDS_Vertex(), TopoDS_Vertex()); + TopExp::Vertices(ProjEdgeIn, V1In, V2In); + + ProjEdgeOnPlane(theProfiles3d.back(), RefPlane, ProjEdgeOut, TopoDS_Vertex(), TopoDS_Vertex()); + TopExp::Vertices(ProjEdgeOut, V1Out, V2Out); + + TopoDS_Edge ProjEdgeLeftB, ProjEdgeRightB; + ProjEdgeOnPlane(theLeftBank, RefPlane, ProjEdgeLeftB, V1In, V1Out); + ProjEdgeOnPlane(theRightBank, RefPlane, ProjEdgeRightB, V2In, V2Out); + + BRepLib_MakeWire WM(ProjEdgeIn, ProjEdgeOut, ProjEdgeLeftB, ProjEdgeRightB); + for (size_t i = 0; i < internProf.size(); i++ ) + WM.Add(internProf[i]); + + TopoDS_Face outF = BRepLib_MakeFace(RefPlane, WM.Wire()).Face(); + thePrs.myPrs2D = outF; + return true; /*if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) { return false; diff --git a/src/HYDROData/HYDROData_Stream.h b/src/HYDROData/HYDROData_Stream.h index 87ef5905..eb96c872 100644 --- a/src/HYDROData/HYDROData_Stream.h +++ b/src/HYDROData/HYDROData_Stream.h @@ -25,6 +25,7 @@ #include #include +#include DEFINE_STANDARD_HANDLE(HYDROData_Stream, HYDROData_NaturalObject) @@ -87,7 +88,7 @@ public: */ HYDRODATA_EXPORT static bool CreatePresentations( const TopoDS_Edge& theLeftBank, const TopoDS_Edge& theRightBank, - const TopTools_ListOfShape& theProfiles3d, + const std::vector& theProfiles3d, PrsDefinition& thePrs ); public: