Jump to content

I don't get this

- - - - -

  • Please log in to reply
6 replies to this topic

#1
swann_

swann_

    Newbie

  • Members
  • Pip
  • 7 posts
Hello,

in this code HDK: samples/standalone/geoisosurface.C Source File there is a densityFunction that takes UT_Vector3 as a parameter.

Later this function is passed into another one but there is no UT_Vector3 pased into it, even braces are not there so how it works ? I'm seeing this for the first time.

Thanks in advance.

#2
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
The link is broken.
sudo rm -rf /

#3
swann_

swann_

    Newbie

  • Members
  • Pip
  • 7 posts
Hm, thats strange, it works for me and this is not site that need logging. It's public documentation.
Maybe try this :
http://www.sidefx.com/docs/hdk11.0/geoisosurface_8_c_source.html

If it still doesn't work for you give me sign.

#4
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Still doesn't work.
sudo rm -rf /

#5
swann_

swann_

    Newbie

  • Members
  • Pip
  • 7 posts
This is main code:

00001 /*

00002  * Copyright (c) 2011

00003  *      Side Effects Software Inc.  All rights reserved.

00004  *

00005  * Redistribution and use of Houdini Development Kit samples in source and

00006  * binary forms, with or without modification, are permitted provided that the

00007  * following conditions are met:

00008  * 1. Redistributions of source code must retain the above copyright notice,

00009  *    this list of conditions and the following disclaimer.

00010  * 2. The name of Side Effects Software may not be used to endorse or

00011  *    promote products derived from this software without specific prior

00012  *    written permission.

00013  *

00014  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS

00015  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES

00016  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN

00017  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,

00018  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT

00019  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,

00020  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF

00021  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING

00022  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,

00023  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

00024  *

00025  *----------------------------------------------------------------------------

00026  */

00027 

00028 #include <GU/GU_Detail.h>

00029 

00030 namespace HDK_Sample {

00031 

00032 static float

00033 densityFunction(const UT_Vector3 &P)

00034 {

00035     // Return the signed distance to the unit sphere

00036     return 1 - P.length();

00037 }

00038 

00039 }

00040 

00041 int

00042 main(int argc, char *argv[])

00043 {

00044     GU_Detail           gdp;

00045     UT_BoundingBox      bounds;

00046 

00047     // Evaluate the iso-surface inside this bounding box

00048     bounds.setBounds(-1, -1, -1, 1, 1, 1);

00049 

00050     // Create an iso-surface

00051     gdp.polyIsoSurface(HDK_Sample::densityFunction, bounds, 20, 20, 20);

00052 

00053     // Save to sphere.bgeo

00054     gdp.save("sphere.bgeo", true, NULL);

00055 

00056     return 0;

00057 }


Additionally here is PolyIsoSurface function that takes DensityFunction in this code as a parameter.

GU_PrimPoly* GU_Detail::polyIsoSurface(float(*)(const UT_Vector3 &) ptOutside, const UT_BoundingBox & bbox, int xdiv, int ydiv, int zdiv)



#6
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,719 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Oh, okay. This is called a function pointer, which is exactly like a regular pointer but you can use it to call different functions. Do you know how to use pointers?
sudo rm -rf /

#7
swann_

swann_

    Newbie

  • Members
  • Pip
  • 7 posts
Yeah, just that I see this first time in my journey with C++. So I supose it's simmilar to C# delegate ?

EDIT:
Nevermind, googled/binged it.

Thanks for help.

Edited by swann_, 29 April 2011 - 01:34 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users