Пример #1
0
/*F prioritylist = CollectElementsOfPriority(fullspec,priority)
**
**  DESCRIPTION
**    fullspec: the full structural specification
**    priority: The current priority to isolate
**    prioritylist: The indicies of elements (repeated, see below)
**
**  REMARKS
**
**   This isolates the set of structural elements of the same priority.
**   In addition, each element is repeated according to the minimum and
**   the maximum number of that element. This means the number of this
**   substructure that will appear in the final structure is determined
**   at this stage.
**
**
**  REFERENCES
**
**  SEE ALSO
**
**  HEADERFILE
**
*/
static DataSubSet *CollectElementsOfPriority(FullMoleculeSpecification *fullspec,INT priority) {
  DataSubSet *priorityelements;
  FullStructuralElement *element;
  DataSubSet *priorityset;
  INT piter,eiter,elementpriority;
  INT i,maxcount,num;
  double fnum,fmin,fmax;
  double fr,frr;
  maxcount = fullspec->NumberOfElements*20;
  priorityelements = AllocateDataSubSet;
  CreateDataSubSet(priorityelements,fullspec->ID,fullspec->Name,
		   fullspec->NumberOfElements,maxcount,0);
  priorityelements->NumberOfPoints = 0;
  element = fullspec->FullStructuralElements;
  for(eiter=0;eiter<fullspec->NumberOfElements;eiter++) {
    elementpriority = element->Info->Priority;
    if(elementpriority == priority) {
      fmin = (double) element->Info->Minimum;
      fmax = (double) element->Info->Maximum;

      num = element->Info->Minimum + PickPoint(element->Info->Maximum - element->Info->Minimum);
      num = element->Info->Minimum + PickPoint(element->Info->Maximum - element->Info->Minimum);
      num = element->Info->Minimum + PickPoint(element->Info->Maximum - element->Info->Minimum);
      num = element->Info->Minimum + PickPoint(element->Info->Maximum - element->Info->Minimum);
      num = element->Info->Minimum + PickPoint(element->Info->Maximum - element->Info->Minimum);
      for(i=0;i<num;i++) {
	*(priorityelements->Points + priorityelements->NumberOfPoints) = eiter;
	priorityelements->NumberOfPoints++;
      }
    }
    element++;
  }
  return priorityelements;
}
Пример #2
0
/*F AddStructureNext(currentstructure,element)
**
**  DESCRIPTION
**    currentstructure: The current structure to add to
**    element: The structural element to add
**
**  REMARKS
**
**   This connects the current structure with the structural element
**   to form a new currentstructure
**
**
**  REFERENCES
**
**  SEE ALSO
**
**  HEADERFILE
**
*/
static void AddStructureNext(CurrentStructure *currentstructure,
			 FullStructuralElement *element){
  INT currentattach, structureattach,replacepoint,replacepointC;
  CombinedGraph *combined,*newcombined;
  AttachmentRemoved *currentR,*elementR;
  CurrentStructure *elementcurrent;
  INT a1,a2,offset;
  Neighbor *n1,*n2;

  currentattach = PickPoint(currentstructure->Attachments->NumberOfPoints);
  structureattach = PickPoint(element->Connections->NumberOfPoints);

  elementcurrent = AllocateCurrentStructure;
  CreateCurrentStructure(elementcurrent,currentstructure->ID,currentstructure->Name,
			 0,element->MoleculeGraph,element->Connections);
  
  /*
  PrintPrettyGraph("current: ",stdout,currentstructure->Structure);
  PrintPrettyDataSubSet(stdout,"Attachments: ",currentstructure->Attachments);
  PrintPrettyGraph("element: ",stdout,element->MoleculeGraph);
  PrintPrettyDataSubSet(stdout,"Attachments: ",elementcurrent->Attachments);
  */
  replacepoint = *(elementcurrent->Attachments->Points + structureattach);
  replacepointC = *(currentstructure->Attachments->Points + currentattach);
  printf("Remove: Element (%d,%d,%d),  Current(%d,%d,%d)\n",
	 replacepoint,structureattach,element->Connections->NumberOfPoints,
	 replacepointC,currentattach,currentstructure->Attachments->NumberOfPoints);
  currentR = RemoveAttachment(currentstructure,currentattach);
  elementR = RemoveAttachment(elementcurrent,structureattach);
  /*  PrintPrettyGraph("currentR: ",stdout,currentR->Structure);
  PrintPrettyGraph("elementR: ",stdout,elementR->Structure);
  */
  offset = currentR->Structure->NumberOfNodes;
  combined = AllocateCombinedGraph;
  CreateCombinedGraph(combined,currentstructure->ID,currentstructure->Name,
		      currentR->Structure,
		      1,0);
  *(combined->Begins) = 0;

  newcombined = AddGraphToCombined(elementR->Structure,combined);

  a1 = currentR->Attachment;
  a2 = elementR->Attachment + offset;
  n1 = newcombined->Combined->Neighbors + a1;
  n2 = newcombined->Combined->Neighbors + a2;
  AddElementToNeighbor(a1,n2);
  AddElementToNeighbor(a2,n1);
  FreeGraph(currentstructure->Structure);
  CopyFullGraph(currentstructure->Structure,newcombined->Combined);

  /*
  PrintPrettyGraph("newcombined with bond: ",stdout,currentstructure->Structure);
  */
  offset = *(newcombined->Begins +1);
  AdjustAttachmentPointsOfNewElement(offset,replacepoint,replacepointC,elementcurrent,currentstructure);  
}
Пример #3
0
/*F next = PickNextStructureToAdd(priorityelements);
**
**  DESCRIPTION
**    priorityelements: The indicies of structures to add (repeated)
**    next: The index of the next element to add
**
**  REMARKS
**
**   This randomly picks one of the structural elements
**
**
**  REFERENCES
**
**  SEE ALSO
**
**  HEADERFILE
**
*/
static INT PickNextStructureToAdd(DataSubSet *priorityelements) {
  INT index,point;
  DataSubSet *nextlist;
  
  index = PickPoint(priorityelements->NumberOfPoints);
  
  point = *(priorityelements->Points + index);

  nextlist = RemoveI(index,priorityelements);
  FreeDataSubSet(priorityelements);
  CopyFullDataSubSet(priorityelements,nextlist);
  FreeDataSubSet(nextlist);
  Free(nextlist);

  return point;
}
Пример #4
0
JNIEXPORT void JNICALL Java_JavaGL_pickPoint( JNIEnv *env, jobject object, jint x, jint y )
{
	PickPoint( x, y );
}