Esempio n. 1
0
	CMesh::CMesh(_In_opt_ CMesh * pMesh) : m_BeamLattice(this->m_Nodes)
	{
		if (!pMesh)
			throw CNMRException(NMR_ERROR_INVALIDPARAM);

		mergeMesh(pMesh);
	}
Esempio n. 2
0
	CMesh::CMesh(_In_opt_ CMesh * pMesh)
	{
		if (!pMesh)
			throw CNMRException(NMR_ERROR_INVALIDPARAM);

		mergeMesh(pMesh);
	}
Esempio n. 3
0
void sweeper::reconLastStroke( ) {

	if( appstate.vedioMode ){
		int brchNum = settings.size() ;
		loadSettings() ;

		if( settings.size() >= brchNum+1 )
			settings.resize( brchNum+1 ) ;



		// write iditifier
		meshLable.resize(brchNum+1) ;
		meshes.resize(brchNum+1) ;

		mergeMesh() ;
		
		return ;
	}

	ongoingSkel.reconstruct() ;

	bool found = false;
	for( int i=0; i<meshes.size(); ++i ){
		if( meshLable[i] == ongoingSkel.iditifier){
			found = true ;
			meshes[i] = ongoingSkel.resultMesh[0] ;
		}
	}
	

	if( !found ){
		meshes.push_back( ongoingSkel.resultMesh[0] );
		meshLable.push_back( ongoingSkel.iditifier ) ;
		settings.push_back( ongoingSkel ) ;
	}

	
	mergeMesh() ;
}
Esempio n. 4
0
	void CMesh::mergeMesh(_In_opt_ CMesh * pMesh)
	{
		mergeMesh(pMesh, fnMATRIX3_identity());
	}
Esempio n. 5
0
void sweeper::performFeatureStroke(){

	std::cout<<" sweeper::performFeatureStroke{"<<std::endl;
	int cvnum = ReconstructorPara::cvNum ;

	skelpath &strokedSkel = settings[featureStrokeSkelId] ;

	// project the stroke to the surface
	std::vector<Profile3D> prof3d = strokedSkel.resultProf3d[0];
	std::vector<Profile2D> prof2d =  strokedSkel.resultProf2d[0];
	std::vector<ON_NurbsCurve> nbs = strokedSkel.solvers[0].finalNurbs ;
	for( int i=0; i<nbs.size(); ++i ){
		prof2d[i] = ReconstructorUtility::discretizeNurbs(nbs[i],500) ;
		prof3d[i] = ReconstructorUtility::convert2dProfileTo3d( prof2d[i], strokedSkel.solvers[0].cutplanes[i], strokedSkel.solvers[0].centers[i] ) ;
	}

	std::vector<Profile2D> prof3d_w2d ;
	std::vector<Profile3D> prof3d_w3d ;
	for( int i=0; i<prof3d.size(); ++i ){
		prof3d_w2d.push_back(  ReconstructorUtility::project3dPointsOntoScreen( prof3d[i]) ) ;
		prof3d_w3d.push_back(  ReconstructorUtility::convertLocal3dToWorld3d( prof3d[i]) ) ;
	}

	Curve2D ogFeaStr_w2d = ReconstructorUtility::convertScreen2dToWorld2d( ongoingFeatureStroke ) ;
	ReconstructorUtility::getUniformCubicBSpline( ogFeaStr_w2d, ogFeaStr_w2d, 100) ;

	std::vector<int> interId(prof3d.size(),-1 ) ;
	for( int i=0; i<prof3d.size(); ++i){

		std::vector<int> candidateNode ;
		for( int j=0; j<prof3d[i].size(); ++j ){
			int n = prof3d[i].size() ;
			for( int k=0; k<ogFeaStr_w2d.size()-1; ++k )
				if( ReconstructorUtility::vectorIntersect( prof3d_w2d[i][j], prof3d_w2d[i][(j+1)%n], ogFeaStr_w2d[k], ogFeaStr_w2d[k+1] )  ){

					// candidate node must locate in front
					int back_count = 0;
					int front_count = 0;
					for( int id=0; id<prof3d_w3d[i].size(); ++id )
						if( prof3d_w3d[i][id].Z() < prof3d_w3d[i][j].Z() )
							back_count++ ;
						else
							front_count++ ;

					if( back_count > front_count ){
						candidateNode.push_back(j) ;
						candidateNode.push_back((j+1)%n) ;
					}

					//break;
				}
		}

		if( candidateNode.size() ){
			int nstNodeId = 0;
			double depth = -1e10 ;
			for( int id=0; id<candidateNode.size(); ++id ){
				if( prof3d_w3d[i][candidateNode[id]].Z() > depth ){ nstNodeId=candidateNode[id]; depth=prof3d_w3d[i][candidateNode[id]].Z() ; }
			}
			interId[i] = nstNodeId ;
		}
	}


	// output featureStroke3d for displaying
	featureStroke3d.clear() ;
	for( int i=0; i<interId.size(); ++i  ){
		if( interId[i]>0 ){
			featureStroke3d.push_back( prof3d[i][interId[i]] ) ;
		}
	}

	// find sharp control point
	int2 sharpScope;
	bool first = true ;
	for( int i=0; i<interId.size(); ++i ) {
		if( first&&interId[i]>=0 ){
			first = false ;
			sharpScope.x = i ;
		}

		if( !first && interId[i]>=0  )
			sharpScope.y = i ;
	}

	std::vector<Curve3D> cvpts ;
	for( int i=0 ; i<nbs.size(); ++i )
		cvpts.push_back( ReconstructorUtility::convert2dProfileTo3d( ReconstructorUtility::getCvPts(nbs[i]),  strokedSkel.solvers[0].cutplanes[i], strokedSkel.solvers[0].centers[i] ) ) ;

	std::vector<int> sharpCvId(prof3d.size(),-1 ) ;
	for( int i=0; i<interId.size(); ++i ) {
		if( interId[i] < 0 )
			continue ;

		//std::vector<double> distances ;
		//for( int j=0; j<cvpts[i].size(); ++j )
		//	distances.push_back( ( featureStroke3d[ReconstructorUtility::NearstPoint( featureStroke3d,cvpts[i][j])] - cvpts[i][j]).Norm() ) ;
		//sharpCvId[i] = ReconstructorUtility::getMinId(distances) ;

		sharpCvId[i] = ( (int)round( ( interId[i] / (double)prof3d[i].size() ) / (1.0/cvnum) + 1.0) +  cvnum )%cvnum;
	}

	// compute nstCVid
	std::vector<int> cvidDiff( ReconstructorPara::cvNum, 0) ;
	for( int i=0; i<sharpCvId.size(); ++i )
		if( sharpCvId[i] >= 0 )
			for( int j=0; j<cvidDiff.size(); ++j )
				cvidDiff[j] += std::min( abs(j-sharpCvId[i]), abs( ReconstructorPara::cvNum - abs(j-sharpCvId[i]) ) ) ;
	int nstCVID = ReconstructorUtility::getMinId(cvidDiff) ;

	strokedSkel.solvers[0].setFeatureStrokeCVId( nstCVID, ogFeaStr_w2d, featureStroke3d, sharpScope ) ;


	for( int i=0; i<sharpCvId.size(); ++i )
		std::cout<< sharpCvId[i] <<" " ;
	std::cout <<"\nnstCVID = " << nstCVID<<std::endl;

	// reconstruction
	strokedSkel.reconstruct() ;
	meshes[featureStrokeSkelId] = settings[featureStrokeSkelId].resultMesh[0] ;
	
	ongoingSkel = strokedSkel ;
	ongoingSkel=skelpath(strokedSkel.smoothedBrchPts,true);
	mergeMesh() ;

	std::cout <<"}"<<std::endl;

}