]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
new algo of stream pres
authorisn <isn@opencascade.com>
Wed, 5 Oct 2016 15:24:03 +0000 (18:24 +0300)
committerisn <isn@opencascade.com>
Wed, 5 Oct 2016 15:24:41 +0000 (18:24 +0300)
src/HYDROData/HYDROData_Stream.cxx
src/HYDROData/HYDROData_Stream.h

index ec4969fd7a5760a3980df063c26f970f96c5620e..1d76a26aaf8755d38ebd5d5941e309423a29980e 100644 (file)
@@ -1032,12 +1032,74 @@ void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination,
     }
   }
 }
+#include <GeomProjLib.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <Geom_Plane.hxx>
+#include <BRepTools.hxx>
+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<TopoDS_Edge>& 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<TopoDS_Edge> 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;
index 87ef5905f535654b2fbb1596328f8b89e54ecaa1..eb96c872ea8070730e17cc8ea3e928e80b28642b 100644 (file)
@@ -25,6 +25,7 @@
 #include <TopoDS_Edge.hxx>
 
 #include <Geom_BSplineCurve.hxx>
+#include <vector>
 
 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<TopoDS_Edge>& theProfiles3d,
                                                     PrsDefinition&              thePrs );
 
 public: