SBasis compose(Linear2d const &a, D2<SBasis> const &p) { D2<SBasis> omp(-p[X] + 1, -p[Y] + 1); return multiply(omp[0], omp[1])*a[0] + multiply(p[0], omp[1])*a[1] + multiply(omp[0], p[1])*a[2] + multiply(p[0], p[1])*a[3]; }
bool project_mesh::generic_run( int target_dimension ) { if (viennagrid::result_of::geometric_dimension<OutputMeshT>::value != target_dimension) return false; typedef viennagrid::segmented_mesh<InputMeshT, InputSegmentationT> InputSegmentedMeshType; typename viennamesh::result_of::const_parameter_handle<InputSegmentedMeshType>::type imp = input_mesh.get<InputSegmentedMeshType>(); if (imp) { typedef viennagrid::segmented_mesh<OutputMeshT, OutputSegmentationT> OutputSegmentedMeshType; output_parameter_proxy<OutputSegmentedMeshType> omp(output_mesh); project_mesh_impl( imp().mesh, imp().segmentation, omp().mesh, omp().segmentation ); return true; } return false; }
void CSimPetriDoc::CreateOMPDoc(CString pathToFile) { ompMode = TRUE; delete stepper; //Créer le squelette const std::wstring pathName(pathToFile); const wchar_t *separator = _T(";"); omp::Reader dataReader(pathName, separator); omp::PetriOMP omp(dataReader, skeleton); //Créer le stepper stepper = new pm::TrackableStepper(&skeleton, &timer); //Ajouter les places double radiusPlaces = ((double)(3)/4) * min(size.cx/2, size.cy/2); pm::Places places = skeleton.getPlaces(); unsigned index = 0; for(auto it=places.begin(); it!=places.end(); ++it) { int x(size.cx/2 + radiusPlaces*std::cos(((double)(index)/places.size())*2*3.14)); int y(-size.cy/2 + radiusPlaces*std::sin(((double)(index)/places.size())*2*3.14)); shapesMap.insert(std::make_pair(*it, AddPlace(Point(x,y), *it))); ++index; } //Ajouter les transitions double radiusTrans = ((double)(1)/2) * min(size.cx/2, size.cy/2); pm::Transitions transitions = skeleton.getTransitions(); index = 0; for(auto it=transitions.begin(); it!=transitions.end(); ++it) { Point source = shapesMap.at((*it)->getInputArcs().front()->getSourceNode())->GetPosition(); Point end = shapesMap.at((*it)->getOutputArcs().front()->getEndNode())->GetPosition(); //int x(size.cx/2 + radiusTrans*std::cos(((double)(index)/transitions.size())*2*3.14)); //int y(-size.cy/2 + radiusTrans*std::sin(((double)(index)/transitions.size())*2*3.14)); shapesMap.insert(std::make_pair(*it, AddTransition(Geometry::MiddlePoint(source, end), *it))); ++index; } //Ajouter les arcs pm::Arcs arcs = skeleton.getArcs(); std::vector<Point> nullVector; for(auto it=arcs.begin(); it!=arcs.end(); ++it) AddArc(shapesMap.at((*it)->getSourceNode()), shapesMap.at((*it)->getEndNode()), nullVector, *it); }
bool make_mesh::run_impl() { output_parameter_proxy<netgen::mesh> omp(output_mesh); StdCaptureHandle capture_handle; if (omp != input_mesh) omp() = input_mesh(); ::netgen::MeshingParameters mesh_parameters; if (cell_size.valid()) { ::netgen::Point3d pmin; ::netgen::Point3d pmax; omp()().GetBox(pmin, pmax); double bb_volume = std::abs( (pmax.X() - pmin.X()) * (pmax.Y() - pmin.Y()) * (pmax.Z() - pmin.Z()) ); double cell_volume = cell_size()*cell_size()*cell_size(); double max_cell_count = 100000000; if ( cell_volume * max_cell_count < bb_volume ) { warning(1) << "Cell size is too small and might result in too much elements" << std::endl; warning(1) << "Cell size = " << cell_size() << std::endl; warning(1) << "Mesh max cell count = " << max_cell_count << std::endl; warning(1) << "Mesh bounding box = " << pmin << "," << pmax << std::endl; warning(1) << "Mesh bounding box volume = " << bb_volume << std::endl; warning(1) << "Mesh max cell volume = " << cell_volume * max_cell_count << std::endl; } mesh_parameters.maxh = cell_size(); } try { omp()().CalcLocalH(mesh_parameters.grading); MeshVolume (mesh_parameters, omp()()); RemoveIllegalElements (omp()()); OptimizeVolume (mesh_parameters, omp()()); } catch (::netgen::NgException const & ex) { error(1) << "Netgen Error: " << ex.What() << std::endl; return false; } return true; }
bool occ_make_mesh::run_impl() { io::FileType ft; if (filetype.valid()) ft = io::from_string( filetype() ); else ft = io::from_filename( filename() ); try { output_parameter_proxy<netgen::mesh> omp(output_mesh); ::netgen::OCCGeometry * geometry; if (ft == io::OCC_STEP) geometry = ::netgen::LoadOCC_STEP( filename().c_str() ); else if (ft == io::OCC_IGES) geometry = ::netgen::LoadOCC_IGES( filename().c_str() ); else { error(1) << "File type \"" << io::to_string(ft) << "\" is not supported" << std::endl; return false; } // http://sourceforge.net/p/netgen-mesher/discussion/905307/thread/7176bc7d/ TopTools_IndexedMapOfShape FMap; FMap.Assign( geometry->fmap ); if (!FMap.Extent()) { std::cout << "Error retrieving Face map... (OpenCascade error)" << endl; return false; } ::netgen::MeshingParameters mp; mp.elementorder = 0; mp.quad = 0; mp.inverttets = 0; mp.inverttrigs = 0; if (cell_size.valid()) { mp.uselocalh = 1; mp.maxh = cell_size(); } mp.curvaturesafety = curvature_safety_factor(); mp.segmentsperedge = segments_per_edge(); mp.grading = grading(); int perfstepsend = 6; omp()().geomtype = ::netgen::Mesh::GEOM_OCC; ::netgen::occparam.resthcloseedgeenable = 0; //mp.closeedgeenable; ::netgen::occparam.resthcloseedgefac = 1.0; //mp.closeedgefact; ::netgen::mparam = mp; omp()().DeleteMesh(); ::netgen::OCCSetLocalMeshSize( *geometry, omp()() ); ::netgen::OCCFindEdges(*geometry, omp()()); ::netgen::OCCMeshSurface(*geometry, omp()(), perfstepsend); omp()().CalcSurfacesOfNode(); ::netgen::MeshVolume(mp, omp()()); ::netgen::RemoveIllegalElements( omp()() ); ::netgen::MeshQuality3d( omp()() ); ::netgen::OptimizeVolume(mp, omp()() ); } catch (::netgen::NgException const & ex) { error(1) << "Netgen Error: " << ex.What() << std::endl; return false; } return true; }
bool adapt_hull::run_impl() { typedef viennagrid::triangular_3d_mesh MeshType; typedef viennagrid::triangular_3d_segmentation SegmentationType; typedef viennagrid::triangular_hull_3d_segmentation OrientedSegmentationType; typedef viennagrid::segmented_mesh<MeshType, SegmentationType> SegmentedMeshType; typedef viennagrid::segmented_mesh<MeshType, OrientedSegmentationType> OrientedSegmentedMeshType; { viennamesh::result_of::const_parameter_handle<OrientedSegmentedMeshType>::type imp = input_mesh.get<OrientedSegmentedMeshType>(); if (imp) { output_parameter_proxy<OrientedSegmentedMeshType> omp(output_mesh); ::vgmodeler::hull_adaptor adaptor; if (cell_size.valid()) adaptor.maxsize() = cell_size(); adaptor.process( imp().mesh, imp().segmentation, omp().mesh, omp().segmentation ); return true; } } // { // viennamesh::result_of::const_parameter_handle<SegmentedMeshType>::type imp = input_mesh.get<SegmentedMeshType>(); // if (imp) // { // output_parameter_proxy<OrientedSegmentedMeshType> omp(output_mesh); // // viennamesh::algorithm_handle segmenting_algo( new hull_segmenting() ); // segmenting_algo->set_input( "mesh", imp ); // segmenting_algo->run(); // // viennamesh::result_of::const_parameter_handle<OrientedSegmentedMeshType>::type tmp = // dynamic_handle_cast<OrientedSegmentedMeshType>(segmenting_algo->get_output("mesh")); // // ::vgmodeler::hull_adaptor adaptor; // if (cell_size.valid()) // adaptor.maxsize() = cell_size(); // adaptor.process( tmp().mesh, tmp().segmentation, omp().mesh, omp().segmentation ); // // return true; // } // } // // { // viennamesh::result_of::const_parameter_handle<MeshType>::type imp = input_mesh.get<MeshType>(); // if (imp) // { // output_parameter_proxy<OrientedSegmentedMeshType> omp(output_mesh); // // viennamesh::algorithm_handle segmenting_algo( new hull_segmenting() ); // segmenting_algo->set_input( "mesh", imp ); // segmenting_algo->run(); // // viennamesh::result_of::const_parameter_handle<OrientedSegmentedMeshType>::type tmp = // dynamic_handle_cast<OrientedSegmentedMeshType>(segmenting_algo->get_output("mesh")); // // ::vgmodeler::hull_adaptor adaptor; // if (cell_size.valid()) // adaptor.maxsize() = cell_size(); // adaptor.process( tmp().mesh, tmp().segmentation, omp().mesh, omp().segmentation ); // // return true; // } // } return false; }