1 // Created on: 1999-10-25
2 // Created by: Sergey ZARITCHNY
3 // Copyright (c) 1999-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.
22 #include <QANewBRepNaming_LoaderParent.ixx>
24 #include <TNaming.hxx>
25 #include <TDF_Label.hxx>
26 #include <TNaming_Builder.hxx>
27 #include <TopLoc_Location.hxx>
28 #include <TopExp_Explorer.hxx>
29 #include <TopTools_MapOfShape.hxx>
30 #include <TopTools_DataMapOfShapeShape.hxx>
31 #include <TopTools_ListOfShape.hxx>
32 #include <TopTools_ListIteratorOfListOfShape.hxx>
33 #include <BRepBuilderAPI_MakeShape.hxx>
34 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
36 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
37 #include <TopoDS_Iterator.hxx>
38 #include <TopTools_MapIteratorOfMapOfShape.hxx>
39 #include <TDataStd_Name.hxx>
40 #include <TNaming_NamedShape.hxx>
43 //=======================================================================
44 //function : GetDangleShapes
45 //purpose : Returns dangle sub shapes Generator - Dangle.
46 //=======================================================================
48 Standard_Boolean QANewBRepNaming_LoaderParent::GetDangleShapes(const TopoDS_Shape& ShapeIn,
49 const TopAbs_ShapeEnum GeneratedFrom,
50 TopTools_DataMapOfShapeShape& Dangles)
53 TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
54 TopAbs_ShapeEnum GeneratedTo;
55 if (GeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
56 else if (GeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
57 else return Standard_False;
58 TopExp::MapShapesAndAncestors(ShapeIn, GeneratedTo, GeneratedFrom, subShapeAndAncestors);
59 for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
60 const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
61 const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
62 if (ancestors.Extent() == 1) Dangles.Bind(ancestors.First(), mayBeDangle);
64 return Dangles.Extent();
67 //=======================================================================
68 //function : GetDangleShapes
69 //purpose : Returns dangle sub shapes.
70 //=======================================================================
72 Standard_Boolean QANewBRepNaming_LoaderParent::GetDangleShapes(const TopoDS_Shape& ShapeIn,
73 const TopAbs_ShapeEnum GeneratedFrom,
74 TopTools_MapOfShape& Dangles)
77 TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
78 TopAbs_ShapeEnum GeneratedTo;
79 if (GeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
80 else if (GeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
81 else return Standard_False;
82 TopExp::MapShapesAndAncestors(ShapeIn, GeneratedTo, GeneratedFrom, subShapeAndAncestors);
83 for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
84 const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
85 const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
86 if (ancestors.Extent() == 1) Dangles.Add(mayBeDangle);
88 return Dangles.Extent();
91 //=======================================================================
92 //function : LoadGeneratedDangleShapes
94 //=======================================================================
96 void QANewBRepNaming_LoaderParent::LoadGeneratedDangleShapes(const TopoDS_Shape& ShapeIn,
97 const TopAbs_ShapeEnum GeneratedFrom,
98 TNaming_Builder& Builder)
100 TopTools_DataMapOfShapeShape dangles;
101 if (!QANewBRepNaming_LoaderParent::GetDangleShapes(ShapeIn, GeneratedFrom, dangles)) return;
102 TopTools_DataMapIteratorOfDataMapOfShapeShape itr(dangles);
103 for (; itr.More(); itr.Next()) Builder.Generated(itr.Key(), itr.Value());