Beispiel #1
0
JNIEXPORT jfloatArray JNICALL Java_de_tesis_dynaware_javafx_graphics_importers_fbx_JFbxLib_getMeshVertices(JNIEnv *env, jobject obj, jint attributeIndex) {

	// Check FBX file has been opened.
	if (!isOpen()) { throwFileClosedException(env); }

	// Check attribute index bounds for safety.
	if (!checkAttributeBounds(attributeIndex)) { throwArrayOutOfBoundsException(env); }

	// Check attribute type for safety.
	if (!isValidType(attributeIndex, FbxNodeAttribute::EType::eMesh)) { return NULL; }

	FbxMesh* mesh = (FbxMesh*)currentNode->GetNodeAttributeByIndex(attributeIndex);

	FbxVector4 *controlPoints    = mesh->GetControlPoints();
	const int controlPointsCount = mesh->GetControlPointsCount();

	jfloatArray vertices = env->NewFloatArray(3*controlPointsCount);

	// Check memory could be allocated.
	if (vertices == NULL) {	throwOutOfMemoryError(env); }

	for (int i=0; i<controlPointsCount; i++)	{
		jfloat vertex[3];

		vertex[0] = controlPoints[i][0];
		vertex[1] = controlPoints[i][1];
		vertex[2] = controlPoints[i][2];

		env->SetFloatArrayRegion(vertices, 3*i, 3, vertex);
	}

	return vertices;
}
Beispiel #2
0
int HttpMime::addUpdateSuffixMimeMap(MimeSetting *pSetting,
                                     char *pSuffixes, int update)
{
    pSuffixes = StringTool::strTrim(pSuffixes);
    pSuffixes = StringTool::strLower(pSuffixes, pSuffixes);
    char *p = pSuffixes;
    while (1)
    {
        p = strtok(pSuffixes, ", \t");
        if (!p)
            return 0;
        pSuffixes = NULL;
        p = StringTool::strTrim(p);
        while (*p == '.')
            ++p;
        if (*p == 0)
            continue;
        if (!isValidType(p))
            continue;
        if (strcmp(p, "default") == 0)
        {
            m_pDefault = pSetting;
            continue;
        }
        if (!m_pSuffixMap->addUpdateMapping(p, pSetting, update))
            continue;
    }

}
static Aurora::FileType detectType(const Common::UString &file) {
	Aurora::FileType type = TypeMan.getFileType(file);
	if (isValidType(type))
		return type;

	return Aurora::kFileTypeNone;
}
Beispiel #4
0
JNIEXPORT void JNICALL Java_de_tesis_dynaware_javafx_graphics_importers_fbx_JFbxLib_triangulate(JNIEnv *env, jobject obj, jint attributeIndex) {

	// Check FBX file has been opened.
	if (!isOpen()) { throwFileClosedException(env); }

	// Check attribute index bounds for safety.
	if (!checkAttributeBounds(attributeIndex)) { throwArrayOutOfBoundsException(env); }

	// Check attribute type for safety.
	if (!isValidType(attributeIndex, FbxNodeAttribute::EType::eMesh) &&
		!isValidType(attributeIndex, FbxNodeAttribute::EType::ePatch) &&
		!isValidType(attributeIndex, FbxNodeAttribute::EType::eNurbs) &&
		!isValidType(attributeIndex, FbxNodeAttribute::EType::eNurbsSurface)) { return; }

	FbxGeometryConverter *converter = new FbxGeometryConverter(sdkManager);
	converter->Triangulate(currentNode->GetNodeAttributeByIndex(attributeIndex), true);
}
bool RObject::canAccommodateStructure (RData *new_data) {
	RK_TRACE (OBJECTS);
	RK_ASSERT (new_data->getDataLength () >= 5);
	RK_ASSERT (new_data->getDataType () == RData::StructureVector);

	if (!isValidName (new_data->getStructureVector ()[0])) return false;
	if (!isValidType (new_data->getStructureVector ()[1])) return false;
	return true;
}
Beispiel #6
0
/*
Function: setIdentifierType(std::vector<int> type)

Parameters:
std::vector<int> type: A vector of tokens is used to determine the data type
of the current symbol. 

Description: Allows the caller to specify the data type of the symbol
table entry. This function will return false if the supplied vector contains
an invalid data type. 
*/
bool symbolTableEntry::setIdentifierType(std::vector<int> type) {
	// check if the incoming vector contains a valid data type
	entryType = isValidType(type);

	if(entryType != -1){
		identifierType = type;
		return true;
	}

	else return false;
}
Beispiel #7
0
JNIEXPORT jboolean JNICALL Java_de_tesis_dynaware_javafx_graphics_importers_fbx_JFbxLib_isTriangleMesh(JNIEnv *env, jobject obj, jint attributeIndex) {

	// Check FBX file has been opened.
	if (!isOpen()) { throwFileClosedException(env); }

	// Check attribute index bounds for safety.
	if (!checkAttributeBounds(attributeIndex)) { throwArrayOutOfBoundsException(env); }

	// Check attribute type for safety.
	if (!isValidType(attributeIndex, FbxNodeAttribute::EType::eMesh)) { return false; }

	return ((FbxMesh*) currentNode->GetNodeAttributeByIndex(attributeIndex))->IsTriangleMesh();
}
Beispiel #8
0
const Pizza::Pizza*		Waiter::getPizza(const std::string& command)
{
  std::string			type;
  std::string			size;
  std::stringstream		ss;
  Pizza::TypePizza		enumType;
  Pizza::TaillePizza		enumSize;

  ss << command;
  ss >> type >> size;
  enumType = isValidType(type);
  enumSize = isValidSize(size);
  if (enumSize && enumType)
      return (new Pizza::Pizza(enumType, enumSize));
  return (NULL);
}
Beispiel #9
0
JNIEXPORT jintArray JNICALL Java_de_tesis_dynaware_javafx_graphics_importers_fbx_JFbxLib_getMeshFaceSmoothingGroups(JNIEnv *env, jobject obj, jint attributeIndex) {

	// Check FBX file has been opened.
	if (!isOpen()) { throwFileClosedException(env); }

	// Check attribute index bounds for safety.
	if (!checkAttributeBounds(attributeIndex)) { throwArrayOutOfBoundsException(env); }

	// Check attribute type for safety.
	if (!isValidType(attributeIndex, FbxNodeAttribute::EType::eMesh)) { return NULL; }

	FbxMesh* mesh = (FbxMesh*)currentNode->GetNodeAttributeByIndex(attributeIndex);

	FbxGeometryElementSmoothing* smoothingElement = mesh->GetElementSmoothing(0);

	// If smoothing is not defined explicitly, try to convert from normals. Convert edge-smoothing to face-smoothing.
	if (!smoothingElement || smoothingElement->GetMappingMode() == FbxGeometryElement::eByEdge) {

		FbxGeometryConverter geometryConverter(sdkManager);
		if (!smoothingElement) {
			geometryConverter.ComputeEdgeSmoothingFromNormals(mesh);
			smoothingElement = mesh->GetElementSmoothing(0);
		}
		if (smoothingElement->GetMappingMode() == FbxGeometryElement::eByEdge) {
			geometryConverter.ComputePolygonSmoothingFromEdgeSmoothing(mesh);
		}
	}

	const int polygonCount = mesh->GetPolygonCount();

	jintArray faceSmoothingGroups = env->NewIntArray(polygonCount);

	// Check memory could be allocated.
	if (faceSmoothingGroups == NULL) { throwOutOfMemoryError(env); }

	for (int i=0; i<polygonCount; i++) {
		jint iValue = smoothingElement->GetDirectArray().GetAt(i);
		env->SetIntArrayRegion(faceSmoothingGroups, i, 1, &iValue);
	}

	return faceSmoothingGroups;
}
Beispiel #10
0
/*!
 * \brief Constructs a new account entry for the specified account which is deserialize from
 *        the specified \a stream.
 * \throws Throws ParsingException when an parsing error occurs.
 */
Field::Field(AccountEntry *tiedAccount, istream &stream)
{
    BinaryReader reader(&stream);
    const int version = reader.readByte();
    if (version != 0x0 && version != 0x1) {
        throw ParsingException("Field version is not supported.");
    }
    m_name = reader.readLengthPrefixedString();
    m_value = reader.readLengthPrefixedString();
    byte type = reader.readByte();
    if (!isValidType(type)) {
        throw ParsingException("Field type is not supported.");
    }
    m_type = static_cast<FieldType>(type);
    // read extended header for version 0x1
    if (version == 0x1) {
        const uint16 extendedHeaderSize = reader.readUInt16BE();
        // currently there's nothing to read here
        m_extendedData = reader.readString(extendedHeaderSize);
    }
    m_tiedAccount = tiedAccount;
}
Beispiel #11
0
JNIEXPORT jfloatArray JNICALL Java_de_tesis_dynaware_javafx_graphics_importers_fbx_JFbxLib_getMeshTexCoords(JNIEnv *env, jobject obj, jint attributeIndex) {

	// Check FBX file has been opened.
	if (!isOpen()) { throwFileClosedException(env); }

	// Check attribute index bounds for safety.
	if (!checkAttributeBounds(attributeIndex)) { throwArrayOutOfBoundsException(env); }

	// Check attribute type for safety.
	if (!isValidType(attributeIndex, FbxNodeAttribute::EType::eMesh)) { return NULL; }

	FbxMesh* mesh = (FbxMesh*)currentNode->GetNodeAttributeByIndex(attributeIndex);

	// Currently we only read from the first layer.
	FbxLayerElementUV *firstLayer = mesh->GetElementUV(0);

	if (firstLayer==NULL) {	return NULL; }

	const int uvCount = firstLayer->GetDirectArray().GetCount();

	jfloatArray texCoords = env->NewFloatArray(2*uvCount);
	if (texCoords == NULL) {
		return NULL;
	}

	for (int i=0; i<uvCount; i++) {
		jfloat uv[2];

		// Note that we invert the 'v' index to match the JavaFX (DirectX?) convention.
		uv[0] = firstLayer->GetDirectArray().GetAt(i)[0];
		uv[1] = 1-firstLayer->GetDirectArray().GetAt(i)[1];

		env->SetFloatArrayRegion(texCoords, 2*i, 2, uv);
	}

	return texCoords;
}
Beispiel #12
0
expv 
compile_intrinsic_call(ID id, expv args) {
    intrinsic_entry *ep = NULL;
    int found = 0;
    int nArgs = 0;
    int nIntrArgs = 0;
    int i;
    expv ret = NULL;
    expv a = NULL;
    TYPE_DESC tp = NULL, ftp;
    list lp;
    INTR_OPS iOps = INTR_END;
    const char *iName = NULL;
    expv kindV = NULL;
    int typeNotMatch = 0;
    int isVarArgs = 0;
    EXT_ID extid;

    if (SYM_TYPE(ID_SYM(id)) != S_INTR) {
      //fatal("%s: not intrinsic symbol", __func__);

      // declarea as intrinsic but not defined in the intrinc table

      SYM_TYPE(ID_SYM(id)) = S_INTR;

      if (args == NULL) {
        args = list0(LIST);
      }

      if (ID_TYPE(id) == NULL) implicit_declaration(id);
      tp = ID_TYPE(id);
      //tp = BASIC_TYPE_DESC(TYPE_SUBR);

      expv symV = expv_sym_term(F_FUNC, NULL, ID_SYM(id));

      ftp = function_type(tp);
      TYPE_SET_INTRINSIC(ftp);

      extid = new_external_id_for_external_decl(ID_SYM(id), ftp);
      ID_TYPE(id) = ftp;
      PROC_EXT_ID(id) = extid;
      if (TYPE_IS_EXTERNAL(tp)){
	ID_STORAGE(id) = STG_EXT;
      }
      else{
	EXT_PROC_CLASS(extid) = EP_INTRINSIC;
      }

      ret = expv_cons(FUNCTION_CALL, tp, symV, args);
      return ret;
    }

    ep = &(intrinsic_table[SYM_VAL(ID_SYM(id))]);
    iOps = INTR_OP(ep);
    iName = ID_NAME(id);

    /* Count a number of argument, first. */
    nArgs = 0;
    if (args == NULL) {
        args = list0(LIST);
    }
    FOR_ITEMS_IN_LIST(lp, args) {
        nArgs++;
    }

    /* Search an intrinsic by checking argument types. */
    found = 0;
    for (;
         ((INTR_OP(ep) == iOps) &&
          ((strcasecmp(iName, INTR_NAME(ep)) == 0) ||
           !(isValidString(INTR_NAME(ep)))));
         ep++) {

        kindV = NULL;
        typeNotMatch = 0;
        isVarArgs = 0;

        /* Check a number of arguments. */
        if (INTR_N_ARGS(ep) < 0 ||
            INTR_N_ARGS(ep) == nArgs) {
            /* varriable args or no kind arg. */
            if (INTR_N_ARGS(ep) < 0) {
                isVarArgs = 1;
            }
            nIntrArgs = nArgs;
        } else if (INTR_HAS_KIND_ARG(ep) &&
                   ((INTR_N_ARGS(ep) + 1) == nArgs)) {
            /* could be intrinsic call with kind arg. */

            expv lastV = expr_list_get_n(args, nArgs - 1);
            if (lastV == NULL) {
                return NULL;    /* error recovery */
            }
            if (EXPV_KW_IS_KIND(lastV)) {
                goto gotKind;
            }
            tp = EXPV_TYPE(lastV);
            if (!(isValidType(tp))) {
                return NULL;    /* error recovery */
            }
            if (TYPE_BASIC_TYPE(tp) != TYPE_INT) {
                /* kind arg must be integer type. */
                continue;
            }

            gotKind:
            nIntrArgs = INTR_N_ARGS(ep);
            kindV = lastV;
        } else {
            continue;
        }

        /* The number of arguments matchs. Then check types. */
        for (i = 0; i < nIntrArgs; i++) {
            a = expr_list_get_n(args, i);
            if (a == NULL) {
                return NULL;    /* error recovery */
            }
            tp = EXPV_TYPE(a);
            if (!(isValidType(tp))) {
	      //return NULL;    /* error recovery */
	      continue;
            }
            if (compare_intrinsic_arg_type(a, tp,
                                           ((isVarArgs == 0) ?
                                            INTR_ARG_TYPE(ep)[i] :
                                            INTR_ARG_TYPE(ep)[0])) != 0) {
                /* Type mismatch. */
                typeNotMatch = 1;
                break;
            }
        }
        if (typeNotMatch == 1) {
            continue;
        } else {
            found = 1;
            break;
        }
    }

    if (found == 1) {
        /* Yes we found an intrinsic to use. */
        SYMBOL sp = NULL;
        expv symV = NULL;

        /* Then we have to determine return type. */
        if (INTR_RETURN_TYPE(ep) != INTR_TYPE_NONE) {
            tp = get_intrinsic_return_type(ep, args, kindV);
            if (!(isValidType(tp))) {
	      //fatal("%s: can't determine return type.", __func__);
	      //return NULL;
	      tp = BASIC_TYPE_DESC(TYPE_GNUMERIC_ALL);
            }
        } else {
            tp = BASIC_TYPE_DESC(TYPE_SUBR);
        }

        /* Finally find symbol for the intrinsic and make it expv. */
        sp = find_symbol((char *)iName);
        if (sp == NULL) {
            fatal("%s: symbol '%s' is not created??",
                  __func__,
                  INTR_NAME(ep));
            /* not reached */
            return NULL;
        }
        symV = expv_sym_term(F_FUNC, NULL, sp);
        if (symV == NULL) {
            fatal("%s: symbol expv creation failure.", __func__);
            /* not reached */
            return NULL;
        }

        ftp = function_type(tp);
        TYPE_SET_INTRINSIC(ftp);
        /* set external id for functionType's type ID.
         * dont call declare_external_id() */
        extid = new_external_id_for_external_decl(ID_SYM(id), ftp);
        ID_TYPE(id) = ftp;
        PROC_EXT_ID(id) = extid;
        if(TYPE_IS_EXTERNAL(tp)){
           ID_STORAGE(id) = STG_EXT;
        }else{
           EXT_PROC_CLASS(extid) = EP_INTRINSIC;
        }
        ret = expv_cons(FUNCTION_CALL, tp, symV, args);
    }

    if (ret == NULL) {
        error_at_node((expr)args,
                      "argument(s) mismatch for an intrinsic '%s()'.",
                      iName);
    }
    return ret;
}
bool DOMFileSystemBase::supportsToURL() const
{
    ASSERT(isValidType(m_type));
    return m_type != FileSystemTypeIsolated;
}
Beispiel #14
0
int HttpMime::addUpdateMIME( char * pType, char * pDesc, const char * &reason, int update )
{
    pType = StringTool::strtrim( pType );
    pDesc = StringTool::strtrim( pDesc );
    if ( !isValidMimeType(pDesc) )
    {
        reason = "invalid MIME description";
        return -1;
    }
    if ( strlen( pDesc ) > MAX_MIME_LEN )
    {
        reason = "MIME description is too long";
        return -1;
    }

    pType = StringTool::strlower( pType, pType );
    pDesc = StringTool::strlower( pDesc, pDesc );
    MIMESetting * pSetting = m_pMIMEMap->findMIME( pDesc );
    if ( pSetting )
    {
        if ( strcmp( pDesc, pSetting->getMIME()->c_str() ) != 0 )
        {
//            LOG_WARN(("[MIME] File %s line %d: MIME type with different parameter"
//                    " is not allowed, current: \"%s\" new: \"%s\", new one is used.",
//                            pFilePath, lineNo, pSetting->getMIME()->c_str(), pDesc));
            AutoStr2 * pMime = ::getMIME( pDesc );
            pSetting->setMIME( pMime );
        }
    }
    else
    {
        pSetting = m_pMIMEMap->addMIME( pDesc );
        if ( !pSetting )
        {
            reason = "invalid MIME type";
            return -1;
        }
    }
    char * p = pType;
    while( 1 )
    {
        p = strtok( pType, ", " );
        if ( !p )
            return 0;
        pType = NULL;
        p = StringTool::strtrim( p );
        while( *p == '.' )
            ++p;
        if ( *p == 0 )
        {
            continue;
        }
        if ( !isValidType(p) )
        {
            continue;
        }
        if ( strcmp( p, "default" ) == 0 )
        {
            m_pDefault = pSetting;
            continue;
        }
        if ( !m_pSuffixMap->addUpdateMapping( p, pSetting, update ) )
        {
            continue;
        }
    }
}
Beispiel #15
0
JNIEXPORT jintArray JNICALL Java_de_tesis_dynaware_javafx_graphics_importers_fbx_JFbxLib_getMeshFaces(JNIEnv *env, jobject obj, jint attributeIndex) {

	// Check FBX file has been opened.
	if (!isOpen()) { throwFileClosedException(env); }

	// Check attribute index bounds for safety.
	if (!checkAttributeBounds(attributeIndex)) { throwArrayOutOfBoundsException(env); }

	// Check attribute type for safety.
	if (!isValidType(attributeIndex, FbxNodeAttribute::EType::eMesh)) { return NULL; }

	FbxMesh* mesh = (FbxMesh*)currentNode->GetNodeAttributeByIndex(attributeIndex);

	bool byPolygonVertex = false;
	bool index           = false;
	bool indexToDirect   = false;
	bool direct          = false;

	FbxLayerElementUV *firstLayer = mesh->GetElementUV(0);
	if (firstLayer!=NULL) {
		byPolygonVertex = firstLayer->GetMappingMode()==FbxLayerElement::EMappingMode::eByPolygonVertex;
		index           = firstLayer->GetReferenceMode()==FbxLayerElement::EReferenceMode::eIndex;
		indexToDirect   = firstLayer->GetReferenceMode()==FbxLayerElement::EReferenceMode::eIndexToDirect;
		direct          = firstLayer->GetReferenceMode()==FbxLayerElement::EReferenceMode::eDirect;
	}

	const int polygonCount = mesh->GetPolygonCount();

	jintArray faces = env->NewIntArray(6*polygonCount);

	// Check memory could be allocated.
	if (faces == NULL) { throwOutOfMemoryError(env); }

	for (int i=0; i<polygonCount; i++) {
		jint face[6];

		// Assume we are working with a triangle mesh.
		face[0] = mesh->GetPolygonVertex(i,0);
		face[2] = mesh->GetPolygonVertex(i,1);
		face[4] = mesh->GetPolygonVertex(i,2);

		if (byPolygonVertex && (index || indexToDirect)) {
			face[1] = mesh->GetTextureUVIndex(i, 0);
			face[3] = mesh->GetTextureUVIndex(i, 1);
			face[5] = mesh->GetTextureUVIndex(i, 2);
		}
		else if (direct) {
			face[1] = 3*i;
			face[3] = 3*i+1;
			face[5] = 3*i+2;
		}
		else {
			face[1] = 0;
			face[3] = 0;
			face[5] = 0;
		}

		env->SetIntArrayRegion(faces, 6*i, 6, face);
	}

	return faces;
}