I don't know why either. Two possibilities come to mind:
1) Maybe you are just not thinking in terms of the right units.
The volume will be in mm^3.
2) Maybe your shape contains some surfaces that are visible but
are never defined to be a solid. VolumeProperties only
takes solid geometries into account.
Cascade can compute the volume of a face, but that volume should be 0.
It is entirely possible that the system you used to produce the STEP
file only generated trimmed surfaces (which became faces) as opposed
to solids. You may want to check if there is an option to create
solids in your source system. Most 3D solid modelers used in CAD
systems allow this as an option. When importing a STEP file with
STEPControl_Reader, I use the OneShape function to get it as a single
shape. This usually gives me a single solid or a compound of solids.
My STEP files usually come from Pro/ENGINEER as solid geometry.
You can build solids from the faces by first making a shell and
then making a solid from the shell, but this can be a lot of work
(that is a little beyond me), because you would have to build the
connectivity yourself.
Mon, 08/09/2004 - 16:19
Look at BRepGProp::VolumeProperties
The resulting Mass should be the volume of your shape.
Wed, 08/11/2004 - 15:07
thanks for your help. i use that code
----------------------------------------
GProp_GProps System;
myAISContext->InitCurrent();
TopoDS_Shape current_shape = myAISContext->SelectedShape();
BRepGProp::VolumeProperties(current_shape, System);
Standard_Real vol = System.Mass();
-------------------------------------------------------
but i always get the wrong value. I dont know why?
Wed, 08/11/2004 - 15:36
I don't know why either. Two possibilities come to mind:
1) Maybe you are just not thinking in terms of the right units.
The volume will be in mm^3.
2) Maybe your shape contains some surfaces that are visible but
are never defined to be a solid. VolumeProperties only
takes solid geometries into account.
Rob
Fri, 08/13/2004 - 18:13
If i use the function currentshape.ShapeType(), i always get TopAbs_FACE as result. But why can i compute the volume of a face???
Is that the error? Should i first constuct a solid? but how?
Mon, 08/16/2004 - 17:41
Cascade can compute the volume of a face, but that volume should be 0.
It is entirely possible that the system you used to produce the STEP
file only generated trimmed surfaces (which became faces) as opposed
to solids. You may want to check if there is an option to create
solids in your source system. Most 3D solid modelers used in CAD
systems allow this as an option. When importing a STEP file with
STEPControl_Reader, I use the OneShape function to get it as a single
shape. This usually gives me a single solid or a compound of solids.
My STEP files usually come from Pro/ENGINEER as solid geometry.
You can build solids from the faces by first making a shell and
then making a solid from the shell, but this can be a lot of work
(that is a little beyond me), because you would have to build the
connectivity yourself.
Good luck,
Rob