0024624: Lost word in license statement in source files
[occt.git] / src / ChFi2d / ChFi2d.cxx
1 // Created on: 1995-06-26
2 // Created by: Philippe DERVIEUX
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <ChFi2d.ixx>
18
19 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
20 #include <TopTools_ListIteratorOfListOfShape.hxx>
21 #include <TopExp.hxx>
22
23 #include <TopoDS.hxx>
24
25 //=======================================================================
26 //function : CommonVertex
27 //purpose  : 
28 //=======================================================================
29 Standard_Boolean ChFi2d::CommonVertex(const TopoDS_Edge& E1, 
30                                      const TopoDS_Edge& E2,
31                                      TopoDS_Vertex& V)
32 {
33   TopoDS_Vertex firstVertex1, lastVertex1, firstVertex2, lastVertex2;
34   TopExp::Vertices(E1, firstVertex1, lastVertex1);
35   TopExp::Vertices(E2, firstVertex2, lastVertex2);
36
37   if (firstVertex1.IsSame(firstVertex2) || 
38       firstVertex1.IsSame(lastVertex2)) {
39     V = firstVertex1;
40     return Standard_True;
41   }
42   if (lastVertex1.IsSame(firstVertex2) ||
43            lastVertex1.IsSame(lastVertex2)) {
44     V = lastVertex1;
45     return Standard_True;
46   }
47   return Standard_False;
48 } // CommonVertex
49
50
51 //=======================================================================
52 //function : FindConnectedEdges
53 //purpose  : 
54 //=======================================================================
55
56 ChFi2d_ConstructionError ChFi2d::FindConnectedEdges(const TopoDS_Face& F,
57                                                   const TopoDS_Vertex& V, 
58                                                   TopoDS_Edge& E1, 
59                                                   TopoDS_Edge& E2)
60 {
61   TopTools_IndexedDataMapOfShapeListOfShape  vertexMap ;
62   TopExp::MapShapesAndAncestors (F, TopAbs_VERTEX, 
63                                  TopAbs_EDGE, vertexMap);
64   
65   if (vertexMap.Contains(V)) {
66     TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(V));
67     if (iterator.More()) {
68       E1 = TopoDS::Edge(iterator.Value());
69       iterator.Next();
70     } // if ...
71     else  return ChFi2d_ConnexionError;
72     if (iterator.More()) {
73       E2 = TopoDS::Edge(iterator.Value());
74       iterator.Next();
75     } // if ...
76     else return ChFi2d_ConnexionError;
77     
78     if(iterator.More()) return ChFi2d_ConnexionError;
79   } // if (isFind)
80   else return ChFi2d_ConnexionError;
81   return ChFi2d_IsDone;
82 } // FindConnectedEdges