Back to index

salome-geom  6.5.0
Public Member Functions | Static Public Member Functions | Friends
GEOMImpl_SplineDriver Class Reference

#include <GEOMImpl_SplineDriver.hxx>

List of all members.

Public Member Functions

void * operator new (size_t, void *anAddress)
void * operator new (size_t size)
void operator delete (void *anAddress)
Standard_EXPORT GEOMImpl_SplineDriver ()
virtual Standard_EXPORT
Standard_Integer 
Execute (TFunction_Logbook &log) const
virtual Standard_EXPORT void Validate (TFunction_Logbook &) const
Standard_EXPORT Standard_Boolean MustExecute (const TFunction_Logbook &) const
Standard_EXPORT ~GEOMImpl_SplineDriver ()
Standard_EXPORT const Handle (Standard_Type)&DynamicType() const
Standard_EXPORT Standard_Boolean IsKind (const Handle(Standard_Type)&AType) const

Static Public Member Functions

static Standard_EXPORT const
Standard_GUID & 
GetID ()

Friends

Standard_EXPORT friend
Handle_Standard_Type & 
GEOMImpl_SplineDriver_Type_ ()

Detailed Description

Definition at line 125 of file GEOMImpl_SplineDriver.hxx.


Constructor & Destructor Documentation

Definition at line 67 of file GEOMImpl_SplineDriver.cxx.

{
}

Definition at line 149 of file GEOMImpl_SplineDriver.hxx.

{};

Member Function Documentation

Standard_Integer GEOMImpl_SplineDriver::Execute ( TFunction_Logbook &  log) const [virtual]

Definition at line 75 of file GEOMImpl_SplineDriver.cxx.

{
  if (Label().IsNull()) return 0;
  Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());

  GEOMImpl_ISpline aCI (aFunction);
  Standard_Integer aType = aFunction->GetType();

  TopoDS_Shape aShape;

  if (aType == SPLINE_BEZIER || aType == SPLINE_INTERPOLATION) {

    bool useCoords = aCI.GetConstructorType() == COORD_CONSTRUCTOR;
    TColgp_Array1OfPnt points(1, (useCoords ? aCI.GetLength() : 1) );
    if(useCoords) {
      Handle(TColStd_HArray1OfReal) aCoordsArray = aCI.GetCoordinates();
      int anArrayLength = aCoordsArray->Length();
      for (int i = 0, j = 1; i <= (anArrayLength-3); i += 3) {
       gp_Pnt aPnt = gp_Pnt(aCoordsArray->Value(i+1), aCoordsArray->Value(i+2), aCoordsArray->Value(i+3));
       points.SetValue(j,aPnt);
       j++;
      } 
    }

    
    int ind, aLen = aCI.GetLength();
    if (aLen < 2) return 0;
    Standard_Boolean isSeveral = Standard_False;
    gp_Pnt aPrevP;
    int aRealLen = aLen;
    if (aType == SPLINE_BEZIER && aCI.GetIsClosed()) {
      TopoDS_Vertex aV1;
      if(useCoords) {
       aV1 = BRepBuilderAPI_MakeVertex(points.Value(1));
      } else {
       Handle(GEOM_Function) aFPoint = aCI.GetPoint(1);
       TopoDS_Shape aFirstPnt = aFPoint->GetValue();
       aV1 = TopoDS::Vertex(aFirstPnt);
      }

      TopoDS_Vertex aV2;
      if(useCoords) { 
       aV2 = BRepBuilderAPI_MakeVertex(points.Value(aLen));
      } else {
       Handle(GEOM_Function) aLPoint = aCI.GetPoint(aLen);
       TopoDS_Shape aLastPnt = aLPoint->GetValue();
       aV2 = TopoDS::Vertex(aLastPnt);
      }
      
      if (!aV1.IsNull() && !aV2.IsNull() && !aV1.IsSame(aV2)) {
        aRealLen++;
      }
    }
    
    TColgp_Array1OfPnt CurvePoints (1, aRealLen);
    for (ind = 1; ind <= aLen; ind++) {
      gp_Pnt aP;
      if( useCoords ) { 
       aP = points.Value(ind);
        if (!isSeveral && ind > 1) {
          if (aP.Distance(aPrevP) > Precision::Confusion()) {
            isSeveral = Standard_True;
          }
        }
        CurvePoints.SetValue(ind, aP);
        aPrevP = aP;
      } else {      
       Handle(GEOM_Function) aRefPoint = aCI.GetPoint(ind);
       TopoDS_Shape aShapePnt = aRefPoint->GetValue();
       if (aShapePnt.ShapeType() == TopAbs_VERTEX) {
         aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
         if (!isSeveral && ind > 1) {
           if (aP.Distance(aPrevP) > Precision::Confusion()) {
             isSeveral = Standard_True;
           }
         }
         CurvePoints.SetValue(ind, aP);
         aPrevP = aP;
       }
      }
    }
    if (aType == SPLINE_BEZIER) {
      if (!isSeveral) {
        Standard_ConstructionError::Raise("Points for Bezier Curve are too close");
      }
      if (aRealLen > aLen) { // set last point equal to first for the closed curve
        CurvePoints.SetValue(aRealLen, CurvePoints.Value(1));
      }
      Handle(Geom_BezierCurve) GBC = new Geom_BezierCurve(CurvePoints);
      aShape = BRepBuilderAPI_MakeEdge(GBC).Edge();
    } else {
      //GeomAPI_PointsToBSpline GBC (CurvePoints);
      //aShape = BRepBuilderAPI_MakeEdge(GBC).Edge();
      
      Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aLen);

      if (aCI.GetDoReordering()) {
        for (int curInd = 1; curInd < aLen - 1; curInd++) {
          gp_Pnt curPnt = CurvePoints.Value(curInd);
          int nearInd = 0;
          double nearDist = RealLast();
          for (ind = curInd + 1; ind <= aLen; ind++) {
            double dist = curPnt.SquareDistance(CurvePoints.Value(ind));
            if (dist < nearDist && (nearDist - dist) > Precision::Confusion()) {
              nearInd = ind;
              nearDist = dist;
            }
          }
          if (nearInd > 0 && nearInd != curInd + 1) {
            // Keep given order of points to use it in case of equidistant candidates
            //               .-<---<-.
            //              /         \
            // o  o  o  c  o->o->o->o->n  o  o
            //          |  |           |
            //     curInd  curInd+1    nearInd
            gp_Pnt nearPnt = CurvePoints.Value(nearInd);
            for (ind = nearInd; ind > curInd + 1; ind--) {
              CurvePoints.SetValue(ind, CurvePoints.Value(ind - 1));
            }
            CurvePoints.SetValue(curInd + 1, nearPnt);
          }
        }
        for (ind = 1; ind <= aLen; ind++) {
          aHCurvePoints->SetValue(ind, CurvePoints.Value(ind));
        }
      }
      else {
        for (ind = 1; ind <= aLen; ind++) {
          aHCurvePoints->SetValue(ind, CurvePoints.Value(ind));
        }
      }
      
      bool isClosed = aCI.GetIsClosed();
      GeomAPI_Interpolate GBC (aHCurvePoints, isClosed, gp::Resolution());
      GBC.Perform();
      if (GBC.IsDone())
        aShape = BRepBuilderAPI_MakeEdge(GBC.Curve()).Edge();
      else
        return 0;
    }
  }
  else {
  }
  
  if (aShape.IsNull()) return 0;
  
  aFunction->SetValue(aShape);
  
  log.SetTouched(Label());
  
  return 1;
}

Here is the call graph for this function:

const Standard_GUID & GEOMImpl_SplineDriver::GetID ( ) [static]

Definition at line 56 of file GEOMImpl_SplineDriver.cxx.

{
  static Standard_GUID aSplineDriver("FF1BBB33-5D14-4df2-980B-3A668264EA16");
  return aSplineDriver;
}
Standard_EXPORT const GEOMImpl_SplineDriver::Handle ( Standard_Type  ) const [inline]

Definition at line 155 of file GEOMImpl_SplineDriver.hxx.

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_EXPORT Standard_Boolean GEOMImpl_SplineDriver::IsKind ( const Handle(Standard_Type)&  AType) const [inline]

Definition at line 156 of file GEOMImpl_SplineDriver.hxx.

{ return (STANDARD_TYPE(GEOMImpl_SplineDriver) == AType || TFunction_Driver::IsKind(AType)); } 

Here is the call graph for this function:

Standard_EXPORT Standard_Boolean GEOMImpl_SplineDriver::MustExecute ( const TFunction_Logbook &  ) const [inline]

Definition at line 147 of file GEOMImpl_SplineDriver.hxx.

{ return Standard_True; }
void GEOMImpl_SplineDriver::operator delete ( void *  anAddress) [inline]

Definition at line 137 of file GEOMImpl_SplineDriver.hxx.

      { 
        if (anAddress) Standard::Free((Standard_Address&)anAddress); 
      }
void* GEOMImpl_SplineDriver::operator new ( size_t  ,
void *  anAddress 
) [inline]

Definition at line 129 of file GEOMImpl_SplineDriver.hxx.

      {
        return anAddress;
      }
void* GEOMImpl_SplineDriver::operator new ( size_t  size) [inline]

Definition at line 133 of file GEOMImpl_SplineDriver.hxx.

      { 
        return Standard::Allocate(size); 
      }
virtual Standard_EXPORT void GEOMImpl_SplineDriver::Validate ( TFunction_Logbook &  ) const [inline, virtual]

Definition at line 146 of file GEOMImpl_SplineDriver.hxx.

{}

Friends And Related Function Documentation

Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_SplineDriver_Type_ ( ) [friend]

Definition at line 233 of file GEOMImpl_SplineDriver.cxx.

{

  static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
  if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
  static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
  if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
  static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
  if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);


  static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
  static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_SplineDriver",
                                                         sizeof(GEOMImpl_SplineDriver),
                                                         1,
                                                         (Standard_Address)_Ancestors,
                                                         (Standard_Address)NULL);

  return _aType;
}

The documentation for this class was generated from the following files: