0026586: Eliminate compile warnings obtained by building occt with vc14: declaration...
[occt.git] / src / XCAFDimTolObjects / XCAFDimTolObjects_Tool.cxx
CommitLineData
9ebaae37 1// Copyright (c) 1999-2014 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#include <XCAFDimTolObjects_Tool.hxx>
15#include <XCAFDimTolObjects_DimensionObjectSequence.hxx>
16#include <TDF_ChildIterator.hxx>
17#include <XCAFDoc_DimTolTool.hxx>
18#include <XCAFDoc_Dimension.hxx>
19#include <XCAFDimTolObjects_GeomToleranceObjectSequence.hxx>
20#include <XCAFDoc_GeomTolerance.hxx>
21#include <XCAFDimTolObjects_DatumObjectSequence.hxx>
22#include <XCAFDoc_Datum.hxx>
23#include <XCAFDoc_ShapeTool.hxx>
24#include <XCAFDoc_Datum.hxx>
25#include <TDF_Label.hxx>
26#include <TDF_LabelSequence.hxx>
27#include <XCAFDoc_DocumentTool.hxx>
28#include <TDocStd_Document.hxx>
29#include <NCollection_DataMap.hxx>
30#include <XCAFDimTolObjects_DataMapOfToleranceDatum.hxx>
31
32//=======================================================================
33//function : XCAFDimTolObjects_Tool
34//purpose :
35//=======================================================================
36
37XCAFDimTolObjects_Tool::XCAFDimTolObjects_Tool(const Handle(TDocStd_Document)& theDoc)
38{
39 myDimTolTool = XCAFDoc_DocumentTool::DimTolTool(theDoc->Main());
40}
41
42//=======================================================================
43//function : GetDimensions
44//purpose :
45//=======================================================================
46
47void XCAFDimTolObjects_Tool::GetDimensions(XCAFDimTolObjects_DimensionObjectSequence& theDimensionObjectSequence) const
48{
49 theDimensionObjectSequence.Clear();
50 TDF_ChildIterator aChildIterator( myDimTolTool->Label() );
51 for (; aChildIterator.More(); aChildIterator.Next()) {
52 TDF_Label aL = aChildIterator.Value();
53 Handle(XCAFDoc_Dimension) aDimension;
54 if(aL.FindAttribute(XCAFDoc_Dimension::GetID(),aDimension)) {
55 theDimensionObjectSequence.Append(aDimension->GetObject());
56 }
57 }
58}
59
60//=======================================================================
61//function : GetGeomTolerances
62//purpose :
63//=======================================================================
64
65void XCAFDimTolObjects_Tool::GetGeomTolerances(XCAFDimTolObjects_GeomToleranceObjectSequence& theGeomToleranceObjectSequence,
66 XCAFDimTolObjects_DatumObjectSequence& theDatumSequence,
67 XCAFDimTolObjects_DataMapOfToleranceDatum& theMap) const
68{
69 theGeomToleranceObjectSequence.Clear();
70 TDF_ChildIterator aChildIterator( myDimTolTool->Label() );
71 for (; aChildIterator.More(); aChildIterator.Next()) {
72 TDF_Label aL = aChildIterator.Value();
73 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
74 if(aL.FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGeomTolerance)) {
75 theGeomToleranceObjectSequence.Append(aGeomTolerance->GetObject());
76 TDF_LabelSequence aSeq;
77 if(myDimTolTool->GetDatumOfTolerLabels(aGeomTolerance->Label(), aSeq))
78 {
79 for(Standard_Integer i = 1; i <= aSeq.Length(); i++)
80 {
81 Handle(XCAFDoc_Datum) aDatum;
82 if(aSeq.Value(i).FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
83 {
84 theDatumSequence.Append(aDatum->GetObject());
85 theMap.Bind(theGeomToleranceObjectSequence.Last(), theDatumSequence.Last());
86 }
87 }
88 }
89 }
90 }
91}
92
93//=======================================================================
94//function : GetRefDimensions
95//purpose :
96//=======================================================================
97
98Standard_Boolean XCAFDimTolObjects_Tool::GetRefDimensions(const TopoDS_Shape& theShape,
99 XCAFDimTolObjects_DimensionObjectSequence& theDimensionObjectSequence) const
100{
101 theDimensionObjectSequence.Clear();
102 TDF_Label aShapeL;
103 myDimTolTool->ShapeTool()->Search(theShape, aShapeL);
104 if(!aShapeL.IsNull())
105 {
106 TDF_LabelSequence aSeq;
107 if( myDimTolTool->GetRefDimensionLabels(aShapeL, aSeq) ) {
108 for(Standard_Integer i = 1; i <= aSeq.Length(); i++)
109 {
110 Handle(XCAFDoc_Dimension) aDimension;
111 if( aSeq.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(),aDimension))
112 theDimensionObjectSequence.Append(aDimension->GetObject());
113 }
114 return Standard_True;
115 }
116 }
117 return Standard_False;
118}
119
120//=======================================================================
121//function : GetRefGeomTolerances
122//purpose :
123//=======================================================================
124
125Standard_Boolean XCAFDimTolObjects_Tool::GetRefGeomTolerances(const TopoDS_Shape& theShape,
126 XCAFDimTolObjects_GeomToleranceObjectSequence& theGeomToleranceObjectSequence,
127 XCAFDimTolObjects_DatumObjectSequence& theDatumSequence,
128 XCAFDimTolObjects_DataMapOfToleranceDatum& theMap) const
129{
130 theGeomToleranceObjectSequence.Clear();
131 TDF_Label aShapeL;
132 myDimTolTool->ShapeTool()->Search(theShape, aShapeL);
133 if(!aShapeL.IsNull())
134 {
135 TDF_LabelSequence aSeq;
136 if( myDimTolTool->GetRefGeomToleranceLabels(aShapeL, aSeq) ) {
137 for(Standard_Integer i = 1; i <= aSeq.Length(); i++)
138 {
139 Handle(XCAFDoc_GeomTolerance) aGeomTolerance;
140 if( aSeq.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGeomTolerance))
141 {
142 theGeomToleranceObjectSequence.Append(aGeomTolerance->GetObject());
51740958 143 TDF_LabelSequence aLocalSeq;
144 if(myDimTolTool->GetDatumOfTolerLabels(aGeomTolerance->Label(), aLocalSeq))
9ebaae37 145 {
51740958 146 for(Standard_Integer j = 1; j <= aLocalSeq.Length(); j++)
9ebaae37 147 {
148 Handle(XCAFDoc_Datum) aDatum;
51740958 149 if(aLocalSeq.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
9ebaae37 150 {
151 theDatumSequence.Append(aDatum->GetObject());
152 theMap.Bind(theGeomToleranceObjectSequence.Last(), theDatumSequence.Last());
153 }
154 }
155 }
156 }
157 }
158 return Standard_True;
159 }
160 }
161 return Standard_False;
162}
163
164//=======================================================================
165//function : GetRefDatum
166//purpose :
167//=======================================================================
168
169Standard_Boolean XCAFDimTolObjects_Tool::GetRefDatum(const TopoDS_Shape& theShape,
170 Handle(XCAFDimTolObjects_DatumObject)& theDatumObject) const
171{
172 TDF_Label aShapeL;
173 myDimTolTool->ShapeTool()->Search(theShape, aShapeL);
174 if(!aShapeL.IsNull())
175 {
176 TDF_Label aDatumL;
177 if(myDimTolTool->GetRefDatumLabel(aShapeL, aDatumL))
178 {
179 Handle(XCAFDoc_Datum) aDatum;
180 if( aDatumL.FindAttribute(XCAFDoc_Datum::GetID(),aDatum)){
181 theDatumObject = aDatum->GetObject();
182 return Standard_True;
183 }
184 }
185 }
186 return Standard_False;
187}