Tue, 06/02/2015 - 11:18

Forums:

Hello. At first, sorry for my English.

I need to import *.iges or *.step files (It is I did). Then I need to receive list of roots/surfaces/edges and so on.

For example, to receive list of roots and then their position (x, y, z). Please tell me where to find information about it?

In general, I had to transform *.iges or *.step into Finete Element Mesh. Maybe you have some information about it?

Thank you. Sincerely, Roman.

Tue, 06/02/2015 - 11:37

Hello Roman,

You might consult the source code of various Draw commands (such as "igesbrep" in XSDRAWIGES.cxx and "stepread" in XSDRAWSTEP.cxx) that deal with IGES and STEP files.

It is not clear what you mean by a "root's position (x, y, z)", though - probably, you could contact us to explain your need in more detail.

As for FEA meshing, such solutions exist and are used, for example, in our SALOME software - have a look at http://www.salome-platform.org/user-section/about/mesh.

Do not hesitate to contact us via http://www.opencascade.com/contact with your further information and questions.

Best regards,

Forum Supervisor

Sat, 06/13/2015 - 10:03

Thank you very much for help.

I saw the sample CSharp, I found the function ImportIges() (in OCCTProxy.cpp).

bool ImportIges(char* theFileName)

{

Standard_CString aFileName = (Standard_CString) theFileName;

IGESControl_Reader aReader;

int aStatus = aReader.ReadFile( aFileName );

if ( aStatus == IFSelect_RetDone )

{

aReader.TransferRoots();

TopoDS_Shape aShape = aReader.OneShape();

myAISContext()->Display(new AIS_Shape(aShape));

}

else

{

return false;

}

myAISContext()->UpdateCurrentViewer();

return true;

}

But I cannot receive the arrays of points, lines, BSpline Curves, BSpline Surfaces and so on (all entities). How can I do this?

Thank you. Sincerely, Roman.

Sat, 06/13/2015 - 16:07

Hello Roman,

You can use TopExp_Explorer to loop through the faces, edges, vertex's ect.

Standard_CString aFileName = "D:/OpenCASCADE6.9.0/opencascade-6.9.0/data/iges/128-009.igs";

IGESControl_Reader aReader;

int aStatus = aReader.ReadFile( aFileName );

TopoDS_Shape aShape;

if ( aStatus == IFSelect_RetDone )

{

aReader.TransferRoots();

aShape = aReader.OneShape();

}

// Find all BSplineCurve and lines

TopTools_MapOfShape aProcessedEdges;

double fp,lp;

TopExp_Explorer edgeExp (aShape, TopAbs_EDGE);

while (edgeExp.More()) {

TopoDS_Edge aEdge = TopoDS::Edge(edgeExp.Current());

if (!aProcessedEdges.Contains(aEdge) && !BRep_Tool::Degenerated(aEdge)) {

aProcessedEdges.Add(aEdge);

Handle(Geom_Curve) C1 = BRep_Tool::Curve(aEdge,fp,lp);

if (C1.IsNull()) {

qDebug() << "Geom_Curve is null";

return;

}

GeomAdaptor_Curve aGAC(C1);

switch (aGAC.GetType()) {

case GeomAbs_BSplineCurve: {

Handle(Geom_BSplineCurve) aBSp = aGAC.BSpline();

}

break;

case GeomAbs_Line:

gp_Lin aLin = aGAC.Line();

break;

}

}

edgeExp.Next();

}

// Find all BSplineSurface

TopExp_Explorer faceExp (aShape, TopAbs_FACE);

while (faceExp.More()) {

TopoDS_Face aEdge = TopoDS::Face(faceExp.Current());

Handle(Geom_Surface) C1 = BRep_Tool::Surface(aEdge);

if (C1.IsNull()) {

qDebug() << "Geom_Surface is null";

return;

}

GeomAdaptor_Surface aGAC(C1);

switch (aGAC.GetType()) {{

case GeomAbs_BSplineSurface:

Handle(Geom_BSplineSurface) aBSp = aGAC.BSpline();

}

break;

}

faceExp.Next();

}

// Find all vertex's

TopTools_MapOfShape aProcessedVertex;

TopExp_Explorer vertexExp (aShape, TopAbs_VERTEX);

while (vertexExp.More()) {

TopoDS_Vertex aVetex = TopoDS::Vertex(vertexExp.Current());

if (!aProcessedVertex.Contains(aVetex)) {

aProcessedVertex.Add(aVetex);

gp_Pnt point = BRep_Tool::Pnt(aVetex);

qDebug() << "Found point with position X "+ QString::number(point.X()) + " Y " + QString::number(point.Y()) + " Z " + QString::number(point.Z());

}

vertexExp.Next();

}

Good luck

Sat, 06/13/2015 - 23:07

Daniel Neander, thank you. It works.

You really saved me =)

Mon, 06/15/2015 - 14:22

Thank you for help.

But I have one more question.

How to receive CARTESIAN_POINT (knot vector)?

As I understood, class Geom_BSplineCurve is contained necessary methods, but how to access to them?

Handle(Geom_BSplineCurve) aBSp = aGAC.BSpline();

aBSp have not these methods.

Thank you. Sincerely, Roman.

Tue, 06/16/2015 - 12:21

Hello Roman,

A "Handle" is basically a c++ pointer.

Try the following

Handle(Geom_BSplineCurve) aBSp = aGAC.BSpline();

aBSp->NbKnots();

Wed, 06/17/2015 - 10:38

Hello, Daniel Neander

It does not work.

aBSp has not functions of Geom_BSplineCurve class.

Standard_Integer knots = aGAC.NbKnots(); returns number of elements of knot vector, but I need array of these elements; I need knot vector, degree, control points.

#17 = B_SPLINE_CURVE_WITH_KNOTS('',3,(#18,#19,#20,#21,#22,#23,#24),

.UNSPECIFIED.,.F.,.F.,(4,1,1,1,4),(0.E+000,5.099019513593,

9.571155468592,13.69426109421,17.299812369674),.UNSPECIFIED.);

#18 = CARTESIAN_POINT('',(0.E+000,0.E+000,0.E+000));

#19 = CARTESIAN_POINT('',(0.315574441982,5.35236316417,0.E+000));

#20 = CARTESIAN_POINT('',(0.802251469225,6.833111097242,0.E+000));

#21 = CARTESIAN_POINT('',(2.334769918812,-0.778160723897,0.E+000));

#22 = CARTESIAN_POINT('',(6.983440015292,2.781493261489,0.E+000));

#23 = CARTESIAN_POINT('',(9.293474399511,1.759916728762,0.E+000));

#24 = CARTESIAN_POINT('',(10.,6.12323399574E-016,0.E+000));

There are more ideas? How to receive all information about B-Spline?

Thank you. Sincerely, Roman.

Wed, 06/17/2015 - 12:58

Have you read the documentation for Geom_BSplineCurve? Everything if there.

For Knots:

for (int i = 1; i < aBSp->NbKnots() + 1; i++) {

qDebug() << "Found knot with value " + QString::number(aBSp->Knot(i));

}

Control point is same but called pole.

I am sure you can work out degree :P