static void Main(string[] args) { OcTree <TestObj> tree = new OcTree <TestObj>(20, new Vector3(0, 0, 0)); tree.Insert(new TestObj(Vector3.Empty, new Vector3(1, 1, 1))); tree.Insert(new TestObj(new Vector3(5, 0, 0), new Vector3(1, 1, 1))); }
/// <summary> /// Creates (or finds an existing) vertex for the given position /// </summary> /// <param name="position"></param> /// <returns></returns> public static Vertex GetVertexForPosition(OcTree <Vertex> vertexCollection, Vec3d position) { var vertex = new Vertex { Position = position }; if (vertexCollection.Insert(vertex, position)) { return(vertex); } return(vertexCollection.FindClosest(position)); }
public void AddSceneEntity(T entity) { sceneGraph.Insert(entity); //sceneGraphEntities.Add(0, entity); }
public void OnNewDataSource(IAtom[] atoms, IBond[] bonds, Vector3 origin, Bounds3D bounds) { sceneGraph = new OcTree<ChemEntity>((int)bounds.radius * 2, -bounds.min); /*screenEntities.Add(new BondAngle(device, atoms[0], atoms[1], atoms[2])); screenEntities[0].Init(device); postSceneWorldEntities.Add(new BoundingBoxEntity(new BoundingBox(bounds.min, bounds.max), false, Color.LightGray.ToArgb())); postSceneWorldEntities[0].Init(device); postSceneWorldEntities.Add(new SphereAxis3D()); postSceneWorldEntities[1].Init(device);*/ sceneGraphEntities = sceneGraph.SceneItems; // create molecule entities foreach (IAtom atom in atoms) { AtomEntity aentity = AtomEntity.BuildEntity(atom); sceneGraph.Insert(aentity); /*ScreenLabelVSpaceEntity entity = new ScreenLabelVSpaceEntity(atom.ID + ":" + aentity.UId.ToString(), (Vector3)aentity.Position3D); entity.Init(device); screenEntities.Add(entity);*/ /*AtomSymbolEntity entity = new AtomSymbolEntity(aentity); entity.Init(device); postSceneViewEntities.Add(entity);*/ } //foreach (IBond bond in bonds) //{ //sceneGraph.Insert(new BondE); //} scheme.SetOutputDescription(coDesc); scheme.SetupScene(origin, bounds.radius); // pass throught scheme & effects IGeometryCreator[] schStreams = scheme.GetAtomStreams(); DataFields[] efxFields = null; //effect.DesiredData(out efxFields, false); DataFields[][] allStreams = new DataFields[1 + (efxFields != null ? 1 : 0 )][]; //if (efxFields != null) // allStreams[1] = efxFields; if (scheme.HandlesAtoms && atoms != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetAtomData(atoms, geomStream); } schStreams = scheme.GetBondStreams(); if (scheme.HandlesBonds && bonds != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetBondData(bonds, geomStream); } }
public void OnNewDataSource(IAtom[] atoms, IBond[] bonds, Vector3 origin, Bounds3D bounds) { sceneGraph = new OcTree <ChemEntity>((int)bounds.radius * 2, -bounds.min); /*screenEntities.Add(new BondAngle(device, atoms[0], atoms[1], atoms[2])); * screenEntities[0].Init(device); * * postSceneWorldEntities.Add(new BoundingBoxEntity(new BoundingBox(bounds.min, bounds.max), false, Color.LightGray.ToArgb())); * postSceneWorldEntities[0].Init(device); * postSceneWorldEntities.Add(new SphereAxis3D()); * postSceneWorldEntities[1].Init(device);*/ sceneGraphEntities = sceneGraph.SceneItems; // create molecule entities foreach (IAtom atom in atoms) { AtomEntity aentity = AtomEntity.BuildEntity(atom); sceneGraph.Insert(aentity); /*ScreenLabelVSpaceEntity entity = new ScreenLabelVSpaceEntity(atom.ID + ":" + aentity.UId.ToString(), (Vector3)aentity.Position3D); * entity.Init(device); * screenEntities.Add(entity);*/ /*AtomSymbolEntity entity = new AtomSymbolEntity(aentity); * entity.Init(device); * postSceneViewEntities.Add(entity);*/ } //foreach (IBond bond in bonds) //{ //sceneGraph.Insert(new BondE); //} scheme.SetOutputDescription(coDesc); scheme.SetupScene(origin, bounds.radius); // pass throught scheme & effects IGeometryCreator[] schStreams = scheme.GetAtomStreams(); DataFields[] efxFields = null; //effect.DesiredData(out efxFields, false); DataFields[][] allStreams = new DataFields[1 + (efxFields != null ? 1 : 0)][]; //if (efxFields != null) // allStreams[1] = efxFields; if (scheme.HandlesAtoms && atoms != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetAtomData(atoms, geomStream); } schStreams = scheme.GetBondStreams(); if (scheme.HandlesBonds && bonds != null) { GeomDataBufferStream[] geomStream = new GeomDataBufferStream[schStreams.Length]; for (int i = 0; i < geomStream.Length; i++) { allStreams[0] = schStreams[i].Fields; GeomDataTransformer.CreateBufferStream(allStreams, out geomStream[i]); } // fill buffer stream scheme.SetBondData(bonds, geomStream); } }
static void Main(string[] args) { OcTree<TestObj> tree = new OcTree<TestObj>(20, new Vector3(0, 0, 0)); tree.Insert(new TestObj(Vector3.Empty, new Vector3(1, 1, 1))); tree.Insert(new TestObj(new Vector3(5, 0, 0), new Vector3(1, 1, 1))); }