double AbsoluteQuantitation::applyCalibration(const Feature & component,
    const Feature & IS_component,
    const String & feature_name,
    const String & transformation_model,
    const Param & transformation_model_params)
  {
    // calculate the ratio
    double ratio = calculateRatio(component, IS_component, feature_name);

    // calculate the absolute concentration
    TransformationModel::DataPoints data;
    TransformationDescription tmd(data);
    // tmd.setDataPoints(data);
    tmd.fitModel(transformation_model, transformation_model_params);
    tmd.invert();
    double calculated_concentration = tmd.apply(ratio);

    // AbsoluteQuantitationMethod aqm;
    // double calculated_concentration = aqm.evaluateTransformationModel(
    //   transformation_model, ratio, transformation_model_params);

    // check for less than zero
    if (calculated_concentration < 0.0)
    {
      calculated_concentration = 0.0;
    }

    return calculated_concentration;
  }
  Param AbsoluteQuantitation::fitCalibration(
    const std::vector<AbsoluteQuantitationStandards::featureConcentration> & component_concentrations,
    const String & feature_name,
    const String & transformation_model,
    const Param & transformation_model_params)
  {
    // extract out the calibration points
    TransformationModel::DataPoints data;
    TransformationModel::DataPoint point;
    for (size_t i = 0; i < component_concentrations.size(); i++)
    {
      point.first = component_concentrations[i].actual_concentration/component_concentrations[i].IS_actual_concentration;
      double ratio = calculateRatio(component_concentrations[i].feature, component_concentrations[i].IS_feature,feature_name);
      point.second = ratio/component_concentrations[i].dilution_factor; // adjust based on the dilution factor
      data.push_back(point);
    }

    // fit the data to the model
    TransformationDescription tmd(data);
    // tmd.setDataPoints(data);
    tmd.fitModel(transformation_model, transformation_model_params);
    Param params = tmd.getModelParameters();
    // AbsoluteQuantitationMethod aqm;
    // Param params = aqm.fitTransformationModel(transformation_model, data, transformation_model_params);

    // store the information about the fit
    return params;
  }
Exemple #3
0
IPCCommandResult ES::ImportTmd(Context& context, const IOCtlVRequest& request)
{
  if (!request.HasNumberOfValidVectors(1, 0))
    return GetDefaultReply(ES_EINVAL);

  if (!IOS::ES::IsValidTMDSize(request.in_vectors[0].size))
    return GetDefaultReply(ES_EINVAL);

  std::vector<u8> tmd(request.in_vectors[0].size);
  Memory::CopyFromEmu(tmd.data(), request.in_vectors[0].address, request.in_vectors[0].size);
  return GetDefaultReply(ImportTmd(context, tmd));
}
Exemple #4
0
void SymmetryMod::WeldTriObject (Mesh & mesh, Point3 & N, float offset, float threshold) {
	// Find vertices in target zone of mirror plane:
	BitArray targetVerts;
	targetVerts.SetSize (mesh.numVerts, true);
	targetVerts.ClearAll ();
	for (int i=0; i<mesh.numVerts; i++) {
		float dist = DotProd (N, mesh.verts[i]) - offset;
		if (fabsf(dist) > threshold) continue;
		targetVerts.Set (i);
	}

	// Weld the suitable border vertices:
	MeshDelta tmd(mesh);
	BOOL found = tmd.WeldByThreshold (mesh, targetVerts, threshold);
	tmd.Apply (mesh);
}
Exemple #5
0
void VWeldMod::ModifyTriObject (TimeValue t, ModContext &mc, TriObject *tobj) {
	Mesh &mesh = tobj->GetMesh();
	Interval iv = FOREVER;
	
	float threshold;
	mp_pblock->GetValue (kVwThreshold, t, threshold, iv);
	if (threshold<0.0f) threshold=0.0f;

	// Convert existing selection (at whatever level) to vertex selection:
	BitArray targetVerts;
	ConvertTriSelection (mesh, targetVerts);

	// Weld the vertices
	MeshDelta tmd(mesh);
	BOOL found = tmd.WeldByThreshold (mesh, targetVerts, threshold);
	tmd.Apply (mesh);

	tobj->UpdateValidity (GEOM_CHAN_NUM, iv);
	tobj->UpdateValidity (TOPO_CHAN_NUM, iv);
	tobj->UpdateValidity (VERT_COLOR_CHAN_NUM, iv);
	tobj->UpdateValidity (TEXMAP_CHAN_NUM, iv);
	tobj->UpdateValidity (SELECT_CHAN_NUM, iv);
}
Exemple #6
0
void FExtrudeMod::ModifyTriObject (TimeValue t, ModContext &mc, TriObject *tobj) {
	Mesh &mesh = tobj->GetMesh();
	Interval iv = FOREVER;
	float amount, scale;
	Point3 center;
	int i, j, type;
	
	mp_pblock->GetValue (kFexAmount, t, amount, iv);
	mp_pblock->GetValue (kFexScale, t, scale, iv);
	mp_pblock->GetValue (kFexType, t, type, iv);

	// Extrude the faces -- this just does the topological operation.
	MeshDelta tmd(mesh);
	tmd.ExtrudeFaces (mesh, mesh.faceSel);
	tmd.Apply(mesh);

	// Mark vertices used by selected faces
	BitArray sel;
	sel.SetSize(mesh.getNumVerts());
	for (i=0; i<mesh.getNumFaces(); i++) {
		if (mesh.faceSel[i]) {
			for (int j=0; j<3; j++) sel.Set(mesh.faces[i].v[j],TRUE);
		}
	}

	MeshTempData temp(&mesh);
	Point3 *vertexDir;
	Tab<Point3> centerBasedBuffer;
	if (type<2) {
		int extrusionType = type ? MESH_EXTRUDE_LOCAL : MESH_EXTRUDE_CLUSTER;
		vertexDir = temp.FaceExtDir(extrusionType)->Addr(0);
	} else {
		// We need to move all vertices away from the "center".
		// Compute the center point
		Point3 center;
		mp_base->GetValue(t,&center,iv,CTRL_ABSOLUTE);

		// Create array of vertex directions 
		centerBasedBuffer.SetCount (mesh.numVerts);
		vertexDir = centerBasedBuffer.Addr(0);
		for (i=0; i<mesh.numVerts; i++) {
			if (!sel[i]) continue;
			vertexDir[i] = Normalize((mesh.verts[i] * (*mc.tm)) - center);
		}
	}

	// Actually do the move:
	for (i=0; i<mesh.numVerts; i++) {
		if (!sel[i]) continue;
		mesh.verts[i] += amount * vertexDir[i];
	}

	// Scale verts
	if (scale!=1.0f) {
		temp.freeAll ();
		temp.SetMesh (&mesh);
		FaceClusterList *fc = temp.FaceClusters();
		Tab<Point3> *centers = temp.ClusterCenters (MESH_FACE);

		// Make sure each vertex is only scaled once.
		BitArray done;
		done.SetSize(mesh.getNumVerts());

		// scale each cluster independently
		for (i=0; (DWORD)i<fc->count; i++) {
			Point3 cent = (centers->Addr(0))[i];
			// Scale the cluster about its center
			for (j=0; j<mesh.getNumFaces(); j++) {
				if (fc->clust[j]==(DWORD)i) {
					for (int k=0; k<3; k++) {
						int index = mesh.faces[j].v[k]; 
						if (done[index]) continue;
						done.Set(index);
						mesh.verts[index] = (mesh.verts[index]-cent)*scale + cent;							
					}
				}
			}
		}
	}

	mesh.InvalidateTopologyCache ();
	tobj->UpdateValidity(GEOM_CHAN_NUM,iv);		
}