示例#1
0
        private bool TryReadNurbsPatchPar(CaratReader reader)
        {
            if (!reader.Match("NURBS_PATCH_PAR"))
            {
                return(false);
            }

            var id = reader.ReadInteger();

            reader.Expect(":");

            var ctrlPtsNodes = default(int?);
            var nctrl        = default(int?);
            var pdeg         = default(int?);
            var uknot        = default(List <double>);

            if (reader.Match("NURBS_1D"))
            {
                while (!reader.EOF)
                {
                    if (reader.Match("CTRL_PTS"))
                    {
                        reader.Expect("=");
                        reader.Expect("CTRL_PTS_PAR");
                        ctrlPtsNodes = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("NCTRL"))
                    {
                        reader.Expect("=");
                        nctrl = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("PDEG"))
                    {
                        reader.Expect("=");
                        pdeg = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("UKNOT"))
                    {
                        reader.Expect("=");
                        uknot = reader.ReadDoubleList();
                        continue;
                    }

                    break;
                }
            }
            else
            {
                throw reader.NewUnexpectedTokenException();
            }

            // TODO: process data
            Console.WriteLine($"NURBS_PATCH_PAR ID {id} ...");

            return(true);
        }
示例#2
0
        private bool TryReadNurbsPatch(CaratReader reader)
        {
            if (!reader.Match("NURBS_PATCH"))
            {
                return(false);
            }

            var id = reader.ReadInteger();

            reader.Expect(":");

            var nctrl      = default(int?);
            var mctrl      = default(int?);
            var pdeg       = default(int?);
            var qdeg       = default(int?);
            var uknot      = default(List <double>);
            var vknot      = default(List <double>);
            var trimmingID = default(int?);
            var addPar     = default(int?);

            if (reader.Match("NURBS_2D"))
            {
                while (!reader.EOF)
                {
                    if (reader.Match("CTRL_PTS"))
                    {
                        reader.Expect("=");
                        reader.Expect("CTRL_PTS_NODES");
                        var ctrl_pts_nodes = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("NCTRL"))
                    {
                        if (nctrl != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        nctrl = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("MCTRL"))
                    {
                        if (mctrl != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        mctrl = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("PDEG"))
                    {
                        if (pdeg != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        pdeg = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("QDEG"))
                    {
                        if (qdeg != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        qdeg = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("UKNOT"))
                    {
                        if (uknot != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        uknot = reader.ReadDoubleList();
                        continue;
                    }

                    if (reader.Match("VKNOT"))
                    {
                        if (vknot != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        vknot = reader.ReadDoubleList();
                        continue;
                    }

                    if (reader.Match("TRIMMING"))
                    {
                        if (trimmingID != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        reader.Expect("B_REP");
                        trimmingID = reader.ReadInteger();
                        continue;
                    }

                    if (reader.Match("ADD_PAR"))
                    {
                        if (addPar != null)
                        {
                            throw reader.NewDuplicateTokenException();
                        }

                        reader.Expect("=");
                        addPar = reader.ReadInteger();
                        continue;
                    }

                    break;
                }
            }
            else
            {
                throw reader.NewUnexpectedTokenException();
            }

            // TODO: process data
            Console.WriteLine($"NURBS_PATCH ID {id} NCTRL {nctrl} MCTRL {mctrl} ...");

            return(true);
        }