Studierstube Documentation Project

   Main Page       Modules       Class Hierarchy       Alphabetical List       Compound List       File List       Compound Members       Related Pages   

SoBotanicalBranch.h

Go to the documentation of this file.
00001 /* ========================================================================
00002   * Copyright (C) 2000  Vienna University of Technology
00003   *
00004   * This library is free software; you can redistribute it and/or
00005   * modify it under the terms of the GNU Lesser General Public
00006   * License as published by the Free Software Foundation; either
00007   * version 2.1 of the License, or (at your option) any later version.
00008   *
00009   * This library is distributed in the hope that it will be useful,
00010   * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012   * Lesser General Public License for more details.
00013   *
00014   * You should have received a copy of the GNU Lesser General Public
00015   * License along with this library; if not, write to the Free Software
00016   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017   *
00018   * For further information please contact Dieter Schmalstieg under
00019   * <schmalstieg@ims.tuwien.ac.at> or write to Dieter Schmalstieg,
00020   * Vienna University of Technology, Favoritenstr. 9-11/188, A1040 Vienna,
00021   * Austria.
00022   * ========================================================================
00023   * PROJECT: Studierstube
00024   * ======================================================================== */
00025 
00026  /* ======================================================================= */
00027 /** Header file for API definitions of SoBotanicalBranch
00028   *
00029   * @author Valerie Maquil
00030   *
00031   * $Header: 
00032   * @file                                                                   */
00033  /* ======================================================================= */
00034 
00035 
00036 
00037 #ifndef SoBotanicalBranch_H
00038 #define SoBotanicalBranch_H
00039 
00040 #include "SoBotanicalBase.h"
00041 #include <stbapi/util/ivio.h>
00042 
00043 #include <string>
00044 
00045 
00046 /**
00047  * implements a branch of a botanic tree. Each branch is defined with means of a SoCylinder
00048  * and a SoCone making the connection between this and the previous branch. The bottom radius
00049  * of the SoCone corresponds to the radius of the SoCylinder and its peak is sheared in the 
00050  * direction of the branch.
00051  *
00052  * The direction of the branch is definded with 3 rotations. rotBranch defines the rotation
00053  * of THIS branch around the Y-axis, rotBeta defines the rotation of ALL the branches
00054  * of this hierarchy around the Y-axis. rotAlpha defines the rotation or this branch around the 
00055  * Z-axis.
00056 
00057 CATALOG PARTS
00058 
00059   All Parts
00060   <table>
00061   <tr> <td>Part Name</td><td>Part Type</td><td>Default Type</td><td>NULL Default</td></tr>
00062   <tr> <td>geometry </td><td>SoSeparator</td><td>SoSeparator</td><td>YES</td></tr>
00063   <tr> <td>hiddenGeometry </td><td>SoAbortGroup</td><td>SoAbortGroup</td><td>YES</td></tr>
00064   <tr> <td>subbranches </td><td>SoNodeKitListPart</td><td>---</td><td>NO</td></tr>
00065   <tr> <td>rotBranch </td><td>SoRotationXYZ</td><td>SoRotationXYZ</td><td>NO</td></tr>
00066   <tr> <td>ext</td><td>SoSeparator</td><td>SoSeparator</td><td>NO</td></tr>
00067   <tr> <td>shear </td><td>SoMatrixTransform</td><td>SoMatrixTransform</td><td>NO</td></tr>
00068   <tr> <td>transCone </td><td>SoTranslation</td><td>SoTranslation</td><td>NO</td></tr>
00069   <tr> <td>extBranch </td><td>SoCone</td><td>SoCone</td><td>NO</td></tr>
00070   <tr> <td>rotAlpha </td><td>SoRotationXYZ</td><td>SoRotationXYZ</td><td>NO</td></tr>
00071   <tr> <td>transAfter </td><td>SoTranslation</td><td>SoTranslation</td><td>NO</td></tr>
00072   <tr> <td>branch </td><td>SoCylinder</td><td>SoCylinder</td><td>NO</td></tr>
00073   <tr> <td>rotBeta </td><td>SoRotationXYZ</td><td>SoRotationXYZ</td><td>NO</td></tr>
00074   <tr> <td>transBefore </td><td>SoTranslation</td><td>SoTranslation</td><td>NO</td></tr>
00075   <tr> <td>subgeometry </td><td>SoCylinder</td><td>SoCylinder</td><td>NO</td></tr>
00076   </table>
00077 
00078 Extra Information for List Parts from Above Table
00079 
00080   <table>
00081     <tr> <td>Part Name</td><td>Container Type</td><td>Possible Types</td></tr>
00082     <tr> <td>subbranches</td><td>SoGroup</td><td>SoBotanicalBase</td></tr>
00083    </table>
00084 
00085 
00086 File Format / defaults:
00087 
00088 @verbatim
00089 SoBotanicalBranch {
00090 
00091     SoSFFloat direction         0
00092     SoSFFloat alpha             0
00093     SoSFFloat beta              1.62 #golden section
00094     SoSFInt32 strands           0
00095 
00096 
00097     # from SoBotanicalBase
00098     SoSFInt32 strands           0
00099     SoSFFloat lengthOfBranch    10.0
00100 
00101 }
00102 @endverbatim
00103 
00104 
00105   @ingroup bot
00106 */
00107 class BOTANIC_VIS_API SoBotanicalBranch : public SoBotanicalBase
00108 {
00109     SO_KIT_HEADER(SoBotanicalBranch);
00110 
00111     /**
00112      * children of this branch
00113      */
00114     SO_KIT_CATALOG_ENTRY_HEADER(subbranches);
00115     /**
00116      * in this part the information is stored that shouldn't be rendered 
00117      */
00118     SO_KIT_CATALOG_ENTRY_HEADER(hiddenGeometry);
00119     /** 
00120      * rotation of this branch around the Y-axis, relative to the first branch 
00121      * of this hierarchical level
00122      */
00123     SO_KIT_CATALOG_ENTRY_HEADER(rotBranch);
00124     /**
00125      * translation of the cylinder BEFORE any rotations are performed. This 
00126      * translation goes in Y-direction with a value of half of the height of 
00127      * the cylinder.
00128      */
00129     SO_KIT_CATALOG_ENTRY_HEADER(transBefore);
00130     /**
00131      * rotation of this branch around the Z-axis. The angle of rotation depends 
00132      * on the number of strands and on the field alpha 
00133      */
00134     SO_KIT_CATALOG_ENTRY_HEADER(rotAlpha);
00135     /**
00136      * rotation of all the branches of this hierarchical level around the Y-axis, 
00137      * relative to the branches of the previous hierarchical level
00138      */
00139     SO_KIT_CATALOG_ENTRY_HEADER(rotBeta);
00140     /**
00141      * translation of the cylinder AFTER all rotations have been performed. This 
00142      * translation goes in Y-direction with a value of half of the height of the 
00143      * cylinder.
00144      */
00145     SO_KIT_CATALOG_ENTRY_HEADER(transAfter);
00146     /**
00147      * SoCylinder representing the branch
00148      */
00149     SO_KIT_CATALOG_ENTRY_HEADER(branch);
00150     /**
00151      * geometry of the cone making the connection between this and the previous branch
00152      */
00153     SO_KIT_CATALOG_ENTRY_HEADER(ext);
00154     /**
00155      * rotation of the cone around the Y-axis
00156      */
00157     SO_KIT_CATALOG_ENTRY_HEADER(rotExtBranch);
00158     /**
00159      * the cone itself
00160      */
00161     SO_KIT_CATALOG_ENTRY_HEADER(extBranch);
00162     /**
00163      * the translation of the cone in Y-direction, to put it at the bottom of the cylinder.
00164      * This translation corresponds to half the height of the cylinder
00165      */
00166     SO_KIT_CATALOG_ENTRY_HEADER(transCone);
00167     /**
00168      * the shearing of the cone: the peak of the cone is sheared in direction of the rotation
00169      * of the branch
00170      */
00171     SO_KIT_CATALOG_ENTRY_HEADER(shear);
00172     /**
00173      * pointers of the elements of "subbranches" are stored here to ensure that the above
00174      * transformations will be performed on these children too.
00175      */
00176     SO_KIT_CATALOG_ENTRY_HEADER(subgeometry);
00177 
00178 
00179 
00180 public:
00181     /** 
00182      * inventor class initialization
00183      */
00184     static void initClass();
00185     /**
00186      * constructor
00187      */
00188     SoBotanicalBranch();
00189 
00190     /** 
00191      * rotation angle of THIS branch around the Y-axis. Is chosen such that the branches are
00192      * distributed equally around the previous branch.
00193      */
00194     SoSFFloat direction;
00195     /**
00196      * this angle constitutes a reference for the rotation of each branch around
00197      * the Z-axis. The angles of rotAlpha are chosen such that their sum equals the angle
00198      * alpha.
00199      */
00200     SoSFFloat alpha;
00201     /**
00202      * rotation angle of ALL the branches of this level around the Y-axis. Often the angle 
00203      * 360/phi is chosen where phi = (1 + sqrt(5)/2) is the golden section.
00204      */
00205     SoSFFloat beta;
00206     /** 
00207      * this field stores the number of strands of the father branch. Is used to calculate rotAlpha
00208      * and the bottom radius of the cone.
00209      */
00210     SoSFInt32 previousStrand;
00211 
00212     /**
00213      * sets the connections of the sensors
00214      */
00215     virtual SbBool setUpConnections( SbBool onOff, SbBool doItAlways = FALSE );
00216 
00217     /**
00218      * sets the scaling value for the radius of this branch
00219      */
00220     void setThickness(float size) {thickness = size;};
00221     /**
00222      * sets the alpha of this branch
00223      */
00224     void setAlpha(float angle) {alphaStart = angle;};
00225     
00226     /**
00227      * calculates the correct parameters for its subbranches and sets their fields.
00228      */
00229     int adjustSubbranches();
00230 
00231     /**
00232      * if TRUE this branch has as only child a SoBotanicalFruit
00233      */
00234     bool isFruit;
00235 
00236 protected:
00237     /**
00238      * destructor
00239      */
00240     virtual ~SoBotanicalBranch();
00241 
00242     /** 
00243      * adapts all parts depending on the length of the branch
00244      */
00245     virtual void resizeHeightCB();
00246     /** 
00247      * adapts all parts depending on the thickness of the branch
00248      */
00249     virtual void resizeThicknessCB();
00250 
00251     /**
00252      * field sensor attached to alpha; calls angleSensorCB
00253      */
00254     SoFieldSensor alphaSensor;
00255     /**
00256      * field sensor attached to direction; calls angleSensorCB
00257      */
00258     SoFieldSensor directionSensor;
00259 
00260     /**
00261      * adapts rotAlpha, rotBranch and the shearing transformation of the cone
00262      */
00263     static void angleSensorCB(void *, SoSensor*);
00264 
00265     /**
00266      * field sensor attached to previousStrand; calls previousStrandSensorCB
00267      */
00268     SoFieldSensor previousStrandSensor;
00269     /**
00270      * adapts the bottom radius, the height and the translation of the cone
00271      */
00272     static void previousStrandSensorCB(void *, SoSensor*);
00273     
00274     /**
00275      * thickness of this branch
00276      */
00277     float thickness;
00278     /**
00279      * rotation angle of rotAlpha
00280      */
00281     float alphaStart;
00282 };
00283 
00284 //----------------------------------------------------------------------------
00285 
00286 #endif // SoBotanicalBranch_H
 This page was generated at Sat Jun 26 21:29:46 2004 for BotanicVis by Doxygen.
 If you have any comments, please send a message to schmalstieg@ims.tuwien.ac.at.
www.studierstube.org