Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef VLXWrapper_Core_INCLUDE_ONCE
00033 #define VLXWrapper_Core_INCLUDE_ONCE
00034
00035 #include <vlCore/VLXClassWrapper.hpp>
00036 #include <vlCore/VLXRegistry.hpp>
00037 #include <vlCore/VLXSerializer.hpp>
00038 #include <vlCore/VLXValue.hpp>
00039 #include <vlCore/vlxutils.hpp>
00040
00041 #define VL_SERIALIZER_VERSION 100
00042
00043 #define VLX_IMPORT_CHECK_RETURN(Condition, Obj) \
00044 if (!(Condition)) \
00045 { \
00046 s.signalImportError( Say("Line %n : condition failed : %s\n\tsee %s : %n\n") << (Obj).lineNumber() << #Condition << __FILE__ << __LINE__ ); \
00047 return; \
00048 }
00049
00050 #define VLX_IMPORT_CHECK_RETURN_NULL(Condition, Obj) \
00051 if (!(Condition)) \
00052 { \
00053 s.signalImportError( Say("Line %n : condition failed : %s\n\tsee %s : %n\n") << (Obj).lineNumber() << #Condition << __FILE__ << __LINE__ ); \
00054 return NULL; \
00055 }
00056
00057 namespace vl
00058 {
00059 inline VLXValue export_AABB(const AABB& aabb)
00060 {
00061 VLXValue value ( new VLXStructure("<vl::AABB>") );
00062 *value.getStructure() << "MinCorner" << vlx_toValue(aabb.minCorner());
00063 *value.getStructure() << "MaxCorner" << vlx_toValue(aabb.maxCorner());
00064 return value;
00065 }
00066
00067 inline AABB import_AABB(const VLXStructure* vlx)
00068 {
00069 AABB aabb;
00070
00071 VL_CHECK( vlx->tag() == "<vl::AABB>" )
00072
00073 for(size_t i=0; i<vlx->value().size(); ++i)
00074 {
00075 const std::string& key = vlx->value()[i].key();
00076 const VLXValue& value = vlx->value()[i].value();
00077 if (key == "MinCorner")
00078 {
00079 VL_CHECK(value.type() == VLXValue::ArrayReal)
00080 aabb.setMinCorner( vlx_vec3(value.getArrayReal()) );
00081 }
00082 else
00083 if (key == "MaxCorner")
00084 {
00085 VL_CHECK(value.type() == VLXValue::ArrayReal)
00086 aabb.setMaxCorner( vlx_vec3(value.getArrayReal()) );
00087 }
00088 }
00089
00090 return aabb;
00091 }
00092
00093 inline VLXValue export_Sphere(const Sphere& sphere)
00094 {
00095 VLXValue value ( new VLXStructure("<vl::Sphere>") );
00096 *value.getStructure() << "Center" << vlx_toValue(sphere.center());
00097 *value.getStructure() << "Radius" << sphere.radius();
00098 return value;
00099 }
00100
00101 inline Sphere import_Sphere(const VLXStructure* vlx)
00102 {
00103 Sphere sphere;
00104
00105 VL_CHECK( vlx->tag() == "<vl::Sphere>" )
00106
00107 for(size_t i=0; i<vlx->value().size(); ++i)
00108 {
00109 const std::string& key = vlx->value()[i].key();
00110 const VLXValue& value = vlx->value()[i].value();
00111 if (key == "Center")
00112 {
00113 VL_CHECK(value.type() == VLXValue::ArrayReal)
00114 sphere.setCenter( vlx_vec3(value.getArrayReal()) );
00115 }
00116 else
00117 if (key == "Radius")
00118 {
00119 VL_CHECK(value.type() == VLXValue::Real)
00120 sphere.setRadius( (real)value.getReal() );
00121 }
00122 }
00123
00124 return sphere;
00125 }
00126 }
00127
00128 #endif