Back to index

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

#include <GEOMImpl_GlueDriver.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_GlueDriver ()
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_GlueDriver ()
Standard_EXPORT TopoDS_Shape GlueWithWarnings (const TopoDS_Shape &theShape, const Standard_Real theTolerance, const TopAbs_ShapeEnum theShapeType, const Standard_Boolean doKeepNonSolids, TCollection_AsciiString &theWarning) const
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 ()
static Standard_EXPORT TopoDS_Shape GlueFaces (const TopoDS_Shape &theShape, const Standard_Real theTolerance, const Standard_Boolean doKeepNonSolids=Standard_True)
static Standard_EXPORT TopoDS_Shape GlueByList (const TopoDS_Shape &theShape, const Standard_Real theTolerance, const Standard_Boolean doKeepNonSolids, const TopTools_MapOfShape &theShapesList, const Standard_Boolean doGlueAllEdges)

Friends

Standard_EXPORT friend
Handle_Standard_Type & 
GEOMImpl_GlueDriver_Type_ ()

Detailed Description

Definition at line 129 of file GEOMImpl_GlueDriver.hxx.


Constructor & Destructor Documentation

Definition at line 62 of file GEOMImpl_GlueDriver.cxx.

{
}

Definition at line 153 of file GEOMImpl_GlueDriver.hxx.

{};

Member Function Documentation

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

Definition at line 717 of file GEOMImpl_GlueDriver.cxx.

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

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

  TopoDS_Shape aShape;
  TCollection_AsciiString aWrn;

  Handle(GEOM_Function) aRefBase = aCI.GetBase();
  TopoDS_Shape aShapeBase = aRefBase->GetValue();
  if (aShapeBase.IsNull()) {
    Standard_NullObject::Raise("Shape for gluing is null");
  }

  Standard_Real tol3d = aCI.GetTolerance();

  Standard_Boolean aKeepNonSolids = aCI.GetKeepNonSolids();

  if (aType == GLUE_FACES) {
    //aShape = GlueFacesWithWarnings(aShapeBase, tol3d, aKeepNonSolids, aWrn);
    aShape = GlueWithWarnings(aShapeBase, tol3d, TopAbs_FACE, aKeepNonSolids, aWrn);
  }
  else if (aType == GLUE_EDGES) {
    aShape = GlueWithWarnings(aShapeBase, tol3d, TopAbs_EDGE, aKeepNonSolids, aWrn);
  }
  else if (aType == GLUE_FACES_BY_LIST || aType == GLUE_EDGES_BY_LIST) {
    Handle(TColStd_HSequenceOfTransient) SF = aCI.GetFaces();
    TopTools_MapOfShape aFaces;
    int i = 1;
    for (; i <= SF->Length(); i++) {
      Handle(Standard_Transient) anItem = SF->Value(i);
      if (anItem.IsNull())
        continue;
      Handle(GEOM_Function) aRefSh = Handle(GEOM_Function)::DownCast(anItem);
      if (aRefSh.IsNull())
        continue;
      TopoDS_Shape aFace = aRefSh->GetValue();
      if (aFace.IsNull())
        continue;
      if (!aFaces.Contains(aFace))
        aFaces.Add(aFace);
    }

    Standard_Boolean aGlueAllEdges = Standard_False;
    if (aType == GLUE_FACES_BY_LIST)
      aGlueAllEdges = aCI.GetGlueAllEdges();

    //aShape = GlueFacesByList(aShapeBase, tol3d, aKeepNonSolids, aFaces);
    aShape = GlueByList(aShapeBase, tol3d, aKeepNonSolids, aFaces, aGlueAllEdges);
  }

  if (aShape.IsNull()) return 0;

  aFunction->SetValue(aShape);

  log.SetTouched(Label());

  if (!aWrn.IsEmpty()) {
    Standard_Failure::Raise(aWrn.ToCString());
  }

  return 1;
}

Here is the call graph for this function:

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

Definition at line 70 of file GEOMImpl_GlueDriver.cxx.

{
  static Standard_GUID aGlueDriver("FF1BBB63-5D14-4df2-980B-3A668264EA16");
  return aGlueDriver;
}
TopoDS_Shape GEOMImpl_GlueDriver::GlueByList ( const TopoDS_Shape &  theShape,
const Standard_Real  theTolerance,
const Standard_Boolean  doKeepNonSolids,
const TopTools_MapOfShape &  theShapesList,
const Standard_Boolean  doGlueAllEdges 
) [static]

Definition at line 603 of file GEOMImpl_GlueDriver.cxx.

{
  TopoDS_Shape aRes;

  GEOMAlgo_Gluer2 aGA;

  // 1. Initialization
  aGA.SetArgument(theShape);
  aGA.SetTolerance(theTolerance);
  aGA.SetKeepNonSolids(doKeepNonSolids);

  // 2. Detect interferred shapes
  aGA.Detect();
  Standard_Integer iErr = aGA.ErrorStatus();
  if (iErr) {
    switch (iErr) {
    case 11:
      Standard_Failure::Raise("GEOMAlgo_GlueDetector failed");
      break;
    case 13:
    case 14:
      Standard_Failure::Raise("PerformImagesToWork failed");
      break;
    default:
      {
        // description of all errors see in GEOMAlgo_Gluer2.cxx
        TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer2 with code ");
        aMsg += TCollection_AsciiString(iErr);
        Standard_Failure::Raise(aMsg.ToCString());
        break;
      }
    }
    return aRes;
  }

  // 3. Fill shapes to glue aMSG
  TopTools_DataMapOfShapeListOfShape aMSG;
  const TopTools_DataMapOfShapeListOfShape& aMSD = aGA.ShapesDetected();
  TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSD;
  aItMSD.Initialize(aMSD);
  for (; aItMSD.More(); aItMSD.Next()) {
    const TopoDS_Shape& aSx = aItMSD.Key();
    const TopTools_ListOfShape& aLSD = aItMSD.Value();
    TopTools_ListIteratorOfListOfShape anItLSD (aLSD);
    bool isToGlue = false;
    if (doGlueAllEdges && aSx.ShapeType() == TopAbs_EDGE) {
      isToGlue = true;
    }
    else {
      for (; anItLSD.More() && !isToGlue; anItLSD.Next()) {
        if (theShapesList.Contains(anItLSD.Value())) {
          isToGlue = true;
        }
      }
    }
    if (isToGlue) {
      aMSG.Bind(aSx, aLSD);
    }
  }

  // 4. Set shapes to glue. If the operator is absent, the whole gluing will be done
  aGA.SetShapesToGlue(aMSG);

  // 5. Gluing
  aGA.Perform();
  iErr = aGA.ErrorStatus();
  if (iErr) {
    switch (iErr) {
    case 11:
      Standard_Failure::Raise("GEOMAlgo_GlueDetector failed");
      break;
    case 13:
    case 14:
      Standard_Failure::Raise("PerformImagesToWork failed");
      break;
    default:
      {
        // description of all errors see in GEOMAlgo_Gluer2.cxx
        TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer2 with code ");
        aMsg += TCollection_AsciiString(iErr);
        Standard_Failure::Raise(aMsg.ToCString());
        break;
      }
    }
    return aRes;
  }

  Standard_Integer iWrn = aGA.WarningStatus();
  if (iWrn) {
    switch (iWrn) {
    case 1:
      MESSAGE("No shapes to glue");
      break;
    default:
      // description of all warnings see in GEOMAlgo_Gluer2.cxx
      MESSAGE("Warning in GEOMAlgo_Gluer2 with code " << iWrn);
      break;
    }
  }

  // 6. Result
  aRes = aGA.Shape();

  return aRes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TopoDS_Shape GEOMImpl_GlueDriver::GlueFaces ( const TopoDS_Shape &  theShape,
const Standard_Real  theTolerance,
const Standard_Boolean  doKeepNonSolids = Standard_True 
) [static]

Definition at line 327 of file GEOMImpl_GlueDriver.cxx.

{
  TopoDS_Shape aRes;

  GEOMAlgo_Gluer2 aGA;

  // 1. Initialization
  aGA.SetArgument(theShape);
  aGA.SetTolerance(theTolerance);
  aGA.SetKeepNonSolids(doKeepNonSolids);

  // 2. Detect interferred shapes
  aGA.Detect();

  //Standard_Integer iWrnDetect = aGA.WarningStatus();
  //if (iWrnDetect == 2) {
  //  Standard_Failure::Raise("GLUE_ERROR_STICKED_SHAPES");
  //}

  Standard_Integer iErr = aGA.ErrorStatus();
  if (iErr) {
    switch (iErr) {
    case 11:
      Standard_Failure::Raise("GEOMAlgo_GlueDetector failed");
      break;
    case 13:
    case 14:
      Standard_Failure::Raise("PerformImagesToWork failed");
      break;
    default:
      {
        // description of all errors see in GEOMAlgo_Gluer2.cxx
        TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer2 with code ");
        aMsg += TCollection_AsciiString(iErr);
        Standard_Failure::Raise(aMsg.ToCString());
        break;
      }
    }
    return aRes;
  }

  // 3. Set shapes to glue. If the operator is absent, the whole gluing will be done
  //aGA.SetShapesToGlue(aMSG);

  // 4. Gluing
  aGA.Perform();
  iErr = aGA.ErrorStatus();
  if (iErr) {
    switch (iErr) {
    case 11:
      Standard_Failure::Raise("GEOMAlgo_GlueDetector failed");
      break;
    case 13:
    case 14:
      Standard_Failure::Raise("PerformImagesToWork failed");
      break;
    default:
      {
        // description of all errors see in GEOMAlgo_Gluer2.cxx
        TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer2 with code ");
        aMsg += TCollection_AsciiString(iErr);
        Standard_Failure::Raise(aMsg.ToCString());
        break;
      }
    }
    return aRes;
  }

  Standard_Integer iWrn = aGA.WarningStatus();
  if (iWrn) {
    switch (iWrn) {
    case 1:
      MESSAGE("No shapes to glue");
      break;
    default:
      // description of all warnings see in GEOMAlgo_Gluer2.cxx
      MESSAGE("Warning in GEOMAlgo_Gluer2 with code " << iWrn);
      break;
    }
  }

  // 5. Result
  aRes = aGA.Shape();

  return aRes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TopoDS_Shape GEOMImpl_GlueDriver::GlueWithWarnings ( const TopoDS_Shape &  theShape,
const Standard_Real  theTolerance,
const TopAbs_ShapeEnum  theShapeType,
const Standard_Boolean  doKeepNonSolids,
TCollection_AsciiString &  theWarning 
) const

Definition at line 420 of file GEOMImpl_GlueDriver.cxx.

{
  TopoDS_Shape aRes;

  GEOMAlgo_Gluer2 aGA;

  // 1. Initialization
  aGA.SetArgument(theShape);
  aGA.SetTolerance(theTolerance);
  aGA.SetKeepNonSolids(doKeepNonSolids);

  // 2. Detect interferred shapes
  aGA.Detect();

  //modified by NIZNHY-PKV Tue Mar 13 14:07:12 2012f
#if OCC_VERSION_LARGE > 0x06050200
  Standard_Integer iWrnDetect = aGA.WarningStatus();
  if (iWrnDetect == 2) {
    /*
    TopTools_ListIteratorOfListOfShape aItLS;

    // Sticked shapes are detected
    const TopTools_IndexedDataMapOfShapeListOfShape& aIDMSS = pGluer2->StickedShapes();

    Standard_Integer i, aNb = aIDMSS.Extent();
    for (i = 1; i <= aNb; ++i) {
      // ancestor aSa (edge, wire face,..)  
      const TopoDS_Shape& aSa = aIDMSS.FindKey(i); 

      // successors aSs (vertex, edge, ...)
      // of the ancestor that are sticked 
      // for given value of the tolerance
      const TopTools_ListOfShape& aLSS = aIDMSS.FindFromIndex(i);
      aItLS.Initialize(aLSS);
      for (; aItLS.More(); aItLS.Next()) {
       const TopoDS_Shape& aSs = aItLS.Value();
      }
    }
    */
    Standard_Failure::Raise("GLUE_ERROR_STICKED_SHAPES");
    //Standard_Failure::Raise("Sticked shapes are detected. The tolerance value is too big.");
    //theWarning = "Sticked shapes are detected. The tolerance value is too big.";
  }
#endif
  //modified by NIZNHY-PKV Tue Mar 13 14:07:14 2012t

  Standard_Integer iErr = aGA.ErrorStatus();
  if (iErr) {
    switch (iErr) {
    case 11:
      Standard_Failure::Raise("GEOMAlgo_GlueDetector failed");
      break;
    case 13:
    case 14:
      Standard_Failure::Raise("PerformImagesToWork failed");
      break;
    default:
      {
        // description of all errors see in GEOMAlgo_Gluer2.cxx
        TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer2 with code ");
        aMsg += TCollection_AsciiString(iErr);
        Standard_Failure::Raise(aMsg.ToCString());
        break;
      }
    }
    return aRes;
  }

  if (theShapeType != TopAbs_FACE) {
    // 3. Fill shapes to glue aMSG
    TopTools_DataMapOfShapeListOfShape aMSG;
    const TopTools_DataMapOfShapeListOfShape& aMSD = aGA.ShapesDetected();
    TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItMSD;
    aItMSD.Initialize(aMSD);
    for (; aItMSD.More(); aItMSD.Next()) {
      const TopoDS_Shape& aSx = aItMSD.Key();
      const TopTools_ListOfShape& aLSD = aItMSD.Value();
      if (aSx.ShapeType() == theShapeType) {
        aMSG.Bind(aSx, aLSD);
      }
    }

    // 4. Set shapes to glue. If the operator is absent, the whole gluing will be done
    aGA.SetShapesToGlue(aMSG);
  }

  // 5. Gluing
  aGA.Perform();
  iErr = aGA.ErrorStatus();
  if (iErr) {
    switch (iErr) {
    case 11:
      Standard_Failure::Raise("GEOMAlgo_GlueDetector failed");
      break;
    case 13:
    case 14:
      Standard_Failure::Raise("PerformImagesToWork failed");
      break;
    default:
      {
        // description of all errors see in GEOMAlgo_Gluer2.cxx
        TCollection_AsciiString aMsg ("Error in GEOMAlgo_Gluer2 with code ");
        aMsg += TCollection_AsciiString(iErr);
        Standard_Failure::Raise(aMsg.ToCString());
        break;
      }
    }
    return aRes;
  }

  Standard_Integer iWrn = aGA.WarningStatus();
  if (iWrn) {
    switch (iWrn) {
    case 1:
      theWarning = "No shapes to glue";
      break;
    default:
      // description of all warnings see in GEOMAlgo_Gluer2.cxx
      theWarning = "Warning in GEOMAlgo_Gluer2 with code ";
      theWarning += TCollection_AsciiString(iWrn);
      break;
    }
  }

  // 6. Result
  aRes = aGA.Shape();

  // 7. Fill history to be used by GetInPlace functionality
  TopTools_IndexedMapOfShape aResIndices;
  TopExp::MapShapes(aRes, aResIndices);

  Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());

  // history for all argument shapes
  TDF_LabelSequence aLabelSeq;
  aFunction->GetDependency(aLabelSeq);
  Standard_Integer nbArg = aLabelSeq.Length();

  for (Standard_Integer iarg = 1; iarg <= nbArg; iarg++) {

    TDF_Label anArgumentRefLabel = aLabelSeq.Value(iarg);

    Handle(GEOM_Object) anArgumentObject = GEOM_Object::GetReferencedObject(anArgumentRefLabel);
    TopoDS_Shape anArgumentShape = anArgumentObject->GetValue();

    TopTools_IndexedMapOfShape anArgumentIndices;
    TopExp::MapShapes(anArgumentShape, anArgumentIndices);
    Standard_Integer nbArgumentEntities = anArgumentIndices.Extent();

    // Find corresponding label in history
    TDF_Label anArgumentHistoryLabel =
      aFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_True);

    for (Standard_Integer ie = 1; ie <= nbArgumentEntities; ie++) {
      TopoDS_Shape anEntity = anArgumentIndices.FindKey(ie);
      const TopTools_ListOfShape& aModified = aGA.Modified(anEntity);
      Standard_Integer nbModified = aModified.Extent();

      if (nbModified > 0) {
        TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
        Handle(TDataStd_IntegerArray) anAttr =
          TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);

        TopTools_ListIteratorOfListOfShape itM (aModified);
        for (int im = 1; itM.More(); itM.Next(), ++im) {
          int id = aResIndices.FindIndex(itM.Value());
          anAttr->SetValue(im, id);
        }
      }
    }
  }

  return aRes;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_EXPORT const GEOMImpl_GlueDriver::Handle ( Standard_Type  ) const [inline]

Definition at line 185 of file GEOMImpl_GlueDriver.hxx.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 186 of file GEOMImpl_GlueDriver.hxx.

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

Here is the call graph for this function:

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

Definition at line 151 of file GEOMImpl_GlueDriver.hxx.

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

Definition at line 141 of file GEOMImpl_GlueDriver.hxx.

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

Definition at line 133 of file GEOMImpl_GlueDriver.hxx.

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

Definition at line 137 of file GEOMImpl_GlueDriver.hxx.

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

Definition at line 150 of file GEOMImpl_GlueDriver.hxx.

{}

Friends And Related Function Documentation

Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_GlueDriver_Type_ ( ) [friend]

Definition at line 788 of file GEOMImpl_GlueDriver.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_GlueDriver",
                                                         sizeof(GEOMImpl_GlueDriver),
                                                         1,
                                                         (Standard_Address)_Ancestors,
                                                         (Standard_Address)NULL);

  return _aType;
}

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