Back to index

salome-geom  6.5.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes
ShHealOper_EdgeDivide Class Reference

Class ShHealOper_EdgeDivide. More...

#include <ShHealOper_EdgeDivide.hxx>

Inheritance diagram for ShHealOper_EdgeDivide:
Inheritance graph
[legend]
Collaboration diagram for ShHealOper_EdgeDivide:
Collaboration graph
[legend]

List of all members.

Public Member Functions

Standard_EXPORT ShHealOper_EdgeDivide ()
Standard_EXPORT ShHealOper_EdgeDivide (const TopoDS_Shape &theShape)
 Empty constructor.
virtual Standard_EXPORT void Init (const TopoDS_Shape &theShape)
 Constructor initializes by shape.
Standard_EXPORT Standard_Boolean Perform (const TopoDS_Shape &theEdge, const Standard_Real theValue, const Standard_Boolean theDivideParamMode=Standard_True)
Standard_EXPORT Standard_Boolean Perform (const TopoDS_Shape &theEdge, const TColStd_SequenceOfReal &theValues, const Standard_Boolean theDivideParamMode=Standard_True)
const TopoDS_Shape & GetResultShape () const
Standard_Boolean GetModifiedShape (const TopoDS_Shape &theOldShape, TopoDS_Shape &theNewShape) const
Standard_Boolean IsDone () const
void SetContext (Handle(ShapeBuild_ReShape)&theContext)
 Handle (ShapeBuild_ReShape) Context()
Standard_Integer GetErrorStatus ()

Protected Member Functions

Standard_Boolean build (const Handle(TColStd_HSequenceOfReal)&theValues)
Standard_Boolean computeValues (const Handle(TColStd_HSequenceOfReal)&theValues, Standard_Boolean &theHas3d, Standard_Boolean &theHas2d, Standard_Boolean &hasPCurves)
 Handle (ShapeBuild_ReShape) myContext

Protected Attributes

TopoDS_Shape myInitShape
TopoDS_Shape myResultShape
Standard_Boolean myDone
ShHealOper_Error myErrorStatus

Private Attributes

TopTools_IndexedDataMapOfShapeListOfShape myMapEdgesFace
Standard_Boolean myDivideParamMode
TopoDS_Edge myEdge

Detailed Description

Class ShHealOper_EdgeDivide.

Definition at line 40 of file ShHealOper_EdgeDivide.hxx.


Constructor & Destructor Documentation

Definition at line 46 of file ShHealOper_EdgeDivide.hxx.

ShHealOper_EdgeDivide::ShHealOper_EdgeDivide ( const TopoDS_Shape &  theShape)

Empty constructor.

Definition at line 52 of file ShHealOper_EdgeDivide.cxx.

{
  Init(theShape);
}

Here is the call graph for this function:


Member Function Documentation

Standard_Boolean ShHealOper_EdgeDivide::build ( const Handle(TColStd_HSequenceOfReal)&  theValues) [protected]

Definition at line 120 of file ShHealOper_EdgeDivide.cxx.

{
  if(myEdge.IsNull() || !theValues->Length()) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return Standard_False;
  }

  Standard_Boolean has3d = Standard_False, 
  has2d = Standard_False, 
  hasPCurves = Standard_False;
  
  //computation of the split values in dependance from specified mode and values.
  if(!computeValues(theValues, has3d,has2d,hasPCurves)) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return Standard_False;
  }
  
  //setting split values in the splitting curve tools.
  Handle(ShapeUpgrade_WireDivide) aSplitTool = new ShapeUpgrade_WireDivide;
  aSplitTool->Load(myEdge);
  aSplitTool->SetContext(myContext);
  if(has3d) {
    Handle(ShHealOper_SplitCurve3d) aSplitCurve3d = new ShHealOper_SplitCurve3d;
    aSplitCurve3d->SetValues(theValues);
    aSplitTool->SetSplitCurve3dTool(aSplitCurve3d);
  }
  else if(has2d) {
    Handle(ShHealOper_SplitCurve2d) aSplitCurve2d = new ShHealOper_SplitCurve2d;
    aSplitCurve2d->SetValues(theValues);
    aSplitTool->SetSplitCurve2dTool(aSplitCurve2d);
  }
  else {
    myErrorStatus = ShHealOper_InvalidParameters;
    return Standard_False;
  }
  
  //split 3d curve and pcurve for each face reffering to edge.
  Standard_Boolean isDone = Standard_True;
  if(hasPCurves) {
    const TopTools_ListOfShape& lfaces  = myMapEdgesFace.FindFromKey(myEdge);
    TopTools_ListIteratorOfListOfShape aItf(lfaces);
    for( ; aItf.More() && isDone; aItf.Next()) {
      TopoDS_Face aFace = TopoDS::Face(aItf.Value());
      aSplitTool->SetFace(aFace);
      aSplitTool->Perform();
      isDone = aSplitTool->Status( ShapeExtend_DONE );
      if( aSplitTool->Status( ShapeExtend_FAIL ))
        myErrorStatus = ShHealOper_ErrorExecution;
    }
  }
  else {
     aSplitTool->Perform();
     isDone = aSplitTool->Status( ShapeExtend_DONE );
     if( aSplitTool->Status( ShapeExtend_FAIL ))
        myErrorStatus = ShHealOper_ErrorExecution;
  }
  if(isDone)
    myResultShape = myContext->Apply(myInitShape);
  return isDone;
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean ShHealOper_EdgeDivide::computeValues ( const Handle(TColStd_HSequenceOfReal)&  theValues,
Standard_Boolean &  theHas3d,
Standard_Boolean &  theHas2d,
Standard_Boolean &  hasPCurves 
) [protected]

Definition at line 186 of file ShHealOper_EdgeDivide.cxx.

{
  hasPCurves = (myMapEdgesFace.Contains(myEdge) && 
                myMapEdgesFace.FindFromKey(myEdge).Extent());
  if(hasPCurves && (!BRep_Tool::SameRange(myEdge) || !BRep_Tool::SameParameter(myEdge))) {
    ShapeFix_Edge sfe;
    sfe.FixSameParameter(myEdge);
  }
  
  Standard_Real aFirst =0.,aLast=0.;

  //computation of the split values if edge should be splitted by parameter.
  if(myDivideParamMode) {
    BRep_Tool::Range(myEdge,aFirst,aLast);
    Handle(Geom_Curve) aCurve = BRep_Tool::Curve(myEdge,aFirst,aLast);
    
    theHas3d = (!aCurve.IsNull());
    theHas2d = (aCurve.IsNull() && (fabs(aLast-aFirst) > Precision::PConfusion() ));
    Standard_Integer i = 1;
    for( ; i <= theValues->Length();i++) {
      Standard_Real aVal = theValues->Value(i);
      theValues->ChangeValue(i) = aFirst+ aVal*fabs(aLast - aFirst);
    }
  }
  else {
     //computation of the split values if edge should be splitted by length.
    ShapeAnalysis_Edge sae;
    Handle(Geom_Curve) aCurve;
    Standard_Real aCurLen =0.;
    GeomAdaptor_Curve aAdC;
    Geom2dAdaptor_Curve aAdC2d;
    if(sae.Curve3d(myEdge,aCurve,aFirst,aLast,Standard_False)) {
      aAdC.Load(aCurve,aFirst,aLast);
      aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast); 
      theHas3d = Standard_True;
    }
    else {
      if(hasPCurves) {
        TopoDS_Face aFace = TopoDS::Face(myMapEdgesFace.FindFromKey(myEdge).First());
        Handle(Geom2d_Curve) aCurve2d;
        if(sae.PCurve(myEdge,aFace,aCurve2d,aFirst,aLast)) {
          aAdC2d.Load(aCurve2d,aFirst,aLast);
          aCurLen = GCPnts_AbscissaPoint::Length(aAdC,aFirst,aLast);
          theHas2d = Standard_True;
        }
          
      }
    }
    if(!theHas3d && !theHas2d)
      return Standard_False;

    Standard_Integer i = 1;
    for( ; i <= theValues->Length();i++) {
      Standard_Real aLen = theValues->Value(i)*aCurLen;
      if(theHas3d) {
        GCPnts_AbscissaPoint anAbsc(aAdC,aLen,aFirst);
        if(anAbsc.IsDone()) 
          theValues->ChangeValue(i) = anAbsc.Parameter();
        else
          theValues->Remove(i--);
      }
      else if(theHas2d) {
        GCPnts_AbscissaPoint anAbsc(aAdC2d,aLen,aFirst);
        if(anAbsc.IsDone()) 
          theValues->ChangeValue(i) = anAbsc.Parameter();
        else
          theValues->Remove(i--);
      }
    }
  }
  return (theValues->Length());
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Integer ShHealOper_Tool::GetErrorStatus ( ) [inline, inherited]

Definition at line 90 of file ShHealOper_Tool.hxx.

  {
    return myErrorStatus;
  }

Here is the caller graph for this function:

Standard_Boolean ShHealOper_Tool::GetModifiedShape ( const TopoDS_Shape &  theOldShape,
TopoDS_Shape &  theNewShape 
) const [inline, inherited]

Definition at line 64 of file ShHealOper_Tool.hxx.

  {
    theNewShape = myContext->Apply(theOldShape);
    return (!theNewShape.IsSame(theOldShape));
  }
const TopoDS_Shape& ShHealOper_Tool::GetResultShape ( ) const [inline, inherited]

Definition at line 57 of file ShHealOper_Tool.hxx.

  {
    return myResultShape;

  }

Here is the caller graph for this function:

ShHealOper_Tool::Handle ( ShapeBuild_ReShape  ) [inline, inherited]

Definition at line 84 of file ShHealOper_Tool.hxx.

  {
    return myContext;
  }

Here is the caller graph for this function:

ShHealOper_Tool::Handle ( ShapeBuild_ReShape  ) [protected, inherited]
void ShHealOper_EdgeDivide::Init ( const TopoDS_Shape &  theShape) [virtual]

Constructor initializes by shape.

Reimplemented from ShHealOper_Tool.

Definition at line 61 of file ShHealOper_EdgeDivide.cxx.

{
  ShHealOper_Tool::Init(theShape);
  myDivideParamMode = Standard_True;
  myMapEdgesFace.Clear();
  TopExp::MapShapesAndAncestors(theShape,TopAbs_EDGE,TopAbs_FACE,myMapEdgesFace);
  
}

Here is the caller graph for this function:

Standard_Boolean ShHealOper_Tool::IsDone ( ) const [inline, inherited]

Definition at line 72 of file ShHealOper_Tool.hxx.

  {
    return myDone;
  }
Standard_Boolean ShHealOper_EdgeDivide::Perform ( const TopoDS_Shape &  theEdge,
const Standard_Real  theValue,
const Standard_Boolean  theDivideParamMode = Standard_True 
)

Definition at line 98 of file ShHealOper_EdgeDivide.cxx.

{
  myDone = Standard_False;
  myErrorStatus = ShHealOper_NotError;
  if(theEdge.ShapeType() != TopAbs_EDGE) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  }
  myDivideParamMode = theDivideParamMode;
  myEdge = TopoDS::Edge(theEdge);
  Handle(TColStd_HSequenceOfReal) aSeqValues = new TColStd_HSequenceOfReal;
  aSeqValues->Append(theValue);
  myDone = build(aSeqValues);
  return myDone;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean ShHealOper_EdgeDivide::Perform ( const TopoDS_Shape &  theEdge,
const TColStd_SequenceOfReal &  theValues,
const Standard_Boolean  theDivideParamMode = Standard_True 
)

Definition at line 74 of file ShHealOper_EdgeDivide.cxx.

{ 
  myDone = Standard_False;
  myDivideParamMode = theDivideParamMode;
  if(theEdge.ShapeType() != TopAbs_EDGE) {
    myErrorStatus = ShHealOper_InvalidParameters;
    return myDone;
  }
  myEdge = TopoDS::Edge(theEdge);
  Standard_Integer i =1;
  Handle(TColStd_HSequenceOfReal) aSeqValues = new TColStd_HSequenceOfReal;
  for( ; i <= theValues.Length(); i++)
      aSeqValues->Append(theValues.Value(i));
  myDone = build(aSeqValues);
  return myDone;
  
}

Here is the call graph for this function:

void ShHealOper_Tool::SetContext ( Handle(ShapeBuild_ReShape)&  theContext) [inline, inherited]

Definition at line 78 of file ShHealOper_Tool.hxx.

  {
    myContext = theContext;
  }

Member Data Documentation

Standard_Boolean ShHealOper_EdgeDivide::myDivideParamMode [private]

Definition at line 85 of file ShHealOper_EdgeDivide.hxx.

Standard_Boolean ShHealOper_Tool::myDone [protected, inherited]

Definition at line 100 of file ShHealOper_Tool.hxx.

TopoDS_Edge ShHealOper_EdgeDivide::myEdge [private]

Definition at line 86 of file ShHealOper_EdgeDivide.hxx.

Definition at line 101 of file ShHealOper_Tool.hxx.

TopoDS_Shape ShHealOper_Tool::myInitShape [protected, inherited]

Definition at line 98 of file ShHealOper_Tool.hxx.

TopTools_IndexedDataMapOfShapeListOfShape ShHealOper_EdgeDivide::myMapEdgesFace [private]

Definition at line 84 of file ShHealOper_EdgeDivide.hxx.

TopoDS_Shape ShHealOper_Tool::myResultShape [protected, inherited]

Definition at line 99 of file ShHealOper_Tool.hxx.


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