Simple Volume Tracker in C++ ============================ The purpose of this tutorial is to show you a simplified version of the real Volume Tracker that is implemented in the CompuCell3D. We will guide you step by step how to develop the code. ANd later show you how to compile it and how to use it in a simulation. Note that this will be rather a toy module because real VolumeTracker is loaded with every simulation we cannot have two modules incrementing and decrementing volumes . our version will only do printouts each time the cell's volume is incremented or decremented. The reason we begin with this toy example is because it is probably the simples lattice monitor plugin one can write. We assume that you cloned CompuCell3D repository to ``~/src-cc3d/CompuCell3D`` To begin, lets launch Twedit++. Then from CC3D C++ Menu lets select ``Generate New Module...`` and you should see the dialog: |svp_001| We need to fill module name, point to the directory where the code should be generated and select if the code should be generated in Developer Zone or in the main code layout. We will pick main layout, call module ``SimpleVolumeTracker`` and pick ``/Users/m/src-cc3d/CompuCell3D/CompuCell3D/core/CompuCell3D/plugins`` as a module directory. The Module Type is ``Plugin`` and we pick ``LatticeMonitor`` as a Plugin functionality |svp_002| After, we click ``OK`` Twedit++ will generate code template that compiles out-of-the-box but does nothing interesting. The important thing is that Twedit++ generates a lot of boiler-plate code that we would need to write manually. This is a very tedious task and by using Twedit++ we saved ourselves a lot of work. |svp_003| It is our task to make this code useful. We will do it now. Here is the template of the core function (``field3DChange``) that Each Lattice Monitor needs to implement. .. code-block:: cpp void SimpleVolumeTrackerPlugin::field3DChange(const Point3D &pt, CellG *newCell, CellG *oldCell) { //This function will be called after each successful pixel copy - field3DChange does usual housekeeping tasks to make sure state of cells, and state of the lattice is update if (newCell){ //PUT YOUR CODE HERE }else{ //PUT YOUR CODE HERE } if (oldCell){ //PUT YOUR CODE HERE }else{ //PUT YOUR CODE HERE } } Here is how we can modify it: .. code-block:: cpp void SimpleVolumeTrackerPlugin::field3DChange(const Point3D &pt, CellG *newCell, CellG *oldCell) { //This function will be called after each successful pixel copy - field3DChange does usual housekeeping tasks to make sure state of cells, and state of the lattice is update if (newCell){ cerr<<"Cell id "<id<<" increases volume by 1"<id<<" decreases volume by 1"< inside XML - in my case ``/Users/m/src-cc3d/CompuCell3D/CompuCell3D/core/Demos/Models/cellsort/cellsort_2D/Simulation/cellsort_2D.xml``: .. code-block:: xml 10 10000 10 1 2 25 2.0 0 16 2 11 16 16 2
40 0 5 Condensing,NonCondensing then run it using .. code-block:: python -m cc3d.run_script -i /Users/m/src-cc3d/CompuCell3D/CompuCell3D/core/Demos/Models/cellsort/cellsort_2D/cellsort_2D.cc3d and we should get printouts printouts that look as follows: .. code-block:: console Cell id 148 decreases volume by 1 Cell id 149 increases volume by 1 Cell id 162 decreases volume by 1 Cell id 83 increases volume by 1 Cell id 82 decreases volume by 1 Cell id 189 increases volume by 1 Cell id 188 decreases volume by 1 Congratulations. You have developed your first CompuCell3D plugins. Even though the SimpleVolumeTracker in its current form is not terribly useful it taught us the mechanics of adding new plugin, compiling cc3d and using new plugin with freshly compiled CC3D. In the next chapters we will develop more pragmatic examples .. |svp_001| image:: images/simple_volume_tracker_001.png .. |svp_002| image:: images/simple_volume_tracker_002.png .. |svp_003| image:: images/simple_volume_tracker_003.png