Get dimensions data for STEP(AP242)

Hi Team, I have created a dimension in creoand exported a step file using AP 242 protocol.
I am trying to get dimension information such as value, Arrowpoints, linePoints, location, name and type of that dimensions.
Below is my function that I worked to get the information

But the only info I am able to get is name and vertex points in mm
After investigation i found getValues function of class XCAFDimTolObjects_DimensionObject which is returing 0.

I have attached cpp file having code as well as image of the dimensions and the properties i am using to export my file from creo.

int getDimensionsData(Handle(TDocStd_Document) document) {
Handle(XCAFDoc_DimTolTool) m_gdtTool = XCAFDoc_DocumentTool::DimTolTool(document->Main());
Handle(XCAFDoc_ShapeTool) m_shapeTool = XCAFDoc_DocumentTool::ShapeTool(document->Main());

TDF_LabelSequence labels_datums, label_geoms, label_dims, label_dimTols, label_ding;
m_gdtTool->GetDatumLabels(labels_datums);
m_gdtTool->GetDimensionLabels(label_dims);
m_gdtTool->GetGeomToleranceLabels(label_geoms);

int datumSize = labels_datums.Length(); //getting 0
int dimSize = label_dims.Length(); //getting 1 since only step file have only one dimension
int geomSize = label_geoms.Length(); //getting 0

// Geometric Tolerances
for (int i = 1; i {
const TDF_Label& label_dim = label_dims.Value(i);

Handle(XCAFDoc_Dimension) aDimAttr;
label_dim.FindAttribute(XCAFDoc_Dimension::GetID(), aDimAttr);

if (!aDimAttr.IsNull())
{
Handle(XCAFDimTolObjects_DimensionObject) aDimObject = aDimAttr->GetObject();
Handle(TCollection_HAsciiString) name = aDimObject->GetPresentationName();

if (!name)
name = aDimObject->GetSemanticName();

double val = aDimObject->GetValue(); // getting 0.0000000000000000
double lowerTolVal = aDimObject->GetLowerTolValue(); // getting 0.0000000000000000
double lowerBoundVal = aDimObject->GetLowerBound(); // getting 0.0000000000000000
double upperTolVal = aDimObject->GetUpperTolValue(); // getting 0.0000000000000000
double upperBound = aDimObject->GetUpperBound(); // getting 0.0000000000000000

gp_Pnt lowerBoun = aDimObject->GetPoint(); // getting x,y,z as 0.0000000000000000
gp_Pnt lowerBou = aDimObject->GetPoint2(); // getting x,y,z as 0.0000000000000000
gp_Pnt lowerBo = aDimObject->GetPointTextAttach(); // getting x,y,z as 0.0000000000000000

gp_Dir Dir;
double a = aDimObject->GetDirection(Dir);
XCAFDimTolObjects_DimensionType dimType = aDimObject->GetType(); //DimensionType_DimensionPresentation
XCAFDimTolObjects_DimensionQualifier dimQualifier = aDimObject->GetQualifier(); //XCAFDimTolObjects_DimensionQualifier_None

Handle(TColStd_HArray1OfReal) vals = aDimObject->GetValues();
if (vals)
{
int length = vals->Length();
if (length)
{
double dval = vals->Value(length - 1);
}
}
if (name)
{
TCollection_AsciiString ascNameStr = name->String(); //getting name "dd1" as given in creo
std::wstring nameStr = StrTool::str2wstr(ascNameStr.ToCString());

// Get shape
TDF_LabelSequence fir, sec;
m_gdtTool->GetRefShapeLabel(label_dim, fir, sec);

GDT_Item* gdt = nullptr;

//getting points in mm
//p1 = x:0.0 y:26632.637026440600 z:16798.487548626999
//p2 = x:7492.7460000000001 y:26632.637026440600 z:16798.487548626999

gp_Pnt p1, p2;

for (int j = 1; j {
const TDF_Label& label_shape = fir.Value(1);
const TopoDS_Shape& shape = m_shapeTool->GetShape(label_shape);
TopAbs_ShapeEnum shapetype = shape.ShapeType();
TopExp_Explorer expFace;
int n = 1;
for (expFace.Init(shape, TopAbs_VERTEX); expFace.More(); expFace.Next()) {
TopoDS_Vertex aVertex = TopoDS::Vertex(expFace.Current());
if (n == 1) {
p1 = BRep_Tool::Pnt(aVertex);
}
else {
p2 = BRep_Tool::Pnt(aVertex);
}
++n;
}
const gp_Trsf& trsf = m_shapeTool->GetLocation(label_shape).Transformation();
NCollection_IndexedDataMap dimmap;
m_gdtTool->GetGDTPresentations(dimmap);
bool val = dimmap.IsEmpty();
int val2 = dimmap.Size();

}

for (int j = 1; j {
const TDF_Label& label_shape = sec.Value(1);
const TopoDS_Shape& shape = m_shapeTool->GetShape(label_shape);

//gdt->AddShape(shape);
}
}
return 0;

}
}
}

Dmitrii Pasukhin's picture

Hello

DimensionType_DimensionPresentation - is a non-semantic type. That is why you can't find any semantic info. You can get only refences to the shapes, name of PMI, name of Presentation and pre-tessalted presentation of PMI.

If you're sure the type of PMI is wrong, let me know. I will try to analyze.

Best regards, Dmitrii.

Yash Soni's picture

Hi Dimitri,

Thanks for your time. I have attached a screenshot of the output I get for the type and other objects.
Yes the type is XCAFDimTolObjects_DimensionType_DimensionPresentation where it should be Linear
I will be needing values for types such as linear , angle, radius , diameter etc.
I could also share you the stp file which has a single dimensions if needed.

Dmitrii Pasukhin's picture

Thank you for your investigation.

Yes, the file with only one PMI will be very helpful. As soon, as you share a file, I start to analyze it.

Best regards, Dmitrii.

Yash Soni's picture

Hi Dimitri,

I have attached the file below<
Thanks

Yash Soni's picture

Hi Dimitri
I have investigated a little more about it I hope it helps
I have verified with a new step file i created having 3 different dimensions

for two of the dimensions dd1 and dd2 I am getting type as XCAFDimTolObjects_DimensionType_CommonLabel
whereas the other dd3 is of type XCAFDimTolObjects_DimensionType_DimensionPresentation.
What I able to get is the edge points p1 and p2 for all three. Also for angle dimensions.

Do we have to calculate the value and other properties from only those information.

I have found the documentation https://dev.opencascade.org/doc/refman/html/_x_c_a_f_dim_tol_objects___d...
which shows us the list of types of dimensions supported by opencascade.

I am not sure what are we missing.

Thanks Regards
Yash

Yash Soni's picture

Hi Dimitri seems like you have been busy. Just a quick update
I am able to get linear,radian and angle dimensions as a string from the step file.
Using this function I created.

void getNameDimensionTypeMap(Handle(XSControl_WorkSession) ws, std::map<TCollection_ExtendedString, TCollection_ExtendedString> &nameDimTypeMap) {
Handle(XSControl_TransferReader) tr = ws->TransferReader();
Handle(Transfer_TransientProcess) tp = tr->TransientProcess();
Handle(Interface_InterfaceModel) model = ws->Model();

Standard_Integer num_entities = model->NbEntities();
const Interface_Graph& graph = tp->Graph();
for (Standard_Integer i = 1; i <= num_entities; i++)
{
Handle(Standard_Transient) entity = model->Value(i);

// Read DG&T entities
Interface_EntityIterator ei = graph.Sharings(entity);
for (ei.Start(); ei.More(); ei.Next())
{
//std::cout << ei.Value()->get_type_descriptor()->Name() << std::endl;
/*if (ei.Value()->IsKind(STANDARD_TYPE(StepShape_GeometricSet))) {
auto curve = Handle(StepShape_GeometricSet)::DownCast(ei.Value());
auto name = curve->Name();
std::cout << name->ToCString();
}*/
if (ei.Value()->IsKind(STANDARD_TYPE(StepVisual_AnnotationCurveOccurrence))) {
auto curve = Handle(StepVisual_AnnotationCurveOccurrence)::DownCast(ei.Value());
auto dimensionName = curve->Name()->ToCString();
auto dimensionType = curve->Item()->Name()->ToCString();
nameDimTypeMap[dimensionName] = dimensionType;
}
}
}
}

I am also able to get the edge information in my p1 and p2 in my getDimensionsData function.
What I am not able to calculate is the points for the wittness lines because I cant access the witness lines for each dimensions

I have attached a diagram indicating the issue and the view of the step file with dimensions.(red circle- point line Not accessible)

This is the only issue of accessing witness lines is blocking me to move further.

Your help will be very much helpfull
Thanks

Dmitrii Pasukhin's picture

Hello, attached step files: step_with_multiple_Dimensions.7z and step_with_dimensions.7z are pure pre-tessalated. The name something like "radious dimension" is just a name of geometry and do not impact on type.

I recommended you to re-write step files with other settings. For example, if it is possible, enable supplemental geometry. And write PMI as semantic, not tessellated.

As for a standard, pmi written according 214 ISO, but STEP file written as a 242. It is very strange.
Moreover, there are not any constructive geometry to compute (vertex or planes). You have as ref geometry only edges and something else, that are not attached well.

Additionally one of dimension is not translated(d_3) (skipped via step import). I can fix it ASAP. But it is pure tesslated too. You do not find any new semantic information in this enity.

Best regards, Dmitrii.

Yash Soni's picture

Hi Dimitri,

I recommended you to re-write step files with other settings. For example, if it is possible, enable supplemental geometry. And write PMI as semantic, not tessellated.

After investigating over this I think you are talking about enabling rich content option in CREO when exporting step AP242.
By enabling this we can Include rich sementic content with the exported annotations data.

I have created a step file with this I hope this file can help.

Ragards Yash

 

Attachments: 
Dmitrii Pasukhin's picture

It looks very good. Now you have semantic information. Do you need something else?

To define attachment points and other possibilities with PMI operation, you can request PMI Visualization Component | PMI software (opencascade.com).

Now you receive all information from the step file. But one of the PMI is skipped, because it's attached to the supplemental geometry, that is only on developing (now it is on testing stage).

Best regards, Dmitrii.

Yash Soni's picture

I think what I am not able to get is the shapes for dimesniosn properly.
Based on the dcumentation https://dev.opencascade.org/doc/overview/html/occt_user_guides__xde.html
GetRefShapeLabel function should give me the shapes but for angle dimensions its giving me witness points for another dimension.

For angle dimensions I need 4 points (not getting) (2 arrow points and 2 witnesspoints)
For linear I need 4 (not getting) (2 arrow points and 2 witnesspoints)
for radial I need 2 (getting properly).

I have tried functions such as
GetDimensionLabels
GetRefDimensionLabels
GetDimTol
gp_Pnt d1 = aDimObject->GetPoint2(); (giving 0,0,0)
gp_Pnt d2 = aDimObject->GetPoint(); (giving 0,0,0)

But not giving me the point values that I need.

Regards Yash

Yash Soni's picture

Hi Dimitri, Thanks a lot for assistance.
Going to my first post for this section that says
I am trying to get dimension information such as value, Arrowpoints, linePoints, location, name and type of that dimensions.
Using the sementic data now I am able to get the
value using aDimObject.getValue() ;
name using aDimObject->GetSemanticName();

Type aDimObject->GetType();
Not able to get Arrowpoints values and witnessLinePoints correctly.  (refer image getShape.jpg that has code to find points)

For example in radial dimensions case I am getting fir and sec length as 1 and thus my
p1 = 0,-80,100 (values coverted from mm to inches)
p2 = -180,-80,100
p3 = 0,100,100
p4 = 0,-80,100

Here p1 and p4 is the witnesslinepoints for angle dimensions (0,-80,100)
Question 1 Why are we getting p2 and p3 in radial dimensions loop as these values are witness line points for linear dimensions. Is it because the dimensions lies on the same plane? I dont know.

Can you help me in getting the required points for dimensions as showed in DimensionsDataAsNeeded.jpg 

Regards 
Yash

Yash Soni's picture

Hi Dimitri, Happy New Year

A quick update

I have used the dumpJson function to see that the point values that we want is present in the shape that we get from getShape and adimObject that we get from aDimAttr->GetObject();
I have attached the output.

Seems like the dimension and shape does not have values for arrow points just the values of witness line points.

To verify whether if I have missed something while exporting the step file from creo so I tried enabling all the properties still the arrow points was not present.

Is it a functionality that is work in progress or the application protocol for step is not what we are expecting.

Regards Yash

Dmitrii Pasukhin's picture

Hello,

According ISO you can get only point of attachment to the shape and text location. In your files there are not attachment points.

What about point of lines (starts of arrow) you can't find this information in step file.

You need to compute (point of attachments, point of starting arrow) using attachments shapes and plane of PMI (find point of intersection). You can use our commercial product PMI Visualization Component | PMI software (opencascade.com) to do this

Best regards, Dmitrii.