Home
Reply
Contributor
kobofa
Posts: 10

How to get the centroid of surface??? please~

Hi

 

i made the surface using api function - api_mk_fa_spl_ctrlpts()

 

this surface is closed.

 

i want to get the centroid the this surface but i don't know..

 

api_body_mass_props)?? if this function is right, how can i use this function.

 

i tried to test this function

 

ex)

 

BODY* bod = NULL;

 

api_make_cuboid(100,150,200, bod, NULL);

 

mass_prop;

api_body_mass_prop(bod,mpop, NULL,NULL);

 

SPAposition cp = mpop.get_centroid();

 

printf("%f %f %f\n",cp.x(), cp.y(), cp.z());

 

----------------------------------------------

 

result is 0.00000    0.00000       0.00000

 

this is wrong???

 

i'm starter. please help me !

 

Contributor
DrSlonix
Posts: 7

Re: How to get the centroid of surface??? please~

Kobofa, Your cuboid (solid block) is created with its center at the origin.  Therefore, the center of mass is located at the origin.

 

Try to achieve the desired effect by using api_solid_block ().

 

Best regards!

Contributor
kobofa
Posts: 10

Re: How to get the centroid of surface??? please~

thank you !

 

i will try that.

Contributor
kobofa
Posts: 10

then..how to get the centroid of face??? convert to solid from face?

 
Spatial Employee
Entity
Posts: 64

Re: then..how to get the centroid of face??? convert to solid from face?

Hi kobofa,

 

You can call api_mk_by_faces to convert the face to a body, then use the mass-props API to get the centroid.

 

John

Contributor
kobofa
Posts: 10

Re: then..how to get the centroid of face??? convert to solid from face?

[ Edited ]

thank you

 

BODY* cucu = NULL;
BODY* cici = NULL;

api_mk_by_faces(cucu,4,Bspsurface_array,cici,NULL);
 
mass_props mpop;
api_body_mass_props(cucu,mpop,NULL,NULL);
 
double cp = mpop.get_volume();

printf("%lf\n",cp);

 

my code is that;

but didn't calculate the volume --;

 

what's wrong? hm..

 

i attached modeling picture; the picture is 4 surface;

surface_modeling_pic.jpg
Spatial Employee
Entity
Posts: 64

Re: then..how to get the centroid of face??? convert to solid from face?

Hi kobofa,

 

The API api_mk_by_faces does not create a solid body - it merely collects the input faces into a single body as single-shell lumps, all of which are 2D and have zero volume.  This should be sufficient to calculate centroids, as in your original question.

 

If you need to make a solid from the surfaces in your picture, you will need to trim the faces so that you have coincident edges, then use the stitcher to create the solid.  I'm sorry, but I'm not a stitcher expert, so maybe someone else can help you with this new question if it is important to you.

 

Best regards,

John

Contributor
kobofa
Posts: 10

Re: thank you for your answer. john.

then..this model is made by 6 faces. this is trimed surface. then don't covert to solid from 6 face???

forum_question.jpg
Trusted Contributor
Tim
Posts: 14

kobofa, some fun api's to explore with stitching surfaces...

[ Edited ]

kobofa, some fun api's to explore with stitching surfaces are api_imprint_stitch and api_stitch.   You can use them to stitch together collections of untrimmed surfaces and later use for other modeling operations as in the video below.

 

http://www.csi-concepts.com/Demo/videos/stitched2.mp4

 

Regards

 

Tim