Esempio n. 1
0
        public unsafe void Execute(int startIndex)
        {
            int planeIndex = startIndex;

            for (int j = 0; j < 4; j++)
            {
                int segmentRays = contexts[j].segment.RayCount;
                if (segmentRays <= 0)
                {
                    continue;
                }
                if (planeIndex >= segmentRays)
                {
                    planeIndex -= segmentRays;
                    continue;
                }

                rays[startIndex] = new RayContext
                {
                    context       = (SegmentContext *)contexts.GetUnsafeReadOnlyPtr() + j,
                    planeRayIndex = planeIndex
                };
                break;
            }
        }
 public ConesSteps(ConesContext conesContext,
                   IntersectionsContext intersectionsContext,
                   RayContext rayContext,
                   VectorsContext vectorsContext)
 {
     _vectorsContext       = vectorsContext;
     _rayContext           = rayContext;
     _intersectionsContext = intersectionsContext;
     _conesContext         = conesContext;
 }
 public CylindersSteps(CylindersContext cylindersContext,
                       IntersectionsContext intersectionsContext,
                       RayContext rayContext,
                       VectorsContext vectorsContext)
 {
     _vectorsContext       = vectorsContext;
     _rayContext           = rayContext;
     _intersectionsContext = intersectionsContext;
     _cylindersContext     = cylindersContext;
 }
Esempio n. 4
0
 public PlanesSteps(PlanesContext planesContext,
                    IntersectionsContext intersectionsContext,
                    VectorsContext vectorsContext,
                    RayContext rayContext)
 {
     _rayContext           = rayContext;
     _vectorsContext       = vectorsContext;
     _intersectionsContext = intersectionsContext;
     _planesContext        = planesContext;
 }
 public TriangleMeshesSteps(TriangleMeshesContext meshesContext,
                            PointsContext pointsContext,
                            IntersectionsContext intersectionsContext,
                            RayContext rayContext)
 {
     _rayContext           = rayContext;
     _intersectionsContext = intersectionsContext;
     _pointsContext        = pointsContext;
     _meshesContext        = meshesContext;
 }
Esempio n. 6
0
 public RaysSteps(
     RayContext rayContext,
     PointsContext pointsContext,
     VectorsContext vectorsContext,
     TransformationsContext transformationsContext)
 {
     _transformationsContext = transformationsContext;
     _vectorsContext         = vectorsContext;
     _pointsContext          = pointsContext;
     _rayContext             = rayContext;
 }
 public ShapeGroupsSteps(ShapeGroupsContext shapeGroupsContext,
                         ShapesContext shapesContext,
                         RayContext rayContext,
                         IntersectionsContext intersectionsContext,
                         SphereContext sphereContext)
 {
     _sphereContext        = sphereContext;
     _intersectionsContext = intersectionsContext;
     _rayContext           = rayContext;
     _shapesContext        = shapesContext;
     _shapeGroupsContext   = shapeGroupsContext;
 }
 public TrianglesSteps(TrianglesContext triangesContext,
                       PointsContext pointsContext,
                       VectorsContext vectorsContext,
                       RayContext rayContext,
                       IntersectionsContext intersectionsContext)
 {
     _intersectionsContext = intersectionsContext;
     _rayContext           = rayContext;
     _vectorsContext       = vectorsContext;
     _pointsContext        = pointsContext;
     _triangesContext      = triangesContext;
 }
Esempio n. 9
0
 public CameraSteps(CameraContext cameraContext,
                    WorldContext worldContext,
                    PointsContext pointsContext,
                    VectorsContext vectorsContext,
                    RayContext rayContext)
 {
     _rayContext     = rayContext;
     _vectorsContext = vectorsContext;
     _pointsContext  = pointsContext;
     _worldContext   = worldContext;
     _cameraContext  = cameraContext;
 }
Esempio n. 10
0
 public CubesSteps(CubesContext cubesContext,
                   IntersectionsContext intersectionsContext,
                   RayContext rayContext,
                   VectorsContext vectorsContext,
                   PointsContext pointsContext)
 {
     _pointsContext        = pointsContext;
     _vectorsContext       = vectorsContext;
     _rayContext           = rayContext;
     _intersectionsContext = intersectionsContext;
     _cubesContext         = cubesContext;
 }
 public SpheresSteps(SphereContext sphereContext,
                     RayContext rayContext,
                     IntersectionsContext intersectionsContext,
                     VectorsContext vectorsContext,
                     PointsContext pointsContext)
 {
     _pointsContext        = pointsContext;
     _vectorsContext       = vectorsContext;
     _intersectionsContext = intersectionsContext;
     _sphereContext        = sphereContext;
     _rayContext           = rayContext;
 }
Esempio n. 12
0
 public ShapesSteps(ShapesContext shapesContext,
                    MaterialsContext materialsContext,
                    RayContext rayContext,
                    IntersectionsContext intersectionsContext,
                    VectorsContext vectorsContext,
                    TransformationsContext transformationsContext)
 {
     _transformationsContext = transformationsContext;
     _vectorsContext         = vectorsContext;
     _intersectionsContext   = intersectionsContext;
     _rayContext             = rayContext;
     _materialsContext       = materialsContext;
     _shapesContext          = shapesContext;
 }
 public IntersectionsSteps(IntersectionsContext intersectionsContext,
                           SphereContext sphereContext,
                           WorldContext worldContext,
                           RayContext rayContext,
                           PlanesContext planesContext,
                           ComputationsContext computationsContext)
 {
     _computationsContext  = computationsContext;
     _planesContext        = planesContext;
     _rayContext           = rayContext;
     _worldContext         = worldContext;
     _intersectionsContext = intersectionsContext;
     _sphereContext        = sphereContext;
 }
Esempio n. 14
0
 public WorldSteps(WorldContext worldContext,
                   SphereContext sphereContext,
                   RayContext rayContext,
                   ColorsContext colorContext,
                   PointsContext pointsContext,
                   LightsContext lightsContext,
                   PlanesContext planesContext,
                   ComputationsContext computationsContext)
 {
     _computationsContext = computationsContext;
     _planesContext       = planesContext;
     _lightsContext       = lightsContext;
     _pointsContext       = pointsContext;
     _colorContext        = colorContext;
     _rayContext          = rayContext;
     _sphereContext       = sphereContext;
     _worldContext        = worldContext;
 }
        /// <summary>Formats the insert statement</summary>
        /// <param name="obj"></param>
        /// <param name="props"></param>
        private SQLiteCommand FormatInsertCommand <T>(T obj, string tableName, IEnumerable <PropertyInfo> props, string ctx)
        {
            // if no table or properties then abort
            if (obj == null || String.IsNullOrWhiteSpace(tableName) || props == null || props.Count() < 1)
            {
                return(null);
            }

            // determine the context type from the object itself
            RayContext ctxType = RayPropertyAttribute.CalculateContext(typeof(T), ctx);

            if (ctxType == RayContext.Error)
            {
                throw new System.Exception("A context was specified by no properties have RayAttribute");
            }

            Dictionary <string, SQLiteParameter> paras = new Dictionary <string, SQLiteParameter>();

            // set the value of each property on the object
            foreach (PropertyInfo prop in props)
            {
                // dict values
                string          propName = null;
                SQLiteParameter param    = null;

                // can you publicly read the property
                if (!prop.CanRead)
                {
                    continue;
                }

                // reject arrays except byte[]
                if (prop.PropertyType.IsArray && prop.PropertyType != typeof(byte[]))
                {
                    continue;
                }

                // reject most generic Lists for now
                if (prop.PropertyType.IsGenericType && prop.PropertyType.GetGenericTypeDefinition() == typeof(List <>))
                {
                    continue;
                }

                // property names is determined context type
                if (ctxType == RayContext.PropertyName)
                {
                    propName = prop.Name;
                }
                else if (ctxType == RayContext.Null)
                {
                    // get the properties FieldMap attribute
                    RayPropertyAttribute dest = prop.GetCustomAttributes <RayPropertyAttribute>(false).Where(a => a.IsNullContext).FirstOrDefault();

                    if (dest == null)
                    {
                        continue;
                    }

                    propName = dest.Destination.Trim();
                }

                // get the value
                object value = prop.GetValue(obj);

                // any null values just set to DB Null
                if (value == null)
                {
                    param = new SQLiteParameter($":{propName}", Convert.DBNull);
                }
                // strings
                else if (prop.PropertyType == typeof(string))
                {
                    param = new SQLiteParameter($":{propName}", (value as string));
                }
                // Guids
                else if (prop.PropertyType == typeof(Guid) || prop.PropertyType == typeof(Nullable <Guid>))
                {
                    param = new SQLiteParameter($":{propName}", ((Guid)value).ToString());
                }
                // dates of any kind
                else if (prop.PropertyType == typeof(DateTime) || prop.PropertyType == typeof(Nullable <DateTime>))
                {
                    param = new SQLiteParameter($":{propName}", value);
                }
                else if (prop.PropertyType == typeof(DateTimeOffset) || prop.PropertyType == typeof(Nullable <DateTimeOffset>))
                {
                    param = new SQLiteParameter($":{propName}", value);
                }
                // bools are converted to int
                else if (prop.PropertyType == typeof(bool) || prop.PropertyType == typeof(Nullable <bool>))
                {
                    param = new SQLiteParameter($":{propName}", (bool)value ? 1 : 0);
                }
                // enums are int until we create an attribute option to specify text
                else if (prop.PropertyType.IsEnum)
                {
                    param = new SQLiteParameter($":{propName}", (int)value);
                }
                // binary blobs
                else if (prop.PropertyType == typeof(byte[]))
                {
                    param = new SQLiteParameter($":{propName}", value);
                }
                else if (!prop.PropertyType.IsClass)   // everything else thats NOT a class we have not already handled
                {
                    param = new SQLiteParameter($":{propName}", value);
                }

                // add the whole thing to the dictionary
                if (param != null)
                {
                    paras.Add(propName, param);
                }
            }

            // roll the query
            var parameters = paras.Select(n => n.Value.ParameterName).ToArray();

            string query = $"INSERT INTO {tableName} ({String.Join( ",", paras.Keys.ToArray() )}) VALUES ({String.Join( ",", parameters)})";

            SQLiteCommand cmd = new SQLiteCommand(query);

            cmd.CommandType = System.Data.CommandType.Text;
            cmd.Parameters.AddRange(paras.Values.ToArray());

            return(cmd);
        }