void QMCCostFunctionSingle::resetPsi()
  {

    OptimizableSetType::iterator oit(OptVariables.begin()), oit_end(OptVariables.end());
    while(oit != oit_end)
    {
      Return_t v=(*oit).second;
      OptVariablesForPsi[(*oit).first]=v;
      map<string,set<string>*>::iterator eit(equalConstraints.find((*oit).first));
      if(eit != equalConstraints.end())
      {
        set<string>::iterator f((*eit).second->begin()),l((*eit).second->end());
        while(f != l)
        {
          OptVariablesForPsi[(*f)]=v;
          ++f;
        }
      }
      ++oit;
    }

    //cout << "QMCCostFunctionSingle::resetPsi " <<endl;
    //oit=OptVariablesForPsi.begin();
    //oit_end=OptVariablesForPsi.end();
    //while(oit != oit_end)
    //{
    //  cout << (*oit).first << "=" << (*oit).second << " ";
    //  ++oit;
    //}
    //cout << endl;
    Psi.resetParameters(OptVariablesForPsi);
  }
Example #2
0
RESULT eServiceCenter::addServiceFactory(int id, iServiceHandler *hnd, std::list<std::string> &extensions)
{
	handler.insert(std::pair<int,ePtr<iServiceHandler> >(id, hnd));
	for (std::list<std::string>::const_iterator eit(extensions.begin()); eit != extensions.end(); ++eit)
	{
		extensions_r[*eit] = id;
	}
	return 0;
}
Example #3
0
void SubdAccBuilder::computeCornerStencil(SubdFaceRing *ring, GregoryAccStencil *stencil)
{
	const int cornerIndices[7] = {8, 11, 19, 16,   6, 9, 12};
	int primitiveOffset = ring->is_quad()? 0: 4;

	SubdEdge *firstEdge = ring->firstEdge();

	/* compute corner control points */
	int v = 0;

	for(SubdFace::EdgeIterator it(firstEdge); !it.isDone(); it.advance(), v++) {
		SubdVert *vert = it.current()->from();
		int valence = vert->valence();
		int cid = cornerIndices[primitiveOffset+v];

		if(vert->is_boundary()) {
			/* compute vertex limit position */
			SubdEdge *edge0 = vert->edge;
			SubdEdge *edge1 = vert->edge->prev;

			assert(edge0->face == NULL);
			assert(edge0->to() != vert);
			assert(edge1->face == NULL);
			assert(edge1->from() != vert);

			stencil->get(cid, vert) = 2.0f/3.0f;
			stencil->get(cid, edge0->to()) = 1.0f/6.0f;
			stencil->get(cid, edge1->from()) = 1.0f/6.0f;

			assert(stencil->get(cid).is_normalized());
		}
		else {
			stencil->get(cid, vert) = 3.0f*valence*valence;

			for(SubdVert::EdgeIterator eit(vert->edge); !eit.isDone(); eit.advance()) {
				SubdEdge *edge = eit.current();
				assert(vert->co == edge->from()->co);

				stencil->get(cid, edge->to()) = 12.0f;

				if(SubdFaceRing::is_triangle(edge->face)) {
					/* distribute weight to all verts */
					stencil->get(cid, vert) += 1.0f;
					stencil->get(cid, edge->to()) += 1.0f;
					stencil->get(cid, edge->next->to()) += 1.0f;
				}
				else
					stencil->get(cid, edge->next->to()) = 3.0f;
			}

			/* normalize stencil. */
			stencil->get(cid).normalize();
		}
	}
}
Example #4
0
Q3MeshEdge *Q3MeshNode::edgeAdjacentTo(const Q3MeshNode *node) const
{
    QListIterator<Q3MeshEdge *> eit(edges_);
    while(eit.hasNext())
    {
        Q3MeshEdge *edge = eit.next();
        if (edge->a() == node || edge->b() == node)
            return edge;
    }
    return NULL;
}
Example #5
0
int eServiceFS::getServiceTypeForExtension(const std::string &str)
{
	for (std::map<int, std::list<std::string> >::iterator sit(m_additional_extensions.begin()); sit != m_additional_extensions.end(); ++sit)
	{
		for (std::list<std::string>::iterator eit(sit->second.begin()); eit != sit->second.end(); ++eit)
		{
			if (*eit == str)
				return sit->first;
		}
	}
	return -1;
}
Example #6
0
int eServiceCenter::getServiceTypeForExtension(const char *str)
{
	for (std::map<int, std::list<std::string> >::iterator sit(extensions.begin()); sit != extensions.end(); ++sit)
	{
		for (std::list<std::string>::iterator eit(sit->second.begin()); eit != sit->second.end(); ++eit)
		{
			if (*eit == str)
				return sit->first;
		}
	}
	return -1;
}
Example #7
0
void DualGraph::saveGraph(const char *filename) {
    std::ofstream output(filename);
    for (NodeIter nit(this); !nit.end(); ++nit) {
        GraphNode *node = *nit;
		output << "v " << node->id() << "\n";
	}

    for (EdgeIter eit(this); !eit.end(); ++eit) {
        GraphEdge *edge = *eit;
        output << "e " << edge->from()->id() << " " << edge->to()->id() << "\n";
	}
    output.close();
}
Example #8
0
long int EdgeIterator::operator*() { return IGRAPH_EIT_GET(eit()); }
Example #9
0
bool EdgeIterator::operator==(const EdgeIterator &rhs) const {
  return eit().pos == rhs.eit().pos;
}
Example #10
0
void EdgeIterator::reset() { IGRAPH_EIT_RESET(eit()); }
Example #11
0
long int EdgeIterator::size() const { return IGRAPH_EIT_SIZE(eit()); }
Example #12
0
bool EdgeIterator::at_end() const { return IGRAPH_EIT_END(eit()); }
Example #13
0
void EdgeIterator::next() { IGRAPH_EIT_NEXT(eit()); }
Example #14
0
void PMTextureMapEdit::displayObject( PMObject* o )
{
   QString str;

   if( o->isA( "TextureMapBase" ) )
   {
      bool readOnly = o->isReadOnly( );
      m_pDisplayedObject = ( PMTextureMapBase* ) o;
      QValueList<double> mv = m_pDisplayedObject->mapValues( );
      QValueList<double>::Iterator vit = mv.begin( );
      QPtrListIterator<PMFloatEdit> eit( m_edits );
      PMFloatEdit* edit;

      m_numValues = 0;

      for( ; vit != mv.end( ); ++vit )
      {
         if( eit.current( ) )
         {
            eit.current( )->setValue( *vit );
            eit.current( )->show( );
            eit.current( )->setReadOnly( readOnly );
            ++eit;
         }
         else
         {
            edit = new PMFloatEdit( this );
            m_pEditLayout->addWidget( edit );
            m_edits.append( edit );
            edit->setValue( *vit );
            edit->setValidation( true, 0.0, true, 1.0 );
            edit->setReadOnly( readOnly );
            connect( edit, SIGNAL( dataChanged( ) ), SIGNAL( dataChanged( ) ) );
         }
         m_numValues++;
      }
      for( ; eit.current( ); ++eit )
         eit.current( )->hide( );
      if( m_numValues == 0 )
      {
         if( o->linkedObject( ) )
         {
            m_pPureLinkLabel->show( );
            m_pNoChildLabel->hide( );
         }
         else
         {
            m_pPureLinkLabel->hide( );
            m_pNoChildLabel->show( );
         }
      }
      else
      {
         m_pNoChildLabel->hide( );
         m_pPureLinkLabel->hide( );
      }
   }
   else
      kdError( PMArea ) << "PMTextureMapEdit: Can't display object\n";
   Base::displayObject( o );
   enableLinkEdit( m_numValues == 0 );
}
Example #15
0
DualGraph* generateGraph(std::vector<Patch*>& patches) {
	
	DualGraph *dualGraph = new DualGraph;

	std::map<Vertex*, std::vector<Patch*> > ver2patchMap;
	for (auto p : patches) {

		GraphNode *node = dualGraph->addNode();
		p->graphNode = node;

		for (auto v : p->vertices) {
			auto pvec = ver2patchMap[v];
			for (size_t i = 0; i < pvec.size(); ++i) {
				Patch *p0 = pvec[i];
				dualGraph->addEdge(p0->graphNode, node);
				dualGraph->addEdge(node, p0->graphNode);
			}
			ver2patchMap[v].push_back(p);
		}
	}


	//well.. let's print out the dualgraph

	//convert the dual graph to cm
	//first, the position, each center of the cluster
	std::ofstream dgfile("dualgraph.cm");
	
	for (auto p : patches) {
		GraphNode *gnode = p->graphNode;
		dgfile << "Vertex " << gnode->id() + 1 << " " << p->center[0] << " " << p->center[1] << " " << p->center[2] << "\n";
	}

	for (auto p : patches) {
		GraphNode *gnode = p->graphNode;
		for (GraphNode::EdgeIter eit(gnode); !eit.end(); ++eit) {
			GraphEdge *edge = *eit;
			if (edge->to()->id() > gnode->id()) {
				dgfile << "Edge " << edge->from()->id() + 1 << " " << edge->to()->id() + 1 << "\n";
			}
		}
	}

	dualGraph->saveMetis("dualgraph.metis");

	dgfile.close();
	


	std::vector <std::string> edgestr;
	std::set<Vertex*> vertices;
	double total_boundary_length = 0;
	int boundary_count = 0;
	for (auto p : patches) {
		std::set<Vertex*> pvertices;
		for (auto he : p->boundary) {
			
			if (!he->twin()) {
				total_boundary_length += (he->source()->point() - he->target()->point()).norm();
				++boundary_count;
				if ( ver2patchMap[he->source()].size() == 1) {
					//continue;
				}
				vertices.insert(he->source());
				auto itpair = pvertices.insert(he->source());
				if (itpair.second) {
					p->corners.push_back(he->source());
				}

				if ( ver2patchMap[he->target()].size() == 1) {
				//	continue;
				}
				vertices.insert(he->target());
				itpair = pvertices.insert(he->target());
				if (itpair.second) {
					p->corners.push_back(he->target());
				}
				
			}  

			if ( ver2patchMap[he->source()].size() >= 3) {
				vertices.insert(he->source());
				auto itpair = pvertices.insert(he->source());			
				if (itpair.second) {
					p->corners.push_back(he->source());
				}
					
			}


			if ( ver2patchMap[he->target()].size() >= 3) {
				vertices.insert(he->target());
				auto itpair = pvertices.insert(he->target());			
				if (itpair.second) {
					p->corners.push_back(he->target());
				}

			}

		}
	}

	avg_length = total_boundary_length / boundary_count;
	std::map<Vertex*, int> prevOrder, nowOrder;
	std::ofstream output("graph.m");

	int vid = 1;
	for (auto v : vertices) {
		
		output << "Vertex " << vid << " " << v->point()[0] << " " << v->point()[1] << " " << v->point()[2] << "\n";
		prevOrder[v] = v->index();
		nowOrder[v] = vid++;
		
	}

	int fid = 0;
	for (auto p : patches) {
		output << "Face " << ++fid << " ";
	
		for (auto v : p->corners) {
			
			output << nowOrder[v]  << " ";
		}
		output << "\n";
	}

	for (auto v : vertices) {
		
		v->index() = prevOrder[v];
	}

	return dualGraph;
}
Example #16
0
void SubdAccBuilder::computeEdgeStencil(SubdFaceRing *ring, GregoryAccStencil *stencil)
{
	const int cornerIndices[7] = {8, 11, 19, 16,    6,  9, 12};
	const int edge1Indices[7] = {9, 13, 18, 14,    7, 10, 13};
	const int edge2Indices[7] = {12, 10, 15, 17,    14,  8, 11};
	int primitiveOffset = ring->is_quad()? 0: 4;

	float tangentScales[14] = {
		0.0f, 0.0f, 0.0f, 0.667791f, 1.0f,
		1.11268f, 1.1284f, 1.10289f, 1.06062f,
		1.01262f, 0.963949f, 0.916926f, 0.872541f, 0.831134f
	};

	SubdEdge *firstEdge = ring->firstEdge();

	/* compute corner / edge control points */
	int v = 0;

	for(SubdFace::EdgeIterator it(firstEdge); !it.isDone(); it.advance(), v++) {
		SubdVert *vert = it.current()->from();
		int valence = vert->valence();
		int cid = cornerIndices[primitiveOffset+v];

		int i1 = 0, i2 = 0, j = 0;

		for(SubdVert::EdgeIterator eit(vert->edge); !eit.isDone(); eit.advance(), j++) {
			SubdEdge *edge = eit.current();

			/* find index of "our" edge for edge control points */
			if(edge == it.current())
				i1 = j;
			if(edge == it.current()->prev->pair)
				i2 = j;
		}

		if(vert->is_boundary()) {
			int num_verts = ring->num_verts();
			StencilMask	r0(num_verts);
			StencilMask	r1(num_verts);

			computeBoundaryTangentStencils(ring, vert, r0, r1);

			int k = valence - 1;
			float omega = M_PI_F / k;

			int eid1 = edge1Indices[primitiveOffset + v];
			int eid2 = edge2Indices[primitiveOffset + v];

			if(it.current()->is_boundary()) {
				assert(it.current()->from() == vert);

				stencil->get(eid1, vert) = 2.0f / 3.0f;
				stencil->get(eid1, it.current()->to()) = 1.0f / 3.0f;

				assert(stencil->get(eid1).is_normalized());

				if(valence == 2) {
					for(int i = 0; i < num_verts; i++)
						stencil->get(eid1)[i] += r0[i] * 0.0001f;
				}
			}
			else {
				stencil->get(eid1) = stencil->get(cid);

				/* compute index of it.current() around vert */
				int idx = 0;

				for(SubdVert::EdgeIterator eit(vert->edges()); !eit.isDone(); eit.advance(), idx++)
					if(eit.current() == it.current())
						break;

				assert(idx != valence);

				float c = cosf(idx * omega);
				float s = sinf(idx * omega);

				for(int i = 0; i < num_verts; i++)
					stencil->get(eid1)[i] += (r0[i] * s + r1[i] * c) / 3.0f;
			}

			if(it.current()->prev->is_boundary()) {
				assert(it.current()->prev->pair->from() == vert);

				stencil->get(eid2, vert) = 2.0f / 3.0f;
				stencil->get(eid2, it.current()->prev->pair->to()) = 1.0f / 3.0f;

				assert(stencil->get(eid2).is_normalized());

				if(valence == 2) {
					for(int i = 0; i < num_verts; i++)
						stencil->get(eid2)[i] += r0[i] * 0.0001f;
				}
			}
			else {
				stencil->get(eid2) = stencil->get(cid);

				/* compute index of it.current() around vert */
				int idx = 0;

				for(SubdVert::EdgeIterator eit(vert->edges()); !eit.isDone(); eit.advance(), idx++)
					if(eit.current() == it.current()->prev->pair)
						break;

				assert(idx != valence);

				float c = cosf(idx * omega);
				float s = sinf(idx * omega);

				for(int i = 0; i < num_verts; i++)
					stencil->get(eid2)[i] += (r0[i] * s + r1[i] * c) / 3;
			}
		}
		else {
			float costerm = cosf(M_PI_F / valence);
			float sqrtterm = sqrtf(4.0f + costerm*costerm);

			/* float tangentScale = 1.0f; */
			float tangentScale = tangentScales[min(valence, 13U)];

			float alpha = (1.0f +  costerm / sqrtterm) / (3.0f * valence) * tangentScale;
			float beta  = 1.0f / (3.0f * valence * sqrtterm) * tangentScale;


			int eid1 = edge1Indices[primitiveOffset + v];
			int eid2 = edge2Indices[primitiveOffset + v];

			stencil->get(eid1) = stencil->get(cid);
			stencil->get(eid2) = stencil->get(cid);

			j = 0;
			for(SubdVert::EdgeIterator eit(vert->edges()); !eit.isDone(); eit.advance(), j++) {
				SubdEdge *edge = eit.current();
				assert(vert->co == edge->from()->co);

				float costerm1_a = cosf(M_PI_F * 2 * (j-i1) / valence);
				float costerm1_b = cosf(M_PI_F * (2 * (j-i1)-1) / valence); /* -1 instead of +1 b/c of edge->next->to() */

				float costerm2_a = cosf(M_PI_F * 2 * (j-i2) / valence);
				float costerm2_b = cosf(M_PI_F * (2 * (j-i2)-1) / valence); /* -1 instead of +1 b/c of edge->next->to() */


				stencil->get(eid1, edge->to()) += alpha * costerm1_a;
				stencil->get(eid2, edge->to()) += alpha * costerm2_a;

				if(SubdFaceRing::is_triangle(edge->face)) {
					/* @@ this probably does not provide watertight results!! (1/3 + 1/3 + 1/3 != 1) */

					/* distribute weight to all verts */
					stencil->get(eid1, vert) += beta * costerm1_b / 3.0f;				
					stencil->get(eid1, edge->to()) += beta * costerm1_b / 3.0f;
					stencil->get(eid1, edge->next->to()) += beta * costerm1_b / 3.0f;

					stencil->get(eid2, vert) += beta * costerm2_b / 3.0f;
					stencil->get(eid2, edge->to()) += beta * costerm2_b / 3.0f;
					stencil->get(eid2, edge->next->to()) += beta * costerm2_b / 3.0f;
				}
				else {
					stencil->get(eid1, edge->next->to()) += beta * costerm1_b;
					stencil->get(eid2, edge->next->to()) += beta * costerm2_b;
				}
			}
		}
	}
}