1 // Created on: 1993-05-05
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <MAT_Zone.ixx>
24 #include <MAT_BasicElt.hxx>
25 #include <MAT_SequenceOfArc.hxx>
26 #include <MAT_Node.hxx>
28 //========================================================================
31 //========================================================================
35 //========================================================================
38 //========================================================================
39 MAT_Zone::MAT_Zone(const Handle(MAT_BasicElt)& aBasicElt)
44 //========================================================================
47 //========================================================================
48 void MAT_Zone::Perform (const Handle(MAT_BasicElt)& aBasicElt)
50 Handle (MAT_Node) NextNode, StartNode;
51 Handle (MAT_Arc) CurrentArc;
53 limited = Standard_True;
55 // ------------------------------------------------------------------------
56 // Si le premier arc correspondant a la zone est Null => Sequence vide.
57 // ------------------------------------------------------------------------
58 if (aBasicElt->EndArc().IsNull()) return;
60 // ----------------------------
61 // Angle rentrant => Zone Vide.
62 // ----------------------------
63 // if(aBasicElt->EndArc() == aBasicElt->StartArc()) return;
65 // --------------------------------
66 // Initialisation de la frontier.
67 // --------------------------------
68 CurrentArc = aBasicElt->EndArc();
69 frontier.Append(CurrentArc);
71 // --------------------------------------------------------------------------
72 // Determination du premier noeud qui permet de construire la zone en tournant
74 // --------------------------------------------------------------------------
75 NextNode = NodeForTurn(CurrentArc,aBasicElt,MAT_Left);
76 StartNode = CurrentArc->TheOtherNode(NextNode);
78 // -------------------------------------------------------------------------
79 // Exploration du Graph toujours sur les arcs voisins a gauche jusqu'a
80 // - retour sur la Figure .
81 // - l acces a un noeud infini .
82 // (Ces deux cas correspondent a des noeuds pendants.)
83 // - retour sur l arc de depart si le basicElt est ferme.
84 // -------------------------------------------------------------------------
86 while (!NextNode->PendingNode() && (NextNode != StartNode)) {
87 CurrentArc = CurrentArc->Neighbour(NextNode,MAT_Left);
88 frontier.Append(CurrentArc);
89 NextNode = CurrentArc->TheOtherNode(NextNode);
92 // -----------------------------------------------------------------------
93 // Si NextNode est a l infini : exploration du graph a partir du StartArc
95 // exploration sur les arcs voisins a droite.
97 // -----------------------------------------------------------------------
99 if (NextNode->Infinite()) {
100 limited = Standard_False;
101 CurrentArc = aBasicElt->StartArc();
102 frontier.Append(CurrentArc);
103 // --------------------------------------------------------------------------
104 // Determination du premier noeud qui permet de construire la zone en
105 //tournan surla droite.
106 // --------------------------------------------------------------------------
107 NextNode = NodeForTurn(CurrentArc,aBasicElt,MAT_Right);
109 // -----------------------------------------------------
110 // Cette branche est aussi terminee par un noeud infini.
111 // -----------------------------------------------------
112 while (!NextNode->Infinite()) {
113 CurrentArc = CurrentArc->Neighbour(NextNode,MAT_Right);
114 frontier.Append(CurrentArc);
115 NextNode = CurrentArc->TheOtherNode(NextNode);
120 //========================================================================
121 // function: NumberOfArcs
123 //========================================================================
124 Standard_Integer MAT_Zone::NumberOfArcs()const
126 return frontier.Length();
129 //========================================================================
130 // function: ArcOnFrontier
132 //========================================================================
133 Handle(MAT_Arc) MAT_Zone::ArcOnFrontier(const Standard_Integer Index)const
135 return frontier.Value(Index);
138 //========================================================================
139 // function: NoEmptyZone
141 //========================================================================
142 Standard_Boolean MAT_Zone::NoEmptyZone()const
144 return (!frontier.IsEmpty());
147 //========================================================================
150 //========================================================================
151 Standard_Boolean MAT_Zone::Limited()const
156 //========================================================================
159 //========================================================================
160 Handle(MAT_Node) MAT_Zone::NodeForTurn (const Handle(MAT_Arc)& anArc,
161 const Handle(MAT_BasicElt)& aBE,
162 const MAT_Side aSide)
165 Handle(MAT_Arc) NeighbourArc;
166 Handle(MAT_Node) NodeSol ;
168 NodeSol = anArc->FirstNode();
169 NeighbourArc = anArc->Neighbour(NodeSol,aSide);
170 if (NeighbourArc.IsNull()) {
171 NodeSol = anArc->SecondNode();
172 NeighbourArc = anArc->Neighbour(NodeSol,aSide);
174 if (NeighbourArc.IsNull()) {
177 if (NeighbourArc->FirstElement() == aBE) {
180 else if (NeighbourArc->SecondElement() == aBE) {
184 return anArc->TheOtherNode(NodeSol);