Exemple #1
0
        static void Main(string[] args)
        {
            List <CompontParam> param_list = new List <CompontParam>();
            CompontParam        param      = new CompontParam();

            param.name  = "test";
            param.param = new List <double>();
            param.param.Add(11);
            param_list.Add(param);
            RayLineCluster input = new RayLineCluster();

            input.ray_cluster = new List <RayLine>();
            RayLine line = new RayLine();

            line.start_point   = new Vector3();
            line.normal_line   = new Vector3();
            line.start_point.x = 1;
            line.start_point.y = 2;
            line.start_point.z = 3;
            line.normal_line.x = 4;
            line.normal_line.y = 5;
            line.normal_line.z = 6;

            input.ray_cluster.Add(line);
            List <RayLineCluster> output = new List <RayLineCluster>();

            TBTfront.Ant ant = new TBTfront.Ant();
            int          res = ant.clacLight(param_list, input, output);

            Console.WriteLine(output.Count);
            Console.WriteLine(output[0].ray_cluster[0].start_point.x);
            Console.WriteLine(output[0].ray_cluster[0].normal_line.y);
            Console.ReadKey();
        }
Exemple #2
0
        public void genRays(RayLineCluster rayline_cluster, double ds = 0)
        {
            // 调后台生成光线
            TBTfront.Ant ant = new TBTfront.Ant();
            List <TBTfront.CompontParam> list_data = new List <TBTfront.CompontParam>();

            list_data.Add(this);
            List <TBTfront.RayLineCluster> rayline_list = new List <TBTfront.RayLineCluster>();
            CalcOption opt = new CalcOption();

            opt.is_ign_non_intersection = true;
            opt.is_ign_restriction      = true;
            ant.clacLight(list_data, rayline_cluster, rayline_list, opt);
            rayline_cluster = rayline_list[1];
        }
Exemple #3
0
        public void update()
        {
            // 调后台生成场
            TBTfront.Ant ant = new TBTfront.Ant();
            List <TBTfront.CompontParam> list_data = new List <TBTfront.CompontParam>();

            list_data.Add(this);
            this.field = new TBTfront.FieldBase();
            ant.clacField(list_data, this.field, this.field);
            // 调后台生成光线
            List <TBTfront.RayLineCluster> rayline_list = new List <TBTfront.RayLineCluster>();
            CalcOption opt = new CalcOption();

            ant.clacLight(list_data, this.rayline_cluster, rayline_list, opt);
            this.rayline_cluster = rayline_list[1];
        }
Exemple #4
0
        static public vtkAlgorithmOutput calcRestriction(CompontData data)
        {
            //calculation::RayTracing rayTracing(this);
            Restriction rest = (Restriction)data.restriction;

            if (rest == null)
            {
                return(null);
            }

            // 调后台生成光线
            TBTfront.Ant ant = new TBTfront.Ant();
            List <TBTfront.CompontParam> list_data = new List <TBTfront.CompontParam>();

            list_data.Add(rest);
            list_data.Add(data);
            List <TBTfront.RayLineCluster> rayline_list = new List <TBTfront.RayLineCluster>();
            RayLineCluster rayline_cluster = new RayLineCluster();
            CalcOption     opt             = new CalcOption();

            opt.is_ign_non_intersection = true;
            opt.is_ign_restriction      = true;
            ant.clacLight(list_data, rayline_cluster, rayline_list, opt);
            rayline_cluster = rayline_list[2];


            vtkPoints points = vtkPoints.New();

            foreach (var ray in rayline_cluster.ray_cluster)
            {
                points.InsertNextPoint(ray.start_point.x,
                                       ray.start_point.y,
                                       ray.start_point.z);
            }

            vtkPolyData polyData = vtkPolyData.New();

            polyData.SetPoints(points);

            vtkDelaunay2D delaunay = vtkDelaunay2D.New();

            delaunay.SetInput(polyData);
            delaunay.Update();
            return(delaunay.GetOutputPort());
        }
Exemple #5
0
        static public vtkProp3D genRayActor(List <RayLineCluster> data)
        {
            vtkPoints    points    = vtkPoints.New();
            vtkCellArray pLineCell = vtkCellArray.New();

            vtkLine p1   = vtkLine.New();
            int     cout = 0;

            System.Windows.Forms.MessageBox.Show("cluster.start_radius:" + data.Count.ToString());
            for (int i = 0; i < data.Count; i++)
            {
                RayLineCluster cluster = data[i];
                if (i != data.Count - 1)
                {
                    // 第一个的起点连第二次的起点
                    List <RayLine> rays_start = cluster.ray_cluster;
                    List <RayLine> rays_end   = data[i + 1].ray_cluster;
                    for (int j = 0; j < rays_start.Count; j++)
                    {
                        points.InsertNextPoint(rays_start[j].start_point.x,
                                               rays_start[j].start_point.y, rays_start[j].start_point.z);
                        points.InsertNextPoint(rays_end[j].start_point.x,
                                               rays_end[j].start_point.y, rays_end[j].start_point.z);

                        p1.GetPointIds().SetId(0, cout++);
                        p1.GetPointIds().SetId(1, cout++);
                        pLineCell.InsertNextCell(p1);
                    }
                }
                else
                {
                    foreach (var line in cluster.ray_cluster)
                    {
                        points.InsertNextPoint(line.start_point.x,
                                               line.start_point.y, line.start_point.z);
                        points.InsertNextPoint(
                            line.start_point.x + 0.5 * line.normal_line.x,
                            line.start_point.y + 0.5 * line.normal_line.y,
                            line.start_point.z + 0.5 * line.normal_line.z);
                        p1.GetPointIds().SetId(0, cout++);
                        p1.GetPointIds().SetId(1, cout++);
                        pLineCell.InsertNextCell(p1);
                    }
                }
            }

            vtkPolyData pointsData = vtkPolyData.New();

            pointsData.SetPoints(points); //获得网格模型中的几何数据:点集
            pointsData.SetLines(pLineCell);

            vtkPolyDataMapper pointMapper = vtkPolyDataMapper.New();

            pointMapper.SetInput(pointsData);
            pointMapper.Update();

            vtkActor actor = vtkActor.New();

            actor.SetMapper(pointMapper);
            actor.GetProperty().SetColor(1, 0, 0);
            return(actor);
        }