예제 #1
0
static VALUE
rbclipper_execute_internal(VALUE self, ClipType cliptype,
                           VALUE subjfill, VALUE clipfill, VALUE resulttype)
{
  if (NIL_P(subjfill)) {
    subjfill = ID2SYM(id_even_odd);
  }

  if (NIL_P(clipfill)) {
      clipfill = ID2SYM(id_even_odd);
  }

  if (NIL_P(resulttype)) {
    resulttype = ID2SYM(id_polygons);
  }

  double inv_multiplier = 1.0 / NUM2LONG(rb_iv_get(self, "@multiplier"));

  VALUE r = rb_ary_new();
  if (resulttype == ID2SYM(id_polygons)) {
      Paths solution;
      XCLIPPER(self)->Execute((ClipType) cliptype,
                              solution,
                              sym_to_filltype(subjfill),
                              sym_to_filltype(clipfill));
      for(Paths::iterator i = solution.begin(); i != solution.end(); ++i) {
        VALUE sub = rb_ary_new();
        for(Path::iterator p = i->begin(); p != i->end(); ++p) {
          rb_ary_push(sub, rb_ary_new3(2, DBL2NUM(p->X * inv_multiplier), DBL2NUM(p->Y * inv_multiplier)));
        }
        rb_ary_push(r, sub);
      }
  }
  return r;
}
예제 #2
0
vector<ofVec3f> ofApp::offsetCell(list<int> & crv, float amt) {
	float scaling = 10;
	ClipperOffset co;
	Path P;
	Paths offsetP;
	float offset = amt;

	for (auto index : crv) {
		ofVec3f v = linesMesh.getVertex(index);
		P.push_back(IntPoint(v.x*scaling, v.y*scaling));
	}
	co.AddPath(P, jtRound, etClosedPolygon);
	co.Execute(offsetP, -offset*scaling);

	vector<ofVec3f> offsetPts;
	if (offsetP.size() > 0) {
		//visual offset for etching
		CleanPolygons(offsetP);

		if (doEtchOffset) {
			co.Clear();
			co.AddPaths(offsetP, jtRound, etClosedPolygon);
			co.Execute(offsetP, -etchOffset*scaling);
		}

		Path & oP = offsetP[0];
		for (int i = 0; i < oP.size(); i++) {
			ofVec3f pt3D(oP[i].X / scaling, oP[i].Y / scaling);
			offsetPts.push_back(pt3D);
		}
	}
	return offsetPts;
}
예제 #3
0
파일: PathOverlap.cpp 프로젝트: bcgsc/abyss
/** Read contig paths from the specified file.
 * @param g the contig adjacency graph
 * @param inPath the file of contig paths
 * @param[out] pathIDs the path IDs
 * @return the paths
 */
static Paths readPaths(Graph& g,
		const string& inPath, vector<string>& pathIDs)
{
	typedef graph_traits<Graph>::vertex_descriptor V;

	assert(pathIDs.empty());
	ifstream fin(inPath.c_str());
	if (opt::verbose > 0)
		cerr << "Reading `" << inPath << "'..." << endl;
	if (inPath != "-")
		assert_good(fin, inPath);
	istream& in = inPath == "-" ? cin : fin;

	assert_good(in, inPath);
	Paths paths;
	string id;
	ContigPath path;
	while (in >> id >> path) {
		if (path.empty()) {
			// Remove this contig from the graph.
			V u = find_vertex(id, false, g);
			clear_vertex(u, g);
			remove_vertex(u, g);
		} else {
			pathIDs.push_back(id);
			paths.push_back(path);
		}
	}
	assert(in.eof());
	return paths;
}
예제 #4
0
static VALUE
rbclipper_offset_polygons(int argc, VALUE* argv, VALUE self)
{
    double multiplier = NUM2DBL(rb_iv_get(self, "@multiplier"));
    double inv_multiplier = 1.0 / multiplier;
    VALUE polygonsValue, deltaValue, joinTypeValue, endTypeValue;

    rb_scan_args(argc, argv, "31", &polygonsValue, &deltaValue, &joinTypeValue, &endTypeValue);

    Paths polygons;
    for(long i = 0; i != RARRAY_LEN(polygonsValue); i++) {
        VALUE sub = rb_ary_entry(polygonsValue, i);
        Check_Type(sub, T_ARRAY);

        ClipperLib::Path tmp;
        ary_to_polygon(sub, &tmp, multiplier);
        polygons.push_back(tmp);
    }

    Paths resultPaths;

    XCLIPPEROFFSET(self)->AddPaths(polygons, sym_to_jointype(joinTypeValue), sym_to_endtype(endTypeValue));
    XCLIPPEROFFSET(self)->Execute(resultPaths, NUM2DBL(deltaValue) * multiplier);

    VALUE r = rb_ary_new();
    for(Paths::iterator i = resultPaths.begin(); i != resultPaths.end(); ++i) {
        VALUE sub = rb_ary_new();
        for(Path::iterator p = i->begin(); p != i->end(); ++p) {
            rb_ary_push(sub, rb_ary_new3(2, DBL2NUM(p->X * inv_multiplier), DBL2NUM(p->Y * inv_multiplier)));
        }
        rb_ary_push(r, sub);
    }
    return r;
}
예제 #5
0
	Paths* popPathFrom(string c) {
		Paths* ps = getPathFrom(c);
		for(int i=0;i<ps->size();i++) {
			this->remove(ps->at(i));
		}
		return ps;
	}
예제 #6
0
/** Returns a list of possible paths to the given resource. */
DataManager::Paths DataManager::paths(Path resource) const
{
	Paths p;
	for (Paths::const_iterator d = dirs.begin(); d != dirs.end(); d++)
		p.push_back(*d + resource);
	return p;
}
예제 #7
0
static bool to_polygons(Paths &polygons, GB_ARRAY array)
{
	int count;
	CPOLYGON *p;
	int i;

	if (GB.CheckObject(array))
		return true;

	count = GB.Array.Count(array);
	if (count == 0)
		return false;

	polygons.clear();

	for(i = 0; i < count; i++)
	{
		p = *(CPOLYGON **)GB.Array.Get(array, i);
		if (!p)
			continue;

		polygons.push_back(*(p->poly));
	}

	return false;
}
예제 #8
0
bool LoadFromFile(Paths &ppg, char * filename, double scale= 1,
  int xOffset = 0, int yOffset = 0)
{
  ppg.clear();

  FILE *f = fopen(filename, "r");
  if (!f) return false;
  int polyCnt, vertCnt;
  char junk [80];
  double X, Y;
  if (fscanf(f, "%d", &polyCnt) == 1 && polyCnt > 0)
  {
    ppg.resize(polyCnt);
    for (int i = 0; i < polyCnt; i++) {
      if (fscanf(f, "%d", &vertCnt) != 1 || vertCnt <= 0) break;
      ppg[i].resize(vertCnt);
      for (int j = 0; j < vertCnt; j++) {
        if (fscanf(f, "%lf%*[, ]%lf", &X, &Y) != 2) break;
        ppg[i][j].X = Round((X + xOffset) * scale);
        ppg[i][j].Y = Round((Y + yOffset) * scale);
        fgets(junk, 80, f);
      }
    }
  }
  fclose(f);
  return true;
}
예제 #9
0
	Paths* clone() {
		Paths* ps = new Paths();
		for (int i=0;i<this->size();i++) {
			ps->push(paths[i]->clone());
		}
		return ps;
	}
예제 #10
0
void MountMods(const Paths& paths, const std::vector<CStr>& mods)
{
	OsPath modPath = paths.RData()/"mods";
	OsPath modUserPath = paths.UserData()/"mods";
	for (size_t i = 0; i < mods.size(); ++i)
	{
		size_t priority = (i+1)*2;	// mods are higher priority than regular mountings, which default to priority 0
		size_t userFlags = VFS_MOUNT_WATCH|VFS_MOUNT_ARCHIVABLE|VFS_MOUNT_REPLACEABLE;
		size_t baseFlags = userFlags|VFS_MOUNT_MUST_EXIST;

		OsPath modName(mods[i]);
		if (InDevelopmentCopy())
		{
			// We are running a dev copy, so only mount mods in the user mod path
			// if the mod does not exist in the data path.
			if (DirectoryExists(modPath / modName/""))
				g_VFS->Mount(L"", modPath / modName/"", baseFlags, priority);
			else
				g_VFS->Mount(L"", modUserPath / modName/"", userFlags, priority);
		}
		else
		{
			g_VFS->Mount(L"", modPath / modName/"", baseFlags, priority);
			// Ensure that user modified files are loaded, if they are present
			g_VFS->Mount(L"", modUserPath / modName/"", userFlags, priority+1);
		}
	}
}
예제 #11
0
static void getWritePaths(Paths& paths)
{
	paths.push_back(PathInfo(SlPaths::GetLobbyWriteDir(), "LobbyWriteDir", true));
	paths.push_back(PathInfo(SlPaths::GetCachePath(), "CachePath", true));
	paths.push_back(PathInfo(SlPaths::GetExecutableFolder(), "ExecutableFolder", false));
	paths.push_back(PathInfo(SlPaths::GetDownloadDir(), "DownloadDir", true));
	paths.push_back(PathInfo(SlPaths::GetDataDir(), "Current SpringData:", true));
}
예제 #12
0
int SHAPE_POLY_SET::NewOutline ()
{
    Path empty_path;
    Paths poly;
    poly.push_back(empty_path);
    m_polys.push_back(poly);
    return m_polys.size() - 1;
}
예제 #13
0
//FIXME: merge with basicly duplicate in slpaths.cpp
std::string GetSpringlobbyInfo()
{
	static const std::string nl = std::string("\n");
	std::string res;
	res = getSpringlobbyAgent() + nl;
	const bool configwriteable = wxFileName::IsFileWritable(TowxString(SlPaths::GetConfigPath()));
	res += stdprintf("SpringLobby config file: %s (%swritable)\n",
			 SlPaths::GetConfigPath().c_str(),
			 BtS(configwriteable, "", "not ").c_str());
	Paths paths;
	getWritePaths(paths);
	for (size_t i = 0; i < paths.size(); ++i) {
		std::string path = paths[i].m_path;
#if defined(__WIN32__) || defined(_MSC_VER)
		path = Utf8ToLocalEncoding(path.c_str());
#endif
		res += stdprintf("%s (%s)\n", paths[i].m_desc.c_str(), path.c_str());
		const bool wx = wxFileName::IsDirWritable(path);
		const bool posix = access(path.c_str(), WRITABLE) == 0;
		bool tried = false;
		try {
			std::ofstream of;
			wxString dummy_fn = paths[i].m_path;
			if (!wxEndsWithPathSeparator(dummy_fn)) {
				dummy_fn += wxFileName::GetPathSeparator();
			}
			dummy_fn += _T("dummy.txt");

			std::string dummyFileString = dummy_fn.ToStdString();
#if defined(__WIN32__) || defined(_MSC_VER)
			dummyFileString = Utf8ToLocalEncoding(dummyFileString.c_str());
#endif
			of.open(dummyFileString);

			if (of.is_open()) {
				of << "fhreuohgeiuhguie";
				of.flush();
				of.close();
				tried = wxRemoveFile(dummyFileString);
			}
		} catch (...) {
		}
		if (paths[i].m_requireswrite && (!wx || !posix || !tried)) {
			wxLogError("%s is not writeable!", path.c_str());
		}
		res += stdprintf(("\tWX: %s POSIX: %s TRY: %s\n"), BtS(wx).c_str(), BtS(posix).c_str(), BtS(tried).c_str());
	}

	res += stdprintf("Current unitsync: %s\n", SlPaths::GetUnitSync().c_str());
	res += stdprintf("Current spring executable: %s\n", SlPaths::GetSpringBinary().c_str());
	res += stdprintf("Portable mode: %s\n", BtS(SlPaths::IsPortableMode()).c_str());

	res += stdprintf(("Compiled with wxWidgets %d.%d.%d.%d"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER, wxSUBRELEASE_NUMBER) + nl;
	res += "Started with: \n";
	for (int i = 0; i < wxTheApp->argc; ++i)
		res += STD_STRING(wxTheApp->argv[i]) + std::string(" ");
	return res;
}
예제 #14
0
	Paths* getPathFrom(string c) {
		Paths* ps = new Paths();
		for (int i=0; i<paths.size(); i++) {
			if (paths[i]->c1 == c || paths[i]->c2 == c) {
				ps->push(paths[i]);
			}
		}
		return ps;
	}
예제 #15
0
//---------------------------------------------------------------------------------------
void BooksDlg::load_available_books()
{
    Paths* pPaths = m_appScope.get_paths();
    wxString sPath = pPaths->GetBooksPath();
    wxString sPattern = "*.lmb";

    wxString sRead = _("Please read the <a-1>Study guide</a-1> for information about \
the best way to use LenMus Phonascus and the books.");

    sRead.Replace("<a-1>", "<a href=\"lenmus#study-guide\">'");
    sRead.Replace("</a-1>", "'</a>");


    wxString sHeader = "<html><body>";
    wxString sContent = sHeader +
        "<p>" + sRead +
        "</p>"
        "<h3>" + _("Available books:") + "</h3><ul>";

//    wxLogMessage("[BooksDlg::load_available_books] Scanning path <%s>", sPath.wx_str());
    wxDir dir(sPath);
    if ( !dir.IsOpened() )
    {
        wxMessageBox( wxString::Format(_("Error when trying to move to folder %s"),
                                       sPath.wx_str() ));
        LOMSE_LOG_ERROR(str(boost::format("Error when trying to move to folder %s")
                        % sPath.wx_str() ));
        return;
    }

    //Scan the books folder and load all books found
    wxString filename;
    bool fFound = dir.GetFirst(&filename, sPattern, wxDIR_FILES);
    while (fFound)
    {
        if ((filename != "TestingNewExercises.lmb" &&
             filename != "L1_Dictation.lmb" &&
             filename != "L3_MusicReading.lmb" )
            || m_appScope.are_experimental_features_enabled() )
        {
            wxFileName oFilename(sPath, filename, wxPATH_NATIVE);
            wxString name = get_book_name(oFilename);
            wxString link = wxString::Format("book-%s", filename.wx_str());

            sContent += "<li><a href=\"lenmus#"
                     + link
                     + "\">"
                     + name
                     + "</a></li>";
        }
        fFound = dir.GetNext(&filename);
    }
    sContent += "</ul></body></html>";

    m_pHtmlWnd->SetPage(sContent);
}
예제 #16
0
// process the rest area.
void TerraGenerator::buildBackground(Path& tileRect)
{
    backGroundClipper_.AddPath(tileRect, ptSubject, true);
    Paths background;
    backGroundClipper_.Execute(ctDifference, background, pftNonZero, pftNonZero);
    backGroundClipper_.Clear();

    if (!background.empty())
        populateMesh(background, createRegionContext(style_, ""));
}
예제 #17
0
    /// Compute total number of edges
    static size_t computeNumberOfEdges(const Paths& paths)
    {
        size_t count=0;
        for (Paths::const_iterator i = paths.begin(), e = paths.end();
                i != e; ++i) {

            count += i->size();
        }
        return count;
    }
예제 #18
0
void Application::_parseCommandLine()
{
  typedef boost::filesystem::path Path;
  typedef std::vector<std::string> Paths;

  boost::program_options::options_description baseOptions ( "Options" );
  baseOptions.add_options()
      ( "cache-directory", boost::program_options::value<std::string>(), "Specify the cache directory file." );

  boost::program_options::options_description hidden ( "Hidden options" );
  hidden.add_options()
    ( "files", boost::program_options::value<Paths>(), "files");

  boost::program_options::options_description allOptions;
  allOptions.add ( baseOptions ).add ( hidden );

  boost::program_options::positional_options_description p;
  p.add("files", -1);

  // Get the command line arguments.
  using Usul::CommandLine::Arguments;

  boost::program_options::variables_map vm;
  boost::program_options::store (
    boost::program_options::command_line_parser ( Arguments::instance().argc(), Arguments::instance().argv() ).
    options ( allOptions ).positional(p).allow_unregistered().run(), vm );

  // Check for the cache directory.
  if ( vm.count ( "cache-directory" ) )
  {
    const std::string cacheDirectory ( vm["cache-directory"].as<std::string>() );
    std::cout << "Setting cache directory to " << cacheDirectory << std::endl;
    Minerva::Core::DiskCache::instance().cacheDirectory ( cacheDirectory );
  }

  Paths filenames;

  if ( vm.count ( "files" ) )
  {
    filenames = vm["files"].as<Paths>();
  }

  // Have to load the config files now. Remove them from the arguments.
  Paths configs;
  
  Path ext ( ".jconf" );
  std::remove_copy_if ( filenames.begin(), filenames.end(), std::back_inserter ( configs ),
		        boost::lambda::bind ( static_cast<Path::string_type (*) ( const Path& )> ( &boost::filesystem::extension ), boost::lambda::_1 ) != ext );

  this->_loadConfigFiles ( configs );

  // Load the model files.
  this->_loadModelFiles ( filenames );
}
예제 #19
0
void SaveToConsole(const string name, const Paths &pp, double scale = 1.0)
{
  cout << '\n' << name << ":\n"
    << pp.size() << '\n';
  for (unsigned i = 0; i < pp.size(); ++i)
  {
    cout << pp[i].size() << '\n';
    for (unsigned j = 0; j < pp[i].size(); ++j)
      cout << pp[i][j].X /scale << ", " << pp[i][j].Y /scale << ",\n";
  }
  cout << "\n";
}
예제 #20
0
	Paths findLadders(string beginWord, string endWord, Dict &wordList)
	{
		Paths paths;
		Path path(1, beginWord);
		if (beginWord == endWord) { paths.push_back(path); return paths; }
		Dict _front, _back;
		_front.insert(beginWord);
		_back.insert(endWord);
		Tree tree;
		if (build(_front, _back, wordList, tree, false))
			getPath(beginWord, endWord, tree, path, paths);
		return paths;
	}
예제 #21
0
파일: PathOverlap.cpp 프로젝트: bcgsc/abyss
/** Find every pair of overlapping paths. */
static Overlaps findOverlaps(const Graph& g, const Paths& paths)
{
	SeedMap seedMap = makeSeedMap(paths);

	Overlaps overlaps;
	for (Paths::const_iterator it = paths.begin();
			it != paths.end(); ++it) {
		unsigned i = it - paths.begin();
		findOverlaps(g, paths, seedMap, Vertex(i, false), overlaps);
		findOverlaps(g, paths, seedMap, Vertex(i, true), overlaps);
	}
	return overlaps;
}
예제 #22
0
파일: geometry.cpp 프로젝트: Paulloz/godot
Vector<Vector<Point2> > Geometry::_polypaths_do_operation(PolyBooleanOperation p_op, const Vector<Point2> &p_polypath_a, const Vector<Point2> &p_polypath_b, bool is_a_open) {

	using namespace ClipperLib;

	ClipType op = ctUnion;

	switch (p_op) {
		case OPERATION_UNION: op = ctUnion; break;
		case OPERATION_DIFFERENCE: op = ctDifference; break;
		case OPERATION_INTERSECTION: op = ctIntersection; break;
		case OPERATION_XOR: op = ctXor; break;
	}
	Path path_a, path_b;

	// Need to scale points (Clipper's requirement for robust computation)
	for (int i = 0; i != p_polypath_a.size(); ++i) {
		path_a << IntPoint(p_polypath_a[i].x * SCALE_FACTOR, p_polypath_a[i].y * SCALE_FACTOR);
	}
	for (int i = 0; i != p_polypath_b.size(); ++i) {
		path_b << IntPoint(p_polypath_b[i].x * SCALE_FACTOR, p_polypath_b[i].y * SCALE_FACTOR);
	}
	Clipper clp;
	clp.AddPath(path_a, ptSubject, !is_a_open); // forward compatible with Clipper 10.0.0
	clp.AddPath(path_b, ptClip, true); // polylines cannot be set as clip

	Paths paths;

	if (is_a_open) {
		PolyTree tree; // needed to populate polylines
		clp.Execute(op, tree);
		OpenPathsFromPolyTree(tree, paths);
	} else {
		clp.Execute(op, paths); // works on closed polygons only
	}
	// Have to scale points down now
	Vector<Vector<Point2> > polypaths;

	for (Paths::size_type i = 0; i < paths.size(); ++i) {
		Vector<Vector2> polypath;

		const Path &scaled_path = paths[i];

		for (Paths::size_type j = 0; j < scaled_path.size(); ++j) {
			polypath.push_back(Point2(
					static_cast<real_t>(scaled_path[j].X) / SCALE_FACTOR,
					static_cast<real_t>(scaled_path[j].Y) / SCALE_FACTOR));
		}
		polypaths.push_back(polypath);
	}
	return polypaths;
}
예제 #23
0
파일: eclass.cpp 프로젝트: clbr/netradiant
    void visit(const char* name, const EntityClassScanner& table) const
    {
      Paths paths;
      EntityClassQuake3_constructDirectory(baseDirectory, table.getExtension(), paths);
      if(!string_equal(baseDirectory, gameDirectory))
      {
        EntityClassQuake3_constructDirectory(gameDirectory, table.getExtension(), paths);
      }

      for(Paths::iterator i = paths.begin(); i != paths.end(); ++i)
      {
        EntityClassesLoadFile(table, (*i).second)((*i).first.c_str());
      }
    }
예제 #24
0
파일: geometry.cpp 프로젝트: Paulloz/godot
Vector<Vector<Point2> > Geometry::_polypath_offset(const Vector<Point2> &p_polypath, real_t p_delta, PolyJoinType p_join_type, PolyEndType p_end_type) {

	using namespace ClipperLib;

	JoinType jt = jtSquare;

	switch (p_join_type) {
		case JOIN_SQUARE: jt = jtSquare; break;
		case JOIN_ROUND: jt = jtRound; break;
		case JOIN_MITER: jt = jtMiter; break;
	}

	EndType et = etClosedPolygon;

	switch (p_end_type) {
		case END_POLYGON: et = etClosedPolygon; break;
		case END_JOINED: et = etClosedLine; break;
		case END_BUTT: et = etOpenButt; break;
		case END_SQUARE: et = etOpenSquare; break;
		case END_ROUND: et = etOpenRound; break;
	}
	ClipperOffset co;
	Path path;

	// Need to scale points (Clipper's requirement for robust computation)
	for (int i = 0; i != p_polypath.size(); ++i) {
		path << IntPoint(p_polypath[i].x * SCALE_FACTOR, p_polypath[i].y * SCALE_FACTOR);
	}
	co.AddPath(path, jt, et);

	Paths paths;
	co.Execute(paths, p_delta * SCALE_FACTOR); // inflate/deflate

	// Have to scale points down now
	Vector<Vector<Point2> > polypaths;

	for (Paths::size_type i = 0; i < paths.size(); ++i) {
		Vector<Vector2> polypath;

		const Path &scaled_path = paths[i];

		for (Paths::size_type j = 0; j < scaled_path.size(); ++j) {
			polypath.push_back(Point2(
					static_cast<real_t>(scaled_path[j].X) / SCALE_FACTOR,
					static_cast<real_t>(scaled_path[j].Y) / SCALE_FACTOR));
		}
		polypaths.push_back(polypath);
	}
	return polypaths;
}
예제 #25
0
static VALUE
rbclipper_add_polygons_internal(VALUE self, VALUE polygonsValue, PolyType polytype) {
  double multiplier = NUM2DBL(rb_iv_get(self, "@multiplier"));
  Paths polygons;
  for(long i = 0; i != RARRAY_LEN(polygonsValue); i++) {
    VALUE sub = rb_ary_entry(polygonsValue, i);
    Check_Type(sub, T_ARRAY);

    ClipperLib::Path tmp;
    ary_to_polygon(sub, &tmp, multiplier);
    polygons.push_back(tmp);
  }
  XCLIPPER(self)->AddPaths(polygons, polytype, true);
  return Qnil;
}
예제 #26
0
//---------------------------------------------------------------------------------------
void BooksDlg::OnLinkClicked(wxHtmlLinkEvent& event)
{
    const wxHtmlLinkInfo& link = event.GetLinkInfo();
    wxString sLocation = link.GetHref();

    //study guide
    if (sLocation == "lenmus#study-guide")
    {
        HelpSystem* pHelp = m_appScope.get_help_controller();
        pHelp->display_section(10101);    //study-guide
        //show_html_document("study-guide.htm");
        return;
    }

    //verify if it is a LenMus command link
    int iPos = sLocation.Find("lenmus#");
    if (iPos == wxNOT_FOUND)
    {
        // external link
        ::wxLaunchDefaultBrowser(sLocation);
    }
    else
    {
        wxString filename = sLocation.substr(12);
        Paths* pPaths = m_appScope.get_paths();
        wxString sPath = pPaths->GetBooksPath();
        wxFileName oFile(sPath, filename, wxPATH_NATIVE);
        if (!oFile.FileExists())
        {
            //try to use the english version
            sPath = pPaths->GetLocaleRootPath();
            oFile.AssignDir(sPath);
            oFile.AppendDir("en");
            oFile.AppendDir("books");
            oFile.SetFullName(filename);
            if (!oFile.FileExists())
            {
                wxMessageBox(_("Sorry: File not found!"));
                LOMSE_LOG_WARN(str(boost::format("File '%s' not found!")
                               % oFile.GetFullPath().wx_str() ));
                return;
            }
        }

        m_fullName = oFile.GetFullPath();
        EndModal(wxID_OK);
    }
}
예제 #27
0
void TerraGenerator::populateMesh(Paths& paths, const RegionContext& regionContext)
{
    ClipperLib::SimplifyPolygons(paths);
    ClipperLib::CleanPolygons(paths);

    bool hasHeightOffset = std::abs(regionContext.options.heightOffset) > 1E-8;
    // calculate approximate size of overall points
    std::size_t size = 0;
    for (auto i = 0; i < paths.size(); ++i)
        size += static_cast<std::size_t>(paths[i].size() * 1.5);

    Polygon polygon(size);
    for (const Path& path : paths) {
        double area = ClipperLib::Area(path);
        bool isHole = area < 0;
        if (std::abs(area) < AreaTolerance)
            continue;

        backGroundClipper_.AddPath(path, ptClip, true);

        Points points = restorePoints(path);
        if (isHole)
            polygon.addHole(points);
        else
            polygon.addContour(points);

        if (hasHeightOffset)
            processHeightOffset(points, regionContext);
    }

    if (!polygon.points.empty())
        fillMesh(polygon, regionContext);
}
예제 #28
0
파일: PathOverlap.cpp 프로젝트: bcgsc/abyss
/** Index the first and last contig of each path to facilitate finding
 * overlaps between paths. */
static SeedMap makeSeedMap(const Paths& paths)
{
	SeedMap seedMap;
	for (Paths::const_iterator it = paths.begin();
			it != paths.end(); ++it) {
		if (it->empty())
			continue;
		assert(!it->front().ambiguous());
		seedMap.insert(make_pair(it->front(),
					Vertex(it - paths.begin(), false)));
		assert(!it->back().ambiguous());
		seedMap.insert(make_pair(it->back() ^ 1,
					Vertex(it - paths.begin(), true)));
	}
	return seedMap;
}
예제 #29
0
int SHAPE_POLY_SET::AddOutline( const SHAPE_LINE_CHAIN& aOutline )
{
    assert ( aOutline.IsClosed() );

    Path p = convert ( aOutline );
    Paths poly;

    if( !Orientation( p ) )
        ReversePath(p); // outlines are always CW

    poly.push_back( p );

    m_polys.push_back( poly );

    return m_polys.size() - 1;
}
예제 #30
0
파일: pcircle.cpp 프로젝트: nphuc/alg
int main() {
    n=8;
    create();
    //GP();
    Paths res;
    Path p;
    unsigned long c=0;
    for(int i=2; i<=2*n; ++i) {
        if(i%2==0) {
            res=all(1,i,p,1);
            c+=res.size();
            PSP(res);
        }
    }
    printf("%lu",c);

}