]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
OCC functionality moving out from the widget
authornds <nds@opencascade.com>
Wed, 4 Dec 2013 04:08:29 +0000 (04:08 +0000)
committernds <nds@opencascade.com>
Wed, 4 Dec 2013 04:08:29 +0000 (04:08 +0000)
One compound shape for curve sections.

src/HYDROCurveCreator/CurveCreator_Curve.cxx
src/HYDROCurveCreator/CurveCreator_Curve.hxx
src/HYDROCurveCreator/CurveCreator_Utils.cxx
src/HYDROCurveCreator/CurveCreator_Utils.h

index 26268884a478d27e839db990be5dc490a85dab1f..ac43473ce7d33d1cdcd1ff670a13285470571b53 100644 (file)
@@ -28,8 +28,6 @@
 #include "CurveCreator_Displayer.h"
 #include "CurveCreator_Utils.h"
 
-#include <AIS_Point.hxx>
-#include <AIS_Line.hxx>
 #include <AIS_Shape.hxx>
 #include <Geom_CartesianPoint.hxx>
 #include <gp_Pnt.hxx>
@@ -182,20 +180,6 @@ int CurveCreator_Curve::toICoord(const int theIPnt) const
   return theIPnt * myDimension;
 }
 
-std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructSection( int theISection ) const
-{
-  std::vector<Handle_AIS_InteractiveObject> aSectionRepresentation;
-
-  TopoDS_Shape aShape;
-  CurveCreator_Utils::constructShape( this, theISection, aShape, aSectionRepresentation );
-
-  AIS_Shape* anAISShape = new AIS_Shape( aShape );
-  //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
-  aSectionRepresentation.push_back( anAISShape );
-
-  return aSectionRepresentation;
-}
-
 //=======================================================================
 // function: setUndoDepth
 // purpose:
@@ -254,35 +238,6 @@ int CurveCreator_Curve::getUndoDepth() const
   return myUndoDepth;
 }
 
-Handle_AIS_Point CurveCreator_Curve::getAISPoint( int theISection, int theIPoint ) const
-{
-  double anX, anY, aZ;
-  getCoordinates( theISection, theIPoint, anX, anY, aZ );
-  gp_Pnt aPoint( anX, anY, aZ);
-
-  AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
-  return aPnt;
-}
-
-Handle_AIS_Line CurveCreator_Curve::getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const
-{
-  double anX, anY, aZ;
-  getCoordinates( theISection, theIPoint1, anX, anY, aZ );
-  gp_Pnt aPoint1( anX, anY, aZ);
-
-  double anX2, anY2, aZ2;
-  getCoordinates( theISection, theIPoint2, anX2, anY2, aZ2 );
-//MTN to avoid crash during line construction
-  if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
-    aZ2 += 1e-7;
-  }
-
-  gp_Pnt aPoint2( anX2, anY2, aZ2 );
-
-  AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
-  return aLine;
-}
-
 void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
 {
   CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
@@ -1016,29 +971,10 @@ std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire() co
 {
   std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
 
-#ifndef ONE_SHAPE
-  std::vector<Handle_AIS_InteractiveObject> aSectionObjects;
-  for( int iSection = 0 ; iSection < getNbSections() ; iSection++ ){
-    aSectionObjects = constructSection( iSection );
-    for( int iObject = 0 ; iObject < aSectionObjects.size() ; iObject++ ){
-      aCurveRepresentation.push_back( aSectionObjects.at(iObject) );
-    }
-  }
-#else
   TopoDS_Shape aShape;
   CurveCreator_Utils::constructShape( this, aShape );
 
   AIS_Shape* anAISShape = new AIS_Shape( aShape );
-  //aShape->SetSelectionMode( AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
   aCurveRepresentation.push_back( anAISShape );
-#endif
   return aCurveRepresentation;
 }
-
-void CurveCreator_Curve::getPoint( const int theISection, const int theIPoint,
-                                   gp_Pnt& thePoint ) const
-{
-  double anX, anY, aZ;
-  getCoordinates( theISection, theIPoint, anX, anY, aZ );
-  thePoint = gp_Pnt( anX, anY, aZ);
-}
index 0981118855dd49a6dc4d328b599dba49ac38e137..67f0242f3d68da2e7b6d7064220b7657a29eb924 100644 (file)
@@ -30,8 +30,6 @@
 #include "CurveCreator_Diff.hxx"
 #include "CurveCreator_AISCurve.hxx"
 
-#include <AIS_Point.hxx>
-#include <AIS_Line.hxx>
 #include <AIS_InteractiveObject.hxx>
 
 #include <list>
@@ -94,8 +92,6 @@ public:
    */
   virtual int toICoord(const int theIPnt) const;
 
-  ListAISObjects constructSection( int theISection ) const;
-
   //! For internal use only! Undo/Redo are not used here.
   virtual bool moveSectionInternal(const int theISection,
                            const int theNewIndex);
@@ -111,8 +107,6 @@ protected:
   virtual bool addEmptyDiff();
 
 public: // TODO: remove public
-  Handle_AIS_Point getAISPoint( int theISection, int theIPoint ) const;
-  Handle_AIS_Line  getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const;
   void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
 protected:  // TODO: remove public
   void redisplayCurve();
@@ -270,9 +264,6 @@ public:
   /***********************************************/
   virtual ListAISObjects constructWire() const;
 
-public: // TODO: remove
-  void getPoint( const int theSectionId, const int thePointId, gp_Pnt& thePoint ) const;
-
 public:
   Handle(CurveCreator_AISCurve)   myAISCurve;
   bool                            myIsLocked;
index 0007e660c82fe01417f2f1d0b6de90c17e45b040..5e39c62504b5425c24ce6268e71dec910bb0c809 100644 (file)
@@ -84,135 +84,6 @@ gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) a
   return GEOMUtils::ConvertClickToPoint( x, y, aView );
 }
 
-
-//#define USE_COMPOUND
-#include "CurveCreator_Curve.hxx" // TODO - remove
-void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
-                                         const int theISection, TopoDS_Shape& theShape,
-                                         std::vector<Handle_AIS_InteractiveObject>& aSectionRepresentation )
-{
-  CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection );
-
-
-  int aPointSize = theCurve->getNbPoints( theISection );
-  bool aSectIsClosed = theCurve->isClosed( theISection );
-  if( aSectType == CurveCreator::Polyline )
-  {
-#ifdef USE_COMPOUND
-    BRep_Builder aBuilder;
-    TopoDS_Compound aComp;
-    aBuilder.MakeCompound(aComp);
-
-    int iPoint = 0;
-    gp_Pnt aPrevPoint, aPoint;
-    if ( aPointSize == 1 ) {
-      CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPrevPoint );
-      TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPrevPoint ).Vertex();
-      aBuilder.Add( aComp, aVertex );
-    }
-    else if ( aPointSize > 1 ) {
-      TopoDS_Edge aPointEdge;
-      TopoDS_Vertex aVertex;
-      CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPrevPoint );
-      aVertex = BRepBuilderAPI_MakeVertex( aPrevPoint ).Vertex();
-      aBuilder.Add( aComp, aVertex );
-      iPoint++;
-      for( ; iPoint < aPointSize; iPoint++ ) {
-        CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
-        aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
-        aBuilder.Add( aComp, aVertex );
-        aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
-        aBuilder.Add( aComp, aPointEdge );
-        aPrevPoint = aPoint;
-      }
-      if( aSectIsClosed && ( aPointSize > 2 ) ) {
-        CurveCreator_UtilsICurve::getPoint( theCurve, theISection, 0, aPoint );
-        aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
-        aBuilder.Add( aComp, aVertex );
-        aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
-        aBuilder.Add( aComp, aPointEdge );
-      }
-      theShape = aComp;
-    }
-#endif
-  }
-  else if( aSectType == CurveCreator::Spline )
-  {
-    std::vector<double> aPoints;
-    for( int iPoint = 0; iPoint < aPointSize; iPoint++ )
-    {
-      CurveCreator::Coordinates aCoords = theCurve->getPoint( theISection, iPoint );
-      double aX = aCoords[0];
-      double aY = aCoords[1];
-      double aZ = aCoords[2];
-      aPoints.push_back( aX );
-      aPoints.push_back( aY );
-    }
-
-    if( aPointSize > 1 )
-    {
-      Handle(Geom_BSplineCurve) aBSplineCurve;
-      // fill array for algorithm by the received coordinates
-      int aLen = aPoints.size() / 2;
-      Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen);
-      std::vector<double>::const_iterator aListIter = aPoints.begin();
-      for (int ind = 1; ind <= aLen; ind++) {
-        gp_Pnt aPnt(gp::Origin());
-        aPnt.SetX(*aListIter);
-        aListIter++;
-        aPnt.SetY(*aListIter);
-        aListIter++;
-        aPnt.SetZ(0);
-        aHCurvePoints->SetValue(ind, aPnt);
-      }
-      // compute BSpline
-      GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution());
-      aGBC.Perform();
-      if (aGBC.IsDone()) {
-        aBSplineCurve = aGBC.Curve();
-      }
-      TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge();
-
-      TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
-      theShape = aWire;
-    }
-  }
-
-  const CurveCreator_Curve* aCurve = dynamic_cast<const CurveCreator_Curve*>( theCurve );
-  if ( !aCurve )
-    return;
-
-  if( aSectType == CurveCreator::Polyline )
-  {
-#ifndef USE_COMPOUND
-    int iPoint = 0; 
-    for( ; iPoint < ( aPointSize - 1 ) ; iPoint++ ){
-      Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint);
-      aSectionRepresentation.push_back( anAISPnt );
-      Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, iPoint+1 );
-      aSectionRepresentation.push_back( aLine );
-    }
-    if( aPointSize != 0 ){
-      Handle_AIS_Point anAISPnt = aCurve->getAISPoint(theISection, iPoint); 
-      aSectionRepresentation.push_back( anAISPnt );
-      if( aSectIsClosed && ( aPointSize > 1 ) ){
-        Handle_AIS_Line aLine = aCurve->getAISLine( theISection, iPoint, 0 );
-        aSectionRepresentation.push_back( aLine );
-      }
-    }
-#endif
-  }
-  else if( aSectType == CurveCreator::Spline )
-  {
-    std::vector<double> aPoints;
-    for( int iPoint = 0; iPoint < aPointSize; iPoint++ )
-    {
-      Handle_AIS_Point anAISPnt = aCurve->getAISPoint( theISection, iPoint );
-      aSectionRepresentation.push_back( anAISPnt );
-    }
-  }
-}
-
 void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
                                          TopoDS_Shape& theShape )
 {
index b81f4cf2bb9ff3ff96fc91d32162bdc0cf7cea0e..0182d19b16611005a20cd09fbbcb3325969b7a81 100644 (file)
@@ -61,17 +61,6 @@ public:
   CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y,
                                                          Handle(V3d_View) theView );
 
-  /**
-   * Generates shape on the curve with a fixed section index
-   * \param theCurve a curve object, that contains data
-   * \param theISection a curve section index
-   * \param theShape a generated shape
-   */
-  CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
-                                                  const int theISection,
-                                                  TopoDS_Shape& theShape,
-                                                  std::vector<Handle_AIS_InteractiveObject>& theAdditional );
-
   /**
    * Generates shape on the curve
    * \param theCurve a curve object, that contains data