- Main Page
- Classes
- Files

- Search for |

# Filter.h

Go to the documentation of this file.

    00001 /*****************************
    00002 File:      Filter.h
    00003 Language:   C++ (header)
    00004 Project:    H3DNetworkingUtils
    00005 The contents of this file are subject to the Mozilla Public License
    00006 Version 1.1 (the "License"); you may not use this file except in
    00007 compliance with the License. You may obtain a copy of the License at
    00008 http://www.mozilla.org/MPL/
    00009
    00010 Software distributed under the License is distributed on an "AS IS"
    00011 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    00012 License for the specific language governing rights and limitations
    00013 under the License.
    00014
    00015 The Original Code is H3DNetworkingUtils v1.0.
    00016
    00017 The Initial Developer of the Original Code is CSIRO.
    00018 Portions created by the Initial Developer are Copyright (C) 1009 CSIRO. All Rights Reserved.
    00019 Contributor(s):
    00020     Chris Gunn  <Chris.Gunn@csiro.au> <ChrisJGunn@gmail.com>
    00021 ***************************/
    00022
    00025
    00026 #ifndef Filter_H
    00027 #define Filter_H
    00028
    00029 #include <H3D/X3DChildNode.h>
    00030 #include <H3D/FieldTemplates.h>
    00031 #include <H3D/SFBool.h>
    00032 #include "H3DNetworkingUtils/FilteredSFVec3f.h"
    00033
    00034
    00035 // This next line is needed because H3DAPI.dll instantiates this template but this class does not see the header with
    00036 // the instantiation in it. So without the line, this class would instantiate an identical one and there would
    00037 // be a multiply defined symbol in the link stage.
    00038 template struct __declspec(dllimport) H3D::AutoUpdate <H3D::SFBool>;
    00039
    00040 namespace H3DNetworkingUtils {
    00041
    00046
    00047 class H3D_NETWORKING_UTILS_DLL_SPEC Filter : public H3D::X3DChildNode {
    00048 public:
    00049
    00050   class EnableSwitch;
    00051
    00053   Filter(H3D::Inst<H3D::SFVec3f        > _rawValue = 0,
    00054          H3D::Inst<FilteredSFVec3f     > _filteredValue = 0,
    00055          H3D::Inst<H3D::SFInt32        > _samp_size = 0,
    00056          H3D::Inst<EnableSwitch        > _enabled   = 0);
    00057
    00058   static H3D::H3DNodeDatabase database;
    00059
    00060   class EnableSwitch : public H3D::AutoUpdate< H3D::SFBool >  {
    00061   public:
    00062     virtual void update() {
    00063       H3D::SFBool * on = static_cast<H3D::SFBool *>(event.ptr);
    00064       if (on->getValue() == value) {
    00065         return;
    00066       }
    00067       value = on->getValue();
    00068       if (value) {
    00069         filtP->rawValue->route(filtP->filteredValue);
    00070         filtP->sampleSize->route(filtP->filteredValue);
    00071       }
    00072       else {
    00073         filtP->rawValue->unroute(filtP->filteredValue);
    00074         filtP->sampleSize->unroute(filtP->filteredValue);
    00075       }
    00076     }
    00077     Filter * filtP;
    00078   };
    00079
    00084   auto_ptr<H3D::SFVec3f    > rawValue;
    00085
    00090   auto_ptr<FilteredSFVec3f > filteredValue;
    00091
    00096   auto_ptr<H3D::SFInt32    > sampleSize;
    00097
    00102   auto_ptr<EnableSwitch    > enabled;
    00103 };
    00104
    00105 }
    00106
    00107 #endif
    00108