0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / ChFi2d / ChFi2d.cxx
CommitLineData
b311480e 1// Created on: 1995-06-26
2// Created by: Philippe DERVIEUX
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <ChFi2d.hxx>
7fd59977 19#include <TopExp.hxx>
7fd59977 20#include <TopoDS.hxx>
42cf5bc1 21#include <TopoDS_Edge.hxx>
22#include <TopoDS_Face.hxx>
23#include <TopoDS_Vertex.hxx>
24#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
25#include <TopTools_ListIteratorOfListOfShape.hxx>
7fd59977 26
27//=======================================================================
28//function : CommonVertex
29//purpose :
30//=======================================================================
31Standard_Boolean ChFi2d::CommonVertex(const TopoDS_Edge& E1,
32 const TopoDS_Edge& E2,
33 TopoDS_Vertex& V)
34{
35 TopoDS_Vertex firstVertex1, lastVertex1, firstVertex2, lastVertex2;
36 TopExp::Vertices(E1, firstVertex1, lastVertex1);
37 TopExp::Vertices(E2, firstVertex2, lastVertex2);
38
39 if (firstVertex1.IsSame(firstVertex2) ||
40 firstVertex1.IsSame(lastVertex2)) {
41 V = firstVertex1;
42 return Standard_True;
43 }
44 if (lastVertex1.IsSame(firstVertex2) ||
45 lastVertex1.IsSame(lastVertex2)) {
46 V = lastVertex1;
47 return Standard_True;
48 }
49 return Standard_False;
50} // CommonVertex
51
52
53//=======================================================================
54//function : FindConnectedEdges
55//purpose :
56//=======================================================================
57
58ChFi2d_ConstructionError ChFi2d::FindConnectedEdges(const TopoDS_Face& F,
59 const TopoDS_Vertex& V,
60 TopoDS_Edge& E1,
61 TopoDS_Edge& E2)
62{
63 TopTools_IndexedDataMapOfShapeListOfShape vertexMap ;
64 TopExp::MapShapesAndAncestors (F, TopAbs_VERTEX,
65 TopAbs_EDGE, vertexMap);
66
67 if (vertexMap.Contains(V)) {
68 TopTools_ListIteratorOfListOfShape iterator(vertexMap.FindFromKey(V));
69 if (iterator.More()) {
70 E1 = TopoDS::Edge(iterator.Value());
71 iterator.Next();
72 } // if ...
73 else return ChFi2d_ConnexionError;
74 if (iterator.More()) {
75 E2 = TopoDS::Edge(iterator.Value());
76 iterator.Next();
77 } // if ...
78 else return ChFi2d_ConnexionError;
79
80 if(iterator.More()) return ChFi2d_ConnexionError;
81 } // if (isFind)
82 else return ChFi2d_ConnexionError;
83 return ChFi2d_IsDone;
84} // FindConnectedEdges