Ejemplo n.º 1
0
 CAS* EngineBase::newCAS() const {
     assert(EXISTS(iv_casDefinition));
     assert(EXISTS(iv_pAnnotatorContext));
     CAS* tmpCas = uima::internal::CASImpl::createCASImpl(
     *CONST_CAST(uima::internal::CASDefinition*, iv_casDefinition), *iv_pAnnotatorContext);
     return tmpCas->getInitialView();
 }
Ejemplo n.º 2
0
 IndexIterator* IndexABase::createFilteredIterator(FSFilter const * cpFilter) const {
   IndexIterator* pit = createIterator();
   assert( EXISTS(pit) );
   IndexIterator* result = new FilterIndexIterator(cpFilter, pit);
   assert( EXISTS(result) );
   return result;
 }
    void CapabilityContainer::copyEntriesForUnspecifedLanguage() {
      if (iv_psetInputTOFsForUnspecifiedLang == NULL) {
        // if it is not in the input it can't be in the output either
        assert(findOutputTOFs(Language(Language::UNSPECIFIED)) == NULL);
        return;
      }
      assert(EXISTS(iv_psetInputTOFsForUnspecifiedLang));
      if (iv_psetInputTOFsForUnspecifiedLang->size() != 0) {
        TyMapLang2TypeOrFeatures::iterator it;
        for (it = iv_mapLang2InputTypesOrFeatures.begin(); it != iv_mapLang2InputTypesOrFeatures.end(); ++it) {
          if (&(*it).second != iv_psetInputTOFsForUnspecifiedLang) { // don't append onto ourselves
            if ((*it).second.size() > 0) { // don't append to empty
#ifndef NDEBUG
              size_t uiOldSize = (*it).second.size();
#endif /* NDEBUG */
              // MSV6 compile error: (*it).second.insert(iv_psetInputTOFsForUnspecifiedLang->begin(), iv_psetInputTOFsForUnspecifiedLang->end());
              TySetTypeOrFeatures::const_iterator tofit;
              for (tofit = iv_psetInputTOFsForUnspecifiedLang->begin(); tofit != iv_psetInputTOFsForUnspecifiedLang->end(); ++tofit) {
                (*it).second.insert( *tofit );
              }
              assert((*it).second.size() >= uiOldSize);
            }
          }
        }

        // Now do the same copying for the output

        // if it is in the input it must be in the output too
        assert(findOutputTOFs(Language(Language::UNSPECIFIED)) != NULL);
        assert(EXISTS(iv_psetOutputTOFsForUnspecifiedLang));

        for (it = iv_mapLang2OutputTypesOrFeatures.begin(); it != iv_mapLang2OutputTypesOrFeatures.end(); ++it) {
          if (&(*it).second != iv_psetOutputTOFsForUnspecifiedLang) { // don't append onto ourselves
            if ((*it).second.size() > 0) { // don't append to empty
#ifndef NDEBUG
              size_t uiOldSize = (*it).second.size();
#endif /* NDEBUG */
              // MSV6 compile error: (*it).second.insert(iv_psetOutputTOFsForUnspecifiedLang->begin(), iv_psetOutputTOFsForUnspecifiedLang->end());
              TySetTypeOrFeatures::const_iterator tofit;
              for (tofit = iv_psetOutputTOFsForUnspecifiedLang->begin(); tofit != iv_psetOutputTOFsForUnspecifiedLang->end(); ++tofit) {
                (*it).second.insert(*tofit);
              }
              assert((*it).second.size() >= uiOldSize);
            }
          }
        }
      }
    }
Ejemplo n.º 4
0
    uima::lowlevel::IndexComparator const * IndexDefinition::getComparator(IndexDefinition::TyIndexID const & crID) const {
      assert( isValidIndexId(crID) );
      map<IndexDefinition::TyIndexID, uima::lowlevel::internal::IndexFactory*>::const_iterator cit;
      cit = iv_mapFactories.find(crID);
      uima::lowlevel::internal::IndexFactory const * pFactory = (*cit).second;
      assert( EXISTS(pFactory) );
      uima::lowlevel::IndexComparator const * cpResult = pFactory->getComparator();
#ifndef NDEBUG
      if ( getIndexKind(crID) == enFIFO ) {
        assert( cpResult == NULL );
      } else {
        assert( EXISTS(cpResult) );
      }
#endif
      return cpResult;
    }
Ejemplo n.º 5
0
 TyErrorId
 extractConfigOption(
         const AnnotatorContext& crclConfig,
         const UnicodeString* cpclConfigGroup,
         const ConfigOptionInfo::StOptionInfo& crclOptionInfo,
         T& rclTargetVariable
 ) {
     assert(!crclOptionInfo.bOptionIsMultiValued);
     // assume the worst
     TyErrorId utErrId = UIMA_ERR_CONFIG_SECTION_NOT_FOUND;
     assert(crclOptionInfo.uiNbrOfValuesRequired <= 1);
     if (EXISTS(cpclConfigGroup)) {
         //utErrId = crclConfig.extractValue(crclOptionInfo.cpszOptionName, rclTargetVariable);
         utErrId = crclConfig.extractValue(*cpclConfigGroup, crclOptionInfo.cpszOptionName, rclTargetVariable);
     } else {
         utErrId = crclConfig.extractValue(crclOptionInfo.cpszOptionName, rclTargetVariable);
     }
     if (utErrId != UIMA_ERR_NONE) { // could not find option or value(s)
         if (crclOptionInfo.uiNbrOfValuesRequired != 0
             || crclOptionInfo.cpszDefaultValueAsString == NULL) {
             // required value not there: return error we got from config
             return utErrId;
         }
         convertFromString((std::string) crclOptionInfo.cpszDefaultValueAsString, rclTargetVariable);
         // we used the provided default: this is not an error so we return OK
         utErrId = UIMA_ERR_NONE;
     }
     return utErrId;
 }
Ejemplo n.º 6
0
 IndexDefinition::EnIndexKind IndexDefinition::getIndexKind(IndexDefinition::TyIndexID const & crID) const {
   assert( isValidIndexId(crID) );
   map<IndexDefinition::TyIndexID, uima::lowlevel::internal::IndexFactory*>::const_iterator cit;
   cit = iv_mapFactories.find(crID);
   uima::lowlevel::internal::IndexFactory const * pFactory = (*cit).second;
   assert( EXISTS(pFactory) );
   return pFactory->getIndexKind();
 }
Ejemplo n.º 7
0
	TESTCASE() {

		MAX_WAIT_TIME(3*USECSPERSEC);

		for (int i = 0; i < NUM_THREADS; i++)
		{
			CREATE_THREAD(i+1, increment_routine, (void*)counter);
		}

		//-----------------------------------------

		printf("counter->x: %lx\n", &counter->x);
		printf("counter->lock: %lx\n", &counter->mutex);

		EXISTS(t1, PTRUE, "Select thread t1");
		EXISTS(t2, NOT(t1), "Select thread t2");
//
		RUN_UNTIL(BY(t1), ENDS(), __, "Reads from x");
//
//		RUN_UNTIL(NOT_BY(t1), WRITES(&counter->x, t2), __, "Writes to x");
//
//		RUN_UNTIL(PTRUE, ENDS(t1), __, "Ends...");


//		WHILE_STAR
//		{
//			FORALL(t, (TID == t1 || TID == t2), "Select thread t");
//			RUN_UNTIL(BY(t), ENDS(), __, "Run until ends");
//		}



//			FORALL(t, PTRUE, "Select thread t");
//			RUN_UNTIL(BY(t), ENDS(), __, "Run until ends");



//			FORALL(t, PTRUE, "Select thread t");
//			RUN_UNTIL(BY(t), PTRUE, __, "Run until ends");
//		}

	}
Ejemplo n.º 8
0
 void checkArray(const uima::lowlevel::TyFSType ARRAY_TYPE, lowlevel::TyFS tyFS, uima::lowlevel::FSHeap * pFSSystem, TyMessageId tyContext) {
   assert(EXISTS(pFSSystem));
   if (pFSSystem->getType( tyFS) != ARRAY_TYPE ) {
     UIMA_EXC_THROW_NEW(FSIsNotArrayException,
                        UIMA_ERR_FS_IS_NOT_ARRAY,
                        UIMA_MSG_ID_EXC_FS_IS_NOT_ARRAY,
                        ErrorMessage(tyContext),
                        ErrorInfo::recoverable
                       );
   }
 }
Ejemplo n.º 9
0
 /**
  * generic implementation of find().
  */
 TyFS IndexABase::find(TyFS fs) const {
   auto_ptr<IndexIterator> it(createIterator());
   assert( EXISTS(it.get()) );
   for (it->moveToFirst(); it->isValid(); it->moveToNext() ) {
     TyFS nextFS = it->get();
     if (nextFS == fs) {
       return fs;
     }
   }
   return uima::lowlevel::FSHeap::INVALID_FS;
 }
    void
    CapabilityContainer::init( vector<Capability*> const & vecCap, TypeSystem const & typeSystem, EnMatchPolicy enMatchPolicy ) {
      iv_enMatchPolicy = enMatchPolicy;
      vector<Capability*>::const_iterator it;
      assert(iv_mapLang2InputTypesOrFeatures.size() == 0);
      assert(iv_mapLang2OutputTypesOrFeatures.size() == 0);
      for (it = vecCap.begin(); it != vecCap.end(); ++it) {
        assert(EXISTS(*it));
        Capability const & cap = (*(*it));
        initTypeOrFeatures(
          iv_mapLang2InputTypesOrFeatures,
          cap.getCapabilityTypes(Capability::INPUT),
          cap.getSupportedLanguages(),
          typeSystem);
        initTypeOrFeatures(
          iv_mapLang2InputTypesOrFeatures,
          cap.getCapabilityFeatures(Capability::INPUT),
          cap.getSupportedLanguages(),
          typeSystem);
        initTypeOrFeatures(
          iv_mapLang2OutputTypesOrFeatures,
          cap.getCapabilityTypes(Capability::OUTPUT),
          cap.getSupportedLanguages(),
          typeSystem);
        initTypeOrFeatures(
          iv_mapLang2OutputTypesOrFeatures,
          cap.getCapabilityFeatures(Capability::OUTPUT),
          cap.getSupportedLanguages(),
          typeSystem);
      }

      // try to find input tofs for unspecifed language
      assert(iv_psetInputTOFsForUnspecifiedLang == NULL);
      TySetTypeOrFeatures const * pSetInputTOFs =
        findInputTOFs(Language(Language::UNSPECIFIED));
      if (pSetInputTOFs != NULL) {
        iv_psetInputTOFsForUnspecifiedLang = pSetInputTOFs;
      }
      // try to find output tofs for unspecifed language
      assert(iv_psetOutputTOFsForUnspecifiedLang == NULL);
      TySetTypeOrFeatures const * pSetOutputTOFs =
        findOutputTOFs(Language(Language::UNSPECIFIED));
      if (pSetOutputTOFs != NULL) {
        iv_psetOutputTOFsForUnspecifiedLang = pSetOutputTOFs;
      }

      copyEntriesForUnspecifedLanguage();
      if (hasEmptyOutputTypeOrFeatures(Language(Language::UNSPECIFIED))) {
        iv_bHasEmptyOutputTOFsForUnspecifiedLang = true;
      }

      computeClosure(iv_mapLang2OutputTypesOrFeatures, iv_mapLang2OutputTypesOrFeaturesNoTerritory );
      computeClosure(iv_mapLang2InputTypesOrFeatures, iv_mapLang2InputTypesOrFeaturesNoTerritory );
    }
Ejemplo n.º 11
0
// Process incoming events
static int callback(int device, Finger *data, int nFingers, double timestamp, int frame)
{
	if (!running || !sampling_interval_passed()) {
		return 0;
	}

	tuio_frame_begin();

	std::set<int> fingers;

	// Process incoming events
	int i;
	for (i=0; i<nFingers; i++) {
		Finger *f = &data[i];
		int id = f->identifier;

		float x = f->normalized.pos.x;
		float y = 1.0f - f->normalized.pos.y; // reverse y axis
		float size = f->size;
		
		if (EXISTS(currentFingers, id)) {
			// update
			touch_update(id, x, y, size);
		}
		else {
			// add
			touch_add(id, x, y, size);
		}
		fingers.insert(id);
	}

	// Remove old events
	std::set<int>::iterator iter;
	FOREACH(currentFingers, iter) {
		int id = *iter;
		if (!EXISTS(fingers, id)) {
			// remove
			touch_remove(id);
		}
	}
Ejemplo n.º 12
0
T Request_new(struct evhttp_request *req, void *data)
{
	T R;
	struct evkeyval *val;

	R = g_malloc0(sizeof(*R));
	R->req = req;
	R->data = data;
	R->uri = evhttp_decode_uri(evhttp_request_uri(R->req));
	R->parts = g_strsplit_set(R->uri,"/?",0);

	Request_parse_getvars(R);
	Request_parse_postvars(R);

	TRACE(TRACE_DEBUG,"R->uri: [%s]", R->uri);
	TAILQ_FOREACH(val, R->req->input_headers, next)
		TRACE(TRACE_DEBUG,"input_header: [%s: %s]", val->key, val->value);

	// 
	// uri-parts: /controller/id/method/arg
	//
	if (EXISTS(R->parts[1])) {
		R->controller = R->parts[1];
		TRACE(TRACE_DEBUG,"R->controller: [%s]", R->controller);
		if (EXISTS(R->parts[2])) {
			R->id = R->parts[2];
			TRACE(TRACE_DEBUG,"R->id: [%s]", R->id);
			if (EXISTS(R->parts[3])) {
				R->method = R->parts[3];
				TRACE(TRACE_DEBUG,"R->method: [%s]", R->method);
				if (EXISTS(R->parts[4])) {
					R->arg = R->parts[4];
					TRACE(TRACE_DEBUG,"R->arg: [%s]", R->arg);
				}
			}
		}
	}

	return R;
}
Ejemplo n.º 13
0
    void IndexDefinition::defineIndex(EnIndexKind enIxKind,
                                      TyFSType tyType,
                                      vector<uima::lowlevel::TyFSFeature> const & crKeyFeatures,
                                      vector<uima::lowlevel::IndexComparator::EnKeyFeatureComp> const & crComparators,
                                      IndexDefinition::TyIndexID const & crID,
                                      bool bIsPermanent) {
      assert(!iv_bIsCommitted);
      // if index does not yet exist
      if (! isValidIndexId(crID)) {
        // create comparator
        assert( crKeyFeatures.size() == crComparators.size() );
        uima::lowlevel::IndexComparator * pComparator = new uima::lowlevel::IndexComparator(*this, tyType);
        assert( EXISTS(pComparator) );

        size_t i;
        for (i=0; i<crKeyFeatures.size(); ++i) {
          pComparator->addKey(crKeyFeatures[i], crComparators[i]);
        }
        iv_vecComparators.push_back(pComparator);

        // create factory with the comparator
        internal::IndexFactory* pFactory = createFactory(enIxKind, tyType, pComparator);
        assert( pFactory != NULL );

        // register factory for index ID
        UIMA_TPRINT("creating index");
        assert( iv_mapFactories.find(crID) == iv_mapFactories.end() );
        iv_mapFactories[crID] = pFactory;
        assert( iv_crTypeSystem.subsumes( pFactory->getType(), tyType ) );
        assert( iv_mapIndexTypes.find(crID) == iv_mapIndexTypes.end() );

        // register type for index ID
        iv_mapIndexTypes[crID] = tyType;

        // register if index is contains permanent FSs
        assert( iv_mapIsPermanentFlags.find(crID) == iv_mapIsPermanentFlags.end() );
        iv_mapIsPermanentFlags[crID] = bIsPermanent;
      } else {
        // check if index is compatible with existing one
        UIMA_TPRINT(" An index with ID " << crID << " already exists, checking if it is compatible");

        if (! isCompatibleIndexDefinition( enIxKind, tyType, crKeyFeatures, crComparators, crID, bIsPermanent) ) {
          UIMA_EXC_THROW_NEW(IncompatibleIndexDefinitionsException,
                             UIMA_ERR_INCOMPATIBLE_INDEX_DEFINITIONS,
                             ErrorMessage(UIMA_MSG_ID_EXC_INCOMPATIBLE_INDEX_DEFINITIONS, crID),
                             UIMA_MSG_ID_EXCON_CREATING_INDEXES_FROM_CONFIG,
                             ErrorInfo::recoverable);
        }


      }
    }
Ejemplo n.º 14
0
int MPlex::exists(char *word)
{
	char	buff[BUF_SIZE];
	int	i;

	strcpy(buff, "^");
	strcat(buff, word);
	strcat(buff, sTAGSEP);

	for (i = 0; i < strlen(buff); ++i) buff[i] = tolower(buff[i]);

	return EXISTS(tree, buff);
}
Ejemplo n.º 15
0
// Process incoming events
static void callback(MTDeviceRef device, MTTouch touches[], size_t numTouches, double timestamp, size_t frame) {
	
	if (!running || !sampling_interval_passed()) {
		return;
	}

	tuio_frame_begin();

	std::set<int> fingers;

	// Process incoming events
	int i;
	for (i=0; i<numTouches; i++) {
		MTTouch *f = &touches[i];
		int id = f->pathIndex;

		float x = f->normalizedVector.position.x;
		float y = 1.0f - f->normalizedVector.position.y; // reverse y axis
		
		if (EXISTS(currentFingers, id)) {
			// update
			touch_update(id, x, y);
		}
		else {
			// add
			touch_add(id, x, y);
		}
		fingers.insert(id);
	}

	// Remove old events
	std::set<int>::iterator iter;
	FOREACH(currentFingers, iter) {
		int id = *iter;
		if (!EXISTS(fingers, id)) {
			// remove
			touch_remove(id);
		}
	}
Ejemplo n.º 16
0
int GaFillMesh(GaQuadMesh *mesh, int region, const GpColor *colors,
               long nColumns)
{
  int value= 0;
  long iMax= mesh->iMax;
  long ijMax= iMax*mesh->jMax;
  GpReal *x= mesh->x, *y= mesh->y;
  int *ireg= mesh->reg;
  GpReal qx[4], qy[4];
  long ij, row, col;
  int rgb = colors? gistA.rgb : 0;
  gistA.rgb = 0;

  /* Create default region array if none supplied */
  if (!ireg) {
    ireg= NewReg(iMax, ijMax);
    if (!ireg) return 1;
    mesh->reg= ireg;
  }

  InitializeClip();

  /* The only filled area attribute set is the color.  */
  row= col= 0;
  if (!colors) gistA.f.color = BG_COLOR;
  for (ij=iMax+1 ; ij<ijMax ; ij++) {
    if (EXISTS(ij)) {
      qx[0]= x[ij-iMax-1];  qy[0]= y[ij-iMax-1];
      qx[1]= x[ij-iMax  ];  qy[1]= y[ij-iMax  ];
      qx[2]= x[ij       ];  qy[2]= y[ij       ];
      qx[3]= x[ij     -1];  qy[3]= y[ij     -1];
      if (rgb) {
        gistA.f.color = P_RGB(colors[3*(row+col)],
                              colors[3*(row+col)+1],colors[3*(row+col)+2]);
      } else if (colors) {
        gistA.f.color = colors[row+col];
      }
      gpClipInit= 1;
      value|= GpFill(4, qx, qy);
    }
    col++;
    if (col==iMax) {
      col= 0;
      row+= nColumns;
    }
  }

  if (tmpReg) FreeTmpReg();
  return value;
}
Ejemplo n.º 17
0
        /**
         * Gathers all output capabilities from the TAE specifier.
         * This result spec is implicitly assumed when calling process(CAS) without a result spec.
         */
        TyErrorId EngineBase::initializeCompleteResultSpec() {
            iv_completeResultSpec.clear();

            assert(EXISTS(iv_casDefinition));
            uima::TypeSystem const& rTypeSystem = iv_casDefinition->getTypeSystem();

            AnnotatorContext const& crANC = getAnnotatorContext();

            AnalysisEngineMetaData::TyVecpCapabilities const& crVecCaps = crANC.getTaeSpecifier().getAnalysisEngineMetaData()->getCapabilites();
            AnalysisEngineMetaData::TyVecpCapabilities::const_iterator citCaps;

            for (citCaps = crVecCaps.begin(); citCaps != crVecCaps.end(); ++citCaps) {
                Capability const* cpCap = *citCaps;
                Capability::TyVecCapabilityTofs const& crTypes = cpCap->getCapabilityTypes(Capability::OUTPUT);
                Capability::TyVecCapabilityTofs::const_iterator citTOFs;
                for (citTOFs = crTypes.begin(); citTOFs != crTypes.end(); ++citTOFs) {
                    Type t = rTypeSystem.getType(*citTOFs);
                    if (!t.isValid()) {
                        ErrorInfo errInf(
                        ErrorMessage(UIMA_MSG_ID_UNKNOWN_FEATURE_IN_CAPBILITY_SPEC, (*citTOFs)),
                        UIMA_ERR_ANNOTATOR_MGR_CONFIG_INVALID_RESULTSPECIFICATION,
                        ErrorInfo::unrecoverable);
                        getAnnotatorContext().getLogger().logError(errInf);
                        return UIMA_ERR_ANNOTATOR_MGR_CONFIG_INVALID_RESULTSPECIFICATION;
                    }
                    iv_completeResultSpec.add(t);
                }

                Capability::TyVecCapabilityTofs const& crFeatures = cpCap->getCapabilityFeatures(Capability::OUTPUT);
                for (citTOFs = crFeatures.begin(); citTOFs != crFeatures.end(); ++citTOFs) {
                    Feature f = rTypeSystem.getFeatureByFullName(*citTOFs);
                    if (!f.isValid()) {
                        ErrorInfo errInf(
                        ErrorMessage(UIMA_MSG_ID_UNKNOWN_FEATURE_IN_CAPBILITY_SPEC, (*citTOFs)),
                        UIMA_ERR_ANNOTATOR_MGR_CONFIG_INVALID_RESULTSPECIFICATION,
                        ErrorInfo::unrecoverable);
                        getAnnotatorContext().getLogger().logError(errInf);
                        return UIMA_ERR_ANNOTATOR_MGR_CONFIG_INVALID_RESULTSPECIFICATION;
                    }
                    iv_completeResultSpec.add(f);
                }

            }
            return UIMA_ERR_NONE;
        }
Ejemplo n.º 18
0
TESTCASE() {

    ThreadVarPtr t_ip1 = CREATE_THREAD(insertpair_routine1, (void*)&multiset);
    ThreadVarPtr t_ip2 = CREATE_THREAD(insertpair_routine2, (void*)&multiset);
    ThreadVarPtr t_ip3 = CREATE_THREAD(insertpair_routine3, (void*)&multiset);

    ThreadVarPtr t_lu1 = CREATE_THREAD(lookup_routine1, (void*)&multiset);
    ThreadVarPtr t_lu2 = CREATE_THREAD(lookup_routine2, (void*)&multiset);
    ThreadVarPtr t_lu3 = CREATE_THREAD(lookup_routine3, (void*)&multiset);

    printf("=============================================\n"
           "=============================================\n");

    //----------------------------------------------------------------------------------
    //----------------------------------------------------------------------------------

    FORALL(t1, BY(t_ip1) || BY(t_ip2) || BY(t_ip3));
    RUN_UNTIL(BY(t1), ENDS(), __);

    FORALL(t2, (BY(t_ip1) || BY(t_ip2) || BY(t_ip3)) && NOT(t1));
    RUN_UNTIL(BY(t2), ENDS(), __);

    FORALL(t3, (BY(t_ip1) || BY(t_ip2) || BY(t_ip3)) && NOT(t1) && NOT(t2));
    RUN_UNTIL(BY(t3), ENDS(), __);

    RUN_UNTIL(BY(t_lu2), ENDS(), __);
    RUN_UNTIL(BY(t_lu1), ENDS(), __);
    RUN_UNTIL(BY(t_lu3), ENDS(), __);

    WHILE_STAR
    {
        EXISTS(t);
        RUN_UNTIL(PTRUE && !FINAL(), FINAL(t))

    }
    RUN_UNTIL(PTRUE, FINAL())
}
Ejemplo n.º 19
0
int GaContourInit(GaQuadMesh *msh, int regn,
                  const GpReal *zz, GpReal lev)
       /* Find the edges cut by the current contour, remembering
          z, triangle, and level for the GaContour routine, which
          actually walks the contour.  The z array represents function
          values on the mesh msh.  If triangle!=0,
          it represents the initial value of the triangulation array,
          which determines the behavior of GaContour in saddle zones.
            triangle[j][i]= 1, -1, or 0 as the zone bounded by
              [j-1][i-1], [j-1][i], [j][i], and [j][i-1]
              has been triangulated from (-1,-1) to (0,0),
              from (-1,0) to (0,-1), or has not yet been
              triangulated.
          The msh->triangle array is updated by GaContour.
          If a contour passes through an untriangulated saddle zone,
          GaContour chooses a triangulation and marks the triangle
          array approriately, so that subsequent calls to GaContour
          will never produce intersecting contour curves.  */
{
  long iMax= msh->iMax;
  long ijMax= iMax*msh->jMax;
  int *ireg= msh->reg;
  long ij;

  /* Create default region array if none supplied */
  if (!ireg) {
    ireg= NewReg(iMax, ijMax);
    if (!ireg) return 0;
    msh->reg= ireg;
  }

  /* Remember data for GaContour */
  mesh= msh;
  region= regn;
  z= zz;
  level= lev;

  /* Get scratch space to hold edges */
  if (GaGetScratchS(2*ijMax)) return 0;
  iedges= gasScratch;
  jedges= gasScratch+ijMax;

  /* Find all points above contour level */
  for (ij=0 ; ij<ijMax ; ij++) iedges[ij]= zz[ij]>lev;

  /* Find j=const edges which cut level plane */
  nj= njb= 0;
  for (ij=1 ; ij<ijMax ; ij++) {
    if ((iedges[ij]^iedges[ij-1]) && (EXISTS(ij)||EXISTS(ij+iMax))) {
      if ((ireg[ij]==region) ^ (ireg[ij+iMax]==region)) {
        jedges[ij]= 2;  /* contour enters mesh here */
        njb++;
      } else {
        jedges[ij]= 1;  /* interior edge */
        nj++;
      }
    } else {
      jedges[ij]= 0;
    }
  }
  jbegin= 1;

  /* Find i=const edges which cut level plane */
  ni= nib= 0;
  for (ij=ijMax-1 ; ij>=iMax ; ij--) {
    if ((iedges[ij]^iedges[ij-iMax]) && (EXISTS(ij)||EXISTS(ij+1))) {
      if ((ireg[ij]==region) ^ (ireg[ij+1]==region)) {
        iedges[ij]= 2;  /* contour enters mesh here */
        nib++;
      } else {
        iedges[ij]= 1;  /* interior edge */
        ni++;
      }
    } else {
      iedges[ij]= 0;
    }
  }
  ibegin= iMax;

  /* Set keepLeft to a known value (arbitrary but repeatable) */
  keepLeft= 0;

  /* Get scratch space for level curves */
  if (GaGetScratchP(ni+nib+nj+njb+1)) return 0;

  if (tmpReg) FreeTmpReg();
  return ni || nib || nj || njb;
}
Ejemplo n.º 20
0
int GaVectors(GaQuadMesh *mesh, int region,
              const GpReal *u, const GpReal *v, GpReal scale)
{
  int value= 0;
  long iMax= mesh->iMax;
  long ijMax= iMax*mesh->jMax;
  GpReal *x= mesh->x, *y= mesh->y;
  int *ireg= mesh->reg;
  int hollow= gistA.vect.hollow;
  GpReal aspect= gistA.vect.aspect;
  int etype= gistA.e.type;
  GpReal xc, yc, dx, dy, vx[3], vy[3];
  long ij;
  GpReal scalx, offx, scaly, offy, dxscale, dyscale;

  /* Create default region array if none supplied */
  if (!ireg) {
    ireg= NewReg(iMax, ijMax);
    if (!ireg) return 1;
    mesh->reg= ireg;
  }

  /* Save transform map, set up for transform here */
  SwapNormMap(&scalx, &offx, &scaly, &offy);

  dxscale= 0.3333333333*scale*scalx;
  dyscale= 0.3333333333*scale*scaly;
  aspect*= 3.0;

  if (!hollow) gistA.e.type= L_NONE;

  InitializeClip();

  for (ij=0 ; ij<ijMax ; ij++) {
    if (EXISTS(ij) || EXISTS(ij+1) || EXISTS(ij+1+iMax) || EXISTS(ij+iMax)) {
      xc= scalx*x[ij]+offx;
      yc= scaly*y[ij]+offy;
      dx= dxscale*u[ij];
      dy= dyscale*v[ij];

      /* Dart has centroid at (xc,yc), length 3*(dx,dy), given aspect */
      vx[1]= xc + 2.0*dx;
      vy[1]= yc + 2.0*dy;
      vx[0]= xc - dx + aspect*dy;
      vx[2]= xc - dx - aspect*dy;
      vy[0]= yc - dy - aspect*dx;
      vy[2]= yc - dy + aspect*dx;

      if (hollow) {
        gpCloseNext= gpClipInit= 1;
        value|= GpLines(3, vx, vy);
      } else {
        gpClipInit= 1;
        value|= GpFill(3, vx, vy);
      }
    }
  }

  if (!hollow) gistA.e.type= etype;
  if (tmpReg) FreeTmpReg();
  SwapMapNorm();
  return value;
}
Ejemplo n.º 21
0
int GaContour(long *cn, GpReal **cx, GpReal **cy, int *closed)
       /* After a call to GaContourInit, GaContour must be called
          repeatedly to generate the sequence of curves obtained by
          walking the edges cut by the contour level plane.  GaContour
          returns 1 until there are no more contours to be plotted,
          when it returns 0.  GaContour signals an error by returning
          0, but setting *cn!=0.  The curve coordinates (*cx,*cy)
          use internal scratch space and the associated storage must
          not be freed.  (*cx, *cy) are valid only until the next
          GaContour or GaMesh call.  */
{
  long iMax= mesh->iMax;
  long ijMax= iMax*mesh->jMax;
  GpReal *x= mesh->x, *y= mesh->y;
  int *ireg= mesh->reg;
  long ij, zone, step, inc, n;
  GpReal frac;
  int isClosed;
  short mark;

  /* Find a starting point -- get current zone and edge */
  if (nib>0) {
    for (ij=ibegin ; ij<ijMax ; ij++) if (iedges[ij]==2) break;
    if (ij>=ijMax)  return 0; /* this is a bug */
    iedges[ij]= 0;
    zone= EXISTS(ij)? ij : ij+1;
    step= EXISTS(ij)? -1 : 1;
    if (--nib) ibegin= ij+1;
    else ibegin= iMax;
    inc= iMax;

  } else if (njb>0) {
    for (ij=jbegin ; ij<ijMax ; ij++) if (jedges[ij]==2) break;
    if (ij>=ijMax)  return 0; /* this is a bug */
    jedges[ij]= 0;
    zone= EXISTS(ij)? ij : ij+iMax;
    step= EXISTS(ij)? -iMax : iMax;
    if (--njb) jbegin= ij+1;
    else jbegin= 1;
    inc= 1;

  } else if (ni>0) {
    for (ij=ibegin ; ij<ijMax ; ij++) if (iedges[ij]) break;
    if (ij>=ijMax)  return 0; /* this is a bug */
    iedges[ij]= 0;
    zone= ij+1;    /* or ij, doesn't really matter... */
    step= 1;       /* ...this choice tends to go counterclockwise */
    ni--;
    ibegin= ij+1;
    inc= iMax;

  } else if (nj>0) {
    for (ij=jbegin ; ij<ijMax ; ij++) if (jedges[ij]) break;
    if (ij>=ijMax)  return 0; /* this is a bug */
    jedges[ij]= 0;
    zone= ij;      /* or ij+iMax, doesn't really matter... */
    step= -iMax;   /* ...this choice tends to go counterclockwise */
    nj--;
    jbegin= ij+1;
    inc= 1;

  } else {
    return 0;      /* no more edges, only correct way out */
  }

  /* Salt away first point */
  frac= (z[ij]-level)/(z[ij]-z[ij-inc]);
  gaxScratch[0]= frac*(x[ij-inc]-x[ij]) + x[ij];
  gayScratch[0]= frac*(y[ij-inc]-y[ij]) + y[ij];
  n= 1;

  /* Walk the contour */
  isClosed= 0;
  for(;;) {
    /* Find exit from current zone */
    if (inc==1) { /* this is a j=const edge */
      if (jedges[ij+step] && !iedges[zone]) {
        /* step, inc unchanged */
        ij+= step;
      } else if (iedges[zone] &&
                 (!iedges[zone-1] || DoSaddle(zone, step, ij, inc))) {
        ij= zone;
        if (step>0) keepLeft= 1;  /* just turned right */
        else keepLeft= 0;
        step= 1;
        inc= iMax;
      } else if (iedges[zone-1]) {
        ij= zone-1;
        if (step>0) keepLeft= 0;  /* just turned left */
        else keepLeft= 1;
        step= -1;
        inc= iMax;
      } else {
        isClosed= 1;  /* end of a closed contour */
        break;
      }
    } else {      /* this is a i=const edge */
      if (iedges[ij+step] && !jedges[zone]) {
        /* step, inc unchanged */
        ij+= step;
      } else if (jedges[zone] &&
                 (!jedges[zone-iMax] || DoSaddle(zone, step, ij, inc))) {
        ij= zone;
        if (step>0) keepLeft= 0;  /* just turned left */
        else keepLeft= 1;
        step= iMax;
        inc= 1;
      } else if (jedges[zone-iMax]) {
        ij= zone-iMax;
        if (step>0) keepLeft= 1;  /* just turned right */
        else keepLeft= 0;
        step= -iMax;
        inc= 1;
      } else {
        isClosed= 1;  /* end of a closed contour */
        break;
      }
    }

    /* Salt away current point */
    frac= (z[ij]-level)/(z[ij]-z[ij-inc]);
    gaxScratch[n]= frac*(x[ij-inc]-x[ij]) + x[ij];
    gayScratch[n]= frac*(y[ij-inc]-y[ij]) + y[ij];
    n++;

    /* Step into next zone */
    zone+= step;

    /* Erase edge marker for entry edge */
    if (inc==1) {
      mark= jedges[ij];
      jedges[ij]= 0;
      if (mark==2) { /* end of an open contour */
        njb--;
        if (!njb) jbegin= 1;
        break;
      } else nj--;
    } else {
      mark= iedges[ij];
      iedges[ij]= 0;
      if (mark==2) { /* end of an open contour */
        nib--;
        if (!nib) ibegin= iMax;
        break;
      }
      else ni--;
    }
  }

  *cn= n;
  *cx= gaxScratch;
  *cy= gayScratch;
  *closed= isClosed;

  /* Copy first point for closed curves (as a convenience) */
  if (isClosed) {
    gaxScratch[n]= gaxScratch[0];
    gayScratch[n]= gayScratch[0];
  }

  return 1;
}
Ejemplo n.º 22
0
 bool moveTo(TyFS fs) {
   assert( EXISTS(iv_pIterator) );
   return iv_pIterator->moveTo(fs);
 }
Ejemplo n.º 23
0
 bool isValid() const {
   assert( EXISTS(iv_pIterator) );
   return iv_pIterator->isValid();
 }
Ejemplo n.º 24
0
 void moveToLast() {
   assert( EXISTS(iv_pIterator) );
   iv_pIterator->moveToLast();
   moveToPreviousUnfiltered();
 }
Ejemplo n.º 25
0
 void moveToFirst() {
   assert( EXISTS(iv_pIterator) );
   iv_pIterator->moveToFirst();
   moveToNextUnfiltered();
 }
Ejemplo n.º 26
0
 /**
 * returns the LogFacility to be used for logging
 **/
 LogFacility& getLogger() const {
     assert(EXISTS(iv_pLogger));
     return *iv_pLogger;
 }
Ejemplo n.º 27
0
 virtual AnnotatorContext const & getAnnotatorContext() const {
   assert( EXISTS(iv_pAnnotatorContext) );
   return *iv_pAnnotatorContext;
 }
Ejemplo n.º 28
0
 uima::internal::CASDefinition & getCASDefinition() {
   assert( EXISTS(iv_casDefinition) );
   return *iv_casDefinition;
 }
Ejemplo n.º 29
0
 inline AnnotatorContext & Annotator::getAnnotatorContext(void) {
   assertWithMsg(EXISTS(iv_pclAnnotatorContext), "Annotator::init() Forgot to call 'setAnnotatorContext()'");
   return(*iv_pclAnnotatorContext);
 }
Ejemplo n.º 30
0
 virtual ~FilterIndexIterator() {
   assert( EXISTS(iv_pIterator) );
   delete iv_pIterator;
 }