]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
#refs 518
authorisn <isn@opencascade.com>
Tue, 19 May 2015 12:11:53 +0000 (15:11 +0300)
committerisn <isn@opencascade.com>
Tue, 19 May 2015 12:11:53 +0000 (15:11 +0300)
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_Polyline.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Polyline.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Shape.cxx

index d15866492d180d52dbd5fc740c52876f08bdbd8e..6f684a9cc2beec33024595311867bd6976be0280 100644 (file)
@@ -63,6 +63,7 @@ set(PROJECT_HEADERS
     HYDROGUI_Region.h
     HYDROGUI_RemoveImageRefsOp.h
     HYDROGUI_Shape.h
+    HYDROGUI_Polyline.h
     HYDROGUI_ShapeBathymetry.h
     HYDROGUI_ShapeImage.h
     HYDROGUI_ShowHideOp.h
@@ -173,6 +174,7 @@ set(PROJECT_SOURCES
     HYDROGUI_Region.cxx
     HYDROGUI_RemoveImageRefsOp.cxx
     HYDROGUI_Shape.cxx
+    HYDROGUI_Polyline.cxx
     HYDROGUI_ShapeBathymetry.cxx
     HYDROGUI_ShapeImage.cxx
     HYDROGUI_ShowHideOp.cxx
diff --git a/src/HYDROGUI/HYDROGUI_Polyline.cxx b/src/HYDROGUI/HYDROGUI_Polyline.cxx
new file mode 100644 (file)
index 0000000..e624cb3
--- /dev/null
@@ -0,0 +1,133 @@
+// 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
+//
+// 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 <HYDROGUI_Polyline.h>
+
+#include <AIS_InteractiveContext.hxx>
+#include <BRep_Tool.hxx>
+#include <GCPnts_AbscissaPoint.hxx>
+#include <GeomAdaptor_Curve.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <TopExp.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <BRepBndLib.hxx>
+#include <Precision.hxx>
+
+IMPLEMENT_STANDARD_HANDLE (HYDROGUI_Polyline, AIS_Shape)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROGUI_Polyline, AIS_Shape)
+
+
+HYDROGUI_Polyline::HYDROGUI_Polyline(const TopoDS_Shape& shape)
+  : AIS_Shape(shape)
+{ 
+}
+
+HYDROGUI_Polyline::~HYDROGUI_Polyline()
+{
+}
+
+void HYDROGUI_Polyline::Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                            const Handle(Prs3d_Presentation)& aPrs,
+                            const Standard_Integer aMode)
+{  
+  AIS_Shape::Compute(aPresentationManager, aPrs, aMode);
+   
+  TopExp_Explorer Exp ( myshape, TopAbs_EDGE );
+  for ( ; Exp.More(); Exp.Next() ) {
+    TopoDS_Vertex aV1, aV2;
+    TopoDS_Edge anEdge = TopoDS::Edge(Exp.Current());
+    
+    if ( anEdge.IsNull() ) 
+      continue;
+    TopExp::Vertices(anEdge, aV1, aV2);
+    gp_Pnt aP = BRep_Tool::Pnt(aV1);
+    gp_Vec aDirVec;
+    double aFp, aLp;
+    Handle(Geom_Curve) C = BRep_Tool::Curve(anEdge,aFp,aLp);
+    if ( C.IsNull() ) 
+      continue;
+  
+    Bnd_Box aBB;
+    BRepBndLib::Add(anEdge, aBB);
+    Standard_Real aXmin,aYmin,aZmin,aXmax,aYmax,aZmax;
+    aBB.Get(aXmin,aYmin,aZmin,aXmax,aYmax,aZmax);
+    Standard_Real aLen = Max(Abs(aXmax - aXmin), Max (Abs(aZmax - aZmin), Abs(aYmax - aYmin)));
+  
+    GeomAdaptor_Curve aAdC;
+    aAdC.Load(C, aFp, aLp);
+    double aLenC;
+    double aLenH;
+    int aNbSegments = 20;
+    double aArrLen = aLen / 10.;
+    double anIncr = (aLp-aFp)/aNbSegments;
+    double aMaxRatio = 0;
+    double aMaxRatioStep = 1;
+    for (double t = aFp; t < aLp - anIncr; t += anIncr)
+    {
+       aLenC  = GCPnts_AbscissaPoint::Length(aAdC, t, t + anIncr);
+       aLenH = C->Value (t).Distance (C->Value (t + anIncr));
+       if ( aLenH / aLenC > aMaxRatio) {
+         aMaxRatio = aLenH / aLenC;
+         aMaxRatioStep = t;
+       }
+    }
+
+    bool UseD1 = false;
+    if (Abs(aMaxRatioStep) < Precision::Confusion())
+    {
+      aMaxRatioStep = (aLp - aFp)/2.0;
+      UseD1 = true;
+    }
+
+    if (Abs(aLp - aMaxRatioStep) < Precision::Confusion())
+    {
+      aMaxRatioStep =  (aLp - aFp)/2.0;
+      UseD1 = true;
+    }      
+    
+    gp_Pnt aPnt1 = C->Value (aMaxRatioStep);
+    gp_Vec aDir;
+    if (!UseD1) {
+      GCPnts_AbscissaPoint aAbsPoint(aAdC, -aArrLen, aMaxRatioStep);
+      double aParam = aAbsPoint.Parameter();      
+      gp_Pnt aPnt2 = C->Value (aParam);
+      gp_XYZ D = aPnt1.XYZ();
+      D.Subtract (aPnt2.XYZ());
+      aDir = D;
+    }
+    else
+      C->D1(aMaxRatioStep, C->Value (aMaxRatioStep), aDir);
+  
+    if ( anEdge.Orientation() == TopAbs_REVERSED )
+      aDir = -aDir;
+  
+    Prs3d_Arrow::Draw(aPrs, aPnt1, aDir, M_PI/180.*12., aArrLen);     
+  }
+}
diff --git a/src/HYDROGUI/HYDROGUI_Polyline.h b/src/HYDROGUI/HYDROGUI_Polyline.h
new file mode 100644 (file)
index 0000000..e14c540
--- /dev/null
@@ -0,0 +1,55 @@
+// 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
+//
+// 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
+//
+
+#ifndef _HYDROGUI_Polyline_HeaderFile
+#define _HYDROGUI_Polyline_HeaderFile
+
+#include <AIS_Shape.hxx>
+#include <AIS_InteractiveObject.hxx>
+
+#include <Standard.hxx>
+#include <Standard_DefineHandle.hxx>
+#include <PrsMgr_PresentationManager.hxx>
+#include <Handle_Prs3d_Presentation.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <AIS_DisplayMode.hxx>
+
+class TopoDS_Shape;
+
+class HYDROGUI_Polyline : public AIS_Shape
+{
+public:
+  
+  Standard_EXPORT HYDROGUI_Polyline(const TopoDS_Shape& shape);
+  Standard_EXPORT ~HYDROGUI_Polyline();
+
+  Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+                                      const Handle(Prs3d_Presentation)& aPresentation,
+                                      const Standard_Integer aMode = 0);
+  
+public:
+  DEFINE_STANDARD_RTTI(HYDROGUI_Polyline);
+};
+
+DEFINE_STANDARD_HANDLE(HYDROGUI_Polyline, AIS_Shape)
+
+#endif
index 08900fbe1f320597af4ecc652aa135732ea981e2..182c586b9217abe4dd5be94cc193e0c7ba1a812f 100644 (file)
@@ -33,6 +33,7 @@
 #include <HYDROData_ShapesGroup.h>
 #include <HYDROData_Stream.h>
 #include <HYDROData_Zone.h>
+#include <HYDROGUI_PrsShape.h>
 
 #include <AIS_Shape.hxx>
 #include <BRep_Builder.hxx>
@@ -482,7 +483,12 @@ Handle_AIS_InteractiveObject HYDROGUI_Shape::createShape() const
   if( myTopoShape.IsNull() )
     return Handle_AIS_InteractiveObject();
   else
-    return new AIS_Shape( myTopoShape );
+    if ( myObject->IsKind( STANDARD_TYPE(HYDROData_PolylineXY) ) ||
+        myObject->IsKind( STANDARD_TYPE(HYDROData_Polyline3D)) ||
+        myObject->IsKind( STANDARD_TYPE(HYDROData_Profile) ))
+      return new HYDROGUI_PrsShape(myTopoShape);
+    else
+      return new AIS_Shape( myTopoShape );
 }
 
 void HYDROGUI_Shape::buildShape()