DATAKIT API  V2025.1
How to use Dtk_GeometricalTolerance Class

A Geometrical Tolerance is a complex structure used into PMI and Drawing representions and is known as Dtk_GeometricalTolerance into DATAKIT API.
This tutorial will try to explain you how to use Dtk_GeometricalTolerance to retrieve all relevant data.
Here is an image representing a Dtk_GeometricalTolerance :

The Dtk_GeometricalTolerance are composed of 1 or several Dtk_ToleranceSpecificationContainer defined by their types (e.g., Position and Perpendicularity).
Each Dtk_ToleranceSpecificationContainer gathers 1 or several Dtk_ToleranceSpecification .
Each Dtk_ToleranceSpecification contains the text value of the tolerance and can have 1 Dtk_ReferenceFrame if needed. It can also have 0 to several Dtk_FCFFeatureIndicator .
Each Dtk_ReferenceFrame can have 0 to 3 Dtk_ReferenceBlock .

To illustrate the use of this class, we will try to get all information concerning this Geometrical Tolerance (Shown in the exploded view):

First, we will try to retrieve the first Dtk_ToleranceSpecificationContainer , represented by this image:

//we get the first Tolerance Specification Container
TmpTolSpecCont = MyGeomTol->GetToleranceSpecificationContainer( 0 );
//we get the Type of this Tolerance Specification Container : Position
TolSpecContType = TmpTolSpecCont->ToleranceSpecificationContainerType();


Then we focus onto the First Dtk_ToleranceSpecification :

//we get the first Tolerance Specification of the Position Tolerance Specification Container
Dtk_ToleranceSpecificationPtr FirstTolSpec = TmpTolSpecCont->GetToleranceSpecification( 0 );
//we retrieve the '0.5(M)' Dtk_CompositeText
Dtk_CompositeText FirstTolSpecValueTexts = FirstTolSpec->GetMainValue();
// we retrieve the ReferenceFrame
Dtk_ReferenceFramePtr TmpReferenceFrame = FirstTolSpec->ReferenceFrame();
Dtk_string RefLabel;
//retrieve the A label
RefLabel = TmpReferenceFrame->FirstReference()->GetReferenceLabel( 0 );
//retrieve the B label
RefLabel = TmpReferenceFrame->SecondReference()->GetReferenceLabel( 0 );
//ERROR the Third Reference is NULL
//RefLabel = TmpReferenceFrame->ThirdReference()->GetReferenceLabel( 0 );
///////// End of the First Position Tolerance Specification /////////


Now we process the Second Dtk_ToleranceSpecification of the Position Tolerance Specification Container :

//we get the second Tolerance Specification of the Position Tolerance Specification Container
Dtk_ToleranceSpecificationPtr SecondTolSpec = TmpTolSpecCont->GetToleranceSpecification( 1 );
//we retrieve the '0.3' Dtk_CompositeText
Dtk_CompositeText SecondTolSpecValueTexts = SecondTolSpec->GetMainValue();
//retrieve the 'B(L)' label
//Instead of retrieving the ReferenceFrame, we can directly get ReferenceBlock from Dtk_ToleranceSpecificationPtr (this is an alternative)
RefLabel = SecondTolSpec->FirstReference()->GetReferenceLabel( 0 );
//retrieve the DTK_FDT_MODIFIER_LEAST_MATERIAL of the 'B' label
DTK_FDT_MODIFIER Mofidier = SecondTolSpec->FirstReference()->GetMaterialModifier( 0 );
//ERROR the Second Reference is NULL
//RefLabel = SecondTolSpec->SecondReference()->GetReferenceLabel(0);
//ERROR the Third Reference is NULL
//RefLabel = TmpReferenceFrame->ThirdReference()->GetReferenceLabel(0);
///////// End of Position Tolerance Specification Container /////////


Finally we focus onto the Second Dtk_ToleranceSpecificationContainer ...

...which only has one Dtk_ToleranceSpecification :

//we get the Second Tolerance Specification Container which Type is Perpendicularity
TmpTolSpecCont = MyGeomTol->GetToleranceSpecificationContainer( 1 );
//we get the Perpendicularity Type
TolSpecContType = TmpTolSpecCont->ToleranceSpecificationContainerType();
//we get the first Tolerance Specification of the Perpendicularity Tolerance Specification Container
FirstTolSpec = TmpTolSpecCont->GetToleranceSpecification( 0 );
//we retrieve the '0.1' Dtk_CompositeText
FirstTolSpecValueTexts = FirstTolSpec->GetMainValue();
//retrieve the 'A' label
RefLabel = FirstTolSpec->FirstReference()->GetReferenceLabel( 0 );
//retrieve the 'B' label
RefLabel = FirstTolSpec->FirstReference()->GetReferenceLabel( 1 );
//retrieve the 'C' label
RefLabel = FirstTolSpec->SecondReference()->GetReferenceLabel( 0 );
//retrieve the 'D' label
RefLabel = FirstTolSpec->ThirdReference()->GetReferenceLabel( 0 );
//Now we iterate on each indicator to retrieve its data
for( Dtk_Size_t l = 0; l < FirstTolSpec->GetNumIndicators(); l++ )
{
const Dtk_FCFFeatureIndicatorPtr& CurrentIndicator = FirstTolSpec->GetIndicator( l );
//we retrieve the indicator type
const Dtk_FCFFeatureIndicatorType& IndicatorType = CurrentIndicator->GetFeatureIndicatorType();
//then the indicator type enum - OrientationPlane -...
//...and indicator type geometries
Dtk_tab< Dtk_CurvePtr > IndicatorTypeGeoms;
IndicatorType.CreateGeometries( IndicatorTypeGeoms );
//Then we retrieve the Indicator Symbol - symmetry here -
const Dtk_Text& IndicatorSymbol = CurrentIndicator->GetSymbol();
//and the indicator Datum Feature Identitfier - E -
const Dtk_Text& IndicatorDatumFeatureIdentifier = CurrentIndicator->GetDatumFeatureIdentifier();
}
//ERROR there isn't any Second Tolerance Specification
//SecondTolSpec = TmpTolSpecCont->GetToleranceSpecification(1);
///// End of Perpendicularity Tolerance Specification Container /////


Here the full sample code to retrieve this Geometrical Tolerance:

//we get the first Tolerance Specification Container
TmpTolSpecCont = MyGeomTol->GetToleranceSpecificationContainer( 0 );
//we get the Type of this Tolerance Specification Container : Position
TolSpecContType = TmpTolSpecCont->ToleranceSpecificationContainerType();
//we get the first Tolerance Specification of the Position Tolerance Specification Container
Dtk_ToleranceSpecificationPtr FirstTolSpec = TmpTolSpecCont->GetToleranceSpecification( 0 );
//we retrieve the '0.5(M)' Dtk_CompositeText
Dtk_CompositeText FirstTolSpecValueTexts = FirstTolSpec->GetMainValue();
// we retrieve the ReferenceFrame
Dtk_ReferenceFramePtr TmpReferenceFrame = FirstTolSpec->ReferenceFrame();
Dtk_string RefLabel;
//retrieve the A label
RefLabel = TmpReferenceFrame->FirstReference()->GetReferenceLabel( 0 );
//retrieve the B label
RefLabel = TmpReferenceFrame->SecondReference()->GetReferenceLabel( 0 );
//ERROR the Third Reference is NULL
//RefLabel = TmpReferenceFrame->ThirdReference()->GetReferenceLabel( 0 );
//we get the second Tolerance Specification of the Position Tolerance Specification Container
Dtk_ToleranceSpecificationPtr SecondTolSpec = TmpTolSpecCont->GetToleranceSpecification( 1 );
//we retrieve the '0.3' Dtk_CompositeText
Dtk_CompositeText SecondTolSpecValueTexts = SecondTolSpec->GetMainValue();
//retrieve the 'B(L)' label
//Instead of retrieving the ReferenceFrame, we can directly get ReferenceBlock from Dtk_ToleranceSpecificationPtr (this is an alternative)
RefLabel = SecondTolSpec->FirstReference()->GetReferenceLabel( 0 );
//retrieve the DTK_FDT_MODIFIER_LEAST_MATERIAL of the 'B' label
DTK_FDT_MODIFIER Mofidier = SecondTolSpec->FirstReference()->GetMaterialModifier( 0 );
//ERROR the Second Reference is NULL
//RefLabel = SecondTolSpec->SecondReference()->GetReferenceLabel(0);
//ERROR the Third Reference is NULL
//RefLabel = TmpReferenceFrame->ThirdReference()->GetReferenceLabel(0);
//we get the Second Tolerance Specification Container which Type is Perpendicularity
TmpTolSpecCont = MyGeomTol->GetToleranceSpecificationContainer( 1 );
//we get the Perpendicularity Type
TolSpecContType = TmpTolSpecCont->ToleranceSpecificationContainerType();
//we get the first Tolerance Specification of the Perpendicularity Tolerance Specification Container
FirstTolSpec = TmpTolSpecCont->GetToleranceSpecification( 0 );
//we retrieve the '0.1' Dtk_CompositeText
FirstTolSpecValueTexts = FirstTolSpec->GetMainValue();
//retrieve the 'A' label
RefLabel = FirstTolSpec->FirstReference()->GetReferenceLabel( 0 );
//retrieve the 'B' label
RefLabel = FirstTolSpec->FirstReference()->GetReferenceLabel( 1 );
//retrieve the 'C' label
RefLabel = FirstTolSpec->SecondReference()->GetReferenceLabel( 0 );
//retrieve the 'D' label
RefLabel = FirstTolSpec->ThirdReference()->GetReferenceLabel( 0 );
//Now we iterate on each indicator to retrieve its data
for( Dtk_Size_t l = 0; l < FirstTolSpec->GetNumIndicators(); l++ )
{
const Dtk_FCFFeatureIndicatorPtr& CurrentIndicator = FirstTolSpec->GetIndicator( l );
//we retrieve the indicator type
const Dtk_FCFFeatureIndicatorType& IndicatorType = CurrentIndicator->GetFeatureIndicatorType();
//then the indicator type enum - OrientationPlane -...
//...and indicator type geometries
Dtk_tab< Dtk_CurvePtr > IndicatorTypeGeoms;
IndicatorType.CreateGeometries( IndicatorTypeGeoms );
//Then we retrieve the Indicator Symbol - symmetry here -
const Dtk_Text& IndicatorSymbol = CurrentIndicator->GetSymbol();
//and the indicator Datum Feature Identitfier - E -
const Dtk_Text& IndicatorDatumFeatureIdentifier = CurrentIndicator->GetDatumFeatureIdentifier();
}
//ERROR there isn't any Second Tolerance Specification
//SecondTolSpec = TmpTolSpecCont->GetToleranceSpecification(1);
///// End of Perpendicularity Tolerance Specification Container /////


DTK_FDT_MODIFIER
DTK_FDT_MODIFIER
This is the several tolerances modifiers list.
Definition: util_draw_dtk.hpp:63
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Dtk_FCFFeatureIndicatorType
This is the Feature Indicator. It is part of the Dtk_FCFFeatureIndicator. .
Definition: util_draw_dtk.hpp:5898
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:712
Dtk_Text
This is the base text class. It's part of Dtk_CompositeText. It's used into a lot of 2D Entities It c...
Definition: util_draw_dtk.hpp:1126
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
Dtk_FCFFeatureIndicatorType::Dtk_FCFFeatureIndicatorTypeEnum
Dtk_FCFFeatureIndicatorTypeEnum
Definition: util_draw_dtk.hpp:5901
Dtk_CompositeText
This is the composite text class. It's basically a Dtk_Text Container. This class represents a group ...
Definition: util_draw_dtk.hpp:1557
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
Dtk_ToleranceSpecificationContainer::TypeEnum
TypeEnum
Definition: util_draw_dtk.hpp:6197
Dtk_FCFFeatureIndicatorType::GetIndicatorType
const Dtk_FCFFeatureIndicatorTypeEnum & GetIndicatorType() const
Retrieves the IndicatorType semantic Type - Read Only -.
Definition: util_draw_dtk.hpp:5976
Dtk_FCFFeatureIndicatorType::CreateGeometries
Dtk_ErrorStatus CreateGeometries(Dtk_tab< Dtk_CurvePtr > &outGeoms) const
Process IndicatorType Related geometries.