コード例 #1
0
ファイル: main.cpp プロジェクト: Alexandr-Galko/fougtools
int main(int argc, char** argv)
{
  QApplication app(argc, argv);

  Handle_V3d_Viewer occViewer = internal::createOccViewer();
  Handle_AIS_InteractiveContext occContext = new AIS_InteractiveContext(occViewer);

  // Load BRep files specified at command line
  for (int i = 1; i < argc; ++i) {
    TopoDS_Shape shape;
    BRep_Builder brepBuilder;
    BRepTools::Read(shape, argv[i], brepBuilder);

    Handle_AIS_Shape aisShape = new AIS_Shape(shape);
    aisShape->SetMaterial(Graphic3d_NOM_PLASTIC);
    aisShape->SetDisplayMode(AIS_Shaded);
    aisShape->SetColor(Quantity_NOC_GRAY50);
    aisShape->Attributes()->SetFaceBoundaryDraw(Standard_True);

    occContext->Display(aisShape, i == (argc - 1));
  }

  occ::QtView qtView(occContext);
  new QtViewController(&qtView);
  qtView.show();
  return app.exec();
}
コード例 #2
0
ファイル: utils.cpp プロジェクト: neoplacer/fougtools
void eraseObjectFromContext(Handle_AIS_InteractiveObject object,
                            Handle_AIS_InteractiveContext context)
{
  if (!object.IsNull()) {
    context->Erase(object, Standard_False);
    context->Remove(object, Standard_False);
    context->Clear(object, Standard_False); // Remove() can be used too
    context->SelectionManager()->Remove(object);
    while (!object.IsNull())
      object.Nullify();
  }
}
コード例 #3
0
ファイル: beamtest.cpp プロジェクト: jf---/openshapefactory
void beamtest::readbinary()
	{


QTime time;
time.start();
Handle_AIS_InteractiveContext ic = ui::getInstance()->getWindowContext();

QString filename = QFileDialog::getOpenFileName ( this,
							 tr("Import File"),"");

QFile file(filename);
file.open(QIODevice::ReadOnly);
QDataStream in(&file);    // read the data serialized from the file

QList<gp_Pnt> vertlist;
double x ;
double y ;
double z ;

int i=0;
do {

i++;
in >> x >> y >> z ;

if (i % 100000 == 0) qDebug() << i;
gp_Pnt thevert(x,y,z);
vertlist.append(thevert);
} while ( in.status() ==QDataStream::Ok );

file.close();

Handle(AIS_PointCloud) mypc1 = new AIS_PointCloud(vertlist);
ic->Display(mypc1);

double milliseconds = time.elapsed();
double seconds = (milliseconds/1000);
double minutes = seconds/60;
double hours = minutes/60;

QString timetxt;
QTextStream linestream(&timetxt);
linestream << "h" << hours << ":m " << minutes << ":s " << seconds << ".ms" << milliseconds; 

ui::getInstance()->Statusbar(timetxt);
qDebug() <<  "time ellapsed reading binary file:" << timetxt;

}
コード例 #4
0
ファイル: TIGLViewerWindow.cpp プロジェクト: Heathckliff/tigl
void AddVertex (double x, double y, double z, Handle_AIS_InteractiveContext theContext)
{
    TopoDS_Vertex aVertex=BRepBuilderAPI_MakeVertex( gp_Pnt(x,y,z) );
    Handle(AIS_Shape) AISVertex = new AIS_Shape(aVertex);
    // context is the handle to an AIS_InteractiveContext object.
    theContext->Display(AISVertex);
}
コード例 #5
0
void AspMainTest::TestSpartialDescriptorCalculation(MainFrame *frame, AspMainTool *tool){

	auto unitMap = tool->product->GetUnitMap();
	auto view = frame->myViewer;

	Handle_AIS_InteractiveContext context = view->getIC();

	std::vector<Part *> selectedParts = tool->GetSelectedPart(context);

	if (selectedParts.size() < 1){
		QString status = "Firstly, choose one part then try again!";

		QMessageBox::information(frame, "Assembly Information", status);
		return;
	}

	Standard_Integer curLC = context->OpenLocalContext();

	AssemblyGraphBuilder builder;
	for (auto &part : selectedParts){
			auto end = part->colOfSurf.end();

			for (auto sp=part->colOfSurf.begin();sp!=end;sp++){
					//==========================================
					//			Test 
					//==========================================
					
					std::pair<gp_Pnt, gp_Vec> s1Desc;
					if(builder.GetTraitOfFace(*sp,s1Desc)){

						Handle_ISession_Direction axis = new ISession_Direction(s1Desc.first, s1Desc.second*10, 3);
						Handle_Geom_CartesianPoint adaptPnt = new Geom_CartesianPoint(s1Desc.first);
						
						axis->SetColor(Quantity_NOC_RED);

						Handle_AIS_Point aisPoint = new AIS_Point(adaptPnt);
						
						context->LocalContext()->Display(aisPoint);
						context->LocalContext()->Display(axis, AIS_WireFrame);
						
					}
			}
	}
	view->getView()->Redraw();
}
コード例 #6
0
ファイル: gui_document.cpp プロジェクト: fougue/mayo
void eraseGpxObjectFromContext(
        const Handle_AIS_InteractiveObject &object,
        const Handle_AIS_InteractiveContext &context)
{
    if (!object.IsNull()) {
        context->Erase(object, Standard_False);
        context->Remove(object, Standard_False);
#if OCC_VERSION_HEX < 0x060900
        context->Clear(object, Standard_False); // Note: Remove() can be used too
#else
        context->ClearPrs(object, 0, Standard_False);
#endif
        context->SelectionManager()->Remove(object);

        Handle_AIS_InteractiveObject objectHCopy = object;
        while (!objectHCopy.IsNull())
            objectHCopy.Nullify();
    }
}
コード例 #7
0
void AspMainTest::TestContactSpotProcess(MainFrame * frame, AspMainTool *tool){

	auto unitMap = tool->product->GetUnitMap();
	auto view = frame->myViewer;

	Standard_Real Gap = 0.5;
	Handle_AIS_InteractiveContext context = view->getIC();
	if (context->HasOpenedContext())
		context->CloseAllContexts();

	context->EraseAll(true);

	Standard_Integer curLC = context->OpenLocalContext();

	for (auto iter = unitMap->begin(); iter != unitMap->end(); iter++){
		Part *part = dynamic_cast<Part *>(iter->second);
		auto subItr = iter;
		for (++subItr; subItr != unitMap->end(); subItr++){
			Part *obstacle = dynamic_cast<Part *>(subItr->second);
			//==========================================
			//			Visualise current Parts
			context->ClearLocalContext(AIS_ClearMode::AIS_CM_Interactive);

			Handle_AIS_Shape shape = tool->mapOfShapes.find(part->GetUri())->second;
			context->LocalContext()->Display(shape, AIS_Shaded);
			context->SetTransparency(shape, 0.2, false);
			shape = tool->mapOfShapes.find(obstacle->GetUri())->second;;
			context->LocalContext()->Display(shape, AIS_WireFrame);
			view->getView()->Redraw();
			//==========================================
			if (obstacle->BndBox()->Distance(*part->BndBox()) < Gap)
			for (auto &sp : *part){
				if (sp.myBox.Distance(*obstacle->BndBox())<Gap)
				for (auto &obstSp : *obstacle){

					if (sp.myBox.Distance(obstSp.myBox)>Gap)
						continue;
					//==========================================
					//			Visualise current surface

					context->ClearLocalContext(AIS_ClearMode::AIS_CM_Interactive);
					tool->ShowSurface(context, sp);
					tool->ShowSurface(context, obstSp);
					view->getView()->Redraw();
					//==========================================
					
					//==========================================
					//			Launch function Contact Spot

					if (asp::DBGBuilder::NotInContact(sp, obstSp, 1, Gap))
						continue;

					ContactSpot spot(sp, obstSp, part, obstacle);
					if (spot.IsDone()){

						//==========================================
						auto vecArray1 = spot.getF1ContactAxis();
						auto vecArray2 = spot.getF2ContactAxis();

						if (vecArray1.size() && vecArray2.size()){
							for (auto &dir : vecArray1){
								Handle_ISession_Direction axis = new ISession_Direction(dir.Location(), dir.Direction(), 10);
								context->LocalContext()->Display(axis, AIS_WireFrame);
							}

							for (auto &dir : vecArray2){
								Handle_ISession_Direction axis = new ISession_Direction(dir.Location(), dir.Direction(), 10);
								context->LocalContext()->Display(axis, AIS_WireFrame);
							}
							view->getView()->Redraw();
						}
						//}
					}
				}
			}

		}
	}
	context->CloseLocalContext(curLC);

}
コード例 #8
0
void AspMainTest::TestIsoFaceForPartCalculation(MainFrame* frame, AspMainTool *tool){

	auto aView = frame->myViewer;

	Handle_AIS_InteractiveContext context = frame->myViewer->getIC();

	std::vector<Part *> selectedParts = tool->GetSelectedPart(context);

	if (selectedParts.size()<2)
		return;

	/*auto &PartMap = */selectedParts[0]->UnitMap;
	

	
	AssemblyGraphBuilder builder;
	//auto NewPart = Part(*(selectedParts[0]));
	//for (new)
	auto p1G = builder.GetPartGraphsSet(selectedParts[0],false);
	auto p2G = builder.GetPartGraphsSet(selectedParts[1], false);
	
	std::vector<PartIsomorphism> res;
	bool result;
	bool isReversed = false;
	if (p1G.first.vertex_set().size() > p2G.first.vertex_set().size() ||
		p1G.second.vertex_set().size() > p2G.second.vertex_set().size())
	{
		result = builder.IsomorphismOfPartCompare(p2G, p1G, &res);
		isReversed= true;
	}
	else{
		result = builder.IsomorphismOfPartCompare(p1G, p2G, &res);
	}
	context->ClearSelected(false);
	
	if(!result)
		return;

	context->EraseAll();
	context->OpenLocalContext(true, true);
	if (!isReversed){
		res[0].isoPart.first = selectedParts[0]->GetUri();
		res[0].isoPart.second = selectedParts[1]->GetUri();
	}
	else{
		res[0].isoPart.first = selectedParts[1]->GetUri();
		res[0].isoPart.second = selectedParts[0]->GetUri();
	}

	_int cColor=0;
	for (auto &iso : res){
	auto partIter=	std::find_if(selectedParts.begin(), selectedParts.end(),[&iso](Part* p)->bool{return iso.isoPart.first==p->GetUri();});
	auto coPartIter = std::find_if(selectedParts.begin(), selectedParts.end(), [&iso](Part* p)->bool{return iso.isoPart.second == p->GetUri(); });
	auto end = selectedParts.end();

	if (partIter == end && coPartIter == end)
		continue;

	auto FaceSetEnd = iso.isoFaceSet.end();
		for (auto &surfP1: *(*partIter)){
			auto surfP1Uri = surfP1.uri;

			auto isoFacesPair = find_if(iso.isoFaceSet.begin(), FaceSetEnd, [&surfP1Uri](std::pair<FaceUri, FaceUri> &f)-> bool { return f.first == surfP1Uri; });

			if (isoFacesPair == FaceSetEnd)
				continue;

			auto surfP2Uri = isoFacesPair->second;

			auto &coPartSurfCol = (*coPartIter)->colOfSurf;

			auto surfP2 = find_if(coPartSurfCol.begin(), coPartSurfCol.end(), [&surfP2Uri](const SurfaceAttribute &att)->bool{return att.uri==surfP2Uri;});

			if (surfP2 == coPartSurfCol.end())
					continue;

			Handle_AIS_Shape S1 = new AIS_Shape(surfP1.surf.Face());
			Handle_AIS_Shape S2 = new AIS_Shape(surfP2->surf.Face());

			Quantity_Color shapeColor = Color::name(++cColor);

			_int DisplayMode= AIS_Shaded;
			
		
		
		context->LocalContext()->Display(S1, DisplayMode);
		context->LocalContext()->Display(S2, DisplayMode);

		context->SetColor(S1, shapeColor.Name(), false);
		context->SetColor(S2, shapeColor.Name(), false);

		
		}
	}

	aView->Update();

}
コード例 #9
0
ファイル: beamtest.cpp プロジェクト: jf---/openshapefactory
void beamtest::readbinarywithcolor()
	{


QTime time;
time.start();
Handle_AIS_InteractiveContext ic = ui::getInstance()->getWindowContext();

QString filename = QFileDialog::getOpenFileName ( this,
												 tr("Import File"),"");

QFile file(filename);
 file.open(QIODevice::ReadOnly);
 QDataStream in(&file);    // read the data serialized from the file

 //double pcount;
 //in >> pcount ;         // extract "the answer is" and 42


//QProgressDialog progress("loading cloudpoint", "Abort Copy", 1,100);

//QList<Graphic3d_Vertex> vertlist;
QList<gp_Pnt> vertlist;




//for (int i=0;i < pcount;i++)
//{
	       
	double x ;
	double y ;
	double z ;
	double intensity;
	int i=0;
	do {
		
	i++;
	in >> x >> y >> z >> intensity;

	if (i % 100000 == 0) qDebug() << i;
	

			//Graphic3d_Vertex thevert(x,y,z);
			gp_Pnt thevert(x,y,z);
			vertlist.append(thevert);

//			Quantity_Color rgbval(intensity,0,0,Quantity_TOC_RGB);
//			colorlist.append(rgbval);


	//if (i > 30000000) break;
			
		} while ( in.status() ==QDataStream::Ok );

file.close();

Handle(AIS_PointCloud) mypc1 = new AIS_PointCloud(vertlist);
ic->Display(mypc1);

double milliseconds = time.elapsed();
double seconds = (milliseconds/1000);
double minutes = seconds/60;
double hours = minutes/60;

QString timetxt;
QTextStream linestream(&timetxt);
linestream << "h" << hours << ":m " << minutes << ":s " << seconds << ".ms" << milliseconds; 

ui::getInstance()->Statusbar(timetxt);
qDebug() <<  "time ellapsed:" << timetxt;

}