Developer documentation | Axl-2.5.1

axlFieldParametricSurfaceWriter.cpp
Go to the documentation of this file.
1 /* axlFieldParametricSurfaceWriter.cpp ---
2  *
3  * Author: Anais Ducoffe
4  * Copyright (C) 2013 - Anais Ducoffe, Inria.
5  */
6 
7 /* Commentary:
8  *
9  */
10 
11 /* Change log:
12  *
13  */
14 
16 
18 
19 #include <dtkCoreSupport/dtkAbstractData.h>
20 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
21 
22 // /////////////////////////////////////////////////////////////////
23 // axlFieldParametricSurfaceWriter
24 // /////////////////////////////////////////////////////////////////
25 
27 {
28  this->setObjectName(this->description());
29 }
30 
32 {
33 
34 }
35 
37 {
38  return "axlFieldParametricSurfaceWriter";
39 }
40 
42 {
43  return "axlFieldParametricSurfaceWriter";
44 }
45 
47 {
48  return QStringList() << "axlFieldParametricSurface";
49 }
50 
52 {
53  return dtkAbstractDataFactory::instance()->registerDataWriterType("axlFieldParametricSurfaceWriter", QStringList(), createaxlFieldParametricSurfaceWriter);
54 }
55 
56 bool axlFieldParametricSurfaceWriter::accept(dtkAbstractData *data)
57 {
58  axlFieldParametricSurface *spatialField = dynamic_cast<axlFieldParametricSurface *>(data);
59  if(spatialField)
60  return true;
61 
62  return false;
63 }
64 
65 bool axlFieldParametricSurfaceWriter::reject(dtkAbstractData *data)
66 {
67  return !this->accept(data);
68 }
69 
70 QDomElement axlFieldParametricSurfaceWriter::write(QDomDocument *doc, dtkAbstractData *data)
71 {
72  axlFieldParametricSurface *field = dynamic_cast<axlFieldParametricSurface *>(data);
73 
74  QDomElement fieldElement = doc->createElement("field");
75 
77  fieldElement.setAttribute("type", field->identifier());
78 
80  if(field->type() == axlFieldParametricSurface::Int){
81  fieldElement.setAttribute("valueType", "int");
82  }else if(field->type() == axlFieldParametricSurface::Float){
83  fieldElement.setAttribute("valueType", "float");
84  }else{
85  fieldElement.setAttribute("valueType", "double");
86  }
87 
88 
91  fieldElement.setAttribute("support", "point");
92  }else if(field->support() == axlFieldParametricSurface::Cell){
93  fieldElement.setAttribute("support", "cell");
94  }else{
95  fieldElement.setAttribute("support", "custom");
96  }
97 
100  fieldElement.setAttribute("kind", "scalar");
101  }else if(field->kind() == axlFieldParametricSurface::Vector){
102  fieldElement.setAttribute("kind", "vector");
103  }else{
104  fieldElement.setAttribute("kind", "tensor");
105  }
106 
108  axlAbstractDataWriter *function_writer = dynamic_cast<axlAbstractDataWriter *>(dtkAbstractDataFactory::instance()->writer(field->getFunction()->identifier()+"Writer"));
109  qDebug() << Q_FUNC_INFO << field->getFunction()->identifier();
110  if(function_writer){
111  qDebug() << Q_FUNC_INFO << "writer found for function";
112  QDomElement functionElement = function_writer->write(doc, field->getFunction());
113  fieldElement.appendChild(functionElement);
114  }
115 
116 
117  return fieldElement;
118 }
119 
120 
121 
122 QDomElement axlFieldParametricSurfaceWriter::elementByWriter(axlAbstractDataWriter *axl_writer, QDomDocument *doc, dtkAbstractData *data)
123 {
124  QDomElement element;
125 
126  if(!axl_writer)
127  return element;
128 
129  if(!axl_writer->accept(data))
130  return element;
131 
132  element = axl_writer->write(doc, data);
133 
134  return element;
135 }
136 
137 dtkAbstractDataWriter *createaxlFieldParametricSurfaceWriter(void)
138 {
140 }
141 
Class axlFieldParametricSurface defines an API for field which owns a BSpline Surface as a function a...
virtual bool accept(dtkAbstractData *data)=0
axlAbstractData * getFunction(void)
Returns the Bspline function which determines the values of the parametric field. ...
virtual QString identifier(void) const
Returns the identifier of the field "axlFieldParametricSurface".
virtual Kind kind(void)
QDomElement write(QDomDocument *doc, dtkAbstractData *data)
virtual Support support(void)
dtkAbstractDataWriter * createaxlFieldParametricSurfaceWriter(void)
virtual Type type(void)
virtual QDomElement write(QDomDocument *doc, dtkAbstractData *data)=0