/** * Processes a single fragment into fragment(s). Override this method * in your implementation to process individual drawables into more * fragments. * * @param input * Single fragment to convert * @param env * Contextual compilation information * @return * The converted input data. The default implementation of this * method returns the input data. */ public virtual FragmentList process(Fragment drawable, FilterEnv env) { FragmentList output = new FragmentList(); output.Add(drawable); return(output); }
//フラグメントを作成 public GameObject CreateFragment() { GameObject f = HomographyFragment.CreateFragment("fragment", mHomographyShader, mTextureBuffer); f.transform.SetParent(mHomographyController.transform); FragmentList.Add(f.GetComponent <HomographyFragment> ()); return(f); }
public Text AddText(string name, string textValue = "") { var item = new Text(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Text"), Name = name, TextValue = textValue }; FragmentList.Add(item); return(item); }
public Placeholder AddPlaceholder(string name, string @class = "", string property = "") { var item = new Placeholder(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Placeholder"), Name = name, Class = @class, Property = property }; FragmentList.Add(item); return(item); }
public ContainerFragment AddContainerFragment(string name, string primary = "", string secondary = "") { var item = new ContainerFragment(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("ContainerFragment"), Name = name, Primary = primary, Secondary = secondary }; FragmentList.Add(item); return(item); }
public TextBlock AddTextBlock() { var name = CreateContainerFragmentBody("TextBlock"); var textBlock = new TextBlock(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("TextBlock"), Name = name, Primary = name, Secondary = "Empty1" }; FragmentList.Add(textBlock); SetContainerLinks(textBlock); return(textBlock); }
public Annotation AddAnnotation() { var name = CreateContainerFragmentBody("Annotation"); var annotation = new Annotation(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Annotation"), Name = name, Primary = name, Secondary = "Empty1" }; FragmentList.Add(annotation); SetContainerLinks(annotation); return(annotation); }
public Profile AddProfile() { var name = CreateContainerFragmentBody("Profile"); var profile = new Profile(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Profile"), Name = name, Primary = name, Secondary = "Empty1" }; FragmentList.Add(profile); SetContainerLinks(profile); return(profile); }
public Function AddFunction(string functionName = "") { var name = "Function" + FragmentList.Count; var function = new Function(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Function"), Name = name, Primary = "Empty1", Secondary = "Empty1", FunctionName = functionName }; FragmentList.Add(function); SetContainerLinks(function); return(function); }
public Segment AddSegment(string @class = "", string cardinality = "") { var name = CreateContainerFragmentBody("Segment"); var segment = new Segment(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Segment"), Name = name, Primary = name, Secondary = "Empty1", Class = @class, Cardinality = cardinality }; FragmentList.Add(segment); SetContainerLinks(segment); return(segment); }
public Lookup AddLookup(string noMatch = "", string class1 = "", string property1 = "", string class2 = "", string property2 = "") { var name = CreateContainerFragmentBody("Lookup"); var lookup = new Lookup(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Lookup"), Name = name, Primary = name, Secondary = "Empty1", NoMatch = noMatch, Class1 = class1, Property1 = property1, Class2 = class2, Property2 = property2 }; FragmentList.Add(lookup); SetContainerLinks(lookup); return(lookup); }
public Condition AddCondition(string class1 = "", string property1 = "", string comparison = "", string class2 = "", string property2 = "", string lit = "", string useLit = "") { var name = CreateContainerFragmentBody("Condition"); var condition = new Condition(GenDataBase) { GenObject = ((GenObject)GenObject).CreateGenObject("Condition"), Name = name, Primary = name, Secondary = "Empty1", Class1 = class1, Property1 = property1, Comparison = comparison, Class2 = class2, Property2 = property2, Lit = lit, UseLit = useLit }; FragmentList.Add(condition); SetContainerLinks(condition); return(condition); }
private static FragmentList Decode(IBinaryReader patchReader) { var l = new FragmentList(); while(patchReader.BaseStream.Position != patchReader.BaseStream.Length) { var start = patchReader.ReadUInt32(); var end = patchReader.ReadUInt32(); var len = patchReader.ReadUInt32(); var data = patchReader.ReadBytes((int)len); var f = new Fragment { Start = (int)start, End = (int)end, Length = (int)len, Data = data }; //Console.WriteLine("chunk:" + start + " " + end + " " + len); l.Add(f); } return l; }
// FragmentFilter overrides public override FragmentList process(FeatureList input, FilterEnv env) { FragmentList output = new FragmentList(); //cuidado con las entidades dentro del for int i = 0; Vector3 scale; Vector3 distanceScale; Vector3 mScale = new Vector3 (1,1,1); float lWidth = 1; if (Scale != null) { scale = Registry.instance().GetEngine("Python").run(Scale).asVec3(); } else { scale = new Vector3(1, 1, 1); } if (CoordScale != null) { distanceScale = Registry.instance().GetEngine("Python").run(CoordScale).asVec3(); } else { distanceScale = new Vector3(1, 1, 1); } if (LineWidth != null) { lWidth = Registry.instance().GetEngine("Python").run(LineWidth).asFloat(); } if (MaterialScale != null) { mScale = Registry.instance().GetEngine("Python").run(MaterialScale).asVec3(); } SceneNode nodeIni = point3d(env.getName(), i, 0, 0, 0, null, env.getSceneMgr()); #if ESCALA_NODO_INICIAL if (Scale != null) { nodeIni.SetScale(Registry.instance().GetEngine("Python").run(Scale).asVec3()); } if (coordScale != null) { Vector3 vec3 = Registry.instance().GetEngine("Python").run(Scale).asVec3(); nodeIni.SetPosition(nodeIni.Position.x * vec3.x, nodeIni.Position.y * vec3.y, nodeIni.Position.z * vec3.z); #if TRACE_BUILDGEOMFILTER System.Console.WriteLine("(" + n.Position.x + "," + n.Position.y + ")"); #endif } #endif Fragment fIni = new Fragment(nodeIni); output.Add(fIni); foreach (Feature feature in input) { //if type of features is Point if (feature.row.Geometry is SharpMap.Geometries.Point) { SharpMap.Geometries.Point p = (SharpMap.Geometries.Point)feature.row.Geometry; i++; SceneNode n = point3d(env.getName(), i, (float)p.X, (float)p.Y, 0, nodeIni, env.getSceneMgr()); n.SetScale(scale); n.SetPosition(n.Position.x * distanceScale.x, n.Position.y * distanceScale.y, n.Position.z * distanceScale.z); Fragment f = new Fragment(n); output.Add(f); } //if type of features is Polygon else if (feature.row.Geometry is SharpMap.Geometries.Polygon) { SharpMap.Geometries.Polygon polygon = (SharpMap.Geometries.Polygon)feature.row.Geometry; ManualObject polygonNode = null; if (polygonNode == null) { polygonNode = env.getSceneMgr().CreateManualObject(env.getName() + "Node_" + i); MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(polygonNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); int numVertices = polygon.ExteriorRing.NumPoints/*/10+1*/; int numValores = 3; double[][] data = new double[numVertices][]; for (int j = 0; j < numVertices; j++) { data[j] = new double[numValores]; } int k = 0; //1 polygon = N vertices foreach (SharpMap.Geometries.Point point in polygon.ExteriorRing.Vertices) { //if (k % 10 == 0) { data[k/*/10*/][0] = point.X; data[k/*/10*/][1] = point.Y; data[k/*/10*/][2] = 0; } k++; //SceneNode n = point3d(env.getName()+i+k, k + 10, (float)point.X * 10.0f, (float)point.Y * 10.0f, 0, nodeIni, env.getSceneMgr()); } for (int j = 0; j < data.GetLength(0); j++) { Glu.gluTessVertex(data[j], 0, new Vector3((float)(data[j][1] * distanceScale.y), (float)(data[j][2] * distanceScale.z), (float)(data[j][0] * distanceScale.x))); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); nodeIni.AttachObject(polygonNode); } i++; } //if type of features is MultiPolygon else if (feature.row.Geometry is SharpMap.Geometries.MultiPolygon) { SharpMap.Geometries.MultiPolygon mp = (SharpMap.Geometries.MultiPolygon)feature.row.Geometry; // 1 MultiPolygon = N polygon foreach (SharpMap.Geometries.Polygon polygon in mp.Polygons) { ManualObject polygonNode = null; if (polygonNode == null) { polygonNode = env.getSceneMgr().CreateManualObject(env.getName() + "Node_" + i); MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(polygonNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); int numVertices = polygon.ExteriorRing.NumPoints; int numValores = 3; double[][] data = new double[numVertices][]; for (int j = 0; j < numVertices; j++) { data[j] = new double[numValores]; } int k = 0; //1 polygon = N vertices foreach (SharpMap.Geometries.Point point in polygon.ExteriorRing.Vertices) { data[k][0] = point.X; data[k][1] = point.Y; data[k][2] = 0; k++; //SceneNode n = point3d(env.getName(), i, (float)point.X, (float)point.Y, 0, nodeIni, env.getSceneMgr()); } for (int j = 0; j < data.GetLength(0); j++) { Glu.gluTessVertex(data[j], 0, new Vector3(((float)data[j][1]) * distanceScale.y, ((float)data[j][2]) * distanceScale.z, ((float)data[j][0]) * distanceScale.x)); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); nodeIni.AttachObject(polygonNode); } i++; } } //if type of features is Line else if (feature.row.Geometry is SharpMap.Geometries.ILineal/*SharpMap.Geometries.LineString*/) { System.Collections.Generic.List<SharpMap.Geometries.ILineal> lineas = new System.Collections.Generic.List<SharpMap.Geometries.ILineal>(); if (feature.row.Geometry is SharpMap.Geometries.MultiLineString) { foreach (SharpMap.Geometries.LineString l in ((SharpMap.Geometries.MultiLineString)(feature.row.Geometry)).LineStrings) { lineas.Add(l); } } else { lineas.Add((SharpMap.Geometries.ILineal)(feature.row.Geometry)); } foreach (SharpMap.Geometries.ILineal line in lineas) { ManualObject lineNode = env.getSceneMgr().CreateManualObject("line" + i); //MaterialPtr material = MaterialManager.Singleton.Create(nameMaterial, //ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); //material.GetTechnique(0).GetPass(0).VertexColourTracking = // (int)TrackVertexColourEnum.TVC_AMBIENT; //material.GetTechnique(0).GetPass(0).SetDepthBias(100); //material.GetTechnique(0).GetPass(0).LightingEnabled = false; int nSeg = 5; // Number of segments on the cap or join pieces BufferParameters param = new BufferParameters(nSeg, BufferParameters.BufferEndCapStyle.CapRound, BufferParameters.BufferJoinStyle.JoinRound, 2); IGeometryFactory<Coord> geometryFactory = new GeometryFactory<Coord>(new CoordSeqFac(new CoordFac(PrecisionModelType.DoubleFloating))); //IWktGeometryReader<Coord> reader = geometryFactory.WktReader; //string txt = feature.row.Geometry.AsText(); ILineString line1 = (ILineString)GeometryConverter.ToNTSGeometry((SharpMap.Geometries.LineString)line, geometryFactory); // (ILineString<Coord>)reader.Read(txt); IGeometry coordBuffer = line1.Buffer(lWidth, param); ICoordinateSequence coords = coordBuffer.Coordinates; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(lineNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); foreach (Coord coord in coords) { double[] data = new double[] { coord.X * distanceScale.x, coord.Y * distanceScale.y, (double.IsNaN(coord.Z) ? 0 : coord.Z) * distanceScale.z }; Glu.gluTessVertex(data, 0, new Vector3((float)data[1], (float)data[2], (float)data[0])); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); i++; nodeIni.AttachObject(lineNode); } if ((feature.row.Geometry is SharpMap.Geometries.Polygon) | (feature.row.Geometry is SharpMap.Geometries.MultiPolygon)) { Fragment f = new Fragment(nodeIni); output.Add(f); } } } i = 0;//breakpoint /*foreach (Fragment fragment in output) { fragment.Node.Scale(0,0,0); }*/ #if TODO // if features are arriving in batch, resolve the color here. // otherwise we will resolve it later in process(feature,env). is_batch = input.Count > 1; batch_feature_color = overall_color; if (is_batch && getColorScript() != null) { ScriptResult r = env.getScriptEngine().run(getColorScript(), env); if (r.isValid()) batch_feature_color = r.asVec4(); else env.getReport().error(r.asString()); } return base.process(input, env); #endif //throw new NotImplementedException(); if (successor != null) { if (successor is FeatureFilter) { FeatureFilter filter = (FeatureFilter)successor; FeatureList l = filter.process(input, env); //FeatureList l = successor.process(input, env); } else if (successor is FragmentFilter) { FragmentFilter filter = (FragmentFilter)successor; FragmentList l = filter.process(output, env); } } return output; }
static int Gather(FragmentList dest, FragmentList src, int cut, int offset) { unchecked { int postend, c, l; var s = src.Head; while(s != src.Tail) { if(s.Value.Start + offset >= cut) break; /* We've gone far enough */ postend = offset + s.Value.Start + s.Value.Length; if(postend <= cut) { /* Save this hunk */ offset += s.Value.Start + s.Value.Length - s.Value.End; dest.Add(s.Value); s = s.Next; } // if else { /* Break up this hunk */ c = cut - offset; if(s.Value.End < c) { c = s.Value.End; } l = cut - offset - s.Value.Start; if(s.Value.Length < l) l = s.Value.Length; offset += s.Value.Start + l - c; Fragment d = new Fragment(); d.Start = s.Value.Start; d.End = c; d.Length = l; d.Data = s.Value.Data; d.Offset = s.Value.Offset; dest.Add(d); s.Value = new Fragment(c, s.Value.End, s.Value.Length - l, s.Value.Offset + l, s.Value.Data); /*s.Value.Start = c; s.Value.Length = s.Value.Length - l; s.Value.Offset = s.Value.Offset + l;*/ break; } // else } src.Head = s; return offset; } }
// FragmentFilter overrides public override FragmentList process(FeatureList input, FilterEnv env) { FragmentList output = new FragmentList(); //cuidado con las entidades dentro del for int i = 0; Vector3 scale; Vector3 distanceScale; Vector3 mScale = new Vector3(1, 1, 1); float lWidth = 1; if (Scale != null) { scale = Registry.instance().GetEngine("Python").run(Scale).asVec3(); } else { scale = new Vector3(1, 1, 1); } if (CoordScale != null) { distanceScale = Registry.instance().GetEngine("Python").run(CoordScale).asVec3(); } else { distanceScale = new Vector3(1, 1, 1); } if (LineWidth != null) { lWidth = Registry.instance().GetEngine("Python").run(LineWidth).asFloat(); } if (MaterialScale != null) { mScale = Registry.instance().GetEngine("Python").run(MaterialScale).asVec3(); } SceneNode nodeIni = point3d(env.getName(), i, 0, 0, 0, null, env.getSceneMgr()); #if ESCALA_NODO_INICIAL if (Scale != null) { nodeIni.SetScale(Registry.instance().GetEngine("Python").run(Scale).asVec3()); } if (coordScale != null) { Vector3 vec3 = Registry.instance().GetEngine("Python").run(Scale).asVec3(); nodeIni.SetPosition(nodeIni.Position.x * vec3.x, nodeIni.Position.y * vec3.y, nodeIni.Position.z * vec3.z); #if TRACE_BUILDGEOMFILTER System.Console.WriteLine("(" + n.Position.x + "," + n.Position.y + ")"); #endif } #endif Fragment fIni = new Fragment(nodeIni); output.Add(fIni); foreach (Feature feature in input) { //if type of features is Point if (feature.row.Geometry is SharpMap.Geometries.Point) { SharpMap.Geometries.Point p = (SharpMap.Geometries.Point)feature.row.Geometry; i++; SceneNode n = point3d(env.getName(), i, (float)p.X, (float)p.Y, 0, nodeIni, env.getSceneMgr()); n.SetScale(scale); n.SetPosition(n.Position.x * distanceScale.x, n.Position.y * distanceScale.y, n.Position.z * distanceScale.z); Fragment f = new Fragment(n); output.Add(f); } //if type of features is Polygon else if (feature.row.Geometry is SharpMap.Geometries.Polygon) { SharpMap.Geometries.Polygon polygon = (SharpMap.Geometries.Polygon)feature.row.Geometry; ManualObject polygonNode = null; if (polygonNode == null) { polygonNode = env.getSceneMgr().CreateManualObject(env.getName() + "Node_" + i); MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(polygonNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); int numVertices = polygon.ExteriorRing.NumPoints /*/10+1*/; int numValores = 3; double[][] data = new double[numVertices][]; for (int j = 0; j < numVertices; j++) { data[j] = new double[numValores]; } int k = 0; //1 polygon = N vertices foreach (SharpMap.Geometries.Point point in polygon.ExteriorRing.Vertices) { //if (k % 10 == 0) { data[k /*/10*/][0] = point.X; data[k /*/10*/][1] = point.Y; data[k /*/10*/][2] = 0; } k++; //SceneNode n = point3d(env.getName()+i+k, k + 10, (float)point.X * 10.0f, (float)point.Y * 10.0f, 0, nodeIni, env.getSceneMgr()); } for (int j = 0; j < data.GetLength(0); j++) { Glu.gluTessVertex(data[j], 0, new Vector3((float)(data[j][1] * distanceScale.y), (float)(data[j][2] * distanceScale.z), (float)(data[j][0] * distanceScale.x))); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); nodeIni.AttachObject(polygonNode); } i++; } //if type of features is MultiPolygon else if (feature.row.Geometry is SharpMap.Geometries.MultiPolygon) { SharpMap.Geometries.MultiPolygon mp = (SharpMap.Geometries.MultiPolygon)feature.row.Geometry; // 1 MultiPolygon = N polygon foreach (SharpMap.Geometries.Polygon polygon in mp.Polygons) { ManualObject polygonNode = null; if (polygonNode == null) { polygonNode = env.getSceneMgr().CreateManualObject(env.getName() + "Node_" + i); MaterialPtr material = MaterialManager.Singleton.Create("Test/ColourPolygon", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); material.GetTechnique(0).GetPass(0).VertexColourTracking = (int)TrackVertexColourEnum.TVC_AMBIENT; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(polygonNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); int numVertices = polygon.ExteriorRing.NumPoints; int numValores = 3; double[][] data = new double[numVertices][]; for (int j = 0; j < numVertices; j++) { data[j] = new double[numValores]; } int k = 0; //1 polygon = N vertices foreach (SharpMap.Geometries.Point point in polygon.ExteriorRing.Vertices) { data[k][0] = point.X; data[k][1] = point.Y; data[k][2] = 0; k++; //SceneNode n = point3d(env.getName(), i, (float)point.X, (float)point.Y, 0, nodeIni, env.getSceneMgr()); } for (int j = 0; j < data.GetLength(0); j++) { Glu.gluTessVertex(data[j], 0, new Vector3(((float)data[j][1]) * distanceScale.y, ((float)data[j][2]) * distanceScale.z, ((float)data[j][0]) * distanceScale.x)); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); nodeIni.AttachObject(polygonNode); } i++; } } //if type of features is Line else if (feature.row.Geometry is SharpMap.Geometries.ILineal /*SharpMap.Geometries.LineString*/) { System.Collections.Generic.List <SharpMap.Geometries.ILineal> lineas = new System.Collections.Generic.List <SharpMap.Geometries.ILineal>(); if (feature.row.Geometry is SharpMap.Geometries.MultiLineString) { foreach (SharpMap.Geometries.LineString l in ((SharpMap.Geometries.MultiLineString)(feature.row.Geometry)).LineStrings) { lineas.Add(l); } } else { lineas.Add((SharpMap.Geometries.ILineal)(feature.row.Geometry)); } foreach (SharpMap.Geometries.ILineal line in lineas) { ManualObject lineNode = env.getSceneMgr().CreateManualObject("line" + i); //MaterialPtr material = MaterialManager.Singleton.Create(nameMaterial, //ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME); //material.GetTechnique(0).GetPass(0).VertexColourTracking = // (int)TrackVertexColourEnum.TVC_AMBIENT; //material.GetTechnique(0).GetPass(0).SetDepthBias(100); //material.GetTechnique(0).GetPass(0).LightingEnabled = false; int nSeg = 5; // Number of segments on the cap or join pieces BufferParameters param = new BufferParameters(nSeg, BufferParameters.BufferEndCapStyle.CapRound, BufferParameters.BufferJoinStyle.JoinRound, 2); IGeometryFactory <Coord> geometryFactory = new GeometryFactory <Coord>(new CoordSeqFac(new CoordFac(PrecisionModelType.DoubleFloating))); //IWktGeometryReader<Coord> reader = geometryFactory.WktReader; //string txt = feature.row.Geometry.AsText(); ILineString line1 = (ILineString)GeometryConverter.ToNTSGeometry((SharpMap.Geometries.LineString)line, geometryFactory); // (ILineString<Coord>)reader.Read(txt); IGeometry coordBuffer = line1.Buffer(lWidth, param); ICoordinateSequence coords = coordBuffer.Coordinates; //Vector3 v = Registry.instance().GetEngine("Python").run(Color, feature, null).asVec3(); MogreTessellationCallbacks callback = new MogreTessellationCallbacks(lineNode, Color, feature); if (nameMaterial != null) { callback.Material = nameMaterial; // "Test/ColourPolygon2"; callback.MaterialScale = mScale; } GLUtessellatorImpl Glu = (GLUtessellatorImpl)GLUtessellatorImpl.gluNewTess(); Glu.gluTessCallback(GLU.GLU_TESS_VERTEX, callback); Glu.gluTessCallback(GLU.GLU_TESS_BEGIN, callback); Glu.gluTessCallback(GLU.GLU_TESS_END, callback); Glu.gluTessCallback(GLU.GLU_TESS_ERROR, callback); Glu.gluTessCallback(GLU.GLU_TESS_COMBINE, callback); Glu.gluTessBeginPolygon(null); Glu.gluTessBeginContour(); foreach (Coord coord in coords) { double[] data = new double[] { coord.X *distanceScale.x, coord.Y *distanceScale.y, (double.IsNaN(coord.Z) ? 0 : coord.Z) * distanceScale.z }; Glu.gluTessVertex(data, 0, new Vector3((float)data[1], (float)data[2], (float)data[0])); } Glu.gluTessEndContour(); Glu.gluTessNormal(0, 0, 1); Glu.gluTessEndPolygon(); i++; nodeIni.AttachObject(lineNode); } if ((feature.row.Geometry is SharpMap.Geometries.Polygon) | (feature.row.Geometry is SharpMap.Geometries.MultiPolygon)) { Fragment f = new Fragment(nodeIni); output.Add(f); } } } i = 0;//breakpoint /*foreach (Fragment fragment in output) * { * fragment.Node.Scale(0,0,0); * }*/ #if TODO // if features are arriving in batch, resolve the color here. // otherwise we will resolve it later in process(feature,env). is_batch = input.Count > 1; batch_feature_color = overall_color; if (is_batch && getColorScript() != null) { ScriptResult r = env.getScriptEngine().run(getColorScript(), env); if (r.isValid()) { batch_feature_color = r.asVec4(); } else { env.getReport().error(r.asString()); } } return(base.process(input, env)); #endif //throw new NotImplementedException(); if (successor != null) { if (successor is FeatureFilter) { FeatureFilter filter = (FeatureFilter)successor; FeatureList l = filter.process(input, env); //FeatureList l = successor.process(input, env); } else if (successor is FragmentFilter) { FragmentFilter filter = (FragmentFilter)successor; FragmentList l = filter.process(output, env); } } return(output); }
private static FragmentList Combine(FragmentList a, FragmentList b) { unchecked { int offset = 0; int post; FragmentList c = new FragmentList(); for(var bh = b.Head; bh != b.Tail; bh = bh.Next) { offset = Gather(c, a, bh.Value.Start, offset); post = Discard(a, bh.Value.End, offset); var ct = new Fragment { Start = bh.Value.Start - offset, End = bh.Value.End - post, Length = bh.Value.Length, Data = bh.Value.Data, Offset = bh.Value.Offset }; c.Add(ct); offset = post; } var t = a.Head; for(; t != a.Tail; t = t.Next) c.Add(t.Value); return c; } }