src/cpp/NativeGL.cpp \
src/cpp/NgonData.cpp \
src/cpp/NgonGeneralData.cpp \
- src/cpp/NgonPolylineData.cpp
+ src/cpp/NgonPolylineData.cpp \
+ src/cpp/TriangleMeshData.cpp \
+ src/cpp/TriangleMeshFecData.cpp
GIWS_WRAPPERS = src/jni/graphic_objects.giws.xml
libscigraphic_objects_la-NativeGL.lo \
libscigraphic_objects_la-NgonData.lo \
libscigraphic_objects_la-NgonGeneralData.lo \
- libscigraphic_objects_la-NgonPolylineData.lo
+ libscigraphic_objects_la-NgonPolylineData.lo \
+ libscigraphic_objects_la-TriangleMeshData.lo \
+ libscigraphic_objects_la-TriangleMeshFecData.lo
am_libscigraphic_objects_la_OBJECTS = $(am__objects_2) \
$(am__objects_3) $(am__objects_4) $(am__objects_5) \
$(am__objects_6)
src/cpp/NativeGL.cpp \
src/cpp/NgonData.cpp \
src/cpp/NgonGeneralData.cpp \
- src/cpp/NgonPolylineData.cpp
+ src/cpp/NgonPolylineData.cpp \
+ src/cpp/TriangleMeshData.cpp \
+ src/cpp/TriangleMeshFecData.cpp
GIWS_WRAPPERS = src/jni/graphic_objects.giws.xml
GATEWAY_C_SOURCES = sci_gateway/c/gw_graphic_objects.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-NgonData.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-NgonGeneralData.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-NgonPolylineData.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-TriangleMeshData.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-TriangleMeshFecData.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-createGraphicObject.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-dataModel.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscigraphic_objects_la-deleteGraphicObject.Plo@am__quote@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscigraphic_objects_la-NgonPolylineData.lo `test -f 'src/cpp/NgonPolylineData.cpp' || echo '$(srcdir)/'`src/cpp/NgonPolylineData.cpp
+libscigraphic_objects_la-TriangleMeshData.lo: src/cpp/TriangleMeshData.cpp
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscigraphic_objects_la-TriangleMeshData.lo -MD -MP -MF $(DEPDIR)/libscigraphic_objects_la-TriangleMeshData.Tpo -c -o libscigraphic_objects_la-TriangleMeshData.lo `test -f 'src/cpp/TriangleMeshData.cpp' || echo '$(srcdir)/'`src/cpp/TriangleMeshData.cpp
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libscigraphic_objects_la-TriangleMeshData.Tpo $(DEPDIR)/libscigraphic_objects_la-TriangleMeshData.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/cpp/TriangleMeshData.cpp' object='libscigraphic_objects_la-TriangleMeshData.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscigraphic_objects_la-TriangleMeshData.lo `test -f 'src/cpp/TriangleMeshData.cpp' || echo '$(srcdir)/'`src/cpp/TriangleMeshData.cpp
+
+libscigraphic_objects_la-TriangleMeshFecData.lo: src/cpp/TriangleMeshFecData.cpp
+@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscigraphic_objects_la-TriangleMeshFecData.lo -MD -MP -MF $(DEPDIR)/libscigraphic_objects_la-TriangleMeshFecData.Tpo -c -o libscigraphic_objects_la-TriangleMeshFecData.lo `test -f 'src/cpp/TriangleMeshFecData.cpp' || echo '$(srcdir)/'`src/cpp/TriangleMeshFecData.cpp
+@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libscigraphic_objects_la-TriangleMeshFecData.Tpo $(DEPDIR)/libscigraphic_objects_la-TriangleMeshFecData.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/cpp/TriangleMeshFecData.cpp' object='libscigraphic_objects_la-TriangleMeshFecData.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscigraphic_objects_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscigraphic_objects_la-TriangleMeshFecData.lo `test -f 'src/cpp/TriangleMeshFecData.cpp' || echo '$(srcdir)/'`src/cpp/TriangleMeshFecData.cpp
+
mostlyclean-libtool:
-rm -f *.lo
#include "NgonGridData.hxx"
#include "NgonPolylineData.hxx"
#include "TriangleMeshData.hxx"
+#include "TriangleMeshFecData.hxx"
#include "graphicObjectProperties.h"
#define Z_COORDINATES_SHIFT_SET 14
#define Z_COORDINATES_SET 15
+#define NUM_VERTICES 16
+#define NUM_INDICES 17
+#define INDICES 18
+#define VALUES 19
+#define FEC_TRIANGLES 20
#endif
#ifndef TRIANGLE_MESH_DATA_H
#define TRIANGLE_MESH_DATA_H
-#include <string>
-
#include "Data3D.hxx"
extern "C" {
#include "BOOL.h"
-
-#include <stdio.h>
}
/**
- * Triangle mesh data stub class
- * To be fully implemented
+ * Triangle mesh data class
*/
-class TriangleMeshData : public Data3D
+class TriangleMeshData: public Data3D
{
-private :
+protected:
- /** Vertex coordinates array */
+ /**
+ * Vertex coordinates array
+ * Contiguous (x, y, z) triplets
+ */
double* vertices;
- /** Triangle indices array */
+ /** Triangle indices array
+ * Contiguous (v0, v1, v2) triplets
+ */
unsigned int* indices;
+ /**
+ * Per-vertex or per-facet scalar values
+ * Considered to be per-vertex for now
+ * To be correctly implemented
+ */
+ double* values;
+
/** Number of vertices */
unsigned int numberVertices;
/** Number of triangles */
unsigned int numberTriangles;
-public :
- TriangleMeshData(void)
- {
- vertices = NULL;
- indices = NULL;
-
- numberVertices = 0;
- numberTriangles = 0;
- }
+public:
+ TriangleMeshData(void);
/* To be implemented */
- TriangleMeshData(unsigned int numberVertices, unsigned int numberTriangles)
- {
- vertices = new double[3*numberVertices];
-
- indices = new unsigned int[3*numberTriangles];
-
- this->numberVertices = numberVertices;
- this->numberTriangles = numberTriangles;
- }
-
- double* getData(void)
- {
- return vertices;
- }
-
- unsigned int* getIndices(void)
- {
- return indices;
- }
-
- /* To be implemented */
- void setData(double* data)
- {
-
- }
-
- /* To be implemented */
- void setIndices(unsigned int* indices)
- {
-
- }
-
+ TriangleMeshData(unsigned int numberVertices, unsigned int numberTriangles);
+
+ virtual ~TriangleMeshData();
+
+ /**
+ * Returns the property value (identifier) associated to a name
+ * @return the property identifier
+ */
+ int getPropertyFromName(char* propertyName);
+
+ /**
+ * Sets a data property
+ * @param property the property identifier
+ * @param value the property values
+ * @param numElements the number of elements to set
+ * @return 1 if the property has correctly been set, 0 otherwise
+ */
+ int setDataProperty(int property, void* value, int numElements);
+
+ /**
+ * Returns a data property
+ * @param property the property identifier
+ * @return a pointer to the data property
+ */
+ void* getDataProperty(int property);
+
+ /**
+ * Returns the number of vertices composing the mesh
+ * @return the number of vertices
+ */
+ unsigned int getNumVertices();
+
+ /**
+ * Sets the number of vertices
+ * Resizes the vertex array if required
+ * @param numVertices the number of vertices to set
+ * @return 1 if the number of vertices has been correctly set, 0 otherwise (failed allocation)
+ */
+ int setNumVertices(unsigned int numVertices);
+
+ /**
+ * Returns the number of index triplets (number of triangles)
+ * @return the number of index triplets
+ */
+ unsigned int getNumIndices();
+
+ /**
+ * Returns the array of vertex coordinates
+ * @return the array of vertex coordinates
+ */
+ double* getVertices(void);
+
+ /**
+ * Sets vertex values
+ * @param vertices the array of vertex {x,y,z} coordinates to set
+ * @param numElements the number of vertices
+ */
+ void setVertices(double* vertices, unsigned int numElements);
+
+ /**
+ * Returns the array of triangle indices
+ * @return the array of triangle indices
+ */
+ unsigned int* getIndices(void);
+
+ /**
+ * Sets the number of index triplets (number of triangles)
+ * Resizes the array of indices if required
+ * @param numIndices the number of index triplets to set
+ * @return 1 if the number of index triplets has been correctly set, 0 otherwise (failed allocation)
+ */
+ int setNumIndices(unsigned int numIndices);
+
+ /**
+ * Sets the array of index triplet values
+ * @param indices the array of index triplet values
+ * @param numElements the number of triplets
+ */
+ void setIndices(unsigned int* indices, unsigned int numElements);
+
+ /**
+ * Sets the x coordinates
+ * @param data the array of x coordinates
+ * @param numElements the number of x coordinates to set
+ */
+ void setDataX(double* data, unsigned int numElements);
+
+ /**
+ * Sets the y coordinates
+ * @param data the array of y coordinates
+ * @param numElements the number of y coordinates to set
+ */
+ void setDataY(double* data, unsigned int numElements);
+
+ /**
+ * Sets the z coordinates
+ * @param data the array of z coordinates
+ * @param numElements the number of z coordinates to set
+ */
+ void setDataZ(double* data, unsigned int numElements);
+
+ /**
+ * Returns the array of per-vertex values
+ * @return the array of per-vertex values
+ */
+ double* getValues(void);
+
+ /**
+ * Sets the array of per-vertex values
+ * @param data the array of per-vertex values
+ * @param numElements the number of values to set
+ */
+ void setValues(double* data, unsigned int numElements);
+
+ /**
+ * Resets the vertex coordinates
+ */
+ void resetCoordinates(void);
+
+ /**
+ * Converts a triangle vertex index as seen by Scilab to an internal format triangle vertex index
+ * @param scilabIndex the Scilab index to convert
+ * @returns the internal format triangle vertex index
+ */
+ static unsigned int scilabIndexToIndex(unsigned int scilabIndex);
};
#endif
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Manuel Juliachs
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#ifndef TRIANGLE_MESH_FEC_DATA_H
+#define TRIANGLE_MESH_FEC_DATA_H
+
+#include "Data3D.hxx"
+#include "TriangleMeshData.hxx"
+
+extern "C" {
+#include "BOOL.h"
+}
+
+/**
+ * Fec triangle mesh data class
+ */
+
+class TriangleMeshFecData: public TriangleMeshData
+{
+
+private:
+
+ /**
+ * Fec-specific triangle values array
+ * Each fec triangle is a 5-tuple (number, v0, v1, v2, flag), the numTriangles
+ * values being stored contiguously for each element (numTriangles number values,
+ * numTriangles v0 values, etc.)
+ * The v0, v1, v2 values are duplicate with the parent class' indices.
+ */
+ double* fecValues;
+
+public:
+ TriangleMeshFecData(void);
+
+ /* To be implemented */
+ TriangleMeshFecData(unsigned int numberVertices, unsigned int numberTriangles);
+
+ virtual ~TriangleMeshFecData();
+
+ /**
+ * Returns the property value (identifier) associated to a name
+ * @return the property identifier
+ */
+ int getPropertyFromName(char* propertyName);
+
+ /**
+ * Sets a data property
+ * @param property the property identifier
+ * @param value the property values
+ * @param numElements the number of elements to set
+ * @return 1 if the property has correctly been set, 0 otherwise
+ */
+ int setDataProperty(int property, void* value, int numElements);
+
+ /**
+ * Returns a data property
+ * @param property the property identifier
+ * @return a pointer to the data property
+ */
+ void* getDataProperty(int property);
+
+ /**
+ * Returns the number of index triplets (number of triangles)
+ * @return the number of index triplets
+ */
+ unsigned int getNumIndices();
+
+ /**
+ * Sets the number of number of index triplets (number of triangles)
+ * Resizes the arrays of indices and fec triangle values if required
+ * @param numIndices the number of index triplets to set
+ * @return 1 if the number of index triplets has been correctly set, 0 otherwise (failed allocation)
+ */
+ int setNumIndices(unsigned int numIndices);
+
+ /**
+ * Sets the array of fec triangle values
+ * @param the array of fec triangles values
+ * @param numElements the number of triangles to set
+ */
+ void setFecTriangles(double* data, int numElements);
+
+ /**
+ * Returns the array of fec triangle values
+ * @return the array of fec triangle values
+ */
+ double* getFecTriangles(void);
+};
+
+#endif
#define __GO_DATA_MODEL_COLORS__ "DataModelColors"
+#define __GO_DATA_MODEL_NUM_VERTICES__ "DataModelVertices"
+#define __GO_DATA_MODEL_NUM_INDICES__ "DataModelNumIndices"
#define __GO_DATA_MODEL_INDICES__ "DataModelIndices"
+#define __GO_DATA_MODEL_VALUES__ "DataModelValues"
+
+#define __GO_DATA_MODEL_FEC_TRIANGLES__ "DataModelFecTriangles"
#define __GO_REFERENCED__ "Referenced"
#define __GO_VALID__ "Valid"
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Manuel Juliachs
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "TriangleMeshData.hxx"
+#include "DataProperties.hxx"
+
+extern "C" {
+#include <string.h>
+#include "BOOL.h"
+
+#include "graphicObjectProperties.h"
+}
+
+TriangleMeshData::TriangleMeshData(void)
+{
+ vertices = NULL;
+ indices = NULL;
+ values = NULL;
+
+ numberVertices = 0;
+ numberTriangles = 0;
+}
+
+/* To be correctly implemented */
+TriangleMeshData::TriangleMeshData(unsigned int numberVertices, unsigned int numberTriangles)
+{
+ vertices = new double[3*numberVertices];
+
+ indices = new unsigned int[3*numberTriangles];
+
+ this->numberVertices = numberVertices;
+ this->numberTriangles = numberTriangles;
+}
+
+/* To be correctly implemented */
+TriangleMeshData::~TriangleMeshData(void)
+{
+ if (numberVertices > 0)
+ {
+ delete [] vertices;
+ delete [] values;
+ }
+
+ if (numberTriangles > 0)
+ {
+ delete [] indices;
+ }
+
+}
+
+int TriangleMeshData::getPropertyFromName(char* propertyName)
+{
+ if (strcmp(propertyName, __GO_DATA_MODEL_NUM_VERTICES__) == 0)
+ {
+ return NUM_VERTICES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_NUM_INDICES__) == 0)
+ {
+ return NUM_INDICES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_X__) == 0)
+ {
+ return X_COORDINATES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_Y__) == 0)
+ {
+ return Y_COORDINATES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_Z__) == 0)
+ {
+ return Z_COORDINATES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_COORDINATES__) == 0)
+ {
+ return COORDINATES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_INDICES__) == 0)
+ {
+ return INDICES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_VALUES__) == 0)
+ {
+ return VALUES;
+ }
+ else
+ {
+ return Data3D::getPropertyFromName(propertyName);
+ }
+
+}
+
+
+int TriangleMeshData::setDataProperty(int property, void* value, int numElements)
+{
+ if (property == NUM_VERTICES)
+ {
+ return setNumVertices(*((unsigned int*) value));
+ }
+ else if (property == NUM_INDICES)
+ {
+ return setNumIndices(*((unsigned int*) value));
+ }
+ else if (property == X_COORDINATES)
+ {
+ setDataX((double*) value, numElements);
+ }
+ else if (property == Y_COORDINATES)
+ {
+ setDataY((double*) value, numElements);
+ }
+ else if (property == Z_COORDINATES)
+ {
+ setDataZ((double*) value, numElements);
+ }
+ else if (property == COORDINATES)
+ {
+ setVertices((double*) value, numElements);
+ }
+ else if (property == INDICES)
+ {
+ setIndices((unsigned int*) value, numElements);
+ }
+ else if (property == VALUES)
+ {
+ setValues((double*) value, numElements);
+ }
+ else
+ {
+ return Data3D::setDataProperty(property, value, numElements);
+ }
+
+ return 1;
+}
+
+void* TriangleMeshData::getDataProperty(int property)
+{
+ /* Used for now to return the address of a single unsigned integer */
+ static int localUIntResult;
+
+ if (property == NUM_VERTICES)
+ {
+ localUIntResult = getNumVertices();
+ return &localUIntResult;
+ }
+ else if (property == NUM_INDICES)
+ {
+ localUIntResult = getNumIndices();
+ return &localUIntResult;
+ }
+ else if (property == COORDINATES)
+ {
+ return getVertices();
+ }
+ else if (property == INDICES)
+ {
+ return getIndices();
+ }
+ else if (property == VALUES)
+ {
+ return getValues();
+ }
+ else
+ {
+ return Data3D::getDataProperty(property);
+ }
+}
+
+unsigned int TriangleMeshData::getNumVertices(void)
+{
+ return numberVertices;
+}
+
+/*
+ * Values are considered as being specified per-vertex for now
+ * To be corrected
+ */
+int TriangleMeshData::setNumVertices(unsigned int numVertices)
+{
+ int result;
+
+ result = 1;
+
+ if (numVertices == 0 && numberVertices > 0)
+ {
+ numberVertices = 0;
+
+ delete [] vertices;
+ delete [] values;
+
+ return 1;
+ }
+
+ if (numVertices != this->numberVertices)
+ {
+ double* newVertices = NULL;
+ double* newValues = NULL;
+
+ try
+ {
+ newVertices = new double[3*numVertices];
+ }
+ catch (const std::exception& e)
+ {
+ result = 0;
+ }
+
+ try
+ {
+ newValues = new double[3*numVertices];
+ }
+ catch (const std::exception& e)
+ {
+ result = 0;
+ }
+
+ if (result)
+ {
+ if (this->numberVertices > 0)
+ {
+ delete [] vertices;
+ delete [] values;
+ }
+
+ vertices = newVertices;
+ values = newValues;
+
+ this->numberVertices = numVertices;
+
+ resetCoordinates();
+ }
+ else
+ {
+ /* Failed allocation, nothing is set */
+ if (newVertices != NULL)
+ {
+ delete [] newVertices;
+ }
+
+ if (newValues != NULL)
+ {
+ delete [] newValues;
+ }
+ }
+
+ }
+
+ return result;
+}
+
+unsigned int TriangleMeshData::getNumIndices(void)
+{
+ return numberTriangles;
+}
+
+int TriangleMeshData::setNumIndices(unsigned int numIndices)
+{
+ int result;
+
+ result = 1;
+
+ if (numIndices != this->numberTriangles)
+ {
+ unsigned int* newIndices = NULL;
+
+ try
+ {
+ newIndices = new unsigned int[3*numIndices];
+ }
+ catch (const std::exception& e)
+ {
+ result = 0;
+ }
+
+ if (result)
+ {
+ if (this->numberTriangles > 0)
+ {
+ delete [] indices;
+ }
+
+ indices = newIndices;
+
+ this->numberTriangles = numIndices;
+ }
+ else
+ {
+ /* Failed allocation, nothing is set */
+ if (newIndices != NULL)
+ {
+ delete [] newIndices;
+ }
+ }
+
+ }
+
+ return result;
+}
+
+double* TriangleMeshData::getVertices(void)
+{
+ return vertices;
+}
+
+void TriangleMeshData::setVertices(double* vertices, unsigned int numElements)
+{
+ for (int i = 0; i < numElements; i++)
+ {
+ this->vertices[3*i] = vertices[3*i];
+ this->vertices[3*i+1] = vertices[3*i+1];
+ this->vertices[3*i+2] = vertices[3*i+2];
+ }
+}
+
+unsigned int* TriangleMeshData::getIndices(void)
+{
+ return indices;
+}
+
+void TriangleMeshData::setIndices(unsigned int* indices, unsigned int numElements)
+{
+ for (int i = 0; i < numElements; i++)
+ {
+ this->indices[3*i] = indices[3*i];
+ this->indices[3*i+1] = indices[3*i+1];
+ this->indices[3*i+2] = indices[3*i+2];
+ }
+}
+
+void TriangleMeshData::setDataX(double* data, unsigned int numElements)
+{
+ for (int i = 0; i < numElements; i++)
+ {
+ vertices[3*i] = data[i];
+ }
+}
+
+void TriangleMeshData::setDataY(double* data, unsigned int numElements)
+{
+ for (int i = 0; i < numElements; i++)
+ {
+ vertices[3*i+1] = data[i];
+ }
+}
+
+void TriangleMeshData::setDataZ(double* data, unsigned int numElements)
+{
+ for (int i = 0; i < numElements; i++)
+ {
+ vertices[3*i+2] = data[i];
+ }
+}
+
+void TriangleMeshData::setValues(double* data, unsigned int numElements)
+{
+ for (int i = 0; i < numElements; i++)
+ {
+ values[i] = data[i];
+ }
+}
+
+double* TriangleMeshData::getValues(void)
+{
+ return values;
+}
+
+unsigned int TriangleMeshData::scilabIndexToIndex(unsigned int scilabIndex)
+{
+ return (scilabIndex - 1);
+}
+
+void TriangleMeshData::resetCoordinates(void)
+{
+ for (int i = 0; i < numberVertices; i++)
+ {
+ vertices[3*i] = 0.0;
+ vertices[3*i+1] = 0.0;
+ vertices[3*i+2] = 0.0;
+ }
+}
+
--- /dev/null
+/*
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2010 - DIGITEO - Manuel Juliachs
+ *
+ * This file must be used under the terms of the CeCILL.
+ * This source file is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at
+ * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+ *
+ */
+
+#include "TriangleMeshFecData.hxx"
+#include "TriangleMeshData.hxx"
+#include "DataProperties.hxx"
+
+extern "C" {
+#include <string.h>
+#include "BOOL.h"
+
+#include "graphicObjectProperties.h"
+}
+
+TriangleMeshFecData::TriangleMeshFecData(void)
+{
+ vertices = NULL;
+ indices = NULL;
+ values = NULL;
+ fecValues = NULL;
+
+ numberVertices = 0;
+ numberTriangles = 0;
+}
+
+/* To be correctly implemented */
+TriangleMeshFecData::TriangleMeshFecData(unsigned int numberVertices, unsigned int numberTriangles)
+{
+ vertices = new double[3*numberVertices];
+
+ indices = new unsigned int[3*numberTriangles];
+
+ fecValues = new double[5*numberTriangles];
+
+ this->numberVertices = numberVertices;
+ this->numberTriangles = numberTriangles;
+}
+
+/* To be correctly implemented */
+TriangleMeshFecData::~TriangleMeshFecData(void)
+{
+ if (numberVertices > 0)
+ {
+ delete [] vertices;
+ delete [] values;
+ }
+
+ if (numberTriangles > 0)
+ {
+ delete [] indices;
+ delete [] fecValues;
+ }
+
+ numberVertices = 0;
+ numberTriangles = 0;
+}
+
+int TriangleMeshFecData::getPropertyFromName(char* propertyName)
+{
+ if (strcmp(propertyName, __GO_DATA_MODEL_NUM_INDICES__) == 0)
+ {
+ return NUM_INDICES;
+ }
+ else if (strcmp(propertyName, __GO_DATA_MODEL_FEC_TRIANGLES__) == 0)
+ {
+ return FEC_TRIANGLES;
+ }
+ else
+ {
+ return TriangleMeshData::getPropertyFromName(propertyName);
+ }
+}
+
+
+int TriangleMeshFecData::setDataProperty(int property, void* value, int numElements)
+{
+ if (property == NUM_INDICES)
+ {
+ return setNumIndices(*((unsigned int*) value));
+ }
+ else if (property == FEC_TRIANGLES)
+ {
+ setFecTriangles((double*) value, numElements);
+ }
+ else
+ {
+ return TriangleMeshData::setDataProperty(property, value, numElements);
+ }
+
+ return 1;
+}
+
+void* TriangleMeshFecData::getDataProperty(int property)
+{
+ /* Used for now to return the address of a single unsigned integer */
+ static int localUIntResult;
+
+ if (property == NUM_INDICES)
+ {
+ localUIntResult = getNumIndices();
+ return &localUIntResult;
+ }
+ else if (property == FEC_TRIANGLES)
+ {
+ return getFecTriangles();
+ }
+ else
+ {
+ return TriangleMeshData::getDataProperty(property);
+ }
+
+}
+
+unsigned int TriangleMeshFecData::getNumIndices(void)
+{
+ return numberTriangles;
+}
+
+int TriangleMeshFecData::setNumIndices(unsigned int numIndices)
+{
+ int result;
+
+ result = 1;
+
+ if (numIndices != this->numberTriangles)
+ {
+ unsigned int* newIndices = NULL;
+ double* newFecValues = NULL;
+
+ try
+ {
+ newIndices = new unsigned int[3*numIndices];
+ }
+ catch (const std::exception& e)
+ {
+ result = 0;
+ }
+
+ try
+ {
+ newFecValues = new double[5*numIndices];
+ }
+ catch (const std::exception& e)
+ {
+ result = 0;
+ }
+
+
+ if (result)
+ {
+ if (this->numberTriangles > 0)
+ {
+ delete [] indices;
+ delete [] fecValues;
+ }
+
+ indices = newIndices;
+ fecValues = newFecValues;
+
+ this->numberTriangles = numIndices;
+ }
+ else
+ {
+ /* Failed allocation, nothing is set */
+ if (newIndices != NULL)
+ {
+ delete [] newIndices;
+ }
+
+ if (newFecValues != NULL)
+ {
+ delete [] newFecValues;
+ }
+ }
+
+ }
+
+ return result;
+}
+
+void TriangleMeshFecData::setFecTriangles(double* data, int numElements)
+{
+ for (int i = 0; i < numElements; i++)
+ {
+ indices[3*i] = scilabIndexToIndex((unsigned int) data[numElements+i]);
+ indices[3*i+1] = scilabIndexToIndex((unsigned int) data[2*numElements+i]);
+ indices[3*i+2] = scilabIndexToIndex((unsigned int) data[3*numElements+i]);
+
+ /* Triangle number */
+ fecValues[i] = data[i];
+
+ /* Triangle vertices */
+ fecValues[numElements+i] = data[numElements+i];
+ fecValues[2*numElements+i] = data[2*numElements+i];
+ fecValues[3*numElements+i] = data[3*numElements+i];
+
+ /* Flag */
+ fecValues[4*numElements+i] = data[4*numElements+i];
+ }
+}
+
+double* TriangleMeshFecData::getFecTriangles(void)
+{
+ return fecValues;
+}
+
*/
if (strcmp(_sType, __GO_MATPLOT__) == 0)
{
- newObject = new NgonGridData();
+ newObject = new NgonGridData();
}
else if (strcmp(_sType, __GO_FAC3D__) == 0)
{
}
else if (strcmp(_sType, __GO_FEC__) == 0)
{
- newObject = new TriangleMeshData();
+ newObject = new TriangleMeshFecData();
}
else
{
public static final String __GO_DATA_MODEL_COLORS__ = "DataModelColors";
+public static final String __GO_DATA_MODEL_NUM_VERTICES__ = "DataModelVertices";
+public static final String __GO_DATA_MODEL_NUM_INDICES__ = "DataModelNumIndices";
public static final String __GO_DATA_MODEL_INDICES__ = "DataModelIndices";
+public static final String __GO_DATA_MODEL_VALUES__ = "DataModelValues";
+
+public static final String __GO_DATA_MODEL_FEC_TRIANGLES__ = "DataModelFecTriangles";
public static final String __GO_REFERENCED__ = "Referenced";
public static final String __GO_VALID__ = "Valid";
@DECLARE@ __GO_DATA_MODEL_COLORS__ @EQUAL@ "DataModelColors" @END@
+@DECLARE@ __GO_DATA_MODEL_NUM_VERTICES__ @EQUAL@ "DataModelVertices" @END@
+@DECLARE@ __GO_DATA_MODEL_NUM_INDICES__ @EQUAL@ "DataModelNumIndices" @END@
@DECLARE@ __GO_DATA_MODEL_INDICES__ @EQUAL@ "DataModelIndices" @END@
+@DECLARE@ __GO_DATA_MODEL_VALUES__ @EQUAL@ "DataModelValues" @END@
+
+@DECLARE@ __GO_DATA_MODEL_FEC_TRIANGLES__ @EQUAL@ "DataModelFecTriangles" @END@
@DECLARE@ __GO_REFERENCED__ @EQUAL@ "Referenced" @END@
@DECLARE@ __GO_VALID__ @EQUAL@ "Valid" @END@