1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-08 14:17:06 +03:00

0026689: Necessary to improve STEPCAFControl_Reader to read GD&T data from STEP model(AP242).

Small corrections
added tests, corrected remarks
corrected remarks
Fix compilation errors.
Update test case (direction can be exist only for Oriented dimension).
fix compilation warning
This commit is contained in:
ink
2015-09-15 14:58:17 +03:00
committed by bugmaster
parent 82f443b628
commit 1c9d32256d
43 changed files with 4211 additions and 456 deletions

View File

@@ -94,12 +94,23 @@ Standard_GUID XCAFDoc::DimTolRefGUID()
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DimensionRefGUID()
Standard_GUID XCAFDoc::DimensionRefFirstGUID()
{
static Standard_GUID ID("efd212e3-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
//=======================================================================
//function : DimensionRefGUID
//purpose :
//=======================================================================
Standard_GUID XCAFDoc::DimensionRefSecondGUID()
{
static Standard_GUID ID("efd212e0-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
//=======================================================================
//function : GeomToleranceRefGUID
//purpose :

View File

@@ -78,7 +78,10 @@ public:
Standard_EXPORT static Standard_GUID DimTolRefGUID();
//! Return GUIDs for TreeNode representing specified types of Dimension
Standard_EXPORT static Standard_GUID DimensionRefGUID() ;
Standard_EXPORT static Standard_GUID DimensionRefFirstGUID() ;
//! Return GUIDs for TreeNode representing specified types of Dimension
Standard_EXPORT static Standard_GUID DimensionRefSecondGUID() ;
//! Return GUIDs for TreeNode representing specified types of GeomTolerance
Standard_EXPORT static Standard_GUID GeomToleranceRefGUID() ;

View File

@@ -17,10 +17,12 @@
#include <TCollection_HAsciiString.hxx>
#include <TDF_Attribute.hxx>
#include <TDF_Label.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDF_RelocationTable.hxx>
#include <XCAFDoc_Datum.hxx>
#include <TDataStd_AsciiString.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TNaming_NamedShape.hxx>
@@ -34,7 +36,14 @@ enum ChildLab
ChildLab_Name = 1,
ChildLab_Modifiers,
ChildLab_ModifierWithValue,
ChildLab_DatumTarget
ChildLab_IsDTarget,
ChildLab_DTargetType,
ChildLab_AxisLoc,
ChildLab_AxisN,
ChildLab_AxisRef,
ChildLab_DTargetLength,
ChildLab_DTargetWidth,
ChildLab_DatumTarget,
};
//=======================================================================
@@ -152,7 +161,12 @@ Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetIdentification() const
void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theObject)
{
Backup();
if (!theObject->GetName().IsNull())
TDF_ChildIterator anIter(Label());
for(;anIter.More(); anIter.Next())
{
anIter.Value().ForgetAllAttributes();
}
if (!theObject->GetName().IsNull() && !theObject->GetName()->IsEmpty())
{
Handle(TDataStd_AsciiString) anAttName;
if(!Label().FindChild(ChildLab_Name).FindAttribute(TDataStd_AsciiString::GetID(), anAttName))
@@ -162,16 +176,8 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
}
anAttName->Set(theObject->GetName()->String());
}
else
{
Label().FindChild(ChildLab_Name).ForgetAllAttributes();
}
if(theObject->GetModifiers().Length() == 0)
{
Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
}
else
if(theObject->GetModifiers().Length() > 0)
{
Handle(TDataStd_IntegerArray) aModifiers;
if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers))
@@ -205,19 +211,60 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
aModifierWithValueM->Set(aM);
aModifierWithValueV->Set(aV);
}
else
{
Label().FindChild(ChildLab_ModifierWithValue).ForgetAllAttributes();
}
if(!theObject->GetDatumTarget().IsNull())
Handle(TDataStd_Integer) aIsTarget = new TDataStd_Integer();
aIsTarget->Set(theObject->IsDatumTarget());
Label().FindChild(ChildLab_IsDTarget).AddAttribute(aIsTarget);
if(theObject->IsDatumTarget())
{
TNaming_Builder tnBuild(Label().FindChild(ChildLab_DatumTarget));
tnBuild.Generated(theObject->GetDatumTarget());
}
else
{
Label().FindChild(ChildLab_DatumTarget).ForgetAllAttributes();
Handle(TDataStd_Integer) aType = new TDataStd_Integer();
aType->Set(theObject->GetDatumTargetType());
Label().FindChild(ChildLab_DTargetType).AddAttribute(aType);
if(theObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area)
{
if(!theObject->GetDatumTarget().IsNull())
{
TNaming_Builder tnBuild(Label().FindChild(ChildLab_DatumTarget));
tnBuild.Generated(theObject->GetDatumTarget());
}
}
else
{
Handle(TDataStd_RealArray) aLoc = new TDataStd_RealArray();
Handle(TDataStd_RealArray) aN = new TDataStd_RealArray();
Handle(TDataStd_RealArray) aR = new TDataStd_RealArray();
gp_Ax2 anAx = theObject->GetDatumTargetAxis();
aLoc->SetValue(aLoc->Upper(),anAx.Location().X());
aLoc->SetValue(aLoc->Upper()+1,anAx.Location().Y());
aLoc->SetValue(aLoc->Upper()+2,anAx.Location().Z());
aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
aR->SetValue(aR->Upper(),anAx.Direction().X());
aR->SetValue(aR->Upper(),anAx.Direction().X());
aR->SetValue(aR->Upper(),anAx.Direction().X());
Label().FindChild(ChildLab_AxisLoc).AddAttribute(aLoc);
Label().FindChild(ChildLab_AxisN).AddAttribute(aN);
Label().FindChild(ChildLab_AxisRef).AddAttribute(aR);
if(theObject->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
{
Handle(TDataStd_Real) aLen = new TDataStd_Real();
aLen->Set(theObject->GetDatumTargetLength());
Label().FindChild(ChildLab_DTargetLength).AddAttribute(aLen);
if(theObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
{
Handle(TDataStd_Real) aWidth = new TDataStd_Real();
aWidth->Set(theObject->GetDatumTargetWidth());
Label().FindChild(ChildLab_DTargetWidth).AddAttribute(aWidth);
}
}
}
}
}
@@ -257,10 +304,64 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
}
}
Handle(TNaming_NamedShape) aDatumTarget;
if(Label().FindChild(ChildLab_DatumTarget).FindAttribute(TNaming_NamedShape::GetID(), aDatumTarget))
Handle(TDataStd_Integer) aIsDTarget;
if(Label().FindChild(ChildLab_IsDTarget).FindAttribute(TDataStd_Integer::GetID(), aIsDTarget))
{
anObj->SetDatumTarget(aDatumTarget->Get());
anObj->IsDatumTarget((aIsDTarget->Get() != 0));
}
else
{
return anObj;
}
if (aIsDTarget->Get() != 0)
{
Handle(TDataStd_Integer) aDTargetType;
if(Label().FindChild(ChildLab_DTargetType).FindAttribute(TDataStd_Integer::GetID(), aDTargetType))
{
anObj->SetDatumTargetType((XCAFDimTolObjects_DatumTargetType)aDTargetType->Get());
if(anObj->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area)
{
Handle(TNaming_NamedShape) aDatumTarget;
if(Label().FindChild(ChildLab_DatumTarget).FindAttribute(TNaming_NamedShape::GetID(), aDatumTarget))
{
anObj->SetDatumTarget(aDatumTarget->Get());
}
}
else
{
Handle(TDataStd_RealArray) aLoc;
Handle(TDataStd_RealArray) aN;
Handle(TDataStd_RealArray) aR;
if(Label().FindChild(ChildLab_AxisLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
Label().FindChild(ChildLab_AxisN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
Label().FindChild(ChildLab_AxisRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3 )
{
gp_Pnt aL(aLoc->Value(aLoc->Upper()), aLoc->Value(aLoc->Upper()+1), aLoc->Value(aLoc->Upper()+2));
gp_Dir aD(aN->Value(aN->Upper()), aN->Value(aN->Upper()+1), aN->Value(aN->Upper()+2));
gp_Dir aDR(aR->Value(aR->Upper()), aR->Value(aR->Upper()+1), aR->Value(aR->Upper()+2));
gp_Ax2 anAx(aL, aD, aDR);
anObj->SetDatumTargetAxis(anAx);
}
if(anObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
{
Handle(TDataStd_Real) aLen;
if(Label().FindChild(ChildLab_DTargetLength).FindAttribute(TDataStd_Integer::GetID(), aLen))
{
anObj->SetDatumTargetLength(aLen->Get());
}
if(anObj->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
{
Handle(TDataStd_Real) aWidth;
if(Label().FindChild(ChildLab_DTargetWidth).FindAttribute(TDataStd_Integer::GetID(), aWidth))
{
anObj->SetDatumTargetWidth(aWidth->Get());
}
}
}
}
}
}
return anObj;

View File

@@ -314,43 +314,79 @@ void XCAFDoc_DimTolTool::SetDimension(const TDF_Label& theFirstL,
const TDF_Label& theSecondL,
const TDF_Label& theDimTolL) const
{
Handle(XCAFDoc_GraphNode) aChGNode;
Handle(XCAFDoc_GraphNode) aFGNode;
Handle(XCAFDoc_GraphNode) aSecondFGNode;
TDF_LabelSequence aFirstLS, aSecondLS;
if(!theFirstL.IsNull())
aFirstLS.Append(theFirstL);
if(!theSecondL.IsNull())
aSecondLS.Append(theSecondL);
SetDimension(aFirstLS, aSecondLS, theDimTolL);
}
//Handle(XCAFDoc_GraphNode) ChGNode, FGNode;
if ( theDimTolL.FindAttribute (XCAFDoc::DimensionRefGUID(), aChGNode) ) {
while (aChGNode->NbFathers() > 0) {
aFGNode = aChGNode->GetFather(1);
aFGNode->UnSetChild(aChGNode);
}
theDimTolL.ForgetAttribute ( XCAFDoc::DimTolRefGUID() );
}
//=======================================================================
//function : SetDimension
//purpose :
//=======================================================================
if(!IsDimension(theDimTolL))
void XCAFDoc_DimTolTool::SetDimension(const TDF_LabelSequence& theFirstL,
const TDF_LabelSequence& theSecondL,
const TDF_Label& theDimTolL) const
{
if(!IsDimension(theDimTolL) || theFirstL.Length() == 0)
{
return;
}
if (!theDimTolL.FindAttribute(XCAFDoc::DimensionRefGUID(), aChGNode) ) {
Handle(XCAFDoc_GraphNode) aChGNode;
Handle(XCAFDoc_GraphNode) aFGNode;
Handle(XCAFDoc_GraphNode) aSecondFGNode;
if ( theDimTolL.FindAttribute (XCAFDoc::DimensionRefFirstGUID(), aChGNode) ) {
while (aChGNode->NbFathers() > 0) {
aFGNode = aChGNode->GetFather(1);
aFGNode->UnSetChild(aChGNode);
if(aFGNode->NbChildren() == 0)
aFGNode->ForgetAttribute( XCAFDoc::DimensionRefFirstGUID() );
}
theDimTolL.ForgetAttribute ( XCAFDoc::DimensionRefFirstGUID() );
}
if ( theDimTolL.FindAttribute (XCAFDoc::DimensionRefSecondGUID(), aChGNode) ) {
while (aChGNode->NbFathers() > 0) {
aFGNode = aChGNode->GetFather(1);
aFGNode->UnSetChild(aChGNode);
if(aFGNode->NbChildren() == 0)
aFGNode->ForgetAttribute( XCAFDoc::DimensionRefSecondGUID() );
}
theDimTolL.ForgetAttribute ( XCAFDoc::DimensionRefSecondGUID() );
}
if (!theDimTolL.FindAttribute(XCAFDoc::DimensionRefFirstGUID(), aChGNode)) {
aChGNode = new XCAFDoc_GraphNode;
aChGNode = XCAFDoc_GraphNode::Set(theDimTolL);
aChGNode->SetGraphID(XCAFDoc::DimensionRefFirstGUID());
}
if (!theFirstL.FindAttribute(XCAFDoc::DimensionRefGUID(), aFGNode) ) {
aFGNode = new XCAFDoc_GraphNode;
aFGNode = XCAFDoc_GraphNode::Set(theFirstL);
}
aFGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
aChGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
aFGNode->SetChild(aChGNode);
aChGNode->SetFather(aFGNode);
if (!theSecondL.IsNull()){
if(!theSecondL.FindAttribute(XCAFDoc::DimensionRefGUID(), aSecondFGNode) ) {
aSecondFGNode = new XCAFDoc_GraphNode;
aSecondFGNode = XCAFDoc_GraphNode::Set(theSecondL);
for(Standard_Integer i = theFirstL.Lower(); i <= theFirstL.Upper(); i++)
{
if (!theFirstL.Value(i).FindAttribute(XCAFDoc::DimensionRefFirstGUID(), aFGNode) ) {
aFGNode = new XCAFDoc_GraphNode;
aFGNode = XCAFDoc_GraphNode::Set(theFirstL.Value(i));
}
aSecondFGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
aFGNode->SetGraphID(XCAFDoc::DimensionRefFirstGUID());
aFGNode->SetChild(aChGNode);
aChGNode->SetFather(aFGNode);
}
if (!theDimTolL.FindAttribute(XCAFDoc::DimensionRefSecondGUID(), aChGNode) && theSecondL.Length() > 0) {
aChGNode = new XCAFDoc_GraphNode;
aChGNode = XCAFDoc_GraphNode::Set(theDimTolL);
aChGNode->SetGraphID(XCAFDoc::DimensionRefSecondGUID());
}
for(Standard_Integer i = theSecondL.Lower(); i <= theSecondL.Upper(); i++)
{
if(!theSecondL.Value(i).FindAttribute(XCAFDoc::DimensionRefSecondGUID(), aSecondFGNode) ) {
aSecondFGNode = new XCAFDoc_GraphNode;
aSecondFGNode = XCAFDoc_GraphNode::Set(theSecondL.Value(i));
}
aSecondFGNode->SetGraphID(XCAFDoc::DimensionRefSecondGUID());
aSecondFGNode->SetChild(aChGNode);
aChGNode->SetFather(aSecondFGNode);
}
@@ -364,12 +400,60 @@ void XCAFDoc_DimTolTool::SetDimension(const TDF_Label& theFirstL,
void XCAFDoc_DimTolTool::SetGeomTolerance(const TDF_Label& theL,
const TDF_Label& theDimTolL) const
{
// set reference
Handle(TDataStd_TreeNode) refNode, mainNode;
refNode = TDataStd_TreeNode::Set ( theDimTolL, XCAFDoc::GeomToleranceRefGUID() );
mainNode = TDataStd_TreeNode::Set ( theL, XCAFDoc::GeomToleranceRefGUID() );
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
mainNode->Append(refNode);
TDF_LabelSequence aSeq;
aSeq.Append(theL);
SetGeomTolerance(aSeq, theDimTolL);
}
//=======================================================================
//function : SetGeomTolerance
//purpose :
//=======================================================================
void XCAFDoc_DimTolTool::SetGeomTolerance(const TDF_LabelSequence& theL,
const TDF_Label& theDimTolL) const
{
// // set reference
// Handle(TDataStd_TreeNode) refNode, mainNode;
// refNode = TDataStd_TreeNode::Set ( theDimTolL, XCAFDoc::GeomToleranceRefGUID() );
// mainNode = TDataStd_TreeNode::Set ( theL, XCAFDoc::GeomToleranceRefGUID() );
// refNode->Remove(); // abv: fix against bug in TreeNode::Append()
// mainNode->Append(refNode);
if(!IsGeomTolerance(theDimTolL) || theL.Length() == 0)
{
return;
}
Handle(XCAFDoc_GraphNode) aChGNode;
Handle(XCAFDoc_GraphNode) aFGNode;
//Handle(XCAFDoc_GraphNode) ChGNode, FGNode;
if ( theDimTolL.FindAttribute (XCAFDoc::GeomToleranceRefGUID(), aChGNode) ) {
while (aChGNode->NbFathers() > 0) {
aFGNode = aChGNode->GetFather(1);
aFGNode->UnSetChild(aChGNode);
if(aFGNode->NbChildren() == 0)
aFGNode->ForgetAttribute( XCAFDoc::GeomToleranceRefGUID() );
}
theDimTolL.ForgetAttribute ( XCAFDoc::GeomToleranceRefGUID() );
}
if (!theDimTolL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(), aChGNode)) {
aChGNode = new XCAFDoc_GraphNode;
aChGNode = XCAFDoc_GraphNode::Set(theDimTolL);
aChGNode->SetGraphID(XCAFDoc::GeomToleranceRefGUID());
}
for(Standard_Integer i = theL.Lower(); i <= theL.Upper(); i++)
{
if (!theL.Value(i).FindAttribute(XCAFDoc::GeomToleranceRefGUID(), aFGNode) ) {
aFGNode = new XCAFDoc_GraphNode;
aFGNode = XCAFDoc_GraphNode::Set(theL.Value(i));
}
aFGNode->SetGraphID(XCAFDoc::GeomToleranceRefGUID());
aFGNode->SetChild(aChGNode);
aChGNode->SetFather(aFGNode);
}
}
//=======================================================================
@@ -412,26 +496,43 @@ TDF_Label XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& L,
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetRefShapeLabel(const TDF_Label& theL,
TDF_LabelSequence& theShapeL) const
TDF_LabelSequence& theShapeLFirst,
TDF_LabelSequence& theShapeLSecond) const
{
theShapeL.Clear();
theShapeLFirst.Clear();
theShapeLSecond.Clear();
Handle(TDataStd_TreeNode) aNode;
if( !theL.FindAttribute(XCAFDoc::DimTolRefGUID(),aNode) || !aNode->HasFather() ) {
if( !theL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) || !aNode->HasFather() ) {
if( !theL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aNode) || !aNode->HasFather() ) {
Handle(XCAFDoc_GraphNode) aGNode;
if( theL.FindAttribute(XCAFDoc::DimensionRefGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
Handle(XCAFDoc_GraphNode) aGNode;
if( theL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
{
theShapeLFirst.Append(aGNode->GetFather(i)->Label());
}
return Standard_True;
}
else if( theL.FindAttribute(XCAFDoc::DimensionRefFirstGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
{
theShapeLFirst.Append(aGNode->GetFather(i)->Label());
}
if( theL.FindAttribute(XCAFDoc::DimensionRefSecondGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
{
theShapeL.Append(aGNode->GetFather(i)->Label());
theShapeLSecond.Append(aGNode->GetFather(i)->Label());
}
return Standard_True;
}
return Standard_True;
}
else
{
return Standard_False;
}
}
}
theShapeL.Append(aNode->Father()->Label());
theShapeLFirst.Append(aNode->Father()->Label());
return Standard_True;
}
@@ -444,14 +545,22 @@ Standard_Boolean XCAFDoc_DimTolTool::GetRefDimensionLabels(const TDF_Label& theS
TDF_LabelSequence& theDimTols) const
{
Handle(XCAFDoc_GraphNode) aGNode;
if( theShapeL.FindAttribute(XCAFDoc::DimensionRefGUID(),aGNode) && aGNode->NbChildren() > 0 ) {
Standard_Boolean aResult = Standard_False;
if( theShapeL.FindAttribute(XCAFDoc::DimensionRefFirstGUID(),aGNode) && aGNode->NbChildren() > 0 ) {
for(Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
{
theDimTols.Append(aGNode->GetChild(i)->Label());
}
return Standard_True;
aResult = Standard_True;
}
return Standard_False;
if( theShapeL.FindAttribute(XCAFDoc::DimensionRefSecondGUID(),aGNode) && aGNode->NbChildren() > 0 ) {
for(Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
{
theDimTols.Append(aGNode->GetChild(i)->Label());
}
aResult = Standard_True;
}
return aResult;
}
//=======================================================================
@@ -462,16 +571,14 @@ Standard_Boolean XCAFDoc_DimTolTool::GetRefDimensionLabels(const TDF_Label& theS
Standard_Boolean XCAFDoc_DimTolTool::GetRefGeomToleranceLabels(const TDF_Label& theShapeL,
TDF_LabelSequence& theDimTols) const
{
Handle(TDataStd_TreeNode) aNode;
if( !theShapeL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aNode) ||
!aNode->HasFirst() ) {
Handle(XCAFDoc_GraphNode) aGNode;
if( !theShapeL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aGNode) ||
aGNode->NbChildren() == 0 ) {
return Standard_False;
}
Handle(TDataStd_TreeNode) aLast = aNode->First();
theDimTols.Append(aLast->Label());
while(aLast->HasNext()) {
aLast = aLast->Next();
theDimTols.Append(aLast->Label());
for(Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
{
theDimTols.Append(aGNode->GetChild(i)->Label());
}
return Standard_True;
}
@@ -482,15 +589,20 @@ Standard_Boolean XCAFDoc_DimTolTool::GetRefGeomToleranceLabels(const TDF_Label&
//=======================================================================
Standard_Boolean XCAFDoc_DimTolTool::GetRefDatumLabel(const TDF_Label& theShapeL,
TDF_Label& theDatum) const
TDF_LabelSequence& theDatum) const
{
Handle(TDataStd_TreeNode) aNode;
if( !theShapeL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) ||
!aNode->HasFirst() ) {
return Standard_False;
}
Handle(TDataStd_TreeNode) aLast = aNode->First();
theDatum = aLast->Label();
Handle(TDataStd_TreeNode) aFirst = aNode->First();
theDatum.Append(aFirst->Label());
for(Standard_Integer i = 1; i < aNode->NbChildren(); i++)
{
aFirst = aFirst->Next();
theDatum.Append(aFirst->Label());
}
return Standard_True;
}

View File

@@ -68,6 +68,9 @@ public:
//! in the DGTtable
Standard_EXPORT void GetDimensionLabels (TDF_LabelSequence& theLabels) const;
//! Sets a link with GUID
Standard_EXPORT void SetDimension (const TDF_LabelSequence& theFirstLS, const TDF_LabelSequence& theSecondLS, const TDF_Label& theDimTolL) const;
//! Sets a link with GUID
Standard_EXPORT void SetDimension (const TDF_Label& theFirstL, const TDF_Label& theSecondL, const TDF_Label& theDimTolL) const;
@@ -90,6 +93,9 @@ public:
//! Sets a link with GUID
Standard_EXPORT void SetGeomTolerance (const TDF_Label& theL, const TDF_Label& theDimTolL) const;
//! Sets a link with GUID
Standard_EXPORT void SetGeomTolerance (const TDF_LabelSequence& theL, const TDF_Label& theDimTolL) const;
//! Returns all GeomTolerance labels defined for label ShapeL
Standard_EXPORT Standard_Boolean GetRefGeomToleranceLabels (const TDF_Label& theShapeL, TDF_LabelSequence& theDimTols) const;
@@ -126,7 +132,7 @@ public:
//! Returns ShapeL defined for label DimTolL
//! Returns False if the DimTolL is not in DGTtable
Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& DimTolL, TDF_LabelSequence& ShapeL) const;
Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& DimTolL, TDF_LabelSequence& ShapeLFirst, TDF_LabelSequence& ShapeLSecond) const;
//! Returns all DimTol labels defined for label ShapeL
Standard_EXPORT Standard_Boolean GetRefDGTLabels (const TDF_Label& ShapeL, TDF_LabelSequence& DimTols) const;
@@ -175,7 +181,7 @@ public:
Standard_EXPORT Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL, TDF_LabelSequence& theTols) const;
//! Returns Datum label defined for label ShapeL
Standard_EXPORT Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, TDF_Label& theDatum) const;
Standard_EXPORT Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, TDF_LabelSequence& theDatum) const;
Standard_EXPORT const Standard_GUID& ID() const;

View File

@@ -14,6 +14,7 @@
#include <XCAFDoc_Dimension.hxx>
#include <TDF_RelocationTable.hxx>
#include <TDF_ChildIterator.hxx>
#include <XCAFDoc.hxx>
#include <TDataStd_TreeNode.hxx>
#include <Precision.hxx>
@@ -86,78 +87,59 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
{
Backup();
Handle(TDataStd_Integer) aType;
if(!Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
//Label().ForForgetAllAttributes();
TDF_ChildIterator anIter(Label());
for(;anIter.More(); anIter.Next())
{
aType = new TDataStd_Integer();
Label().FindChild(ChildLab_Type).AddAttribute(aType);
anIter.Value().ForgetAllAttributes();
}
Handle(TDataStd_Integer) aType = new TDataStd_Integer();
Label().FindChild(ChildLab_Type).AddAttribute(aType);
aType->Set(theObject->GetType());
if(theObject->GetValues().IsNull())
if(!theObject->GetValues().IsNull())
{
Label().FindChild(ChildLab_Value).ForgetAllAttributes();
}
else
{
Handle(TDataStd_RealArray) aVal;
if(!Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_RealArray::GetID(), aVal))
{
aVal = new TDataStd_RealArray();
Label().FindChild(ChildLab_Value).AddAttribute(aVal);
}
Handle(TDataStd_RealArray) aVal = new TDataStd_RealArray();
Label().FindChild(ChildLab_Value).AddAttribute(aVal);
aVal->ChangeArray(theObject->GetValues());
}
Handle(TDataStd_Integer) aQualifier;
if(!Label().FindChild(ChildLab_Qualifier).FindAttribute(TDataStd_Integer::GetID(), aQualifier))
{
aQualifier = new TDataStd_Integer();
Label().FindChild(ChildLab_Qualifier).AddAttribute(aQualifier);
}
Handle(TDataStd_Integer) aQualifier = new TDataStd_Integer();
Label().FindChild(ChildLab_Qualifier).AddAttribute(aQualifier);
aQualifier->Set(theObject->GetQualifier());
Standard_Boolean aH;
XCAFDimTolObjects_DimensionFormVariance aF;
XCAFDimTolObjects_DimensionGrade aG;
theObject->GetClassOfTolerance(aH,aF,aG);
Handle(TDataStd_IntegerArray) aClass;
if(!Label().FindChild(ChildLab_Class).FindAttribute(TDataStd_IntegerArray::GetID(), aClass))
Handle(TColStd_HArray1OfInteger) anArrI;
if(aF != XCAFDimTolObjects_DimensionFormVariance_None)
{
aClass = new TDataStd_IntegerArray();
Handle(TDataStd_IntegerArray) aClass = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Class).AddAttribute(aClass);
anArrI = new TColStd_HArray1OfInteger(1,3);
anArrI->SetValue(1,aH);
anArrI->SetValue(2,aF);
anArrI->SetValue(3,aG);
aClass->ChangeArray(anArrI);
}
Handle(TColStd_HArray1OfInteger) anArrI = new TColStd_HArray1OfInteger(1,3);
anArrI->SetValue(1,aH);
anArrI->SetValue(2,aF);
anArrI->SetValue(3,aG);
aClass->ChangeArray(anArrI);
Standard_Integer aL, aR;
theObject->GetNbOfDecimalPlaces(aL, aR);
Handle(TDataStd_IntegerArray) aDec;
if(!Label().FindChild(ChildLab_Dec).FindAttribute(TDataStd_IntegerArray::GetID(), aDec))
if (aL > 0 || aR > 0)
{
aDec = new TDataStd_IntegerArray();
Handle(TDataStd_IntegerArray) aDec = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Dec).AddAttribute(aDec);
anArrI = new TColStd_HArray1OfInteger(1,2);
anArrI->SetValue(1,aL);
anArrI->SetValue(2,aR);
aDec->ChangeArray(anArrI);
}
anArrI = new TColStd_HArray1OfInteger(1,2);
anArrI->SetValue(1,aL);
anArrI->SetValue(2,aR);
aDec->ChangeArray(anArrI);
if(theObject->GetModifiers().Length() == 0)
if(theObject->GetModifiers().Length() > 0)
{
Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
}
else
{
Handle(TDataStd_IntegerArray) aModifiers;
if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers))
{
aModifiers = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
}
Handle(TDataStd_IntegerArray) aModifiers = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
anArrI = new TColStd_HArray1OfInteger(1,theObject->GetModifiers().Length());
for(Standard_Integer i = 1; i <= theObject->GetModifiers().Length(); i++)
anArrI->SetValue(i,theObject->GetModifiers().Value(i));
@@ -166,44 +148,37 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
if(!theObject->GetPath().IsNull())
{
TNaming_Builder tnBuild(Label().FindChild(ChildLab_Path));
tnBuild.Generated(theObject->GetPath());
}
else
{
Label().FindChild(ChildLab_Path).ForgetAllAttributes();
TNaming_Builder tnBuild(Label().FindChild(ChildLab_Path));
tnBuild.Generated(theObject->GetPath());
}
Handle(TDataStd_RealArray) aDir;
if(!Label().FindChild(ChildLab_Dir).FindAttribute(TDataStd_RealArray::GetID(), aDir))
Handle(TColStd_HArray1OfReal) anArrR;
if(theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented)
{
aDir = new TDataStd_RealArray();
gp_Dir aD;
theObject->GetDirection(aD);
Handle(TDataStd_RealArray) aDir = new TDataStd_RealArray();
Label().FindChild(ChildLab_Dir).AddAttribute(aDir);
anArrR = new TColStd_HArray1OfReal(1,3);
anArrR->SetValue(1,aD.X());
anArrR->SetValue(2,aD.Y());
anArrR->SetValue(3,aD.Z());
aDir->ChangeArray(anArrR);
}
gp_Dir aD;
theObject->GetDirection(aD);
Handle(TColStd_HArray1OfReal) anArrR = new TColStd_HArray1OfReal(1,3);
anArrR->SetValue(1,aD.X());
anArrR->SetValue(2,aD.Y());
anArrR->SetValue(3,aD.Z());
aDir->ChangeArray(anArrR);
Handle(TDataStd_RealArray) aPnts;
if(!Label().FindChild(ChildLab_Pnts).FindAttribute(TDataStd_RealArray::GetID(), aPnts))
{
aPnts = new TDataStd_RealArray();
Label().FindChild(ChildLab_Pnts).AddAttribute(aPnts);
}
Handle(TColgp_HArray1OfPnt) aP = theObject->GetPoints();
if(!aP.IsNull() && aP->Length() > 0)
{
anArrR = new TColStd_HArray1OfReal(1,6);
Handle(TDataStd_RealArray) aPnts;
anArrR->SetValue(1,aP->Value(1).X());
anArrR->SetValue(2,aP->Value(1).Y());
anArrR->SetValue(3,aP->Value(1).Z());
anArrR->SetValue(4,aP->Value(2).X());
anArrR->SetValue(5,aP->Value(2).Y());
anArrR->SetValue(6,aP->Value(2).Z());
aPnts = new TDataStd_RealArray();
Label().FindChild(ChildLab_Pnts).AddAttribute(aPnts);
aPnts->ChangeArray(anArrR);
}
}

View File

@@ -14,10 +14,12 @@
#include <XCAFDoc_GeomTolerance.hxx>
#include <TDF_RelocationTable.hxx>
#include <TDF_ChildIterator.hxx>
#include <XCAFDoc.hxx>
#include <TDataStd_TreeNode.hxx>
#include <TDataStd_Integer.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TDataStd_RealArray.hxx>
#include <TDataStd_Real.hxx>
#include <XCAFDimTolObjects_GeomToleranceObject.hxx>
@@ -30,7 +32,10 @@ enum ChildLab
ChildLab_ZoneModif,
ChildLab_ValueOfZoneModif,
ChildLab_Modifiers,
ChildLab_aMaxValueModif
ChildLab_aMaxValueModif,
ChildLab_AxisLoc,
ChildLab_AxisN,
ChildLab_AxisRef
};
//=======================================================================
@@ -80,80 +85,90 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
{
Backup();
Handle(TDataStd_Integer) aType;
if(!Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
//Label().ForForgetAllAttributes();
TDF_ChildIterator anIter(Label());
for(;anIter.More(); anIter.Next())
{
aType = new TDataStd_Integer();
Label().FindChild(ChildLab_Type).AddAttribute(aType);
anIter.Value().ForgetAllAttributes();
}
aType->Set(theObject->GetType());
Handle(TDataStd_Integer) aTypeOfValue;
if(!Label().FindChild(ChildLab_TypeOfValue).FindAttribute(TDataStd_Integer::GetID(), aTypeOfValue))
Handle(TDataStd_Integer) aType = new TDataStd_Integer();
aType->Set(theObject->GetType());
Label().FindChild(ChildLab_Type).AddAttribute(aType);
if(theObject->GetTypeOfValue() != XCAFDimTolObjects_GeomToleranceTypeValue_None)
{
aTypeOfValue = new TDataStd_Integer();
Handle(TDataStd_Integer) aTypeOfValue = new TDataStd_Integer();
aTypeOfValue->Set(theObject->GetTypeOfValue());
Label().FindChild(ChildLab_TypeOfValue).AddAttribute(aTypeOfValue);
}
aTypeOfValue->Set(theObject->GetTypeOfValue());
Handle(TDataStd_Real) aValue;
if(!Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_Real::GetID(), aValue))
{
aValue = new TDataStd_Real();
Label().FindChild(ChildLab_Value).AddAttribute(aValue);
}
Handle(TDataStd_Real) aValue = new TDataStd_Real();
aValue->Set(theObject->GetValue());
Label().FindChild(ChildLab_Value).AddAttribute(aValue);
Handle(TDataStd_Integer) aMatReqModif;
if(!Label().FindChild(ChildLab_MatReqModif).FindAttribute(TDataStd_Integer::GetID(), aMatReqModif))
if(theObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None)
{
Label().FindChild(ChildLab_MatReqModif).FindAttribute(TDataStd_Integer::GetID(), aMatReqModif);
aMatReqModif = new TDataStd_Integer();
Label().FindChild(ChildLab_MatReqModif).AddAttribute(aMatReqModif);
aMatReqModif->Set(theObject->GetMaterialRequirementModifier());
}
aMatReqModif->Set(theObject->GetMaterialRequirementModifier());
Handle(TDataStd_Integer) aZoneModif;
if(!Label().FindChild(ChildLab_ZoneModif).FindAttribute(TDataStd_Integer::GetID(), aZoneModif))
if(theObject->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_None)
{
aZoneModif = new TDataStd_Integer();
Handle(TDataStd_Integer) aZoneModif = new TDataStd_Integer();
aZoneModif->Set(theObject->GetZoneModifier());
Label().FindChild(ChildLab_ZoneModif).AddAttribute(aZoneModif);
}
aZoneModif->Set(theObject->GetZoneModifier());
Handle(TDataStd_Real) aValueOfZoneModif;
if(!Label().FindChild(ChildLab_ValueOfZoneModif).FindAttribute(TDataStd_Real::GetID(), aValueOfZoneModif))
if(theObject->GetValueOfZoneModifier() > 0)
{
aValueOfZoneModif = new TDataStd_Real();
Handle(TDataStd_Real) aValueOfZoneModif = new TDataStd_Real();
aValueOfZoneModif->Set(theObject->GetValueOfZoneModifier());
Label().FindChild(ChildLab_ValueOfZoneModif).AddAttribute(aValueOfZoneModif);
}
aValueOfZoneModif->Set(theObject->GetValueOfZoneModifier());
if(theObject->GetModifiers().Length() == 0)
if(theObject->GetModifiers().Length() > 0)
{
Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
}
else
{
Handle(TDataStd_IntegerArray) aModifiers;
if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers)
|| theObject->GetModifiers().Length() == 0)
{
aModifiers = new TDataStd_IntegerArray();
Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
}
Handle(TDataStd_IntegerArray) aModifiers = new TDataStd_IntegerArray();
Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1,theObject->GetModifiers().Length());
for(Standard_Integer i = 1; i <= theObject->GetModifiers().Length(); i++)
anArr->SetValue(i,theObject->GetModifiers().Value(i));
aModifiers->ChangeArray(anArr);
Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
}
Handle(TDataStd_Real) aMaxValueModif;
if(!Label().FindChild(ChildLab_aMaxValueModif).FindAttribute(TDataStd_Real::GetID(), aMaxValueModif))
if(theObject->GetMaxValueModifier() > 0)
{
aMaxValueModif = new TDataStd_Real();
Handle(TDataStd_Real) aMaxValueModif = new TDataStd_Real();
aMaxValueModif->Set(theObject->GetMaxValueModifier());
Label().FindChild(ChildLab_aMaxValueModif).AddAttribute(aMaxValueModif);
}
aMaxValueModif->Set(theObject->GetMaxValueModifier());
if(theObject->HasAxis())
{
Handle(TDataStd_RealArray) aLoc = new TDataStd_RealArray();
Handle(TDataStd_RealArray) aN = new TDataStd_RealArray();
Handle(TDataStd_RealArray) aR = new TDataStd_RealArray();
gp_Ax2 anAx = theObject->GetAxis();
aLoc->SetValue(aLoc->Upper(),anAx.Location().X());
aLoc->SetValue(aLoc->Upper()+1,anAx.Location().Y());
aLoc->SetValue(aLoc->Upper()+2,anAx.Location().Z());
aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
aR->SetValue(aR->Upper(),anAx.Direction().X());
aR->SetValue(aR->Upper(),anAx.Direction().X());
aR->SetValue(aR->Upper(),anAx.Direction().X());
Label().FindChild(ChildLab_AxisLoc).AddAttribute(aLoc);
Label().FindChild(ChildLab_AxisN).AddAttribute(aN);
Label().FindChild(ChildLab_AxisRef).AddAttribute(aR);
}
}
//=======================================================================
@@ -216,7 +231,20 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject()
{
anObj->SetMaxValueModifier(aMaxValueModif->Get());
}
Handle(TDataStd_RealArray) aLoc;
Handle(TDataStd_RealArray) aN;
Handle(TDataStd_RealArray) aR;
if(Label().FindChild(ChildLab_AxisLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
Label().FindChild(ChildLab_AxisN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
Label().FindChild(ChildLab_AxisRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3 )
{
gp_Pnt aL(aLoc->Value(aLoc->Upper()), aLoc->Value(aLoc->Upper()+1), aLoc->Value(aLoc->Upper()+2));
gp_Dir aD(aN->Value(aN->Upper()), aN->Value(aN->Upper()+1), aN->Value(aN->Upper()+2));
gp_Dir aDR(aR->Value(aR->Upper()), aR->Value(aR->Upper()+1), aR->Value(aR->Upper()+2));
gp_Ax2 anAx(aL, aD, aDR);
anObj->SetAxis(anAx);
}
return anObj;
}