Beispiel #1
0
int SkpModel::LoadFaces(){
	int out = 0;
	SUResult res;

	for (int i=0; i<entities_.size(); i++){
		size_t num_faces;
		SUEntitiesGetNumFaces(entities_[i], &num_faces);
		if (num_faces > 0){
			std::vector<SUFaceRef> faces(num_faces);
			res = SUEntitiesGetFaces(entities_[i], num_faces, &faces[0], &num_faces);
			if (res != SU_ERROR_NONE)
				std::cout << "Error in loading faces \n";

			for (int j=0; j<faces.size(); j++)
				faces_.push_back(faces[j]);
			
			/*
			std::cout << num_faces << "\n";
			SUMeshHelperRef mesh = SU_INVALID;
			std::cout << "Here \n";
			res = SUMeshHelperCreate(&mesh, faces[0]);
			size_t num_vertices;
			SUMeshHelperGetNumVertices(mesh, &num_vertices);
			SUMeshHelperRelease(&mesh);
			*/
		}
	}
	return out;
}
Beispiel #2
0
void ModelWriter::visitFaces(SUEntitiesRef ents, VisitorFunc func, bool recursive, Transform transform)
{
	size_t count =0;
	SUEntitiesGetNumFaces(ents,&count);

	vector<SUFaceRef> faces(count);
	SUEntitiesGetFaces(ents,count,faces.data(),&count);

	for(int i=0; i < count; i++){
		(*this.*func)(faces[i], transform);
	}

	SUEntitiesGetNumGroups(ents,&count);
	vector<SUGroupRef> groups(count);
	SUEntitiesGetGroups(ents,count,groups.data(),&count);


	for(int i=0; i < count; i++){
		SUEntitiesRef ents2 = SU_INVALID;
		SUGroupGetEntities(groups[i],&ents2);

		Transform t;
		SUGroupGetTransform(groups[i], (SUTransformation*)&t);
		visitFaces(ents2,func,true, transform * t);
	}

	if(recursive) {
		
		SUEntitiesGetNumInstances(ents,&count);
		vector<SUComponentInstanceRef> instances(count);
		SUEntitiesGetInstances(ents,count,instances.data(),&count);
	
		for(int i=0; i < count; i++){
			
			Transform t;
			SUComponentDefinitionRef def = SU_INVALID;
			SUEntitiesRef ents2 = SU_INVALID;

			SUComponentInstanceGetTransform(instances[i],(SUTransformation*)&t);
			SUComponentInstanceGetDefinition(instances[i],&def);
			SUComponentDefinitionGetEntities(def,&ents2);

			visitFaces(ents2,func,true, transform * t);
		}
	}
}
Beispiel #3
0
int SkpModel::Entities2AllComponentCount(SUEntitiesRef entities){

	int out = 0;	
	if (SUIsInvalid(entities))
		return 1;
	
	size_t instanceCount = 0;
  SUResult res =  SUEntitiesGetNumInstances(entities, &instanceCount);
  if (res != SU_ERROR_NONE)
    return 1;
	IncrementInstances(instanceCount);

  /*	
	if (instanceCount > 0) {
		std::vector<SUComponentInstanceRef> instances(instanceCount);
		std::vector<SUEntitiesRef> entities2(instanceCount);
		SUEntitiesGetInstances(entities, instanceCount,
													 &instances[0], &instanceCount);
		out += Instances2Entities(&instances, &entities2);

		for (size_t i = 0; i < instanceCount; i++) {
			out += count_all_components_entities(entities2[i]);
		}
	}
	*/

	size_t groupCount = 0;
	res =  SUEntitiesGetNumGroups(entities, &groupCount);
  if (res != SU_ERROR_NONE)
    return 1;
	IncrementGroups(groupCount); 

	/*
	if (groupCount > 0){
		std::vector<SUGroupRef> groups(groupCount);
		std::vector<SUEntitiesRef> entities2(groupCount);
		SUEntitiesGetGroups(entities, groupCount, &groups[0], &groupCount);
		out += Groups2Entities(&groups, &entities2);
		for (size_t i=0; i < groupCount; i++){
			out += count_all_components_entities(entities2[i]);
		}
	}
	*/

	size_t edgeCount = 0;
	res = SUEntitiesGetNumEdges(entities, true,	&edgeCount);
  if (res != SU_ERROR_NONE)
    return 1;
	IncrementEdges(edgeCount);

	size_t guideCount = 0;
	res =  SUEntitiesGetNumGuidePoints(entities, &guideCount);
  if (res != SU_ERROR_NONE)
    return 1;
	IncrementGuides(guideCount);

	size_t curveCount = 0;
	res =  SUEntitiesGetNumCurves(entities, &curveCount);
  if (res != SU_ERROR_NONE)
    return 1;
	IncrementCurves(curveCount);

	size_t imCount = 0;
	res =  SUEntitiesGetNumImages(entities, &imCount);
  if (res != SU_ERROR_NONE)
    return 1;
	IncrementImages(imCount);

  size_t faceCount = 0;
  res = SUEntitiesGetNumFaces(entities, &faceCount);
  if (res != SU_ERROR_NONE)
    return 1;
	IncrementFaces(faceCount);

	return out;	
	
}