Incorrect volume calculation and classification

Hello,

I am trying to calculate the volume of a solid and also classify point against it (in or out). In the attached image you can see a point marked with a yellow + that is classified as inside the black solid segment (clearly incorrect). I also know the volume of the black solid is incorrectly calculated (the volume is positive but about 30% less than the expected value). Here is how I generate the solid and check a point if it is IN or OUT:

BRepOffsetAPI_ThruSections generator(Standard_True,Standard_False);
generator.AddWire(prevProf);
generator.AddWire(currProf);
generator.Build();
TopoDS_Shape solidShape = generator.Shape();

gp_Pnt checkPoint(0.365350, 0.15, -0.005166);
BRepClass3d_SolidClassifier solidClass(solidShape, checkPoint, 1.0e-6);
TopAbs_State state = solidClass.State();
GProp_GProps props2;
BRepGProp::VolumeProperties(solidShape, props2);
Standard_Real vol2 = props2.Mass();

For the 40 segments shown in the image only 2 segments have this problem of incorrect classification of points and volumes. All segments are constructed from wires that are created from hexagonal array of points. Any ideas on how to diagnose the problem with solid and correct it would be greatly appreciated. BTW, I am using OpenCASCADE 6.5.0.

Thanks,
Harun

Evgeny Lodyzhehsky's picture

Dear Harun Bayraktar.

It is quite difficult to cure smth. by picture.
Please, save and attach the "solidShape" to the post.

hharun's picture

What is the easiest way to save a solidShape in a format you can use?

Thanks,
Harun

Evgeny Lodyzhehsky's picture

Use the following method to save a shape:

Standard_Boolean
BRepTools::Write(const TopoDS_Shape& Sh,
const Standard_CString File,
const Handle(Message_ProgressIndicator)& PR)

hharun's picture

Thanks for the tip. So much to learn. I have attached the exported text file for the black segment in the original image. The point coordinates were in the original message although I think any point would results in a state IN.

Attachments: 
Evgeny Lodyzhehsky's picture

Dear Harun Bayraktar.

The "solidShape" you've attached is not closed solid.
Try to use the class BRepCheck_Analyzer to certain of that.

The operations like classification, calculation of the volume properties for non-closed solids are weakly defined.
Indeed it is hard to say (except some cases like half-space for e.g.) whether the point in or out the solid when the solid is non-closed and has open shell-holes.
The computed state of the point "checkPoint" with "solidShape"
is IN, but the result OUT will be wrong too because the "solidShape" is wrong argument for the classification algorithm.
Please, try to close your solid before.
The attached shape is like seg23.dat but closed.

Attachments: 
hharun's picture

Dear Evgeny,

Thanks a lot for the explanation which makes perfect sense for a non-closed solid. I guess the follow up question is why the ThruSections algorithm creates a non-closed solid out of closed wires and why it sometimes is ok and sometimes fails? Is there an easy way to force the solid to be closed? How did you close it?

Thanks a lot for your help, it is much appreciated,
Harun