For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Normals come out wrong using VIS (Vtk Integration Service)

André Rabe's picture
Forums: 

Hi,

I'm having quite the issue for some days getting the VIS classes to work my way and would greatly appreciate some directions and/or confirmation that it could be an issue with OCCT.

I'm will try to keep it simple and not post walls of source code.

I'm trying to get out of VIS a list of points, triangles indexes and normals to be use as data for an external renderer.

The two first sets of data come out fine. And as the title suggests, the normals "came out" wrong (see attachment for a screenshot of a VTK window showing theses, base model is a simple cube)

I tried with the code snippets from the guides.

Both the high level API way and the low level one.

I tried while using the low level way to fiddle around with the different parameters from the ShapeMesher

const Standard_Real& theDevCoeff = 0.0001,
const Standard_Real& theDevAngle = 12.0 * M_PI / 180.0,
const Standard_Integer theNbUIsos = 1,
const Standard_Integer theNbVIsos = 

No success ( but granted that I can't barely understand theses, still no result even with extreme values)

Edit: Here goes some simplified code, I hope it will help to provide some insight :)

//Class cpp file (Simplified)

STEPControl_Reader reader;
IFSelect_ReturnStatus stat = reader.ReadFile(path);

if (stat != IFSelect_ReturnStatus::IFSelect_RetDone) {
    std::cout << std::endl << " Failed to load file at path : " << path << std::endl;
    return false;
}
reader.NbRootsForTransfer();
reader.TransferRoots();
lastLoadedShape = reader.OneShape();

IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(lastLoadedShape);
IVtkVTK_ShapeData::Handle aDataImpl = new IVtkVTK_ShapeData();
IVtk_IShapeMesher::Handle aMesher = new IVtkOCC_ShapeMesher(0.0001, 6);

aMesher->Build(aShapeImpl, aDataImpl);

//This is a member of the class
currentStateOfData = aDataImpl->getVtkPolyData();

vtkSmartPointer<vtkPolyDataNormals> normalData = vtkSmartPointer<vtkPolyDataNormals>::New();

normalData->SetInputData(data_source);
normalData->ComputePointNormalsOn();
normalData->ComputeCellNormalsOff();
normalData->Update();

currentStateOfData = normalData->GetOutput();



// Next comes the code that invoke a 'VTk Debug window' (see attachement)

Any idea appreciated !

Kirill Gavrilov's picture

Currently, VIS doesn't use normals from original Geometry - there is an issue on Bugtracker registered to this matter:
https://tracker.dev.opencascade.org/view.php?id=25845

Patches are welcome:
https://dev.opencascade.org/index.php?q=home/get_involved

André Rabe's picture

Damn.

Well thanks a lot for the heads up,

so you're telling me that it's a no-go to get that information with the current state of OCCT ?

(Except with a patch, that I would gladly code, if I had the time and competence :-) )

EDIT: I read the bug report, I must add that even with the vtk filter, It's unusable from my end.

Kirill Gavrilov's picture

There is no problem to get normals from shape in OCCT (like StdPrs_ShadedShape).
It is just IVtk visualization that doesn't yet fill this information for displaying in VTK viewer.

André Rabe's picture

Thanks a lot for the tip.

I'm currently struggling to take in the whole pipeline, learning from the User guide "Visualization".

I'll try to report back with an example when I'm done later, for people looking for the same use case.

André Rabe's picture

I'll be upfront, I having a pretty hard time finding the simpler way of getting my vertices/triangles/normals list.

I tried instancing a AIS_Shape from my TopoDS_Shape, and then calling


virtual void AIS_Shape::Compute ( 
                const Handle< PrsMgr_PresentationManager3d > &  thePrsMgr,
		const Handle< Prs3d_Presentation > &  	thePrs,
		const Standard_Integer  	theMode 
) 	

but I quickly have to go down a rabbit hole (PrsMgr_PresentationManager then another and another lower level class).

EDIT :Also tried to

auto triangles = StdPrs_ShadedShape::FillTriangles(lastLoadedShape);

Retuens "NULL" :(

Could anyone point a more precise direction, please ?

Cheers.

Andre