Back to index

salome-geom  6.5.0
Public Member Functions | Static Public Member Functions | Private Attributes
GEOMImpl_Block6Explorer Class Reference

#include <GEOMImpl_Block6Explorer.hxx>

List of all members.

Public Member Functions

 GEOMImpl_Block6Explorer ()
void InitByBlock (const TopoDS_Shape &theBlock)
void InitByBlockAndFace (const TopoDS_Shape &theBlock, const TopoDS_Shape &theFace)
void InitByBlockAndEdges (const TopoDS_Shape &theBlock, const TopoDS_Shape &theEdge1, const TopoDS_Shape &theEdge2)
void InitByBlockAndVertices (const TopoDS_Shape &theBlock, const TopoDS_Shape &theVertex1, const TopoDS_Shape &theVertex2, const TopoDS_Shape &theVertex3)
void InitByTwoFaces (const TopoDS_Shape &theFace1, const TopoDS_Shape &theFace2)
TopoDS_Shape GetVertex (const Standard_Integer theVertexID)
Standard_Integer GetVertexID (const TopoDS_Shape &theVertex)
Standard_Integer GetVertexID (const Standard_Integer theFaceID, const Standard_Integer theVertexNB)
Standard_Integer GetVertexOnEdgeID (const Standard_Integer theEdgeID, const Standard_Integer theVertexNB)
TopoDS_Shape GetEdge (const Standard_Integer theEdgeID, const Standard_Boolean doMake=Standard_False)
Standard_Integer GetEdgeID (const TopoDS_Shape &theEdge)
Standard_Integer GetEdgeID (const Standard_Integer theFaceID, const Standard_Integer theEdgeNB)
Standard_Integer FindEdgeID (const Standard_Integer theVertex1ID, const Standard_Integer theVertex2ID)
Standard_Integer FindCommonEdgeID (const Standard_Integer theFace1ID, const Standard_Integer theFace2ID)
TopoDS_Shape GetFace (const Standard_Integer theFaceID, const Standard_Boolean doMake=Standard_False)
Standard_Integer GetFaceID (const TopoDS_Shape &theFace)
Standard_Integer FindFaceID (const Standard_Integer theEdge1ID, const Standard_Integer theEdge2ID)
Standard_Integer GetOppositeFaceID (const Standard_Integer theFaceID)
Standard_Boolean IsSimilarFaces (const Standard_Integer theFace1ID, const Standard_Integer theFace2ID, const gp_Trsf theTransformation)

Static Public Member Functions

static void MapShapesAndAncestors (const TopoDS_Shape &S, const TopAbs_ShapeEnum TS, const TopAbs_ShapeEnum TA, TopTools_IndexedDataMapOfShapeListOfShape &M)
static Standard_Boolean IsSimilarEdges (const TopoDS_Shape &E1, const TopoDS_Shape &E2)
static Standard_Integer FindEdge (TopoDS_Shape &theResult, const TopoDS_Shape &V1, const TopoDS_Shape &V2, const TopTools_IndexedDataMapOfShapeListOfShape &MVE, const Standard_Boolean findAll=Standard_False)
static Standard_Integer FindFace (TopoDS_Shape &theResult, const TopoDS_Shape &V1, const TopoDS_Shape &V2, const TopoDS_Shape &V3, const TopoDS_Shape &V4, const TopTools_IndexedDataMapOfShapeListOfShape &MVF, const Standard_Boolean findAll=Standard_False)
static TCollection_AsciiString MakeFace (const TopoDS_Wire &theWire, const Standard_Boolean isPlanarWanted, TopoDS_Shape &theResult)
 Build a face, bound by the given wire.
static TCollection_AsciiString MakeAnyFace (const TopoDS_Wire &theWire, TopoDS_Shape &theResult)
 Build a face, bound by the given wire.

Private Attributes

TopTools_Array1OfShape myFaces
TopTools_Array1OfShape myEdges
TopTools_Array1OfShape myVertices

Detailed Description

Definition at line 108 of file GEOMImpl_Block6Explorer.hxx.


Constructor & Destructor Documentation

Definition at line 205 of file GEOMImpl_Block6Explorer.cxx.


Member Function Documentation

Standard_Integer GEOMImpl_Block6Explorer::FindCommonEdgeID ( const Standard_Integer  theFace1ID,
const Standard_Integer  theFace2ID 
)

Definition at line 316 of file GEOMImpl_Block6Explorer.cxx.

{
  return edge_id_faces(theFace1ID, theFace2ID);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::FindEdge ( TopoDS_Shape &  theResult,
const TopoDS_Shape &  V1,
const TopoDS_Shape &  V2,
const TopTools_IndexedDataMapOfShapeListOfShape &  MVE,
const Standard_Boolean  findAll = Standard_False 
) [static]

Definition at line 1129 of file GEOMImpl_Block6Explorer.cxx.

{
  Standard_Integer isFound = 0;

  const TopTools_ListOfShape& anEdgesOfV1 = MVE.FindFromKey(V1);
  const TopTools_ListOfShape& anEdgesOfV2 = MVE.FindFromKey(V2);

  TopTools_ListIteratorOfListOfShape it1 (anEdgesOfV1);
  for (; it1.More(); it1.Next()) {
    TopTools_ListIteratorOfListOfShape it2 (anEdgesOfV2);
    for (; it2.More(); it2.Next()) {
      if (it1.Value().IsSame(it2.Value())) {
        isFound++;
        theResult = it1.Value();
        if (!findAll) return isFound;
      }
    }
  }

  return isFound;
}

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::FindEdgeID ( const Standard_Integer  theVertex1ID,
const Standard_Integer  theVertex2ID 
)

Definition at line 305 of file GEOMImpl_Block6Explorer.cxx.

{
  return edge_id_vertices(theVertex1ID, theVertex2ID);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::FindFace ( TopoDS_Shape &  theResult,
const TopoDS_Shape &  V1,
const TopoDS_Shape &  V2,
const TopoDS_Shape &  V3,
const TopoDS_Shape &  V4,
const TopTools_IndexedDataMapOfShapeListOfShape &  MVF,
const Standard_Boolean  findAll = Standard_False 
) [static]

Definition at line 1160 of file GEOMImpl_Block6Explorer.cxx.

{
  Standard_Integer isFound = Standard_False;

  const TopTools_ListOfShape& aFacesOfV1 = MVF.FindFromKey(V1);
  const TopTools_ListOfShape& aFacesOfV2 = MVF.FindFromKey(V2);
  const TopTools_ListOfShape& aFacesOfV3 = MVF.FindFromKey(V3);
  const TopTools_ListOfShape& aFacesOfV4 = MVF.FindFromKey(V4);

  TopTools_ListIteratorOfListOfShape it1 (aFacesOfV1);
  for (; it1.More(); it1.Next()) {
    TopTools_ListIteratorOfListOfShape it2 (aFacesOfV2);
    for (; it2.More(); it2.Next()) {
      if (it1.Value().IsSame(it2.Value())) {
        TopTools_ListIteratorOfListOfShape it3 (aFacesOfV3);
        for (; it3.More(); it3.Next()) {
          if (it1.Value().IsSame(it3.Value())) {
            TopTools_ListIteratorOfListOfShape it4 (aFacesOfV4);
            for (; it4.More(); it4.Next()) {
              if (it1.Value().IsSame(it4.Value())) {
                isFound++;
                theResult = it1.Value();
                if (!findAll) return isFound;
              }
            }
          }
        }
      }
    }
  }

  return isFound;
}

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::FindFaceID ( const Standard_Integer  theEdge1ID,
const Standard_Integer  theEdge2ID 
)

Definition at line 377 of file GEOMImpl_Block6Explorer.cxx.

{
  return face_id_edges(theEdge1ID, theEdge2ID);
}

Here is the call graph for this function:

TopoDS_Shape GEOMImpl_Block6Explorer::GetEdge ( const Standard_Integer  theEdgeID,
const Standard_Boolean  doMake = Standard_False 
)

Definition at line 259 of file GEOMImpl_Block6Explorer.cxx.

{
  TopoDS_Shape aNullShape;
  if (theEdgeID < 1 || theEdgeID > NBEDGES) return aNullShape;
  if (myEdges(theEdgeID).IsNull() && doMake) {
    // Create the required edge as a linear segment between
    // corresponding vertices and put it in the Block's edges
    BRepBuilderAPI_MakeEdge ME (TopoDS::Vertex(myVertices(vertex_id_edge(theEdgeID, 1))),
                                TopoDS::Vertex(myVertices(vertex_id_edge(theEdgeID, 2))));
    if (!ME.IsDone()) {
      Standard_ConstructionError::Raise("Edge construction failed");
    }
    myEdges(theEdgeID) = ME.Shape();
  }

  return myEdges(theEdgeID);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::GetEdgeID ( const TopoDS_Shape &  theEdge)

Definition at line 282 of file GEOMImpl_Block6Explorer.cxx.

{
  for (Standard_Integer id = 1; id <= NBEDGES; id++) {
    if (theEdge.IsSame(myEdges(id))) return id;
  }
  Standard_NoSuchObject::Raise("The Edge does not belong to the Block");
  return 0;
}
Standard_Integer GEOMImpl_Block6Explorer::GetEdgeID ( const Standard_Integer  theFaceID,
const Standard_Integer  theEdgeNB 
)

Definition at line 295 of file GEOMImpl_Block6Explorer.cxx.

{
  return edge_id(theFaceID, theEdgeNB);
}

Here is the call graph for this function:

TopoDS_Shape GEOMImpl_Block6Explorer::GetFace ( const Standard_Integer  theFaceID,
const Standard_Boolean  doMake = Standard_False 
)

Definition at line 326 of file GEOMImpl_Block6Explorer.cxx.

{
  TopoDS_Shape aNullShape;
  if (theFaceID < 1 || theFaceID > NBFACES) return aNullShape;

  if (myFaces(theFaceID).IsNull() && doMake) {

    // Create the required face between
    // corresponding edges and put it in the Block's faces

    TopoDS_Shape E1 = GetEdge(edge_id(theFaceID, 1), doMake);
    TopoDS_Shape E2 = GetEdge(edge_id(theFaceID, 2), doMake);
    TopoDS_Shape E3 = GetEdge(edge_id(theFaceID, 3), doMake);
    TopoDS_Shape E4 = GetEdge(edge_id(theFaceID, 4), doMake);

    BRepBuilderAPI_MakeWire MW (TopoDS::Edge(E1),
                                TopoDS::Edge(E2),
                                TopoDS::Edge(E3),
                                TopoDS::Edge(E4));
    if (!MW.IsDone()) {
      Standard_ConstructionError::Raise("Wire construction failed");
    }
    TopoDS_Shape aFace;
    MakeFace(MW, Standard_False, aFace);
    if (aFace.IsNull()) {
      Standard_ConstructionError::Raise("Face construction failed");
    }
    myFaces(theFaceID) = aFace;
  }

  return myFaces(theFaceID);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::GetFaceID ( const TopoDS_Shape &  theFace)

Definition at line 364 of file GEOMImpl_Block6Explorer.cxx.

{
  for (Standard_Integer id = 1; id <= NBFACES; id++) {
    if (theFace.IsSame(myFaces(id))) return id;
  }
  Standard_NoSuchObject::Raise("The Face does not belong to the Block");
  return 0;
}

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::GetOppositeFaceID ( const Standard_Integer  theFaceID)

Definition at line 387 of file GEOMImpl_Block6Explorer.cxx.

{
  Standard_Integer opp_face_id[NBFACES + 1] = {
    0,
    2,  // to 1 face
    1,  // to 2 face
    4,  // to 3 face
    3,  // to 4 face
    6,  // to 5 face
    5}; // to 6 face

  return opp_face_id[theFaceID];
}

Here is the caller graph for this function:

TopoDS_Shape GEOMImpl_Block6Explorer::GetVertex ( const Standard_Integer  theVertexID)

Definition at line 214 of file GEOMImpl_Block6Explorer.cxx.

{
  TopoDS_Shape aNullShape;
  if (theVertexID < 1 || theVertexID > NBVERTS) return aNullShape;
  return myVertices(theVertexID);
}

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::GetVertexID ( const TopoDS_Shape &  theVertex)

Definition at line 225 of file GEOMImpl_Block6Explorer.cxx.

{
  for (Standard_Integer id = 1; id <= NBVERTS; id++) {
    if (theVertex.IsSame(myVertices(id))) return id;
  }
  Standard_NoSuchObject::Raise("The Vertex does not belong to the Block");
  return 0;
}

Here is the caller graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::GetVertexID ( const Standard_Integer  theFaceID,
const Standard_Integer  theVertexNB 
)

Definition at line 238 of file GEOMImpl_Block6Explorer.cxx.

{
  return vertex_id(theFaceID, theVertexNB);
}

Here is the call graph for this function:

Standard_Integer GEOMImpl_Block6Explorer::GetVertexOnEdgeID ( const Standard_Integer  theEdgeID,
const Standard_Integer  theVertexNB 
)

Definition at line 249 of file GEOMImpl_Block6Explorer.cxx.

{
  return vertex_id_edge(theEdgeID, theVertexNB);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMImpl_Block6Explorer::InitByBlock ( const TopoDS_Shape &  theBlock)

Definition at line 479 of file GEOMImpl_Block6Explorer.cxx.

{
  // 1. Find any one face of the block
  TopExp_Explorer faces (theBlock, TopAbs_FACE);
  if (!faces.More()) {
    Standard_ConstructionError::Raise("The block has no faces");
  }
  TopoDS_Shape aFirstFace = faces.Current();

  // 2. Store all elements of the block relatively aFirstFace
  InitByBlockAndFace(theBlock, aFirstFace);
}

Here is the call graph for this function:

void GEOMImpl_Block6Explorer::InitByBlockAndEdges ( const TopoDS_Shape &  theBlock,
const TopoDS_Shape &  theEdge1,
const TopoDS_Shape &  theEdge2 
)

Definition at line 537 of file GEOMImpl_Block6Explorer.cxx.

{
  // 1. Store vertices and edges of the first face

  // 1.1. Store two given edges
  myEdges(edge_id(1, 1)) = theEdge1;
  myEdges(edge_id(1, 3)) = theEdge3;

  // 1.2. Find and store the first face
  TopTools_IndexedDataMapOfShapeListOfShape MEF;
  MapShapesAndAncestors(theBlock, TopAbs_EDGE, TopAbs_FACE, MEF);
  if (MEF.Extent() != NBEDGES) {
    Standard_TypeMismatch::Raise("Block has wrong number of edges");
  }
  const TopTools_ListOfShape& aFacesOfE1 = MEF.FindFromKey(theEdge1);
  const TopTools_ListOfShape& aFacesOfE3 = MEF.FindFromKey(theEdge3);

  Standard_Boolean isFound = Standard_False;
  TopTools_ListIteratorOfListOfShape anIterF1 (aFacesOfE1);
  for (; anIterF1.More() && !isFound; anIterF1.Next()) {

    TopTools_ListIteratorOfListOfShape anIterF3 (aFacesOfE3);
    for (; anIterF3.More() && !isFound; anIterF3.Next()) {

      if (anIterF1.Value().IsSame(anIterF3.Value())) {
        isFound = Standard_True;

        // Store the face, defined by two opposite edges
        myFaces(1) = anIterF1.Value();
      }
    }
  }
  if (!isFound) {
    Standard_ConstructionError::Raise
      ("Edges 1 and 2 do not belong to one face of the block");
  }

  // 1.3. Make vertices of the first edge the first and the
  //      second vertices of the first face. Order is free.
  TopoDS_Edge E = TopoDS::Edge(theEdge1);
  TopoDS_Vertex V1, V2;
  TopExp::Vertices(E, V1, V2, Standard_True);
  myVertices(vertex_id(1,1)) = V1;
  myVertices(vertex_id(1,2)) = V2;

  // Init maps vertex->list_of_edges for the face
  TopTools_IndexedDataMapOfShapeListOfShape M1;
  MapShapesAndAncestors(myFaces(1), TopAbs_VERTEX, TopAbs_EDGE, M1);
  if (M1.Extent() != 4) {
    Standard_TypeMismatch::Raise("The first face of block has wrong number of vertices");
  }

  // 1.4. Find and store others elements of the first face

  // edges of the first vertex
  TopoDS_Shape E1_f = M1.FindFromKey(V1).First();
  TopoDS_Shape E1_l = M1.FindFromKey(V1).Last();

  if (E1_f.IsSame(theEdge1)) {
    myEdges(edge_id(1, 4)) = E1_l;
  } else {
    myEdges(edge_id(1, 4)) = E1_f;
  }

  // fourth vertex
  TopoDS_Edge E4 = TopoDS::Edge(myEdges(edge_id(1, 4)));
  TopoDS_Vertex V41, V42;
  TopExp::Vertices(E4, V41, V42, Standard_True);
  if (V41.IsSame(V1)) {
    myVertices(vertex_id(1,4)) = V42;
  } else {
    myVertices(vertex_id(1,4)) = V41;
  }

  // edges of the second vertex
  TopoDS_Shape E2_f = M1.FindFromKey(V2).First();
  TopoDS_Shape E2_l = M1.FindFromKey(V2).Last();

  if (E2_f.IsSame(theEdge1)) {
    myEdges(edge_id(1, 2)) = E2_l;
  } else {
    myEdges(edge_id(1, 2)) = E2_f;
  }

  // fird vertex
  TopoDS_Edge E2 = TopoDS::Edge(myEdges(edge_id(1, 2)));
  TopoDS_Vertex V21, V22;
  TopExp::Vertices(E2, V21, V22, Standard_True);
  if (V21.IsSame(V2)) {
    myVertices(vertex_id(1,3)) = V22;
  } else {
    myVertices(vertex_id(1,3)) = V21;
  }

  // 2. Store all other elements of the block
  InitByBlockAndVertices (theBlock,
                          myVertices(vertex_id(1,1)),
                          myVertices(vertex_id(1,2)),
                          myVertices(vertex_id(1,3)));
}

Here is the call graph for this function:

void GEOMImpl_Block6Explorer::InitByBlockAndFace ( const TopoDS_Shape &  theBlock,
const TopoDS_Shape &  theFace 
)

Definition at line 496 of file GEOMImpl_Block6Explorer.cxx.

{
  myFaces(1) = theFace;

  // 2. Get wire of the first face
  TopExp_Explorer wires (myFaces(1), TopAbs_WIRE);
  if (!wires.More()) {
    Standard_ConstructionError::Raise("A face of the block has no wires");
  }
  TopoDS_Shape aWire = wires.Current();
  wires.Next();
  if (wires.More()) {
    Standard_ConstructionError::Raise("A face of the block has more than one wires");
  }

  // 3. Explore wire to init edges and vertices of the first face
  BRepTools_WireExplorer aWE (TopoDS::Wire(aWire), TopoDS::Face(myFaces(1)));
  Standard_Integer nb = 1;
  for (; aWE.More(); aWE.Next(), nb++) {
    if (nb > 4) {
      Standard_ConstructionError::Raise("A face of the block has more than four edges");
    }
    myEdges(edge_id(1, nb)) = aWE.Current();
    myVertices(vertex_id(1, nb)) = aWE.CurrentVertex();
  }
  if (nb < 5) {
    Standard_ConstructionError::Raise("A face of the block has less than four edges");
  }

  // 2. Store all other elements of the block
  InitByBlockAndVertices (theBlock,
                          myVertices(vertex_id(1,1)),
                          myVertices(vertex_id(1,2)),
                          myVertices(vertex_id(1,3)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMImpl_Block6Explorer::InitByBlockAndVertices ( const TopoDS_Shape &  theBlock,
const TopoDS_Shape &  theVertex1,
const TopoDS_Shape &  theVertex2,
const TopoDS_Shape &  theVertex3 
)

Definition at line 644 of file GEOMImpl_Block6Explorer.cxx.

{
  // Here we suppose, that vertices are ordered, i.e. exists edge between
  // theVertex1 and theVertex2 and edge between theVertex2 and theVertex3

  // 1. Store vertices and edges of the first face.
  //    If the first face is initialized, it means, that this
  //    method is called from another initialization method, and all
  //    vertices and edges of the first face are also initialized
  if (myFaces(1).IsNull()) {

    // 1.1. Store first three vertices
    myVertices(vertex_id(1, 1)) = theVertex1;
    myVertices(vertex_id(1, 2)) = theVertex2;
    myVertices(vertex_id(1, 3)) = theVertex3;

    // 1.2. Find and store the first face
    TopTools_IndexedDataMapOfShapeListOfShape MVF;
    MapShapesAndAncestors(theBlock, TopAbs_VERTEX, TopAbs_FACE, MVF);
    if (MVF.Extent() != NBVERTS) {
      Standard_TypeMismatch::Raise("Block has wrong number of vertices");
    }
    const TopTools_ListOfShape& aFacesOfV1 = MVF.FindFromKey(theVertex1);
    const TopTools_ListOfShape& aFacesOfV3 = MVF.FindFromKey(theVertex3);

    Standard_Boolean isFound = Standard_False;
    TopTools_ListIteratorOfListOfShape anIterF1 (aFacesOfV1);
    for (; anIterF1.More() && !isFound; anIterF1.Next()) {

      TopTools_ListIteratorOfListOfShape anIterF3 (aFacesOfV3);
      for (; anIterF3.More() && !isFound; anIterF3.Next()) {

        if (anIterF1.Value().IsSame(anIterF3.Value())) {
          isFound = Standard_True;

          // Store the face, defined by two opposite vertices
          myFaces(1) = anIterF1.Value();
        }
      }
    }
    if (!isFound) {
      Standard_ConstructionError::Raise
        ("Vertices 1 and 3 do not belong to one face of the block");
    }

    // Init maps vertex->list_of_edges for the face
    TopTools_IndexedDataMapOfShapeListOfShape M1;
    MapShapesAndAncestors(myFaces(1), TopAbs_VERTEX, TopAbs_EDGE, M1);
    if (M1.Extent() != 4) {
      Standard_TypeMismatch::Raise("The first face of block has wrong number of vertices");
    }

    // 1.3. Find and store edges and last vertex of the first face
    const TopTools_ListOfShape& anEdgesOfV1 = M1.FindFromKey(theVertex1);
    const TopTools_ListOfShape& anEdgesOfV2 = M1.FindFromKey(theVertex2);
    const TopTools_ListOfShape& anEdgesOfV3 = M1.FindFromKey(theVertex3);

    TopTools_ListIteratorOfListOfShape anIterE2 (anEdgesOfV2);
    for (; anIterE2.More(); anIterE2.Next()) {

      TopTools_ListIteratorOfListOfShape anIterE1 (anEdgesOfV1);
      for (; anIterE1.More(); anIterE1.Next()) {

        if (anIterE1.Value().IsSame(anIterE2.Value())) {
          // Store the first edge, defined by two vertices
          myEdges(edge_id(1,1)) = anIterE1.Value();

        } else {
          // Store the last edge
          myEdges(edge_id(1,4)) = anIterE1.Value();

          // Find and store the last vertex
          TopoDS_Edge E = TopoDS::Edge(myEdges(4));
          TopoDS_Vertex V1, V2;
          TopExp::Vertices(E, V1, V2, Standard_True);

          if (V1.IsSame(theVertex1)) {
            myVertices(vertex_id(1,4)) = V2;
          } else {
            myVertices(vertex_id(1,4)) = V1;
          }
        }
      }

      TopTools_ListIteratorOfListOfShape anIterE3 (anEdgesOfV3);
      for (; anIterE3.More(); anIterE3.Next()) {

        if (anIterE3.Value().IsSame(anIterE2.Value())) {
          // Store the second edge, defined by two vertices
          myEdges(edge_id(1,2)) = anIterE3.Value();

        } else {
          // Store the fird edge
          myEdges(edge_id(1,3)) = anIterE3.Value();
        }
      }
    }
  }

  // Init map vertex->list_of_edges for the block
  TopTools_IndexedDataMapOfShapeListOfShape MB;
  MapShapesAndAncestors(theBlock, TopAbs_VERTEX, TopAbs_EDGE, MB);
  if (MB.Extent() != NBVERTS) {
    Standard_TypeMismatch::Raise("Block has wrong number of vertices");
  }

  // 2. Store edges, linking the first face with the second one
  //    and vertices of the second face
  TopTools_IndexedMapOfShape aFaceEdges;
  TopExp::MapShapes(myFaces(1), TopAbs_EDGE, aFaceEdges);

  Standard_Integer i = 1;
  for (; i <= 4; i++) {
    // Get i-th vertex of the face 1
    TopoDS_Shape Vi = myVertices(vertex_id(1, i));
    if (!MB.Contains(Vi)) {
      Standard_ConstructionError::Raise("Face does not belong to the block");
    }

    // Get list of block's edges, sharing this Vertex
    const TopTools_ListOfShape& anEdgesOfVi = MB.FindFromKey(Vi);
    TopTools_ListIteratorOfListOfShape anEdgesIter (anEdgesOfVi);

    // Get Edge (from the List), not belonging to the face 1
    Standard_Boolean isFound = Standard_False;
    for (; anEdgesIter.More() && !isFound; anEdgesIter.Next()) {
      if (!aFaceEdges.Contains(anEdgesIter.Value())) {
        isFound = Standard_True;

        // Store the linking edge
        TopoDS_Shape aLinkEdge = anEdgesIter.Value();
        myEdges(side_edge_id(i)) = aLinkEdge;

        // Get another vertex of the linking edge
        TopoDS_Edge E = TopoDS::Edge(aLinkEdge);
        TopoDS_Vertex V1, V2;
        TopExp::Vertices(E, V1, V2, Standard_True);

        // Store the i-th vertex of the second (opposite to the first) face
        if (V1.IsSame(Vi)) {
          myVertices(vertex_id(2, i)) = V2;
        } else {
          myVertices(vertex_id(2, i)) = V1;
        }
      }
    }
  }

  // 3. Store edges of the second (opposite to the first) face
  for (i = 1; i <= 4; i++) {
    // Get i-th and (i+1)-th vertices of the face 2
    TopoDS_Shape Vi = myVertices(vertex_id(2, i));
    TopoDS_Shape Vj = myVertices(vertex_id(2, mod4(i + 1)));

    // Get list of block's edges, sharing Vi
    const TopTools_ListOfShape& anEdgesOfVi = MB.FindFromKey(Vi);
    // Get list of block's edges, sharing Vj
    const TopTools_ListOfShape& anEdgesOfVj = MB.FindFromKey(Vj);

    // Get Edge (from the List), linking this vertex with the next one
    Standard_Boolean isFound = Standard_False;
    TopTools_ListIteratorOfListOfShape anEdgesIteri (anEdgesOfVi);
    for (; anEdgesIteri.More() && !isFound; anEdgesIteri.Next()) {

      TopTools_ListIteratorOfListOfShape anEdgesIterj (anEdgesOfVj);
      for (; anEdgesIterj.More() && !isFound; anEdgesIterj.Next()) {

        if (anEdgesIteri.Value().IsSame(anEdgesIterj.Value())) {
          isFound = Standard_True;

          // Store the linking edge
          myEdges(edge_id(2, i)) = anEdgesIteri.Value();
        }
      }
    }
  }

  // 4. Store faces of the block
  TopTools_IndexedDataMapOfShapeListOfShape MBE;
  MapShapesAndAncestors(theBlock, TopAbs_EDGE, TopAbs_FACE, MBE);
  if (MBE.Extent() != NBEDGES) {
    Standard_TypeMismatch::Raise("Block has wrong number of edges");
  }

  for (i = 2; i <= NBFACES; i++) {
    TopoDS_Shape Ei1 = myEdges(edge_id(i, 1));
    TopoDS_Shape Ei2 = myEdges(edge_id(i, 2));
    const TopTools_ListOfShape& aFacesOfEi1 = MBE.FindFromKey(Ei1);
    const TopTools_ListOfShape& aFacesOfEi2 = MBE.FindFromKey(Ei2);

    Standard_Boolean isFound = Standard_False;
    TopTools_ListIteratorOfListOfShape anIterEi1 (aFacesOfEi1);
    for (; anIterEi1.More() && !isFound; anIterEi1.Next()) {

      TopTools_ListIteratorOfListOfShape anIterEi2 (aFacesOfEi2);
      for (; anIterEi2.More() && !isFound; anIterEi2.Next()) {

        if (anIterEi1.Value().IsSame(anIterEi2.Value())) {
          isFound = Standard_True;

          // Store the face, defined by two edges
          myFaces(i) = anIterEi1.Value();
        }
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMImpl_Block6Explorer::InitByTwoFaces ( const TopoDS_Shape &  theFace1,
const TopoDS_Shape &  theFace2 
)

Definition at line 859 of file GEOMImpl_Block6Explorer.cxx.

{
  if (theFace1.IsSame(theFace2)) {
    Standard_ConstructionError::Raise("The faces must be different");
  }

  // Add two given faces in the structure
  myFaces(1) = theFace1;
  myFaces(2) = theFace2;

  // Step 1. Order vertices (and edges)

  // 1.1. Ordered vertices and edges of the first face we put in <myVertices>

  // Get wire of the first face
  TopExp_Explorer wires1 (myFaces(1), TopAbs_WIRE);
  if (!wires1.More()) {
    Standard_ConstructionError::Raise("A face for the block has no wires");
  }
  TopoDS_Shape aWire1 = wires1.Current();
  wires1.Next();
  if (wires1.More()) {
    Standard_ConstructionError::Raise("A face for the block has more than one wire");
  }

  BRepTools_WireExplorer aWE1 (TopoDS::Wire(aWire1), TopoDS::Face(myFaces(1)));
  Standard_Integer nb;
  for (nb = 1; aWE1.More(); aWE1.Next(), nb++) {
    if (nb > 4) {
      Standard_ConstructionError::Raise("A face for the block has more than four edges");
    }
    myEdges(edge_id(1, nb)) = aWE1.Current();
    myVertices(vertex_id(1, nb)) = aWE1.CurrentVertex();
  }
  if (nb < 5) {
    Standard_ConstructionError::Raise("A face for the block has less than four edges");
  }

  // 1.2. Ordered vertices and edges of the second face we temporarily store
  // in arrays, to find for them rigth location in <myVertices> on the Step 2.

  // declare arrays
  TopTools_Array1OfShape aVertis2(1,4); // ordered vertices of the second face
  TopTools_Array1OfShape anEdges2(1,4); // anEdges2(i) links aVertis2(i) and aVertis2(i+1)

  // Get wire of the second face
  TopExp_Explorer wires2 (myFaces(2), TopAbs_WIRE);
  if (!wires2.More()) {
    Standard_ConstructionError::Raise("A face for the block has no wires");
  }
  TopoDS_Shape aWire2 = wires2.Current();
  wires2.Next();
  if (wires2.More()) {
    Standard_ConstructionError::Raise("A face for the block has more than one wire");
  }

  BRepTools_WireExplorer aWE2 (TopoDS::Wire(aWire2), TopoDS::Face(myFaces(2)));
  for (nb = 1; aWE2.More(); aWE2.Next(), nb++) {
    if (nb > 4) {
      Standard_ConstructionError::Raise("A face for the block has more than four edges");
    }
    anEdges2(nb) = aWE2.Current();
    aVertis2(nb) = aWE2.CurrentVertex();
  }
  if (nb < 5) {
    Standard_ConstructionError::Raise("A face for the block has less than four edges");
  }

  // Step 2. Find right place in <myVertices> for the <aVertis2>,
  //         so as to minimize common length of linking edges
  //         between face 1 and face 2.
  //         Each linking edge (of four) will link vertices of the
  //         faces 1 and 2 with equal local numbers.
  // The right place is defined by:
  //  - vertex <aVertis2(i_min)>, which will become the first vertex
  //         of the second face <myVertices(vertex_id(2,1))>
  //  - orientation of <aVertis2> relatively their future location
  //         in <myVertices> (s_min = 1 if direct, s_min = -1 if reversed)
  Standard_Integer i_min = 0, s_min = 0;

  TColgp_Array1OfPnt aPnts1 (1,4); // points of the first face
  aPnts1(1) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 1))));
  aPnts1(2) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 2))));
  aPnts1(3) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 3))));
  aPnts1(4) = BRep_Tool::Pnt(TopoDS::Vertex(myVertices(vertex_id(1, 4))));

  TColgp_Array1OfPnt aPnts2 (1,4); // points of the second face
  aPnts2(1) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(1)));
  aPnts2(2) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(2)));
  aPnts2(3) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(3)));
  aPnts2(4) = BRep_Tool::Pnt(TopoDS::Vertex(aVertis2(4)));

  Standard_Real Dist_min = RealLast();
  // try all possible locations to find the best (with minimum sum distance)
  Standard_Integer i = 1;
  for (; i <= 4; i++) {
    // try direct orientation
    Standard_Real Dist_plus = aPnts1(1).Distance(aPnts2(i)) +
                              aPnts1(2).Distance(aPnts2(mod4(i + 1))) +
                              aPnts1(3).Distance(aPnts2(mod4(i + 2))) +
                              aPnts1(4).Distance(aPnts2(mod4(i + 3)));
    if (Dist_plus < Dist_min) {
      Dist_min = Dist_plus;
      i_min = i;
      s_min = 1;
    }

    // try reversed orientation
    Standard_Real Dist_minus = aPnts1(1).Distance(aPnts2(i)) +
                               aPnts1(2).Distance(aPnts2(mod4(i - 1))) +
                               aPnts1(3).Distance(aPnts2(mod4(i - 2))) +
                               aPnts1(4).Distance(aPnts2(mod4(i - 3)));
    if (Dist_minus < Dist_min) {
      Dist_min = Dist_minus;
      i_min = i;
      s_min = - 1;
    }
  }

  // 3. Put vertices and edges of the second face to they
  //    permanent location in <myVertices> and <myEdges>
  for (i = 1; i <= 4; i++) {
    Standard_Integer nb = mod4(i_min + s_min*(i - 1));

    if (aPnts1(i).Distance(aPnts2(nb)) < Precision::Confusion()) {
      Standard_ConstructionError::Raise("The faces are too close");
    }

    myVertices(vertex_id(2, i)) = aVertis2(nb);

    if (s_min == -1) nb = mod4(nb - 1);
    myEdges(edge_id(2, i)) = anEdges2(nb);
  }

  // check the wires closure
  TopoDS_Wire wire1 = TopoDS::Wire(aWire1);
  TopoDS_Wire wire2 = TopoDS::Wire(aWire2);
  TopoDS_Vertex aV1, aV2;

  TopExp::Vertices(wire1, aV1, aV2);
  if (!aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2))
    aWire1.Closed(true);

  TopExp::Vertices(wire2, aV1, aV2);
  if (!aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2))
    aWire2.Closed(true);

  // 4. Generate side surface
  if (!aWire1.Closed() || !aWire2.Closed()) {
    // BRepOffsetAPI_ThruSections is not applicable on not closed wires
    GetFace(3, Standard_True);
    GetFace(4, Standard_True);
    GetFace(5, Standard_True);
    GetFace(6, Standard_True);
  } else {
    // try to build faces on native surfaces of edges or planar
    Standard_Boolean tryThru = Standard_False;
    for (Standard_Integer i = 3; i <= 6 && !tryThru; i++) {
      Standard_Boolean doMake = Standard_True;
      TopoDS_Shape E1 = GetEdge(edge_id(i, 1), doMake);
      TopoDS_Shape E2 = GetEdge(edge_id(i, 2), doMake);
      TopoDS_Shape E3 = GetEdge(edge_id(i, 3), doMake);
      TopoDS_Shape E4 = GetEdge(edge_id(i, 4), doMake);

      BRepBuilderAPI_MakeWire MW (TopoDS::Edge(E1),
                                  TopoDS::Edge(E2),
                                  TopoDS::Edge(E3),
                                  TopoDS::Edge(E4));
      if (!MW.IsDone()) {
        Standard_ConstructionError::Raise("Wire construction failed");
      }

      BRepBuilderAPI_MakeFace MF (MW, Standard_False);
      if (MF.IsDone()) {
        myFaces(i) = MF.Shape();
      } else {
        tryThru = Standard_True;
      }
    }

    // Build side surface by ThruSections algorithm
    if (tryThru) {
      BRepOffsetAPI_ThruSections THS;
      THS.AddWire(TopoDS::Wire(aWire1));
      THS.AddWire(TopoDS::Wire(aWire2));
      THS.Build();
      if (!THS.IsDone()) {
        StdFail_NotDone::Raise("Side surface generation failed");
      }
      for (Standard_Integer i = 1; i <= 4; i++) {
        // fill face
        myFaces(i+2) = THS.GeneratedFace(myEdges(i));

        // fill edge
        Standard_Integer ee = side_edge_id(i);
        TopTools_IndexedDataMapOfShapeListOfShape MVE;
        MapShapesAndAncestors(myFaces(i+2), TopAbs_VERTEX, TopAbs_EDGE, MVE);
        FindEdge(myEdges(ee),
                 myVertices(vertex_id_edge(ee, 1)),
                 myVertices(vertex_id_edge(ee, 2)),
                 MVE);
      }
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Standard_Boolean GEOMImpl_Block6Explorer::IsSimilarEdges ( const TopoDS_Shape &  E1,
const TopoDS_Shape &  E2 
) [static]

Definition at line 1108 of file GEOMImpl_Block6Explorer.cxx.

{
  TopoDS_Edge E1e = TopoDS::Edge(E1);
  TopoDS_Edge E2e = TopoDS::Edge(E2);
  TopoDS_Vertex V11, V12, V21, V22;
  TopExp::Vertices(E1e, V11, V12, Standard_True);
  TopExp::Vertices(E2e, V21, V22, Standard_True);
  if (BRepTools::Compare(V11, V21) && BRepTools::Compare(V12, V22))
    return Standard_True;
  if (BRepTools::Compare(V11, V22) && BRepTools::Compare(V12, V21))
    return Standard_True;

  return Standard_False;
}

Here is the caller graph for this function:

Standard_Boolean GEOMImpl_Block6Explorer::IsSimilarFaces ( const Standard_Integer  theFace1ID,
const Standard_Integer  theFace2ID,
const gp_Trsf  theTransformation 
)

Definition at line 405 of file GEOMImpl_Block6Explorer.cxx.

{
  Standard_Integer common_edge_id = FindCommonEdgeID(theFace1ID, theFace2ID);

  if (common_edge_id == 0) { // opposite faces
    for (Standard_Integer id = 1; id <= 4; id++) {
      TopoDS_Shape E1 = GetEdge(edge_id(theFace1ID, id));
      TopoDS_Shape E2 = GetEdge(edge_id(theFace2ID, id));

      BRepBuilderAPI_Transform aTrsf (E1, theTransformation, Standard_False);
      if (!IsSimilarEdges(aTrsf.Shape(), E2))
        return Standard_False;
    }
  } else { // the faces have common edge
    TopTools_Array1OfShape aVerts1 (1,4);
    TopTools_Array1OfShape aVerts2 (1,4);

    Standard_Integer common_vertex1 = GetVertexOnEdgeID(common_edge_id, 1);
    Standard_Integer common_vertex2 = GetVertexOnEdgeID(common_edge_id, 2);
    aVerts1(1) = myVertices(common_vertex1);
    aVerts1(2) = myVertices(common_vertex2);
    aVerts2(1) = myVertices(common_vertex1);
    aVerts2(2) = myVertices(common_vertex2);

    Standard_Integer not_common_v11 = 0, not_common_v12 = 0;
    Standard_Integer vnb, vid;
    for (vnb = 1; vnb <= 4; vnb++) {
      vid = GetVertexID(theFace1ID, vnb);
      if (vid != common_vertex1 && FindEdgeID(vid, common_vertex1) == 0) {
        not_common_v12 = vid;
      } else {
        if (vid != common_vertex2 && FindEdgeID(vid, common_vertex2) == 0) {
          not_common_v11 = vid;
        }
      }
    }

    Standard_Integer not_common_v21 = 0, not_common_v22 = 0;
    for (vnb = 1; vnb <= 4; vnb++) {
      vid = GetVertexID(theFace2ID, vnb);
      if (vid != common_vertex1 && FindEdgeID(vid, common_vertex1) == 0) {
        not_common_v22 = vid;
      } else {
        if (vid != common_vertex2 && FindEdgeID(vid, common_vertex2) == 0) {
          not_common_v21 = vid;
        }
      }
    }
    aVerts1(3) = myVertices(not_common_v11);
    aVerts1(4) = myVertices(not_common_v12);
    aVerts2(3) = myVertices(not_common_v21);
    aVerts2(4) = myVertices(not_common_v22);

    for (Standard_Integer id = 1; id <= 4; id++) {
      BRepBuilderAPI_Transform aTrsf (aVerts1(id), theTransformation, Standard_False);
      TopoDS_Vertex V1 = TopoDS::Vertex(aTrsf.Shape());
      TopoDS_Vertex V2 = TopoDS::Vertex(aVerts2(id));
      if (!BRepTools::Compare(V1, V2)) {
        return Standard_False;
      }
    }
  }

  return Standard_True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TCollection_AsciiString GEOMImpl_Block6Explorer::MakeAnyFace ( const TopoDS_Wire &  theWire,
TopoDS_Shape &  theResult 
) [static]

Build a face, bound by the given wire.

Parameters:
theWireThe initial wire to build the face on.
theResultThe resulting shape.
Returns:
Error or warning description. Empty string in case of success.

Definition at line 1332 of file GEOMImpl_Block6Explorer.cxx.

{
  TCollection_AsciiString aWarning;

  // try to build a face on any surface under the edges of the wire
  BRepBuilderAPI_MakeFace MK (theWire, Standard_False);
  if (MK.IsDone()) {
    theResult = MK.Shape();
    return aWarning;
  }

  // try to construct filling surface
  BRepOffsetAPI_MakeFilling MF;

  Standard_Integer nbEdges = 0;
  BRepTools_WireExplorer aWE (theWire);
  for (; aWE.More(); aWE.Next(), nbEdges++) {
    MF.Add(TopoDS::Edge(aWE.Current()), GeomAbs_C0);
  }

  MF.Build();
  if (!MF.IsDone()) {
    aWarning = "BRepOffsetAPI_MakeFilling failed";
    return aWarning;
  }

  // Result of filling
  TopoDS_Shape aFace = MF.Shape();

  // 12.04.2006 for PAL12149 begin
  Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(aFace));

// VSR: debug issues 0021568 and 0021550 (15/05/2012) - BEGIN
// the following block, when enabled, leads to extra vertices generation by partition algorithm
// in some cases, for example when fillet is made on a PipeTShape
//#if OCC_VERSION_LARGE > 0x06050200
#if 0
// VSR: debug issues 0021568 and 0021550 (15/05/2012) - END
  BRep_Builder BB;
  TopoDS_Iterator itw(theWire);
  for (; itw.More(); itw.Next())
  {
    const TopoDS_Edge& anEdge = TopoDS::Edge(itw.Value());
    TopoDS_Edge NewEdge = TopoDS::Edge(MF.Generated(anEdge).First());
    Standard_Real fpar, lpar;
    Handle(Geom2d_Curve) NewPCurve = BRep_Tool::CurveOnSurface(NewEdge, TopoDS::Face(aFace), fpar, lpar);
    TopLoc_Location aLoc;
    Standard_Real NewTol = BRep_Tool::Tolerance(NewEdge);
    BB.UpdateEdge(anEdge, NewPCurve, aGS, aLoc, NewTol);
  }
#endif

  BRepBuilderAPI_MakeFace MK1 (aGS, theWire);
  if (MK1.IsDone()) {
    TopoDS_Shape aFace1 = MK1.Shape();

    BRepCheck_Analyzer ana (aFace1, false);
    if (!ana.IsValid()) {
      TopoDS_Shape aFace2;
      ShHealOper_ShapeProcess aHealer;
      aHealer.Perform(aFace1, aFace2);
      if (aHealer.isDone())
        theResult = aFace2;
    }
  }
  // 12.04.2006 for PAL12149 end

  if (theResult.IsNull()) { // try to deal with pure result of filling
    // Update tolerance
    Standard_Real aTol = MF.G0Error();

    TColgp_Array1OfPnt aPnts (1,nbEdges); // points of the given wire
    BRepTools_WireExplorer aWE1 (theWire);
    Standard_Integer vi = 1;
    for (; aWE1.More() && vi <= nbEdges; aWE1.Next(), vi++) {
      aPnts(vi) = BRep_Tool::Pnt(TopoDS::Vertex(aWE1.CurrentVertex()));
    }

    // Find maximum deviation in vertices
    TopExp_Explorer exp (aFace, TopAbs_VERTEX);
    TopTools_MapOfShape mapShape;
    for (; exp.More(); exp.Next()) {
      if (mapShape.Add(exp.Current())) {
        TopoDS_Vertex aV = TopoDS::Vertex(exp.Current());
        Standard_Real aTolV = BRep_Tool::Tolerance(aV);
        gp_Pnt aP = BRep_Tool::Pnt(aV);
        Standard_Real min_dist = aP.Distance(aPnts(1));
        for (vi = 2; vi <= nbEdges; vi++) {
          min_dist = Min(min_dist, aP.Distance(aPnts(vi)));
        }
        aTol = Max(aTol, aTolV);
        aTol = Max(aTol, min_dist);
      }
    }

    if ((*((Handle(BRep_TFace)*)&aFace.TShape()))->Tolerance() < aTol) {
      (*((Handle(BRep_TFace)*)&aFace.TShape()))->Tolerance(aTol);
    }
    theResult = aFace;
  }

  return aWarning;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TCollection_AsciiString GEOMImpl_Block6Explorer::MakeFace ( const TopoDS_Wire &  theWire,
const Standard_Boolean  isPlanarWanted,
TopoDS_Shape &  theResult 
) [static]

Build a face, bound by the given wire.

Parameters:
theWireThe initial wire to build the face on.
isPlanarWantedIf true, try to build a planar face.
Note:
If isPlanarWanted is true, but planar face cannot be built with acceptable tolerance, any face will be built.
Parameters:
theResultThe resulting shape.
Returns:
Error or warning description. Empty string in case of success.

Definition at line 1204 of file GEOMImpl_Block6Explorer.cxx.

{
  if (!isPlanarWanted)
    return MakeAnyFace(theWire, theResult);

  // Try to build a planar face.

  // If required tolerance increase will be
  // higher than PLANAR_FACE_MAX_TOLERANCE,
  // we will try to build a non-planar face.

  TCollection_AsciiString aWarning;

  // Workaround for Mantis issue 0020956

  // Count the number of points in the wire.
  // Collect the first three points.
  gp_Pnt p1, p2, p3;
  bool is3Pnts (false);
  bool p1set(false), p2set(false), p3set(false);
  BRepTools_WireExplorer wexpl (theWire);
  for (; wexpl.More(); wexpl.Next()) {
    if (!p1set) {
      p1set = true;
      p1 = BRep_Tool::Pnt(wexpl.CurrentVertex());
    }
    else if (!p2set) {
      p2set = true;
      p2 = BRep_Tool::Pnt(wexpl.CurrentVertex());
    }
    else if (!p3set) {
      p3set = true;
      is3Pnts = true;
      p3 = BRep_Tool::Pnt(wexpl.CurrentVertex());
    }
    else {
      is3Pnts = false;
      break;
    }
  }

  // Construct a plane for the case of three points in the wire.
  gp_Pln plane;
  if (is3Pnts) {
    gce_MakePln mkPln (p1, p2, p3);
    if (mkPln.IsDone()) {
      plane = mkPln.Value();
    }
    else {
      is3Pnts = false;
    }
  }

  // Construct a face based on the plane (in case of three points in the wire) or
  // allow MakeFace to build the plane itself (in case of the number of points is greater than 3).
  if (is3Pnts) {
    BRepBuilderAPI_MakeFace MK (plane, theWire, isPlanarWanted);
    if (MK.IsDone()) {
      theResult = MK.Shape();
      return aWarning;
    }
  }
  else {
    BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
    if (MK.IsDone()) {
      theResult = MK.Shape();
      return aWarning;
    }
  }

  // try to update wire tolerances to build a planar face

  // Find a deviation
  Standard_Real aToleranceReached, aTol;
  BRepLib_FindSurface aFS;
  aFS.Init(theWire, -1., isPlanarWanted);
  aToleranceReached = aFS.ToleranceReached();
  aTol = aFS.Tolerance();

  if (!aFS.Found()) {
    aFS.Init(theWire, aToleranceReached, isPlanarWanted);
    if (!aFS.Found()) return aWarning;
    aToleranceReached = aFS.ToleranceReached();
    aTol = aFS.Tolerance();
  }
  aTol = Max(1.2 * aToleranceReached, aTol);

  // Mantis issue 0021432: EDF GEOM: Faces with huge tolerance can be built in GEOM
  if (aTol > PLANAR_FACE_MAX_TOLERANCE) {
    aWarning = MakeAnyFace(theWire, theResult);
    if (aWarning.IsEmpty() && !theResult.IsNull())
      aWarning = "MAKE_FACE_TOLERANCE_TOO_BIG";
    return aWarning;
  }

  // Copy the wire, bacause it can be updated with very-very big tolerance here
  BRepBuilderAPI_Copy aMC (theWire);
  if (!aMC.IsDone()) return aWarning;
  TopoDS_Wire aWire = TopoDS::Wire(aMC.Shape());
  // Update tolerances to <aTol>
  BRep_Builder B;
  for (TopExp_Explorer expE (aWire, TopAbs_EDGE); expE.More(); expE.Next()) {
    TopoDS_Edge anE = TopoDS::Edge(expE.Current());
    B.UpdateEdge(anE, aTol);
  }
  for (TopExp_Explorer expV (aWire, TopAbs_VERTEX); expV.More(); expV.Next()) {
    TopoDS_Vertex aV = TopoDS::Vertex(expV.Current());
    B.UpdateVertex(aV, aTol);
  }
  //BRepLib::UpdateTolerances(aWire);
  // Build face
  BRepBuilderAPI_MakeFace MK1 (aWire, isPlanarWanted);
  if (MK1.IsDone()) {
    theResult = MK1.Shape();
    // Mantis issue 0021432: EDF GEOM: Faces with huge tolerance can be built in GEOM
    //if (aTol > PLANAR_FACE_MAX_TOLERANCE)
    //  aWarning = "MAKE_FACE_TOLERANCE_TOO_BIG";
  }

  return aWarning;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void GEOMImpl_Block6Explorer::MapShapesAndAncestors ( const TopoDS_Shape &  S,
const TopAbs_ShapeEnum  TS,
const TopAbs_ShapeEnum  TA,
TopTools_IndexedDataMapOfShapeListOfShape &  M 
) [static]

Definition at line 1070 of file GEOMImpl_Block6Explorer.cxx.

{
  TopTools_ListOfShape empty;
  TopTools_MapOfShape mapA;

  // visit ancestors
  TopExp_Explorer exa (S,TA);
  for (; exa.More(); exa.Next()) {
    // visit shapes
    const TopoDS_Shape& anc = exa.Current();
    if (mapA.Add(anc)) {
      TopExp_Explorer exs (anc,TS);
      TopTools_MapOfShape mapS;
      for (; exs.More(); exs.Next()) {
        if (mapS.Add(exs.Current())) {
          Standard_Integer index = M.FindIndex(exs.Current());
          if (index == 0) index = M.Add(exs.Current(),empty);
          M(index).Append(anc);
        }
      }
    }
  }

  // visit shapes not under ancestors
  TopExp_Explorer ex (S,TS,TA);
  for (; ex.More(); ex.Next()) {
    Standard_Integer index = M.FindIndex(ex.Current());
    if (index == 0) index = M.Add(ex.Current(),empty);
  }
}

Here is the caller graph for this function:


Member Data Documentation

TopTools_Array1OfShape GEOMImpl_Block6Explorer::myEdges [private]

Definition at line 244 of file GEOMImpl_Block6Explorer.hxx.

TopTools_Array1OfShape GEOMImpl_Block6Explorer::myFaces [private]

Definition at line 243 of file GEOMImpl_Block6Explorer.hxx.

TopTools_Array1OfShape GEOMImpl_Block6Explorer::myVertices [private]

Definition at line 245 of file GEOMImpl_Block6Explorer.hxx.


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