Back to index

salome-geom  6.5.0
Defines | Functions
GEOMImpl_IShapesOperations.cxx File Reference
#include <Standard_Stream.hxx>
#include "GEOMImpl_IShapesOperations.hxx"
#include "GEOMImpl_Types.hxx"
#include "GEOMImpl_VectorDriver.hxx"
#include "GEOMImpl_ShapeDriver.hxx"
#include "GEOMImpl_CopyDriver.hxx"
#include "GEOMImpl_GlueDriver.hxx"
#include "GEOMImpl_IVector.hxx"
#include "GEOMImpl_IShapes.hxx"
#include "GEOMImpl_IGlue.hxx"
#include "GEOMImpl_Block6Explorer.hxx"
#include "GEOMImpl_IHealingOperations.hxx"
#include <GEOMImpl_Gen.hxx>
#include "GEOM_Function.hxx"
#include "GEOM_ISubShape.hxx"
#include "GEOM_PythonDump.hxx"
#include "GEOMAlgo_ClsfBox.hxx"
#include "GEOMAlgo_ClsfSolid.hxx"
#include "GEOMAlgo_CoupleOfShapes.hxx"
#include "GEOMAlgo_FinderShapeOn1.hxx"
#include "GEOMAlgo_FinderShapeOnQuad.hxx"
#include "GEOMAlgo_FinderShapeOn2.hxx"
#include "GEOMAlgo_GetInPlace.hxx"
#include "GEOMAlgo_GlueDetector.hxx"
#include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx"
#include "GEOMAlgo_ListOfCoupleOfShapes.hxx"
#include <Basics_OCCTVersion.hxx>
#include "utilities.h"
#include "OpUtil.hxx"
#include "Utils_ExceptHandlers.hxx"
#include <TFunction_DriverTable.hxx>
#include <TFunction_Driver.hxx>
#include <TFunction_Logbook.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
#include <TDF_Tool.hxx>
#include <BRepExtrema_ExtCF.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
#include <BRepGProp.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Solid.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Compound.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_Array1OfShape.hxx>
#include <TopTools_DataMapIteratorOfDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_MapOfOrientedShape.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_SphericalSurface.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <GeomLib_Tool.hxx>
#include <Geom2d_Curve.hxx>
#include <Bnd_Box.hxx>
#include <GProp_GProps.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColStd_HArray1OfInteger.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <gp_Cylinder.hxx>
#include <gp_Lin.hxx>
#include <gp_Pnt.hxx>
#include <vector>
#include <algorithm>
#include <functional>
#include <Standard_NullObject.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx>
#include <GEOMImpl_MeasureDriver.hxx>
#include <GEOMImpl_IMeasure.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepClass_FaceClassifier.hxx>
#include <BRepClass3d_SolidClassifier.hxx>
#include <Precision.hxx>
#include <TopoDS_TShape.hxx>

Go to the source code of this file.

Defines

#define STD_SORT_ALGO   1
#define MAX_TOLERANCE   1.e-7

Functions

 Handle (GEOM_Object) GEOMImpl_IShapesOperations
 MakeEdge.
 Handle (TColStd_HSequenceOfTransient) GEOMImpl_IShapesOperations
 GetGlueShapes.
 Handle (TColStd_HSequenceOfInteger) GEOMImpl_IShapesOperations
 SubShapeAllIDs.
static GEOM::TPythonDumpoperator<< (GEOM::TPythonDump &theDump, const GEOMAlgo_State theState)
 Handle (Geom_Surface) GEOMImpl_IShapesOperations
 Creates Geom_Plane.
static bool GetInPlaceOfShape (const Handle(GEOM_Function)&theWhereFunction, const TopTools_IndexedMapOfShape &theWhereIndices, const TopoDS_Shape &theWhat, TColStd_ListOfInteger &theModifiedList)
 GetInPlaceOfShape.
std::pair< double, double > ShapeToDouble (const TopoDS_Shape &S, bool isOldSorting)
static bool isSameEdge (const TopoDS_Edge &theEdge1, const TopoDS_Edge &theEdge2)
static bool isSameFace (const TopoDS_Face &theFace1, const TopoDS_Face &theFace2)
bool isSameSolid (const TopoDS_Solid &theSolid1, const TopoDS_Solid &theSolid2)

Define Documentation

#define MAX_TOLERANCE   1.e-7

Definition at line 4585 of file GEOMImpl_IShapesOperations.cxx.

#define STD_SORT_ALGO   1

Definition at line 145 of file GEOMImpl_IShapesOperations.cxx.


Function Documentation

static bool GetInPlaceOfShape ( const Handle(GEOM_Function)&  theWhereFunction,
const TopTools_IndexedMapOfShape &  theWhereIndices,
const TopoDS_Shape &  theWhat,
TColStd_ListOfInteger &  theModifiedList 
) [static]

GetInPlaceOfShape.

Definition at line 3583 of file GEOMImpl_IShapesOperations.cxx.

{
  if (theWhereFunction.IsNull() || theWhat.IsNull()) return false;

  if (theWhereIndices.Contains(theWhat)) {
    // entity was not changed by the operation
    Standard_Integer aWhatIndex = theWhereIndices.FindIndex(theWhat);
    theModifiedList.Append(aWhatIndex);
    return true;
  }

  // try to find in history
  TDF_Label aHistoryLabel = theWhereFunction->GetHistoryEntry(Standard_False);

  // search in history for all argument shapes
  Standard_Boolean isFound = Standard_False;
  Standard_Boolean isGood = Standard_False;

  TDF_LabelSequence aLabelSeq;
  theWhereFunction->GetDependency(aLabelSeq);
  Standard_Integer nbArg = aLabelSeq.Length();

  for (Standard_Integer iarg = 1; iarg <= nbArg && !isFound; 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);

    if (anArgumentIndices.Contains(theWhat)) {
      isFound = Standard_True;
      Standard_Integer aWhatIndex = anArgumentIndices.FindIndex(theWhat);

      // Find corresponding label in history
      TDF_Label anArgumentHistoryLabel =
        theWhereFunction->GetArgumentHistoryEntry(anArgumentRefLabel, Standard_False);
      if (anArgumentHistoryLabel.IsNull()) {
        // Lost History of operation argument. Possibly, all its entities was removed.
        isGood = Standard_True;
      }
      else {
        TDF_Label aWhatHistoryLabel = anArgumentHistoryLabel.FindChild(aWhatIndex, Standard_False);

        if (aWhatHistoryLabel.IsNull()) {
          // Removed entity ? Compound ? Compsolid ? Shell ? Wire
          isGood = Standard_False;
        } else {
          Handle(TDataStd_IntegerArray) anIntegerArray;
          if (!aWhatHistoryLabel.FindAttribute(TDataStd_IntegerArray::GetID(), anIntegerArray)) {
            //Error: Empty modifications history for the sought shape.
            isGood = Standard_False;
          }
          else {
            isGood = Standard_True;
            Standard_Integer imod, aModifLen = anIntegerArray->Array()->Length();
            for (imod = 1; imod <= aModifLen; imod++) {
              theModifiedList.Append(anIntegerArray->Array()->Value(imod));
            }
          }
        }
      }
    }
  }

  isFound = isGood;

  if (!isFound) {
    // try compound/compsolid/shell/wire element by element
    bool isFoundAny = false;
    TopTools_MapOfShape mapShape;

    if (theWhat.ShapeType() == TopAbs_COMPOUND ||
        theWhat.ShapeType() == TopAbs_COMPSOLID) {
      // recursive processing of compound/compsolid
      TopoDS_Iterator anIt (theWhat, Standard_True, Standard_True);
      for (; anIt.More(); anIt.Next()) {
        if (mapShape.Add(anIt.Value())) {
          TopoDS_Shape curWhat = anIt.Value();
          isFoundAny = GetInPlaceOfShape(theWhereFunction, theWhereIndices, curWhat, theModifiedList);
          if (isFoundAny) isFound = Standard_True;
        }
      }
    }
    else if (theWhat.ShapeType() == TopAbs_SHELL) {
      // try to replace a shell by its faces images
      TopExp_Explorer anExp (theWhat, TopAbs_FACE);
      for (; anExp.More(); anExp.Next()) {
        if (mapShape.Add(anExp.Current())) {
          TopoDS_Shape curWhat = anExp.Current();
          isFoundAny = GetInPlaceOfShape(theWhereFunction, theWhereIndices, curWhat, theModifiedList);
          if (isFoundAny) isFound = Standard_True;
        }
      }
    }
    else if (theWhat.ShapeType() == TopAbs_WIRE) {
      // try to replace a wire by its edges images
      TopExp_Explorer anExp (theWhat, TopAbs_EDGE);
      for (; anExp.More(); anExp.Next()) {
        if (mapShape.Add(anExp.Current())) {
          TopoDS_Shape curWhat = anExp.Current();
          isFoundAny = GetInPlaceOfShape(theWhereFunction, theWhereIndices, curWhat, theModifiedList);
          if (isFoundAny) isFound = Standard_True;
        }
      }
    }
    else {
      // Removed entity
    }
  }

  return isFound;
}

Here is the call graph for this function:

MakeEdge.

GetObject.

case GetInPlaceOld: default:

case GetInPlace: default:

ReverseShape.

GetSubShape.

MakeGlueEdgesByList.

MakeGlueEdges.

GetGlueFaces.

MakeGlueFaces.

MakeShape.

MakeCompound.

MakeSolidShells.

MakeShell.

MakeFaceWires.

MakeFace.

MakeWire.

MakeEdgeWire.

MakeEdgeOnCurveByLength.

MakeGlueFacesByList

Definition at line 173 of file GEOMImpl_IShapesOperations.cxx.

{
  SetErrorCode(KO);

  if (thePnt1.IsNull() || thePnt2.IsNull()) return NULL;

  //Add a new Edge object
  Handle(GEOM_Object) anEdge = GetEngine()->AddObject(GetDocID(), GEOM_EDGE);

  //Add a new Vector function
  Handle(GEOM_Function) aFunction =
    anEdge->AddFunction(GEOMImpl_VectorDriver::GetID(), VECTOR_TWO_PNT);

  //Check if the function is set correctly
  if (aFunction->GetDriverGUID() != GEOMImpl_VectorDriver::GetID()) return NULL;

  GEOMImpl_IVector aPI (aFunction);

  Handle(GEOM_Function) aRef1 = thePnt1->GetLastFunction();
  Handle(GEOM_Function) aRef2 = thePnt2->GetLastFunction();
  if (aRef1.IsNull() || aRef2.IsNull()) return NULL;

  aPI.SetPoint1(aRef1);
  aPI.SetPoint2(aRef2);

  //Compute the Edge value
  try {
#if OCC_VERSION_LARGE > 0x06010000
    OCC_CATCH_SIGNALS;
#endif
    if (!GetSolver()->ComputeFunction(aFunction)) {
      SetErrorCode("Vector driver failed");
      return NULL;
    }
  }
  catch (Standard_Failure) {
    Handle(Standard_Failure) aFail = Standard_Failure::Caught();
    SetErrorCode(aFail->GetMessageString());
    return NULL;
  }

  //Make a Python command
  GEOM::TPythonDump(aFunction) << anEdge << " = geompy.MakeEdge("
                               << thePnt1 << ", " << thePnt2 << ")";

  SetErrorCode(OK);
  return anEdge;
}

Here is the call graph for this function:

Handle ( TColStd_HSequenceOfTransient  )

GetGlueShapes.

Find sub-shapes complying with given status about quadrangle.

GetShapesOnSphere.

GetShapesOnCylinderWithLocation.

GetShapesOnCylinder.

GetShapesOnPlaneWithLocation.

GetShapesOnPlane.

Find shape objects and their entries by their ids.

Find sub-shapes complying with given status about surface.

MakeSubShapes.

MakeExplode.

GetExistingSubObjects.

Parameters:
theBox- the box to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfTransient)- found sub-shapes
Parameters:
theCheckShape- the shape to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfTransient)- found sub-shapes
Parameters:
theShapeIDs- incoming shape ids
theShapeEntries- outgoing entries like "entry1, entry2, ..."
Return values:
Handle(TColStd_HSequenceOfTransient)- found shape objects
Parameters:
theSurface- the surface to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
theShapeEntries- outgoing entries like "entry1, entry2, ..."
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes
Parameters:
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theTopLeftPoint- top left quadrangle corner
theTopRigthPoint- top right quadrangle corner
theBottomLeftPoint- bottom left quadrangle corner
theBottomRigthPoint- bottom right quadrangle corner
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes

Definition at line 981 of file GEOMImpl_IShapesOperations.cxx.

{
  SetErrorCode(KO);

  if (theShape.IsNull()) return NULL;
  TopoDS_Shape aShape = theShape->GetValue();
  if (aShape.IsNull()) return NULL;

  Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;

  GEOMAlgo_GlueDetector aGluer;
  aGluer.SetArgument(aShape);
  aGluer.SetTolerance(theTolerance);
  aGluer.Perform();
  Standard_Integer iErr = aGluer.ErrorStatus();
  if (iErr) return NULL;

  TCollection_AsciiString anAsciiList, anEntry;
  TopTools_IndexedMapOfShape anIndices;
  TopExp::MapShapes(aShape, anIndices);
  Handle(TColStd_HArray1OfInteger) anArray;
  Handle(GEOM_Object) anObj;

  TopTools_ListOfShape listOnePerSet;

  const TopTools_DataMapOfShapeListOfShape& aImages = aGluer.Images();
  TopTools_DataMapIteratorOfDataMapOfShapeListOfShape aItDMSLS (aImages);
  for (int index = 1; aItDMSLS.More(); aItDMSLS.Next(), ++index) {
    // some key shape
    //const TopoDS_Shape& aSkey = aItDMSLS.Key();  

    // list of shapes of the argument that can be glued
    const TopTools_ListOfShape& aLSD = aItDMSLS.Value(); 

    //listShape.Append(aLSD.First());
    TopoDS_Shape aValue = aLSD.First();

    if (aValue.ShapeType() == theType) {
      listOnePerSet.Append(aValue);
    }
  }

  // for stable order of returned entities
  GEOMImpl_IShapesOperations::SortShapes(listOnePerSet, Standard_False);

  TopTools_ListIteratorOfListOfShape aListIt (listOnePerSet);
  for (; aListIt.More(); aListIt.Next()) {
    TopoDS_Shape aValue = aListIt.Value();
    anArray = new TColStd_HArray1OfInteger(1,1);
    anArray->SetValue(1, anIndices.FindIndex(aValue));
    anObj = GetEngine()->AddSubShape(theShape, anArray);
    if (!anObj.IsNull()) {
      aSeq->Append(anObj);

      // for python command
      TDF_Tool::Entry(anObj->GetEntry(), anEntry);
      anAsciiList += anEntry;
      anAsciiList += ",";
    }
  }

  // Make a Python command
  if (anAsciiList.Length() > 0) {
    anAsciiList.Trunc(anAsciiList.Length() - 1);
    Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
    GEOM::TPythonDump pd (aFunction, /*append=*/true);
    pd << "[" << anAsciiList.ToCString();
    if (theType == TopAbs_FACE)
      pd << "] = geompy.GetGlueFaces(" << theShape << ", " << theTolerance << ")";
    else if (theType == TopAbs_EDGE)
      pd << "] = geompy.GetGlueEdges(" << theShape << ", " << theTolerance << ")";
  }

  SetErrorCode(OK);

  return aSeq;
}

Here is the call graph for this function:

Handle ( TColStd_HSequenceOfInteger  )

SubShapeAllIDs.

Find IDs of sub-shapes complying with given status about quadrangle.

GetShapesOnSphereIDs.

GetShapesOnCylinderWithLocationIDs.

GetShapesOnCylinderIDs.

GetShapesOnPlaneWithLocationIDs.

GetShapesOnPlaneIDs.

Find sub-shapes complying with given status about surface.

Find IDs of sub-shapes complying with given status about surface.

GetFreeFacesIDs.

Parameters:
theBox- the box to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes
Parameters:
theCheckShape- the shape to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes
Parameters:
theSurface- the surface to check state of sub-shapes against
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes
Parameters:
theShape- the shape to explore
theShapeType- type of sub-shape of theShape
theTopLeftPoint- top left quadrangle corner
theTopRigthPoint- top right quadrangle corner
theBottomLeftPoint- bottom left quadrangle corner
theBottomRigthPoint- bottom right quadrangle corner
theState- required state
Return values:
Handle(TColStd_HSequenceOfInteger)- IDs of found sub-shapes

Definition at line 1346 of file GEOMImpl_IShapesOperations.cxx.

{
  SetErrorCode(KO);

  if (theShape.IsNull()) return NULL;
  TopoDS_Shape aShape = theShape->GetValue();
  if (aShape.IsNull()) return NULL;

  Handle(TColStd_HSequenceOfInteger) aSeq = new TColStd_HSequenceOfInteger;
  TopTools_MapOfShape mapShape;
  TopTools_ListOfShape listShape;

  if (aShape.ShapeType() == TopAbs_COMPOUND &&
      (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
       TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID ||
       TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND))
  {
    TopoDS_Iterator It (aShape, Standard_True, Standard_True);
    for (; It.More(); It.Next()) {
      if (mapShape.Add(It.Value())) {
        if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
            TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) {
          listShape.Append(It.Value());
        }
      }
    }
  }
  else if (theExplodeType != EXPLODE_NEW_EXCLUDE_MAIN || aShape.ShapeType() != theShapeType) // issue 0021079
  {
    TopExp_Explorer exp (aShape, TopAbs_ShapeEnum(theShapeType));
    for (; exp.More(); exp.Next())
      if (mapShape.Add(exp.Current()))
        listShape.Append(exp.Current());
  }

  if (listShape.IsEmpty()) {
    //SetErrorCode("The given shape has no sub-shapes of the requested type");
    SetErrorCode(NOT_FOUND_ANY); // NPAL18017
    return aSeq;
  }

  if (isSorted) {
    bool isOldSorting = false;
    if (theExplodeType == EXPLODE_OLD_INCLUDE_MAIN)
      isOldSorting = true;
    SortShapes(listShape, isOldSorting);
  }

  TopTools_IndexedMapOfShape anIndices;
  TopExp::MapShapes(aShape, anIndices);
  Handle(TColStd_HArray1OfInteger) anArray;

  TopTools_ListIteratorOfListOfShape itSub (listShape);
  for (int index = 1; itSub.More(); itSub.Next(), ++index) {
    TopoDS_Shape aValue = itSub.Value();
    aSeq->Append(anIndices.FindIndex(aValue));
  }

  Handle(GEOM_Function) aFunction = theShape->GetLastFunction();

  //Make a Python command
  GEOM::TPythonDump pd (aFunction, /*append=*/true);
  pd << "listSubShapeIDs = geompy.SubShapeAll";
  switch (theExplodeType) {
  case EXPLODE_NEW_EXCLUDE_MAIN:
    break;
  case EXPLODE_NEW_INCLUDE_MAIN:
    pd << (isSorted ? "SortedCentresIDs(" : "IDs(")
       << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
    break;
  case EXPLODE_OLD_INCLUDE_MAIN:
    pd << (isSorted ? "SortedIDs(" : "IDs(")
       << theShape << ", " << TopAbs_ShapeEnum(theShapeType) << ")";
    break;
  default: ;
  }

  SetErrorCode(OK);
  return aSeq;
}

Here is the call graph for this function:

Handle ( Geom_Surface  )

Creates Geom_Plane.

Creates Geom_CylindricalSurface.

Parameters:
theAx1- shape object defining plane parameters
Return values:
Handle(Geom_Surface)- resulting surface
Parameters:
theAx1- edge defining cylinder axis
theRadius- cylinder radius
Return values:
Handle(Geom_Surface)- resulting surface

Definition at line 2144 of file GEOMImpl_IShapesOperations.cxx.

{
  if (anAx1.ShapeType() != TopAbs_EDGE) return NULL;
  TopoDS_Edge anEdge = TopoDS::Edge(anAx1);
  TopoDS_Vertex V1, V2;
  TopExp::Vertices(anEdge, V1, V2, Standard_True);
  if (V1.IsNull() || V2.IsNull()) {
    SetErrorCode("Bad edge given for the plane normal vector");
    return NULL;
  }
  gp_Pnt aLoc = BRep_Tool::Pnt(V1);
  gp_Vec aVec (aLoc, BRep_Tool::Pnt(V2));
  if (aVec.Magnitude() < Precision::Confusion()) {
    SetErrorCode("Vector with null magnitude given");
    return NULL;
  }
  return new Geom_Plane(aLoc, aVec);
}
static bool isSameEdge ( const TopoDS_Edge &  theEdge1,
const TopoDS_Edge &  theEdge2 
) [static]

Definition at line 4591 of file GEOMImpl_IShapesOperations.cxx.

{
  TopoDS_Vertex V11, V12, V21, V22;
  TopExp::Vertices(theEdge1, V11, V12);
  TopExp::Vertices(theEdge2, V21, V22);
  gp_Pnt P11 = BRep_Tool::Pnt(V11);
  gp_Pnt P12 = BRep_Tool::Pnt(V12);
  gp_Pnt P21 = BRep_Tool::Pnt(V21);
  gp_Pnt P22 = BRep_Tool::Pnt(V22);
  bool coincide = false;

  //Check that ends of edges coincide
  if(P11.Distance(P21) <= MAX_TOLERANCE) {
    if(P12.Distance(P22) <= MAX_TOLERANCE) coincide =  true;
  }
  else if(P11.Distance(P22) <= MAX_TOLERANCE) {
    if(P12.Distance(P21) <= MAX_TOLERANCE) coincide = true;
  }

  if(!coincide) return false;

  if (BRep_Tool::Degenerated(theEdge1))
    if (BRep_Tool::Degenerated(theEdge2)) return true;
    else return false;
  else
    if (BRep_Tool::Degenerated(theEdge2)) return false;

  double U11, U12, U21, U22;
  Handle(Geom_Curve) C1 = BRep_Tool::Curve(theEdge1, U11, U12);
  Handle(Geom_Curve) C2 = BRep_Tool::Curve(theEdge2, U21, U22);
  if(C1->DynamicType() == C2->DynamicType()) return true;

  //Check that both edges has the same geometry
  double range = U12-U11;
  double U = U11+ range/3.0;
  gp_Pnt P1 = C1->Value(U);     //Compute a point on one third of the edge's length
  U = U11+range*2.0/3.0;
  gp_Pnt P2 = C1->Value(U);     //Compute a point on two thirds of the edge's length

  if(!GeomLib_Tool::Parameter(C2, P1, MAX_TOLERANCE, U) ||  U < U21 || U > U22)
    return false;

  if(P1.Distance(C2->Value(U)) > MAX_TOLERANCE) return false;

  if(!GeomLib_Tool::Parameter(C2, P2, MAX_TOLERANCE, U) || U < U21 || U > U22)
    return false;

  if(P2.Distance(C2->Value(U)) > MAX_TOLERANCE) return false;

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool isSameFace ( const TopoDS_Face &  theFace1,
const TopoDS_Face &  theFace2 
) [static]

Definition at line 4648 of file GEOMImpl_IShapesOperations.cxx.

{
  TopExp_Explorer E(theFace1, TopAbs_EDGE);
  TopTools_ListOfShape LS1, LS2;
  for(; E.More(); E.Next()) LS1.Append(E.Current());

  E.Init(theFace2, TopAbs_EDGE);
  for(; E.More(); E.Next()) LS2.Append(E.Current());

  //Compare the number of edges in the faces
  if(LS1.Extent() != LS2.Extent()) return false;

  double aMin = RealFirst(), aMax = RealLast();
  double xminB1=aMax, yminB1=aMax, zminB1=aMax, xminB2=aMax, yminB2=aMax, zminB2=aMax;
  double xmaxB1=aMin, ymaxB1=aMin, zmaxB1=aMin, xmaxB2=aMin, ymaxB2=aMin, zmaxB2=aMin;

  for(E.Init(theFace1, TopAbs_VERTEX); E.More(); E.Next()) {
    gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(E.Current()));
    if(P.X() < xminB1) xminB1 = P.X();
    if(P.Y() < yminB1) yminB1 = P.Y();
    if(P.Z() < zminB1) zminB1 = P.Z();
    if(P.X() > xmaxB1) xmaxB1 = P.X();
    if(P.Y() > ymaxB1) ymaxB1 = P.Y();
    if(P.Z() > zmaxB1) zmaxB1 = P.Z();
  }

  for(E.Init(theFace2, TopAbs_VERTEX); E.More(); E.Next()) {
    gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(E.Current()));
    if(P.X() < xminB2) xminB2 = P.X();
    if(P.Y() < yminB2) yminB2 = P.Y();
    if(P.Z() < zminB2) zminB2 = P.Z();
    if(P.X() > xmaxB2) xmaxB2 = P.X();
    if(P.Y() > ymaxB2) ymaxB2 = P.Y();
    if(P.Z() > zmaxB2) zmaxB2 = P.Z();
  }

  //Compare the bounding boxes of both faces
  if(gp_Pnt(xminB1, yminB1, zminB1).Distance(gp_Pnt(xminB2, yminB2, zminB2)) > MAX_TOLERANCE)
    return false;

  if(gp_Pnt(xmaxB1, ymaxB1, zmaxB1).Distance(gp_Pnt(xmaxB2, ymaxB2, zmaxB2)) > MAX_TOLERANCE)
    return false;

  Handle(Geom_Surface) S1 = BRep_Tool::Surface(theFace1);
  Handle(Geom_Surface) S2 = BRep_Tool::Surface(theFace2);

  //Check if there a coincidence of two surfaces at least in two points
  double U11, U12, V11, V12, U21, U22, V21, V22;
  BRepTools::UVBounds(theFace1, U11, U12, V11, V12);
  BRepTools::UVBounds(theFace2, U21, U22, V21, V22);

  double rangeU = U12-U11;
  double rangeV = V12-V11;
  double U = U11 + rangeU/3.0;
  double V = V11 + rangeV/3.0;
  gp_Pnt P1 = S1->Value(U, V);
  U = U11+rangeU*2.0/3.0;
  V = V11+rangeV*2.0/3.0;
  gp_Pnt P2 = S1->Value(U, V);

  if (!GeomLib_Tool::Parameters(S2, P1, MAX_TOLERANCE, U, V) || U < U21 || U > U22 || V < V21 || V > V22)
    return false;

  if (P1.Distance(S2->Value(U,V)) > MAX_TOLERANCE) return false;

  if (!GeomLib_Tool::Parameters(S2, P2, MAX_TOLERANCE, U, V) || U < U21 || U > U22 || V < V21 || V > V22)
    return false;

  if (P2.Distance(S2->Value(U, V)) > MAX_TOLERANCE) return false;

  //Check that each edge of the Face1 has a counterpart in the Face2
  TopTools_MapOfOrientedShape aMap;
  TopTools_ListIteratorOfListOfShape LSI1(LS1);
  for(; LSI1.More(); LSI1.Next()) {
    TopoDS_Edge E = TopoDS::Edge(LSI1.Value());
    bool isFound = false;
    TopTools_ListIteratorOfListOfShape LSI2(LS2);
    for(; LSI2.More(); LSI2.Next()) {
      TopoDS_Shape aValue = LSI2.Value();
      if(aMap.Contains(aValue)) continue; //To avoid checking already found edge several times
      if(isSameEdge(E, TopoDS::Edge(aValue))) {
        aMap.Add(aValue);
        isFound = true;
        break;
      }
    }
    if(!isFound) return false;
  }

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool isSameSolid ( const TopoDS_Solid &  theSolid1,
const TopoDS_Solid &  theSolid2 
)

Definition at line 4744 of file GEOMImpl_IShapesOperations.cxx.

{
  TopExp_Explorer E(theSolid1, TopAbs_FACE);
  TopTools_ListOfShape LS1, LS2;
  for(; E.More(); E.Next()) LS1.Append(E.Current());
  E.Init(theSolid2, TopAbs_FACE);
  for(; E.More(); E.Next()) LS2.Append(E.Current());

  if(LS1.Extent() != LS2.Extent()) return false;

  double aMin = RealFirst(), aMax = RealLast();
  double xminB1=aMax, yminB1=aMax, zminB1=aMax, xminB2=aMax, yminB2=aMax, zminB2=aMax;
  double xmaxB1=aMin, ymaxB1=aMin, zmaxB1=aMin, xmaxB2=aMin, ymaxB2=aMin, zmaxB2=aMin;

  for(E.Init(theSolid1, TopAbs_VERTEX); E.More(); E.Next()) {
    gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(E.Current()));
    if(P.X() < xminB1) xminB1 = P.X();
    if(P.Y() < yminB1) yminB1 = P.Y();
    if(P.Z() < zminB1) zminB1 = P.Z();
    if(P.X() > xmaxB1) xmaxB1 = P.X();
    if(P.Y() > ymaxB1) ymaxB1 = P.Y();
    if(P.Z() > zmaxB1) zmaxB1 = P.Z();
  }

  for(E.Init(theSolid2, TopAbs_VERTEX); E.More(); E.Next()) {
    gp_Pnt P = BRep_Tool::Pnt(TopoDS::Vertex(E.Current()));
    if(P.X() < xminB2) xminB2 = P.X();
    if(P.Y() < yminB2) yminB2 = P.Y();
    if(P.Z() < zminB2) zminB2 = P.Z();
    if(P.X() > xmaxB2) xmaxB2 = P.X();
    if(P.Y() > ymaxB2) ymaxB2 = P.Y();
    if(P.Z() > zmaxB2) zmaxB2 = P.Z();
  }

  //Compare the bounding boxes of both solids
  if(gp_Pnt(xminB1, yminB1, zminB1).Distance(gp_Pnt(xminB2, yminB2, zminB2)) > MAX_TOLERANCE)
    return false;

  if(gp_Pnt(xmaxB1, ymaxB1, zmaxB1).Distance(gp_Pnt(xmaxB2, ymaxB2, zmaxB2)) > MAX_TOLERANCE)
    return false;

  //Check that each face of the Solid1 has a counterpart in the Solid2
  TopTools_MapOfOrientedShape aMap;
  TopTools_ListIteratorOfListOfShape LSI1(LS1);
  for(; LSI1.More(); LSI1.Next()) {
    TopoDS_Face F = TopoDS::Face(LSI1.Value());
    bool isFound = false;
    TopTools_ListIteratorOfListOfShape LSI2(LS2);
    for(; LSI2.More(); LSI2.Next()) {
      if(aMap.Contains(LSI2.Value())) continue; //To avoid checking already found faces several times
      if(isSameFace(F, TopoDS::Face(LSI2.Value()))) {
        aMap.Add(LSI2.Value());
        isFound = true;
        break;
      }
    }
    if(!isFound) return false;
  }

  return true;
}

Here is the call graph for this function:

static GEOM::TPythonDump& operator<< ( GEOM::TPythonDump theDump,
const GEOMAlgo_State  theState 
) [static]

Definition at line 2090 of file GEOMImpl_IShapesOperations.cxx.

{
  switch (theState) {
  case GEOMAlgo_ST_IN:
    theDump << "geompy.GEOM.ST_IN";
    break;
  case GEOMAlgo_ST_OUT:
    theDump << "geompy.GEOM.ST_OUT";
    break;
  case GEOMAlgo_ST_ON:
    theDump << "geompy.GEOM.ST_ON";
    break;
  case GEOMAlgo_ST_ONIN:
    theDump << "geompy.GEOM.ST_ONIN";
    break;
  case GEOMAlgo_ST_ONOUT:
    theDump << "geompy.GEOM.ST_ONOUT";
    break;
  default:
    theDump << "geompy.GEOM.ST_UNKNOWN";
    break;
  }
  return theDump;
}
std::pair<double, double> ShapeToDouble ( const TopoDS_Shape &  S,
bool  isOldSorting 
)

Definition at line 4274 of file GEOMImpl_IShapesOperations.cxx.

{
  // Computing of CentreOfMass
  gp_Pnt GPoint;
  double Len;

  if (S.ShapeType() == TopAbs_VERTEX) {
    GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S));
    Len = (double)S.Orientation();
  }
  else {
    GProp_GProps GPr;
    // BEGIN: fix for Mantis issue 0020842
    if (isOldSorting) {
      BRepGProp::LinearProperties(S, GPr);
    }
    else {
      if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) {
        BRepGProp::LinearProperties(S, GPr);
      }
      else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) {
        BRepGProp::SurfaceProperties(S, GPr);
      }
      else {
        BRepGProp::VolumeProperties(S, GPr);
      }
    }
    // END: fix for Mantis issue 0020842
    GPoint = GPr.CentreOfMass();
    Len = GPr.Mass();
  }

  double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9;
  return std::make_pair(dMidXYZ, Len);
}

Here is the caller graph for this function: