0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / QANewBRepNaming / QANewBRepNaming_LoaderParent.cxx
CommitLineData
b311480e 1// Created on: 1999-10-25
2// Created by: Sergey ZARITCHNY
3// Copyright (c) 1999-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
17#include <QANewBRepNaming_LoaderParent.ixx>
18
19#include <TNaming.hxx>
20#include <TDF_Label.hxx>
21#include <TNaming_Builder.hxx>
22#include <TopLoc_Location.hxx>
23#include <TopExp_Explorer.hxx>
24#include <TopTools_MapOfShape.hxx>
25#include <TopTools_DataMapOfShapeShape.hxx>
26#include <TopTools_ListOfShape.hxx>
27#include <TopTools_ListIteratorOfListOfShape.hxx>
28#include <BRepBuilderAPI_MakeShape.hxx>
29#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
30#include <TopExp.hxx>
31#include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
32#include <TopoDS_Iterator.hxx>
33#include <TopTools_MapIteratorOfMapOfShape.hxx>
34#include <TDataStd_Name.hxx>
35#include <TNaming_NamedShape.hxx>
36
37
38//=======================================================================
39//function : GetDangleShapes
40//purpose : Returns dangle sub shapes Generator - Dangle.
41//=======================================================================
42
43Standard_Boolean QANewBRepNaming_LoaderParent::GetDangleShapes(const TopoDS_Shape& ShapeIn,
44 const TopAbs_ShapeEnum GeneratedFrom,
45 TopTools_DataMapOfShapeShape& Dangles)
46{
47 Dangles.Clear();
48 TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
49 TopAbs_ShapeEnum GeneratedTo;
50 if (GeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
51 else if (GeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
52 else return Standard_False;
53 TopExp::MapShapesAndAncestors(ShapeIn, GeneratedTo, GeneratedFrom, subShapeAndAncestors);
54 for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
55 const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
56 const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
57 if (ancestors.Extent() == 1) Dangles.Bind(ancestors.First(), mayBeDangle);
58 }
59 return Dangles.Extent();
60}
61
62//=======================================================================
63//function : GetDangleShapes
64//purpose : Returns dangle sub shapes.
65//=======================================================================
66/*
67Standard_Boolean QANewBRepNaming_LoaderParent::GetDangleShapes(const TopoDS_Shape& ShapeIn,
68 const TopAbs_ShapeEnum GeneratedFrom,
69 TopTools_MapOfShape& Dangles)
70{
71 Dangles.Clear();
72 TopTools_IndexedDataMapOfShapeListOfShape subShapeAndAncestors;
73 TopAbs_ShapeEnum GeneratedTo;
74 if (GeneratedFrom == TopAbs_FACE) GeneratedTo = TopAbs_EDGE;
75 else if (GeneratedFrom == TopAbs_EDGE) GeneratedTo = TopAbs_VERTEX;
76 else return Standard_False;
77 TopExp::MapShapesAndAncestors(ShapeIn, GeneratedTo, GeneratedFrom, subShapeAndAncestors);
78 for (Standard_Integer i = 1; i <= subShapeAndAncestors.Extent(); i++) {
79 const TopoDS_Shape& mayBeDangle = subShapeAndAncestors.FindKey(i);
80 const TopTools_ListOfShape& ancestors = subShapeAndAncestors.FindFromIndex(i);
81 if (ancestors.Extent() == 1) Dangles.Add(mayBeDangle);
82 }
83 return Dangles.Extent();
84}
85*/
86//=======================================================================
87//function : LoadGeneratedDangleShapes
88//purpose :
89//=======================================================================
90
91void QANewBRepNaming_LoaderParent::LoadGeneratedDangleShapes(const TopoDS_Shape& ShapeIn,
92 const TopAbs_ShapeEnum GeneratedFrom,
93 TNaming_Builder& Builder)
94{
95 TopTools_DataMapOfShapeShape dangles;
96 if (!QANewBRepNaming_LoaderParent::GetDangleShapes(ShapeIn, GeneratedFrom, dangles)) return;
97 TopTools_DataMapIteratorOfDataMapOfShapeShape itr(dangles);
98 for (; itr.More(); itr.Next()) Builder.Generated(itr.Key(), itr.Value());
99}
100