2 #include <dtkCoreSupport/dtkAbstractDataFactory.h>
19 return "axlShapeBSplineReader";
23 return "axlShapeBSplineReader";
31 return dtkAbstractDataFactory::instance()->registerDataReaderType(
"axlShapeBSplineReader", QStringList(),
createaxlShapeBSplineReader);
36 QDomElement element = node.toElement();
38 if(element.tagName() ==
"surface"){
39 if(element.attribute(
"type") ==
"patch")
47 return !this->
accept(node);
52 QDomElement element = node.toElement();
55 int pointCount = element.attribute(
"nb_points").toInt();
56 int edgeCount = element.attribute(
"nb_edges").toInt();
57 int faceCount = element.attribute(
"nb_faces").toInt();
58 int orderu = element.attribute(
"orderu").toInt();
59 int orderv = element.attribute(
"orderv").toInt();
61 double *points =
new double[3*pointCount];
62 QVector< QVector<int> >pe;
63 QVector< QVector<int> >pf;
64 QVector< QPair<int,int> >npf;
69 QString name = element.attribute(
"name");
71 surf->setObjectName(name);
75 QString color = element.attribute(
"color");
76 if (!color.isEmpty()) {
77 QStringList colorList = color.split(
" ");
78 if (colorList.size() > 2)
79 surf->
setColor(QColor(colorList.at(0).toInt(), colorList.at(1).toInt(), colorList.at(2).toInt()));
80 if (colorList.size() == 4)
85 QString shader = element.attribute(
"shader");
87 if (!shader.isEmpty()) {
89 dirShader =
":axlShader/shader/" + shader;
90 if (!QFile::exists(dirShader)) {
91 QSettings settings(
"inria",
"dtk");
93 settings.beginGroup(
"shader");
94 dirShader = settings.value(
"path", defaultPath).toString();
95 dirShader.append(
"/" + shader);
101 QString size = element.attribute(
"size");
106 QDomElement pointsElement = element.elementsByTagName(
"points").at(0).toElement();
107 QStringList pointsList = pointsElement.text().simplified().split(QRegExp(
"\\s+"));
109 for (
int k = 0; k < pointsList.size(); k+=3){
110 points[k] = pointsList.at(k).toDouble();
111 points[k+1] =pointsList.at(k+1).toDouble();
112 points[k+2] =pointsList.at(k+2).toDouble();
118 QDomElement edgesElement = element.elementsByTagName(
"edges").at(0).toElement();
119 QDomNodeList edgesList = edgesElement.elementsByTagName(
"edge");
121 for (
int k = 0; k < edgesList.size(); k++) {
122 QDomElement edgeElement = edgesList.at(k).toElement();
124 QDomElement controlPointsElement = edgeElement.elementsByTagName(
"controlPoints").at(0).toElement();
125 QStringList controlpointsList = controlPointsElement.text().simplified().split(QRegExp(
"\\s+"));
126 QVector<int> controlPointIndices;
128 for (
int k = 0; k < controlpointsList.size(); k++){
129 controlPointIndices.append(controlpointsList.at(k).toInt());
132 pe.append(controlPointIndices);
134 tags.append(edgeElement.attribute(
"tag"));
139 QDomElement facesElement = element.elementsByTagName(
"faces").at(0).toElement();
140 QDomNodeList facesList = facesElement.elementsByTagName(
"face");
142 for (
int k = 0; k < facesList.size(); k++) {
143 QDomElement faceElement = facesList.at(k).toElement();
145 QDomElement controlPointsElement = faceElement.elementsByTagName(
"controlPoints").at(0).toElement();
146 QStringList controlpointsList = controlPointsElement.text().simplified().split(QRegExp(
"\\s+"));
147 QVector<int> controlPointIndices;
149 for (
int k = 0; k < controlpointsList.size(); k++){
150 controlPointIndices.append(controlpointsList.at(k).toInt());
153 pf.append(controlPointIndices);
155 QDomElement edgeIndicesElement = faceElement.elementsByTagName(
"nbpts").at(0).toElement();
156 QStringList edgeIndicesList = edgeIndicesElement.text().simplified().split(QRegExp(
"\\s+"));
157 QPair<int,int> np = QPair<int,int>(edgeIndicesList.at(0).toInt(),edgeIndicesList.at(1).toInt());
162 surf->
setSurface(orderu,orderv,pointCount,edgeCount,faceCount, points,pe,pf,npf);
165 for(
int i = 0; i < tags.size(); i++){
Edge * getEdge(int i)
Return edge.
dtkAbstractDataReader * createaxlShapeBSplineReader(void)
QString identifier(void) const
bool reject(const QDomNode &node)
void setShader(const QString &shader)
QStringList handled(void) const
static bool registered(void)
void setSurface(int order_u, int order_v, int nbpoints, int nbEdges, int nbFaces, double *points, QVector< QVector< int > > pe, QVector< QVector< int > >pf, QVector< QPair< int, int > >npf)
Create a surface.
QString description(void) const
bool accept(const QDomNode &node)
void setOpacity(const double &opacity)
axlAbstractData * read(const QDomNode &node)
Class axlShapeBSpline defines a set of boundary curves (Edges) and bspline surface patches (Face)...
void setSize(const double &size)
void setColor(double r, double g, double b)
Class axlAbstractData defines an API for all type of axel data.