Field3D
main.cpp File Reference
#include <iostream>
#include <string>
#include <Field3D/DenseField.h>
#include <Field3D/MACField.h>
#include <Field3D/SparseField.h>
#include <Field3D/InitIO.h>
#include <Field3D/Field3DFile.h>
#include <Field3D/Types.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 67 of file main.cpp.

References FieldBase::attribute, SparseField< Data_T >::clear(), DenseField< Data_T >::clear(), Field3DOutputFile::create(), half, initIO(), FieldBase::name, ResizableField< Data_T >::setSize(), Field3DOutputFile::writeScalarLayer(), and Field3DOutputFile::writeVectorLayer().

{
  typedef Field3D::half half; 

  // Call initIO() to initialize standard I/O methods and load plugins ---

  Field3D::initIO();

  // Create a set of fields with different types and bit depths ---

  // ... First a DenseField<half>

  DenseField<half>::Ptr denseField(new DenseField<half>);
  denseField->name = "density_source";
  denseField->attribute = "density";
  denseField->setSize(V3i(50, 50, 50));
  denseField->clear(0.0f);

  // ... Then two SparseFields to make up a moving levelset

  SparseField<float>::Ptr sparseField(new SparseField<float>);
  sparseField->name = "character";
  sparseField->attribute = "levelset";
  sparseField->setSize(V3i(250, 250, 250));
  sparseField->clear(0.0f);
  
  SparseField<V3f>::Ptr sparseVField(new SparseField<V3f>);
  sparseVField->name = "character";
  sparseVField->attribute = "v";
  sparseVField->setSize(V3i(50, 50, 50));
  sparseVField->clear(V3f(0.0f));

  // ... Finally a MACField<V3f>, using the typedefs

  MACField3f::Ptr macField(new MACField3f);
  macField->name = "simulation";
  macField->attribute = "v";
  macField->setSize(V3i(120, 50, 100));
  macField->clear(V3f(0.0f));
  
  // Write the output ---

  Field3DOutputFile out;
  out.create("mixed_file.f3d");
  out.writeScalarLayer<half>(denseField); 
  out.writeScalarLayer<float>(sparseField); 
  out.writeVectorLayer<float>(sparseVField); 
  out.writeVectorLayer<float>(macField); 
}