OpenNI.Context.CreateProductionNodeObject C# (CSharp) Method

CreateProductionNodeObject() private method

private CreateProductionNodeObject ( IntPtr nodeHandle, NodeType type ) : OpenNI.ProductionNode
nodeHandle System.IntPtr
type NodeType
return OpenNI.ProductionNode
        private ProductionNode CreateProductionNodeObject(IntPtr nodeHandle, NodeType? type)
        {
            lock (this)
            {
                if (!this.allNodes.ContainsKey(nodeHandle))
                {
                    if (type == null)
                    {
                        IntPtr pNodeInfo = SafeNativeMethods.xnGetNodeInfo(nodeHandle);
                        type = NodeInfo.FromNative(pNodeInfo).Description.Type;
                    }

                    ProductionNode node;

                   	// start with concrete types
                    if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Device))
                    {
                        node = new Device(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Depth))
                    {
                        node = new DepthGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Image))
                    {
                        node = new ImageGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Audio))
                    {
                        node = new AudioGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.IR))
                    {
                        node = new IRGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.User))
                    {
                        node = new UserGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Recorder))
                    {
                        node = new Recorder(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Player))
                    {
                        node = new Player(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Gesture))
                    {
                        node = new GestureGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Scene))
                    {
                        node = new SceneAnalyzer(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Hands))
                    {
                        node = new HandsGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Codec))
                    {
                        node = new Codec(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ScriptNode))
                    {
                        node = new ScriptNode(this, nodeHandle, true);
                    }
                    // move on to abstract types
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.MapGenerator))
                    {
                        node = new MapGenerator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.Generator))
                    {
                        node = new Generator(this, nodeHandle, true);
                    }
                    else if (SafeNativeMethods.xnIsTypeDerivedFrom(type.Value, NodeType.ProductionNode))
                    {
                        node = new ProductionNode(this, nodeHandle, true);
                    }
                    else
                    {
                        throw new NotImplementedException("C# wrapper: Unknown generator type!");
                    }

                    this.allNodes[nodeHandle] = node;
                }

                return this.allNodes[nodeHandle];
            } // lock
        }

Same methods

Context::CreateProductionNodeObject ( IntPtr nodeHandle ) : OpenNI.ProductionNode

Usage Example

Beispiel #1
0
        static public ProductionNode CreateProductionNodeFromNative(IntPtr nodeHandle)
        {
            IntPtr  pContext = SafeNativeMethods.xnGetRefContextFromNodeHandle(nodeHandle);
            Context context  = Context.FromNative(pContext);

            SafeNativeMethods.xnContextRelease(pContext);
            return(context.CreateProductionNodeObject(nodeHandle));
        }