Back to index

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

#include <GEOMImpl_PartitionDriver.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_PartitionDriver ()
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_PartitionDriver ()
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_PartitionDriver_Type_ ()

Detailed Description

Definition at line 125 of file GEOMImpl_PartitionDriver.hxx.


Constructor & Destructor Documentation

Definition at line 79 of file GEOMImpl_PartitionDriver.cxx.

{
}

Definition at line 149 of file GEOMImpl_PartitionDriver.hxx.

{};

Member Function Documentation

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

Definition at line 112 of file GEOMImpl_PartitionDriver.cxx.

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

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

  TopoDS_Shape aShape;
  //sklNMTAlgo_Splitter1 PS;
  GEOMAlgo_Splitter PS;

  TopTools_DataMapOfShapeShape aCopyMap;
  TColStd_IndexedDataMapOfTransientTransient aMapTShapes;

  if (aType == PARTITION_PARTITION || aType == PARTITION_NO_SELF_INTERSECTIONS)
  {
    Handle(TColStd_HSequenceOfTransient) aShapes  = aCI.GetShapes();
    Handle(TColStd_HSequenceOfTransient) aTools   = aCI.GetTools();
    Handle(TColStd_HSequenceOfTransient) aKeepIns = aCI.GetKeepIns();
    Handle(TColStd_HSequenceOfTransient) aRemIns  = aCI.GetRemoveIns();
    Handle(TColStd_HArray1OfInteger) aMaterials   = aCI.GetMaterials();
    //skl Standard_Boolean DoRemoveWebs = !aMaterials.IsNull();

    unsigned int ind;
    //unsigned int ind, nbshapes = 0;
    //nbshapes += aShapes->Length() + aTools->Length();
    //nbshapes += aKeepIns->Length() + aRemIns->Length();
    //TopTools_MapOfShape ShapesMap(nbshapes), ToolsMap(nbshapes);
    TopTools_MapOfShape ShapesMap, ToolsMap;

    // add object shapes that are in ListShapes;
    for (ind = 1; ind <= aShapes->Length(); ind++) {
      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(ind));
      TopoDS_Shape aShape_i = aRefShape->GetValue();
      if (aShape_i.IsNull()) {
        Standard_NullObject::Raise("In Partition a shape is null");
      }
      //
      //BRepBuilderAPI_Copy aCopyTool (aShape_i);
      TopoDS_Shape aShape_i_copy;
      TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
      //if (aCopyTool.IsDone())
      //  aShape_i_copy = aCopyTool.Shape();
      //else
      //  Standard_NullObject::Raise("Bad shape detected");
      //
      // fill aCopyMap for history
      TopTools_IndexedMapOfShape aShape_i_inds;
      TopTools_IndexedMapOfShape aShape_i_copy_inds;
      TopExp::MapShapes(aShape_i, aShape_i_inds);
      TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
      Standard_Integer nbInds = aShape_i_inds.Extent();
      for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
        aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
      }
      //
      TopTools_ListOfShape aSimpleShapes;
      //PrepareShapes(aShape_i, aType, aSimpleShapes);
      PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
      TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
      for (; aSimpleIter.More(); aSimpleIter.Next()) {
        const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
        if (ShapesMap.Add(aSimpleSh)) {
          PS.AddShape(aSimpleSh);
          //skl if (DoRemoveWebs) {
          //skl if (aMaterials->Length() >= ind)
          //skl PS.SetMaterial(aSimpleSh, aMaterials->Value(ind));
          //skl }
        }
      }
    }

    // add tool shapes that are in ListTools and not in ListShapes;
    for (ind = 1; ind <= aTools->Length(); ind++) {
      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aTools->Value(ind));
      TopoDS_Shape aShape_i = aRefShape->GetValue();
      if (aShape_i.IsNull()) {
        Standard_NullObject::Raise("In Partition a tool shape is null");
      }
      //
      //BRepBuilderAPI_Copy aCopyTool (aShape_i);
      TopoDS_Shape aShape_i_copy;
      TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
      //if (aCopyTool.IsDone())
      //  aShape_i_copy = aCopyTool.Shape();
      //else
      //  Standard_NullObject::Raise("Bad shape detected");
      //
      // fill aCopyMap for history
      TopTools_IndexedMapOfShape aShape_i_inds;
      TopTools_IndexedMapOfShape aShape_i_copy_inds;
      TopExp::MapShapes(aShape_i, aShape_i_inds);
      TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
      Standard_Integer nbInds = aShape_i_inds.Extent();
      for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
        aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
      }
      //
      TopTools_ListOfShape aSimpleShapes;
      //PrepareShapes(aShape_i, aType, aSimpleShapes);
      PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
      TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
      for (; aSimpleIter.More(); aSimpleIter.Next()) {
        const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
        if (!ShapesMap.Contains(aSimpleSh) && ToolsMap.Add(aSimpleSh)) {
          PS.AddTool(aSimpleSh);
        }
      }
    }

    // add shapes that are in ListKeepInside, as object shapes;
    for (ind = 1; ind <= aKeepIns->Length(); ind++) {
      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
      TopoDS_Shape aShape_i = aRefShape->GetValue();
      if (aShape_i.IsNull()) {
        Standard_NullObject::Raise("In Partition a Keep Inside shape is null");
      }
      //
      //BRepBuilderAPI_Copy aCopyTool (aShape_i);
      TopoDS_Shape aShape_i_copy;
      TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
      //if (aCopyTool.IsDone())
      //  aShape_i_copy = aCopyTool.Shape();
      //else
      //  Standard_NullObject::Raise("Bad shape detected");
      //
      // fill aCopyMap for history
      TopTools_IndexedMapOfShape aShape_i_inds;
      TopTools_IndexedMapOfShape aShape_i_copy_inds;
      TopExp::MapShapes(aShape_i, aShape_i_inds);
      TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
      Standard_Integer nbInds = aShape_i_inds.Extent();
      for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
        aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
      }
      //
      TopTools_ListOfShape aSimpleShapes;
      //PrepareShapes(aShape_i, aType, aSimpleShapes);
      PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
      TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
      for (; aSimpleIter.More(); aSimpleIter.Next()) {
        const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
        if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
          PS.AddShape(aSimpleSh);
      }
    }

    // add shapes that are in ListRemoveInside, as object shapes;
    for (ind = 1; ind <= aRemIns->Length(); ind++) {
      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
      TopoDS_Shape aShape_i = aRefShape->GetValue();
      if (aShape_i.IsNull()) {
        Standard_NullObject::Raise("In Partition a Remove Inside shape is null");
      }
      //
      //BRepBuilderAPI_Copy aCopyTool (aShape_i);
      TopoDS_Shape aShape_i_copy;
      TNaming_CopyShape::CopyTool(aShape_i, aMapTShapes, aShape_i_copy);
      //if (aCopyTool.IsDone())
      //  aShape_i_copy = aCopyTool.Shape();
      //else
      //  Standard_NullObject::Raise("Bad shape detected");
      //
      // fill aCopyMap for history
      TopTools_IndexedMapOfShape aShape_i_inds;
      TopTools_IndexedMapOfShape aShape_i_copy_inds;
      TopExp::MapShapes(aShape_i, aShape_i_inds);
      TopExp::MapShapes(aShape_i_copy, aShape_i_copy_inds);
      Standard_Integer nbInds = aShape_i_inds.Extent();
      for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
        aCopyMap.Bind(aShape_i_inds.FindKey(ie), aShape_i_copy_inds.FindKey(ie));
      }
      //
      TopTools_ListOfShape aSimpleShapes;
      //PrepareShapes(aShape_i, aType, aSimpleShapes);
      PrepareShapes(aShape_i_copy, aType, aSimpleShapes);
      TopTools_ListIteratorOfListOfShape aSimpleIter (aSimpleShapes);
      for (; aSimpleIter.More(); aSimpleIter.Next()) {
        const TopoDS_Shape& aSimpleSh = aSimpleIter.Value();
        if (!ToolsMap.Contains(aSimpleSh) && ShapesMap.Add(aSimpleSh))
          PS.AddShape(aSimpleSh);
      }
    }

    PS.SetLimitMode(aCI.GetKeepNonlimitShapes());
    PS.SetLimit((TopAbs_ShapeEnum)aCI.GetLimit());
    PS.Perform();

    //skl PS.Compute();
    //skl PS.SetRemoveWebs(!DoRemoveWebs);
    //skl PS.Build((TopAbs_ShapeEnum) aCI.GetLimit());
    /*skl
    // suppress result outside of shapes in KInsideMap
    for (ind = 1; ind <= aKeepIns->Length(); ind++) {
      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aKeepIns->Value(ind));
      TopoDS_Shape aShape_i = aRefShape->GetValue();
      PS.KeepShapesInside(aShape_i);
    }

    // suppress result inside of shapes in RInsideMap
    for (ind = 1; ind <= aRemIns->Length(); ind++) {
      Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aRemIns->Value(ind));
      TopoDS_Shape aShape_i = aRefShape->GetValue();
      PS.RemoveShapesInside(aShape_i);
    }
    */
  }
  else if (aType == PARTITION_HALF)
  {
    Handle(GEOM_Function) aRefShape = aCI.GetShape();
    Handle(GEOM_Function) aRefPlane = aCI.GetPlane();
    TopoDS_Shape aShapeArg = aRefShape->GetValue();
    TopoDS_Shape aPlaneArg = aRefPlane->GetValue();

    if (aShapeArg.IsNull() || aPlaneArg.IsNull()) {
      Standard_NullObject::Raise("In Half Partition a shape or a plane is null");
    }

    TopoDS_Shape aShapeArg_copy;
    TopoDS_Shape aPlaneArg_copy;
    {
      TNaming_CopyShape::CopyTool(aShapeArg, aMapTShapes, aShapeArg_copy);
      //BRepBuilderAPI_Copy aCopyTool (aShapeArg);
      //if (aCopyTool.IsDone())
      //  aShapeArg_copy = aCopyTool.Shape();
      //else
      //  Standard_NullObject::Raise("Bad shape detected");
      //
      // fill aCopyMap for history
      TopTools_IndexedMapOfShape aShapeArg_inds;
      TopTools_IndexedMapOfShape aShapeArg_copy_inds;
      TopExp::MapShapes(aShapeArg, aShapeArg_inds);
      TopExp::MapShapes(aShapeArg_copy, aShapeArg_copy_inds);
      Standard_Integer nbInds = aShapeArg_inds.Extent();
      for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
        aCopyMap.Bind(aShapeArg_inds.FindKey(ie), aShapeArg_copy_inds.FindKey(ie));
      }
    }
    {
      TNaming_CopyShape::CopyTool(aPlaneArg, aMapTShapes, aPlaneArg_copy);
      //BRepBuilderAPI_Copy aCopyTool (aPlaneArg);
      //if (aCopyTool.IsDone())
      //  aPlaneArg_copy = aCopyTool.Shape();
      //else
      //  Standard_NullObject::Raise("Bad shape detected");
      //
      // fill aCopyMap for history
      TopTools_IndexedMapOfShape aPlaneArg_inds;
      TopTools_IndexedMapOfShape aPlaneArg_copy_inds;
      TopExp::MapShapes(aPlaneArg, aPlaneArg_inds);
      TopExp::MapShapes(aPlaneArg_copy, aPlaneArg_copy_inds);
      Standard_Integer nbInds = aPlaneArg_inds.Extent();
      for (Standard_Integer ie = 1; ie <= nbInds; ie++) {
        aCopyMap.Bind(aPlaneArg_inds.FindKey(ie), aPlaneArg_copy_inds.FindKey(ie));
      }
    }

    // add object shapes that are in ListShapes;
    PS.AddShape(aShapeArg_copy);
    //PS.AddShape(aShapeArg);

    // add tool shapes that are in ListTools and not in ListShapes;
    PS.AddTool(aPlaneArg_copy);
    //PS.AddTool(aPlaneArg);

    //skl PS.Compute();
    PS.Perform();
    //PS.SetRemoveWebs(Standard_False);
    //PS.Build(aShapeArg.ShapeType());

  } else {
  }

  aShape = PS.Shape();
  if (aShape.IsNull()) return 0;

  //Alternative case to check not valid partition IPAL21418
  TopoDS_Iterator It (aShape, Standard_True, Standard_True);
  int nbSubshapes=0;
  for (; It.More(); It.Next())
    nbSubshapes++;
  if (!nbSubshapes)
    Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
  //end of IPAL21418

  if (!BRepAlgo::IsValid(aShape)) {
    // 08.07.2008 added by skl during fixing bug 19761 from Mantis
    ShapeFix_ShapeTolerance aSFT;
    aSFT.LimitTolerance(aShape, Precision::Confusion(),
                        Precision::Confusion(), TopAbs_SHAPE);
    Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
    aSfs->Perform();
    aShape = aSfs->Shape();
    if (!BRepAlgo::IsValid(aShape))
      Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
  }

  aFunction->SetValue(aShape);

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

  // Map: source_shape/images of source_shape in Result
  const TopTools_IndexedDataMapOfShapeListOfShape& aMR = PS.ImagesResult();

  // history for all argument shapes
  // be sure to use aCopyMap
  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);
      // be sure to use aCopyMap here
      if (aCopyMap.IsBound(anEntity))
        anEntity = aCopyMap.Find(anEntity);
      //
      if (!aMR.Contains(anEntity)) continue;

      const TopTools_ListOfShape& aModified = aMR.FindFromKey(anEntity);
      Standard_Integer nbModified = aModified.Extent();

      if (nbModified > 0) { // Mantis issue 0021182
        int ih = 1;
        TopTools_ListIteratorOfListOfShape itM (aModified);
        for (; itM.More() && nbModified > 0; itM.Next(), ++ih) {
          if (!aResIndices.Contains(itM.Value())) {
            nbModified = 0;
          }
        }
      }
      if (nbModified > 0) {
        TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(ie, Standard_True);
        Handle(TDataStd_IntegerArray) anAttr =
          TDataStd_IntegerArray::Set(aWhatHistoryLabel, 1, nbModified);

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

  log.SetTouched(Label());

  return 1;
}

Here is the call graph for this function:

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

Definition at line 68 of file GEOMImpl_PartitionDriver.cxx.

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

Definition at line 155 of file GEOMImpl_PartitionDriver.hxx.

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 156 of file GEOMImpl_PartitionDriver.hxx.

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

Here is the call graph for this function:

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

Definition at line 147 of file GEOMImpl_PartitionDriver.hxx.

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

Definition at line 137 of file GEOMImpl_PartitionDriver.hxx.

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

Definition at line 129 of file GEOMImpl_PartitionDriver.hxx.

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

Definition at line 133 of file GEOMImpl_PartitionDriver.hxx.

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

Definition at line 146 of file GEOMImpl_PartitionDriver.hxx.

{}

Friends And Related Function Documentation

Standard_EXPORT friend Handle_Standard_Type& GEOMImpl_PartitionDriver_Type_ ( ) [friend]

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

  return _aType;
}

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