Example #1
0
Result
RSS14Reader::decodeRow(int rowNumber, const BitArray& row_, std::unique_ptr<DecodingState>& state) const
{
	RSS14DecodingState* prevState = nullptr;
	if (state == nullptr) {
		state.reset(prevState = new RSS14DecodingState);
	}
	else {
#if !defined(ZX_HAVE_CONFIG)
		#error "You need to include ZXConfig.h"
#elif !defined(ZX_NO_RTTI)
		prevState = dynamic_cast<RSS14DecodingState*>(state.get());
#else
		prevState = static_cast<RSS14DecodingState*>(state.get());
#endif
	}

	if (prevState == nullptr) {
		throw std::runtime_error("Invalid state");
	}

	BitArray row = row_.copy();
	AddOrTally(prevState->possibleLeftPairs, DecodePair(row, false, rowNumber));
	row.reverse();
	AddOrTally(prevState->possibleRightPairs, DecodePair(row, true, rowNumber));
//	row.reverse();

	for (const auto& left : prevState->possibleLeftPairs) {
		if (left.count() > 1) {
			for (const auto& right : prevState->possibleRightPairs) {
				if (right.count() > 1) {
					if (CheckChecksum(left, right)) {
						return ConstructResult(left, right);
					}
				}
			}
		}
	}
	return Result(DecodeStatus::NotFound);
}
Example #2
0
void VWeldMod::ConvertTriSelection (Mesh & mesh, BitArray & targetVerts) {
	targetVerts.SetSize (mesh.numVerts);
	targetVerts.ClearAll ();

	int i, j;
	switch (mesh.selLevel) {
	case MESH_OBJECT:
		targetVerts.SetAll ();
		break;
	case MESH_VERTEX:
		targetVerts = mesh.vertSel;
		break;
	case MESH_EDGE:
		for (i=0; i<mesh.numFaces; i++) {
			for (j=0; j<3; j++) {
				if (!mesh.edgeSel[i*3+j]) continue;
				targetVerts.Set (mesh.faces[i].v[j]);
				targetVerts.Set (mesh.faces[i].v[(j+1)%3]);
			}
		}
		break;
	case MESH_FACE:
		for (i=0; i<mesh.numFaces; i++) {
			if (!mesh.faceSel[i]) continue;
			for (j=0; j<3; j++) targetVerts.Set (mesh.faces[i].v[j]);
		}
		break;
	}
}
Example #3
0
  void GetWorkingArea(BitArray & working_elements, BitArray & working_points,
		      const Mesh & mesh, const Array<ElementIndex> & bad_elements,
		      const int width)
  {
    working_elements.Clear();
    working_points.Clear();

    for(int i=0; i<bad_elements.Size(); i++)
      {
	working_elements.Set(bad_elements[i]);
	const Element & el = mesh[bad_elements[i]];
	for(int j=1; j<=el.GetNP(); j++)
	  working_points.Set(el.PNum(j));
      }
    

    for(int i=0; i<width; i++)
      {
	for(ElementIndex j=0; j<mesh.GetNE(); j++)
	  {
	    if(!working_elements.Test(j))
	      {  
		const Element & el = mesh[j];
		bool set_active = false;
		
		for(int k=1; !set_active && k<=el.GetNP(); k++)
		  set_active = working_points.Test(el.PNum(k));
		
		if(set_active)
		  working_elements.Set(j);
	      }
	  }

	for(ElementIndex j=0; j<mesh.GetNE(); j++)
	  {
	    if(working_elements.Test(j))
	      {
		const Element & el = mesh[j];
		for(int k=1; k<=el.GetNP(); k++)
		  working_points.Set(el.PNum(k));
	      }
	  }
      }
  }
Example #4
0
void EditFaceDataModData::DescribeSelection (int & numFaces, int & whichFace, float & value, bool &valueDetermined) {
	numFaces = 0;
	for (int i=0; i<mFaceSel.GetSize(); i++) {
		if (!mFaceSel[i]) continue;
		if (!numFaces) {
			whichFace = i;
			value = FaceValue (i);
		} else if (valueDetermined) {
			if (value != FaceValue(i)) valueDetermined = false;
		}
		numFaces++;
	}
}
Example #5
0
void EditPolyData::GrowSelection (IMeshSelect *imod, int level) {
	DbgAssert (mpMesh);
	if( !mpMesh ) return;

	BitArray newSel;
	int mnSelLevel = meshSelLevel[level];
	DbgAssert (mpMesh->GetFlag (MN_MESH_FILLED_IN));
	if (!mpMesh->GetFlag (MN_MESH_FILLED_IN)) return;

	SynchBitArrays();

	int i;
	switch (mnSelLevel) {
	case MNM_SL_VERTEX:
		for (i=0; i<mpMesh->numv; i++) mpMesh->v[i].SetFlag (MN_USER, mVertSel[i]!=0);
		mpMesh->ClearEFlags (MN_USER);
		mpMesh->PropegateComponentFlags (MNM_SL_EDGE, MN_USER, MNM_SL_VERTEX, MN_USER);
		newSel.SetSize (mpMesh->numv);
		for (i=0; i<mpMesh->nume; i++) {
			if (mpMesh->e[i].GetFlag (MN_USER)) {
				newSel.Set (mpMesh->e[i].v1);
				newSel.Set (mpMesh->e[i].v2);
			}
		}
		SetVertSel (newSel, imod, TimeValue(0));
		break;
	case MNM_SL_EDGE:
		for (i=0; i<mpMesh->nume; i++) mpMesh->e[i].SetFlag (MN_USER, mEdgeSel[i]!=0);
		mpMesh->ClearVFlags (MN_USER);
		mpMesh->PropegateComponentFlags (MNM_SL_VERTEX, MN_USER, MNM_SL_EDGE, MN_USER);
		newSel.SetSize (mpMesh->nume);
		for (i=0; i<mpMesh->nume; i++) {
			if (mpMesh->v[mpMesh->e[i].v1].GetFlag (MN_USER)
				|| mpMesh->v[mpMesh->e[i].v2].GetFlag (MN_USER))
				newSel.Set (i);
		}
		SetEdgeSel (newSel, imod, TimeValue(0));
		break;
	case MNM_SL_FACE:
		for (i=0; i<mpMesh->numf; i++) mpMesh->f[i].SetFlag (MN_USER, mFaceSel[i]!=0);
		mpMesh->ClearVFlags (MN_USER);
		mpMesh->PropegateComponentFlags (MNM_SL_VERTEX, MN_USER, MNM_SL_FACE, MN_USER);
		newSel.SetSize (mpMesh->numf);
		for (i=0; i<mpMesh->numf; i++) {
         int j;
			for (j=0; j<mpMesh->f[i].deg; j++) {
				if (mpMesh->v[mpMesh->f[i].vtx[j]].GetFlag (MN_USER)) break;
			}
			if (j<mpMesh->f[i].deg) newSel.Set (i);
		}
		SetFaceSel (newSel, imod, TimeValue(0));
		break;
	}
}
std::string
ExpandedBinaryDecoder::Decode(const BitArray& bits)
{
	if (bits.get(1)) {
		return DecodeAI01AndOtherAIs(bits);
	}
	if (!bits.get(2)) {
		return DecodeAnyAI(bits);
	}

	int fourBitEncodationMethod = GenericAppIdDecoder::ExtractNumeric(bits, 1, 4);

	switch (fourBitEncodationMethod) {
	case 4: return DecodeAI013103(bits);
	case 5: return DecodeAI01320x(bits);
	}

	int fiveBitEncodationMethod = GenericAppIdDecoder::ExtractNumeric(bits, 1, 5);
	switch (fiveBitEncodationMethod) {
	case 12: return DecodeAI01392x(bits);
	case 13: return DecodeAI01393x(bits);
	}

	int sevenBitEncodationMethod = GenericAppIdDecoder::ExtractNumeric(bits, 1, 7);
	switch (sevenBitEncodationMethod) {
	case 56: return DecodeAI013x0x1x(bits, "310", "11");
	case 57: return DecodeAI013x0x1x(bits, "320", "11");
	case 58: return DecodeAI013x0x1x(bits, "310", "13");
	case 59: return DecodeAI013x0x1x(bits, "320", "13");
	case 60: return DecodeAI013x0x1x(bits, "310", "15");
	case 61: return DecodeAI013x0x1x(bits, "320", "15");
	case 62: return DecodeAI013x0x1x(bits, "310", "17");
	case 63: return DecodeAI013x0x1x(bits, "320", "17");
	}

	return std::string();
	//throw new IllegalStateException("unknown decoder: " + information);
}
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//|							From IPFTest									 |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
bool PFTestGoToNextEvent::Proceed(IObject* pCont, 
							PreciseTimeValue timeStart, 
							PreciseTimeValue& timeEnd, 
							Object* pSystem, 
							INode* pNode, 
							INode* actionNode, 
							IPFIntegrator* integrator, 
							BitArray& testResult, 
							Tab<float>& testTime)
{
	int conditionType	= pblock()->GetInt(kGoToNextEvent_conditionType, timeStart);
	bool exactStep = IsExactIntegrationStep(timeEnd, pSystem);

	// get channel container interface
	IChannelContainer* chCont;
	chCont = GetChannelContainerInterface(pCont);
	if (chCont == NULL) return false;

	// acquire absolutely necessary particle channels
	IParticleChannelAmountR* chAmount = GetParticleChannelAmountRInterface(pCont);
	if (chAmount == NULL) return false; // can't find number of particles in the container
	IParticleChannelPTVR* chTime = GetParticleChannelTimeRInterface(pCont);
	if (chTime == NULL) return false; // can't read timing info for a particle

	int count = chAmount->Count();
	if (count <= 0) return true;

	testResult.SetSize(count);
	testTime.SetCount(count);
	if((conditionType == kGoToNextEvent_conditionType_all) && exactStep) {
		testResult.SetAll();
		for(int i=0; i<count; i++) testTime[i] = 0.0f;
	} else {
		testResult.ClearAll();
	}

	return true;
}
int main( int argc, char * argv[] ) 
{
  // proejct abandonded becasue bitset

  printf( "%d\n", sizeof( uint8 ) );
  
  BitArray B;
  
  BitArray C( 15 );
  
  // printf( "sizeof(B.m_data) = %d\n", sizeof(B.m_data) );
  // printf( "sizeof(*(B.m_data)) = %d\n", sizeof(*(B.m_data)) );
  // printf( "sizeof(C.m_data) = %d\n", sizeof(C.m_data) );
  // printf( "sizeof(*(C.m_data)) = %d\n", sizeof(*(C.m_data)) );
  
  printf( "%d\n", B.int_size() );
  printf( "%d\n", B.bit_size() );
  
  printf( "%d\n", C.int_size() );
  printf( "%d\n", C.bit_size() );   
  
  bitset<50> Z;
  
  string ostring = Z.to_string<char,char_traits<char>,allocator<char> >();
  printf( ostring.c_str() );
  printf( "\n" );
  
  Z[10] = 1;
  Z[15] = 1;
  
  Z[58] = 1;
  
  ostring = Z.to_string<char,char_traits<char>,allocator<char> >();
  printf( ostring.c_str() );
  printf( "\n" );
  
  return 0;
}
Example #9
0
bool scaling_list(BitArray &ba, uint8_t sizeOfScalingList) {
	uint32_t nextScale = 8;
	uint32_t lastScale = 8;
	uint64_t delta_scale = 0;
	for (uint8_t j = 0; j < sizeOfScalingList; j++) {
		if (nextScale != 0) {
			if (!ba.ReadExpGolomb(delta_scale))
				return false;
			nextScale = (lastScale + delta_scale + 256) % 256;
		}
		lastScale = (nextScale == 0) ? lastScale : nextScale;
	}
	return true;
}
Example #10
0
void EditFaceDataMod::SelectSubComponent (HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert) {
	EditFaceDataModData *d = NULL, *od = NULL;

	ModContextList mcList;
	INodeTab nodes;
	ip->GetModContexts(mcList,nodes);
	BitArray nsel;

	for (int nd=0; nd<mcList.Count(); nd++) {
		d = (EditFaceDataModData*) mcList[nd]->localData;
		if (d==NULL) continue;
		HitRecord *hr = hitRec;
		if (!all && (hr->modContext->localData != d)) continue;
		for (; hr!=NULL; hr=hr->Next()) if (hr->modContext->localData == d) break;
		if (hr==NULL) continue;

		Mesh *mesh = d->GetCacheMesh();
		MNMesh *mnmesh = d->GetCacheMNMesh();
		if (!mesh && !mnmesh) continue;
		if (theHold.Holding() && !d->GetHeld()) theHold.Put (new SelectRestore (this, d));

		switch (selLevel) {
		case SEL_FACE:
			nsel = d->GetFaceSel();
			for (; hr != NULL; hr=hr->Next()) {
				if (d != hr->modContext->localData) continue;
				nsel.Set (hr->hitInfo, invert ? !d->GetFaceSel()[hr->hitInfo] : selected);
				if (!all) break;
			}
			d->GetFaceSel() = nsel;
			break;
		}
	}

	nodes.DisposeTemporary ();
	SelectionChanged ();
}
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//|							From IPFTest									 |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
bool PFTestSplitSelected::Proceed(IObject* pCont, 
							PreciseTimeValue timeStart, 
							PreciseTimeValue& timeEnd, 
							Object* pSystem, 
							INode* pNode, 
							INode* actionNode, 
							IPFIntegrator* integrator, 
							BitArray& testResult, 
							Tab<float>& testTime)
{
	bool exactStep = IsExactIntegrationStep(timeEnd, pSystem);
	int conditionType	= pblock()->GetInt(kSplitSelected_conditionType, timeStart);

	// acquire absolutely necessary particle channels
	IParticleChannelAmountR* chAmount = GetParticleChannelAmountRInterface(pCont);
	if (chAmount == NULL) return false; // can't find number of particles in the container
	int count = chAmount->Count();
	IParticleChannelPTVR* chTime = GetParticleChannelTimeRInterface(pCont);
	if (chTime == NULL) return false; // can't read timing info for a particle
	IParticleChannelBoolR* chSelect = GetParticleChannelSelectionRInterface(pCont);

	// test all particles
	testResult.SetSize(count);
	testResult.ClearAll();
	testTime.SetCount(count);
	for(int i=0; i<count; i++)
	{
		bool selected = (chSelect != NULL) ? chSelect->GetValue(i) : false;
		bool sendOut = ((selected && (conditionType == kSplitSelected_conditionType_selected)) 
						|| (!selected && (conditionType == kSplitSelected_conditionType_notSelected)));
		if (sendOut && exactStep) {
			testResult.Set(i);
			testTime[i] = 0.0f;
		}
	}
	return true;
}
void MNMeshLoop::Build(MNMeshLoopAdvancer &adv, int startid, BitArray &finalsel)
{
  // prepare Loopitems
  m_items.SetCount(MESHLOOP_ALLOC_ITEMCOUNT);
  int allocated = MESHLOOP_ALLOC_ITEMCOUNT;

  // add ourself
  int itemcnt = 0;
  int wave = 1;

  MNMeshLoopItem *item = m_items.Addr(0);
  item->wave = 0;
  item->distance = 0.0f;
  item->id = startid;
  item->pos = adv.GetPos(startid);
  item->prev = NULL;
  finalsel.Set(startid);
  item++;
  itemcnt++;

  Tab<MNMeshLoopFront> fronts;
  int outcount = adv.SetupFront(startid,fronts);

  // then advance each direction
  int added = TRUE;
  while(added){
    added = FALSE;
    for (int o = 0; o < outcount; o++){
      MNMeshLoopFront *front = fronts.Addr(o);

      // loop ended
      if (adv.Advance(front,item,itemcnt,wave,finalsel))
        continue;

      item++;
      itemcnt++;

      // expand memory (we could use append but well no clue how it resizes)
      if (itemcnt%MESHLOOP_ALLOC_ITEMCOUNT == 0){
        m_items.SetCount(itemcnt+MESHLOOP_ALLOC_ITEMCOUNT);
        item = m_items.Addr(itemcnt);
      }
      added = TRUE;
    }
    wave += 1;
  }

  m_numitems = itemcnt;
}
Example #13
0
void TabletReader::QueryExactByColumn(column_t column, const std::string &value, std::function<void(const Record &)> callable) const {
  rocksdb::Status status;
  ReadStoreKey key{column, value};
  std::string result;

  status = db_->Get(env_->getReadStoreReadOptions(), key.ToSlice(), &result);
  if (status.IsNotFound()) {
    return;
  } else if (!status.ok()) {
    throw TabletLevelDbException{status};
  }

  BitArray bitArray;
  bitArray.readStream(result.data(), result.size());

  result.clear();
  Record currentRecord;

  bitArray.iterateSetBits(static_cast<offsetType>(-1), [&] (uint64_t pos) {
    rocksdb::Slice newKey = ReadStoreKey::MaterializedRowKey(pos).ToSlice();
    status = db_->Get(
        env_->getReadStoreReadOptions(),
        newKey,
        &result
    );
    if (status.IsNotFound()) {
      return;
    }
    if (!status.ok()) {
      throw TabletLevelDbException{status};
    }

    currentRecord.ParseFromString(result);
    callable(currentRecord);
  });
}
void	MeshTopoData::UpdateClusterVertices(Tab<ClusterClass*> &clusterList)
{
	BitArray processedVerts;
	processedVerts.SetSize(TVMaps.v.Count());

	for (int i = 0; i < clusterList.Count(); i++)
	{
		
		if (clusterList[i]->ld == this)
		{
			clusterList[i]->verts.SetCount(0);
			processedVerts.ClearAll();
			for (int j = 0; j < clusterList[i]->faces.Count(); j++)
			{
				int findex = clusterList[i]->faces[j];
				AddVertsToCluster(findex, processedVerts, clusterList[i]);
			}
			for (int j = 0; j < clusterList[i]->verts.Count(); j++)
			{
				int id = clusterList[i]->verts[j];
			}
		}
	}
}
Example #15
0
void SymmetryMod::SliceTriObject (Mesh & mesh, Point3 & N, float offset) {
	// Steve Anderson 9/14/2002
	// Using the new "MESH_TEMP_1" flag to override Slice selection behavior,
	// which is undesirable here.
	mesh.SetFlag (MESH_TEMP_1);
	MeshDelta slicemd;
	slicemd.Slice (mesh, N, offset, false, true);
	slicemd.Apply (mesh);
	mesh.ClearFlag (MESH_TEMP_1);

	// We need to strip out faces on the mirror plane itself.
	// (These aren't always removed by slice.)

	// Mark vertices at the plane boundary:
	BitArray targetVerts;
	targetVerts.SetSize (mesh.numVerts);
	targetVerts.ClearAll ();
	for (int i=0; i<mesh.numVerts; i++) {
		float dist = DotProd (N, mesh.verts[i]) - offset;
		if (fabsf(dist) > MNEPS) continue;
		targetVerts.Set (i);
	}
	BitArray delFaces, delVerts;
	delFaces.SetSize (mesh.numFaces);
	for (int i=0; i<mesh.numFaces; i++) {
      int j;
		for (j=0; j<3; j++) {
			if (!targetVerts[mesh.faces[i].v[j]]) break;
		}
		if (j<3) continue;
		// Face needs to be deleted.
		delFaces.Set (i);
	}
	mesh.DeleteFaceSet (delFaces, &delVerts);
	mesh.DeleteVertSet (delVerts);
}
Example #16
0
void	UnwrapMod::BuildUsedListFromSelection(BitArray &usedVerts)
	{
	usedVerts.SetSize(TVMaps.v.Count());
	usedVerts.ClearAll();

	for (int j =0; j < TVMaps.f.Count(); j++)
		{
		int faceIndex = j;
		if (TVMaps.f[faceIndex]->flags & FLAG_SELECTED)
			{
			for (int k = 0; k <  TVMaps.f[faceIndex]->count; k++)
				{
//ne	ed to put patch handles in here also
				int index = TVMaps.f[faceIndex]->t[k];
				usedVerts.Set(index);
				if ((TVMaps.f[faceIndex]->flags & FLAG_CURVEDMAPPING) && (TVMaps.f[faceIndex]->vecs))
					{
					index = TVMaps.f[faceIndex]->vecs->handles[k*2];
					if ((index >= 0) && (index < usedVerts.GetSize()))
						usedVerts.Set(index);

					index = TVMaps.f[faceIndex]->vecs->handles[k*2+1];
					if ((index >= 0) && (index < usedVerts.GetSize()))
						usedVerts.Set(index);
	
					if (TVMaps.f[faceIndex]->flags & FLAG_INTERIOR) 
						{
						index = TVMaps.f[faceIndex]->vecs->interiors[k];
						if ((index >= 0) && (index < usedVerts.GetSize()))
							usedVerts.Set(index);
						}
					}
				}
			}
		}

	}
Example #17
0
void save_bitarray(const char * filename, BitArray & array,
                   int width, int height)
{
    FSFile fp(filename, "w");
    if (!fp.is_open())
        return;
    FileStream stream(fp);
    stream.write_uint32(width);
    stream.write_uint32(height);
    for (int y = 0; y < height; ++y)
    for (int x = 0; x < width; ++x) {
        if (array.get(y * width + x))
            stream.write_uint8(0xFF);
        else
            stream.write_uint8(0x00);
    }
    fp.close();
}
Example #18
0
float EditFaceDataModData::FaceValue (int faceID) {
	if (faceID<0) return 0.0f;
	if (faceID>mFacesAffected.GetSize()) return 0.0f;
	if (mFacesAffected[faceID]) return mtNewFaceValues[faceID];
	IFaceDataMgr *pFDMgr = NULL;
	if (mpCacheMesh && (faceID < mpCacheMesh->numFaces)) {
		// Get the face data manager from the mesh:
		pFDMgr = static_cast<IFaceDataMgr*>(mpCacheMesh->GetInterface (FACEDATAMGR_INTERFACE));
	}
	if (mpCacheMNMesh && (faceID < mpCacheMNMesh->numf)) {
		// Get the face data manager from the mesh:
		pFDMgr = static_cast<IFaceDataMgr*>(mpCacheMNMesh->GetInterface (FACEDATAMGR_INTERFACE));
	}
	if (pFDMgr == NULL) return 0.0f;
	SampleFaceData* fdc = dynamic_cast<SampleFaceData*>(pFDMgr->GetFaceDataChan( FACE_MAXSAMPLEUSE_CLSID ));
	if (!fdc) return 0.0f;
	float val;
	if (!fdc->GetValue (faceID, val)) return 0.0f;
	return val;
}
static std::string
DecodeAI01320x(const BitArray& bits)
{
	static const int HEADER_SIZE = 4 + 1;
	static const int WEIGHT_SIZE = 15;

	if (bits.size() != HEADER_SIZE + AI01_GTIN_SIZE + WEIGHT_SIZE) {
		return std::string();
	}

	std::string buffer;
	AI01EncodeCompressedGtin(buffer, bits, HEADER_SIZE);
	AI01EncodeCompressedWeight(buffer, bits, HEADER_SIZE + AI01_GTIN_SIZE, WEIGHT_SIZE,
		// addWeightCode
		[](std::string& buf, int weight) { buf.append(weight < 10000 ? "(3202)" : "(3203)"); },
		// checkWeight
		[](int weight) { return weight < 10000 ? weight : weight - 10000; });

	return buffer;
}
Example #20
0
// Since vertices might have different normals depending on the face
// you are accessing it through, we get the normal for each face that
// connects to this vertex and interpolate these normals to get a single
// vertex normal fairly perpendicular to the mesh at the point of
// this vertex.
Point3 interpVertexNormal(Mesh* mesh, Matrix3 tm, unsigned int vxNo, BitArray& faceList)
{
	Point3 iNormal = Point3(0.0f, 0.0f, 0.0f);
	int numNormals = 0;

	for (int f = 0; f < mesh->numFaces; f++) {
		for (int fi = 0; fi < 3; fi++) {
			if (mesh->faces[f].v[fi] == vxNo) {
				Point3& fn = VectorTransform(tm, mesh->getFaceNormal(f));
				iNormal += fn;
				numNormals++;
				faceList.Set(f);
			}
		}
	}

	iNormal = iNormal / (float)numNormals;

	return Normalize(iNormal);
}
Example #21
0
// *****************************************************************************
// * Function Name: PrintPrimes                                                *
// * Description:  Asks the user to input a positive inteber.  Keeps asking    *
// *   until a correct value is entered and than returns the value.            *
// *                                                                           *
// * Date: April 1, 2013                                                       *
// * Author: Dr. David A. Gaitros                                              *
// *****************************************************************************
void PrintPrimes(const BitArray & b, const int max)
{   int counter; 
    
    cout << "\nPrimes less than " << max << ':'<< '\n';
     for (int i = 0; i< max; i++)
     {   
       if (b.Query(i))
       {
           counter++;
           cout << i;
         
        if (counter % 8 == 0)
          {
            cout << '\n';
            counter = 0;
          }
          else
            cout << '\t';
       }
     }
}
Example #22
0
  void GetPureBadness(Mesh & mesh, Array<double> & pure_badness,
		      const BitArray & isnewpoint)
  {
    //const int ne = mesh.GetNE();
    const int np = mesh.GetNP();

    pure_badness.SetSize(np+PointIndex::BASE+1);
    pure_badness = -1;

    Array< Point<3>* > backup(np);

    for(int i=0; i<np; i++)
      {
	backup[i] = new Point<3>(mesh.Point(i+1));

	if(isnewpoint.Test(i+PointIndex::BASE) &&
	   mesh.mlbetweennodes[i+PointIndex::BASE][0] > 0)
	  {
	    mesh.Point(i+1) = Center(mesh.Point(mesh.mlbetweennodes[i+PointIndex::BASE][0]),
				     mesh.Point(mesh.mlbetweennodes[i+PointIndex::BASE][1]));
	  }
      }
    for (ElementIndex i = 0; i < mesh.GetNE(); i++)
      {
	double bad = mesh[i].CalcJacobianBadness (mesh.Points());
	for(int j=0; j<mesh[i].GetNP(); j++)
	  if(bad > pure_badness[mesh[i][j]])
	    pure_badness[mesh[i][j]] = bad;

	// save maximum
	if(bad > pure_badness.Last())
	  pure_badness.Last() = bad; 
      }
    
    for(int i=0; i<np; i++)
      {
	mesh.Point(i+1) = *backup[i];
	delete backup[i];
      }
  }
static std::string
DecodeAI01392x(const BitArray& bits)
{
	static const int HEADER_SIZE = 5 + 1 + 2;
	static const int LAST_DIGIT_SIZE = 2;

	if (bits.size() < HEADER_SIZE + AI01_GTIN_SIZE) {
		return std::string();
	}

	std::string buffer;
	AI01EncodeCompressedGtin(buffer, bits, HEADER_SIZE);

	int lastAIdigit = GenericAppIdDecoder::ExtractNumeric(bits, HEADER_SIZE + AI01_GTIN_SIZE, LAST_DIGIT_SIZE);
	buffer.append("(392");
	buffer.append(std::to_string(lastAIdigit));
	buffer.push_back(')');

	if (StatusIsOK(GenericAppIdDecoder::DecodeGeneralPurposeField(bits, HEADER_SIZE + AI01_GTIN_SIZE + LAST_DIGIT_SIZE, buffer))) {
		return buffer;
	}
	return std::string();
}
void MNMesh_selectFaceLoops(MNMesh *mesh, int startid, BitArray &facesel)
{
  BitArray secondarysel(mesh->ENum());
  BitArray ringsel(mesh->ENum());
  facesel.SetSize(mesh->FNum());

  mesh->getEdgeSel(secondarysel);
  // convert to Edge
  MNFace *face = mesh->F(startid);
  for (int d = 0; d < face->deg; d++){
    ringsel.Set(face->edg[d]);
  }
  // ring
  mesh->SelectEdgeRing(ringsel);

  // back to face
  BitArrayEdgeToFace etf(mesh,&facesel);
  SM_BITARRAY_ENUMSET(ringsel,etf,BitArrayEdgeToFace);
  mesh->FaceSelect(facesel);

  // restor old edges
  mesh->EdgeSelect(secondarysel);
}
BOOL MNMeshLoopAdvancer::Advance(MNMeshLoopFront* front, MNMeshLoopItem* item, int itemindex, int wave, BitArray &finalsel)
{
  if (front->nextid < 0 || (front->crossed && finalsel[front->nextid]))
    return TRUE;


  int newid = front->nextid;
  item->wave = wave;
  item->previndex = front->previndex;
  item->id = newid;
  item->pos = GetPos(newid);
  front->previndex = itemindex;
  front->previd = newid;

  front->crossed = finalsel[newid];
  finalsel.Set(newid);

  // check for next connector
  front->connector = GetNextConnector(front->connector,front->contype,newid);
  //front->connector = front->connector == newconnector ? -1 : newconnector;
  front->nextid = front->connector < 0 ? -1 : GetNextID(front->connector,front->contype,newid);

  return FALSE;
}
void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate& update, const Element* animatingElement, const ComputedStyle& style)
{
    if (!animatingElement)
        return;

    if (animatingElement->document().printing() || animatingElement->document().wasPrinting())
        return;

    ElementAnimations* elementAnimations = animatingElement->elementAnimations();
    const TransitionMap* activeTransitions = elementAnimations ? &elementAnimations->cssAnimations().m_transitions : nullptr;
    const CSSTransitionData* transitionData = style.transitions();

#if ENABLE(ASSERT)
    // In debug builds we verify that it would have been safe to avoid populating and testing listedProperties if the style recalc is due to animation.
    const bool animationStyleRecalc = false;
#else
    // In release builds we avoid the cost of checking for new and interrupted transitions if the style recalc is due to animation.
    const bool animationStyleRecalc = elementAnimations && elementAnimations->isAnimationStyleChange();
#endif

    BitArray<numCSSProperties> listedProperties;
    bool anyTransitionHadTransitionAll = false;
    const LayoutObject* layoutObject = animatingElement->layoutObject();
    if (!animationStyleRecalc && style.display() != NONE && layoutObject && layoutObject->style() && transitionData) {
        const ComputedStyle& oldStyle = *layoutObject->style();

        for (size_t i = 0; i < transitionData->propertyList().size(); ++i) {
            const CSSTransitionData::TransitionProperty& transitionProperty = transitionData->propertyList()[i];
            if (transitionProperty.propertyType != CSSTransitionData::TransitionKnownProperty)
                continue;

            CSSPropertyID property = resolveCSSPropertyID(transitionProperty.unresolvedProperty);
            bool animateAll = property == CSSPropertyAll;
            if (animateAll)
                anyTransitionHadTransitionAll = true;
            const StylePropertyShorthand& propertyList = animateAll ? CSSAnimations::propertiesForTransitionAll() : shorthandForProperty(property);
            // If not a shorthand we only execute one iteration of this loop, and refer to the property directly.
            for (unsigned j = 0; !j || j < propertyList.length(); ++j) {
                CSSPropertyID id = propertyList.length() ? propertyList.properties()[j] : property;
                ASSERT(id >= firstCSSProperty);

                if (!animateAll) {
                    if (CSSPropertyMetadata::isInterpolableProperty(id))
                        listedProperties.set(id - firstCSSProperty);
                    else
                        continue;
                }

                // FIXME: We should transition if an !important property changes even when an animation is running,
                // but this is a bit hard to do with the current applyMatchedProperties system.
                PropertyHandle property = PropertyHandle(id);
                if (!update.activeInterpolationsForAnimations().contains(property)
                    && (!elementAnimations || !elementAnimations->cssAnimations().m_previousActiveInterpolationsForAnimations.contains(property))) {
                    calculateTransitionUpdateForProperty(id, *transitionData, i, oldStyle, style, activeTransitions, update, animatingElement);
                }
            }
        }
    }

    if (activeTransitions) {
        for (const auto& entry : *activeTransitions) {
            CSSPropertyID id = entry.key;
            if (!anyTransitionHadTransitionAll && !animationStyleRecalc && !listedProperties.get(id - firstCSSProperty)) {
                // TODO: Figure out why this fails on Chrome OS login page. crbug.com/365507
                // ASSERT(animation.playStateInternal() == Animation::Finished || !(elementAnimations && elementAnimations->isAnimationStyleChange()));
                update.cancelTransition(id);
            } else if (entry.value.animation->finishedInternal()) {
                update.finishTransition(id);
            }
        }
    }
}
Example #27
0
  void RepairBisection(Mesh & mesh, Array<ElementIndex> & bad_elements, 
		       const BitArray & isnewpoint, const Refinement & refinement,
		       const Array<double> & pure_badness, 
		       double max_worsening, const bool uselocalworsening,
		       const Array< Array<int,PointIndex::BASE>* > & idmaps)
  {
    ostringstream ostrstr;

    const int maxtrials = 100;

    //bool doit;
    //cout << "DOIT: " << flush;
    //cin >> doit;

    int ne = mesh.GetNE();
    int np = mesh.GetNP();

    int numbadneighbours = 3;
    const int numtopimprove = 3;

    PrintMessage(1,"repairing");

    PushStatus("Repair Bisection");

    Array<Point<3>* > should(np);
    Array<Point<3>* > can(np);
    Array<Vec<3>* > nv(np);
    for(int i=0; i<np; i++)
      {
	nv[i] = new Vec<3>;
	should[i] = new Point<3>;
	can[i] = new Point<3>;
      }
    
    BitArray isboundarypoint(np),isedgepoint(np);
    isboundarypoint.Clear();
    isedgepoint.Clear();

    for(int i = 1; i <= mesh.GetNSeg(); i++)
      {
	const Segment & seg = mesh.LineSegment(i);
	isedgepoint.Set(seg[0]);
	isedgepoint.Set(seg[1]);
      }

    Array<int> surfaceindex(np);
    surfaceindex = -1;
    
    for (int i = 1; i <= mesh.GetNSE(); i++)
      {
	const Element2d & sel = mesh.SurfaceElement(i);
	for (int j = 1; j <= sel.GetNP(); j++)
	  if(!isedgepoint.Test(sel.PNum(j)))
	    {
	      isboundarypoint.Set(sel.PNum(j));
	      surfaceindex[sel.PNum(j) - PointIndex::BASE] = 
		mesh.GetFaceDescriptor(sel.GetIndex()).SurfNr();
	    }
      }



    Validate(mesh,bad_elements,pure_badness,
	     ((uselocalworsening) ?  (0.8*(max_worsening-1.) + 1.) : (0.1*(max_worsening-1.) + 1.)),
	     uselocalworsening); // -> larger working area
    BitArray working_elements(ne);
    BitArray working_points(np);

    GetWorkingArea(working_elements,working_points,mesh,bad_elements,numbadneighbours);
    //working_elements.Set();
    //working_points.Set();

    ostrstr.str("");
    ostrstr << "worsening: " <<
      Validate(mesh,bad_elements,pure_badness,max_worsening,uselocalworsening);
    PrintMessage(4,ostrstr.str());

    

    int auxnum=0;
    for(int i=1; i<=np; i++)
      if(working_points.Test(i))
	auxnum++;
    
    ostrstr.str("");
    ostrstr << "Percentage working points: " << 100.*double(auxnum)/np;
    PrintMessage(5,ostrstr.str());
    

    BitArray isworkingboundary(np);
    for(int i=1; i<=np; i++)
      if(working_points.Test(i) && isboundarypoint.Test(i))
	isworkingboundary.Set(i);
      else
	isworkingboundary.Clear(i);


    for(int i=0; i<np; i++)
      *should[i] = mesh.Point(i+1);

    
    for(int i=0; i<np; i++)
      {
	if(isnewpoint.Test(i+PointIndex::BASE) && 
	   //working_points.Test(i+PointIndex::BASE) && 
	   mesh.mlbetweennodes[i+PointIndex::BASE][0] > 0)
	  *can[i] = Center(*can[mesh.mlbetweennodes[i+PointIndex::BASE][0]-PointIndex::BASE],
			   *can[mesh.mlbetweennodes[i+PointIndex::BASE][1]-PointIndex::BASE]);
	else
	  *can[i] = mesh.Point(i+1);
      }


    int cnttrials = 1;
    
    double lamedge = 0.5;
    double lamface = 0.5;
    
    double facokedge = 0;
    double facokface = 0;
    double factryedge;
    double factryface = 0;

    double oldlamedge,oldlamface;

    MeshOptimize2d * optimizer2d = refinement.Get2dOptimizer();
    if(!optimizer2d)
      {
	cerr << "No 2D Optimizer!" << endl;
	return;
      }    

    while ((facokedge < 1.-1e-8 || facokface < 1.-1e-8) && 
	   cnttrials < maxtrials &&
	   multithread.terminate != 1)
      {
	(*testout) << "   facokedge " << facokedge << " facokface " << facokface << " cnttrials " << cnttrials << endl
		   << " perc. " << 95. * max2( min2(facokedge,facokface),
					       double(cnttrials)/double(maxtrials)) << endl;

	SetThreadPercent(95. * max2( min2(facokedge,facokface),
				     double(cnttrials)/double(maxtrials)));

	ostrstr.str("");
	ostrstr << "max. worsening " << max_worsening;
	PrintMessage(5,ostrstr.str());
	oldlamedge = lamedge;
	lamedge *= 6;
	if (lamedge > 2)
	  lamedge = 2;
	   
	if(1==1 || facokedge < 1.-1e-8)
	  {
	    for(int i=0; i<nv.Size(); i++)
	      *nv[i] = Vec<3>(0,0,0);
	    for (int i = 1; i <= mesh.GetNSE(); i++)
	      {
		const Element2d & sel = mesh.SurfaceElement(i);
		Vec<3> auxvec = Cross(mesh.Point(sel.PNum(2))-mesh.Point(sel.PNum(1)),
                                      mesh.Point(sel.PNum(3))-mesh.Point(sel.PNum(1)));
		auxvec.Normalize();
		for (int j = 1; j <= sel.GetNP(); j++)
		  if(!isedgepoint.Test(sel.PNum(j)))
		    *nv[sel.PNum(j) - PointIndex::BASE] += auxvec;
	      }
	    for(int i=0; i<nv.Size(); i++)
	      nv[i]->Normalize();
	    
	    
	    do  // move edges
	      {
		lamedge *= 0.5;
		cnttrials++;
		if(cnttrials % 10 == 0)
		  max_worsening *= 1.1;
		
		
		factryedge = lamedge + (1.-lamedge) * facokedge;

		ostrstr.str("");
		ostrstr << "lamedge = " << lamedge << ", trying: " << factryedge;
		PrintMessage(5,ostrstr.str());
		

		for (int i = 1; i <= np; i++)
		  {
		    if (isedgepoint.Test(i))
		      {
			for (int j = 0; j < 3; j++)
			  mesh.Point(i)(j) = 
			    lamedge * (*should.Get(i))(j) +
			    (1.-lamedge) * (*can.Get(i))(j);
		      }
		    else
		      mesh.Point(i) = *can.Get(i);
		  }
		if(facokedge < 1.-1e-8)
		  {
		    ostrstr.str("");
		    ostrstr << "worsening: " <<
		      Validate(mesh,bad_elements,pure_badness,max_worsening,uselocalworsening);

		    PrintMessage(5,ostrstr.str());
		  }
		else
		  Validate(mesh,bad_elements,pure_badness,-1,uselocalworsening);


		ostrstr.str("");
		ostrstr << bad_elements.Size() << " bad elements";
		PrintMessage(5,ostrstr.str());
	      }
	    while (bad_elements.Size() > 0 && 
		   cnttrials < maxtrials &&
		   multithread.terminate != 1);
	  }

	if(cnttrials < maxtrials &&
	   multithread.terminate != 1)
	  {
	    facokedge = factryedge;
	    
	    // smooth faces
	    mesh.CalcSurfacesOfNode();
	    
	    MeshingParameters dummymp;
	    mesh.ImproveMeshJacobianOnSurface(dummymp,isworkingboundary,nv,OPT_QUALITY, &idmaps);
	    
	    for (int i = 1; i <= np; i++)
	      *can.Elem(i) = mesh.Point(i);
	    
	    if(optimizer2d)
	      optimizer2d->ProjectBoundaryPoints(surfaceindex,can,should);
	  }


	oldlamface = lamface;
	lamface *= 6;
	if (lamface > 2)
	  lamface = 2;


	if(cnttrials < maxtrials &&
	   multithread.terminate != 1)
	  {

	    do  // move faces
	      {
		lamface *= 0.5;
		cnttrials++;
		if(cnttrials % 10 == 0)
		  max_worsening *= 1.1;
		factryface = lamface + (1.-lamface) * facokface;

		ostrstr.str("");
		ostrstr << "lamface = " << lamface << ", trying: " << factryface;
		PrintMessage(5,ostrstr.str());
		
		
		for (int i = 1; i <= np; i++)
		  {
		    if (isboundarypoint.Test(i))
		      {
			for (int j = 0; j < 3; j++)
			  mesh.Point(i)(j) = 
			    lamface * (*should.Get(i))(j) +
			    (1.-lamface) * (*can.Get(i))(j);
		      }
		    else
		      mesh.Point(i) = *can.Get(i);
		  }

		ostrstr.str("");
		ostrstr << "worsening: " <<
		  Validate(mesh,bad_elements,pure_badness,max_worsening,uselocalworsening);
		PrintMessage(5,ostrstr.str());
	

		ostrstr.str("");
		ostrstr << bad_elements.Size() << " bad elements";
		PrintMessage(5,ostrstr.str());
	      }
	    while (bad_elements.Size() > 0 && 
		   cnttrials < maxtrials &&
		   multithread.terminate != 1);
	  }



	if(cnttrials < maxtrials &&
	   multithread.terminate != 1)
	  {
	    facokface = factryface;
	    // smooth interior
	    
	    mesh.CalcSurfacesOfNode();
	    
	    MeshingParameters dummymp;
	    mesh.ImproveMeshJacobian (dummymp, OPT_QUALITY,&working_points);
	    //mesh.ImproveMeshJacobian (OPT_WORSTCASE,&working_points);
	  

	    for (int i = 1; i <= np; i++)
	      *can.Elem(i) = mesh.Point(i);
	  }
	  
	//!
	if((facokedge < 1.-1e-8 || facokface < 1.-1e-8) && 
	   cnttrials < maxtrials &&
	   multithread.terminate != 1)
	  {
	    MeshingParameters dummymp;
	    MeshOptimize3d optmesh(dummymp);
	    for(int i=0; i<numtopimprove; i++)
	      {
		optmesh.SwapImproveSurface(mesh,OPT_QUALITY,&working_elements,&idmaps);
		optmesh.SwapImprove(mesh,OPT_QUALITY,&working_elements);
		
	      }	    

	    //	    mesh.mglevels = 1;
	    
		
	    ne = mesh.GetNE();
	    working_elements.SetSize(ne);
	    
	    
	    for (int i = 1; i <= np; i++)
	      mesh.Point(i) = *should.Elem(i);
	    
	    Validate(mesh,bad_elements,pure_badness,
		     ((uselocalworsening) ?  (0.8*(max_worsening-1.) + 1.) : (0.1*(max_worsening-1.) + 1.)),
		     uselocalworsening);
	    
	    if(lamedge < oldlamedge || lamface < oldlamface)
	      numbadneighbours++;
	    GetWorkingArea(working_elements,working_points,mesh,bad_elements,numbadneighbours);
	    for(int i=1; i<=np; i++)
	      if(working_points.Test(i) && isboundarypoint.Test(i))
		isworkingboundary.Set(i);
	      else
		isworkingboundary.Clear(i);
	    auxnum=0;
	    for(int i=1; i<=np; i++)
	      if(working_points.Test(i))
		auxnum++;

	    
	    ostrstr.str("");
	    ostrstr << "Percentage working points: " << 100.*double(auxnum)/np;
	    PrintMessage(5,ostrstr.str());
	    
	    for (int i = 1; i <= np; i++)
	      mesh.Point(i) = *can.Elem(i);
	  }
	//!

      }

    MeshingParameters dummymp;
    MeshOptimize3d optmesh(dummymp);
    for(int i=0; i<numtopimprove && multithread.terminate != 1; i++)
      {
	optmesh.SwapImproveSurface(mesh,OPT_QUALITY,NULL,&idmaps);
	optmesh.SwapImprove(mesh,OPT_QUALITY);
	//mesh.UpdateTopology();
      }
    mesh.UpdateTopology();
    /*
    if(cnttrials < 100)
      {
	nv = Vec3d(0,0,0);
	for (int i = 1; i <= mesh.GetNSE(); i++)
	  {
	    const Element2d & sel = mesh.SurfaceElement(i);
	    Vec3d auxvec = Cross(mesh.Point(sel.PNum(2))-mesh.Point(sel.PNum(1)),
				 mesh.Point(sel.PNum(3))-mesh.Point(sel.PNum(1)));
	    auxvec.Normalize();
	    for (int j = 1; j <= sel.GetNP(); j++)
	      if(!isedgepoint.Test(sel.PNum(j)))
		nv[sel.PNum(j) - PointIndex::BASE] += auxvec;
	  }
	for(int i=0; i<nv.Size(); i++)
	  nv[i].Normalize();
	

	mesh.ImproveMeshJacobianOnSurface(isboundarypoint,nv,OPT_QUALITY);
	mesh.CalcSurfacesOfNode();
	    // smooth interior
	    
	
	for (int i = 1; i <= np; i++)
	  if(isboundarypoint.Test(i))
	    can.Elem(i) = mesh.Point(i);
	    
	if(optimizer2d)
	  optimizer2d->ProjectBoundaryPoints(surfaceindex,can,should);

	
	for (int i = 1; i <= np; i++)
	  if(isboundarypoint.Test(i))
	    for(int j=1; j<=3; j++)
	      mesh.Point(i).X(j) = should.Get(i).X(j);
      }
    */


    if(cnttrials == maxtrials)
      {
	for (int i = 1; i <= np; i++)
	  mesh.Point(i) = *should.Get(i);

	Validate(mesh,bad_elements,pure_badness,max_worsening,uselocalworsening);
	
	for(int i=0; i<bad_elements.Size(); i++)
	  {
	    ostrstr.str("");
	    ostrstr << "bad element:" << endl
		    << mesh[bad_elements[i]][0] << ": " << mesh.Point(mesh[bad_elements[i]][0]) << endl
		    << mesh[bad_elements[i]][1] << ": " << mesh.Point(mesh[bad_elements[i]][1]) << endl
		    << mesh[bad_elements[i]][2] << ": " << mesh.Point(mesh[bad_elements[i]][2]) << endl
		    << mesh[bad_elements[i]][3] << ": " << mesh.Point(mesh[bad_elements[i]][3]);
	    PrintMessage(5,ostrstr.str());
	  }
	for (int i = 1; i <= np; i++)
	  mesh.Point(i) = *can.Get(i);
      }

    for(int i=0; i<np; i++)
      {
	delete nv[i];
	delete can[i];
	delete should[i];
      }

    PopStatus();
  }
Example #28
0
String StylePropertySet::asText() const
{
    StringBuilder result;

    int positionXPropertyIndex = -1;
    int positionYPropertyIndex = -1;
    int repeatXPropertyIndex = -1;
    int repeatYPropertyIndex = -1;

    BitArray<numCSSProperties> shorthandPropertyUsed;
    BitArray<numCSSProperties> shorthandPropertyAppeared;

    unsigned size = propertyCount();
    unsigned numDecls = 0;
    for (unsigned n = 0; n < size; ++n) {
        PropertyReference property = propertyAt(n);
        CSSPropertyID propertyID = property.id();
        CSSPropertyID shorthandPropertyID = CSSPropertyInvalid;
        CSSPropertyID borderFallbackShorthandProperty = CSSPropertyInvalid;
        String value;

        switch (propertyID) {
#if ENABLE(CSS_VARIABLES)
        case CSSPropertyVariable:
            if (numDecls++)
                result.append(' ');
            result.append(property.cssText());
            continue;
#endif
        case CSSPropertyBackgroundPositionX:
            positionXPropertyIndex = n;
            continue;
        case CSSPropertyBackgroundPositionY:
            positionYPropertyIndex = n;
            continue;
        case CSSPropertyBackgroundRepeatX:
            repeatXPropertyIndex = n;
            continue;
        case CSSPropertyBackgroundRepeatY:
            repeatYPropertyIndex = n;
            continue;
        case CSSPropertyBorderTopWidth:
        case CSSPropertyBorderRightWidth:
        case CSSPropertyBorderBottomWidth:
        case CSSPropertyBorderLeftWidth:
            if (!borderFallbackShorthandProperty)
                borderFallbackShorthandProperty = CSSPropertyBorderWidth;
        case CSSPropertyBorderTopStyle:
        case CSSPropertyBorderRightStyle:
        case CSSPropertyBorderBottomStyle:
        case CSSPropertyBorderLeftStyle:
            if (!borderFallbackShorthandProperty)
                borderFallbackShorthandProperty = CSSPropertyBorderStyle;
        case CSSPropertyBorderTopColor:
        case CSSPropertyBorderRightColor:
        case CSSPropertyBorderBottomColor:
        case CSSPropertyBorderLeftColor:
            if (!borderFallbackShorthandProperty)
                borderFallbackShorthandProperty = CSSPropertyBorderColor;

            // FIXME: Deal with cases where only some of border-(top|right|bottom|left) are specified.
            if (!shorthandPropertyAppeared.get(CSSPropertyBorder - firstCSSProperty)) {
                value = borderPropertyValue(ReturnNullOnUncommonValues);
                if (value.isNull())
                    shorthandPropertyAppeared.set(CSSPropertyBorder - firstCSSProperty);
                else
                    shorthandPropertyID = CSSPropertyBorder;
            } else if (shorthandPropertyUsed.get(CSSPropertyBorder - firstCSSProperty))
                shorthandPropertyID = CSSPropertyBorder;
            if (!shorthandPropertyID)
                shorthandPropertyID = borderFallbackShorthandProperty;
            break;
        case CSSPropertyWebkitBorderHorizontalSpacing:
        case CSSPropertyWebkitBorderVerticalSpacing:
            shorthandPropertyID = CSSPropertyBorderSpacing;
            break;
        case CSSPropertyFontFamily:
        case CSSPropertyLineHeight:
        case CSSPropertyFontSize:
        case CSSPropertyFontStyle:
        case CSSPropertyFontVariant:
        case CSSPropertyFontWeight:
            // Don't use CSSPropertyFont because old UAs can't recognize them but are important for editing.
            break;
        case CSSPropertyListStyleType:
        case CSSPropertyListStylePosition:
        case CSSPropertyListStyleImage:
            shorthandPropertyID = CSSPropertyListStyle;
            break;
        case CSSPropertyMarginTop:
        case CSSPropertyMarginRight:
        case CSSPropertyMarginBottom:
        case CSSPropertyMarginLeft:
            shorthandPropertyID = CSSPropertyMargin;
            break;
        case CSSPropertyOutlineWidth:
        case CSSPropertyOutlineStyle:
        case CSSPropertyOutlineColor:
            shorthandPropertyID = CSSPropertyOutline;
            break;
        case CSSPropertyOverflowX:
        case CSSPropertyOverflowY:
            shorthandPropertyID = CSSPropertyOverflow;
            break;
        case CSSPropertyPaddingTop:
        case CSSPropertyPaddingRight:
        case CSSPropertyPaddingBottom:
        case CSSPropertyPaddingLeft:
            shorthandPropertyID = CSSPropertyPadding;
            break;
        case CSSPropertyWebkitAnimationName:
        case CSSPropertyWebkitAnimationDuration:
        case CSSPropertyWebkitAnimationTimingFunction:
        case CSSPropertyWebkitAnimationDelay:
        case CSSPropertyWebkitAnimationIterationCount:
        case CSSPropertyWebkitAnimationDirection:
        case CSSPropertyWebkitAnimationFillMode:
            shorthandPropertyID = CSSPropertyWebkitAnimation;
            break;
        case CSSPropertyWebkitFlexDirection:
        case CSSPropertyWebkitFlexWrap:
            shorthandPropertyID = CSSPropertyWebkitFlexFlow;
            break;
        case CSSPropertyWebkitFlexBasis:
        case CSSPropertyWebkitFlexGrow:
        case CSSPropertyWebkitFlexShrink:
            shorthandPropertyID = CSSPropertyWebkitFlex;
            break;
        case CSSPropertyWebkitMaskPositionX:
        case CSSPropertyWebkitMaskPositionY:
        case CSSPropertyWebkitMaskRepeatX:
        case CSSPropertyWebkitMaskRepeatY:
        case CSSPropertyWebkitMaskImage:
        case CSSPropertyWebkitMaskRepeat:
        case CSSPropertyWebkitMaskPosition:
        case CSSPropertyWebkitMaskClip:
        case CSSPropertyWebkitMaskOrigin:
            shorthandPropertyID = CSSPropertyWebkitMask;
            break;
        case CSSPropertyWebkitTransformOriginX:
        case CSSPropertyWebkitTransformOriginY:
        case CSSPropertyWebkitTransformOriginZ:
            shorthandPropertyID = CSSPropertyWebkitTransformOrigin;
            break;
        case CSSPropertyWebkitTransitionProperty:
        case CSSPropertyWebkitTransitionDuration:
        case CSSPropertyWebkitTransitionTimingFunction:
        case CSSPropertyWebkitTransitionDelay:
            shorthandPropertyID = CSSPropertyWebkitTransition;
            break;
#if ENABLE(CSS_EXCLUSIONS)
        case CSSPropertyWebkitWrapFlow:
        case CSSPropertyWebkitShapeMargin:
        case CSSPropertyWebkitShapePadding:
            shorthandPropertyID = CSSPropertyWebkitWrap;
            break;
#endif
        default:
            break;
        }

        unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty;
        if (shorthandPropertyID) {
            if (shorthandPropertyUsed.get(shortPropertyIndex))
                continue;
            if (!shorthandPropertyAppeared.get(shortPropertyIndex) && value.isNull())
                value = getPropertyValue(shorthandPropertyID);
            shorthandPropertyAppeared.set(shortPropertyIndex);
        }

        if (!value.isNull()) {
            propertyID = shorthandPropertyID;
            shorthandPropertyUsed.set(shortPropertyIndex);
        } else
            value = property.value()->cssText();

        if (value == "initial" && !CSSProperty::isInheritedProperty(propertyID))
            continue;

        if (numDecls++)
            result.append(' ');
        result.append(getPropertyName(propertyID));
        result.appendLiteral(": ");
        result.append(value);
        if (property.isImportant())
            result.appendLiteral(" !important");
        result.append(';');
    }

    // FIXME: This is a not-so-nice way to turn x/y positions into single background-position in output.
    // It is required because background-position-x/y are non-standard properties and WebKit generated output
    // would not work in Firefox (<rdar://problem/5143183>)
    // It would be a better solution if background-position was CSS_PAIR.
    if (positionXPropertyIndex != -1 && positionYPropertyIndex != -1 && propertyAt(positionXPropertyIndex).isImportant() == propertyAt(positionYPropertyIndex).isImportant()) {
        PropertyReference positionXProperty = propertyAt(positionXPropertyIndex);
        PropertyReference positionYProperty = propertyAt(positionYPropertyIndex);

        if (numDecls++)
            result.append(' ');
        result.appendLiteral("background-position: ");
        if (positionXProperty.value()->isValueList() || positionYProperty.value()->isValueList())
            result.append(getLayeredShorthandValue(backgroundPositionShorthand()));
        else {
            result.append(positionXProperty.value()->cssText());
            result.append(' ');
            result.append(positionYProperty.value()->cssText());
        }
        if (positionXProperty.isImportant())
            result.appendLiteral(" !important");
        result.append(';');
    } else {
        if (positionXPropertyIndex != -1) {
            if (numDecls++)
                result.append(' ');
            result.append(propertyAt(positionXPropertyIndex).cssText());
        }
        if (positionYPropertyIndex != -1) {
            if (numDecls++)
                result.append(' ');
            result.append(propertyAt(positionYPropertyIndex).cssText());
        }
    }

    // FIXME: We need to do the same for background-repeat.
    if (repeatXPropertyIndex != -1 && repeatYPropertyIndex != -1 && propertyAt(repeatXPropertyIndex).isImportant() == propertyAt(repeatYPropertyIndex).isImportant()) {
        PropertyReference repeatXProperty = propertyAt(repeatXPropertyIndex);
        PropertyReference repeatYProperty = propertyAt(repeatYPropertyIndex);

        if (numDecls++)
            result.append(' ');
        result.appendLiteral("background-repeat: ");
        if (repeatXProperty.value()->isValueList() || repeatYProperty.value()->isValueList())
            result.append(getLayeredShorthandValue(backgroundRepeatShorthand()));
        else {
            result.append(repeatXProperty.value()->cssText());
            result.append(' ');
            result.append(repeatYProperty.value()->cssText());
        }
        if (repeatXProperty.isImportant())
            result.appendLiteral(" !important");
        result.append(';');
    } else {
        if (repeatXPropertyIndex != -1) {
            if (numDecls++)
                result.append(' ');
            result.append(propertyAt(repeatXPropertyIndex).cssText());
        }
        if (repeatYPropertyIndex != -1) {
            if (numDecls++)
                result.append(' ');
            result.append(propertyAt(repeatYPropertyIndex).cssText());
        }
    }

    ASSERT(!numDecls ^ !result.isEmpty());
    return result.toString();
}
Example #29
0
BitArray GammaEncoder::encode(unsigned int num) const{
    BitArray numBinaryRemaining = getBinaryWithoutHighestOne(num);
    return unary.encode(numBinaryRemaining.size() + 1) + numBinaryRemaining;
}
void MeshTopoData::RemoveDeadVerts(PatchMesh *mesh, int channel)
{
	Tab<Point3> vertList;
	Tab<int> idList;
	//copy over vertlist

	int ct = mesh->getNumMapVerts(channel);
	vertList.SetCount(ct);
	PatchTVert *tVerts = mesh->mapVerts(channel);
	for (int i = 0; i < ct; i++)
		vertList[i] = tVerts[i].p;

	BitArray usedList;
	usedList.SetSize(ct);
	TVPatch *tvFace = NULL;
	if (!mesh->getMapSupport(channel))
	{
		return;
	}

	tvFace = mesh->tvPatches[channel];
	if (tvFace == NULL) return;

	for (int i =0; i < mesh->numPatches; i++)
	{
		int pcount = 3;
		if (mesh->patches[i].type == PATCH_QUAD) pcount = 4;

		for (int j = 0; j < pcount; j++)
		{
			int index = tvFace[i].tv[j];
			usedList.Set(index);
			if (!(mesh->patches[i].flags & PATCH_LINEARMAPPING))
			{
				if (!(mesh->patches[i].flags & PATCH_AUTO))
				{
					index = tvFace[i].interiors[j];
					if ((index >= 0) && (index < usedList.GetSize())) usedList.Set(index);
				}
				index = tvFace[i].handles[j*2];
				if ((index >= 0) && (index < usedList.GetSize())) usedList.Set(index);
				index = tvFace[i].handles[j*2+1];
				if ((index >= 0) && (index < usedList.GetSize())) usedList.Set(index);

			}
		}
	}
	mesh->setNumMapVerts (channel,usedList.NumberSet(),TRUE);

	int current = 0;
	tVerts = mesh->mapVerts(channel);

	for (int i = 0; i < ct; i++)
	{
		if (usedList[i])
		{
			tVerts[current].p = vertList[i];
			//now fix up faces
			for (int j = 0; j < mesh->numPatches; j++)
			{
				int pcount = 3;
				if (mesh->patches[j].type == PATCH_QUAD) pcount = 4;

				for (int k = 0; k < pcount; k++)
				{
					int index = tvFace[j].tv[k];
					if (index == i)
					{
						tvFace[j].tv[k] = current;
					}

					index = tvFace[j].interiors[k];
					if ((index >=0) && (index == i))
					{
						tvFace[j].interiors[k] = current;
					}
					index = tvFace[j].handles[k*2];
					if ((index >=0) && (index == i))
					{
						tvFace[j].handles[k*2] = current;
					}
					index = tvFace[j].handles[k*2+1];
					if ((index >=0) && (index == i))
					{
						tvFace[j].handles[k*2+1] = current;
					}


				}

			}
			current++;
		}
}

}