How to create a TopoDS_Shape

Hello,

I am developing a modeller in Java using Java3D and I need to add a function to export models as an Iges or a Step file.

My representation, which is those of Java3D, describe an object with a table of points. A group of three points represent a face.

I am using occJava, a wrapper on OpenCascade to call some functions in Java, and I will do an other wrapper for the missing ones.

My problem is that I can't figure out how to convert my 3D model in an OpenCascade 3D model.

Does anyone could give me a clue please?

Thanks,

Romain

Ro_ma_in's picture

I can use a list of trihedrons otherwise.
But I still don't understand how to make a TopoDS_Shape from them...

hamishl's picture

I'm not the best person to answer this, and don't know javaocc, but this converts a step into a TopoDS_Shape

Standard_CString aFileName = (Standard_CString) filename;
STEPControl_Reader aReader;
IFSelect_ReturnStatus status = aReader.ReadFile(aFileName);
if ( status == IFSelect_RetDone )
{
bool failsonly = false;
aReader.PrintCheckLoad( failsonly, IFSelect_ItemsByEntity );
int nbr = aReader.NbRootsForTransfer();
aReader.PrintCheckTransfer( failsonly, IFSelect_ItemsByEntity );
for ( Standard_Integer n = 1; n <= nbr; n++ )
{
Standard_Boolean ok = aReader.TransferRoot( n );
int nbs = aReader.NbShapes();
if ( nbs > 0 )
{
TopoDS_Shape shape = aReader.Shape( n );
Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
sfs->Init ( shape );

//Make fixing
sfs->Perform();

//Get result
shape = sfs->Shape();
for (TopoDS_Iterator iter(shape); iter.More(); iter.Next()) {
// get the current sub-shape
// which in your case will be TopoDS_Solid
TopoDS_Shape currentShape=iter.Value();
Handle_AIS_Shape myBox;
myBox = new AIS_Shape(currentShape);
myAISContext->SetDisplayMode(myBox,1, Standard_False);
myAISContext->Display(myBox);
}
}
}
} else
return false;
return true;

Ro_ma_in's picture

Thanks but it's not what I'm looking for.

I have : a table of vertices ( [v0,v1,v2,...,vn]; n=3*k+2, k is a non-negative integer) which describe a 3D model :[v0,v1,v2] is a face, [v3,v4,v5] too, v3 and v2 could be equals.

I want: a TopoDS_Shape represent my 3D model.
I know there is a lot of items like TopoDS_Vertex, but I don't know how to create a TopoDS_Vertex which coordinates are (x,y,z), normal is (u,v,w) and color is (r,g,b,a) by example (x,y,z,u,v,w,r,g,b and a are reals).

Ro_ma_in's picture

Problem solved.

The solution was in this files :
-BRepBuilderAPI_MakeVertex.cxx
BRepBuilderAPI_MakeVertex::BRepBuilderAPI_MakeVertex(const gp_Pnt& P)
: myMakeVertex(P)
-gp_Pnt.cxx
void SetCoord(const Standard_Real Xp,const Standard_Real Yp,const Standard_Real Zp) ;