0022627: Change OCCT memory management defaults
[occt.git] / src / ChFi2d / ChFi2d.cxx
CommitLineData
7fd59977 1// File: ChFi2d.cxx
2// Created: Mon Jun 26 09:53:29 1995
3// Author: Philippe DERVIEUX
4// <phd@tlefon>
5
6
7#include <ChFi2d.ixx>
8
9#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
10#include <TopTools_ListIteratorOfListOfShape.hxx>
11#include <TopExp.hxx>
12
13#include <TopoDS.hxx>
14
15//=======================================================================
16//function : CommonVertex
17//purpose :
18//=======================================================================
19Standard_Boolean ChFi2d::CommonVertex(const TopoDS_Edge& E1,
20 const TopoDS_Edge& E2,
21 TopoDS_Vertex& V)
22{
23 TopoDS_Vertex firstVertex1, lastVertex1, firstVertex2, lastVertex2;
24 TopExp::Vertices(E1, firstVertex1, lastVertex1);
25 TopExp::Vertices(E2, firstVertex2, lastVertex2);
26
27 if (firstVertex1.IsSame(firstVertex2) ||
28 firstVertex1.IsSame(lastVertex2)) {
29 V = firstVertex1;
30 return Standard_True;
31 }
32 if (lastVertex1.IsSame(firstVertex2) ||
33 lastVertex1.IsSame(lastVertex2)) {
34 V = lastVertex1;
35 return Standard_True;
36 }
37 return Standard_False;
38} // CommonVertex
39
40
41//=======================================================================
42//function : FindConnectedEdges
43//purpose :
44//=======================================================================
45
46ChFi2d_ConstructionError ChFi2d::FindConnectedEdges(const TopoDS_Face& F,
47 const TopoDS_Vertex& V,
48 TopoDS_Edge& E1,
49 TopoDS_Edge& E2)
50{
51 TopTools_IndexedDataMapOfShapeListOfShape vertexMap ;
52 TopExp::MapShapesAndAncestors (F, TopAbs_VERTEX,
53 TopAbs_EDGE, vertexMap);
54
55 if (vertexMap.Contains(V)) {
56 TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(V));
57 if (iterator.More()) {
58 E1 = TopoDS::Edge(iterator.Value());
59 iterator.Next();
60 } // if ...
61 else return ChFi2d_ConnexionError;
62 if (iterator.More()) {
63 E2 = TopoDS::Edge(iterator.Value());
64 iterator.Next();
65 } // if ...
66 else return ChFi2d_ConnexionError;
67
68 if(iterator.More()) return ChFi2d_ConnexionError;
69 } // if (isFind)
70 else return ChFi2d_ConnexionError;
71 return ChFi2d_IsDone;
72} // FindConnectedEdges